5#include "fxbarcode/oned/BC_OnedCode39Writer.h"
9#include "core/fxcrt/data_vector.h"
10#include "testing/gtest/include/gtest/gtest.h"
14TEST(OnedCode39WriterTest, SetWideNarrowRatio) {
20 CBC_OnedCode39Writer writer;
30 static const char kExpected1[] =
39 DataVector<uint8_t> encoded = writer.Encode(
"PDFIUM");
40 ASSERT_EQ(strlen(kExpected1), encoded.size());
41 for (size_t i = 0; i < strlen(kExpected1); i++)
42 EXPECT_EQ(kExpected1[i] !=
' ', !!encoded[i]) << i;
46 static const char kExpected2[] =
55 encoded = writer.Encode(
"PDFIUM");
56 ASSERT_EQ(strlen(kExpected2), encoded.size());
57 for (size_t i = 0; i < strlen(kExpected2); i++)
58 EXPECT_EQ(kExpected2[i] !=
' ', !!encoded[i]) << i;
61TEST(OnedCode39WriterTest, Encode) {
62 CBC_OnedCode39Writer writer;
64 static const char kExpected1[] =
67 DataVector<uint8_t> encoded = writer.Encode(
"");
68 ASSERT_EQ(strlen(kExpected1), encoded.size());
69 for (size_t i = 0; i < strlen(kExpected1); i++)
70 EXPECT_EQ(kExpected1[i] !=
' ', !!encoded[i]) << i;
72 static const char kExpected2[] =
78 encoded = writer.Encode(
"123");
79 ASSERT_EQ(strlen(kExpected2), encoded.size());
80 for (size_t i = 0; i < strlen(kExpected2); i++)
81 EXPECT_EQ(kExpected2[i] !=
' ', !!encoded[i]) << i;
83 static const char kExpected3[] =
92 encoded = writer.Encode(
"PDFIUM");
93 ASSERT_EQ(strlen(kExpected3), encoded.size());
94 for (size_t i = 0; i < strlen(kExpected3); i++)
95 EXPECT_EQ(kExpected3[i] !=
' ', !!encoded[i]) << i;
97 static const char kExpected4[] =
109 encoded = writer.Encode(
"A -$%./+Z");
110 ASSERT_EQ(strlen(kExpected4), encoded.size());
111 for (size_t i = 0; i < strlen(kExpected4); i++)
112 EXPECT_EQ(kExpected4[i] !=
' ', !!encoded[i]) << i;
115TEST(OnedCode39WriterTest, Checksum) {
116 CBC_OnedCode39Writer writer;
119 static const char kExpected1[] =
126 DataVector<uint8_t> encoded = writer.Encode(
"123");
127 ASSERT_EQ(strlen(kExpected1), encoded.size());
128 for (size_t i = 0; i < strlen(kExpected1); i++)
129 EXPECT_EQ(kExpected1[i] !=
' ', !!encoded[i]) << i;
131 static const char kExpected2[] =
141 encoded = writer.Encode(
"PDFIUM");
142 ASSERT_EQ(strlen(kExpected2), encoded.size());
143 for (size_t i = 0; i < strlen(kExpected2); i++)
144 EXPECT_EQ(kExpected2[i] !=
' ', !!encoded[i]) << i;
void SetCalcChecksum(bool state)
bool SetWideNarrowRatio(int8_t ratio) override