Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Unified Diff: ui/base/template_expressions_unittest.cc

Issue 1220793010: [ui/base;css] adding string template expression replacement (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing test code Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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",
Nico 2015/07/09 19:57:46 Add something nested like "${ab${cd}ef}" (I think
dschuyler 2015/07/14 00:56:17 Done.
+ 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

Powered by Google App Engine
This is Rietveld 408576698