aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2021-09-21 16:17:01 +0200
committerJeroen van Rijn <Kelimion@users.noreply.github.com>2021-09-21 16:17:01 +0200
commit181eabcffcd8ecb7bba1aaab6e57c1c071ee43d8 (patch)
tree32e50345ed4a68d96688de345410bad3ecd19078 /tests
parentb600ffba3bf5cb35e0d53b99ead73e3be5164b13 (diff)
hash: Add CRC-64 (ISO 3306) and inverse.
Diffstat (limited to 'tests')
-rw-r--r--tests/core/hash/test_core_hash.odin16
1 files changed, 13 insertions, 3 deletions
diff --git a/tests/core/hash/test_core_hash.odin b/tests/core/hash/test_core_hash.odin
index 15a69bafb..0102bdb08 100644
--- a/tests/core/hash/test_core_hash.odin
+++ b/tests/core/hash/test_core_hash.odin
@@ -261,14 +261,18 @@ test_xxhash_vectors :: proc(t: ^testing.T) {
test_crc64_vectors :: proc(t: ^testing.T) {
fmt.println("Verifying CRC-64:")
- vectors := map[string][2]u64 {
+ vectors := map[string][4]u64 {
"123456789" = {
0x6c40df5f0b497347, // ECMA-182,
0x995dc9bbdf1939fa, // XZ
+ 0x46a5a9388a5beffe, // ISO 3306
+ 0xb90956c775a41001, // ISO 3306, input and output inverted
},
"This is a test of the emergency broadcast system." = {
0x344fe1d09c983d13, // ECMA-182
0x27db187fc15bbc72, // XZ
+ 0x187184d744afc49e, // ISO 3306
+ 0xe7fcf1006b503b61, // ISO 3306, input and output inverted
},
}
@@ -277,11 +281,17 @@ test_crc64_vectors :: proc(t: ^testing.T) {
b := transmute([]u8)vector
ecma := hash.crc64_ecma_182(b)
xz := hash.crc64_xz(b)
+ iso := hash.crc64_iso_3306(b)
+ iso2 := hash.crc64_iso_3306_inverse(b)
- ecma_error := fmt.tprintf("[CRC-64 ECMA] Expected: %016x. Got: %016x.", ecma, expected[0])
- xz_error := fmt.tprintf("[CRC-64 XZ ] Expected: %016x. Got: %016x.", xz, expected[1])
+ ecma_error := fmt.tprintf("[ CRC-64 ECMA ] Expected: %016x. Got: %016x.", ecma, expected[0])
+ xz_error := fmt.tprintf("[ CRC-64 XZ ] Expected: %016x. Got: %016x.", xz, expected[1])
+ iso_error := fmt.tprintf("[ CRC-64 ISO 3306] Expected: %016x. Got: %016x.", iso, expected[2])
+ iso2_error := fmt.tprintf("[~CRC-64 ISO 3306] Expected: %016x. Got: %016x.", iso2, expected[3])
expect(t, ecma == expected[0], ecma_error)
expect(t, xz == expected[1], xz_error)
+ expect(t, iso == expected[2], iso_error)
+ expect(t, iso2 == expected[3], iso2_error)
}
} \ No newline at end of file