ODCode93ReaderTest.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * Copyright 2017 Huy Cuong Nguyen
  3. * Copyright 2016 ZXing authors
  4. */
  5. // SPDX-License-Identifier: Apache-2.0
  6. #include "oned/ODCode93Reader.h"
  7. #include "BitArray.h"
  8. #include "BitArrayUtility.h"
  9. #include "ReaderOptions.h"
  10. #include "Barcode.h"
  11. #include "gtest/gtest.h"
  12. using namespace ZXing;
  13. using namespace ZXing::OneD;
  14. static std::string Decode(std::string_view input)
  15. {
  16. ReaderOptions opts;
  17. auto row = Utility::ParseBitArray(input, '1');
  18. auto result = DecodeSingleRow(Code93Reader(opts), row.range());
  19. return result.text(TextMode::Plain);
  20. }
  21. TEST(ODCode93ReaderTest, Decode)
  22. {
  23. auto expected = std::string("Code93!\n$%/+ :\x1b;[{\x7f\x00@`\x7f\x7f\x7f", 25);
  24. auto decoded = Decode(
  25. "00000010101111011010001010011001010010110010011001011001010010011001011001001010"
  26. "00010101010000101110101101101010001001001101001101001110010101101011101011011101"
  27. "01110110111010010111010110100111010111011010110101000111011010110001010111011010"
  28. "10001101011101101010001011011101101011010011011101101011001011011101101011001101"
  29. "01110110101011011001110110101011001101110110101001101101110110101001110101001100"
  30. "10110101000101011110100000");
  31. EXPECT_EQ(expected, decoded);
  32. }