26 CBC_DataMatrixWriter writer;
31 static constexpr int kExpectedDimension = 10;
33 static constexpr uint8_t kExpectedData[] = {
34 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
35 1, 1, 0, 1, 1, 0, 1, 0, 0, 1,
36 1, 1, 0, 1, 0, 0, 0, 0, 1, 0,
37 1, 1, 1, 1, 0, 0, 0, 1, 0, 1,
38 1, 0, 1, 0, 0, 0, 1, 0, 0, 0,
39 1, 1, 1, 0, 1, 0, 0, 0, 0, 1,
40 1, 0, 0, 1, 0, 1, 1, 0, 1, 0,
41 1, 0, 1, 0, 1, 1, 1, 1, 0, 1,
42 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
43 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
46 DataVector<uint8_t> data = writer.Encode(L"", &width, &height);
47 ASSERT_EQ(
std::size(kExpectedData), data.size());
48 ASSERT_EQ(kExpectedDimension, width);
49 ASSERT_EQ(kExpectedDimension, height);
50 EXPECT_THAT(data, ElementsAreArray(kExpectedData));
53 static constexpr int kExpectedDimension = 14;
55 static constexpr uint8_t kExpectedData[] = {
56 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
57 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1,
58 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0,
59 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1,
60 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0,
61 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1,
62 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0,
63 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1,
64 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0,
65 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1,
66 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0,
67 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1,
68 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0,
69 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
72 DataVector<uint8_t> data = writer.Encode(L"helloworld", &width, &height);
73 ASSERT_EQ(
std::size(kExpectedData), data.size());
74 ASSERT_EQ(kExpectedDimension, width);
75 ASSERT_EQ(kExpectedDimension, height);
76 EXPECT_THAT(data, ElementsAreArray(kExpectedData));
79 static constexpr int kExpectedDimension = 10;
81 static constexpr uint8_t kExpectedData[] = {
82 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
83 1, 1, 0, 1, 1, 0, 0, 1, 1, 1,
84 1, 1, 0, 0, 0, 1, 0, 1, 1, 0,
85 1, 1, 0, 0, 1, 1, 0, 1, 0, 1,
86 1, 1, 0, 0, 1, 1, 1, 0, 0, 0,
87 1, 0, 0, 0, 0, 1, 1, 1, 1, 1,
88 1, 1, 0, 1, 0, 1, 1, 1, 1, 0,
89 1, 1, 1, 0, 0, 0, 0, 1, 1, 1,
90 1, 1, 0, 1, 1, 0, 0, 1, 0, 0,
91 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
94 DataVector<uint8_t> data = writer.Encode(L"12345", &width, &height);
95 ASSERT_EQ(
std::size(kExpectedData), data.size());
96 ASSERT_EQ(kExpectedDimension, width);
97 ASSERT_EQ(kExpectedDimension, height);
98 EXPECT_THAT(data, ElementsAreArray(kExpectedData));
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 EXPECT_THAT(data, ElementsAreArray(kExpectedData));
132 DataVector<uint8_t> data = writer.Encode(L"hello world", &width, &height);
133 ASSERT_TRUE(data.empty());