From c9a1b3392973ee30e6a9a532f1da8605619b5b06 Mon Sep 17 00:00:00 2001 From: Sam Atman Date: Fri, 23 May 2025 18:46:30 -0400 Subject: 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. --- src/unicode_tests.zig | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/unicode_tests.zig') 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" { defer all_bytes.deinit(); var graphemes = std.mem.splitSequence(u8, line, " ÷ "); - var bytes_index: u32 = 0; + var bytes_index: uoffset = 0; while (graphemes.next()) |field| { var code_points = std.mem.splitScalar(u8, field, ' '); var cp_buf: [4]u8 = undefined; - var cp_index: u32 = 0; + var cp_index: uoffset = 0; var gc_len: u8 = 0; while (code_points.next()) |code_point| { @@ -231,12 +231,12 @@ test "Segmentation Word Iterator" { defer all_bytes.deinit(); var words = std.mem.splitSequence(u8, line, " ÷ "); - var bytes_index: u32 = 0; + var bytes_index: uoffset = 0; while (words.next()) |field| { var code_points = std.mem.splitScalar(u8, field, ' '); var cp_buf: [4]u8 = undefined; - var cp_index: u32 = 0; + var cp_index: uoffset = 0; var gc_len: u8 = 0; while (code_points.next()) |code_point| { @@ -425,6 +425,8 @@ const debug = std.debug; const testing = std.testing; const unicode = std.unicode; +const uoffset = @FieldType(Word, "offset"); + const Grapheme = @import("Graphemes").Grapheme; const Graphemes = @import("Graphemes"); const GraphemeIterator = @import("Graphemes").Iterator; -- cgit v1.2.3