5#include "fxbarcode/oned/BC_OnedCodaBarWriter.h"
9#include "core/fxcrt/data_vector.h"
10#include "testing/gtest/include/gtest/gtest.h"
14TEST(OnedCodaBarWriterTest, Encode) {
15 CBC_OnedCodaBarWriter writer;
17 static const char kExpected1[] =
20 DataVector<uint8_t> encoded = writer.Encode(
"");
21 ASSERT_EQ(strlen(kExpected1), encoded.size());
22 for (size_t i = 0; i < strlen(kExpected1); i++)
23 EXPECT_EQ(kExpected1[i] !=
' ', !!encoded[i]) << i;
25 static const char kExpected2[] =
31 encoded = writer.Encode(
"123");
32 ASSERT_EQ(strlen(kExpected2), encoded.size());
33 for (size_t i = 0; i < strlen(kExpected2); i++)
34 EXPECT_EQ(kExpected2[i] !=
' ', !!encoded[i]) << i;
36 static const char kExpected3[] =
45 encoded = writer.Encode(
"-$./:+");
46 ASSERT_EQ(strlen(kExpected3), encoded.size());
47 for (size_t i = 0; i < strlen(kExpected3); i++)
48 EXPECT_EQ(kExpected3[i] !=
' ', !!encoded[i]) << i;
50 static const char kExpected4[] =
70 encoded = writer.Encode(
"456.987987987/001");
71 ASSERT_EQ(strlen(kExpected4), encoded.size());
72 for (size_t i = 0; i < strlen(kExpected4); i++)
73 EXPECT_EQ(kExpected4[i] !=
' ', !!encoded[i]) << i;
76TEST(OnedCodaBarWriterTest, SetDelimiters) {
77 CBC_OnedCodaBarWriter writer;
108 static const char kExpected[] =
114 DataVector<uint8_t> encoded = writer.Encode(
"987");
115 ASSERT_EQ(strlen(kExpected), encoded.size());
116 for (size_t i = 0; i < strlen(kExpected); i++)
117 EXPECT_EQ(kExpected[i] !=
' ', !!encoded[i]) << i;
bool SetEndChar(char end) override
bool SetStartChar(char start) override