Test FormCalc Encode() function.
It seems the reason these tests have never been enabled is that the
original author never got around to tidying/correcting the test cases.
Change-Id: I58e67b7b004b107996ecee1c696646cb34b7796f
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/62990
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/fxjs/xfa/cfxjse_formcalc_context_embeddertest.cpp b/fxjs/xfa/cfxjse_formcalc_context_embeddertest.cpp
index 77e3880..4b1b4d8 100644
--- a/fxjs/xfa/cfxjse_formcalc_context_embeddertest.cpp
+++ b/fxjs/xfa/cfxjse_formcalc_context_embeddertest.cpp
@@ -1100,16 +1100,25 @@
}
}
-TEST_F(CFXJSE_FormCalcContextEmbedderTest, DISABLED_Encode) {
+TEST_F(CFXJSE_FormCalcContextEmbedderTest, Encode) {
ASSERT_TRUE(OpenDocument("simple_xfa.pdf"));
struct {
const char* program;
const char* result;
} tests[] = {
- {"Encode(\"\"\"hello, world!\"\"\", \"url\")",
- "%%22hello,%%20world!%%22"},
- {"Encode(\"ÁÂÃÄÅÆ\", \"html\")", "ÁÂÃÄÅÆ"}};
+ {"Encode(\"X/~&^*<=>?|\")", "X%2f%7e%26%5e*%3c%3d%3e%3f%7c"},
+ {"Encode(\"X/~&^*<=>?|\", \"mbogo\")", "X%2f%7e%26%5e*%3c%3d%3e%3f%7c"},
+ {"Encode(\"X/~&^*<=>?|\", \"url\")", "X%2f%7e%26%5e*%3c%3d%3e%3f%7c"},
+ {"Encode(\"X/~&^*<=>?|\", \"xml\")", "X/~&^*<=>?|"},
+ {"Encode(\"X/~&^*<=>?|\", \"html\")", "X/~&^*<=>?|"},
+
+ {"Encode(\"\\u0022\\u00f5\\ufed0\")", "%22%f5%fe%d0"},
+ {"Encode(\"\\u0022\\u00f5\\ufed0\", \"mbogo\")", "%22%f5%fe%d0"},
+ {"Encode(\"\\u0022\\u00f5\\ufed0\", \"url\")", "%22%f5%fe%d0"},
+ {"Encode(\"\\u0022\\u00f4\\ufed0\", \"xml\")", ""ôﻐ"},
+ {"Encode(\"\\u0022\\u00f5\\ufed0\", \"html\")", ""õﻐ"},
+ };
for (size_t i = 0; i < FX_ArraySize(tests); ++i) {
EXPECT_TRUE(Execute(tests[i].program));