diff options
Diffstat (limited to 'src/unicode_tests.zig')
| -rw-r--r-- | src/unicode_tests.zig | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/unicode_tests.zig b/src/unicode_tests.zig index 691ccfb..245c03f 100644 --- a/src/unicode_tests.zig +++ b/src/unicode_tests.zig | |||
| @@ -7,11 +7,37 @@ const mem = std.mem; | |||
| 7 | const testing = std.testing; | 7 | const testing = std.testing; |
| 8 | const unicode = std.unicode; | 8 | const unicode = std.unicode; |
| 9 | 9 | ||
| 10 | const grapheme = @import("grapheme"); | ||
| 10 | const Grapheme = @import("grapheme").Grapheme; | 11 | const Grapheme = @import("grapheme").Grapheme; |
| 11 | const GraphemeData = @import("grapheme").GraphemeData; | 12 | const GraphemeData = @import("grapheme").GraphemeData; |
| 12 | const GraphemeIterator = @import("grapheme").Iterator; | 13 | const GraphemeIterator = @import("grapheme").Iterator; |
| 13 | const Normalize = @import("Normalize"); | 14 | const Normalize = @import("Normalize"); |
| 14 | 15 | ||
| 16 | comptime { | ||
| 17 | testing.refAllDecls(grapheme); | ||
| 18 | } | ||
| 19 | test "Iterator.peek" { | ||
| 20 | const peek_seq = "aΔ👨🏻🌾→"; | ||
| 21 | const data = try GraphemeData.init(std.testing.allocator); | ||
| 22 | defer data.deinit(); | ||
| 23 | |||
| 24 | var iter = grapheme.Iterator.init(peek_seq, &data); | ||
| 25 | const peek_a = iter.peek().?; | ||
| 26 | const next_a = iter.next().?; | ||
| 27 | try std.testing.expectEqual(peek_a, next_a); | ||
| 28 | try std.testing.expectEqualStrings("a", peek_a.bytes(peek_seq)); | ||
| 29 | const peek_d1 = iter.peek().?; | ||
| 30 | const peek_d2 = iter.peek().?; | ||
| 31 | try std.testing.expectEqual(peek_d1, peek_d2); | ||
| 32 | const next_d = iter.next().?; | ||
| 33 | try std.testing.expectEqual(peek_d2, next_d); | ||
| 34 | try std.testing.expectEqual(iter.peek(), iter.next()); | ||
| 35 | try std.testing.expectEqual(iter.peek(), iter.next()); | ||
| 36 | try std.testing.expectEqual(null, iter.peek()); | ||
| 37 | try std.testing.expectEqual(null, iter.peek()); | ||
| 38 | try std.testing.expectEqual(iter.peek(), iter.next()); | ||
| 39 | } | ||
| 40 | |||
| 15 | test "Unicode normalization tests" { | 41 | test "Unicode normalization tests" { |
| 16 | var arena = heap.ArenaAllocator.init(testing.allocator); | 42 | var arena = heap.ArenaAllocator.init(testing.allocator); |
| 17 | defer arena.deinit(); | 43 | defer arena.deinit(); |