Merge pull request #1159 from Kelimion/xxhash

xxhash: Add custom secret tests.
This commit is contained in:
Jeroen van Rijn
2021-09-12 12:18:10 +02:00
committed by GitHub
2 changed files with 2212 additions and 127 deletions
+17 -1
View File
@@ -167,7 +167,7 @@ test_xxhash_vectors :: proc(t: ^testing.T) {
defer delete(buf) defer delete(buf)
for seed, table in XXHASH_TEST_VECTOR_SEEDED { for seed, table in XXHASH_TEST_VECTOR_SEEDED {
fmt.printf("Seed: %v\n", seed) fmt.printf("\tSeed: %v\n", seed)
for v, i in table { for v, i in table {
b := buf[:i] b := buf[:i]
@@ -185,4 +185,20 @@ test_xxhash_vectors :: proc(t: ^testing.T) {
expect(t, xxh3_128 == v.xxh3_128, xxh3_128_error) expect(t, xxh3_128 == v.xxh3_128, xxh3_128_error)
} }
} }
fmt.println("Verifying against XXHASH_TEST_VECTOR_SECRET:")
for secret, table in XXHASH_TEST_VECTOR_SECRET {
fmt.printf("\tSecret:\n\t\t\"%v\"\n", secret)
secret_bytes := transmute([]u8)secret
for v, i in table {
b := buf[:i]
xxh3_128 := xxhash.XXH3_128(b, secret_bytes)
xxh3_128_error := fmt.tprintf("[XXH3_128(%03d)] Expected: %32x. Got: %32x.", i, v.xxh3_128_secret, xxh3_128)
expect(t, xxh3_128 == v.xxh3_128_secret, xxh3_128_error)
}
}
} }
File diff suppressed because it is too large Load Diff