mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Fix $$str_hash to use a5hash like String.hash() (#2403)
* Fix `$$str_hash` to use `a5hash` like `String.hash()`
This commit is contained in:
@@ -174,6 +174,18 @@ fn void test_hash_repeat()
|
||||
assert(int.typeid.hash() == int.typeid.hash());
|
||||
}
|
||||
|
||||
fn void test_builtin_string_hashing() => @pool()
|
||||
{
|
||||
var $x = "";
|
||||
ulong l;
|
||||
$for var $i = 0; $i < 65; ++$i: // 65 is a good length to reliably test all branches w/o being excessive
|
||||
l = string::tformat("%s%s", $x, $i).hash();
|
||||
var $r = $$str_hash(@sprintf("%s%s", $x, $i));
|
||||
assert((uint)l == (uint)$r, "Builtin $$str_hash mismatch against String.hash()");
|
||||
$x = $x +++ "a";
|
||||
$endfor
|
||||
}
|
||||
|
||||
fn void test_ct_clz()
|
||||
{
|
||||
assert(@clz((ulong)0) == ulong.sizeof * 8);
|
||||
|
||||
Reference in New Issue
Block a user