| 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..6cafb1f095d486f1dc4756cd3081c2ba306b6bf5
|
| --- /dev/null
|
| +++ b/ui/base/template_expressions_unittest.cc
|
| @@ -0,0 +1,45 @@
|
| +// Copyright 2013 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, ReplaceTemplateExpressions) {
|
| + std::map<std::string, std::string> substitutions;
|
| + substitutions["one"] = "9a";
|
| + substitutions["b"] = "8b";
|
| + substitutions["cc"] = "7c";
|
| + substitutions["four"] = "6d";
|
| + substitutions["very long with spaces"] = "5e";
|
| + substitutions[""] = "4f";
|
| + substitutions["&"] = "3g";
|
| + substitutions["$"] = "2h";
|
| + substitutions["$$"] = "1i";
|
| +
|
| + std::string formatted = ReplaceTemplateExpressions(
|
| + "${one}a,${b}b,${cc}c,${four}d,${very long with "
|
| + "spaces}e,${}f,${&}g,${$}h,${$$}i",
|
| + substitutions);
|
| +
|
| + EXPECT_EQ(formatted, "9aa,8bb,7cc,6dd,5ee,4ff,3gg,2hh,1ii");
|
| +}
|
| +
|
| +TEST(TemplateExpressionsTest,
|
| + ReplaceTemplateExpressionsConsecutiveDollarSigns) {
|
| + std::map<std::string, std::string> substitutions;
|
| + substitutions["a"] = "9a";
|
| + substitutions["b"] = "8b";
|
| + substitutions["c"] = "7c";
|
| + EXPECT_EQ(
|
| + ReplaceTemplateExpressions("$${a} $$${b} $$$${c} $$", substitutions),
|
| + "${a} $${b} $$${c} $");
|
| + EXPECT_EQ(ReplaceTemplateExpressions("$12", substitutions), "12");
|
| + EXPECT_EQ(ReplaceTemplateExpressions("$$", substitutions), "$");
|
| + EXPECT_EQ(ReplaceTemplateExpressions("$", substitutions), "");
|
| +}
|
| +
|
| +} // namespace ui
|
|
|