tests/utils: Add tests for int split(const char*, const char, std::vector<std::string>&)

This commit is contained in:
Peter Keresztes Schmidt 2021-03-24 09:16:39 +01:00
parent bde0bde066
commit 64cf69ebc1
1 changed files with 17 additions and 0 deletions

View File

@ -71,3 +71,20 @@ TEST_CASE("startsWith") {
REQUIRE(startsWith("test=abc", "test") == true);
REQUIRE(startsWith(" test=abc", "test") == false);
}
TEST_CASE("split (char delimiter)") {
std::vector<std::string> items;
int res;
res = split(nullptr, ' ', items);
REQUIRE(res == -1);
REQUIRE(items.size() == 0);
res = split("", ' ', items);
REQUIRE(res == -2);
REQUIRE(items.size() == 0);
res = split("abc def ghi", ' ', items);
REQUIRE(res == 3);
REQUIRE(items == std::vector<std::string>{"abc", "def", "ghi"});
}