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

Side by Side Diff: tools/gn/value_unittest.cc

Issue 265693003: Redo GN "args" command (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: create dir Created 6 years, 7 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 | Annotate | Revision Log
« tools/gn/setup.cc ('K') | « tools/gn/value.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 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 "testing/gtest/include/gtest/gtest.h"
6 #include "tools/gn/value.h"
7
8 TEST(Value, ToString) {
9 Value strval(NULL, "hi\" $me\\you\\$\\\"");
10 EXPECT_EQ("hi\" $me\\you\\$\\\"", strval.ToString(false));
11 EXPECT_EQ("\"hi\\\" \\$me\\you\\\\\\$\\\\\\\"\"", strval.ToString(true));
12
13 // Test lists, bools, and ints.
14 Value listval(NULL, Value::LIST);
15 listval.list_value().push_back(Value(NULL, "hi\"me"));
16 listval.list_value().push_back(Value(NULL, true));
17 listval.list_value().push_back(Value(NULL, false));
18 listval.list_value().push_back(Value(NULL, static_cast<int64>(42)));
19 // Printing lists always causes embedded strings to be quoted (ignoring the
20 // quote flag), or else they wouldn't make much sense.
21 EXPECT_EQ("[\"hi\\\"me\", true, false, 42]", listval.ToString(false));
22 EXPECT_EQ("[\"hi\\\"me\", true, false, 42]", listval.ToString(true));
23
24 // Some weird types, we may want to enhance or change printing of these, but
25 // here we test the current behavior.
26 EXPECT_EQ("<void>", Value().ToString(false));
27 EXPECT_EQ("<scope>", Value(NULL, Value::SCOPE).ToString(false));
28 }
OLDNEW
« tools/gn/setup.cc ('K') | « tools/gn/value.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698