mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
* fix fnv32a * fix fnv64a * Simplify code --------- Co-authored-by: Christoffer Lerno <christoffer@aegik.com>
25 lines
521 B
Plaintext
25 lines
521 B
Plaintext
module std::hash::fnv32a_test @test;
|
|
import std::hash::fnv32a;
|
|
|
|
fn void test_fnv32a()
|
|
{
|
|
Fnv32a hash;
|
|
|
|
char[] input = "Hello world";
|
|
uint want = 0x594d29c7;
|
|
|
|
// update
|
|
hash.init();
|
|
hash.update(input);
|
|
assert ((uint)hash == want, "got: %d, want: %d", hash, want);
|
|
|
|
// update_char
|
|
hash.init();
|
|
foreach (c : input) hash.update_char(c);
|
|
assert ((uint)hash == want, "got: %d, want: %d", hash, want);
|
|
|
|
// encode
|
|
uint encoded = fnv32a::encode(input);
|
|
assert (encoded == want, "got: %d, want: %d", encoded, want);
|
|
}
|