2018-01-13 13:48:58 +11:00
|
|
|
#include "hash/fnv1a.hpp"
|
|
|
|
#include "tap.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
static const struct {
|
|
|
|
uint32_t h32;
|
|
|
|
uint64_t h64;
|
|
|
|
const char *data;
|
|
|
|
} TESTS[] = {
|
|
|
|
{ 0x811c9dc5, 0xcbf29ce484222325, "" },
|
|
|
|
{ 0xe40c292c, 0xaf63dc4c8601ec8c, "a" },
|
|
|
|
{ 0xbf9cf968, 0x85944171f73967e8, "foobar" },
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
int
|
|
|
|
main (void)
|
|
|
|
{
|
2018-08-05 14:42:02 +10:00
|
|
|
cruft::TAP::logger tap;
|
2018-01-13 13:48:58 +11:00
|
|
|
|
2018-08-05 14:42:02 +10:00
|
|
|
const cruft::hash::fnv1a<uint32_t> h32;
|
|
|
|
const cruft::hash::fnv1a<uint64_t> h64;
|
2018-01-13 13:48:58 +11:00
|
|
|
|
|
|
|
for (const auto &t: TESTS) {
|
2018-08-05 14:42:02 +10:00
|
|
|
tap.expect_eq (h32 (cruft::view{t.data}.cast <const uint8_t*> ()), t.h32, "fnv1a32: '%s'", t.data);
|
|
|
|
tap.expect_eq (h64 (cruft::view{t.data}.cast <const uint8_t*> ()), t.h64, "fnv1a64: '%s'", t.data);
|
2018-01-13 13:48:58 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
return tap.status ();
|
|
|
|
}
|