zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit ff1b2889f3819610aee17ddbecdf716eb573ca2f (tree)
parent 0f7de58b642539ad6a71368940f43f59a41e71b2
Author: kristopher tate <kris.tate+github@gmail.com>
Date:   Fri, 30 Nov 2018 02:17:15 +0900

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

Diffstat:
Mstd/mem.zig | 19+++++++++++++++++++
1 file changed, 19 insertions(+), 0 deletions(-)

diff --git a/std/mem.zig b/std/mem.zig @@ -654,6 +654,16 @@ test "mem.split" { assert(it.next() == null); } +test "mem.split (multibyte)" { + var it = split("a|b,c/d e", " /,|"); + assert(eql(u8, it.next().?, "a")); + assert(eql(u8, it.next().?, "b")); + assert(eql(u8, it.next().?, "c")); + assert(eql(u8, it.next().?, "d")); + assert(eql(u8, it.next().?, "e")); + assert(it.next() == null); +} + /// Returns an iterator that iterates over the slices of `buffer` that /// seperates by bytes in `delimiter`. /// separate("abc|def||ghi", "|") @@ -694,7 +704,16 @@ test "mem.separate" { it = separate("hello", " "); assert(eql(u8, it.next().?, "hello")); assert(it.next() == null); +} +test "mem.separate (multibyte)" { + var it = separate("a|b,c/d e", " /,|"); + assert(eql(u8, it.next().?, "a")); + assert(eql(u8, it.next().?, "b")); + assert(eql(u8, it.next().?, "c")); + assert(eql(u8, it.next().?, "d")); + assert(eql(u8, it.next().?, "e")); + assert(it.next() == null); } pub fn startsWith(comptime T: type, haystack: []const T, needle: []const T) bool {