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

Side by Side Diff: base/string_util_unittest.cc

Issue 3266013: Add unit test for ReplaceStringPlaceholders (Closed) Base URL: git://codf21.jail/chromium.git
Patch Set: 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.h ('k') | no next file » | 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 995 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 subst.push_back("2h"); 1006 subst.push_back("2h");
1007 subst.push_back("1i"); 1007 subst.push_back("1i");
1008 1008
1009 std::string formatted = 1009 std::string formatted =
1010 ReplaceStringPlaceholders( 1010 ReplaceStringPlaceholders(
1011 "$1a,$2b,$3c,$4d,$5e,$6f,$7g,$8h,$9i", subst, NULL); 1011 "$1a,$2b,$3c,$4d,$5e,$6f,$7g,$8h,$9i", subst, NULL);
1012 1012
1013 EXPECT_EQ(formatted, "9aa,8bb,7cc,6dd,5ee,4ff,3gg,2hh,1ii"); 1013 EXPECT_EQ(formatted, "9aa,8bb,7cc,6dd,5ee,4ff,3gg,2hh,1ii");
1014 } 1014 }
1015 1015
1016 TEST(StringUtilTest, ReplaceStringPlaceholdersConsecutiveDollarSigns) {
1017 std::vector<std::string> subst;
1018 subst.push_back("a");
1019 subst.push_back("b");
1020 subst.push_back("c");
1021 EXPECT_EQ(ReplaceStringPlaceholders("$$1 $$$2 $$$$3", subst, NULL),
eroman 2010/08/31 06:37:06 nit: EXPECT_EQ(expected, actual).
1022 "$1 $$2 $$$3");
1023 }
1024
1016 TEST(StringUtilTest, SplitStringAlongWhitespace) { 1025 TEST(StringUtilTest, SplitStringAlongWhitespace) {
1017 struct TestData { 1026 struct TestData {
1018 const std::wstring input; 1027 const std::wstring input;
1019 const size_t expected_result_count; 1028 const size_t expected_result_count;
1020 const std::wstring output1; 1029 const std::wstring output1;
1021 const std::wstring output2; 1030 const std::wstring output2;
1022 } data[] = { 1031 } data[] = {
1023 { L"a", 1, L"a", L"" }, 1032 { L"a", 1, L"a", L"" },
1024 { L" ", 0, L"", L"" }, 1033 { L" ", 0, L"", L"" },
1025 { L" a", 1, L"a", L"" }, 1034 { L" a", 1, L"a", L"" },
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 SplitStringUsingSubstr( 1260 SplitStringUsingSubstr(
1252 "unDELIMITERdeuxDELIMITERtroisDELIMITERquatreDELIMITERDELIMITERDELIMITER", 1261 "unDELIMITERdeuxDELIMITERtroisDELIMITERquatreDELIMITERDELIMITERDELIMITER",
1253 "DELIMITER", 1262 "DELIMITER",
1254 &results); 1263 &results);
1255 ASSERT_EQ(7u, results.size()); 1264 ASSERT_EQ(7u, results.size());
1256 EXPECT_THAT( 1265 EXPECT_THAT(
1257 results, ElementsAre("un", "deux", "trois", "quatre", "", "", "")); 1266 results, ElementsAre("un", "deux", "trois", "quatre", "", "", ""));
1258 } 1267 }
1259 1268
1260 } // namespace base 1269 } // namespace base
OLDNEW
« no previous file with comments | « base/string_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698