diff options
Diffstat (limited to 'src/tests/test_simd.cpp')
-rw-r--r-- | src/tests/test_simd.cpp | 52 |
1 files changed, 30 insertions, 22 deletions
diff --git a/src/tests/test_simd.cpp b/src/tests/test_simd.cpp index 1465d9269..a502432f5 100644 --- a/src/tests/test_simd.cpp +++ b/src/tests/test_simd.cpp @@ -7,8 +7,8 @@ #include "tests.h" #if defined(BOTAN_HAS_SIMD_32) - #include <botan/internal/simd_32.h> - #include <botan/cpuid.h> + #include <botan/internal/simd_32.h> + #include <botan/cpuid.h> #endif namespace Botan_Tests { @@ -34,7 +34,7 @@ class SIMD_32_Tests : public Test const uint32_t pat4 = 0xC0D0E0F0; test_eq(result, "default init", Botan::SIMD_4x32(), 0, 0, 0, 0); - test_eq(result, "SIMD scalar constructor", Botan::SIMD_4x32(1,2,3,4), 1, 2, 3, 4); + test_eq(result, "SIMD scalar constructor", Botan::SIMD_4x32(1, 2, 3, 4), 1, 2, 3, 4); const Botan::SIMD_4x32 splat = Botan::SIMD_4x32::splat(pat1); @@ -61,21 +61,21 @@ class SIMD_32_Tests : public Test Botan::rotate_right(pat4, 9)); Botan::SIMD_4x32 add = input + splat; - test_eq(result, "add +", add, pat1+pat1, pat2+pat1, pat3+pat1, pat4+pat1); + test_eq(result, "add +", add, pat1 + pat1, pat2 + pat1, pat3 + pat1, pat4 + pat1); add -= splat; test_eq(result, "sub -=", add, pat1, pat2, pat3, pat4); add += splat; - test_eq(result, "add +=", add, pat1+pat1, pat2+pat1, pat3+pat1, pat4+pat1); + test_eq(result, "add +=", add, pat1 + pat1, pat2 + pat1, pat3 + pat1, pat4 + pat1); - test_eq(result, "xor", input ^ splat, 0, pat2^pat1, pat3^pat1, pat4^pat1); + test_eq(result, "xor", input ^ splat, 0, pat2 ^ pat1, pat3 ^ pat1, pat4 ^ pat1); test_eq(result, "or", input | splat, pat1, pat2 | pat1, pat3 | pat1, pat4 | pat1); test_eq(result, "and", input & splat, pat1, pat2 & pat1, pat3 & pat1, pat4 & pat1); Botan::SIMD_4x32 blender = input; blender |= splat; - test_eq(result, "|=", blender, pat1, pat2|pat1, pat3|pat1, pat4|pat1); + test_eq(result, "|=", blender, pat1, pat2 | pat1, pat3 | pat1, pat4 | pat1); blender &= splat; test_eq(result, "&=", blender, pat1, pat1, pat1, pat1); blender ^= splat; @@ -105,16 +105,16 @@ class SIMD_32_Tests : public Test Botan::reverse_bytes(pat4)); Botan::SIMD_4x32 t1(pat1, pat2, pat3, pat4); - Botan::SIMD_4x32 t2(pat1+1, pat2+1, pat3+1, pat4+1); - Botan::SIMD_4x32 t3(pat1+2, pat2+2, pat3+2, pat4+2); - Botan::SIMD_4x32 t4(pat1+3, pat2+3, pat3+3, pat4+3); + Botan::SIMD_4x32 t2(pat1 + 1, pat2 + 1, pat3 + 1, pat4 + 1); + Botan::SIMD_4x32 t3(pat1 + 2, pat2 + 2, pat3 + 2, pat4 + 2); + Botan::SIMD_4x32 t4(pat1 + 3, pat2 + 3, pat3 + 3, pat4 + 3); Botan::SIMD_4x32::transpose(t1, t2, t3, t4); - test_eq(result, "transpose t1", t1, pat1, pat1+1, pat1+2, pat1+3); - test_eq(result, "transpose t2", t2, pat2, pat2+1, pat2+2, pat2+3); - test_eq(result, "transpose t3", t3, pat3, pat3+1, pat3+2, pat3+3); - test_eq(result, "transpose t4", t4, pat4, pat4+1, pat4+2, pat4+3); + test_eq(result, "transpose t1", t1, pat1, pat1 + 1, pat1 + 2, pat1 + 3); + test_eq(result, "transpose t2", t2, pat2, pat2 + 1, pat2 + 2, pat2 + 3); + test_eq(result, "transpose t3", t3, pat3, pat3 + 1, pat3 + 2, pat3 + 3); + test_eq(result, "transpose t4", t4, pat4, pat4 + 1, pat4 + 2, pat4 + 3); return {result}; } @@ -127,10 +127,14 @@ class SIMD_32_Tests : public Test uint8_t mem_be[16]; simd.store_be(mem_be); - result.test_int_eq("SIMD_4x32 " + op + " elem0 BE", Botan::make_uint32(mem_be[ 0], mem_be[ 1], mem_be[ 2], mem_be[ 3]), exp0); - result.test_int_eq("SIMD_4x32 " + op + " elem1 BE", Botan::make_uint32(mem_be[ 4], mem_be[ 5], mem_be[ 6], mem_be[ 7]), exp1); - result.test_int_eq("SIMD_4x32 " + op + " elem2 BE", Botan::make_uint32(mem_be[ 8], mem_be[ 9], mem_be[10], mem_be[11]), exp2); - result.test_int_eq("SIMD_4x32 " + op + " elem3 BE", Botan::make_uint32(mem_be[12], mem_be[13], mem_be[14], mem_be[15]), exp3); + result.test_int_eq("SIMD_4x32 " + op + " elem0 BE", Botan::make_uint32(mem_be[ 0], mem_be[ 1], mem_be[ 2], mem_be[ 3]), + exp0); + result.test_int_eq("SIMD_4x32 " + op + " elem1 BE", Botan::make_uint32(mem_be[ 4], mem_be[ 5], mem_be[ 6], mem_be[ 7]), + exp1); + result.test_int_eq("SIMD_4x32 " + op + " elem2 BE", Botan::make_uint32(mem_be[ 8], mem_be[ 9], mem_be[10], mem_be[11]), + exp2); + result.test_int_eq("SIMD_4x32 " + op + " elem3 BE", Botan::make_uint32(mem_be[12], mem_be[13], mem_be[14], mem_be[15]), + exp3); // Check load_be+store_be results in same value const Botan::SIMD_4x32 reloaded_be = Botan::SIMD_4x32::load_be(mem_be); @@ -141,10 +145,14 @@ class SIMD_32_Tests : public Test uint8_t mem_le[16]; simd.store_le(mem_le); - result.test_int_eq("SIMD_4x32 " + op + " elem0 LE", Botan::make_uint32(mem_le[ 3], mem_le[ 2], mem_le[ 1], mem_le[ 0]), exp0); - result.test_int_eq("SIMD_4x32 " + op + " elem1 LE", Botan::make_uint32(mem_le[ 7], mem_le[ 6], mem_le[ 5], mem_le[ 4]), exp1); - result.test_int_eq("SIMD_4x32 " + op + " elem2 LE", Botan::make_uint32(mem_le[11], mem_le[10], mem_le[ 9], mem_le[ 8]), exp2); - result.test_int_eq("SIMD_4x32 " + op + " elem3 LE", Botan::make_uint32(mem_le[15], mem_le[14], mem_le[13], mem_le[12]), exp3); + result.test_int_eq("SIMD_4x32 " + op + " elem0 LE", Botan::make_uint32(mem_le[ 3], mem_le[ 2], mem_le[ 1], mem_le[ 0]), + exp0); + result.test_int_eq("SIMD_4x32 " + op + " elem1 LE", Botan::make_uint32(mem_le[ 7], mem_le[ 6], mem_le[ 5], mem_le[ 4]), + exp1); + result.test_int_eq("SIMD_4x32 " + op + " elem2 LE", Botan::make_uint32(mem_le[11], mem_le[10], mem_le[ 9], mem_le[ 8]), + exp2); + result.test_int_eq("SIMD_4x32 " + op + " elem3 LE", Botan::make_uint32(mem_le[15], mem_le[14], mem_le[13], mem_le[12]), + exp3); // Check load_le+store_le results in same value const Botan::SIMD_4x32 reloaded_le = Botan::SIMD_4x32::load_le(mem_le); |