-
Notifications
You must be signed in to change notification settings - Fork 8
/
get_test.go
52 lines (43 loc) · 945 Bytes
/
get_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
52
package sortedmap
import "testing"
func TestGet(t *testing.T) {
sm, records, err := newSortedMapFromRandRecords(3)
if err != nil {
t.Fatal(err)
}
for i := range records {
if val, ok := sm.Get(records[i].Key); val == nil || !ok {
t.Fatalf("TestGet 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 TestBatchGet(t *testing.T) {
sm, _, keys, err := newRandSortedMapWithKeys(1000)
if err != nil {
t.Fatal(err)
}
values, results := sm.BatchGet(keys)
for i, ok := range results {
if values[i] == nil || !ok {
t.Fatalf("TestBatchGet 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)
}
}
}