MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / TestSortedSet

Function TestSortedSet

IceFireDB-Redis-Proxy/test/cmd_sorted_set_test.go:31–175  ·  view source on GitHub ↗

Test ZADD / ZCARD / ZRANK / ZREVRANK.

(t *testing.T)

Source from the content-addressed store, hash-verified

29
30// Test ZADD / ZCARD / ZRANK / ZREVRANK.
31func TestSortedSet(t *testing.T) {
32 server.Clear()
33 c, err := proto.Dial(server.Addr())
34 ok(t, err)
35 defer c.Close()
36 s := server.Direct()
37
38 {
39 mustDo(t, c,
40 "ZADD", "z", "1", "one", "2", "two", "3", "three",
41 proto.Int(3),
42 )
43
44 mustDo(t, c,
45 "ZCARD", "z",
46 proto.Int(3),
47 )
48
49 must0(t, c,
50 "ZRANK", "z", "one",
51 )
52 mustDo(t, c,
53 "ZRANK", "z", "three",
54 proto.Int(2),
55 )
56
57 mustDo(t, c,
58 "ZREVRANK", "z", "one",
59 proto.Int(2),
60 )
61 must0(t, c,
62 "ZREVRANK", "z", "three",
63 )
64 }
65
66 // TYPE of our zset
67 mustDo(t, c,
68 "TYPE", "z",
69 proto.Inline("zset"),
70 )
71
72 // Replace a key
73 {
74 must0(t, c,
75 "ZADD", "z", "2.1", "two",
76 )
77
78 mustDo(t, c,
79 "ZCARD", "z",
80 proto.Int(3),
81 )
82 }
83
84 // To infinity!
85 {
86 mustDo(t, c,
87 "ZADD", "zinf", "inf", "plus inf", "-inf", "minus inf", "10", "ten",
88 proto.Int(3),

Callers

nothing calls this directly

Calls 15

ClearFunction · 0.92
DialFunction · 0.92
AddrFunction · 0.92
DirectFunction · 0.92
IntFunction · 0.92
InlineFunction · 0.92
ErrorFunction · 0.92
okFunction · 0.70
mustDoFunction · 0.70
must0Function · 0.70
equalsFunction · 0.70
mustNilFunction · 0.70

Tested by

no test coverage detected