add unit test for utils::join_words()

This commit is contained in:
Axel Kohlmeyer
2022-07-05 00:27:28 -04:00
parent f1b14fa4a2
commit 574818c3e9

View File

@ -139,6 +139,24 @@ TEST(Utils, count_words_with_extra_spaces)
ASSERT_EQ(utils::count_words(" some text # comment "), 4);
}
TEST(Utils, join_words)
{
std::vector<std::string> words = {"one", "two", "three" };
auto combined = utils::join_words(words, " ");
ASSERT_THAT(combined, StrEq("one two three"));
combined = utils::join_words(words, "");
ASSERT_THAT(combined, StrEq("onetwothree"));
words[1] = "two ";
combined = utils::join_words(words, "__");
ASSERT_THAT(combined, StrEq("one__two __three"));
words.resize(1);
combined = utils::join_words(words, "/");
ASSERT_THAT(combined, StrEq("one"));
words.push_back("");
combined = utils::join_words(words, "1");
ASSERT_THAT(combined, StrEq("one1"));
}
TEST(Utils, split_words_simple)
{
auto list = utils::split_words("one two three");