MCPcopy
hub / github.com/openacid/slim / TestBaseInitIndex

Function TestBaseInitIndex

array/base_test.go:41–113  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

39}
40
41func TestBaseInitIndex(t *testing.T) {
42
43 cases := []struct {
44 input []int32
45 wantCnt int32
46 wantBitmaps []uint64
47 wantOffsets []int32
48 wanterr error
49 }{
50 {
51 []int32{},
52 0,
53 []uint64{},
54 []int32{},
55 nil,
56 },
57 {
58 []int32{0},
59 1,
60 []uint64{1},
61 []int32{0},
62 nil,
63 },
64 {
65 []int32{1, 0},
66 0,
67 []uint64{},
68 []int32{},
69 array.ErrIndexNotAscending,
70 },
71 {
72 []int32{1, 3},
73 2,
74 []uint64{0x0a},
75 []int32{0},
76 nil,
77 },
78 {
79 []int32{1, 65},
80 2,
81 []uint64{0x02, 0x02},
82 []int32{0, 1},
83 nil,
84 },
85 }
86
87 for i, c := range cases {
88 ab := &array.Base{}
89 err := ab.InitIndex(c.input)
90
91 if errors.Cause(err) != c.wanterr {
92 t.Fatalf("expect error: %v but: %v", c.wanterr, err)
93 }
94
95 if err == nil {
96
97 if c.wantCnt != ab.Cnt {
98 t.Fatalf("%d-th: input: %v; want: %v; actual: %v",

Callers

nothing calls this directly

Calls 1

InitIndexMethod · 0.95

Tested by

no test coverage detected