Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
cpdf_defaultappearance_unittest.cpp
Go to the documentation of this file.
1
// Copyright 2018 The PDFium Authors
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
#
include
"core/fpdfdoc/cpdf_defaultappearance.h"
6
7
#
include
<
iterator
>
8
9
#
include
"core/fpdfapi/parser/cpdf_simple_parser.h"
10
#
include
"core/fxcrt/compiler_specific.h"
11
#
include
"core/fxcrt/span.h"
12
#
include
"testing/gtest/include/gtest/gtest.h"
13
#
include
"testing/test_support.h"
14
15
namespace
{
16
17
struct
FindTagTestStruct {
18
pdfium::span<
const
uint8_t> input_span()
const
{
19
// SAFETY: STR_IN_TEST_CASE macro extracts size of literal.
20
return
UNSAFE_BUFFERS
(
pdfium
::make_span(input, input_size));
21
}
22
const
unsigned
char
* input;
23
unsigned
int
input_size;
24
const
char
* token;
25
int
num_params;
26
bool
result;
27
unsigned
int
result_position;
28
};
29
30
}
// namespace
31
32
TEST
(
CPDFDefaultAppearanceTest
,
FindTagParamFromStart
) {
33
const
FindTagTestStruct test_data[] = {
34
// Empty strings.
35
STR_IN_TEST_CASE
(
""
,
"Tj"
, 1,
false
, 0),
36
STR_IN_TEST_CASE
(
""
,
""
, 1,
false
, 0),
37
// Empty token.
38
STR_IN_TEST_CASE
(
" T j"
,
""
, 1,
false
, 5),
39
// No parameter.
40
STR_IN_TEST_CASE
(
"Tj"
,
"Tj"
, 1,
false
, 2),
41
STR_IN_TEST_CASE
(
"(Tj"
,
"Tj"
, 1,
false
, 3),
42
// Partial token match.
43
STR_IN_TEST_CASE
(
"\r12\t34 56 78Tj"
,
"Tj"
, 1,
false
, 15),
44
// Regular cases with various parameters.
45
STR_IN_TEST_CASE
(
"\r\0abd Tj"
,
"Tj"
, 1,
true
, 0),
46
STR_IN_TEST_CASE
(
"12 4 Tj 3 46 Tj"
,
"Tj"
, 1,
true
, 2),
47
STR_IN_TEST_CASE
(
"er^ 2 (34) (5667) Tj"
,
"Tj"
, 2,
true
, 5),
48
STR_IN_TEST_CASE
(
"<344> (232)\t343.4\n12 45 Tj"
,
"Tj"
, 3,
true
, 11),
49
STR_IN_TEST_CASE
(
"1 2 3 4 5 6 7 8 cm"
,
"cm"
, 6,
true
, 3),
50
};
51
52
for
(
const
auto
& item : test_data) {
53
CPDF_SimpleParser
parser(item.input_span());
54
EXPECT_EQ(item.result,
55
CPDF_DefaultAppearance
::
FindTagParamFromStartForTesting
(
56
&parser, item.token, item.num_params))
57
<<
" for case "
<< item.input;
58
EXPECT_EQ(item.result_position, parser
.
GetCurrentPosition
(
)
)
59
<<
" for case "
<< item.input;
60
}
61
}
CPDF_DefaultAppearance
Definition
cpdf_defaultappearance.h:17
CPDF_DefaultAppearance::FindTagParamFromStartForTesting
static bool FindTagParamFromStartForTesting(CPDF_SimpleParser *parser, ByteStringView token, int nParams)
Definition
cpdf_defaultappearance.cpp:139
CPDF_SimpleParser
Definition
cpdf_simple_parser.h:17
CPDF_SimpleParser::GetCurrentPosition
uint32_t GetCurrentPosition() const
Definition
cpdf_simple_parser.h:25
pdfium::CFDETextOutLargeBitmapTest
Definition
cfde_textout_unittest.cpp:117
UNSAFE_BUFFERS
#define UNSAFE_BUFFERS(...)
Definition
compiler_specific.h:95
TEST
TEST(FXCRYPT, MD5GenerateEmtpyData)
Definition
fx_crypt_unittest.cpp:50
STR_IN_TEST_CASE
#define STR_IN_TEST_CASE(input_literal,...)
Definition
test_support.h:15
qtwebengine
src
3rdparty
chromium
third_party
pdfium
core
fpdfdoc
cpdf_defaultappearance_unittest.cpp
Generated on
for Qt by
1.18.0