This commit is contained in:
Kovid Goyal
2024-02-02 06:53:10 +05:30
parent 57f4ea4d4a
commit d9190ea675

View File

@@ -90,7 +90,7 @@ func broadcast_byte(b byte, size int) []byte {
return bytes.Repeat([]byte{b}, size) return bytes.Repeat([]byte{b}, size)
} }
func TestSIMDStringOps(t *testing.T) { func get_sizes(t *testing.T) []int {
sizes := []int{} sizes := []int{}
if Have128bit { if Have128bit {
sizes = append(sizes, 16) sizes = append(sizes, 16)
@@ -102,6 +102,11 @@ func TestSIMDStringOps(t *testing.T) {
if len(sizes) == 0 { if len(sizes) == 0 {
t.Skip("skipping as no SIMD available at runtime") t.Skip("skipping as no SIMD available at runtime")
} }
return sizes
}
func TestSIMDStringOps(t *testing.T) {
sizes := get_sizes(t)
test := func(haystack []byte, a, b byte) { test := func(haystack []byte, a, b byte) {
var actual int var actual int
safe_haystack := append(bytes.Repeat([]byte{'<'}, 64), haystack...) safe_haystack := append(bytes.Repeat([]byte{'<'}, 64), haystack...)
@@ -199,11 +204,11 @@ func TestSIMDStringOps(t *testing.T) {
} }
} }
c0tests("a\nfgdfgd\r")
c0tests("") c0tests("")
c0tests("abcdef") c0tests("abcdef")
c0tests("afsgdfg\x7f") c0tests("afsgdfg\x7f")
c0tests("a\nfgdfgd\r") c0tests("afgd\x1bfgd\t")
c0tests("afgd\rfgd\t")
c0tests("a\x00") c0tests("a\x00")
} }
@@ -301,17 +306,7 @@ func TestIntrinsics(t *testing.T) {
} }
}) })
sizes := []int{} sizes := get_sizes(t)
if Have128bit {
sizes = append(sizes, 16)
}
if Have256bit {
sizes = append(sizes, 32)
}
if len(sizes) == 0 {
t.Skip("skipping as no SIMD available at runtime")
}
for _, sz := range sizes { for _, sz := range sizes {
for _, test := range tests { for _, test := range tests {
test(sz) test(sz)