diff --git a/tests/zm_utils.cpp b/tests/zm_utils.cpp index 4c44cc68c..6f4214f8d 100644 --- a/tests/zm_utils.cpp +++ b/tests/zm_utils.cpp @@ -88,3 +88,49 @@ TEST_CASE("split (char delimiter)") { REQUIRE(res == 3); REQUIRE(items == std::vector{"abc", "def", "ghi"}); } + +TEST_CASE("split (string delimiter)") { + std::vector items; + + items = split("", ""); + REQUIRE(items == std::vector{""}); + + items = split("", " "); + REQUIRE(items == std::vector{""}); + + items = split("", " \t"); + REQUIRE(items == std::vector{""}); + + items = split("", " \t"); + REQUIRE(items == std::vector{""}); + + items = split(" ", " "); + REQUIRE(items.size() == 0); + + items = split(" ", " "); + REQUIRE(items.size() == 0); + + items = split(" ", " \t"); + REQUIRE(items.size() == 0); + + items = split("a b", ""); + REQUIRE(items == std::vector{"a b"}); + + items = split("a b", " "); + REQUIRE(items == std::vector{"a", "b"}); + + items = split("a \tb", " \t"); + REQUIRE(items == std::vector{"a", "b"}); + + items = split(" a \tb ", " \t"); + REQUIRE(items == std::vector{"a", "b"}); + + items = split(" a=b ", "="); + REQUIRE(items == std::vector{" a", "b "}); + + items = split(" a=b ", " ="); + REQUIRE(items == std::vector{"a", "b"}); + + items = split("a b c", " ", 2); + REQUIRE(items == std::vector{"a", "b c"}); +}