From 1a9168ab7d1d5337ec954f7897c2e6b51a0bd95e Mon Sep 17 00:00:00 2001 From: Sam Atman Date: Wed, 4 Feb 2026 15:02:12 -0500 Subject: Convert Graphemes to static allocation And DisplayWidth, although untested at present. The plan is to just work through the codegen / module pairings, and move tests over until everything is covered. --- src/unicode_tests.zig | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/unicode_tests.zig') diff --git a/src/unicode_tests.zig b/src/unicode_tests.zig index e2a5a96..946c197 100644 --- a/src/unicode_tests.zig +++ b/src/unicode_tests.zig @@ -118,8 +118,6 @@ test "Segmentation GraphemeIterator" { const allocator = std.testing.allocator; var reader = std.io.Reader.fixed(@embedFile("GraphemeBreakTest.txt")); - const graph = try Graphemes.init(allocator); - defer graph.deinit(allocator); var line_iter: IterRead = .{ .read = &reader }; @@ -161,7 +159,7 @@ test "Segmentation GraphemeIterator" { const this_str = all_bytes.items; { - var iter = graph.iterator(this_str); + var iter = Graphemes.iterator(this_str); // Check. for (want.items, 1..) |want_gc, idx| { @@ -171,7 +169,7 @@ test "Segmentation GraphemeIterator" { got_gc.bytes(this_str), ); for (got_gc.offset..got_gc.offset + got_gc.len) |i| { - const this_gc = graph.graphemeAtIndex(this_str, i); + const this_gc = Graphemes.graphemeAtIndex(this_str, i); std.testing.expectEqualSlices( u8, got_gc.bytes(this_str), @@ -181,7 +179,7 @@ test "Segmentation GraphemeIterator" { return err; }; } - var after_iter = graph.iterateAfterGrapheme(this_str, got_gc); + var after_iter = Graphemes.iterateAfterGrapheme(this_str, got_gc); if (after_iter.next()) |next_gc| { if (iter.peek()) |next_peek| { std.testing.expectEqualSlices( @@ -202,7 +200,7 @@ test "Segmentation GraphemeIterator" { } } { - var iter = graph.reverseIterator(this_str); + var iter = Graphemes.reverseIterator(this_str); // Check. var i: usize = want.items.len; @@ -226,7 +224,7 @@ test "Segmentation GraphemeIterator" { ); return err; }; - var before_iter = graph.iterateBeforeGrapheme(this_str, got_gc); + var before_iter = Graphemes.iterateBeforeGrapheme(this_str, got_gc); if (before_iter.prev()) |prev_gc| { if (iter.peek()) |prev_peek| { std.testing.expectEqualSlices( -- cgit v1.2.3