30 lib test files: package <mod> -> <mod>_test, the sanctioned Go-over-Hare departure (CLAUDE.md rule-9 carve-out; white-box testing deferred, not forbidden). decimaltest retired per .ai/rob-16-decimaltest-ruling.md: Hare ships no decimal_test.ha (engine covered transitively); coverage migrated losslessly into stoftest rows (all-9s carry, nd>19 pure-decimal) + ftostest f64_roundtrip mirroring ref/hare strconv ftos_test.ha tcsf64; k=0 micro-gap documented at site. regex_test keeps its white-box internal probes under a documented rule-7 divergence (rehome = task #9). 922_decimal_run + its 989 byte-id row removed with the fixture.
65 lines
1.5 KiB
Plaintext
65 lines
1.5 KiB
Plaintext
package crc32_test;
|
|
|
|
import crc32;
|
|
|
|
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, ieee: u32, cast: u32, koop: u32) void = {
|
|
let arr: [128]u8;
|
|
let n: i32 = putstr(s, arr[0:128], 0);
|
|
let buf: []u8 = arr[0:n];
|
|
if (crc32.sum32ieee(buf) != ieee) { let _: i32 = 1/0; };
|
|
if (crc32.sum32castagnoli(buf) != cast) { let _: i32 = 1/0; };
|
|
if (crc32.sum32koopman(buf) != koop) { let _: i32 = 1/0; };
|
|
};
|
|
|
|
@test fn vec_empty() void = {
|
|
let arr: [1]u8;
|
|
let buf: []u8 = arr[0:0];
|
|
if (crc32.sum32ieee(buf) != 0u32) { let _: i32 = 1/0; };
|
|
if (crc32.sum32castagnoli(buf) != 0u32) { let _: i32 = 1/0; };
|
|
if (crc32.sum32koopman(buf) != 0u32) { let _: i32 = 1/0; };
|
|
};
|
|
|
|
@test fn vec_fire() void = {
|
|
check("Give a man a fire, they be warm for a day",
|
|
4026734998u32, 2112273292u32, 1263149916u32);
|
|
};
|
|
|
|
@test fn vec_setfire() void = {
|
|
check("Set a man on fire, they be warm for the rest of their life",
|
|
3931092334u32, 4172943610u32, 3071632577u32);
|
|
};
|
|
|
|
@test fn vec_blm() void = {
|
|
check("Black lives matter",
|
|
2370964079u32, 2068416418u32, 4151357773u32);
|
|
};
|
|
|
|
@test fn vec_unix() void = {
|
|
check("UNIX is simple and coherent",
|
|
3254252081u32, 1650777601u32, 340189632u32);
|
|
};
|
|
|
|
@test fn vec_gnu() void = {
|
|
check("GNU's not UNIX",
|
|
224734747u32, 200511816u32, 332335539u32);
|
|
};
|
|
|
|
export fn main() i32 = {
|
|
vec_empty();
|
|
vec_fire();
|
|
vec_setfire();
|
|
vec_blm();
|
|
vec_unix();
|
|
vec_gnu();
|
|
return 0;
|
|
};
|