Files
ww/lib/strings/utf8_test.ww

23 lines
798 B
Plaintext

// Vectors mirror ref/hare/strings/utf8.ha where ww can express them.
// External strings_test package per the Go foo_test idiom (rule-5/9
// carve-out, task #16); the shared streq helper lives in
// helpers_test.ww — same-package test files compose in dir-mode
// (the package, not the file, is the unit of testing).
package strings_test;
import strings;
// ref/hare/strings/utf8.ha:31. Validation-half coverage lives in
// lib/encoding/utf8 (utf8test) per CLAUDE.md rule 9 carve-out.
@test fn utf8_roundtrip_cases() void = {
let s: str = "hello";
let b: []u8 = strings.toutf8(s);
assert(!(b.len != 5));
assert(!(b[0] != 104u8)); // 'h'
let r: str = strings.frombytes(b);
assert(!(!streq(r, "hello")));
assert(!(r.ptr != s.ptr)); // borrowed, not copied
assert(!(r.cap != r.len));
};