-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtests.js
More file actions
37 lines (31 loc) · 741 Bytes
/
tests.js
File metadata and controls
37 lines (31 loc) · 741 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
var tests = {
test1: function () {
var kv = new keyval();
// Set some key value pairs.
for (var i = 1; i <= 100; i++) {
kv.set(i.toString(), i);
}
// Delete half of the key value pairs.
for (i = 1; i <= 100; i++) {
if (i % 2 === 0) {
kv.del(i.toString());
}
}
// Iterate over the key value pairs.
var tmp, cnt = 0;
kv.rwd(); while (tmp = kv.itr()) cnt++;
// Test if the above actions resulted to -
// the expected results.
if ((cnt === 50 &&
kv.len === 50 &&
kv.get("49").n.v === 51 &&
kv.get("49").p.v === 47) === false)
return false;
// Test delete head.
var foo;
while (--i > 0) {
foo = kv.del(i.toString());
}
if (foo === 1) return true; else return false;
}
}