32 v8::Isolate::Scope isolate_scope(isolate());
33 v8::HandleScope handle_scope(isolate());
34 v8::Context::Scope context_scope(GetV8Context());
40 date = CJS_PublicMethods::ParseDateUsingFormat(isolate(), L"06/25/1968",
41 L"mm/dd/yyyy", &bWrongFormat);
42 date = RoundDownDate(date);
43 EXPECT_DOUBLE_EQ(-47865600000, date);
44 EXPECT_FALSE(bWrongFormat);
48 date = CJS_PublicMethods::ParseDateUsingFormat(isolate(), L"25061968",
49 L"ddmmyyyy", &bWrongFormat);
50 date = RoundDownDate(date);
51 EXPECT_DOUBLE_EQ(-47865600000, date);
52 EXPECT_FALSE(bWrongFormat);
56 date = CJS_PublicMethods::ParseDateUsingFormat(isolate(), L"19680625",
57 L"yyyymmdd", &bWrongFormat);
58 date = RoundDownDate(date);
59 EXPECT_DOUBLE_EQ(-47865600000, date);
60 EXPECT_FALSE(bWrongFormat);
64 date = CJS_PublicMethods::ParseDateUsingFormat(isolate(), L"31121985",
65 L"ddmmyyyy", &bWrongFormat);
66 date = RoundDownDate(date);
67 EXPECT_DOUBLE_EQ(504835200000.0, date);
68 EXPECT_FALSE(bWrongFormat);
72 date = CJS_PublicMethods::ParseDateUsingFormat(isolate(), L"311285",
73 L"ddmmyy", &bWrongFormat);
74 date = RoundDownDate(date);
75 EXPECT_DOUBLE_EQ(3660595200000.0, date);
76 EXPECT_FALSE(bWrongFormat);
80 date = CJS_PublicMethods::ParseDateUsingFormat(isolate(), L"01021995",
81 L"ddmmyyyy", &bWrongFormat);
82 date = RoundDownDate(date);
83 EXPECT_DOUBLE_EQ(791596800000.0, date);
84 EXPECT_FALSE(bWrongFormat);
88 date = CJS_PublicMethods::ParseDateUsingFormat(isolate(), L"010295",
89 L"ddmmyy", &bWrongFormat);
90 date = RoundDownDate(date);
91 EXPECT_DOUBLE_EQ(3947356800000.0, date);
92 EXPECT_FALSE(bWrongFormat);
96 date = CJS_PublicMethods::ParseDateUsingFormat(isolate(), L"01022005",
97 L"ddmmyyyy", &bWrongFormat);
98 date = RoundDownDate(date);
99 EXPECT_DOUBLE_EQ(1107216000000.0, date);
100 EXPECT_FALSE(bWrongFormat);
103 bWrongFormat =
false;
104 date = CJS_PublicMethods::ParseDateUsingFormat(isolate(), L"010205",
105 L"ddmmyy", &bWrongFormat);
106 date = RoundDownDate(date);
107 EXPECT_DOUBLE_EQ(1107216000000.0, date);
108 EXPECT_FALSE(bWrongFormat);
111 bWrongFormat =
false;
112 date = CJS_PublicMethods::ParseDateUsingFormat(isolate(), L"050201",
113 L"yymmdd", &bWrongFormat);
114 date = RoundDownDate(date);
115 EXPECT_DOUBLE_EQ(1107216000000.0, date);
116 EXPECT_FALSE(bWrongFormat);
120 v8::Isolate::Scope isolate_scope(isolate());
121 v8::HandleScope handle_scope(isolate());
122 v8::Context::Scope context_scope(GetV8Context());
123 WideString formatted_date;
128 EXPECT_STREQ(L"250668", formatted_date
.c_str());
131 EXPECT_STREQ(L"68/06/25", formatted_date
.c_str());
135 EXPECT_STREQ(L"311269", formatted_date
.c_str());
137 EXPECT_STREQ(L"69!1231", formatted_date
.c_str());
141 EXPECT_STREQ(L"010170", formatted_date
.c_str());
143 EXPECT_STREQ(L"01-1970-01", formatted_date
.c_str());
148 EXPECT_STREQ(L"311285", formatted_date
.c_str());
151 EXPECT_STREQ(L"851231", formatted_date
.c_str());
156 EXPECT_STREQ(L"010295", formatted_date
.c_str());
159 EXPECT_STREQ(L"19950201", formatted_date
.c_str());
164 EXPECT_STREQ(L"010205", formatted_date
.c_str());
167 EXPECT_STREQ(L"20050102", formatted_date
.c_str());
172 EXPECT_STREQ(L"311285", formatted_date
.c_str());
175 EXPECT_STREQ(L"208531", formatted_date
.c_str());
180 EXPECT_STREQ(L"010295", formatted_date
.c_str());
183 EXPECT_STREQ(L"02012095", formatted_date
.c_str());
187 v8::Isolate::Scope isolate_scope(isolate());
188 v8::HandleScope handle_scope(isolate());
189 v8::Context::Scope context_scope(GetV8Context());
191 ASSERT_TRUE(OpenDocument(
"calculate.pdf"));
192 auto* page = LoadPage(0);
196 CPDFSDKFormFillEnvironmentFromFPDFFormHandle(form_handle()));
202 auto ary = runtime.NewArray();
203 runtime.PutArrayElement(ary, 0, runtime.NewString(
"Calc1_A"));
204 runtime.PutArrayElement(ary, 1, runtime.NewString(
"Calc1_B"));
206 v8::LocalVector<v8::Value> params(runtime.GetIsolate());
207 params.push_back(runtime.NewString(
"SUM"));
208 params.push_back(ary);
210 CJS_Result ret = CJS_PublicMethods::AFSimple_Calculate(&runtime, params);
217 ASSERT_EQ(L"7", result);
221 v8::Isolate::Scope isolate_scope(isolate());
222 v8::HandleScope handle_scope(isolate());
223 v8::Context::Scope context_scope(GetV8Context());
225 ASSERT_TRUE(OpenDocument(
"calculate.pdf"));
226 auto* page = LoadPage(0);
230 CPDFSDKFormFillEnvironmentFromFPDFFormHandle(form_handle()));
236 WideString result = L"-10";
237 WideString change = L"";
239 handler->SetValueForTest(&result);
240 handler->SetRCForTest(&valid);
241 handler->SetStrChangeForTest(&change);
243 handler->ResetWillCommitForTest();
244 handler->SetSelStart(0);
245 handler->SetSelEnd(0);
247 v8::LocalVector<v8::Value> params(runtime.GetIsolate());
248 params.push_back(runtime.NewString(
"-10"));
249 params.push_back(runtime.NewString(
""));
251 CJS_Result ret = CJS_PublicMethods::AFNumber_Keystroke(&runtime, params);
260 handler->SetValueForTest(
nullptr);
261 handler->SetRCForTest(
nullptr);
262 handler->SetStrChangeForTest(
nullptr);