summaryrefslogtreecommitdiff
path: root/src/unicode_tests.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/unicode_tests.zig')
-rw-r--r--src/unicode_tests.zig38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/unicode_tests.zig b/src/unicode_tests.zig
index 18f1814..195fdcb 100644
--- a/src/unicode_tests.zig
+++ b/src/unicode_tests.zig
@@ -287,6 +287,25 @@ test "Segmentation Word Iterator" {
287 } else { 287 } else {
288 try testing.expect(false); 288 try testing.expect(false);
289 } 289 }
290 var peek_iter = wb.iterateAfter(this_str, got_word);
291 const peek_1 = peek_iter.next();
292 if (peek_1) |p1| {
293 const peek_2 = iter.peek();
294 if (peek_2) |p2| {
295 std.testing.expectEqualSlices(
296 u8,
297 p1.bytes(this_str),
298 p2.bytes(this_str),
299 ) catch |err| {
300 debug.print("Bad peek on line {d} #{d} offset {d}\n", .{ line_iter.line, idx + 1, idx });
301 return err;
302 };
303 } else {
304 try testing.expect(false);
305 }
306 } else {
307 try testing.expectEqual(null, iter.peek());
308 }
290 for (got_word.offset..got_word.offset + got_word.len) |i| { 309 for (got_word.offset..got_word.offset + got_word.len) |i| {
291 const this_word = wb.wordAtIndex(this_str, i); 310 const this_word = wb.wordAtIndex(this_str, i);
292 std.testing.expectEqualSlices( 311 std.testing.expectEqualSlices(
@@ -337,6 +356,25 @@ test "Segmentation Word Iterator" {
337 } else { 356 } else {
338 try testing.expect(false); 357 try testing.expect(false);
339 } 358 }
359 var peek_iter = wb.iterateBefore(this_str, got_word);
360 const peek_1 = peek_iter.prev();
361 if (peek_1) |p1| {
362 const peek_2 = r_iter.peek();
363 if (peek_2) |p2| {
364 std.testing.expectEqualSlices(
365 u8,
366 p1.bytes(this_str),
367 p2.bytes(this_str),
368 ) catch |err| {
369 debug.print("Bad peek on line {d} #{d} offset {d}\n", .{ line_iter.line, idx + 1, idx });
370 return err;
371 };
372 } else {
373 try testing.expect(false);
374 }
375 } else {
376 try testing.expectEqual(null, r_iter.peek());
377 }
340 for (got_word.offset..got_word.offset + got_word.len) |i| { 378 for (got_word.offset..got_word.offset + got_word.len) |i| {
341 const this_word = wb.wordAtIndex(this_str, i); 379 const this_word = wb.wordAtIndex(this_str, i);
342 std.testing.expectEqualSlices( 380 std.testing.expectEqualSlices(