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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/base/template_expressions.h"
6
7 #include "testing/gtest/include/gtest/gtest.h"
8
9 namespace ui {
10
11 TEST(TemplateExpressionsTest, ReplaceTemplateExpressions) {
12 std::map<std::string, std::string> substitutions;
13 substitutions["one"] = "9a";
14 substitutions["b"] = "8b";
15 substitutions["cc"] = "7c";
16 substitutions["four"] = "6d";
17 substitutions["very long with spaces"] = "5e";
18 substitutions[""] = "4f";
19 substitutions["&"] = "3g";
20 substitutions["$"] = "2h";
21 substitutions["$$"] = "1i";
22
23 std::string formatted = ReplaceTemplateExpressions(
24 "${one}a,${b}b,${cc}c,${four}d,${very long with "
25 "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.
26 substitutions);
27
28 EXPECT_EQ(formatted, "9aa,8bb,7cc,6dd,5ee,4ff,3gg,2hh,1ii");
29 }
30
31 TEST(TemplateExpressionsTest,
32 ReplaceTemplateExpressionsConsecutiveDollarSigns) {
33 std::map<std::string, std::string> substitutions;
34 substitutions["a"] = "9a";
35 substitutions["b"] = "8b";
36 substitutions["c"] = "7c";
37 EXPECT_EQ(
38 ReplaceTemplateExpressions("$${a} $$${b} $$$${c} $$", substitutions),
39 "${a} $${b} $$${c} $");
40 EXPECT_EQ(ReplaceTemplateExpressions("$12", substitutions), "12");
41 EXPECT_EQ(ReplaceTemplateExpressions("$$", substitutions), "$");
42 EXPECT_EQ(ReplaceTemplateExpressions("$", substitutions), "");
43 }
44
45 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698