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

Unified Diff: base/string_util_unittest.cc

Issue 6877008: Add a unittest case of ReplaceStringPlaceholders() (Closed)
Patch Set: Created 9 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/string_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/string_util_unittest.cc
diff --git a/base/string_util_unittest.cc b/base/string_util_unittest.cc
index cd456429f0a992673309f9fac0ca312d494a5379..47088cf534399308a03198b960d6d88ecd68a9e1 100644
--- a/base/string_util_unittest.cc
+++ b/base/string_util_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -882,19 +882,30 @@ TEST(StringUtilTest, ReplaceStringPlaceholders) {
EXPECT_EQ(formatted, ASCIIToUTF16("9aa,8bb,7cc,6dd,5ee,4ff,3gg,2hh,1ii"));
}
-TEST(StringUtilTest, ReplaceStringPlaceholdersTooFew) {
- // Test whether replacestringplaceholders works as expected when there
- // are fewer inputs than outputs.
Evan Martin 2011/04/19 19:06:46 Is it important to retain the test coverage that t
tony 2011/04/19 19:21:48 Evan is right, we should just add a new test, not
+TEST(StringUtilTest, ReplaceStringPlaceholdersMoreThan9Replacements) {
std::vector<string16> subst;
subst.push_back(ASCIIToUTF16("9a"));
subst.push_back(ASCIIToUTF16("8b"));
subst.push_back(ASCIIToUTF16("7c"));
+ subst.push_back(ASCIIToUTF16("6d"));
+ subst.push_back(ASCIIToUTF16("5e"));
+ subst.push_back(ASCIIToUTF16("4f"));
+ subst.push_back(ASCIIToUTF16("3g"));
+ subst.push_back(ASCIIToUTF16("2h"));
+ subst.push_back(ASCIIToUTF16("1i"));
+ subst.push_back(ASCIIToUTF16("0j"));
+ subst.push_back(ASCIIToUTF16("-1k"));
+ subst.push_back(ASCIIToUTF16("-2l"));
+ subst.push_back(ASCIIToUTF16("-3m"));
+ subst.push_back(ASCIIToUTF16("-4n"));
string16 formatted =
ReplaceStringPlaceholders(
- ASCIIToUTF16("$1a,$2b,$3c,$4d,$5e,$6f,$1g,$2h,$3i"), subst, NULL);
+ ASCIIToUTF16("$1a,$2b,$3c,$4d,$5e,$6f,$7g,$8h,$9i,"
+ "$10j,$11k,$12l,$13m,$14n,$1"), subst, NULL);
- EXPECT_EQ(formatted, ASCIIToUTF16("9aa,8bb,7cc,d,e,f,9ag,8bh,7ci"));
+ EXPECT_EQ(formatted, ASCIIToUTF16("9aa,8bb,7cc,6dd,5ee,4ff,3gg,2hh,"
+ "1ii,0jj,-1kk,-2ll,-3mm,-4nn,9a"));
}
TEST(StringUtilTest, StdStringReplaceStringPlaceholders) {
« no previous file with comments | « base/string_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698