Comparison

spec/util_iterators_spec.lua @ 9328:a9592107021b

util.iterators tests: Check value matches expected [luacheck]
author Matthew Wild <mwild1@gmail.com>
date Fri, 21 Sep 2018 14:30:20 +0100
parent 9327:f6f1dec164b5
child 12744:e894677359e5
comparison
equal deleted inserted replaced
9327:f6f1dec164b5 9328:a9592107021b
19 for k, v in iter.sorted_pairs(orig) do 19 for k, v in iter.sorted_pairs(orig) do
20 n = n + 1; 20 n = n + 1;
21 if last_key then 21 if last_key then
22 assert(k > last_key, "Expected "..k.." > "..last_key) 22 assert(k > last_key, "Expected "..k.." > "..last_key)
23 end 23 end
24 assert.equal(orig[k], v);
24 last_key = k; 25 last_key = k;
25 end 26 end
26 assert.equal("d", last_key); 27 assert.equal("d", last_key);
27 assert.equal(4, n); 28 assert.equal(4, n);
28 end); 29 end);
33 for k, v in iter.sorted_pairs(orig, function (a, b) return a > b end) do 34 for k, v in iter.sorted_pairs(orig, function (a, b) return a > b end) do
34 n = n + 1; 35 n = n + 1;
35 if last_key then 36 if last_key then
36 assert(k < last_key, "Expected "..k.." > "..last_key) 37 assert(k < last_key, "Expected "..k.." > "..last_key)
37 end 38 end
39 assert.equal(orig[k], v);
38 last_key = k; 40 last_key = k;
39 end 41 end
40 assert.equal("a", last_key); 42 assert.equal("a", last_key);
41 assert.equal(4, n); 43 assert.equal(4, n);
42 end); 44 end);