diff options
| author | 2026-02-04 15:02:12 -0500 | |
|---|---|---|
| committer | 2026-02-04 15:02:12 -0500 | |
| commit | 1a9168ab7d1d5337ec954f7897c2e6b51a0bd95e (patch) | |
| tree | 35847e74f41a0a75870b08d8a5fbbb0f1bd0d378 /src/unicode_tests.zig | |
| parent | Merge pull request 'Move part of the `DisplayWidth.strWidth` into its own `Di... (diff) | |
| download | zg-1a9168ab7d1d5337ec954f7897c2e6b51a0bd95e.tar.gz zg-1a9168ab7d1d5337ec954f7897c2e6b51a0bd95e.tar.xz zg-1a9168ab7d1d5337ec954f7897c2e6b51a0bd95e.zip | |
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.
Diffstat (limited to 'src/unicode_tests.zig')
| -rw-r--r-- | src/unicode_tests.zig | 12 |
1 files changed, 5 insertions, 7 deletions
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" { | |||
| 118 | const allocator = std.testing.allocator; | 118 | const allocator = std.testing.allocator; |
| 119 | 119 | ||
| 120 | var reader = std.io.Reader.fixed(@embedFile("GraphemeBreakTest.txt")); | 120 | var reader = std.io.Reader.fixed(@embedFile("GraphemeBreakTest.txt")); |
| 121 | const graph = try Graphemes.init(allocator); | ||
| 122 | defer graph.deinit(allocator); | ||
| 123 | 121 | ||
| 124 | var line_iter: IterRead = .{ .read = &reader }; | 122 | var line_iter: IterRead = .{ .read = &reader }; |
| 125 | 123 | ||
| @@ -161,7 +159,7 @@ test "Segmentation GraphemeIterator" { | |||
| 161 | const this_str = all_bytes.items; | 159 | const this_str = all_bytes.items; |
| 162 | 160 | ||
| 163 | { | 161 | { |
| 164 | var iter = graph.iterator(this_str); | 162 | var iter = Graphemes.iterator(this_str); |
| 165 | 163 | ||
| 166 | // Check. | 164 | // Check. |
| 167 | for (want.items, 1..) |want_gc, idx| { | 165 | for (want.items, 1..) |want_gc, idx| { |
| @@ -171,7 +169,7 @@ test "Segmentation GraphemeIterator" { | |||
| 171 | got_gc.bytes(this_str), | 169 | got_gc.bytes(this_str), |
| 172 | ); | 170 | ); |
| 173 | for (got_gc.offset..got_gc.offset + got_gc.len) |i| { | 171 | for (got_gc.offset..got_gc.offset + got_gc.len) |i| { |
| 174 | const this_gc = graph.graphemeAtIndex(this_str, i); | 172 | const this_gc = Graphemes.graphemeAtIndex(this_str, i); |
| 175 | std.testing.expectEqualSlices( | 173 | std.testing.expectEqualSlices( |
| 176 | u8, | 174 | u8, |
| 177 | got_gc.bytes(this_str), | 175 | got_gc.bytes(this_str), |
| @@ -181,7 +179,7 @@ test "Segmentation GraphemeIterator" { | |||
| 181 | return err; | 179 | return err; |
| 182 | }; | 180 | }; |
| 183 | } | 181 | } |
| 184 | var after_iter = graph.iterateAfterGrapheme(this_str, got_gc); | 182 | var after_iter = Graphemes.iterateAfterGrapheme(this_str, got_gc); |
| 185 | if (after_iter.next()) |next_gc| { | 183 | if (after_iter.next()) |next_gc| { |
| 186 | if (iter.peek()) |next_peek| { | 184 | if (iter.peek()) |next_peek| { |
| 187 | std.testing.expectEqualSlices( | 185 | std.testing.expectEqualSlices( |
| @@ -202,7 +200,7 @@ test "Segmentation GraphemeIterator" { | |||
| 202 | } | 200 | } |
| 203 | } | 201 | } |
| 204 | { | 202 | { |
| 205 | var iter = graph.reverseIterator(this_str); | 203 | var iter = Graphemes.reverseIterator(this_str); |
| 206 | 204 | ||
| 207 | // Check. | 205 | // Check. |
| 208 | var i: usize = want.items.len; | 206 | var i: usize = want.items.len; |
| @@ -226,7 +224,7 @@ test "Segmentation GraphemeIterator" { | |||
| 226 | ); | 224 | ); |
| 227 | return err; | 225 | return err; |
| 228 | }; | 226 | }; |
| 229 | var before_iter = graph.iterateBeforeGrapheme(this_str, got_gc); | 227 | var before_iter = Graphemes.iterateBeforeGrapheme(this_str, got_gc); |
| 230 | if (before_iter.prev()) |prev_gc| { | 228 | if (before_iter.prev()) |prev_gc| { |
| 231 | if (iter.peek()) |prev_peek| { | 229 | if (iter.peek()) |prev_peek| { |
| 232 | std.testing.expectEqualSlices( | 230 | std.testing.expectEqualSlices( |