Skip to content

Commit

Permalink
Re add StringSplit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
osagie98 committed Oct 1, 2024
1 parent 46d8d39 commit 905668a
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions starboard/common/string_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ TEST(StringTest, SplitString) {
std::string str = "The quick brown fox jumps over the lazy dog";
std::vector<std::string> output = SplitString(str, '.');
ASSERT_EQ(output.size(), 1);
ASSERT_EQ(output[0], "The quick brown fox jumps over the lazy dog");
ASSERT_EQ(output[0], str);

std::vector<std::string> vec = {"The", "quick", "brown", "fox", "jumps",
"over", "the", "lazy", "dog"};
Expand All @@ -43,10 +43,19 @@ TEST(StringTest, SplitString) {
for (int i = 0; i < vec.size(); ++i) {
ASSERT_EQ(output[i], vec[i]);
}
}

str = "";
output = SplitString(str, '.');
EXPECT_TRUE(output.empty());
TEST(StringTest, SplitStringEmptyInput) {
std::string str;
std::vector<std::string> output = SplitString(str, '.');
ASSERT_TRUE(output.empty());
}

TEST(StringTest, SplitStringNullDelimiter) {
std::string str = "The quick brown fox jumps over the lazy dog";
std::vector<std::string> output = SplitString(str, '\0');
ASSERT_EQ(output.size(), 1);
ASSERT_EQ(output[0], str);
}

} // namespace
Expand Down

0 comments on commit 905668a

Please sign in to comment.