summaryrefslogtreecommitdiff
path: root/src/unicode_tests.zig
diff options
context:
space:
mode:
authorGravatar Sam Atman2025-05-23 18:46:30 -0400
committerGravatar Sam Atman2025-05-23 18:46:30 -0400
commitc9a1b3392973ee30e6a9a532f1da8605619b5b06 (patch)
tree1198b2fcb544bcef9f634cf507d848d82548f00a /src/unicode_tests.zig
parentAdd iterateBefore and iterateAfter (diff)
downloadzg-c9a1b3392973ee30e6a9a532f1da8605619b5b06.tar.gz
zg-c9a1b3392973ee30e6a9a532f1da8605619b5b06.tar.xz
zg-c9a1b3392973ee30e6a9a532f1da8605619b5b06.zip
Make offset size configurable
Hopefully I can talk users out of taking advantage of this configuration but I'll have better luck with that if it's available.
Diffstat (limited to 'src/unicode_tests.zig')
-rw-r--r--src/unicode_tests.zig10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/unicode_tests.zig b/src/unicode_tests.zig
index 195fdcb..c463dcc 100644
--- a/src/unicode_tests.zig
+++ b/src/unicode_tests.zig
@@ -141,12 +141,12 @@ test "Segmentation GraphemeIterator" {
141 defer all_bytes.deinit(); 141 defer all_bytes.deinit();
142 142
143 var graphemes = std.mem.splitSequence(u8, line, " ÷ "); 143 var graphemes = std.mem.splitSequence(u8, line, " ÷ ");
144 var bytes_index: u32 = 0; 144 var bytes_index: uoffset = 0;
145 145
146 while (graphemes.next()) |field| { 146 while (graphemes.next()) |field| {
147 var code_points = std.mem.splitScalar(u8, field, ' '); 147 var code_points = std.mem.splitScalar(u8, field, ' ');
148 var cp_buf: [4]u8 = undefined; 148 var cp_buf: [4]u8 = undefined;
149 var cp_index: u32 = 0; 149 var cp_index: uoffset = 0;
150 var gc_len: u8 = 0; 150 var gc_len: u8 = 0;
151 151
152 while (code_points.next()) |code_point| { 152 while (code_points.next()) |code_point| {
@@ -231,12 +231,12 @@ test "Segmentation Word Iterator" {
231 defer all_bytes.deinit(); 231 defer all_bytes.deinit();
232 232
233 var words = std.mem.splitSequence(u8, line, " ÷ "); 233 var words = std.mem.splitSequence(u8, line, " ÷ ");
234 var bytes_index: u32 = 0; 234 var bytes_index: uoffset = 0;
235 235
236 while (words.next()) |field| { 236 while (words.next()) |field| {
237 var code_points = std.mem.splitScalar(u8, field, ' '); 237 var code_points = std.mem.splitScalar(u8, field, ' ');
238 var cp_buf: [4]u8 = undefined; 238 var cp_buf: [4]u8 = undefined;
239 var cp_index: u32 = 0; 239 var cp_index: uoffset = 0;
240 var gc_len: u8 = 0; 240 var gc_len: u8 = 0;
241 241
242 while (code_points.next()) |code_point| { 242 while (code_points.next()) |code_point| {
@@ -425,6 +425,8 @@ const debug = std.debug;
425const testing = std.testing; 425const testing = std.testing;
426const unicode = std.unicode; 426const unicode = std.unicode;
427 427
428const uoffset = @FieldType(Word, "offset");
429
428const Grapheme = @import("Graphemes").Grapheme; 430const Grapheme = @import("Graphemes").Grapheme;
429const Graphemes = @import("Graphemes"); 431const Graphemes = @import("Graphemes");
430const GraphemeIterator = @import("Graphemes").Iterator; 432const GraphemeIterator = @import("Graphemes").Iterator;