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.
61 lines
1.6 KiB
Plaintext
61 lines
1.6 KiB
Plaintext
package crc16_test;
|
|
|
|
import crc16;
|
|
|
|
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, ccitt: u16, cmda: u16, dect: u16, ansi: u16) void = {
|
|
let arr: [256]u8;
|
|
let n: i32 = putstr(s, arr[0:256], 0);
|
|
let buf: []u8 = arr[0:n];
|
|
if (crc16.sum16ccitt(buf) != ccitt) { let _: i32 = 1/0; };
|
|
if (crc16.sum16cmda2000(buf) != cmda) { let _: i32 = 1/0; };
|
|
if (crc16.sum16dect(buf) != dect) { let _: i32 = 1/0; };
|
|
if (crc16.sum16ansi(buf) != ansi) { let _: i32 = 1/0; };
|
|
};
|
|
|
|
@test fn vec_empty() void = {
|
|
let arr: [1]u8;
|
|
let buf: []u8 = arr[0:0];
|
|
if (crc16.sum16ccitt(buf) != 0u16) { let _: i32 = 1/0; };
|
|
if (crc16.sum16cmda2000(buf) != 0u16) { let _: i32 = 1/0; };
|
|
if (crc16.sum16dect(buf) != 0u16) { let _: i32 = 1/0; };
|
|
if (crc16.sum16ansi(buf) != 0u16) { let _: i32 = 1/0; };
|
|
};
|
|
|
|
@test fn vec_truman() void = {
|
|
check("Always be sincere, even if you don't mean it. -- Harry Truman",
|
|
0x38DFu16, 0x2441u16, 0x8E44u16, 0xEF5Eu16);
|
|
};
|
|
|
|
@test fn vec_animals() void = {
|
|
check("You get along very well with everyone except animals and people.",
|
|
0xB6AEu16, 0xFED0u16, 0x8739u16, 0xCF56u16);
|
|
};
|
|
|
|
@test fn vec_twain() void = {
|
|
check("All generalizations are false, including this one. -- Mark Twain",
|
|
0xCA68u16, 0x65ECu16, 0x098Au16, 0x45B4u16);
|
|
};
|
|
|
|
@test fn vec_peace() void = {
|
|
check("I want peace and I'm willing to fight for it. -- Harry Truman",
|
|
0xB0E8u16, 0xFE1Fu16, 0x4659u16, 0x5062u16);
|
|
};
|
|
|
|
export fn main() i32 = {
|
|
vec_empty();
|
|
vec_truman();
|
|
vec_animals();
|
|
vec_twain();
|
|
vec_peace();
|
|
return 0;
|
|
};
|