| ... | @@ -654,6 +654,16 @@ test "mem.split" { | ... | @@ -654,6 +654,16 @@ test "mem.split" { |
| 654 | assert(it.next() == null); | 654 | assert(it.next() == null); |
| 655 | } | 655 | } |
| 656 | | 656 | |
| | 657 | test "mem.split (multibyte)" { |
| | 658 | var it = split("a|b,c/d e", " /,|"); |
| | 659 | assert(eql(u8, it.next().?, "a")); |
| | 660 | assert(eql(u8, it.next().?, "b")); |
| | 661 | assert(eql(u8, it.next().?, "c")); |
| | 662 | assert(eql(u8, it.next().?, "d")); |
| | 663 | assert(eql(u8, it.next().?, "e")); |
| | 664 | assert(it.next() == null); |
| | 665 | } |
| | 666 | |
| 657 | /// Returns an iterator that iterates over the slices of `buffer` that | 667 | /// Returns an iterator that iterates over the slices of `buffer` that |
| 658 | /// seperates by bytes in `delimiter`. | 668 | /// seperates by bytes in `delimiter`. |
| 659 | /// separate("abc|def||ghi", "|") | 669 | /// separate("abc|def||ghi", "|") |
| ... | @@ -694,7 +704,16 @@ test "mem.separate" { | ... | @@ -694,7 +704,16 @@ test "mem.separate" { |
| 694 | it = separate("hello", " "); | 704 | it = separate("hello", " "); |
| 695 | assert(eql(u8, it.next().?, "hello")); | 705 | assert(eql(u8, it.next().?, "hello")); |
| 696 | assert(it.next() == null); | 706 | assert(it.next() == null); |
| | 707 | } |
| 697 | | 708 | |
| | 709 | test "mem.separate (multibyte)" { |
| | 710 | var it = separate("a|b,c/d e", " /,|"); |
| | 711 | assert(eql(u8, it.next().?, "a")); |
| | 712 | assert(eql(u8, it.next().?, "b")); |
| | 713 | assert(eql(u8, it.next().?, "c")); |
| | 714 | assert(eql(u8, it.next().?, "d")); |
| | 715 | assert(eql(u8, it.next().?, "e")); |
| | 716 | assert(it.next() == null); |
| 698 | } | 717 | } |
| 699 | | 718 | |
| 700 | pub fn startsWith(comptime T: type, haystack: []const T, needle: []const T) bool { | 719 | pub fn startsWith(comptime T: type, haystack: []const T, needle: []const T) bool { |