authorgravatar for kris.tate+github@gmail.comkristopher tate <kris.tate+github@gmail.com> 2018-11-30 02:17:15+09:00
committergravatar for kris.tate+github@gmail.comkristopher tate <kris.tate+github@gmail.com> 2018-11-30 02:17:15+09:00
logff1b2889f3819610aee17ddbecdf716eb573ca2f
tree067b2e1bf14c6b70460abf53ca619d5dfc82e9a2
parent0f7de58b642539ad6a71368940f43f59a41e71b2
signature Commit is signed but in an unrecognized format.

std.mem: split: test for multiple seperator bytes;


1 files changed, 19 insertions(+), 0 deletions(-)

std/mem.zig+19
......@@ -654,6 +654,16 @@ test "mem.split" {
654654 assert(it.next() == null);
655655}
656656
657test "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
657667/// Returns an iterator that iterates over the slices of `buffer` that
658668/// seperates by bytes in `delimiter`.
659669/// separate("abc|def||ghi", "|")
......@@ -694,7 +704,16 @@ test "mem.separate" {
694704 it = separate("hello", " ");
695705 assert(eql(u8, it.next().?, "hello"));
696706 assert(it.next() == null);
707}
697708
709test "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);
698717}
699718
700719pub fn startsWith(comptime T: type, haystack: []const T, needle: []const T) bool {