Index: webrtc/base/stringencode_unittest.cc |
diff --git a/webrtc/base/stringencode_unittest.cc b/webrtc/base/stringencode_unittest.cc |
index 77fae35fb90da75c840fb263cbe4b7f155fd7b63..406d9c7d4aa599d0d69cbcd51e85f206fb4cec8c 100644 |
--- a/webrtc/base/stringencode_unittest.cc |
+++ b/webrtc/base/stringencode_unittest.cc |
@@ -298,6 +298,22 @@ TEST(TokenizeTest, TokenizeWithMarks) { |
ASSERT_STREQ("E F", fields.at(3).c_str()); |
} |
+TEST(TokenizeTest, TokenizeWithEmptyTokens) { |
+ std::vector<std::string> fields; |
+ EXPECT_EQ(3ul, tokenize_with_empty_tokens("a.b.c", '.', &fields)); |
+ EXPECT_EQ("a", fields[0]); |
+ EXPECT_EQ("b", fields[1]); |
+ EXPECT_EQ("c", fields[2]); |
+ |
+ EXPECT_EQ(3ul, tokenize_with_empty_tokens("..c", '.', &fields)); |
+ EXPECT_TRUE(fields[0].empty()); |
+ EXPECT_TRUE(fields[1].empty()); |
+ EXPECT_EQ("c", fields[2]); |
+ |
+ EXPECT_EQ(1ul, tokenize_with_empty_tokens("", '.', &fields)); |
+ EXPECT_TRUE(fields[0].empty()); |
+} |
+ |
TEST(TokenizeFirstTest, NoLeadingSpaces) { |
std::string token; |
std::string rest; |
@@ -428,4 +444,5 @@ TEST(BoolTest, RoundTrip) { |
EXPECT_TRUE(FromString(ToString(false), &value)); |
EXPECT_FALSE(value); |
} |
+ |
} // namespace rtc |