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
BC_OnedCodaBarWriter_unittest.cpp
Go to the documentation of this file.
1
// Copyright 2017 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
"fxbarcode/oned/BC_OnedCodaBarWriter.h"
6
7
#
include
<
string
.
h
>
8
9
#
include
"core/fxcrt/compiler_specific.h"
10
#
include
"core/fxcrt/data_vector.h"
11
#
include
"testing/gtest/include/gtest/gtest.h"
12
13
namespace
{
14
15
TEST(OnedCodaBarWriterTest, Encode) {
16
CBC_OnedCodaBarWriter writer;
17
18
static
const
char
kExpected1[] =
19
"# ## # # "
// A Start
20
"# # # ##"
;
// B End
21
DataVector<uint8_t> encoded = writer.Encode(
""
);
22
ASSERT_EQ(strlen(kExpected1), encoded.size());
23
for
(size_t i = 0; i < strlen(kExpected1); i++) {
24
UNSAFE_TODO
(EXPECT_EQ(kExpected1[i] !=
' '
, !!encoded[i])) << i;
25
}
26
static
const
char
kExpected2[] =
27
"# ## # # "
// A Start
28
"# # ## # "
// 1
29
"# # # ## "
// 2
30
"## # # # "
// 3
31
"# # # ##"
;
// B End
32
encoded = writer.Encode(
"123"
);
33
ASSERT_EQ(strlen(kExpected2), encoded.size());
34
for
(size_t i = 0; i < strlen(kExpected2); i++) {
35
UNSAFE_TODO
(EXPECT_EQ(kExpected2[i] !=
' '
, !!encoded[i])) << i;
36
}
37
static
const
char
kExpected3[] =
38
"# ## # # "
// A Start
39
"# # ## # "
// -
40
"# ## # # "
// $
41
"## ## ## # "
// .
42
"## ## # ## "
// /
43
"## # ## ## "
// :
44
"# ## ## ## "
// +
45
"# # # ##"
;
// B End
46
encoded = writer.Encode(
"-$./:+"
);
47
ASSERT_EQ(strlen(kExpected3), encoded.size());
48
for
(size_t i = 0; i < strlen(kExpected3); i++) {
49
UNSAFE_TODO
(EXPECT_EQ(kExpected3[i] !=
' '
, !!encoded[i])) << i;
50
}
51
static
const
char
kExpected4[] =
52
"# ## # # "
// A Start
53
"# ## # # "
// 4
54
"## # # # "
// 5
55
"# # # ## "
// 6
56
"## ## ## # "
// .
57
"## # # # "
// 9
58
"# ## # # "
// 8
59
"# # ## # "
// 7
60
"## # # # "
// 9
61
"# ## # # "
// 8
62
"# # ## # "
// 7
63
"## # # # "
// 9
64
"# ## # # "
// 8
65
"# # ## # "
// 7
66
"## ## # ## "
// /
67
"# # # ## "
// 0
68
"# # # ## "
// 0
69
"# # ## # "
// 1
70
"# # # ##"
;
// B End
71
encoded = writer.Encode(
"456.987987987/001"
);
72
ASSERT_EQ(strlen(kExpected4), encoded.size());
73
for
(size_t i = 0; i < strlen(kExpected4); i++) {
74
UNSAFE_TODO
(EXPECT_EQ(kExpected4[i] !=
' '
, !!encoded[i])) << i;
75
}
76
}
77
78
TEST(OnedCodaBarWriterTest, SetDelimiters) {
79
CBC_OnedCodaBarWriter writer;
80
81
EXPECT_TRUE(writer
.
SetStartChar
(
'A'
)
);
82
EXPECT_TRUE(writer
.
SetStartChar
(
'B'
)
);
83
EXPECT_TRUE(writer
.
SetStartChar
(
'C'
)
);
84
EXPECT_TRUE(writer
.
SetStartChar
(
'D'
)
);
85
EXPECT_TRUE(writer
.
SetStartChar
(
'E'
)
);
86
EXPECT_TRUE(writer
.
SetStartChar
(
'N'
)
);
87
EXPECT_TRUE(writer
.
SetStartChar
(
'T'
)
);
88
EXPECT_TRUE(writer
.
SetStartChar
(
'*'
)
);
89
EXPECT_FALSE(writer
.
SetStartChar
(
'V'
)
);
90
EXPECT_FALSE(writer
.
SetStartChar
(
'0'
)
);
91
EXPECT_FALSE(writer
.
SetStartChar
(
'\0'
)
);
92
EXPECT_FALSE(writer
.
SetStartChar
(
'@'
)
);
93
94
EXPECT_TRUE(writer
.
SetEndChar
(
'A'
)
);
95
EXPECT_TRUE(writer
.
SetEndChar
(
'B'
)
);
96
EXPECT_TRUE(writer
.
SetEndChar
(
'C'
)
);
97
EXPECT_TRUE(writer
.
SetEndChar
(
'D'
)
);
98
EXPECT_TRUE(writer
.
SetEndChar
(
'E'
)
);
99
EXPECT_TRUE(writer
.
SetEndChar
(
'N'
)
);
100
EXPECT_TRUE(writer
.
SetEndChar
(
'T'
)
);
101
EXPECT_TRUE(writer
.
SetEndChar
(
'*'
)
);
102
EXPECT_FALSE(writer
.
SetEndChar
(
'V'
)
);
103
EXPECT_FALSE(writer
.
SetEndChar
(
'0'
)
);
104
EXPECT_FALSE(writer
.
SetEndChar
(
'\0'
)
);
105
EXPECT_FALSE(writer
.
SetEndChar
(
'@'
)
);
106
107
writer
.
SetStartChar
(
'N'
)
;
108
writer
.
SetEndChar
(
'*'
)
;
109
110
static
const
char
kExpected[] =
111
"# # # ## "
// N (same as B) Start
112
"## # # # "
// 9
113
"# ## # # "
// 8
114
"# # ## # "
// 7
115
"# # # ##"
;
// * (same as C) End
116
DataVector<uint8_t> encoded = writer.Encode(
"987"
);
117
ASSERT_EQ(strlen(kExpected), encoded.size());
118
for
(size_t i = 0; i < strlen(kExpected); i++) {
119
UNSAFE_TODO
(EXPECT_EQ(kExpected[i] !=
' '
, !!encoded[i])) << i;
120
}
121
}
122
123
}
// namespace
CBC_OnedCodaBarWriter::SetEndChar
bool SetEndChar(char end) override
Definition
BC_OnedCodaBarWriter.cpp:75
CBC_OnedCodaBarWriter::SetStartChar
bool SetStartChar(char start) override
Definition
BC_OnedCodaBarWriter.cpp:67
UNSAFE_TODO
#define UNSAFE_TODO(...)
Definition
compiler_specific.h:102
qtwebengine
src
3rdparty
chromium
third_party
pdfium
fxbarcode
oned
BC_OnedCodaBarWriter_unittest.cpp
Generated on
for Qt by
1.18.0