MCPcopy Index your code
hub / github.com/ByteStorage/FlyDB / TestSortedSet

Function TestSortedSet

structure/zset_test.go:21–63  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

19}
20
21func TestSortedSet(t *testing.T) {
22 type test struct {
23 name string
24 input map[string]int
25 want *FZSet
26 expectError bool
27 }
28
29 zs := newZSetNodes()
30 err := zs.InsertNode(3, "banana", "hello")
31 err = zs.InsertNode(1, "apple", "hello")
32 err = zs.InsertNode(2, "pear", "hello")
33 err = zs.InsertNode(44, "orange", "hello")
34 err = zs.InsertNode(9, "strawberry", "delish")
35 err = zs.InsertNode(15, "dragon-fruit", "nonDelish")
36 b, err := zs.Bytes()
37
38 fromBytes := newZSetNodes()
39 err = fromBytes.FromBytes(b)
40 assert.NoError(t, err)
41 assert.NotNil(t, fromBytes.skipList)
42 assert.Equal(t, fromBytes.size, zs.size)
43 tests := []test{
44 {
45 name: "empty",
46 input: map[string]int{},
47 want: &FZSet{},
48 expectError: false,
49 },
50 {
51 name: "three fruits",
52 input: map[string]int{"banana": 3, "apple": 2, "pear": 4, "peach": 40},
53 want: nil,
54 },
55 }
56
57 for _, tt := range tests {
58 t.Run(tt.name, func(t *testing.T) {
59 assert.ElementsMatch(t, tt.want, nil)
60 })
61 }
62
63}
64
65func TestSortedSet_Bytes(t *testing.T) {
66

Callers

nothing calls this directly

Calls 4

newZSetNodesFunction · 0.85
InsertNodeMethod · 0.80
FromBytesMethod · 0.80
BytesMethod · 0.45

Tested by

no test coverage detected