diff --git a/test/hash/fasthash.cpp b/test/hash/fasthash.cpp index 09624c91..11b8bd44 100644 --- a/test/hash/fasthash.cpp +++ b/test/hash/fasthash.cpp @@ -2,6 +2,7 @@ #include "tap.hpp" #include +#include /////////////////////////////////////////////////////////////////////////////// @@ -26,15 +27,15 @@ main (void) uint32_t hash32; uint64_t seed64; uint64_t hash64; - std::vector data; + const char *data; } TESTS[] = { - { 0x00000000, 0x00000000, 0x0000000000000000, 0x0000000000000000, ""_u8s }, - { 0x00000001, 0xd30ac4de, 0x0000000000000001, 0x2127599bf4321e79, ""_u8s }, - { 0xffffffff, 0xf5c7b4b0, 0xffffffffffffffff, 0x9b4792000001368f, ""_u8s }, - { 0xf5c7b4b0, 0x228128b7, 0x9b4792000001368f, 0x67a642098cc81da6, "a"_u8s }, - { 0x228128b7, 0x8400568d, 0x67a642098cc81da6, 0xc906440e03ce99a8, "abc"_u8s }, - { 0x8400568d, 0x12b4858b, 0x67a642098cc81da6, 0x1a36fbf3d71b0737, "message digest"_u8s }, - { 0x12b4858b, 0x730b822e, 0x1a36fbf3d71b0737, 0x7b48e31e3ac40a0f, "abcdefghijklmnopqrstuvwxyz"_u8s }, + { 0x00000000, 0x00000000, 0x0000000000000000, 0x0000000000000000, "" }, + { 0x00000001, 0xd30ac4de, 0x0000000000000001, 0x2127599bf4321e79, "" }, + { 0xffffffff, 0xf5c7b4b0, 0xffffffffffffffff, 0x9b4792000001368f, "" }, + { 0xf5c7b4b0, 0x228128b7, 0x9b4792000001368f, 0x67a642098cc81da6, "a" }, + { 0x228128b7, 0x8400568d, 0x67a642098cc81da6, 0xc906440e03ce99a8, "abc" }, + { 0x8400568d, 0x12b4858b, 0x67a642098cc81da6, 0x1a36fbf3d71b0737, "message digest" }, + { 0x12b4858b, 0x730b822e, 0x1a36fbf3d71b0737, 0x7b48e31e3ac40a0f, "abcdefghijklmnopqrstuvwxyz" }, }; bool success32 = true; @@ -44,8 +45,10 @@ main (void) util::hash::fasthash h64{}; for (const auto &t: TESTS) { - success32 = success32 && t.hash32 == h32 (t.seed32, t.data); - success64 = success64 && t.hash64 == h64 (t.seed64, t.data); + util::view data { t.data }; + + tap.expect_eq (t.hash32, h32 (t.seed32, data.cast ()), "h32(%0" PRIx32 ")", t.seed32); + tap.expect_eq (t.hash64, h64 (t.seed64, data.cast ()), "h64(%0" PRIx64 ")", t.seed64); } tap.expect (success32, "fasthash32");