forked from monochromegane/gannoy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
maps_test.go
49 lines (41 loc) · 1001 Bytes
/
maps_test.go
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
package gannoy
import "testing"
func TestMapsGetIdNotFound(t *testing.T) {
maps := newMaps()
id, err := maps.getId(0)
if id != -1 {
t.Errorf("Maps getId when not found should return -1, but %d.", id)
}
if err == nil {
t.Errorf("Maps getId when not found should return error.")
}
}
func TestMapsGetId(t *testing.T) {
maps := newMaps()
maps.add(1, 10)
id, err := maps.getId(10)
if id != 1 {
t.Errorf("Maps getId should return 1, but %d.", id)
}
if err != nil {
t.Errorf("Maps getId should not return error.")
}
maps.remove(10)
id, err = maps.getId(10)
if id != -1 {
t.Errorf("Maps getId when not found should return -1, but %d.", id)
}
if err == nil {
t.Errorf("Maps getId when not found should return error.")
}
}
func TestMapsIsExist(t *testing.T) {
maps := newMaps()
if maps.isExist(10) {
t.Errorf("Maps isExist when not exist should return false.")
}
maps.add(1, 10)
if !maps.isExist(10) {
t.Errorf("Maps isExist when exist should return true.")
}
}