Comparison

tests/test_util_cache.lua @ 7961:ff556d010225

tests: Trim trailing whitespace
author Kim Alvefur <zash@zash.se>
date Mon, 06 Mar 2017 16:01:27 +0100
parent 7504:b43cbbbb806f
comparison
equal deleted inserted replaced
7960:9a938b785bc5 7961:ff556d010225
8 8
9 expect_kv(nil, nil, c:head()); 9 expect_kv(nil, nil, c:head());
10 expect_kv(nil, nil, c:tail()); 10 expect_kv(nil, nil, c:tail());
11 11
12 assert_equal(c:count(), 0); 12 assert_equal(c:count(), 0);
13 13
14 c:set("one", 1) 14 c:set("one", 1)
15 assert_equal(c:count(), 1); 15 assert_equal(c:count(), 1);
16 expect_kv("one", 1, c:head()); 16 expect_kv("one", 1, c:head());
17 expect_kv("one", 1, c:tail()); 17 expect_kv("one", 1, c:tail());
18 18
27 c:set("four", 4) 27 c:set("four", 4)
28 c:set("five", 5); 28 c:set("five", 5);
29 assert_equal(c:count(), 5); 29 assert_equal(c:count(), 5);
30 expect_kv("five", 5, c:head()); 30 expect_kv("five", 5, c:head());
31 expect_kv("one", 1, c:tail()); 31 expect_kv("one", 1, c:tail());
32 32
33 c:set("foo", nil); 33 c:set("foo", nil);
34 assert_equal(c:count(), 5); 34 assert_equal(c:count(), 5);
35 expect_kv("five", 5, c:head()); 35 expect_kv("five", 5, c:head());
36 expect_kv("one", 1, c:tail()); 36 expect_kv("one", 1, c:tail());
37 37
38 assert_equal(c:get("one"), 1); 38 assert_equal(c:get("one"), 1);
39 expect_kv("five", 5, c:head()); 39 expect_kv("five", 5, c:head());
40 expect_kv("one", 1, c:tail()); 40 expect_kv("one", 1, c:tail());
41 41
42 assert_equal(c:get("two"), 2); 42 assert_equal(c:get("two"), 2);
44 assert_equal(c:get("four"), 4); 44 assert_equal(c:get("four"), 4);
45 assert_equal(c:get("five"), 5); 45 assert_equal(c:get("five"), 5);
46 46
47 assert_equal(c:get("foo"), nil); 47 assert_equal(c:get("foo"), nil);
48 assert_equal(c:get("bar"), nil); 48 assert_equal(c:get("bar"), nil);
49 49
50 c:set("six", 6); 50 c:set("six", 6);
51 assert_equal(c:count(), 5); 51 assert_equal(c:count(), 5);
52 expect_kv("six", 6, c:head()); 52 expect_kv("six", 6, c:head());
53 expect_kv("two", 2, c:tail()); 53 expect_kv("two", 2, c:tail());
54 54
55 assert_equal(c:get("one"), nil); 55 assert_equal(c:get("one"), nil);
56 assert_equal(c:get("two"), 2); 56 assert_equal(c:get("two"), 2);
57 assert_equal(c:get("three"), 3); 57 assert_equal(c:get("three"), 3);
58 assert_equal(c:get("four"), 4); 58 assert_equal(c:get("four"), 4);
59 assert_equal(c:get("five"), 5); 59 assert_equal(c:get("five"), 5);
60 assert_equal(c:get("six"), 6); 60 assert_equal(c:get("six"), 6);
61 61
62 c:set("three", nil); 62 c:set("three", nil);
63 assert_equal(c:count(), 4); 63 assert_equal(c:count(), 4);
64 64
65 assert_equal(c:get("one"), nil); 65 assert_equal(c:get("one"), nil);
66 assert_equal(c:get("two"), 2); 66 assert_equal(c:get("two"), 2);
67 assert_equal(c:get("three"), nil); 67 assert_equal(c:get("three"), nil);
68 assert_equal(c:get("four"), 4); 68 assert_equal(c:get("four"), 4);
69 assert_equal(c:get("five"), 5); 69 assert_equal(c:get("five"), 5);
70 assert_equal(c:get("six"), 6); 70 assert_equal(c:get("six"), 6);
71 71
72 c:set("seven", 7); 72 c:set("seven", 7);
73 assert_equal(c:count(), 5); 73 assert_equal(c:count(), 5);
74 74
75 assert_equal(c:get("one"), nil); 75 assert_equal(c:get("one"), nil);
76 assert_equal(c:get("two"), 2); 76 assert_equal(c:get("two"), 2);
77 assert_equal(c:get("three"), nil); 77 assert_equal(c:get("three"), nil);
78 assert_equal(c:get("four"), 4); 78 assert_equal(c:get("four"), 4);
79 assert_equal(c:get("five"), 5); 79 assert_equal(c:get("five"), 5);
80 assert_equal(c:get("six"), 6); 80 assert_equal(c:get("six"), 6);
81 assert_equal(c:get("seven"), 7); 81 assert_equal(c:get("seven"), 7);
82 82
83 c:set("eight", 8); 83 c:set("eight", 8);
84 assert_equal(c:count(), 5); 84 assert_equal(c:count(), 5);
85 85
86 assert_equal(c:get("one"), nil); 86 assert_equal(c:get("one"), nil);
87 assert_equal(c:get("two"), nil); 87 assert_equal(c:get("two"), nil);
88 assert_equal(c:get("three"), nil); 88 assert_equal(c:get("three"), nil);
89 assert_equal(c:get("four"), 4); 89 assert_equal(c:get("four"), 4);
90 assert_equal(c:get("five"), 5); 90 assert_equal(c:get("five"), 5);
91 assert_equal(c:get("six"), 6); 91 assert_equal(c:get("six"), 6);
92 assert_equal(c:get("seven"), 7); 92 assert_equal(c:get("seven"), 7);
93 assert_equal(c:get("eight"), 8); 93 assert_equal(c:get("eight"), 8);
94 94
95 c:set("four", 4); 95 c:set("four", 4);
96 assert_equal(c:count(), 5); 96 assert_equal(c:count(), 5);
97 97
98 assert_equal(c:get("one"), nil); 98 assert_equal(c:get("one"), nil);
99 assert_equal(c:get("two"), nil); 99 assert_equal(c:get("two"), nil);
100 assert_equal(c:get("three"), nil); 100 assert_equal(c:get("three"), nil);
101 assert_equal(c:get("four"), 4); 101 assert_equal(c:get("four"), 4);
102 assert_equal(c:get("five"), 5); 102 assert_equal(c:get("five"), 5);
103 assert_equal(c:get("six"), 6); 103 assert_equal(c:get("six"), 6);
104 assert_equal(c:get("seven"), 7); 104 assert_equal(c:get("seven"), 7);
105 assert_equal(c:get("eight"), 8); 105 assert_equal(c:get("eight"), 8);
106 106
107 c:set("nine", 9); 107 c:set("nine", 9);
108 assert_equal(c:count(), 5); 108 assert_equal(c:count(), 5);
109 109
110 assert_equal(c:get("one"), nil); 110 assert_equal(c:get("one"), nil);
111 assert_equal(c:get("two"), nil); 111 assert_equal(c:get("two"), nil);
112 assert_equal(c:get("three"), nil); 112 assert_equal(c:get("three"), nil);
113 assert_equal(c:get("four"), 4); 113 assert_equal(c:get("four"), 4);
114 assert_equal(c:get("five"), nil); 114 assert_equal(c:get("five"), nil);
266 assert_equal(c3:count(), 1); 266 assert_equal(c3:count(), 1);
267 end 267 end
268 268
269 269
270 local c4 = new(3, false); 270 local c4 = new(3, false);
271 271
272 assert_equal(c4:set("a", 1), true); 272 assert_equal(c4:set("a", 1), true);
273 assert_equal(c4:set("a", 1), true); 273 assert_equal(c4:set("a", 1), true);
274 assert_equal(c4:set("a", 1), true); 274 assert_equal(c4:set("a", 1), true);
275 assert_equal(c4:set("a", 1), true); 275 assert_equal(c4:set("a", 1), true);
276 assert_equal(c4:set("b", 2), true); 276 assert_equal(c4:set("b", 2), true);
288 elseif k == "b" then 288 elseif k == "b" then
289 return true; 289 return true;
290 end 290 end
291 return false; 291 return false;
292 end); 292 end);
293 293
294 assert_equal(c5:set("a", 1), true); 294 assert_equal(c5:set("a", 1), true);
295 assert_equal(c5:set("a", 1), true); 295 assert_equal(c5:set("a", 1), true);
296 assert_equal(c5:set("a", 1), true); 296 assert_equal(c5:set("a", 1), true);
297 assert_equal(c5:set("a", 1), true); 297 assert_equal(c5:set("a", 1), true);
298 assert_equal(c5:set("b", 2), true); 298 assert_equal(c5:set("b", 2), true);