-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathinsert_test.go
44 lines (37 loc) · 859 Bytes
/
insert_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
package sortedmap
import (
"testing"
"github.com/umpc/go-sortedmap/asc"
)
func TestInsert(t *testing.T) {
records := randRecords(3)
sm := New(asc.Time)
for i := range records {
if !sm.Insert(records[i].Key, records[i].Val) {
t.Fatalf("Insert failed: %v", keyExistsErr)
}
}
if err := verifyRecords(sm.IterCh(), false); err != nil {
t.Fatal(err)
}
for i := range records {
if sm.Insert(records[i].Key, records[i].Val) {
t.Fatalf("Insert failed: %v", notFoundErr)
}
}
if err := verifyRecords(sm.IterCh(), false); err != nil {
t.Fatal(err)
}
}
func TestBatchInsert(t *testing.T) {
records := randRecords(1000)
sm := New(asc.Time)
for _, ok := range sm.BatchInsert(records) {
if !ok {
t.Fatalf("BatchInsert failed: %v", keyExistsErr)
}
}
if err := verifyRecords(sm.IterCh(), false); err != nil {
t.Fatal(err)
}
}