Files
c3c/test/unit/stdlib/hash/fnv64a.c3
2025-03-03 20:07:02 +01:00

25 lines
531 B
Plaintext

module std::hash::fnv64a_test @test;
import std::hash::fnv64a;
fn void test_fnv64a()
{
Fnv64a hash;
char[] input = "Hello world";
ulong want = 0x2713f785a33764c7;
// update
hash.init();
hash.update(input);
assert ((ulong)hash == want, "got: %d, want: %d", hash, want);
// update_char
hash.init();
foreach (c : input) hash.update_char(c);
assert ((ulong)hash == want, "got: %d, want: %d", hash, want);
// encode
ulong encoded = fnv64a::hash(input);
assert (encoded == want, "got: %d, want: %d", encoded, want);
}