diff options
author | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-29 21:32:01 +0000 |
---|---|---|
committer | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-29 21:32:01 +0000 |
commit | e4dad5bd72ddd563b84eede80cf2b414ea688b2c (patch) | |
tree | 24aa18551de46887173b800c33e8882bf31e712d /base/string_util_unittest.cc | |
parent | 69877c29ce86be61d54007e5b515415fb05d78f8 (diff) | |
download | chromium_src-e4dad5bd72ddd563b84eede80cf2b414ea688b2c.zip chromium_src-e4dad5bd72ddd563b84eede80cf2b414ea688b2c.tar.gz chromium_src-e4dad5bd72ddd563b84eede80cf2b414ea688b2c.tar.bz2 |
Add a version of ReplaceStringPlaceholders that operates on std::string
instead of string16.
BUG=none
TEST=base unit tests
Original patch by avd@google.com at:
http://codereview.chromium.org/245046
Review URL: http://codereview.chromium.org/242061
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27532 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/string_util_unittest.cc')
-rw-r--r-- | base/string_util_unittest.cc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/base/string_util_unittest.cc b/base/string_util_unittest.cc index b11a999..2723541 100644 --- a/base/string_util_unittest.cc +++ b/base/string_util_unittest.cc @@ -1652,6 +1652,25 @@ TEST(StringUtilTest, ReplaceStringPlaceholdersTooFew) { EXPECT_EQ(formatted, ASCIIToUTF16("9aa,8bb,7cc,d,e,f,9ag,8bh,7ci")); } +TEST(StringUtilTest, StdStringReplaceStringPlaceholders) { + std::vector<std::string> subst; + subst.push_back("9a"); + subst.push_back("8b"); + subst.push_back("7c"); + subst.push_back("6d"); + subst.push_back("5e"); + subst.push_back("4f"); + subst.push_back("3g"); + subst.push_back("2h"); + subst.push_back("1i"); + + std::string formatted = + ReplaceStringPlaceholders( + "$1a,$2b,$3c,$4d,$5e,$6f,$7g,$8h,$9i", subst, NULL); + + EXPECT_EQ(formatted, "9aa,8bb,7cc,6dd,5ee,4ff,3gg,2hh,1ii"); +} + TEST(StringUtilTest, SplitStringAlongWhitespace) { struct TestData { const std::wstring input; |