diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-23 02:25:03 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-23 02:25:03 +0000 |
commit | a6b4150dd637f4b6986a58da63cc0c7192af3cc6 (patch) | |
tree | fae5bcad1ec3ab2681e01930fd700c640fe2c3f7 /base/string_util_unittest.cc | |
parent | 270a0c24f933fb8297389b98efdd035040c6def3 (diff) | |
download | chromium_src-a6b4150dd637f4b6986a58da63cc0c7192af3cc6.zip chromium_src-a6b4150dd637f4b6986a58da63cc0c7192af3cc6.tar.gz chromium_src-a6b4150dd637f4b6986a58da63cc0c7192af3cc6.tar.bz2 |
HttpRequestHeaders refactor.
* Create HttpRequestHeaders.
* Switch HttpNetworkTransaction to build request headers.
TODO: Change extra_headers to use HttpRequestHeaders.
BUG=22588
Review URL: http://codereview.chromium.org/1039001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42300 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/string_util_unittest.cc')
-rw-r--r-- | base/string_util_unittest.cc | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/base/string_util_unittest.cc b/base/string_util_unittest.cc index 78939f5..8fc8f15 100644 --- a/base/string_util_unittest.cc +++ b/base/string_util_unittest.cc @@ -11,8 +11,11 @@ #include "base/basictypes.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" +#include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +using ::testing::ElementsAre; + namespace base { namespace { @@ -1492,4 +1495,49 @@ TEST(StringUtilTest, ContainsOnlyChars) { EXPECT_FALSE(ContainsOnlyChars("123a", "4321")); } -} // base +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 |