package crc64_test; import hash.crc64; fn putstr(s: str, into: []u8, off: i32) i32 = { let i: i32 = 0; for (i < s.len) { into[off + i] = s[i]; i += 1; }; return off + s.len; }; fn check(s: str, ecma: u64, iso: u64) void = { let arr: [128]u8; let n: i32 = putstr(s, arr[0:128], 0); let buf: []u8 = arr[0:n]; assert(!(crc64.sum64ecma(buf) != ecma)); assert(!(crc64.sum64iso(buf) != iso)); }; @test fn vec_empty() void = { let arr: [1]u8; let buf: []u8 = arr[0:0]; assert(!(crc64.sum64ecma(buf) != 0u64)); assert(!(crc64.sum64iso(buf) != 0u64)); }; @test fn vec_oscar() void = { check("Man can believe the impossible, but can never believe the improbable. -- Oscar Wilde", 0x17F71EF3BB851DC7u64, 0xD0E8ED57865D6AC6u64); }; @test fn vec_hegel() void = { check("We learn from history that we do not learn from history. -- Georg Hegel", 0xAA3C335BB49ABE9Du64, 0x5FD192CC516BBEC3u64); }; @test fn vec_chapelain() void = { check("The final delusion is the belief that one has lost all delusions. -- Maurice Chapelain", 0x7DFC4F7CE9552D23u64, 0xF71B429C925D99AEu64); }; @test fn vec_unix() void = { check("UNIX is simple and coherent", 0x9C1938E72C1D8619u64, 0x372ABFFD392FF27Du64); }; @test fn vec_gnu() void = { check("GNU's not UNIX", 0x2C0C97B1CB17FCBAu64, 0x9BD1FA95A419A43Du64); }; @test fn vec_blm() void = { check("Black lives matter", 0x159BB7B6086BF47Eu64, 0xC218CBB390CF44EBu64); };