10 static constexpr struct EncodeHighLevelCase {
12 const wchar_t* expected;
14 } kEncodeHighLevelCases[] = {
19 {L"\x000b\x000b\x0030", L"\x0385\x000b\x000b\x0030", 4},
22 {L"xxxxxxXx", L"\x0384\x0341\x02c9\x02c9\x02cd\x02c9", 6},
25 {L"xxxxxx!x", L"\x0384\x0341\x02c9\x02c9\x02cf\x0143", 6},
28 {L"xxxxxx0x", L"\x0384\x0341\x02c9\x02c9\x02ce\x001b\x02cf", 7},
31 {L"xxxxxx0X ", L"\x0384\x0341\x02c9\x02c9\x02ce\x001c\x02cc", 7},
34 {L"xxxxxx\x0b", L"\x0384\x0341\x02c9\x02c9\x02cf\x0391\x0385\x000b", 8},
37 {L"0000000000000", L"\x0386\x000f\x00d9\x017b\x000b\x0064", 6},
41 for (
const EncodeHighLevelCase& testcase : kEncodeHighLevelCases) {
44 UNSAFE_TODO(WideString(testcase.expected, testcase.expected_length));
46 CBC_PDF417HighLevelEncoder::EncodeHighLevel(input);
47 ASSERT_TRUE(result.has_value());
48 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},
87 for (
const EncodeBinaryCase& testcase : kEncodeBinaryCases) {
89 CBC_PDF417HighLevelEncoder::EncodeBinary(
90 ByteStringView(testcase.input).unsigned_span(), testcase.offset,
91 testcase.count, testcase.startmode, &result);
93 UNSAFE_TODO(WideString(testcase.expected, testcase.expected_length));
94 EXPECT_EQ(expected, result) <<
" for case number " << i;
100 static constexpr struct EncodeNumericCase {
101 const wchar_t* input;
104 const wchar_t* expected;
106 } kEncodeNumericCases[] = {
111 {L"0", 0, 1, L"\x000a", 1},
114 {L"800", 0, 3, L"\x0002\x0000", 2},
117 {L"123456", 0, 6, L"\x0001\x015c\x0100", 3},
118 {L"123456", 0, 5, L"\x007c\x02e9", 2},
119 {L"123456", 1, 5, L"\x0089\x009c", 2},
120 {L"123456", 2, 2, L"\x0086", 1},
123 {L"00000000000000000000000000000000000000000000", 0, 44,
124 L"\x01b5\x006f\x02cc\x0084\x01bc\x0076\x00b3\x005c\x01f0\x034f\x01e6"
125 L"\x0090\x020b\x019b\x0064",
130 {L"000000000000000000000000000000000000000000000", 0, 45,
131 L"\x01b5\x006f\x02cc\x0084\x01bc\x0076\x00b3\x005c\x01f0\x034f\x01e6"
132 L"\x0090\x020b\x019b\x0064\x000a",
137 {L"00000000000000000000000000000000000000000000800", 0, 47,
138 L"\x01b5\x006f\x02cc\x0084\x01bc\x0076\x00b3\x005c\x01f0\x034f\x01e6"
139 L"\x0090\x020b\x019b\x0064\x0002\x0000",
143 {L"10000000000000000000000000000000000000000000000000", 0, 50,
144 L"\x01e0\x02f0\x036d\x02ad\x029c\x01ea\x0011\x000b\x02d6\x023c\x0108"
145 L"\x02bb\x0023\x02d2\x00c8\x0001\x00d3\x0064",
150 for (
const EncodeNumericCase& testcase : kEncodeNumericCases) {
153 UNSAFE_TODO(WideString(testcase.expected, testcase.expected_length));
155 CBC_PDF417HighLevelEncoder::EncodeNumeric(input, testcase.offset,
156 testcase.count, &result);
157 EXPECT_EQ(expected, result) <<
" for case number " << i;
208 static constexpr struct ConsecutiveTextCase {
209 const wchar_t* input;
212 } kConsecutiveTextCases[] = {
226 {L"ABC\x0001XXXX", 0, 3},
229 {L"ABC\x0100XXXX", 0, 3},
232 {L"ABC\x0001XXXX", 4, 4},
235 {L"ABC\x0100XXXX", 4, 4},
238 {L"\x0100XXX", 0, 0},
241 {L"123456789012", 0, 12},
244 {L"1234567890123", 0, 0},
247 {L"X123456789012", 0, 13},
250 {L"X1234567890123", 0, 1},
253 {L"XXX121XXX12345678901234", 0, 9},
257 for (
const ConsecutiveTextCase& testcase : kConsecutiveTextCases) {
260 CBC_PDF417HighLevelEncoder::DetermineConsecutiveTextCount(
261 input, testcase.offset);
262 EXPECT_EQ(testcase.expected_count, actual_count)
263 <<
" for case number " << i;