Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1095)

Side by Side Diff: base/string_util_unittest.cc

Issue 3284005: base: Move SplitStringUsingSubstr functions from string_util.h to string_split.h (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: fix base_unittests Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/string_util.cc ('k') | net/http/http_request_headers.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <math.h> 5 #include <math.h>
6 #include <stdarg.h> 6 #include <stdarg.h>
7 7
8 #include <limits> 8 #include <limits>
9 #include <sstream> 9 #include <sstream>
10 10
(...skipping 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1223 EXPECT_TRUE(ContainsOnlyChars("", "")); 1223 EXPECT_TRUE(ContainsOnlyChars("", ""));
1224 EXPECT_FALSE(ContainsOnlyChars("Hello", "")); 1224 EXPECT_FALSE(ContainsOnlyChars("Hello", ""));
1225 1225
1226 EXPECT_TRUE(ContainsOnlyChars("", "1234")); 1226 EXPECT_TRUE(ContainsOnlyChars("", "1234"));
1227 EXPECT_TRUE(ContainsOnlyChars("1", "1234")); 1227 EXPECT_TRUE(ContainsOnlyChars("1", "1234"));
1228 EXPECT_TRUE(ContainsOnlyChars("1", "4321")); 1228 EXPECT_TRUE(ContainsOnlyChars("1", "4321"));
1229 EXPECT_TRUE(ContainsOnlyChars("123", "4321")); 1229 EXPECT_TRUE(ContainsOnlyChars("123", "4321"));
1230 EXPECT_FALSE(ContainsOnlyChars("123a", "4321")); 1230 EXPECT_FALSE(ContainsOnlyChars("123a", "4321"));
1231 } 1231 }
1232 1232
1233 TEST(SplitStringUsingSubstrTest, EmptyString) {
1234 std::vector<std::string> results;
1235 SplitStringUsingSubstr("", "DELIMITER", &results);
1236 ASSERT_EQ(1u, results.size());
1237 EXPECT_THAT(results, ElementsAre(""));
1238 }
1239
1240 TEST(SplitStringUsingSubstrTest, StringWithNoDelimiter) {
1241 std::vector<std::string> results;
1242 SplitStringUsingSubstr("alongwordwithnodelimiter", "DELIMITER", &results);
1243 ASSERT_EQ(1u, results.size());
1244 EXPECT_THAT(results, ElementsAre("alongwordwithnodelimiter"));
1245 }
1246
1247 TEST(SplitStringUsingSubstrTest, LeadingDelimitersSkipped) {
1248 std::vector<std::string> results;
1249 SplitStringUsingSubstr(
1250 "DELIMITERDELIMITERDELIMITERoneDELIMITERtwoDELIMITERthree",
1251 "DELIMITER",
1252 &results);
1253 ASSERT_EQ(6u, results.size());
1254 EXPECT_THAT(results, ElementsAre("", "", "", "one", "two", "three"));
1255 }
1256
1257 TEST(SplitStringUsingSubstrTest, ConsecutiveDelimitersSkipped) {
1258 std::vector<std::string> results;
1259 SplitStringUsingSubstr(
1260 "unoDELIMITERDELIMITERDELIMITERdosDELIMITERtresDELIMITERDELIMITERcuatro",
1261 "DELIMITER",
1262 &results);
1263 ASSERT_EQ(7u, results.size());
1264 EXPECT_THAT(results, ElementsAre("uno", "", "", "dos", "tres", "", "cuatro"));
1265 }
1266
1267 TEST(SplitStringUsingSubstrTest, TrailingDelimitersSkipped) {
1268 std::vector<std::string> results;
1269 SplitStringUsingSubstr(
1270 "unDELIMITERdeuxDELIMITERtroisDELIMITERquatreDELIMITERDELIMITERDELIMITER",
1271 "DELIMITER",
1272 &results);
1273 ASSERT_EQ(7u, results.size());
1274 EXPECT_THAT(
1275 results, ElementsAre("un", "deux", "trois", "quatre", "", "", ""));
1276 }
1277
1278 } // namespace base 1233 } // namespace base
OLDNEW
« no previous file with comments | « base/string_util.cc ('k') | net/http/http_request_headers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698