blob: defe563afad7e6dff1a0da17ec31db294261613c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
// Copyright 2018 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "xfa/fxfa/fm2js/cxfa_fmexpression.h"
#include <memory>
#include <utility>
#include "core/fxcrt/cfx_widetextbuf.h"
#include "core/fxcrt/fx_string.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/test_support.h"
#include "third_party/base/ptr_util.h"
#include "xfa/fxfa/fm2js/cxfa_fmtojavascriptdepth.h"
TEST(CXFA_FMExpressionTest, VarExpressionInitBlank) {
CXFA_FMToJavaScriptDepth::Reset();
CFX_WideTextBuf accumulator;
auto init = pdfium::MakeUnique<CXFA_FMStringExpression>(L"\"\"");
CXFA_FMVarExpression(L"s", std::move(init))
.ToJavaScript(&accumulator, ReturnType::kInfered);
EXPECT_STREQ(L"var s = \"\";\ns = pfm_rt.var_filter(s);\n",
accumulator.MakeString().c_str());
}
TEST(CXFA_FMExpressionTest, VarExpressionInitString) {
CXFA_FMToJavaScriptDepth::Reset();
CFX_WideTextBuf accumulator;
auto init = pdfium::MakeUnique<CXFA_FMStringExpression>(L"\"foo\"");
CXFA_FMVarExpression(L"s", std::move(init))
.ToJavaScript(&accumulator, ReturnType::kInfered);
EXPECT_STREQ(L"var s = \"foo\";\ns = pfm_rt.var_filter(s);\n",
accumulator.MakeString().c_str());
}
TEST(CXFA_FMExpressionTest, VarExpressionInitNumeric) {
CXFA_FMToJavaScriptDepth::Reset();
CFX_WideTextBuf accumulator;
auto init = pdfium::MakeUnique<CXFA_FMNumberExpression>(L"112");
CXFA_FMVarExpression(L"s", std::move(init))
.ToJavaScript(&accumulator, ReturnType::kInfered);
EXPECT_STREQ(L"var s = 112;\ns = pfm_rt.var_filter(s);\n",
accumulator.MakeString().c_str());
}
|