mirror of
https://github.com/HDT3213/godis.git
synced 2025-10-05 16:57:06 +08:00
Add sscan, hscan, zscan
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
package sortedset
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/hdt3213/godis/lib/utils"
|
||||
)
|
||||
|
||||
func TestSortedSet_PopMin(t *testing.T) {
|
||||
var set = Make()
|
||||
@@ -14,3 +18,30 @@ func TestSortedSet_PopMin(t *testing.T) {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetScan(t *testing.T) {
|
||||
set := Make()
|
||||
size := 10
|
||||
for i := 0; i < size; i++ {
|
||||
str := "a" + utils.RandString(5)
|
||||
set.Add(str, float64(i))
|
||||
}
|
||||
keys, nextCursor := set.ZSetScan(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)
|
||||
set.Add(str, float64(i+size))
|
||||
}
|
||||
keys, _ = set.ZSetScan(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