Files
ww/lib/bytes/equal_test.ww
Hojun-Cho 4f37a8b425 lib: split bytes tests into equal/index/contains/tokenize/trim per ref/hare/bytes
Pure move: bytes_test.ww dissolves along its banner seams into sibling
equal_test.ww, index_test.ww (u8 + []u8 arms of index/rindex),
contains_test.ww (contains/hasprefix/hassuffix), tokenize_test.ww
(tokenize/rtokenize/peektoken/remainingtokens + splitn/rsplitn/split +
cut/rcut), and trim_test.ww, mirroring ref/hare/bytes/{equal,index,
contains,tokenize,trim}.ha ownership (Hare keeps splitn and cut in
tokenize.ha; contains.ha owns hasprefix/hassuffix). Blocks are
byte-identical; only the banner lines are deleted. Helpers stay with
their sole consumers: expect_token/expect_done/expect_tok in
tokenize_test.ww, beq in trim_test.ww.

Consumers: Makefile LIBRARY_TESTS replaces the bytes_test.ww entry
with the five new entries at the same position; the
test/byteid/libbyteid_test.ww roster row becomes five fx rows,
NENTEXPECT 48->52 (+4).
2026-08-08 17:20:50 +09:00

24 lines
763 B
Plaintext

// equaltest — exercises bytes.equal. A failing row aborts via the
// assert/abort builtin (task #5 @test conversion).
// Vectors mirror ref/hare/bytes/equal.ha.
package bytes_test;
import bytes;
// ref/hare/bytes/equal.ha:21.
@test fn equal_cases() void = {
let a: [3]u8; a[0] = 1u8; a[1] = 2u8; a[2] = 3u8;
let b: [3]u8; b[0] = 1u8; b[1] = 2u8; b[2] = 3u8;
let c: [3]u8; c[0] = 1u8; c[1] = 4u8; c[2] = 5u8;
let d: [4]u8; d[0] = 1u8; d[1] = 2u8; d[2] = 3u8; d[3] = 4u8;
let e: [2]u8; e[0] = 1u8; e[1] = 2u8;
let z: [1]u8;
assert(!(!bytes.equal(a[0:3], b[0:3])));
assert(!( bytes.equal(a[0:3], c[0:3])));
assert(!( bytes.equal(a[0:3], d[0:4])));
assert(!( bytes.equal(a[0:3], e[0:2])));
assert(!(!bytes.equal(z[0:0], z[0:0]))); // empty-empty
};