diff --git a/pkg/structure/hashx/hashx_test.go b/pkg/structure/hashx/hashx_test.go index 8aa5eac..5913b13 100644 --- a/pkg/structure/hashx/hashx_test.go +++ b/pkg/structure/hashx/hashx_test.go @@ -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) +}