aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFeoramund <161657516+Feoramund@users.noreply.github.com>2024-08-09 17:47:27 -0400
committerFeoramund <161657516+Feoramund@users.noreply.github.com>2024-08-09 18:54:04 -0400
commite7e7fe766a2e9171b7edff58cfdf889a41e1094e (patch)
tree3b37990f1be20c50ee7bad6152e8fd5d041ff0bd
parent0d29cc3375d4f20e122df23726cc526f96bf3305 (diff)
Add test for misaligned data to `core:simd/util` suite
-rw-r--r--tests/core/simd/util/test_core_simd_util.odin34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/core/simd/util/test_core_simd_util.odin b/tests/core/simd/util/test_core_simd_util.odin
index ff7e1f9aa..ba302a121 100644
--- a/tests/core/simd/util/test_core_simd_util.odin
+++ b/tests/core/simd/util/test_core_simd_util.odin
@@ -105,3 +105,37 @@ test_index_byte_zero :: proc(t: ^testing.T) {
}
}
}
+
+@test
+test_misaligned_data :: proc(t: ^testing.T) {
+ for n in 2..<256 {
+ data := make([]u8, n)
+ defer delete(data)
+ for i in 0..<n-1 {
+ data[i] = '-'
+ }
+
+ for m in 1..<n {
+ data[n-1] = 'o'
+ if !testing.expect_value(t, simd_util.index_byte(data[m:n], 'o'), n-1-m) {
+ return
+ }
+ data[n-1] = '-'
+
+ data[m+(n-m)/2] = 'o'
+ if !testing.expect_value(t, simd_util.index_byte(data[m:n], 'o'), (n-m)/2) {
+ return
+ }
+ if !testing.expect_value(t, simd_util.last_index_byte(data[m:n], 'o'), (n-m)/2) {
+ return
+ }
+ data[m+(n-m)/2] = '-'
+
+ data[m] = 'o'
+ if !testing.expect_value(t, simd_util.last_index_byte(data[m:n], 'o'), 0) {
+ return
+ }
+ data[m] = '-'
+ }
+ }
+}