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

Unified 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, 8 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
« tools/gn/setup.cc ('K') | « tools/gn/value.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/value_unittest.cc
diff --git a/tools/gn/value_unittest.cc b/tools/gn/value_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a0fdde59660f96d68f0a3fe75b20e3c3269f75a0
--- /dev/null
+++ b/tools/gn/value_unittest.cc
@@ -0,0 +1,28 @@
+// Copyright 2014 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 "testing/gtest/include/gtest/gtest.h"
+#include "tools/gn/value.h"
+
+TEST(Value, ToString) {
+ Value strval(NULL, "hi\" $me\\you\\$\\\"");
+ EXPECT_EQ("hi\" $me\\you\\$\\\"", strval.ToString(false));
+ EXPECT_EQ("\"hi\\\" \\$me\\you\\\\\\$\\\\\\\"\"", strval.ToString(true));
+
+ // Test lists, bools, and ints.
+ Value listval(NULL, Value::LIST);
+ listval.list_value().push_back(Value(NULL, "hi\"me"));
+ listval.list_value().push_back(Value(NULL, true));
+ listval.list_value().push_back(Value(NULL, false));
+ listval.list_value().push_back(Value(NULL, static_cast<int64>(42)));
+ // Printing lists always causes embedded strings to be quoted (ignoring the
+ // quote flag), or else they wouldn't make much sense.
+ EXPECT_EQ("[\"hi\\\"me\", true, false, 42]", listval.ToString(false));
+ EXPECT_EQ("[\"hi\\\"me\", true, false, 42]", listval.ToString(true));
+
+ // Some weird types, we may want to enhance or change printing of these, but
+ // here we test the current behavior.
+ EXPECT_EQ("<void>", Value().ToString(false));
+ EXPECT_EQ("<scope>", Value(NULL, Value::SCOPE).ToString(false));
+}
« 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