Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 62 additions & 46 deletions test/commands/qrcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,23 @@ BX_USING_NAMESPACES()
BC_AUTO_TEST_SUITE(offline)
BC_AUTO_TEST_SUITE(qrcode__invoke)

// The inflated image data (scanlines) of a png of one image data chunk.
static data_chunk scanlines(const data_chunk& png)
{
constexpr size_t field = sizeof(uint32_t);
const std::string type{ "IDAT" };
const auto it = std::search(png.begin(), png.end(), type.begin(),
type.end());

const data_chunk length(std::prev(it, field), it);
const auto begin = std::next(it, field);
const auto end = std::next(begin, from_big_endian<uint32_t>(length));

data_chunk out{};
zlib_inflate(out, data_chunk(begin, end));
return out;
}

BC_AUTO_TEST_CASE(qrcode__invoke__pixels_0__failure_error)
{
BX_DECLARE_COMMAND(qrcode);
Expand Down Expand Up @@ -92,7 +109,7 @@ BC_AUTO_TEST_CASE(qrcode__invoke__non_default_values__success_expected_size)
BX_REQUIRE_OKAY(command.invoke(output, error));

system::read::bytes::istream reader(output);
BC_REQUIRE_EQUAL(reader.read_bytes().size(), 2728u);
BC_REQUIRE_EQUAL(scanlines(reader.read_bytes()).size(), 2660u);
}

BC_AUTO_TEST_CASE(qrcode__invoke__minimal_size__success_expected)
Expand All @@ -111,51 +128,50 @@ BC_AUTO_TEST_CASE(qrcode__invoke__minimal_size__success_expected)
0x01, 0x00, 0x00, 0x00,
0x00, 0x7e, 0xe8, 0x5a,
0xa2, 0x00, 0x00, 0x00,
0x9c, 0x49, 0x44, 0x41,
0x54, 0x78, 0x01, 0x01,
0x91, 0x00, 0x6e, 0xff,
0x00, 0x01, 0xb3, 0x0c,
0x07, 0x00, 0x7d, 0xc4,
0x4d, 0xf7, 0x00, 0x45,
0x11, 0x7d, 0x17, 0x00,
0x45, 0x88, 0xcd, 0x17,
0x00, 0x45, 0xdd, 0xdd,
0x17, 0x00, 0x7d, 0xbb,
0x8d, 0xf7, 0x00, 0x01,
0x55, 0x54, 0x07, 0x00,
0xff, 0x11, 0x3f, 0xff,
0x00, 0x10, 0x4c, 0x79,
0xdf, 0x00, 0xc7, 0x4c,
0xc1, 0x97, 0x00, 0x19,
0xbb, 0xd3, 0x57, 0x00,
0xe3, 0xef, 0x37, 0xff,
0x00, 0x39, 0x77, 0x24,
0xa7, 0x00, 0xe7, 0x63,
0x34, 0xb7, 0x00, 0x84,
0xc5, 0x99, 0x67, 0x00,
0x63, 0x51, 0x0e, 0x67,
0x00, 0x64, 0xcd, 0x75,
0xd7, 0x00, 0xbb, 0xad,
0x15, 0xb7, 0x00, 0x60,
0x7b, 0xd6, 0x37, 0x00,
0x9f, 0xaf, 0xae, 0x3f,
0x00, 0x78, 0xd6, 0x30,
0x37, 0x00, 0xff, 0x62,
0x57, 0x77, 0x00, 0x01,
0x05, 0xc5, 0x57, 0x00,
0x7d, 0x30, 0xb7, 0x67,
0x00, 0x45, 0x4d, 0x70,
0x17, 0x00, 0x45, 0xcd,
0x1e, 0x27, 0x00, 0x45,
0x3b, 0xb6, 0x57, 0x00,
0x7d, 0x4e, 0x8e, 0xef,
0x00, 0x01, 0x76, 0x21,
0xa7, 0x45, 0x5a, 0x35,
0x29, 0x9b, 0xdf, 0x03,
0xac, 0x00, 0x00, 0x00,
0x00, 0x49, 0x45, 0x4e,
0x44, 0xae, 0x42, 0x60,
0x82
0x9a, 0x49, 0x44, 0x41,
0x54, 0x78, 0x9c, 0x63,
0x60, 0xdc, 0xcc, 0xc3,
0xce, 0x50, 0x7b, 0xc4,
0xf7, 0x3b, 0x83, 0xab,
0x60, 0xad, 0x38, 0x83,
0x6b, 0xc7, 0x59, 0x20,
0x71, 0xf7, 0xae, 0x38,
0x43, 0xed, 0xee, 0xde,
0xef, 0x0c, 0x8c, 0xa1,
0x21, 0xec, 0x0c, 0xff,
0x05, 0xed, 0xff, 0x33,
0x08, 0xf8, 0x54, 0xde,
0x67, 0x38, 0xee, 0x73,
0x70, 0x3a, 0x83, 0xe4,
0xee, 0xcb, 0xe1, 0x0c,
0x8f, 0xdf, 0x9b, 0xff,
0x67, 0xb0, 0x2c, 0x57,
0x59, 0xce, 0xf0, 0x3c,
0xd9, 0x64, 0x3b, 0x43,
0xcb, 0xd1, 0x99, 0xe9,
0x0c, 0xc9, 0x81, 0x7c,
0xe9, 0x0c, 0x29, 0x67,
0x4b, 0xaf, 0x33, 0xec,
0x5e, 0x2b, 0xba, 0x9d,
0x21, 0xa1, 0xfa, 0x9a,
0x39, 0xc3, 0xfc, 0xf5,
0xeb, 0xec, 0x19, 0x2a,
0xae, 0x19, 0x98, 0x33,
0xfc, 0x4f, 0x0a, 0x2f,
0x67, 0x60, 0x64, 0x3d,
0x1a, 0xce, 0x50, 0x6b,
0xb0, 0x3d, 0x9d, 0xc1,
0xd5, 0xb7, 0x00, 0x68,
0xd1, 0x59, 0x39, 0x75,
0x06, 0x57, 0xeb, 0x6d,
0x40, 0x31, 0xbf, 0xbe,
0xf7, 0x0c, 0x8c, 0x65,
0x8a, 0xcb, 0x01, 0x45,
0x5a, 0x35, 0x29, 0x00,
0x41, 0xaf, 0x05, 0x00,
0x00, 0x00, 0x00, 0x49,
0x45, 0x4e, 0x44, 0xae,
0x42, 0x60, 0x82
};

command.set_margin_option(0);
Expand Down
Loading