5#include "fxbarcode/oned/BC_OnedCode39Writer.h"
9#include "core/fxcrt/compiler_specific.h"
10#include "core/fxcrt/data_vector.h"
11#include "testing/gtest/include/gtest/gtest.h"
15TEST(OnedCode39WriterTest, SetWideNarrowRatio) {
21 CBC_OnedCode39Writer writer;
31 static const char kExpected1[] =
40 DataVector<uint8_t> encoded = writer.Encode(
"PDFIUM");
41 ASSERT_EQ(strlen(kExpected1), encoded.size());
42 for (size_t i = 0; i < strlen(kExpected1); i++) {
43 UNSAFE_TODO(EXPECT_EQ(kExpected1[i] !=
' ', !!encoded[i])) << i;
47 static const char kExpected2[] =
56 encoded = writer.Encode(
"PDFIUM");
57 ASSERT_EQ(strlen(kExpected2), encoded.size());
58 for (size_t i = 0; i < strlen(kExpected2); i++) {
59 UNSAFE_TODO(EXPECT_EQ(kExpected2[i] !=
' ', !!encoded[i])) << i;
63TEST(OnedCode39WriterTest, Encode) {
64 CBC_OnedCode39Writer writer;
66 static const char kExpected1[] =
69 DataVector<uint8_t> encoded = writer.Encode(
"");
70 ASSERT_EQ(strlen(kExpected1), encoded.size());
71 for (size_t i = 0; i < strlen(kExpected1); i++) {
72 UNSAFE_TODO(EXPECT_EQ(kExpected1[i] !=
' ', !!encoded[i])) << i;
75 static const char kExpected2[] =
81 encoded = writer.Encode(
"123");
82 ASSERT_EQ(strlen(kExpected2), encoded.size());
83 for (size_t i = 0; i < strlen(kExpected2); i++) {
84 UNSAFE_TODO(EXPECT_EQ(kExpected2[i] !=
' ', !!encoded[i])) << i;
87 static const char kExpected3[] =
96 encoded = writer.Encode(
"PDFIUM");
97 ASSERT_EQ(strlen(kExpected3), encoded.size());
98 for (size_t i = 0; i < strlen(kExpected3); i++) {
99 UNSAFE_TODO(EXPECT_EQ(kExpected3[i] !=
' ', !!encoded[i])) << i;
102 static const char kExpected4[] =
114 encoded = writer.Encode(
"A -$%./+Z");
115 ASSERT_EQ(strlen(kExpected4), encoded.size());
116 for (size_t i = 0; i < strlen(kExpected4); i++) {
117 UNSAFE_TODO(EXPECT_EQ(kExpected4[i] !=
' ', !!encoded[i])) << i;
121TEST(OnedCode39WriterTest, Checksum) {
122 CBC_OnedCode39Writer writer;
125 static const char kExpected1[] =
132 DataVector<uint8_t> encoded = writer.Encode(
"123");
133 ASSERT_EQ(strlen(kExpected1), encoded.size());
134 for (size_t i = 0; i < strlen(kExpected1); i++)
135 UNSAFE_TODO(EXPECT_EQ(kExpected1[i] !=
' ', !!encoded[i])) << i;
137 static const char kExpected2[] =
147 encoded = writer.Encode(
"PDFIUM");
148 ASSERT_EQ(strlen(kExpected2), encoded.size());
149 for (size_t i = 0; i < strlen(kExpected2); i++) {
150 UNSAFE_TODO(EXPECT_EQ(kExpected2[i] !=
' ', !!encoded[i])) << i;
void SetCalcChecksum(bool state)
bool SetWideNarrowRatio(int8_t ratio) override