23 CBC_DataMatrixWriter writer;
28 static constexpr int kExpectedDimension = 10;
30 static constexpr uint8_t kExpectedData[] = {
31 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
32 1, 1, 0, 1, 1, 0, 1, 0, 0, 1,
33 1, 1, 0, 1, 0, 0, 0, 0, 1, 0,
34 1, 1, 1, 1, 0, 0, 0, 1, 0, 1,
35 1, 0, 1, 0, 0, 0, 1, 0, 0, 0,
36 1, 1, 1, 0, 1, 0, 0, 0, 0, 1,
37 1, 0, 0, 1, 0, 1, 1, 0, 1, 0,
38 1, 0, 1, 0, 1, 1, 1, 1, 0, 1,
39 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
40 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
43 DataVector<uint8_t> data = writer.Encode(L"", &width, &height);
44 ASSERT_EQ(
std::size(kExpectedData), data.size());
45 ASSERT_EQ(kExpectedDimension, width);
46 ASSERT_EQ(kExpectedDimension, height);
47 for (size_t i = 0; i <
std::size(kExpectedData); ++i)
48 EXPECT_EQ(kExpectedData[i], data[i]) << i;
51 static constexpr int kExpectedDimension = 14;
53 static constexpr uint8_t kExpectedData[] = {
54 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
55 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1,
56 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0,
57 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1,
58 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0,
59 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1,
60 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0,
61 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1,
62 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0,
63 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1,
64 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0,
65 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1,
66 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0,
67 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
70 DataVector<uint8_t> data = writer.Encode(L"helloworld", &width, &height);
71 ASSERT_EQ(
std::size(kExpectedData), data.size());
72 ASSERT_EQ(kExpectedDimension, width);
73 ASSERT_EQ(kExpectedDimension, height);
74 for (size_t i = 0; i <
std::size(kExpectedData); ++i)
75 EXPECT_EQ(kExpectedData[i], data[i]) << i;
78 static constexpr int kExpectedDimension = 10;
80 static constexpr uint8_t kExpectedData[] = {
81 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
82 1, 1, 0, 1, 1, 0, 0, 1, 1, 1,
83 1, 1, 0, 0, 0, 1, 0, 1, 1, 0,
84 1, 1, 0, 0, 1, 1, 0, 1, 0, 1,
85 1, 1, 0, 0, 1, 1, 1, 0, 0, 0,
86 1, 0, 0, 0, 0, 1, 1, 1, 1, 1,
87 1, 1, 0, 1, 0, 1, 1, 1, 1, 0,
88 1, 1, 1, 0, 0, 0, 0, 1, 1, 1,
89 1, 1, 0, 1, 1, 0, 0, 1, 0, 0,
90 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
93 DataVector<uint8_t> data = writer.Encode(L"12345", &width, &height);
94 ASSERT_EQ(
std::size(kExpectedData), data.size());
95 ASSERT_EQ(kExpectedDimension, width);
96 ASSERT_EQ(kExpectedDimension, height);
97 for (size_t i = 0; i <
std::size(kExpectedData); ++i)
98 EXPECT_EQ(kExpectedData[i], data[i]) << i;
101 static constexpr int kExpectedDimension = 18;
103 static constexpr uint8_t kExpectedData[] = {
104 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
105 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1,
106 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0,
107 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1,
108 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0,
109 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1,
110 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0,
111 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1,
112 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0,
113 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1,
114 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0,
115 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1,
116 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0,
117 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1,
118 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0,
119 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1,
120 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0,
121 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
124 DataVector<uint8_t> data =
125 writer.Encode(L"abcdefghijklmnopqrst", &width, &height);
126 ASSERT_EQ(
std::size(kExpectedData), data.size());
127 ASSERT_EQ(kExpectedDimension, width);
128 ASSERT_EQ(kExpectedDimension, height);
129 for (size_t i = 0; i <
std::size(kExpectedData); ++i)
130 EXPECT_EQ(kExpectedData[i], data[i]) << i;
133 DataVector<uint8_t> data = writer.Encode(L"hello world", &width, &height);
134 ASSERT_TRUE(data.empty());