Files
c3c/test/unit/stdlib/hash/fnv64a.c3
konimarti e67e9d3bbf Fix fnv a hashes (#1667)
* fix fnv32a

* fix fnv64a

* Simplify code

---------

Co-authored-by: Christoffer Lerno <christoffer@aegik.com>
2024-12-07 15:39:45 +01:00

25 lines
533 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::encode(input);
assert (encoded == want, "got: %d, want: %d", encoded, want);
}