| Index: ui/base/template_expressions_unittest.cc
|
| diff --git a/ui/base/template_expressions_unittest.cc b/ui/base/template_expressions_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..f5c363144ff0390a7b893b0d9ef17f397a0511b0
|
| --- /dev/null
|
| +++ b/ui/base/template_expressions_unittest.cc
|
| @@ -0,0 +1,36 @@
|
| +// 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) {
|
| + std::map<base::StringPiece, std::string> substitutions;
|
| + substitutions["test"] = "word";
|
| + substitutions["5"] = "number";
|
| + substitutions[""] = "blank";
|
| +
|
| + EXPECT_EQ(ReplaceTemplateExpressions("${}", substitutions), "blank");
|
| + EXPECT_EQ(ReplaceTemplateExpressions("", substitutions), "");
|
| + EXPECT_EQ(ReplaceTemplateExpressions("${test}", substitutions), "word");
|
| + EXPECT_EQ(ReplaceTemplateExpressions("${5} ", substitutions), "number ");
|
| + EXPECT_EQ(
|
| + ReplaceTemplateExpressions("multiple: ${test}, ${5}.", substitutions),
|
| + "multiple: word, number.");
|
| +}
|
| +
|
| +TEST(TemplateExpressionsTest,
|
| + ReplaceTemplateExpressionsConsecutiveDollarSignsPieces) {
|
| + std::map<base::StringPiece, std::string> substitutions;
|
| + substitutions["a"] = "x";
|
| + EXPECT_EQ(ReplaceTemplateExpressions("$ $$ $$$", substitutions), "$ $$ $$$");
|
| + EXPECT_EQ(ReplaceTemplateExpressions("$${a}", substitutions), "$x");
|
| + EXPECT_EQ(ReplaceTemplateExpressions("$$${a}", substitutions), "$$x");
|
| + EXPECT_EQ(ReplaceTemplateExpressions("$12", substitutions), "$12");
|
| +}
|
| +
|
| +} // namespace ui
|
|
|