1 // Copyright (C) 2014 Google Inc.
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 // License for the specific language governing permissions and limitations under
15 #include "util/string_util.h"
20 #include <gtest/gtest.h>
24 using i18n::addressinput::DoReplaceStringPlaceholders;
26 TEST(StringUtilTest, Ok) {
27 std::vector<std::string> subst;
33 DoReplaceStringPlaceholders("a$1,b$2,c$3", subst));
36 TEST(StringUtilTest, FewParameters) {
37 std::vector<std::string> subst;
42 EXPECT_EQ("aA,bB,cC,d,aA",
43 DoReplaceStringPlaceholders("a$1,b$2,c$3,d$4,a$1", subst));
46 TEST(StringUtilTest, MoreThan9Parameters) {
47 std::vector<std::string> subst;
60 EXPECT_EQ("aA,bB,cC,dD,eE,fF,gG,hH,iI,jJ,kK,aA",
61 DoReplaceStringPlaceholders("a$1,b$2,c$3,d$4,e$5,f$6,g$7,h$8,i$9,"
62 "j$10,k$11,a$1", subst));
65 TEST(StringUtilTest, ConsecutiveDollarSigns) {
66 std::vector<std::string> subst;
71 EXPECT_EQ("$1 $$2 $$$3",
72 DoReplaceStringPlaceholders("$$1 $$$2 $$$$3", subst));