Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: xfa/fxfa/fm2js/xfa_simpleexpression_unittest.cpp

Issue 2534143003: Use unique_ptr in CFXA_FM expressions (Closed)
Patch Set: Comments Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fxfa/fm2js/xfa_simpleexpression.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include <utility>
9 9
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "third_party/base/ptr_util.h" 11 #include "third_party/base/ptr_util.h"
12 #include "xfa/fxfa/fm2js/xfa_lexer.h" 12 #include "xfa/fxfa/fm2js/xfa_lexer.h"
13 13
14 TEST(FMCallExpression, more_than_32_arguments) { 14 TEST(FMCallExpression, more_than_32_arguments) {
15 // 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.
16 auto exp = pdfium::MakeUnique<CXFA_FMIdentifierExpression>(0, L"sign"); 16 auto exp = pdfium::MakeUnique<CXFA_FMIdentifierExpression>(0, L"sign");
17 17
18 std::vector<std::unique_ptr<CXFA_FMSimpleExpression>> args; 18 std::vector<std::unique_ptr<CXFA_FMSimpleExpression>> args;
19 for (size_t i = 0; i < 50; i++) 19 for (size_t i = 0; i < 50; i++)
20 args.push_back(pdfium::MakeUnique<CXFA_FMSimpleExpression>(0, TOKnan)); 20 args.push_back(pdfium::MakeUnique<CXFA_FMSimpleExpression>(0, TOKnan));
21 21
22 CXFA_FMCallExpression callExp(0, exp.release(), std::move(args), true); 22 CXFA_FMCallExpression callExp(0, std::move(exp), 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 }
OLDNEW
« no previous file with comments | « xfa/fxfa/fm2js/xfa_simpleexpression.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698