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

Function TestListStructure_LRange

structure/list_test.go:169–191  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

167}
168
169func TestListStructure_LRange(t *testing.T) {
170 list, _ := initList()
171 defer list.db.Clean()
172
173 // Test LRange function when the key exists
174 listErr = list.LPush(string(randkv.GetTestKey(1)), randkv.RandomValue(100), 0)
175 assert.Nil(t, listErr)
176 values, err := list.LRange(string(randkv.GetTestKey(1)), 0, 1)
177 assert.Nil(t, err)
178 assert.NotNil(t, values)
179
180 // Test LRange function when the key does not exist
181 _, err = list.LRange(string(randkv.GetTestKey(2)), 0, 1)
182 assert.Equal(t, err, _const.ErrKeyNotFound)
183
184 // Test LRange function when the list is empty
185 err = list.LPush(string(randkv.GetTestKey(3)), randkv.RandomValue(100), 0)
186 assert.Nil(t, err)
187 _, err = list.LPop(string(randkv.GetTestKey(3)))
188 assert.Nil(t, err)
189 _, err = list.LRange(string(randkv.GetTestKey(3)), 0, 1)
190 assert.Equal(t, err, ErrListEmpty)
191}
192
193func TestListStructure_LLen(t *testing.T) {
194 list, _ := initList()

Callers

nothing calls this directly

Calls 7

GetTestKeyFunction · 0.92
RandomValueFunction · 0.92
initListFunction · 0.85
LPushMethod · 0.65
LRangeMethod · 0.65
LPopMethod · 0.65
CleanMethod · 0.45

Tested by

no test coverage detected