OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "xfa/fxfa/fm2js/xfa_simpleexpression.h" | 5 #include "xfa/fxfa/fm2js/xfa_simpleexpression.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> |
8 | 9 |
9 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "third_party/base/ptr_util.h" |
10 #include "xfa/fxfa/fm2js/xfa_lexer.h" | 12 #include "xfa/fxfa/fm2js/xfa_lexer.h" |
11 | 13 |
12 TEST(FMCallExpression, more_than_32_arguments) { | 14 TEST(FMCallExpression, more_than_32_arguments) { |
13 // Use sign as it has 3 object parameters at positions 0, 5, and 6. | 15 // Use sign as it has 3 object parameters at positions 0, 5, and 6. |
14 std::unique_ptr<CXFA_FMIdentifierExpression> exp( | 16 auto exp = pdfium::MakeUnique<CXFA_FMIdentifierExpression>(0, L"sign"); |
15 new CXFA_FMIdentifierExpression(0, CFX_WideStringC(L"sign"))); | |
16 | 17 |
17 std::unique_ptr<CFX_ArrayTemplate<CXFA_FMSimpleExpression*>> args( | 18 std::vector<std::unique_ptr<CXFA_FMSimpleExpression>> args; |
18 new CFX_ArrayTemplate<CXFA_FMSimpleExpression*>()); | |
19 for (size_t i = 0; i < 50; i++) | 19 for (size_t i = 0; i < 50; i++) |
20 args->Add(new CXFA_FMSimpleExpression(0, TOKnan)); | 20 args.push_back(pdfium::MakeUnique<CXFA_FMSimpleExpression>(0, TOKnan)); |
21 | 21 |
22 CXFA_FMCallExpression callExp(0, exp.release(), args.release(), true); | 22 CXFA_FMCallExpression callExp(0, exp.release(), std::move(args), true); |
23 CFX_WideTextBuf js; | 23 CFX_WideTextBuf js; |
24 callExp.ToJavaScript(js); | 24 callExp.ToJavaScript(js); |
25 | 25 |
26 // Generate the result javascript string. | 26 // Generate the result javascript string. |
27 CFX_WideString result = L"sign("; | 27 CFX_WideString result = L"sign("; |
28 for (size_t i = 0; i < 50; i++) { | 28 for (size_t i = 0; i < 50; i++) { |
29 if (i > 0) | 29 if (i > 0) |
30 result += L", "; | 30 result += L", "; |
31 | 31 |
32 result += L"foxit_xfa_formcalc_runtime.get_fm_"; | 32 result += L"foxit_xfa_formcalc_runtime.get_fm_"; |
33 // Object positions for sign() method. | 33 // Object positions for sign() method. |
34 if (i == 0 || i == 5 || i == 6) | 34 if (i == 0 || i == 5 || i == 6) |
35 result += L"jsobj()"; | 35 result += L"jsobj()"; |
36 else | 36 else |
37 result += L"value()"; | 37 result += L"value()"; |
38 } | 38 } |
39 result += L")"; | 39 result += L")"; |
40 | 40 |
41 EXPECT_EQ(result.AsStringC(), js.AsStringC()); | 41 EXPECT_EQ(result.AsStringC(), js.AsStringC()); |
42 } | 42 } |
OLD | NEW |