-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.odin
More file actions
60 lines (47 loc) · 1.41 KB
/
Copy pathtest.odin
File metadata and controls
60 lines (47 loc) · 1.41 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package small_map
import "core:fmt"
import "core:testing"
@(test)
test_iterator :: proc(t: ^testing.T) {
sm: Small_Map(int, int, 128)
testing.expect(t, small_map_insert(&sm, 0, 5))
testing.expect(t, small_map_insert(&sm, 1, 2))
testing.expect(t, small_map_insert(&sm, 2, 3))
testing.expect(t, small_map_insert(&sm, 69, 420))
found: int
iter: Small_Map_Iterator
for k, v in small_map_iter(&sm, &iter) {
switch k {
case 0:
testing.expect(t, v^ == 5)
case 1:
testing.expect(t, v^ == 2)
case 2:
testing.expect(t, v^ == 3)
case 69:
testing.expect(t, v^ == 420)
case:
testing.fail(t)
}
found += 1
}
testing.expect(t, found == 4)
}
@(test)
test_small_map :: proc(t: ^testing.T) {
sm: Small_Map(int, int, 128)
testing.expect(t, small_map_insert(&sm, 0, 5))
testing.expect(t, small_map_insert(&sm, 1, 2))
testing.expect(t, small_map_insert(&sm, 2, 3))
testing.expect(t, small_map_insert(&sm, 69, 420))
testing.expect(t, small_map_get(&sm, 0)^ == 5)
testing.expect(t, small_map_get(&sm, 1)^ == 2)
testing.expect(t, small_map_get(&sm, 2)^ == 3)
testing.expect(t, small_map_get(&sm, 69)^ == 420)
testing.expect(t, small_map_remove(&sm, 0))
testing.expect(t, small_map_get(&sm, 0) == nil)
testing.expect(t, small_map_insert(&sm, 0, 123))
testing.expect(t, small_map_get(&sm, 0)^ == 123)
testing.expect(t, small_map_insert(&sm, 0, 69))
testing.expect(t, small_map_get(&sm, 0)^ == 69)
}