summaryrefslogtreecommitdiff
path: root/lib/std/test
diff options
context:
space:
mode:
authorOri Bernstein <ori@markovcorp.com>2017-03-17 17:59:11 -0700
committerOri Bernstein <ori@markovcorp.com>2017-03-17 17:59:11 -0700
commit003c3c95490986905616bd7c79b9ab2a9d65e115 (patch)
tree24a08a44ab82f568c4e0c25e74949f266c1f09a9 /lib/std/test
parent6f8ceb3bf2f16c16cf566b4dc99b09dd2b538479 (diff)
downloadmc-003c3c95490986905616bd7c79b9ab2a9d65e115.tar.gz
Don't count trailing elements when hashing bitsets.
These don't logically affect the contents, so we shouldn't care what they have.
Diffstat (limited to 'lib/std/test')
-rw-r--r--lib/std/test/bitset.myr9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/std/test/bitset.myr b/lib/std/test/bitset.myr
index d6c8a8f..0415be8 100644
--- a/lib/std/test/bitset.myr
+++ b/lib/std/test/bitset.myr
@@ -46,6 +46,15 @@ const main = {
var bs = mkset([0, 63, 64, 65, 73, 127, 128, 129][:])
testr.check(ctx, std.bscount(bs) == 8, "wrong element count, expected {}", std.bscount(bs))
std.bsfree(bs)
+ }],
+ [.name="hash", .fn={ctx
+ var bs = mkset([][:])
+ testr.check(ctx, std.bshash(bs) == 493832887, "wrong hash, expected {}", std.bshash(bs))
+ std.bsput(bs, 123456)
+ testr.check(ctx, std.bshash(bs) == 746495367, "wrong hash, expected {}", std.bshash(bs))
+ std.bsdel(bs, 123456)
+ testr.check(ctx, std.bshash(bs) == 493832887, "wrong hash, expected {}", std.bshash(bs))
+ std.bsfree(bs)
}]
][:])
}