From 49f8dc5b1afc4f92110bf40b7639ee1138aa7240 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Mon, 24 Apr 2017 17:34:35 -0700 Subject: Test more OnedCode128WriterTest methods. Change-Id: Ifc6e98af8e9f8505edce8b04836fbe0d6ab5743d Reviewed-on: https://pdfium-review.googlesource.com/4476 Reviewed-by: Tom Sepez Commit-Queue: Lei Zhang --- fxbarcode/oned/BC_OnedCode128Writer_unittest.cpp | 44 ++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/fxbarcode/oned/BC_OnedCode128Writer_unittest.cpp b/fxbarcode/oned/BC_OnedCode128Writer_unittest.cpp index add4696a18..dc3a38f674 100644 --- a/fxbarcode/oned/BC_OnedCode128Writer_unittest.cpp +++ b/fxbarcode/oned/BC_OnedCode128Writer_unittest.cpp @@ -81,4 +81,48 @@ TEST(OnedCode128WriterTest, Encode128C) { } } +TEST(OnedCode128WriterTest, CheckContentValidity) { + { + CBC_OnedCode128Writer writer(BC_CODE128_B); + EXPECT_TRUE(writer.CheckContentValidity(L"")); + EXPECT_TRUE(writer.CheckContentValidity(L"foo")); + EXPECT_TRUE(writer.CheckContentValidity(L"xyz")); + EXPECT_FALSE(writer.CheckContentValidity(L"\"")); + EXPECT_FALSE(writer.CheckContentValidity(L"f\x10oo")); + EXPECT_FALSE(writer.CheckContentValidity(L"bar\x7F")); + EXPECT_FALSE(writer.CheckContentValidity(L"qux\x88")); + } + { + CBC_OnedCode128Writer writer(BC_CODE128_C); + EXPECT_TRUE(writer.CheckContentValidity(L"")); + EXPECT_TRUE(writer.CheckContentValidity(L"foo")); + EXPECT_TRUE(writer.CheckContentValidity(L"xyz")); + EXPECT_FALSE(writer.CheckContentValidity(L"\"")); + EXPECT_FALSE(writer.CheckContentValidity(L"f\x10oo")); + EXPECT_FALSE(writer.CheckContentValidity(L"bar\x7F")); + EXPECT_FALSE(writer.CheckContentValidity(L"qux\x88")); + } +} + +TEST(OnedCode128WriterTest, FilterContents) { + { + CBC_OnedCode128Writer writer(BC_CODE128_B); + EXPECT_STREQ(L"", writer.FilterContents(L"").c_str()); + EXPECT_STREQ(L"foo", writer.FilterContents(L"foo\x10").c_str()); + EXPECT_STREQ(L"fool", writer.FilterContents(L"foo\x10l").c_str()); + EXPECT_STREQ(L"foo", writer.FilterContents(L"foo\x10\x7F").c_str()); + EXPECT_STREQ(L"foo", writer.FilterContents(L"foo\x10\x7F\x88").c_str()); + EXPECT_STREQ(L"bar", writer.FilterContents(L"bar\x10\x7F\x88").c_str()); + } + { + CBC_OnedCode128Writer writer(BC_CODE128_C); + EXPECT_STREQ(L"", writer.FilterContents(L"").c_str()); + EXPECT_STREQ(L"f", writer.FilterContents(L"foo\x10").c_str()); + EXPECT_STREQ(L"f", writer.FilterContents(L"foo\x10l").c_str()); + EXPECT_STREQ(L"f", writer.FilterContents(L"foo\x10\x7F").c_str()); + EXPECT_STREQ(L"f", writer.FilterContents(L"foo\x10\x7F\x88").c_str()); + EXPECT_STREQ(L"ba", writer.FilterContents(L"bar\x10\x7F\x88").c_str()); + } +} + } // namespace -- cgit v1.2.3