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

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

Issue 2530933002: Use unique pointers in CXFA_FMParse (Closed)
Patch Set: You mad Windows? 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
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 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 std::unique_ptr<CXFA_FMIdentifierExpression> exp =
Tom Sepez 2016/11/28 18:09:12 nit: I'd write auto exp = ... since we already hav
npm 2016/11/28 20:04:39 Done.
15 new CXFA_FMIdentifierExpression(0, CFX_WideStringC(L"sign"))); 17 pdfium::MakeUnique<CXFA_FMIdentifierExpression>(0,
18 CFX_WideStringC(L"sign"));
Tom Sepez 2016/11/28 18:09:12 nit: Can we just pass L"sign" (implicit ctor)?
npm 2016/11/28 20:04:39 Done.
16 19
17 std::unique_ptr<CFX_ArrayTemplate<CXFA_FMSimpleExpression*>> args( 20 std::vector<std::unique_ptr<CXFA_FMSimpleExpression>> args;
18 new CFX_ArrayTemplate<CXFA_FMSimpleExpression*>());
19 for (size_t i = 0; i < 50; i++) 21 for (size_t i = 0; i < 50; i++)
20 args->Add(new CXFA_FMSimpleExpression(0, TOKnan)); 22 args.push_back(pdfium::MakeUnique<CXFA_FMSimpleExpression>(0, TOKnan));
21 23
22 CXFA_FMCallExpression callExp(0, exp.release(), args.release(), true); 24 CXFA_FMCallExpression callExp(0, exp.release(), std::move(args), true);
23 CFX_WideTextBuf js; 25 CFX_WideTextBuf js;
24 callExp.ToJavaScript(js); 26 callExp.ToJavaScript(js);
25 27
26 // Generate the result javascript string. 28 // Generate the result javascript string.
27 CFX_WideString result = L"sign("; 29 CFX_WideString result = L"sign(";
28 for (size_t i = 0; i < 50; i++) { 30 for (size_t i = 0; i < 50; i++) {
29 if (i > 0) 31 if (i > 0)
30 result += L", "; 32 result += L", ";
31 33
32 result += L"foxit_xfa_formcalc_runtime.get_fm_"; 34 result += L"foxit_xfa_formcalc_runtime.get_fm_";
33 // Object positions for sign() method. 35 // Object positions for sign() method.
34 if (i == 0 || i == 5 || i == 6) 36 if (i == 0 || i == 5 || i == 6)
35 result += L"jsobj()"; 37 result += L"jsobj()";
36 else 38 else
37 result += L"value()"; 39 result += L"value()";
38 } 40 }
39 result += L")"; 41 result += L")";
40 42
41 EXPECT_EQ(result.AsStringC(), js.AsStringC()); 43 EXPECT_EQ(result.AsStringC(), js.AsStringC());
42 } 44 }
OLDNEW
« xfa/fxfa/fm2js/xfa_simpleexpression.cpp ('K') | « xfa/fxfa/fm2js/xfa_simpleexpression.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698