Extend Split to work with multiple separators

This commit is contained in:
Martin Leitner-Ankerl
2022-05-02 21:44:09 +02:00
parent 12455acca2
commit b7ab9db545
3 changed files with 45 additions and 12 deletions

View File

@@ -2396,6 +2396,19 @@ BOOST_AUTO_TEST_CASE(test_SplitString)
BOOST_CHECK_EQUAL(result.size(), 1);
BOOST_CHECK_EQUAL(result[0], "AAA");
}
// multiple split characters
{
using V = std::vector<std::string>;
BOOST_TEST(SplitString("a,b.c:d;e", ",;") == V({"a", "b.c:d", "e"}));
BOOST_TEST(SplitString("a,b.c:d;e", ",;:.") == V({"a", "b", "c", "d", "e"}));
BOOST_TEST(SplitString("a,b.c:d;e", "") == V({"a,b.c:d;e"}));
BOOST_TEST(SplitString("aaa", "bcdefg") == V({"aaa"}));
BOOST_TEST(SplitString("x\0a,b"s, "\0"s) == V({"x", "a,b"}));
BOOST_TEST(SplitString("x\0a,b"s, '\0') == V({"x", "a,b"}));
BOOST_TEST(SplitString("x\0a,b"s, "\0,"s) == V({"x", "a", "b"}));
BOOST_TEST(SplitString("abcdefg", "bcd") == V({"a", "", "", "efg"}));
}
}
BOOST_AUTO_TEST_CASE(test_LogEscapeMessage)