5#include "fxbarcode/oned/BC_OnedCode128Writer.h"
9#include "testing/gtest/include/gtest/gtest.h"
20TEST(OnedCode128WriterTest, Encode128B) {
22 static const TestCase kTestCases[] = {
24 {
"a", 169, {104, 65}, 2},
25 {
"1", 121, {104, 17}, 2},
26 {
"a1", 203, {104, 65, 17}, 3},
27 {
"ab", 301, {104, 65, 66}, 3},
28 {
"12", 157, {104, 17, 18}, 3},
29 {
"abc", 502, {104, 65, 66, 67}, 4},
30 {
"123", 214, {104, 17, 18, 19}, 4},
31 {
"abc123", 774, {104, 65, 66, 67, 17, 18, 19}, 7},
32 {
"ABC123", 582, {104, 33, 34, 35, 17, 18, 19}, 7},
33 {
"321ABC", 722, {104, 19, 18, 17, 33, 34, 35}, 7},
34 {
"XYZ", 448, {104, 56, 57, 58}, 4},
36 for (size_t i = 0; i <
std::size(kTestCases); ++i) {
39 const TestCase& test_case = kTestCases[i];
40 std::vector<int32_t> patterns;
42 CBC_OnedCode128Writer::Encode128B(test_case.input, &patterns);
43 EXPECT_EQ(test_case.checksum, checksum);
44 ASSERT_EQ(test_case.num_patterns, patterns.size());
45 for (size_t j = 0; j < patterns.size(); ++j) {
48 EXPECT_EQ(test_case.patterns[j], patterns[j]);
53TEST(OnedCode128WriterTest, Encode128C) {
55 static const TestCase kTestCases[] = {
57 {
"a", 202, {105, 97}, 2},
58 {
"1", 106, {105, 1}, 2},
59 {
"a1", 204, {105, 97, 1}, 3},
60 {
"ab", 398, {105, 97, 98}, 3},
61 {
"12", 117, {105, 12}, 2},
62 {
"abc", 695, {105, 97, 98, 99}, 4},
63 {
"123", 123, {105, 12, 3}, 3},
64 {
"abc123", 758, {105, 97, 98, 99, 12, 3}, 6},
65 {
"ABC123", 566, {105, 65, 66, 67, 12, 3}, 6},
66 {
"321ABC", 933, {105, 32, 1, 65, 66, 67}, 6},
67 {
"XYZ", 641, {105, 88, 89, 90}, 4},
69 for (size_t i = 0; i <
std::size(kTestCases); ++i) {
72 const TestCase& test_case = kTestCases[i];
73 std::vector<int32_t> patterns;
75 CBC_OnedCode128Writer::Encode128C(test_case.input, &patterns);
76 EXPECT_EQ(test_case.checksum, checksum);
77 ASSERT_EQ(test_case.num_patterns, patterns.size());
78 for (size_t j = 0; j < patterns.size(); ++j) {
81 EXPECT_EQ(test_case.patterns[j], patterns[j]);
86TEST(OnedCode128WriterTest, CheckContentValidity) {
109TEST(OnedCode128WriterTest, FilterContents) {
WideString FilterContents(WideStringView contents) override
bool CheckContentValidity(WideStringView contents) override
CBC_OnedCode128Writer(BC_TYPE type)
const wchar_t * c_str() const