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

Unified Diff: tools/gn/input_conversion_unittest.cc

Issue 1048913003: tools/gn: don't allow trailing junk or non-literals in "value" conversion (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clang-format Created 5 years, 9 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
« no previous file with comments | « tools/gn/input_conversion.cc ('k') | tools/gn/parser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/input_conversion_unittest.cc
diff --git a/tools/gn/input_conversion_unittest.cc b/tools/gn/input_conversion_unittest.cc
index 0c2c1c9a6a4a33c9e122fcc64945fb72091723a5..aff66674172f37dda1bf5e34331e4e94850ee07b 100644
--- a/tools/gn/input_conversion_unittest.cc
+++ b/tools/gn/input_conversion_unittest.cc
@@ -141,23 +141,30 @@ TEST_F(InputConversionTest, ValueEmpty) {
}
TEST_F(InputConversionTest, ValueError) {
- Err err;
- std::string input("\n [ \"a\", 5\nfoo bar");
- Value result = ConvertInputToValue(settings(), input, nullptr,
- Value(nullptr, "value"), &err);
- EXPECT_TRUE(err.has_error());
-
- // Blocks not allowed.
- input = "{ foo = 5 }";
- result = ConvertInputToValue(settings(), input, nullptr,
- Value(nullptr, "value"), &err);
- EXPECT_TRUE(err.has_error());
-
- // Function calls not allowed.
- input = "print(5)";
- result = ConvertInputToValue(settings(), input, nullptr,
- Value(nullptr, "value"), &err);
- EXPECT_TRUE(err.has_error());
+ static const char* const kTests[] = {
+ "\n [ \"a\", 5\nfoo bar",
+
+ // Blocks not allowed.
+ "{ foo = 5 }",
+
+ // Function calls not allowed.
+ "print(5)",
+
+ // Trailing junk not allowed.
+ "233105-1",
+
+ // Non-literals hidden in arrays are not allowed.
+ "[233105 - 1]",
+ "[rebase_path(\"//\")]",
+ };
+
+ for (auto test : kTests) {
+ Err err;
+ std::string input(test);
+ Value result = ConvertInputToValue(settings(), input, nullptr,
+ Value(nullptr, "value"), &err);
+ EXPECT_TRUE(err.has_error()) << test;
+ }
}
// Passing none or the empty string for input conversion should ignore the
« no previous file with comments | « tools/gn/input_conversion.cc ('k') | tools/gn/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698