12 static constexpr struct EncodeHighLevelCase {
14 const wchar_t* expected;
16 } kEncodeHighLevelCases[] = {
21 {L"\x000b\x000b\x0030", L"\x0385\x000b\x000b\x0030", 4},
24 {L"xxxxxxXx", L"\x0384\x0341\x02c9\x02c9\x02cd\x02c9", 6},
27 {L"xxxxxx!x", L"\x0384\x0341\x02c9\x02c9\x02cf\x0143", 6},
30 {L"xxxxxx0x", L"\x0384\x0341\x02c9\x02c9\x02ce\x001b\x02cf", 7},
33 {L"xxxxxx0X ", L"\x0384\x0341\x02c9\x02c9\x02ce\x001c\x02cc", 7},
36 {L"xxxxxx\x0b", L"\x0384\x0341\x02c9\x02c9\x02cf\x0391\x0385\x000b", 8},
39 {L"0000000000000", L"\x0386\x000f\x00d9\x017b\x000b\x0064", 6},
42 for (size_t i = 0; i <
std::size(kEncodeHighLevelCases); ++i) {
43 const EncodeHighLevelCase& testcase = kEncodeHighLevelCases[i];
44 WideStringView input(testcase.input);
45 WideString expected(testcase.expected, testcase.expected_length);
46 absl::optional<WideString> result =
47 CBC_PDF417HighLevelEncoder::EncodeHighLevel(input);
48 ASSERT_TRUE(result.has_value());
49 EXPECT_EQ(expected, result.value()) <<
" for case number " << i;
58 static constexpr struct EncodeBinaryCase {
63 const wchar_t* expected;
65 } kEncodeBinaryCases[] = {
79 L"\u039c\u00c9\u031f\u012a\u00d2\u02d0", 6},
83 L"\u039c\u00c9\u031f\u012a\u00d2\u02d0", 6},
86 for (size_t i = 0; i <
std::size(kEncodeBinaryCases); ++i) {
87 const EncodeBinaryCase& testcase = kEncodeBinaryCases[i];
88 std::vector<uint8_t> input_array;
89 size_t input_length = strlen(testcase.input);
90 input_array.resize(input_length);
91 for (size_t j = 0; j < input_length; ++j) {
92 input_array[j] = testcase.input[j];
94 WideString expected(testcase.expected, testcase.expected_length);
96 CBC_PDF417HighLevelEncoder::EncodeBinary(input_array, testcase.offset,
97 testcase.count, testcase.startmode,
99 EXPECT_EQ(expected, result) <<
" for case number " << i;
104 static constexpr struct EncodeNumericCase {
105 const wchar_t* input;
108 const wchar_t* expected;
110 } kEncodeNumericCases[] = {
115 {L"0", 0, 1, L"\x000a", 1},
118 {L"800", 0, 3, L"\x0002\x0000", 2},
121 {L"123456", 0, 6, L"\x0001\x015c\x0100", 3},
122 {L"123456", 0, 5, L"\x007c\x02e9", 2},
123 {L"123456", 1, 5, L"\x0089\x009c", 2},
124 {L"123456", 2, 2, L"\x0086", 1},
127 {L"00000000000000000000000000000000000000000000", 0, 44,
128 L"\x01b5\x006f\x02cc\x0084\x01bc\x0076\x00b3\x005c\x01f0\x034f\x01e6"
129 L"\x0090\x020b\x019b\x0064",
134 {L"000000000000000000000000000000000000000000000", 0, 45,
135 L"\x01b5\x006f\x02cc\x0084\x01bc\x0076\x00b3\x005c\x01f0\x034f\x01e6"
136 L"\x0090\x020b\x019b\x0064\x000a",
141 {L"00000000000000000000000000000000000000000000800", 0, 47,
142 L"\x01b5\x006f\x02cc\x0084\x01bc\x0076\x00b3\x005c\x01f0\x034f\x01e6"
143 L"\x0090\x020b\x019b\x0064\x0002\x0000",
147 {L"10000000000000000000000000000000000000000000000000", 0, 50,
148 L"\x01e0\x02f0\x036d\x02ad\x029c\x01ea\x0011\x000b\x02d6\x023c\x0108"
149 L"\x02bb\x0023\x02d2\x00c8\x0001\x00d3\x0064",
153 for (size_t i = 0; i <
std::size(kEncodeNumericCases); ++i) {
154 const EncodeNumericCase& testcase = kEncodeNumericCases[i];
155 WideString input
(testcase.input
);
156 WideString expected(testcase.expected, testcase.expected_length);
158 CBC_PDF417HighLevelEncoder::EncodeNumeric(input, testcase.offset,
159 testcase.count, &result);
160 EXPECT_EQ(expected, result) <<
" for case number " << i;
210 static constexpr struct ConsecutiveTextCase {
211 const wchar_t* input;
214 } kConsecutiveTextCases[] = {
228 {L"ABC\x0001XXXX", 0, 3},
231 {L"ABC\x0100XXXX", 0, 3},
234 {L"ABC\x0001XXXX", 4, 4},
237 {L"ABC\x0100XXXX", 4, 4},
240 {L"\x0100XXX", 0, 0},
243 {L"123456789012", 0, 12},
246 {L"1234567890123", 0, 0},
249 {L"X123456789012", 0, 13},
252 {L"X1234567890123", 0, 1},
255 {L"XXX121XXX12345678901234", 0, 9},
258 for (size_t i = 0; i <
std::size(kConsecutiveTextCases); ++i) {
259 const ConsecutiveTextCase& testcase = kConsecutiveTextCases[i];
260 WideString input
(testcase.input
);
262 CBC_PDF417HighLevelEncoder::DetermineConsecutiveTextCount(
263 input, testcase.offset);
264 EXPECT_EQ(testcase.expected_count, actual_count)
265 <<
" for case number " << i;