mirror of
https://github.com/HDT3213/godis.git
synced 2025-10-08 10:10:30 +08:00
Add sscan, hscan, zscan
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package set
|
||||
|
||||
import (
|
||||
"github.com/hdt3213/godis/lib/utils"
|
||||
"strconv"
|
||||
"testing"
|
||||
)
|
||||
@@ -30,3 +31,30 @@ func TestSet(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetScan(t *testing.T) {
|
||||
set := Make()
|
||||
size := 10
|
||||
for i := 0; i < size; i++ {
|
||||
str := "a" + utils.RandString(5)
|
||||
set.Add(str)
|
||||
}
|
||||
keys, nextCursor := set.SetScan(0, size, "*")
|
||||
if len(keys) != size {
|
||||
t.Errorf("expect %d keys, actual: %d", size, 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)
|
||||
set.Add(str)
|
||||
}
|
||||
keys, _ = set.SetScan(0, size*2, "a*")
|
||||
if len(keys) != size {
|
||||
t.Errorf("expect %d keys, actual: %d", size, len(keys))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user