summaryrefslogtreecommitdiff
path: root/tools/aapt2/ResourceUtils_test.cpp
diff options
context:
space:
mode:
authorRyan Mitchell <rtmitchell@google.com>2018-06-05 10:15:04 -0700
committerRyan Mitchell <rtmitchell@google.com>2018-06-22 14:06:02 -0700
commitcb76d734fef789bf7246c3c687f3a2d394fe284a (patch)
tree08fbe6e3ae9d727ea9a9030aa1752b9826ce0c55 /tools/aapt2/ResourceUtils_test.cpp
parente42868974bda97f00dfd63559074bb02c1fc6531 (diff)
AAPT2: Fix unrecognized CDATA
This change adds support for resources that have CDATA blocks within their values. The blocks should allow any character to occur without being escaped. It also should not effect the current state of quote processing. Bug: 80326349 Test: Created tests in aapt2_tests Change-Id: Ie1a00e50cffc877e2eb5f788f8d7a1bda839c0cf
Diffstat (limited to 'tools/aapt2/ResourceUtils_test.cpp')
-rw-r--r--tools/aapt2/ResourceUtils_test.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/aapt2/ResourceUtils_test.cpp b/tools/aapt2/ResourceUtils_test.cpp
index 11f3fa3bc6cd..5ce464074335 100644
--- a/tools/aapt2/ResourceUtils_test.cpp
+++ b/tools/aapt2/ResourceUtils_test.cpp
@@ -254,6 +254,29 @@ TEST(ResourceUtilsTest, StringBuilderUnicodeCodes) {
TEST(ResourceUtilsTest, StringBuilderPreserveSpaces) {
EXPECT_THAT(ResourceUtils::StringBuilder(true /*preserve_spaces*/).AppendText("\"").to_string(),
Eq("\""));
+
+ // Single quotes should be able to be used without escaping them when preserving spaces and the
+ // spaces should not be trimmed
+ EXPECT_THAT(ResourceUtils::StringBuilder()
+ .AppendText(" hey guys ")
+ .AppendText(" 'this is so cool' ", /* preserve_spaces */ true)
+ .AppendText(" wow ")
+ .to_string(),
+ Eq(" hey guys 'this is so cool' wow "));
+
+ // Reading a double quote while preserving spaces should not change the quote state
+ EXPECT_THAT(ResourceUtils::StringBuilder()
+ .AppendText(" hey guys ")
+ .AppendText(" \"this is so cool' ", /* preserve_spaces */ true)
+ .AppendText(" wow ")
+ .to_string(),
+ Eq(" hey guys \"this is so cool' wow "));
+ EXPECT_THAT(ResourceUtils::StringBuilder()
+ .AppendText(" hey guys\" ")
+ .AppendText(" \"this is so cool' ", /* preserve_spaces */ true)
+ .AppendText(" wow \" ")
+ .to_string(),
+ Eq(" hey guys \"this is so cool' wow "));
}
} // namespace aapt