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

Unified Diff: tools/gn/string_utils_unittest.cc

Issue 1546393002: Allow \n in GN string literals (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix documentation line Created 4 years, 11 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/string_utils.cc ('K') | « tools/gn/string_utils.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/string_utils_unittest.cc
diff --git a/tools/gn/string_utils_unittest.cc b/tools/gn/string_utils_unittest.cc
index 4e18eb5c78c7ad92fb4004cfd59978d5434bc160..d62e17e7b81055cf848f8b75a90bb624bfc6ba5b 100644
--- a/tools/gn/string_utils_unittest.cc
+++ b/tools/gn/string_utils_unittest.cc
@@ -69,6 +69,10 @@ TEST(StringUtils, ExpandStringLiteralIdentifier) {
EXPECT_TRUE(CheckExpansionCase("$onescope", "{\n one = 1\n}", true));
EXPECT_TRUE(CheckExpansionCase("$onelist", "[1]", true));
+ // Hex values
+ EXPECT_TRUE(CheckExpansionCase("$0x0AA", "\x0A""A", true));
+ EXPECT_TRUE(CheckExpansionCase("$0x0a$0xfF", "\x0A\xFF", true));
+
// Errors
EXPECT_TRUE(CheckExpansionCase("hello #$", nullptr, false));
EXPECT_TRUE(CheckExpansionCase("hello #$%", nullptr, false));
@@ -76,6 +80,12 @@ TEST(StringUtils, ExpandStringLiteralIdentifier) {
EXPECT_TRUE(CheckExpansionCase("hello #${}", nullptr, false));
EXPECT_TRUE(CheckExpansionCase("hello #$nonexistant", nullptr, false));
EXPECT_TRUE(CheckExpansionCase("hello #${unterminated", nullptr, false));
+ EXPECT_TRUE(CheckExpansionCase("hex truncated: $0", nullptr, false));
+ EXPECT_TRUE(CheckExpansionCase("hex truncated: $0x", nullptr, false));
+ EXPECT_TRUE(CheckExpansionCase("hex truncated: $0x0", nullptr, false));
+ EXPECT_TRUE(CheckExpansionCase("hex with bad char: $0a", nullptr, false));
+ EXPECT_TRUE(CheckExpansionCase("hex with bad char: $0x1z", nullptr, false));
+ EXPECT_TRUE(CheckExpansionCase("hex with bad char: $0xz1", nullptr, false));
// Unknown backslash values aren't special.
EXPECT_TRUE(CheckExpansionCase("\\", "\\", true));
« tools/gn/string_utils.cc ('K') | « tools/gn/string_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698