MCPcopy Create free account
hub / github.com/ByteStorage/FlyDB / TestZset_getNodeByRank

Function TestZset_getNodeByRank

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

Source from the content-addressed store, hash-verified

932}
933
934func TestZset_getNodeByRank(t *testing.T) {
935 sl := newSkipList()
936 sl.insert(1, "mem1", "")
937 sl.insert(2, "mem2", "")
938 sl.insert(3, "mem3", "")
939 tests := []struct {
940 name string
941 rank int
942 want *ZSetValue // Expected Output, use your actual SkipListNode instance or null here
943 }{
944 {
945 name: "Case 1: Get Node by Rank 1",
946 rank: 1,
947 want: &ZSetValue{score: 1, member: "mem1", value: ""},
948 },
949 {
950 name: "Case 2: Get Node by Rank 2",
951 rank: 2,
952 want: &ZSetValue{score: 2, member: "mem2", value: ""},
953 },
954 {
955 name: "Case 3: Get Node by Non-existed Rank",
956 rank: 9999,
957 want: nil, // should return nil if rank doesn't exist
958 },
959 }
960
961 // Iterate over test cases
962 for _, tt := range tests {
963 t.Run(tt.name, func(t *testing.T) {
964 got := sl.getNodeByRank(tt.rank)
965 if tt.want == nil {
966 assert.Nil(t, got)
967
968 } else {
969 assert.Equal(t, tt.want, got.value)
970 }
971 })
972 }
973}
974func Test_exists(t *testing.T) {
975 zs, _ := initZSetDB()
976

Callers

nothing calls this directly

Calls 3

newSkipListFunction · 0.85
insertMethod · 0.80
getNodeByRankMethod · 0.80

Tested by

no test coverage detected