| Index: base/string_split_unittest.cc
|
| diff --git a/base/string_split_unittest.cc b/base/string_split_unittest.cc
|
| index 820f74bad52cbed669fee8021749ba36833b7c0e..f696480b60f2a13187435668b0c89383e9119a6c 100644
|
| --- a/base/string_split_unittest.cc
|
| +++ b/base/string_split_unittest.cc
|
| @@ -3,8 +3,11 @@
|
| // found in the LICENSE file.
|
|
|
| #include "base/string_split.h"
|
| +#include "testing/gmock/include/gmock/gmock.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| +using ::testing::ElementsAre;
|
| +
|
| namespace base {
|
|
|
| class SplitStringIntoKeyValuesTest : public testing::Test {
|
| @@ -129,4 +132,49 @@ TEST_F(SplitStringIntoKeyValuePairsTest, DelimiterInValue) {
|
| EXPECT_EQ("value2", kv_pairs[1].second);
|
| }
|
|
|
| +TEST(SplitStringUsingSubstrTest, EmptyString) {
|
| + std::vector<std::string> results;
|
| + SplitStringUsingSubstr("", "DELIMITER", &results);
|
| + ASSERT_EQ(1u, results.size());
|
| + EXPECT_THAT(results, ElementsAre(""));
|
| +}
|
| +
|
| +TEST(SplitStringUsingSubstrTest, StringWithNoDelimiter) {
|
| + std::vector<std::string> results;
|
| + SplitStringUsingSubstr("alongwordwithnodelimiter", "DELIMITER", &results);
|
| + ASSERT_EQ(1u, results.size());
|
| + EXPECT_THAT(results, ElementsAre("alongwordwithnodelimiter"));
|
| +}
|
| +
|
| +TEST(SplitStringUsingSubstrTest, LeadingDelimitersSkipped) {
|
| + std::vector<std::string> results;
|
| + SplitStringUsingSubstr(
|
| + "DELIMITERDELIMITERDELIMITERoneDELIMITERtwoDELIMITERthree",
|
| + "DELIMITER",
|
| + &results);
|
| + ASSERT_EQ(6u, results.size());
|
| + EXPECT_THAT(results, ElementsAre("", "", "", "one", "two", "three"));
|
| +}
|
| +
|
| +TEST(SplitStringUsingSubstrTest, ConsecutiveDelimitersSkipped) {
|
| + std::vector<std::string> results;
|
| + SplitStringUsingSubstr(
|
| + "unoDELIMITERDELIMITERDELIMITERdosDELIMITERtresDELIMITERDELIMITERcuatro",
|
| + "DELIMITER",
|
| + &results);
|
| + ASSERT_EQ(7u, results.size());
|
| + EXPECT_THAT(results, ElementsAre("uno", "", "", "dos", "tres", "", "cuatro"));
|
| +}
|
| +
|
| +TEST(SplitStringUsingSubstrTest, TrailingDelimitersSkipped) {
|
| + std::vector<std::string> results;
|
| + SplitStringUsingSubstr(
|
| + "unDELIMITERdeuxDELIMITERtroisDELIMITERquatreDELIMITERDELIMITERDELIMITER",
|
| + "DELIMITER",
|
| + &results);
|
| + ASSERT_EQ(7u, results.size());
|
| + EXPECT_THAT(
|
| + results, ElementsAre("un", "deux", "trois", "quatre", "", "", ""));
|
| +}
|
| +
|
| } // namespace base
|
|
|