// Copyright 2015 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. #include "ui/base/template_expressions.h" #include "testing/gtest/include/gtest/gtest.h" namespace ui { TEST(TemplateExpressionsTest, ReplaceTemplateExpressionsPieces) { TemplateReplacements substitutions; substitutions["test"] = "word"; substitutions["5"] = "number"; EXPECT_EQ("", ReplaceTemplateExpressions("", substitutions)); EXPECT_EQ("word", ReplaceTemplateExpressions("$i18n{test}", substitutions)); EXPECT_EQ("number ", ReplaceTemplateExpressions("$i18n{5} ", substitutions)); EXPECT_EQ("multiple: word, number.", ReplaceTemplateExpressions("multiple: $i18n{test}, $i18n{5}.", substitutions)); } TEST(TemplateExpressionsTest, ReplaceTemplateExpressionsConsecutiveDollarSignsPieces) { TemplateReplacements substitutions; substitutions["a"] = "x"; EXPECT_EQ("$ $$ $$$", ReplaceTemplateExpressions("$ $$ $$$", substitutions)); EXPECT_EQ("$x", ReplaceTemplateExpressions("$$i18n{a}", substitutions)); EXPECT_EQ("$$x", ReplaceTemplateExpressions("$$$i18n{a}", substitutions)); EXPECT_EQ("$i18n12", ReplaceTemplateExpressions("$i18n12", substitutions)); } } // namespace ui