forked from umpc/go-sortedmap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
has_test.go
51 lines (42 loc) · 868 Bytes
/
has_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
50
51
package sortedmap
import "testing"
func TestHas(t *testing.T) {
sm, records, err := newSortedMapFromRandRecords(3)
if err != nil {
t.Fatal(err)
}
for i := range records {
if !sm.Has(records[i].Key) {
t.Fatalf("TestHas failed: %v", notFoundErr)
}
}
iterCh, err := sm.IterCh()
if err != nil {
t.Fatal(err)
} else {
defer iterCh.Close()
if err := verifyRecords(iterCh.Records(), false); err != nil {
t.Fatal(err)
}
}
}
func TestBatchHas(t *testing.T) {
sm, _, keys, err := newRandSortedMapWithKeys(1000)
if err != nil {
t.Fatal(err)
}
for _, ok := range sm.BatchHas(keys) {
if !ok {
t.Fatalf("TestBatchHas failed: %v", notFoundErr)
}
}
iterCh, err := sm.IterCh()
if err != nil {
t.Fatal(err)
} else {
defer iterCh.Close()
if err := verifyRecords(iterCh.Records(), false); err != nil {
t.Fatal(err)
}
}
}