mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-20 23:44:59 +02:00
...
This commit is contained in:
@@ -132,13 +132,12 @@ func aligned_slice(sz, alignment int) ([]byte, []byte) {
|
|||||||
|
|
||||||
func TestSIMDStringOps(t *testing.T) {
|
func TestSIMDStringOps(t *testing.T) {
|
||||||
sizes := get_sizes(t)
|
sizes := get_sizes(t)
|
||||||
test := func(haystack []byte, a, b byte, dont_pad ...bool) {
|
test := func(haystack []byte, a, b byte, align_offset int) {
|
||||||
var actual int
|
var actual int
|
||||||
if len(dont_pad) == 0 || !dont_pad[0] {
|
sh, _ := aligned_slice(len(haystack)+align_offset, 64)
|
||||||
safe_haystack := append(bytes.Repeat([]byte{'<'}, 64), haystack...)
|
sh = sh[align_offset:]
|
||||||
safe_haystack = append(safe_haystack, bytes.Repeat([]byte{'>'}, 64)...)
|
copy(sh, haystack)
|
||||||
haystack = safe_haystack[64 : 64+len(haystack)]
|
haystack = sh
|
||||||
}
|
|
||||||
expected := index_byte2_scalar(haystack, a, b)
|
expected := index_byte2_scalar(haystack, a, b)
|
||||||
|
|
||||||
for _, sz := range sizes {
|
for _, sz := range sizes {
|
||||||
@@ -156,27 +155,25 @@ func TestSIMDStringOps(t *testing.T) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
// test alignment issues
|
// test alignment issues
|
||||||
|
q := []byte("abc")
|
||||||
for sz := 0; sz < 32; sz++ {
|
for sz := 0; sz < 32; sz++ {
|
||||||
as, _ := aligned_slice(sz+3, 32)
|
test(q, '<', '>', sz)
|
||||||
q := as[sz:]
|
test(q, ' ', 'b', sz)
|
||||||
q[0] = 'a'
|
test(q, '<', 'a', sz)
|
||||||
q[1] = 'b'
|
test(q, '<', 'b', sz)
|
||||||
q[2] = 'c'
|
test(q, 'c', '>', sz)
|
||||||
test(q, '<', '>', true)
|
|
||||||
test(q, ' ', 'b', true)
|
|
||||||
test(q, '<', 'a', true)
|
|
||||||
test(q, '<', 'b', true)
|
|
||||||
test(q, 'c', '>', true)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tests := func(h string, a, b byte) {
|
tests := func(h string, a, b byte) {
|
||||||
for _, sz := range []int{0, 16, 32, 64, 79} {
|
for _, sz := range []int{0, 16, 32, 64, 79} {
|
||||||
q := strings.Repeat(" ", sz) + h
|
q := strings.Repeat(" ", sz) + h
|
||||||
test([]byte(q), a, b)
|
for sz := 0; sz < 32; sz++ {
|
||||||
|
test([]byte(q), a, b, sz)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
test(nil, '<', '>')
|
test(nil, '<', '>', 1)
|
||||||
test([]byte{}, '<', '>')
|
test([]byte{}, '<', '>', 1)
|
||||||
|
|
||||||
tests("", '<', '>')
|
tests("", '<', '>')
|
||||||
tests("a", 0, 0)
|
tests("a", 0, 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user