mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
25 lines
531 B
Plaintext
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);
|
|
}
|