From c11bf4882a8bd7f0f611650cbd5b6bb69f31b9a4 Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Wed, 24 May 2017 21:58:48 -0400 Subject: Enable FM2JSContext Choose tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This Cl enables the Choose tests for FM2JSContext. The Choose tests always return a String. Change-Id: I29b3ce4ed38f94886c6036f3766182fecb6e787b Reviewed-on: https://pdfium-review.googlesource.com/5893 Reviewed-by: Nicolás Peña Commit-Queue: dsinclair --- xfa/fxfa/fm2js/cxfa_fm2jscontext_embeddertest.cpp | 33 ++++++++++++----------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/xfa/fxfa/fm2js/cxfa_fm2jscontext_embeddertest.cpp b/xfa/fxfa/fm2js/cxfa_fm2jscontext_embeddertest.cpp index e9120dc3a0..a30a81742e 100644 --- a/xfa/fxfa/fm2js/cxfa_fm2jscontext_embeddertest.cpp +++ b/xfa/fxfa/fm2js/cxfa_fm2jscontext_embeddertest.cpp @@ -797,26 +797,27 @@ TEST_F(FM2JSContextEmbedderTest, Term) { } } -TEST_F(FM2JSContextEmbedderTest, DISABLED_Choose) { +TEST_F(FM2JSContextEmbedderTest, Choose) { ASSERT_TRUE(OpenDocument("simple_xfa.pdf")); - EXPECT_TRUE( - Execute("Choose(3, \"Taxes\", \"Price\", \"Person\", \"Teller\")")); - CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsString()); - EXPECT_STREQ("Person", value->ToString().c_str()); + struct { + const char* program; + const char* result; + } tests[] = { + {"Choose(3, \"Taxes\", \"Price\", \"Person\", \"Teller\")", "Person"}, + {"Choose(2, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)", "9"}, + {"Choose(20/3, \"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\", \"H\")", + "F"}}; - EXPECT_TRUE(Execute("Choose(2, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)")); - value = GetValue(); - EXPECT_TRUE(value->IsInteger()); - EXPECT_EQ(9, value->ToInteger()); + for (size_t i = 0; i < FX_ArraySize(tests); ++i) { + EXPECT_TRUE(Execute(tests[i].program)); - EXPECT_TRUE(Execute( - "Choose(20/3, \"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\", \"H\")")); - value = GetValue(); - EXPECT_TRUE(value->IsString()); - EXPECT_STREQ("F", value->ToString().c_str()) - << " Result: '" << value->ToString().c_str() << "'"; + CFXJSE_Value* value = GetValue(); + EXPECT_TRUE(value->IsString()); + EXPECT_STREQ(tests[i].result, value->ToString().c_str()) + << "Program: " << tests[i].program << " Result: '" + << value->ToString().c_str() << "'"; + } } TEST_F(FM2JSContextEmbedderTest, DISABLED_Exists) { -- cgit v1.2.3