mirror of
https://github.com/HDT3213/godis.git
synced 2025-10-21 15:59:26 +08:00
Add sscan, hscan, zscan
This commit is contained in:
@@ -53,3 +53,30 @@ func TestSimpleDict_PutIfExists(t *testing.T) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func TestSimpleDict_Scan(t *testing.T) {
|
||||
d := MakeSimple()
|
||||
size := 10
|
||||
for i := 0; i < size; i++ {
|
||||
str := "a" + utils.RandString(5)
|
||||
d.Put(str, []byte(str))
|
||||
}
|
||||
keys, nextCursor := d.DictScan(0, size, "*")
|
||||
if len(keys) != size*2 {
|
||||
t.Errorf("expect %d keys, actual: %d", size*2, len(keys))
|
||||
return
|
||||
}
|
||||
if nextCursor != 0 {
|
||||
t.Errorf("expect 0, actual: %d", nextCursor)
|
||||
return
|
||||
}
|
||||
for i := 0; i < size; i++ {
|
||||
str := "b" + utils.RandString(5)
|
||||
d.Put(str, str)
|
||||
}
|
||||
keys, _ = d.DictScan(0, size*2, "a*")
|
||||
if len(keys) != size*2 {
|
||||
t.Errorf("expect %d keys, actual: %d", size*2, len(keys))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user