mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-19 23:14:55 +02:00
Add not_index_byte and not_index_byte2 functions to simdstring package
Fixes #9646
This commit is contained in:
committed by
Kovid Goyal
parent
d8af7e2c88
commit
f4bf9cf1c9
@@ -244,6 +244,65 @@ func TestSIMDStringOps(t *testing.T) {
|
||||
index_test([]byte("abc"), 'x')
|
||||
index_test([]byte("abc"), 'b')
|
||||
|
||||
not_index_test := func(haystack []byte, needle byte) {
|
||||
var actual int
|
||||
expected := not_index_byte_scalar(haystack, needle)
|
||||
|
||||
for _, sz := range sizes {
|
||||
switch sz {
|
||||
case 16:
|
||||
actual = not_index_byte_asm_128(haystack, needle)
|
||||
case 32:
|
||||
actual = not_index_byte_asm_256(haystack, needle)
|
||||
}
|
||||
if actual != expected {
|
||||
t.Fatalf("not_index failed in: %#v (%d != %d) at size: %d with needle: %#v", string(haystack), expected, actual, sz, needle)
|
||||
}
|
||||
}
|
||||
}
|
||||
not_index_test(nil, 'a')
|
||||
not_index_test([]byte{}, 'a')
|
||||
not_index_test([]byte("aaa"), 'a')
|
||||
not_index_test([]byte("aaab"), 'a')
|
||||
not_index_test([]byte("baaa"), 'a')
|
||||
not_index_test([]byte("abc"), 'a')
|
||||
for _, sz := range []int{0, 16, 32, 64, 79} {
|
||||
q := strings.Repeat("a", sz) + "b"
|
||||
not_index_test([]byte(q), 'a')
|
||||
not_index_test([]byte(q), 'b')
|
||||
not_index_test([]byte(strings.Repeat("a", sz)), 'a')
|
||||
}
|
||||
|
||||
not_index2_test := func(haystack []byte, a, b byte) {
|
||||
var actual int
|
||||
expected := not_index_byte2_scalar(haystack, a, b)
|
||||
|
||||
for _, sz := range sizes {
|
||||
switch sz {
|
||||
case 16:
|
||||
actual = not_index_byte2_asm_128(haystack, a, b)
|
||||
case 32:
|
||||
actual = not_index_byte2_asm_256(haystack, a, b)
|
||||
}
|
||||
if actual != expected {
|
||||
t.Fatalf("not_index2 failed in: %#v (%d != %d) at size: %d with needles: %#v %#v", string(haystack), expected, actual, sz, a, b)
|
||||
}
|
||||
}
|
||||
}
|
||||
not_index2_test(nil, 'a', 'b')
|
||||
not_index2_test([]byte{}, 'a', 'b')
|
||||
not_index2_test([]byte("aabb"), 'a', 'b')
|
||||
not_index2_test([]byte("aabbc"), 'a', 'b')
|
||||
not_index2_test([]byte("caabb"), 'a', 'b')
|
||||
for _, sz := range []int{0, 16, 32, 64, 79} {
|
||||
q := strings.Repeat("ab", sz) + "c"
|
||||
not_index2_test([]byte(q), 'a', 'b')
|
||||
not_index2_test([]byte(strings.Repeat("ab", sz)), 'a', 'b')
|
||||
for align := range 32 {
|
||||
not_index2_test([]byte(strings.Repeat(" ", align)+q), 'a', 'b')
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestIntrinsics(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user