diff options
Diffstat (limited to 'src/unicode_tests.zig')
| -rw-r--r-- | src/unicode_tests.zig | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/unicode_tests.zig b/src/unicode_tests.zig index 946c197..50b8824 100644 --- a/src/unicode_tests.zig +++ b/src/unicode_tests.zig | |||
| @@ -255,8 +255,6 @@ test "Segmentation GraphemeIterator" { | |||
| 255 | test "Segmentation Word Iterator" { | 255 | test "Segmentation Word Iterator" { |
| 256 | const allocator = std.testing.allocator; | 256 | const allocator = std.testing.allocator; |
| 257 | var reader = std.io.Reader.fixed(@embedFile("WordBreakTest.txt")); | 257 | var reader = std.io.Reader.fixed(@embedFile("WordBreakTest.txt")); |
| 258 | const wb = try Words.init(allocator); | ||
| 259 | defer wb.deinit(allocator); | ||
| 260 | 258 | ||
| 261 | var line_iter: IterRead = .{ .read = &reader }; | 259 | var line_iter: IterRead = .{ .read = &reader }; |
| 262 | 260 | ||
| @@ -297,7 +295,7 @@ test "Segmentation Word Iterator" { | |||
| 297 | const this_str = all_bytes.items; | 295 | const this_str = all_bytes.items; |
| 298 | 296 | ||
| 299 | { | 297 | { |
| 300 | var iter = wb.iterator(this_str); | 298 | var iter = Words.iterator(this_str); |
| 301 | var peeked: ?Word = iter.peek(); | 299 | var peeked: ?Word = iter.peek(); |
| 302 | 300 | ||
| 303 | // Check. | 301 | // Check. |
| @@ -330,7 +328,7 @@ test "Segmentation Word Iterator" { | |||
| 330 | } else { | 328 | } else { |
| 331 | try testing.expect(false); | 329 | try testing.expect(false); |
| 332 | } | 330 | } |
| 333 | var peek_iter = wb.iterateAfterWord(this_str, got_word); | 331 | var peek_iter = Words.iterateAfterWord(this_str, got_word); |
| 334 | const peek_1 = peek_iter.next(); | 332 | const peek_1 = peek_iter.next(); |
| 335 | if (peek_1) |p1| { | 333 | if (peek_1) |p1| { |
| 336 | const peek_2 = iter.peek(); | 334 | const peek_2 = iter.peek(); |
| @@ -350,7 +348,7 @@ test "Segmentation Word Iterator" { | |||
| 350 | try testing.expectEqual(null, iter.peek()); | 348 | try testing.expectEqual(null, iter.peek()); |
| 351 | } | 349 | } |
| 352 | for (got_word.offset..got_word.offset + got_word.len) |i| { | 350 | for (got_word.offset..got_word.offset + got_word.len) |i| { |
| 353 | const this_word = wb.wordAtIndex(this_str, i); | 351 | const this_word = Words.wordAtIndex(this_str, i); |
| 354 | std.testing.expectEqualSlices( | 352 | std.testing.expectEqualSlices( |
| 355 | u8, | 353 | u8, |
| 356 | got_word.bytes(this_str), | 354 | got_word.bytes(this_str), |
| @@ -364,7 +362,7 @@ test "Segmentation Word Iterator" { | |||
| 364 | } | 362 | } |
| 365 | } | 363 | } |
| 366 | { | 364 | { |
| 367 | var r_iter = wb.reverseIterator(this_str); | 365 | var r_iter = Words.reverseIterator(this_str); |
| 368 | var peeked: ?Word = r_iter.peek(); | 366 | var peeked: ?Word = r_iter.peek(); |
| 369 | var idx = want.items.len - 1; | 367 | var idx = want.items.len - 1; |
| 370 | 368 | ||
| @@ -399,7 +397,7 @@ test "Segmentation Word Iterator" { | |||
| 399 | } else { | 397 | } else { |
| 400 | try testing.expect(false); | 398 | try testing.expect(false); |
| 401 | } | 399 | } |
| 402 | var peek_iter = wb.iterateBeforeWord(this_str, got_word); | 400 | var peek_iter = Words.iterateBeforeWord(this_str, got_word); |
| 403 | const peek_1 = peek_iter.prev(); | 401 | const peek_1 = peek_iter.prev(); |
| 404 | if (peek_1) |p1| { | 402 | if (peek_1) |p1| { |
| 405 | const peek_2 = r_iter.peek(); | 403 | const peek_2 = r_iter.peek(); |
| @@ -419,7 +417,7 @@ test "Segmentation Word Iterator" { | |||
| 419 | try testing.expectEqual(null, r_iter.peek()); | 417 | try testing.expectEqual(null, r_iter.peek()); |
| 420 | } | 418 | } |
| 421 | for (got_word.offset..got_word.offset + got_word.len) |i| { | 419 | for (got_word.offset..got_word.offset + got_word.len) |i| { |
| 422 | const this_word = wb.wordAtIndex(this_str, i); | 420 | const this_word = Words.wordAtIndex(this_str, i); |
| 423 | std.testing.expectEqualSlices( | 421 | std.testing.expectEqualSlices( |
| 424 | u8, | 422 | u8, |
| 425 | got_word.bytes(this_str), | 423 | got_word.bytes(this_str), |