summaryrefslogtreecommitdiff
path: root/xfa/fxfa/fm2js/xfa_simpleexpression_unittest.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-04-28 12:09:37 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-04-28 19:26:20 +0000
commit7e93a2c4f3279677ea31db81d85af70c7b3bff5a (patch)
tree1642c5f67eaa08de897a3c4147e9c806cac62131 /xfa/fxfa/fm2js/xfa_simpleexpression_unittest.cpp
parent60cd033adf6c469ff47bdaf85a66b5817fdd188b (diff)
downloadpdfium-7e93a2c4f3279677ea31db81d85af70c7b3bff5a.tar.xz
CXFA_FMStringExpression: int16_t is not a good type for a string index.
Use early return while we're at it. Bug: 716519 Change-Id: I4630d8b6121266c76a53f0171ba6dfd307da725a Reviewed-on: https://pdfium-review.googlesource.com/4611 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'xfa/fxfa/fm2js/xfa_simpleexpression_unittest.cpp')
-rw-r--r--xfa/fxfa/fm2js/xfa_simpleexpression_unittest.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/xfa/fxfa/fm2js/xfa_simpleexpression_unittest.cpp b/xfa/fxfa/fm2js/xfa_simpleexpression_unittest.cpp
index 160c4a12c4..b1b96e03d5 100644
--- a/xfa/fxfa/fm2js/xfa_simpleexpression_unittest.cpp
+++ b/xfa/fxfa/fm2js/xfa_simpleexpression_unittest.cpp
@@ -7,6 +7,7 @@
#include <memory>
#include <utility>
+#include "core/fxcrt/fx_string.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/test_support.h"
#include "third_party/base/ptr_util.h"
@@ -41,3 +42,35 @@ TEST(FMCallExpressionTest, more_than_32_arguments) {
EXPECT_EQ(result.AsStringC(), js.AsStringC());
}
+
+TEST(FMStringExpressionTest, Empty) {
+ CFX_WideTextBuf accumulator;
+ CXFA_FMStringExpression(1, CFX_WideStringC()).ToJavaScript(accumulator);
+ EXPECT_EQ(L"", accumulator.AsStringC());
+}
+
+TEST(FMStringExpressionTest, Short) {
+ CFX_WideTextBuf accumulator;
+ CXFA_FMStringExpression(1, L"a").ToJavaScript(accumulator);
+ EXPECT_EQ(L"a", accumulator.AsStringC());
+}
+
+TEST(FMStringExpressionTest, Medium) {
+ CFX_WideTextBuf accumulator;
+ CXFA_FMStringExpression(1, L".abcd.").ToJavaScript(accumulator);
+ EXPECT_EQ(L"\"abcd\"", accumulator.AsStringC());
+}
+
+TEST(FMStringExpressionTest, Long) {
+ CFX_WideTextBuf accumulator;
+ std::vector<CFX_WideStringC::UnsignedType> vec(140000, L'A');
+ CXFA_FMStringExpression(1, CFX_WideStringC(vec)).ToJavaScript(accumulator);
+ EXPECT_EQ(140000, accumulator.GetLength());
+}
+
+TEST(FMStringExpressionTest, Quoted) {
+ CFX_WideTextBuf accumulator;
+ CXFA_FMStringExpression(1, L".Simon says \"\"run\"\".")
+ .ToJavaScript(accumulator);
+ EXPECT_EQ(L"\"Simon says \\\"run\\\"\"", accumulator.AsStringC());
+}