OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/include/fxcrt/fx_basic.h" | 5 #include "core/include/fxcrt/fx_basic.h" |
6 #include "testing/fx_string_testhelpers.h" | 6 #include "testing/fx_string_testhelpers.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "xfa/src/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.h" | 8 #include "xfa/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.h" |
9 | 9 |
10 TEST(PDF417HighLevelEncoder, EncodeHighLevel) { | 10 TEST(PDF417HighLevelEncoder, EncodeHighLevel) { |
11 // TODO(tsepez): implement test cases. | 11 // TODO(tsepez): implement test cases. |
12 } | 12 } |
13 | 13 |
14 TEST(PDF417HighLevelEncoder, EncodeText) { | 14 TEST(PDF417HighLevelEncoder, EncodeText) { |
15 // TODO(tsepez): implement test cases. | 15 // TODO(tsepez): implement test cases. |
16 } | 16 } |
17 | 17 |
18 TEST(PDF417HighLevelEncoder, EncodeBinary) { | 18 TEST(PDF417HighLevelEncoder, EncodeBinary) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // 800 should encode as 1800 base-900 == 2,0. | 75 // 800 should encode as 1800 base-900 == 2,0. |
76 {L"800", 0, 3, L"\x0002\x0000", 2}, | 76 {L"800", 0, 3, L"\x0002\x0000", 2}, |
77 | 77 |
78 // Test longer strings and sub-strings. | 78 // Test longer strings and sub-strings. |
79 {L"123456", 0, 6, L"\x0001\x015c\x0100", 3}, | 79 {L"123456", 0, 6, L"\x0001\x015c\x0100", 3}, |
80 {L"123456", 0, 5, L"\x007c\x02e9", 2}, | 80 {L"123456", 0, 5, L"\x007c\x02e9", 2}, |
81 {L"123456", 1, 5, L"\x0089\x009c", 2}, | 81 {L"123456", 1, 5, L"\x0089\x009c", 2}, |
82 {L"123456", 2, 2, L"\x0086", 1}, | 82 {L"123456", 2, 2, L"\x0086", 1}, |
83 | 83 |
84 // Up to 44 characters encodes as 15 base-900 words. | 84 // Up to 44 characters encodes as 15 base-900 words. |
85 {L"00000000000000000000000000000000000000000000", | 85 {L"00000000000000000000000000000000000000000000", 0, 44, |
86 0, | |
87 44, | |
88 L"\x01b5\x006f\x02cc\x0084\x01bc\x0076\x00b3\x005c\x01f0\x034f\x01e6" | 86 L"\x01b5\x006f\x02cc\x0084\x01bc\x0076\x00b3\x005c\x01f0\x034f\x01e6" |
89 L"\x0090\x020b\x019b\x0064", | 87 L"\x0090\x020b\x019b\x0064", |
90 15}, | 88 15}, |
91 | 89 |
92 // 45 characters should encode as same 15 words followed by one additional | 90 // 45 characters should encode as same 15 words followed by one additional |
93 // word. | 91 // word. |
94 {L"000000000000000000000000000000000000000000000", | 92 {L"000000000000000000000000000000000000000000000", 0, 45, |
95 0, | |
96 45, | |
97 L"\x01b5\x006f\x02cc\x0084\x01bc\x0076\x00b3\x005c\x01f0\x034f\x01e6" | 93 L"\x01b5\x006f\x02cc\x0084\x01bc\x0076\x00b3\x005c\x01f0\x034f\x01e6" |
98 L"\x0090\x020b\x019b\x0064\x000a", | 94 L"\x0090\x020b\x019b\x0064\x000a", |
99 16}, | 95 16}, |
100 | 96 |
101 // 44 characters followed by 800 should encode as 15 words followed by | 97 // 44 characters followed by 800 should encode as 15 words followed by |
102 // 1800 base-900 == 2,0. | 98 // 1800 base-900 == 2,0. |
103 {L"00000000000000000000000000000000000000000000800", | 99 {L"00000000000000000000000000000000000000000000800", 0, 47, |
104 0, | |
105 47, | |
106 L"\x01b5\x006f\x02cc\x0084\x01bc\x0076\x00b3\x005c\x01f0\x034f\x01e6" | 100 L"\x01b5\x006f\x02cc\x0084\x01bc\x0076\x00b3\x005c\x01f0\x034f\x01e6" |
107 L"\x0090\x020b\x019b\x0064\x0002\x0000", | 101 L"\x0090\x020b\x019b\x0064\x0002\x0000", |
108 17}, | 102 17}, |
109 | 103 |
110 // Even longer input. | 104 // Even longer input. |
111 {L"10000000000000000000000000000000000000000000000000", | 105 {L"10000000000000000000000000000000000000000000000000", 0, 50, |
112 0, | |
113 50, | |
114 L"\x01e0\x02f0\x036d\x02ad\x029c\x01ea\x0011\x000b\x02d6\x023c\x0108" | 106 L"\x01e0\x02f0\x036d\x02ad\x029c\x01ea\x0011\x000b\x02d6\x023c\x0108" |
115 L"\x02bb\x0023\x02d2\x00c8\x0001\x00d3\x0064", | 107 L"\x02bb\x0023\x02d2\x00c8\x0001\x00d3\x0064", |
116 18}, | 108 18}, |
117 }; | 109 }; |
118 | 110 |
119 CBC_PDF417HighLevelEncoder::Initialize(); | 111 CBC_PDF417HighLevelEncoder::Initialize(); |
120 for (size_t i = 0; i < FX_ArraySize(encode_numeric_cases); ++i) { | 112 for (size_t i = 0; i < FX_ArraySize(encode_numeric_cases); ++i) { |
121 EncodeNumericCase* ptr = &encode_numeric_cases[i]; | 113 EncodeNumericCase* ptr = &encode_numeric_cases[i]; |
122 CFX_WideString input(ptr->input); | 114 CFX_WideString input(ptr->input); |
123 CFX_WideString expected(ptr->expected, ptr->expected_length); | 115 CFX_WideString expected(ptr->expected, ptr->expected_length); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 CFX_WideString input(ptr->input); | 222 CFX_WideString input(ptr->input); |
231 int actual_count = | 223 int actual_count = |
232 CBC_PDF417HighLevelEncoder::determineConsecutiveTextCount(input, | 224 CBC_PDF417HighLevelEncoder::determineConsecutiveTextCount(input, |
233 ptr->offset); | 225 ptr->offset); |
234 EXPECT_EQ(ptr->expected_count, actual_count) << " for case number " << i; | 226 EXPECT_EQ(ptr->expected_count, actual_count) << " for case number " << i; |
235 } | 227 } |
236 CBC_PDF417HighLevelEncoder::Finalize(); | 228 CBC_PDF417HighLevelEncoder::Finalize(); |
237 } | 229 } |
238 | 230 |
239 TEST(PDF417HighLevelEncoder, ConsecutiveBinaryCount) {} | 231 TEST(PDF417HighLevelEncoder, ConsecutiveBinaryCount) {} |
OLD | NEW |