forked from p53841790/wheat-cache
test(structure-hashx): add hashx range test
This commit is contained in:
parent
594f8acf32
commit
60cf8f5eb1
|
@ -3,6 +3,7 @@ package hashx
|
|||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"testing"
|
||||
"unsafe"
|
||||
|
||||
|
@ -87,3 +88,26 @@ func string2bytes(s string) []byte {
|
|||
}
|
||||
return *(*[]byte)(unsafe.Pointer(&result))
|
||||
}
|
||||
|
||||
func TestHashX_Range(t *testing.T) {
|
||||
|
||||
reComp := regexp.MustCompile("a.+")
|
||||
require.True(t, reComp.MatchString("abbs"))
|
||||
|
||||
h := NewHashXSingle()
|
||||
h.Set("abbs", "abbs")
|
||||
h.Set("ppp", "ppp")
|
||||
h.Set("accs", "accs")
|
||||
|
||||
result := h.Range(0, 3, "")
|
||||
require.Len(t, result, 3)
|
||||
|
||||
result = h.Range(0, -1, "")
|
||||
require.Len(t, result, 3)
|
||||
|
||||
result = h.Range(0, -1, "a.+")
|
||||
require.Len(t, result, 2)
|
||||
|
||||
result = h.Range(1, -1, "a.+")
|
||||
require.Len(t, result, 1)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue