ODCode39ExtendedModeTest.cpp 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright 2017 Huy Cuong Nguyen
  3. * Copyright 2016 ZXing authors
  4. */
  5. // SPDX-License-Identifier: Apache-2.0
  6. #include "BitArray.h"
  7. #include "BitArrayUtility.h"
  8. #include "ReaderOptions.h"
  9. #include "Barcode.h"
  10. #include "oned/ODCode39Reader.h"
  11. #include "gtest/gtest.h"
  12. using namespace ZXing;
  13. using namespace ZXing::OneD;
  14. static std::string Decode(std::string_view encoded)
  15. {
  16. auto opts = ReaderOptions();
  17. BitArray row = Utility::ParseBitArray(encoded, '1');
  18. auto result = DecodeSingleRow(Code39Reader(opts), row.range());
  19. return result.text(TextMode::Plain);
  20. }
  21. TEST(ODCode39FullASCIITest, Decode)
  22. {
  23. EXPECT_EQ(Decode(
  24. "00000100101101101010100100100101100101010110100100100101011010100101101001001001"
  25. "01010110100101101001001001010110110100101010010010010101010110010110100100100101"
  26. "01101011001010100100100101010110110010101001001001010101010011011010010010010101"
  27. "10101001101010010010010101011010011010100100100101010101100110101001001001010110"
  28. "10101001101001001001010101101010011010010010010101101101010010100100100101010101"
  29. "10100110100100100101011010110100101001001001010101101101001010010010010101010101"
  30. "10011010010010010101101010110010100100100101010110101100101001001001010101011011"
  31. "00101001001001010110010101011010010010010101001101010110100100100101011001101010"
  32. "10100100100101010010110101101001001001010110010110101010010010010101001101101010"
  33. "10100100100101101010010110101001001001010110100101101010010010010110110100101010"
  34. "1001001001010101100101101010010010010110101100101010010110110100000"),
  35. std::string("\x0\x1\x2\x3\x4\x5\x6\x7\x8\x9\xa\xb\xc\xd\xe\xf\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f", 0x20));
  36. EXPECT_EQ(Decode(
  37. "00000100101101101010011010110101001001010010110101001011010010010100101011010010"
  38. "11010010010100101101101001010100100101001010101100101101001001010010110101100101"
  39. "01001001010010101101100101010010010100101010100110110100100101001011010100110101"
  40. "00100101001010110100110101001001010010101011001101010010010100101101010100110100"
  41. "10010100101011010100110100101011011011001010110101001001010010110101101001010100"
  42. "11011010110100101011010110010101101101100101010101001101011011010011010101011001"
  43. "10101010100101101101101001011010101100101101010010010100101001101101010101001001"
  44. "00101011011001010101001001001010101001101101010010010010110101001101010100100100"
  45. "1010110100110101010010010010101011001101010010110110100000"),
  46. " !\"#$%&'()*+,-./0123456789:;<=>?");
  47. EXPECT_EQ(Decode(
  48. "00001001011011010101001001001010011010101101101010010110101101001011011011010010"
  49. "10101011001011011010110010101011011001010101010011011011010100110101011010011010"
  50. "10101100110101101010100110101101010011011011010100101010110100110110101101001010"
  51. "11011010010101010110011011010101100101011010110010101011011001011001010101101001"
  52. "10101011011001101010101001011010110110010110101010011011010101010010010010110101"
  53. "01001101010010010010101101010011010100100100101101101010010101001001001010101101"
  54. "001101010010010010110101101001010010110110100000"),
  55. "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_");
  56. EXPECT_EQ(Decode(
  57. "00000100101101101010100100100101100110101010100101001001011010100101101001010010"
  58. "01010110100101101001010010010110110100101010010100100101010110010110100101001001"
  59. "01101011001010100101001001010110110010101001010010010101010011011010010100100101"
  60. "10101001101010010100100101011010011010100101001001010101100110101001010010010110"
  61. "10101001101001010010010101101010011010010100100101101101010010100101001001010101"
  62. "10100110100101001001011010110100101001010010010101101101001010010100100101010101"
  63. "10011010010100100101101010110010100101001001010110101100101001010010010101011011"
  64. "00101001010010010110010101011010010100100101001101010110100101001001011001101010"
  65. "10100101001001010010110101101001010010010110010110101010010100100101001101101010"
  66. "10100100100101011011010010101001001001010101011001101010010010010110101011001010"
  67. "1001001001010110101100101010010010010101011011001010010110110100000"),
  68. "`abcdefghijklmnopqrstuvwxyz{|}~");
  69. }