CODE16K fixes; separator default 1; raster/vector.c quiet_zones, output.c; #191

This commit is contained in:
gitlost 2020-05-21 18:22:28 +01:00
parent 9f56a1c35e
commit 7be63a00b6
36 changed files with 1791 additions and 675 deletions

View file

@ -56,6 +56,8 @@ zint_add_test(channel, test_channel)
zint_add_test(codablock, test_codablock)
zint_add_test(code1, test_code1)
zint_add_test(code128, test_code128)
zint_add_test(code16k, test_code16k)
zint_add_test(code49, test_code49)
zint_add_test(common, test_common)
zint_add_test(composite, test_composite)
zint_add_test(dmatrix, test_dmatrix)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 347 B

After

Width:  |  Height:  |  Size: 347 B

Before After
Before After

View file

@ -1,63 +1,63 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="210" height="68" version="1.1"
<svg width="242" height="64" version="1.1"
xmlns="http://www.w3.org/2000/svg">
<desc>Zint Generated Symbol
</desc>
<g id="barcode" fill="#000000">
<rect x="0" y="0" width="210" height="68" fill="#FFFFFF" />
<rect x="4.00" y="4.00" width="4.00" height="60.00" />
<rect x="10.00" y="4.00" width="2.00" height="60.00" />
<rect x="20.00" y="4.00" width="2.00" height="60.00" />
<rect x="26.00" y="4.00" width="2.00" height="60.00" />
<rect x="30.00" y="4.00" width="8.00" height="60.00" />
<rect x="40.00" y="4.00" width="6.00" height="60.00" />
<rect x="48.00" y="4.00" width="2.00" height="20.00" />
<rect x="54.00" y="4.00" width="2.00" height="20.00" />
<rect x="58.00" y="4.00" width="4.00" height="20.00" />
<rect x="70.00" y="4.00" width="2.00" height="60.00" />
<rect x="74.00" y="4.00" width="2.00" height="60.00" />
<rect x="82.00" y="4.00" width="4.00" height="60.00" />
<rect x="92.00" y="4.00" width="2.00" height="60.00" />
<rect x="96.00" y="4.00" width="2.00" height="40.00" />
<rect x="104.00" y="4.00" width="4.00" height="40.00" />
<rect x="114.00" y="4.00" width="2.00" height="40.00" />
<rect x="118.00" y="4.00" width="2.00" height="40.00" />
<rect x="126.00" y="4.00" width="4.00" height="40.00" />
<rect x="136.00" y="4.00" width="2.00" height="40.00" />
<rect x="140.00" y="4.00" width="2.00" height="40.00" />
<rect x="148.00" y="4.00" width="4.00" height="40.00" />
<rect x="158.00" y="4.00" width="4.00" height="20.00" />
<rect x="164.00" y="4.00" width="4.00" height="20.00" />
<rect x="172.00" y="4.00" width="4.00" height="20.00" />
<rect x="180.00" y="4.00" width="4.00" height="60.00" />
<rect x="190.00" y="4.00" width="6.00" height="60.00" />
<rect x="198.00" y="4.00" width="2.00" height="60.00" />
<rect x="202.00" y="4.00" width="4.00" height="60.00" />
<rect x="48.00" y="24.00" width="4.00" height="20.00" />
<rect x="58.00" y="24.00" width="2.00" height="20.00" />
<rect x="64.00" y="24.00" width="2.00" height="20.00" />
<rect x="158.00" y="24.00" width="8.00" height="20.00" />
<rect x="168.00" y="24.00" width="2.00" height="40.00" />
<rect x="176.00" y="24.00" width="2.00" height="20.00" />
<rect x="48.00" y="44.00" width="2.00" height="20.00" />
<rect x="52.00" y="44.00" width="4.00" height="20.00" />
<rect x="60.00" y="44.00" width="6.00" height="20.00" />
<rect x="96.00" y="44.00" width="6.00" height="20.00" />
<rect x="104.00" y="44.00" width="8.00" height="20.00" />
<rect x="114.00" y="44.00" width="4.00" height="20.00" />
<rect x="122.00" y="44.00" width="4.00" height="20.00" />
<rect x="128.00" y="44.00" width="4.00" height="20.00" />
<rect x="136.00" y="44.00" width="4.00" height="20.00" />
<rect x="144.00" y="44.00" width="6.00" height="20.00" />
<rect x="154.00" y="44.00" width="2.00" height="20.00" />
<rect x="158.00" y="44.00" width="4.00" height="20.00" />
<rect x="174.00" y="44.00" width="2.00" height="20.00" />
<rect x="26.00" y="22.00" width="158.00" height="4.00" />
<rect x="26.00" y="42.00" width="158.00" height="4.00" />
<rect x="4.00" y="0.00" width="202.00" height="4.00" />
<rect x="4.00" y="64.00" width="202.00" height="4.00" />
<rect x="0" y="0" width="242" height="64" fill="#FFFFFF" />
<rect x="20.00" y="2.00" width="4.00" height="60.00" />
<rect x="26.00" y="2.00" width="2.00" height="60.00" />
<rect x="36.00" y="2.00" width="2.00" height="60.00" />
<rect x="42.00" y="2.00" width="2.00" height="60.00" />
<rect x="46.00" y="2.00" width="8.00" height="60.00" />
<rect x="56.00" y="2.00" width="6.00" height="60.00" />
<rect x="64.00" y="2.00" width="2.00" height="20.00" />
<rect x="70.00" y="2.00" width="2.00" height="20.00" />
<rect x="74.00" y="2.00" width="4.00" height="20.00" />
<rect x="86.00" y="2.00" width="2.00" height="60.00" />
<rect x="90.00" y="2.00" width="2.00" height="60.00" />
<rect x="98.00" y="2.00" width="4.00" height="60.00" />
<rect x="108.00" y="2.00" width="2.00" height="60.00" />
<rect x="112.00" y="2.00" width="2.00" height="40.00" />
<rect x="120.00" y="2.00" width="4.00" height="40.00" />
<rect x="130.00" y="2.00" width="2.00" height="40.00" />
<rect x="134.00" y="2.00" width="2.00" height="40.00" />
<rect x="142.00" y="2.00" width="4.00" height="40.00" />
<rect x="152.00" y="2.00" width="2.00" height="40.00" />
<rect x="156.00" y="2.00" width="2.00" height="40.00" />
<rect x="164.00" y="2.00" width="4.00" height="40.00" />
<rect x="174.00" y="2.00" width="4.00" height="20.00" />
<rect x="180.00" y="2.00" width="4.00" height="20.00" />
<rect x="188.00" y="2.00" width="4.00" height="20.00" />
<rect x="196.00" y="2.00" width="4.00" height="60.00" />
<rect x="206.00" y="2.00" width="6.00" height="60.00" />
<rect x="214.00" y="2.00" width="2.00" height="60.00" />
<rect x="218.00" y="2.00" width="4.00" height="60.00" />
<rect x="64.00" y="22.00" width="4.00" height="20.00" />
<rect x="74.00" y="22.00" width="2.00" height="20.00" />
<rect x="80.00" y="22.00" width="2.00" height="20.00" />
<rect x="174.00" y="22.00" width="8.00" height="20.00" />
<rect x="184.00" y="22.00" width="2.00" height="40.00" />
<rect x="192.00" y="22.00" width="2.00" height="20.00" />
<rect x="64.00" y="42.00" width="2.00" height="20.00" />
<rect x="68.00" y="42.00" width="4.00" height="20.00" />
<rect x="76.00" y="42.00" width="6.00" height="20.00" />
<rect x="112.00" y="42.00" width="6.00" height="20.00" />
<rect x="120.00" y="42.00" width="8.00" height="20.00" />
<rect x="130.00" y="42.00" width="4.00" height="20.00" />
<rect x="138.00" y="42.00" width="4.00" height="20.00" />
<rect x="144.00" y="42.00" width="4.00" height="20.00" />
<rect x="152.00" y="42.00" width="4.00" height="20.00" />
<rect x="160.00" y="42.00" width="6.00" height="20.00" />
<rect x="170.00" y="42.00" width="2.00" height="20.00" />
<rect x="174.00" y="42.00" width="4.00" height="20.00" />
<rect x="190.00" y="42.00" width="2.00" height="20.00" />
<rect x="42.00" y="21.00" width="154.00" height="2.00" />
<rect x="42.00" y="41.00" width="154.00" height="2.00" />
<rect x="20.00" y="0.00" width="202.00" height="2.00" />
<rect x="20.00" y="62.00" width="202.00" height="2.00" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Before After
Before After

View file

@ -169,8 +169,8 @@ static void test_reader_init(int index, int generate, int debug) {
char *comment;
};
struct item data[] = {
/* 0*/ { BARCODE_CODABLOCKF, UNICODE_MODE, 16, "1234", 0, 2, 101, "67 64 40 60 63 0C 22 2B 6A 67 64 0B 63 64 3A 1C 29 6A", "CodeB FNC3 CodeC 12 34 / CodeB Pads" },
/* 1*/ { BARCODE_HIBC_BLOCKF, UNICODE_MODE, 16, "123456", 0, 3, 101, "67 64 41 60 0B 11 12 22 6A 67 63 2B 22 38 64 2A 1B 6A 67 64 0C 63 64 2B 2F 52 6A", "CodeB FNC3 + 1 2 / CodeC 34 56 CodeB J" },
/* 0*/ { BARCODE_CODABLOCKF, UNICODE_MODE, READER_INIT, "1234", 0, 2, 101, "67 64 40 60 63 0C 22 2B 6A 67 64 0B 63 64 3A 1C 29 6A", "CodeB FNC3 CodeC 12 34 / CodeB Pads" },
/* 1*/ { BARCODE_HIBC_BLOCKF, UNICODE_MODE, READER_INIT, "123456", 0, 3, 101, "67 64 41 60 0B 11 12 22 6A 67 63 2B 22 38 64 2A 1B 6A 67 64 0C 63 64 2B 2F 52 6A", "CodeB FNC3 + 1 2 / CodeC 34 56 CodeB J" },
};
int data_size = ARRAY_SIZE(data);
@ -191,8 +191,8 @@ static void test_reader_init(int index, int generate, int debug) {
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (generate) {
printf(" /*%3d*/ { %s, %s, %d, \"%s\", %s, %d, %d, \"%s\", \"%s\" },\n",
i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), data[i].output_options,
printf(" /*%3d*/ { %s, %s, %s, \"%s\", %s, %d, %d, \"%s\", \"%s\" },\n",
i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), testUtilOutputOptionsName(data[i].output_options),
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, symbol->errtxt, data[i].comment);
} else {

View file

@ -165,12 +165,12 @@ static void test_reader_init(int index, int generate, int debug) {
char *comment;
};
struct item data[] = {
/* 0*/ { BARCODE_CODE128, UNICODE_MODE, 16, "A", 0, 1, 57, "(5) 104 96 33 60 106", "StartA FNC3 A" },
/* 1*/ { BARCODE_CODE128, UNICODE_MODE, 16, "12", 0, 1, 68, "(6) 104 96 99 12 22 106", "StartB FNC3 CodeC 12" },
/* 2*/ { BARCODE_CODE128B, UNICODE_MODE, 16, "\0371234", 0, 1, 101, "(9) 103 96 95 17 18 19 20 6 106", "StartA FNC3 US 1 2 3 4" },
/* 3*/ { BARCODE_EAN128, GS1_MODE, 16, "[90]12", 0, 1, 68, "", "Reader Initialise not supported by GS1 barcodes (use CODE128)" },
/* 4*/ { BARCODE_EAN14, GS1_MODE, 16, "12", 0, 1, 134, "", "Reader Initialise not supported by GS1 barcodes (use CODE128)" },
/* 5*/ { BARCODE_NVE18, GS1_MODE, 16, "12", 0, 1, 156, "", "Reader Initialise not supported by GS1 barcodes (use CODE128)" },
/* 0*/ { BARCODE_CODE128, UNICODE_MODE, READER_INIT, "A", 0, 1, 57, "(5) 104 96 33 60 106", "StartA FNC3 A" },
/* 1*/ { BARCODE_CODE128, UNICODE_MODE, READER_INIT, "12", 0, 1, 68, "(6) 104 96 99 12 22 106", "StartB FNC3 CodeC 12" },
/* 2*/ { BARCODE_CODE128B, UNICODE_MODE, READER_INIT, "\0371234", 0, 1, 101, "(9) 103 96 95 17 18 19 20 6 106", "StartA FNC3 US 1 2 3 4" },
/* 3*/ { BARCODE_EAN128, GS1_MODE, READER_INIT, "[90]12", 0, 1, 68, "(6) 105 102 90 12 11 106", "StartC FNC1 90 12 (Reader Initialise not supported by GS1 barcodes (use CODE128))" },
/* 4*/ { BARCODE_EAN14, GS1_MODE, READER_INIT, "12", 0, 1, 134, "(12) 105 102 1 0 0 0 0 0 1 25 30 106", "StartC FNC1 01 00 (5) 01 (Reader Initialise not supported by GS1 barcodes (use CODE128))" },
/* 5*/ { BARCODE_NVE18, GS1_MODE, READER_INIT, "12", 0, 1, 156, "(14) 105 102 0 0 0 0 0 0 0 0 1 25 80 106", "StartC FNC1 00 (8) 01 (Reader Initialise not supported by GS1 barcodes (use CODE128))" },
};
int data_size = ARRAY_SIZE(data);
@ -191,8 +191,8 @@ static void test_reader_init(int index, int generate, int debug) {
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (generate) {
printf(" /*%3d*/ { %s, %s, %d, \"%s\", %s, %d, %d, \"%s\", \"%s\" },\n",
i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), data[i].output_options,
printf(" /*%3d*/ { %s, %s, %s, \"%s\", %s, %d, %d, \"%s\", \"%s\" },\n",
i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), testUtilOutputOptionsName(data[i].output_options),
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, symbol->errtxt, data[i].comment);
} else {
@ -302,6 +302,76 @@ static void test_input(int index, int generate, int debug) {
testFinish();
}
static void test_ean128_input(int index, int generate, int debug) {
testStart("");
int ret;
struct item {
unsigned char *data;
int ret;
int expected_width;
char *expected;
char *comment;
};
struct item data[] = {
/* 0*/ { "[90]1[90]1", 0, 123, "(11) 105 102 90 100 17 102 25 99 1 56 106", "StartC FNC1 90 CodeB 1 FNC1 9" },
/* 1*/ { "[90]1[90]12", 0, 123, "(11) 105 102 90 100 17 99 102 90 12 13 106", "StartC FNC1 90 CodeB 1 CodeC FNC1 90 12" },
/* 2*/ { "[90]1[90]123", 0, 134, "(12) 105 102 90 100 17 102 25 99 1 23 57 106", "StartC FNC1 90 CodeB 1 FNC1 9 CodeC 01 23" },
/* 3*/ { "[90]12[90]1", 0, 123, "(11) 105 102 90 12 102 100 25 99 1 19 106", "StartC FNC1 90 12 FNC1 CodeB 9 CodeC 01" },
/* 4*/ { "[90]12[90]12", 0, 101, "(9) 105 102 90 12 102 90 12 14 106", "StartC FNC1 90 12 FNC1 90 12" },
/* 5*/ { "[90]12[90]123", 0, 134, "(12) 105 102 90 12 102 100 25 99 1 23 20 106", "StartC FNC1 90 12 FNC1 CodeB 9 CodeC 01 23" },
/* 6*/ { "[90]123[90]1", 0, 134, "(12) 105 102 90 12 100 19 102 25 99 1 34 106", "StartC FNC1 90 12 CodeB 3 FNC1 9 CodeC 01" },
/* 7*/ { "[90]123[90]1234", 0, 145, "(13) 105 102 90 12 100 19 99 102 90 12 34 98 106", "StartC FNC1 90 12 CodeB 3 CodeC FNC1 90 12 34" },
/* 8*/ { "[90]1[90]1[90]1", 0, 178, "(16) 105 102 90 100 17 102 25 99 1 102 100 25 99 1 51 106", "StartC FNC1 90 CodeB 1 FNC1 9 CodeC 01 FNC1 CodeB 9 CodeC 01" },
/* 9*/ { "[90]1[90]12[90]1", 0, 178, "(16) 105 102 90 100 17 99 102 90 12 102 100 25 99 1 8 106", "StartC FNC1 90 CodeB 1 CodeC FNC1 90 12 FNC1 CodeB 9 CodeC 01" },
/* 10*/ { "[90]1[90]123[90]1", 0, 189, "(17) 105 102 90 100 17 102 25 99 1 23 102 100 25 99 1 70 106", "StartC FNC1 90 CodeB 1 FNC1 9 CodeC 01 23 FNC1 CodeB 9 CodeC 01" },
/* 11*/ { "[90]12[90]123[90]1", 0, 189, "(17) 105 102 90 12 102 100 25 99 1 23 102 100 25 99 1 33 106", "StartC FNC1 90 12 FNC1 CodeB 9 CodeC 01 23 FNC1 CodeB 9 CodeC 01" },
/* 12*/ { "[90]12[90]123[90]12", 0, 167, "(15) 105 102 90 12 102 100 25 99 1 23 102 90 12 11 106", "StartC FNC1 90 12 FNC1 CodeB 9 CodeC 01 23 FNC1 90 12" },
/* 13*/ { "[90]123[90]1[90]1", 0, 189, "(17) 105 102 90 12 100 19 102 25 99 1 102 100 25 99 1 47 106", "StartC FNC1 90 12 CodeB 3 FNC1 9 CodeC 01 FNC1 CodeB 9 CodeC 01" },
/* 14*/ { "[90]123[90]12[90]1", 0, 189, "(17) 105 102 90 12 100 19 99 102 90 12 102 100 25 99 1 80 106", "StartC FNC1 90 12 CodeB 3 CodeC FNC1 90 12 FNC1 CodeB 9 CodeC 01" },
/* 15*/ { "[90]123[90]123[90]12", 0, 178, "(16) 105 102 90 12 100 19 102 25 99 1 23 102 90 12 47 106", "StartC FNC1 90 12 CodeB 3 FNC1 9 CodeC 01 23 FNC1 90 12" },
/* 16*/ { "[90]123[90]1234[90]1", 0, 200, "(18) 105 102 90 12 100 19 99 102 90 12 34 102 100 25 99 1 26 106", "StartC FNC1 90 12 CodeB 3 CodeC FNC1 90 12 34 FNC1 CodeB 9 CodeC 01" },
/* 17*/ { "[90]123[90]1234[90]123", 0, 211, "(19) 105 102 90 12 100 19 99 102 90 12 34 102 100 25 99 1 23 85 106", "StartC FNC1 90 12 CodeB 3 CodeC FNC1 90 12 34 FNC1 CodeB 9 CodeC 01 23" },
/* 18*/ { "[90]12345[90]1234[90]1", 0, 211, "(19) 105 102 90 12 34 100 21 99 102 90 12 34 102 100 25 99 1 30 106", "StartC FNC1 90 12 34 CodeB 5 CodeC FNC1 90 12 34 FNC1 CodeB 9 CodeC 01" },
/* 19*/ { "[90]1A[90]1", 0, 134, "(12) 104 102 25 16 17 33 102 25 99 1 65 106", "StartB FNC1 9 0 1 A FNC1 9 CodeC 01" },
/* 20*/ { "[90]12A[90]123", 0, 145, "(13) 105 102 90 12 100 33 102 25 99 1 23 25 106", "StartC FNC1 90 12 CodeB A FNC1 9 CodeC 01 23" },
/* 21*/ { "[90]123[90]A234[90]123", 0, 244, "(22) 105 102 90 12 100 19 99 102 90 100 33 18 99 34 102 100 25 99 1 23 37 106", "StartC FNC1 90 12 CodeB 3 CodeC FNC1 90 CodeB A 2 CodeC 34 FNC1 CodeB 9 CodeC 01 23" } };
int data_size = sizeof(data) / sizeof(struct item);
char escaped[1024];
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
symbol->debug = ZINT_DEBUG_TEST; // Needed to get codeword dump in errtxt
int length = testUtilSetSymbol(symbol, BARCODE_EAN128, GS1_MODE, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
ret = ZBarcode_Encode(symbol, data[i].data, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (generate) {
printf(" /*%3d*/ { \"%s\", %s, %d, \"%s\", \"%s\" },\n",
i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
testUtilErrorName(data[i].ret), symbol->width, symbol->errtxt, data[i].comment);
} else {
if (ret < 5) {
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
}
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_encode(int index, int generate, int debug) {
testStart("");
@ -444,6 +514,7 @@ int main(int argc, char *argv[]) {
{ "test_hrt", test_hrt, 1, 0, 1 },
{ "test_reader_init", test_reader_init, 1, 1, 1 },
{ "test_input", test_input, 1, 1, 1 },
{ "test_ean128_input", test_ean128_input, 1, 1, 1 },
{ "test_encode", test_encode, 1, 1, 1 },
};

View file

@ -0,0 +1,301 @@
/*
libzint - the open source barcode library
Copyright (C) 2020 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#include "testcommon.h"
static void test_large(int index, int debug) {
testStart("");
int ret;
struct item {
unsigned char *pattern;
int length;
int ret;
int expected_rows;
int expected_width;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { "A", 77, 0, 16, 70 }, // BS EN 12323:2005 4.1 (l)
/* 1*/ { "A", 78, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 2*/ { "0", 154, 0, 16, 70 }, // BS EN 12323:2005 4.1 (l)
/* 3*/ { "0", 155, ZINT_ERROR_TOO_LONG, -1, -1 },
};
int data_size = ARRAY_SIZE(data);
char data_buf[4096];
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
testUtilStrCpyRepeat(data_buf, data[i].pattern, data[i].length);
assert_equal(data[i].length, (int) strlen(data_buf), "i:%d length %d != strlen(data_buf) %d\n", i, data[i].length, (int) strlen(data_buf));
int length = testUtilSetSymbol(symbol, BARCODE_CODE16K, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data_buf, data[i].length, debug);
ret = ZBarcode_Encode(symbol, data_buf, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < 5) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_reader_init(int index, int generate, int debug) {
testStart("");
int ret;
struct item {
int input_mode;
int output_options;
unsigned char *data;
int ret;
int expected_rows;
int expected_width;
char *expected;
char *comment;
};
struct item data[] = {
/* 0*/ { UNICODE_MODE, READER_INIT, "A", 0, 2, 70, "(10) 1 96 33 103 103 103 103 103 68 35", "ModeB FNC3 A Pad (5)" },
/* 1*/ { UNICODE_MODE, READER_INIT, "12", 0, 2, 70, "(10) 5 96 12 103 103 103 103 103 99 41", "ModeC1SB FNC3 12 Pad (5)" },
/* 2*/ { UNICODE_MODE, READER_INIT, "A1234", 0, 2, 70, "(10) 6 96 33 12 34 103 103 103 65 53", "ModeC2SB FNC3 A 12 34 Pad (3)" },
/* 3*/ { GS1_MODE, READER_INIT, "[90]1", ZINT_ERROR_INVALID_OPTION, 0, 0, "Error 422: Cannot use both GS1 mode and Reader Initialisation", "" },
};
int data_size = ARRAY_SIZE(data);
char escaped[1024];
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
symbol->debug = ZINT_DEBUG_TEST; // Needed to get codeword dump in errtxt
int length = testUtilSetSymbol(symbol, BARCODE_CODE16K, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1 /*option_2*/, -1, data[i].output_options, data[i].data, -1, debug);
ret = ZBarcode_Encode(symbol, data[i].data, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (generate) {
printf(" /*%3d*/ { %s, %s, \"%s\", %s, %d, %d, \"%s\", \"%s\" },\n",
i, testUtilInputModeName(data[i].input_mode), testUtilOutputOptionsName(data[i].output_options),
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, symbol->errtxt, data[i].comment);
} else {
if (ret < 5) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
}
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_input(int index, int generate, int debug) {
testStart("");
int ret;
struct item {
int input_mode;
unsigned char *data;
int length;
int ret;
int expected_rows;
int expected_width;
char *expected;
char *comment;
};
// NUL U+0000, CodeA-only
// US U+001F (\037, 31), CodeA-only
// a U+0061 (\141, 97), CodeB-only
// b U+0062 (\142, 98), CodeB-only
// APC U+009F (\237, 159), UTF-8 C29F, CodeA-only extended ASCII, not in ISO 8859-1
// ß U+00DF (\337, 223), UTF-8 C39F, CodeA and CodeB extended ASCII
// é U+00E9 (\351, 233), UTF-8 C3A9, CodeB-only extended ASCII
struct item data[] = {
/* 0*/ { UNICODE_MODE, "\037", -1, 0, 2, 70, "(10) 0 95 103 103 103 103 103 103 22 42", "ModeA US Pad (6)" },
/* 1*/ { UNICODE_MODE, "A", -1, 0, 2, 70, "(10) 1 33 103 103 103 103 103 103 52 82", "ModeB A Pad (6)" },
/* 2*/ { UNICODE_MODE, "12", -1, 0, 2, 70, "(10) 2 12 103 103 103 103 103 103 98 27", "ModeC 12 Pad (6)" },
/* 3*/ { GS1_MODE, "[90]A", -1, 0, 2, 70, "(10) 3 25 16 33 103 103 103 103 83 20", "ModeBFNC1 9 0 A Pad (4)" },
/* 4*/ { GS1_MODE, "[90]12", -1, 0, 2, 70, "(10) 4 90 12 103 103 103 103 103 79 62", "ModeCFNC1 90 12 Pad (5)" },
/* 5*/ { UNICODE_MODE, "a0123456789", -1, 0, 2, 70, "(10) 5 65 1 23 45 67 89 103 27 86", "ModeC1SB a 01 23 45 67 89 Pad" },
/* 6*/ { UNICODE_MODE, "ab0123456789", -1, 0, 2, 70, "(10) 6 65 66 1 23 45 67 89 19 42", "ModeC2SB a b 01 23 45 67 89" },
/* 7*/ { UNICODE_MODE, "1234\037a", -1, 0, 2, 70, "(10) 2 12 34 101 95 98 65 103 67 53", "ModeC 12 34 CodeA US 1SB a Pad" },
/* 8*/ { UNICODE_MODE, "\000\037ß", 4, 0, 2, 70, "(10) 0 64 95 101 63 103 103 103 75 11", "ModeA NUL US FNC4 ß Pad (3)" },
/* 9*/ { UNICODE_MODE, "\000\037é", 4, 0, 2, 70, "(10) 0 64 95 101 98 73 103 103 75 6", "ModeA NUL US FNC4 1SB é Pad (2)" },
/* 10*/ { UNICODE_MODE, "\000\037éa", 5, 0, 2, 70, "(10) 0 64 95 100 100 73 65 103 99 69", "ModeA NUL US CodeB FNC4 é a Pad" },
/* 11*/ { UNICODE_MODE, "abß", -1, 0, 2, 70, "(10) 1 65 66 100 63 103 103 103 66 56", "ModeB a b FNC4 ß Pad (3)" },
/* 12*/ { DATA_MODE, "\141\142\237", -1, 0, 2, 70, "(10) 1 65 66 100 98 95 103 103 6 71", "ModeB a b FNC4 1SA APC Pad (2)" },
/* 13*/ { DATA_MODE, "\141\142\237\037", -1, 0, 2, 70, "(10) 1 65 66 101 101 95 95 103 72 93", "ModeB a b CodeA FNC4 APC US Pad" },
/* 14*/ { UNICODE_MODE, "ééé", -1, 0, 2, 70, "(10) 1 100 73 100 73 100 73 103 105 106", "ModeB FNC4 é FNC4 é FNC4 é Pad" },
/* 15*/ { UNICODE_MODE, "aééééb", -1, 0, 3, 70, "(15) 8 65 100 73 100 73 100 73 100 73 66 103 103 39 83", "ModeB a FNC4 é (4) b Pad (2)" },
/* 16*/ { UNICODE_MODE, "aéééééb", -1, 0, 3, 70, "(15) 8 65 100 73 100 73 100 73 100 73 100 73 66 74 106", "ModeB a FNC4 é (5) b" },
/* 17*/ { UNICODE_MODE, "aééééébcdeé", -1, 0, 4, 70, "(20) 15 65 100 73 100 73 100 73 100 73 100 73 66 67 68 69 100 73 14 69", "ModeB a FNC4 é (5) b c d e FNC4 é" },
};
int data_size = ARRAY_SIZE(data);
char escaped[1024];
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
symbol->debug = ZINT_DEBUG_TEST; // Needed to get codeword dump in errtxt
int length = testUtilSetSymbol(symbol, BARCODE_CODE16K, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
ret = ZBarcode_Encode(symbol, data[i].data, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (generate) {
printf(" /*%3d*/ { %s, \"%s\", %d, %s, %d, %d, \"%s\", \"%s\" },\n",
i, testUtilInputModeName(data[i].input_mode), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length,
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, symbol->errtxt, data[i].comment);
} else {
if (ret < 5) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
}
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_encode(int index, int generate, int debug) {
testStart("");
int ret;
struct item {
int input_mode;
unsigned char *data;
int ret;
int expected_rows;
int expected_width;
char *comment;
char *expected;
};
struct item data[] = {
/* 0*/ { UNICODE_MODE, "ab0123456789", 0, 2, 70, "BS EN 12323:2005 Figure 3",
"1110010101100110111011010011110110111100100110010011000100100010001101"
"1100110101000100111011110100110010010000100110100011010010001110011001"
},
/* 1*/ { UNICODE_MODE, "www.wikipedia.de", 0, 4, 70, "Verified manually against bwipp",
"1110010101000110011000011010110000110101100001101011011001100010001101"
"1100110100001101011011110010110011110110101111001011010110000110011001"
"1101100101001101111011110110010111100101101101001111011001100010010011"
"1000010101111011001010011011110010111101101100001011010001001110111101"
},
};
int data_size = ARRAY_SIZE(data);
char escaped[1024];
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, BARCODE_CODE16K, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
ret = ZBarcode_Encode(symbol, data[i].data, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (generate) {
printf(" /*%3d*/ { %s, \"%s\", %s, %d, %d, \"%s\",\n",
i, testUtilInputModeName(data[i].input_mode), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
testUtilModulesDump(symbol, " ", "\n");
printf(" },\n");
} else {
if (ret < 5) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
if (ret == 0) {
int width, row;
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data);
}
}
}
ZBarcode_Delete(symbol);
}
testFinish();
}
int main(int argc, char *argv[]) {
testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */
{ "test_large", test_large, 1, 0, 1 },
{ "test_reader_init", test_reader_init, 1, 1, 1 },
{ "test_input", test_input, 1, 1, 1 },
{ "test_encode", test_encode, 1, 1, 1 },
};
testRun(argc, argv, funcs, ARRAY_SIZE(funcs));
testReport();
return 0;
}

234
backend/tests/test_code49.c Normal file
View file

@ -0,0 +1,234 @@
/*
libzint - the open source barcode library
Copyright (C) 2020 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#include "testcommon.h"
static void test_large(int index, int debug) {
testStart("");
int ret;
struct item {
unsigned char *pattern;
int length;
int ret;
int expected_rows;
int expected_width;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { "A", 49, 0, 8, 70 }, // ANSI/AIM BC6-2000 Table 1
/* 1*/ { "A", 50, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 2*/ { "0", 81, 0, 8, 70 }, // ANSI/AIM BC6-2000 Table 1
/* 3*/ { "0", 82, ZINT_ERROR_TOO_LONG, -1, -1 },
};
int data_size = ARRAY_SIZE(data);
char data_buf[4096];
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
testUtilStrCpyRepeat(data_buf, data[i].pattern, data[i].length);
assert_equal(data[i].length, (int) strlen(data_buf), "i:%d length %d != strlen(data_buf) %d\n", i, data[i].length, (int) strlen(data_buf));
int length = testUtilSetSymbol(symbol, BARCODE_CODE49, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data_buf, data[i].length, debug);
ret = ZBarcode_Encode(symbol, data_buf, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < 5) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_input(int index, int generate, int debug) {
testStart("");
int ret;
struct item {
int input_mode;
unsigned char *data;
int length;
int ret;
int expected_rows;
int expected_width;
char *expected;
char *comment;
};
// NUL U+0000, S1 SP (39)
// US U+001F (\037, 31), S1 5
struct item data[] = {
/* 0*/ { UNICODE_MODE, "é", -1, ZINT_ERROR_INVALID_DATA, 0, 0, "Error 431: Invalid characters in input data", "ASCII only" },
/* 1*/ { UNICODE_MODE, "EXAMPLE 2", -1, 0, 2, 70, "(16) 14 33 10 22 25 21 14 41 38 2 35 14 18 13 0 22", "2.3.7 Symbol Example" },
/* 2*/ { UNICODE_MODE, "12345", -1, 0, 2, 70, "(16) 5 17 9 48 48 48 48 27 48 48 13 23 0 13 2 0", "2.3 Example 1: Numeric Encodation (Start 2, Numeric)" },
/* 3*/ { UNICODE_MODE, "123456", -1, 0, 2, 70, "(16) 5 17 9 6 48 48 48 34 48 48 36 9 23 41 2 11", "2.3 Example 1: Numeric Encodation" },
/* 4*/ { UNICODE_MODE, "12345678", -1, 0, 2, 70, "(16) 5 17 9 14 6 48 48 0 48 48 25 42 2 17 2 37", "2.3 Example 1: Numeric Encodation" },
/* 5*/ { UNICODE_MODE, "123456789", -1, 0, 2, 70, "(16) 5 17 9 46 16 37 48 31 48 48 7 26 9 39 2 32", "2.3 Example 1: Numeric Encodation" },
/* 6*/ { UNICODE_MODE, "1234567", -1, 0, 2, 70, "(16) 43 45 2 11 39 48 48 40 48 48 33 36 38 6 2 15", "2.3 Example 1: Numeric Encodation" },
/* 7*/ { UNICODE_MODE, "\037", -1, 0, 2, 70, "(16) 5 48 48 48 48 48 48 48 48 48 4 33 13 15 4 18", "US (Start 4, Alphanumeric S1)" },
/* 8*/ { UNICODE_MODE, "\000\037", 2, 0, 2, 70, "(16) 38 43 5 48 48 48 48 33 48 48 45 7 38 43 4 37", "NUL S1 US (Start 4, Alphanumeric S1)" },
/* 9*/ { UNICODE_MODE, "a\000", 2, 0, 2, 70, "(16) 10 43 38 48 48 48 48 38 48 48 32 33 14 15 5 48", "a S1 NUL (Start 5, Alphanumeric S2)" },
/* 10*/ { UNICODE_MODE, "ab", -1, 0, 2, 70, "(16) 10 44 11 48 48 48 48 12 48 48 27 39 42 0 5 13", "a S2 b (Start 5, Alphanumeric S2)" },
/* 11*/ { UNICODE_MODE, "\000A\000a\000", 5, 0, 2, 70, "(16) 38 10 43 38 44 10 43 30 38 48 25 23 38 32 4 12", "NUL A S1 NUL S2 a S1 (C18 30) NUL (Start 4, Alphanumeric S1)" },
/* 12*/ { UNICODE_MODE, "1234\037aA12345A", -1, 0, 3, 70, "(24) 1 2 3 4 43 5 44 4 10 10 48 5 17 9 48 0 10 48 19 2 13 32 7 33", "1 2 3 4 S1 US S2 (C18 4) a A NS 12345 NS (C28 0) A (Start 0, Alpha)" },
/* 13*/ { GS1_MODE, "[90]12345[91]AB12345", -1, 0, 4, 70, "(32) 45 48 47 15 4 7 9 28 48 45 9 1 10 11 48 25 5 17 9 48 48 48 48 27 48 48 37 39 26 8 14", "FNC1 NS 9012345 (C18 28) NS FNC1 9 1 A B NS (C28 25) 12345 Pad (4) (C38 27) (Start 0, Alpha)" },
};
int data_size = ARRAY_SIZE(data);
char escaped[1024];
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
symbol->debug = ZINT_DEBUG_TEST; // Needed to get codeword dump in errtxt
int length = testUtilSetSymbol(symbol, BARCODE_CODE49, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
ret = ZBarcode_Encode(symbol, data[i].data, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (generate) {
printf(" /*%3d*/ { %s, \"%s\", %d, %s, %d, %d, \"%s\", \"%s\" },\n",
i, testUtilInputModeName(data[i].input_mode), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length,
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, symbol->errtxt, data[i].comment);
} else {
if (ret < 5) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
}
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_encode(int index, int generate, int debug) {
testStart("");
int ret;
struct item {
int input_mode;
unsigned char *data;
int ret;
int expected_rows;
int expected_width;
char *comment;
char *expected;
};
struct item data[] = {
/* 0*/ { UNICODE_MODE, "MULTIPLE ROWS IN CODE 49", 0, 5, 70, "ANSI/AIM BC6-2000 Figure 1",
"1011111011001011101011100110000110111101011011111010111101000100001111"
"1010100001000010001001111000101110100110001111010010001011100011001111"
"1011001100000101101101110111000010110010110000111011101011110001101111"
"1010011001100100001111010010001100101011101111110011010001001111101111"
"1011001111001011101000000101001110111110111010001011010001101111101111"
},
/* 1*/ { UNICODE_MODE, "EXAMPLE 2", 0, 2, 70, "ANSI/AIM BC6-2000 Figure 3",
"1011000111011100101111001001000110110011110010100010001111000100101111"
"1011000100110010001100010110010000100001101001111010000001001011101111"
},
};
int data_size = ARRAY_SIZE(data);
char escaped[1024];
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, BARCODE_CODE49, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
ret = ZBarcode_Encode(symbol, data[i].data, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (generate) {
printf(" /*%3d*/ { %s, \"%s\", %s, %d, %d, \"%s\",\n",
i, testUtilInputModeName(data[i].input_mode), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
testUtilModulesDump(symbol, " ", "\n");
printf(" },\n");
} else {
if (ret < 5) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
if (ret == 0) {
int width, row;
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data);
}
}
}
ZBarcode_Delete(symbol);
}
testFinish();
}
int main(int argc, char *argv[]) {
testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */
{ "test_large", test_large, 1, 0, 1 },
{ "test_input", test_input, 1, 1, 1 },
{ "test_encode", test_encode, 1, 1, 1 },
};
testRun(argc, argv, funcs, ARRAY_SIZE(funcs));
testReport();
return 0;
}

View file

@ -159,6 +159,7 @@ static void test_escape_char_process(int index, int generate, int debug) {
int ret;
struct item {
int input_mode;
unsigned char *data;
int ret;
int expected_width;
@ -166,12 +167,13 @@ static void test_escape_char_process(int index, int generate, int debug) {
char *comment;
};
struct item data[] = {
/* 0*/ { "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\e\\G\\R\\x81\\\\", 0, 200, "(18) 103 64 68 71 72 73 74 75 76 77 91 93 94 101 65 60 44 106", "" },
/* 1*/ { "\\c", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character in input data", "" },
/* 2*/ { "\\", ZINT_ERROR_INVALID_DATA, 0, "Error 236: Incomplete escape character in input data", "" },
/* 3*/ { "\\x", ZINT_ERROR_INVALID_DATA, 0, "Error 232: Incomplete escape character in input data", "" },
/* 4*/ { "\\x1", ZINT_ERROR_INVALID_DATA, 0, "Error 232: Incomplete escape character in input data", "" },
/* 5*/ { "\\x1g", ZINT_ERROR_INVALID_DATA, 0, "Error 233: Corrupt escape character in input data", "" },
/* 0*/ { DATA_MODE, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\e\\G\\R\\x81\\\\", 0, 200, "(18) 103 64 68 71 72 73 74 75 76 77 91 93 94 101 65 60 44 106", "" },
/* 1*/ { DATA_MODE, "\\c", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character in input data", "" },
/* 2*/ { DATA_MODE, "\\", ZINT_ERROR_INVALID_DATA, 0, "Error 236: Incomplete escape character in input data", "" },
/* 3*/ { DATA_MODE, "\\x", ZINT_ERROR_INVALID_DATA, 0, "Error 232: Incomplete escape character in input data", "" },
/* 4*/ { DATA_MODE, "\\x1", ZINT_ERROR_INVALID_DATA, 0, "Error 232: Incomplete escape character in input data", "" },
/* 5*/ { DATA_MODE, "\\x1g", ZINT_ERROR_INVALID_DATA, 0, "Error 233: Corrupt escape character in input data", "" },
/* 6*/ { UNICODE_MODE, "\\xA01\\xFF", 0, 90, "(8) 104 100 0 17 100 95 100 106", "" },
};
int data_size = ARRAY_SIZE(data);
@ -186,14 +188,15 @@ static void test_escape_char_process(int index, int generate, int debug) {
symbol->debug = ZINT_DEBUG_TEST; // Needed to get codeword dump in errtxt
int length = testUtilSetSymbol(symbol, BARCODE_CODE128, DATA_MODE | ESCAPE_MODE, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
int length = testUtilSetSymbol(symbol, BARCODE_CODE128, data[i].input_mode | ESCAPE_MODE, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
ret = ZBarcode_Encode(symbol, data[i].data, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (generate) {
printf(" /*%3d*/ { \"%s\", %s, %d, \"%s\", \"%s\" },\n",
i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->width, symbol->errtxt, data[i].comment);
printf(" /*%3d*/ { %s, \"%s\", %s, %d, \"%s\", \"%s\" },\n",
i, testUtilInputModeName(data[i].input_mode), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
testUtilErrorName(data[i].ret), symbol->width, symbol->errtxt, data[i].comment);
} else {
if (ret < 5) {
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);

View file

@ -36,6 +36,231 @@ static int is_row_column_black(struct zint_symbol *symbol, int row, int column)
return symbol->bitmap[i] == 0 && symbol->bitmap[i + 1] == 0 && symbol->bitmap[i + 2] == 0; // Black
}
static void test_options(int index, int debug) {
testStart("");
int ret;
struct item {
int symbology;
char *fgcolour;
char *bgcolour;
int rotate_angle;
unsigned char *data;
int ret;
int expected_rows;
int expected_width;
int expected_bitmap_width;
int expected_bitmap_height;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_CODE128, "123456", "7890AB", 0, "A", 0, 1, 46, 92, 118 },
/* 1*/ { BARCODE_CODE128, "123456", "7890ab", 90, "A", 0, 1, 46, 118, 92 },
/* 2*/ { BARCODE_CODE128, NULL, NULL, 180, "A", 0, 1, 46, 92, 118 },
/* 3*/ { BARCODE_CODE128, NULL, NULL, 270, "A", 0, 1, 46, 118, 92 },
/* 4*/ { BARCODE_CODE128, NULL, NULL, 181, "A", ZINT_ERROR_INVALID_OPTION, -1, -1, -1, -1 },
/* 5*/ { BARCODE_CODE128, "12345", NULL, 0, "A", ZINT_ERROR_INVALID_OPTION, -1, -1, -1, -1 },
/* 6*/ { BARCODE_CODE128, NULL, "1234567", 0, "A", ZINT_ERROR_INVALID_OPTION, -1, -1, -1, -1 },
/* 7*/ { BARCODE_CODE128, "12345 ", NULL, 0, "A", ZINT_ERROR_INVALID_OPTION, -1, -1, -1, -1 },
/* 8*/ { BARCODE_CODE128, NULL, "EEFFGG", 0, "A", ZINT_ERROR_INVALID_OPTION, -1, -1, -1, -1 },
};
int data_size = ARRAY_SIZE(data);
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, BARCODE_CODE128, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
if (data[i].fgcolour) {
strcpy(symbol->fgcolour, data[i].fgcolour);
}
if (data[i].bgcolour) {
strcpy(symbol->bgcolour, data[i].bgcolour);
}
ret = ZBarcode_Encode_and_Buffer(symbol, data[i].data, length, data[i].rotate_angle);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < 5) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
assert_equal(symbol->bitmap_width, data[i].expected_bitmap_width, "i:%d symbol->bitmap_width %d != %d\n", i, symbol->bitmap_width, data[i].expected_bitmap_width);
assert_equal(symbol->bitmap_height, data[i].expected_bitmap_height, "i:%d symbol->bitmap_height %d != %d\n", i, symbol->bitmap_height, data[i].expected_bitmap_height);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_buffer(int index, int generate, int debug) {
testStart("");
int ret;
struct item {
int symbology;
unsigned char *data;
char *composite;
int expected_height;
int expected_rows;
int expected_width;
int expected_bitmap_width;
int expected_bitmap_height;
};
struct item data[] = {
/* 0*/ { BARCODE_CODE11, "0000000000", "", 50, 1, 99, 198, 118 },
/* 1*/ { BARCODE_C25MATRIX, "0000000000", "", 50, 1, 117, 234, 118 },
/* 2*/ { BARCODE_C25INTER, "0000000000", "", 50, 1, 99, 198, 118 },
/* 3*/ { BARCODE_C25IATA, "0000000000", "", 50, 1, 149, 298, 118 },
/* 4*/ { BARCODE_C25LOGIC, "0000000000", "", 50, 1, 109, 218, 118 },
/* 5*/ { BARCODE_C25IND, "0000000000", "", 50, 1, 159, 318, 118 },
/* 6*/ { BARCODE_CODE39, "0000000000", "", 50, 1, 155, 310, 118 },
/* 7*/ { BARCODE_EXCODE39, "0000000000", "", 50, 1, 155, 310, 118 },
/* 8*/ { BARCODE_EANX, "123456789012", "", 50, 1, 95, 230, 118 },
/* 9*/ { BARCODE_EANX_CHK, "1234567890128", "", 50, 1, 95, 230, 118 },
/* 10*/ { BARCODE_EAN128, "[01]12345678901234", "", 50, 1, 134, 268, 118 },
/* 11*/ { BARCODE_CODABAR, "A00000000B", "", 50, 1, 102, 204, 118 },
/* 12*/ { BARCODE_CODE128, "0000000000", "", 50, 1, 90, 180, 118 },
/* 13*/ { BARCODE_DPLEIT, "1234567890123", "", 50, 1, 135, 270, 118 },
/* 14*/ { BARCODE_DPIDENT, "12345678901", "", 50, 1, 117, 234, 118 },
/* 15*/ { BARCODE_CODE16K, "0000000000", "", 20, 2, 70, 162, 44 },
/* 16*/ { BARCODE_CODE49, "0000000000", "", 20, 2, 70, 162, 44 },
/* 17*/ { BARCODE_CODE93, "0000000000", "", 50, 1, 127, 254, 118 },
/* 18*/ { BARCODE_FLAT, "1234567890", "", 50, 1, 90, 180, 100 },
/* 19*/ { BARCODE_RSS14, "1234567890123", "", 50, 1, 96, 192, 118 },
/* 20*/ { BARCODE_RSS_LTD, "1234567890123", "", 50, 1, 74, 148, 118 },
/* 21*/ { BARCODE_RSS_EXP, "[01]12345678901234", "", 34, 1, 134, 268, 86 },
/* 22*/ { BARCODE_TELEPEN, "0000000000", "", 50, 1, 208, 416, 118 },
/* 23*/ { BARCODE_UPCA, "12345678904", "", 50, 1, 95, 230, 118 },
/* 24*/ { BARCODE_UPCA_CHK, "12345678905", "", 50, 1, 95, 230, 118 },
/* 25*/ { BARCODE_UPCE, "1234567", "", 50, 1, 51, 142, 118 },
/* 26*/ { BARCODE_UPCE_CHK, "12345670", "", 50, 1, 51, 142, 118 },
/* 27*/ { BARCODE_POSTNET, "00000000000", "", 12, 2, 185, 370, 24 },
/* 28*/ { BARCODE_MSI_PLESSEY, "0000000000", "", 50, 1, 127, 254, 118 },
/* 29*/ { BARCODE_FIM, "A", "", 50, 1, 17, 34, 100 },
/* 30*/ { BARCODE_LOGMARS, "0000000000", "", 50, 1, 207, 414, 118 },
/* 31*/ { BARCODE_PHARMA, "123456", "", 50, 1, 58, 116, 100 },
/* 32*/ { BARCODE_PZN, "123456", "", 50, 1, 142, 284, 118 },
/* 33*/ { BARCODE_PHARMA_TWO, "12345678", "", 10, 2, 29, 58, 20 },
/* 34*/ { BARCODE_PDF417, "0000000000", "", 21, 7, 103, 206, 42 },
/* 35*/ { BARCODE_PDF417TRUNC, "0000000000", "", 21, 7, 68, 136, 42 },
/* 36*/ { BARCODE_MAXICODE, "0000000000", "", 165, 33, 30, 300, 300 },
/* 37*/ { BARCODE_QRCODE, "1234567890AB", "", 21, 21, 21, 42, 42 },
/* 38*/ { BARCODE_CODE128B, "0000000000", "", 50, 1, 145, 290, 118 },
/* 39*/ { BARCODE_AUSPOST, "12345678901234567890123", "", 8, 3, 133, 266, 16 },
/* 40*/ { BARCODE_AUSREPLY, "12345678", "", 8, 3, 73, 146, 16 },
/* 41*/ { BARCODE_AUSROUTE, "12345678", "", 8, 3, 73, 146, 16 },
/* 42*/ { BARCODE_AUSREDIRECT, "12345678", "", 8, 3, 73, 146, 16 },
/* 43*/ { BARCODE_ISBNX, "123456789", "", 50, 1, 95, 230, 118 },
/* 44*/ { BARCODE_RM4SCC, "0000000000", "", 8, 3, 91, 182, 16 },
/* 45*/ { BARCODE_DATAMATRIX, "ABC", "", 10, 10, 10, 20, 20 },
/* 46*/ { BARCODE_EAN14, "1234567890123", "", 50, 1, 134, 268, 118 },
/* 47*/ { BARCODE_VIN, "00000000000000000", "", 50, 1, 246, 492, 118 },
/* 48*/ { BARCODE_CODABLOCKF, "0000000000", "", 20, 2, 101, 242, 44 },
/* 49*/ { BARCODE_NVE18, "12345678901234567", "", 50, 1, 156, 312, 118 },
/* 50*/ { BARCODE_JAPANPOST, "0000000000", "", 8, 3, 133, 266, 16 },
/* 51*/ { BARCODE_KOREAPOST, "123456", "", 50, 1, 167, 334, 118 },
/* 52*/ { BARCODE_RSS14STACK, "0000000000000", "", 13, 3, 50, 100, 26 },
/* 53*/ { BARCODE_RSS14STACK_OMNI, "0000000000000", "", 69, 5, 50, 100, 138 },
/* 54*/ { BARCODE_RSS_EXPSTACK, "[01]12345678901234", "", 71, 5, 102, 204, 142 },
/* 55*/ { BARCODE_PLANET, "00000000000", "", 12, 2, 185, 370, 24 },
/* 56*/ { BARCODE_MICROPDF417, "0000000000", "", 12, 6, 82, 164, 24 },
/* 57*/ { BARCODE_ONECODE, "12345678901234567890", "", 8, 3, 129, 258, 16 },
/* 58*/ { BARCODE_PLESSEY, "0000000000", "", 50, 1, 227, 454, 118 },
/* 59*/ { BARCODE_TELEPEN_NUM, "0000000000", "", 50, 1, 128, 256, 118 },
/* 60*/ { BARCODE_ITF14, "0000000000", "", 50, 1, 135, 382, 150 },
/* 61*/ { BARCODE_KIX, "123456ABCDE", "", 8, 3, 87, 174, 16 },
/* 62*/ { BARCODE_AZTEC, "1234567890AB", "", 15, 15, 15, 30, 30 },
/* 63*/ { BARCODE_DAFT, "DAFTDAFTDAFTDAFT", "", 8, 3, 31, 62, 16 },
/* 64*/ { BARCODE_MICROQR, "12345", "", 11, 11, 11, 22, 22 },
/* 65*/ { BARCODE_HIBC_128, "0000000000", "", 50, 1, 134, 268, 118 },
/* 66*/ { BARCODE_HIBC_39, "0000000000", "", 50, 1, 223, 446, 118 },
/* 67*/ { BARCODE_HIBC_DM, "ABC", "", 12, 12, 12, 24, 24 },
/* 68*/ { BARCODE_HIBC_QR, "1234567890AB", "", 21, 21, 21, 42, 42 },
/* 69*/ { BARCODE_HIBC_PDF, "0000000000", "", 27, 9, 103, 206, 54 },
/* 70*/ { BARCODE_HIBC_MICPDF, "0000000000", "", 34, 17, 38, 76, 68 },
/* 71*/ { BARCODE_HIBC_BLOCKF, "0000000000", "", 30, 3, 101, 242, 64 },
/* 72*/ { BARCODE_HIBC_AZTEC, "1234567890AB", "", 19, 19, 19, 38, 38 },
/* 73*/ { BARCODE_DOTCODE, "ABC", "", 11, 11, 16, 33, 23 },
/* 74*/ { BARCODE_HANXIN, "1234567890AB", "", 23, 23, 23, 46, 46 },
/* 75*/ { BARCODE_MAILMARK, "01000000000000000AA00AA0A", "", 10, 3, 155, 310, 20 },
/* 76*/ { BARCODE_AZRUNE, "255", "", 11, 11, 11, 22, 22 },
/* 77*/ { BARCODE_CODE32, "12345678", "", 50, 1, 103, 206, 118 },
/* 78*/ { BARCODE_EANX_CC, "123456789012", "[20]01", 50, 7, 99, 238, 118 },
/* 79*/ { BARCODE_EAN128_CC, "[01]12345678901234", "[20]01", 50, 5, 145, 290, 118 },
/* 80*/ { BARCODE_RSS14_CC, "1234567890123", "[20]01", 21, 5, 100, 200, 60 },
/* 81*/ { BARCODE_RSS_LTD_CC, "1234567890123", "[20]01", 19, 6, 74, 148, 56 },
/* 82*/ { BARCODE_RSS_EXP_CC, "[01]12345678901234", "[20]01", 41, 5, 134, 268, 100 },
/* 83*/ { BARCODE_UPCA_CC, "12345678901", "[20]01", 50, 7, 99, 238, 118 },
/* 84*/ { BARCODE_UPCE_CC, "1234567", "[20]01", 50, 9, 55, 150, 118 },
/* 85*/ { BARCODE_RSS14STACK_CC, "0000000000000", "[20]01", 24, 9, 56, 112, 48 },
/* 86*/ { BARCODE_RSS14_OMNI_CC, "0000000000000", "[20]01", 80, 11, 56, 112, 160 },
/* 87*/ { BARCODE_RSS_EXPSTACK_CC, "[01]12345678901234", "[20]01", 78, 9, 102, 204, 156 },
/* 88*/ { BARCODE_CHANNEL, "00", "", 50, 1, 19, 38, 118 },
/* 89*/ { BARCODE_CODEONE, "12345678901234567890", "", 22, 22, 22, 44, 44 },
/* 90*/ { BARCODE_GRIDMATRIX, "ABC", "", 18, 18, 18, 36, 36 },
/* 91*/ { BARCODE_UPNQR, "1234567890AB", "", 77, 77, 77, 154, 154 },
/* 92*/ { BARCODE_ULTRA, "0000000000", "", 13, 13, 18, 36, 26 },
/* 93*/ { BARCODE_RMQR, "12345", "", 11, 11, 27, 54, 22 },
};
int data_size = ARRAY_SIZE(data);
char *text;
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
symbol->symbology = data[i].symbology;
symbol->input_mode = UNICODE_MODE;
symbol->debug |= debug;
if (strlen(data[i].composite)) {
text = data[i].composite;
strcpy(symbol->primary, data[i].data);
} else {
text = data[i].data;
}
int length = strlen(text);
ret = ZBarcode_Encode(symbol, text, length);
assert_zero(ret, "i:%d ZBarcode_Encode(%d) ret %d != 0 %s\n", i, data[i].symbology, ret, symbol->errtxt);
ret = ZBarcode_Buffer(symbol, 0);
assert_zero(ret, "i:%d ZBarcode_Buffer(%d) ret %d != 0\n", i, data[i].symbology, ret);
assert_nonnull(symbol->bitmap, "i:%d ZBarcode_Buffer(%d) bitmap NULL\n", i, data[i].symbology);
if (generate) {
printf(" /*%3d*/ { %s, \"%s\", \"%s\", %d, %d, %d, %d, %d },\n",
i, testUtilBarcodeName(data[i].symbology), data[i].data, data[i].composite,
symbol->height, symbol->rows, symbol->width, symbol->bitmap_width, symbol->bitmap_height);
} else {
assert_equal(symbol->height, data[i].expected_height, "i:%d (%s) symbol->height %d != %d\n", i, testUtilBarcodeName(data[i].symbology), symbol->height, data[i].expected_height);
assert_equal(symbol->rows, data[i].expected_rows, "i:%d (%s) symbol->rows %d != %d\n", i, testUtilBarcodeName(data[i].symbology), symbol->rows, data[i].expected_rows);
assert_equal(symbol->width, data[i].expected_width, "i:%d (%s) symbol->width %d != %d\n", i, testUtilBarcodeName(data[i].symbology), symbol->width, data[i].expected_width);
assert_equal(symbol->bitmap_width, data[i].expected_bitmap_width, "i:%d (%s) symbol->bitmap_width %d != %d\n",
i, testUtilBarcodeName(data[i].symbology), symbol->bitmap_width, data[i].expected_bitmap_width);
assert_equal(symbol->bitmap_height, data[i].expected_bitmap_height, "i:%d (%s) symbol->bitmap_height %d != %d\n",
i, testUtilBarcodeName(data[i].symbology), symbol->bitmap_height, data[i].expected_bitmap_height);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_chk_extendable(int index, int debug) {
testStart("");
@ -116,6 +341,7 @@ static void test_row_separator(int index, int debug) {
int ret;
struct item {
int symbology;
int option_1;
int option_3;
unsigned char *data;
int ret;
@ -131,13 +357,14 @@ static void test_row_separator(int index, int debug) {
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_CODABLOCKF, -1, "A", 0, 20, 2, 101, 210, 48, 22, 28, 4 }, // Col 28 TODO: investigate extra 2 compared to vector 26
/* 1*/ { BARCODE_CODABLOCKF, 0, "A", 0, 20, 2, 101, 210, 48, 22, 28, 4 }, // Same as default
/* 2*/ { BARCODE_CODABLOCKF, 1, "A", 0, 20, 2, 101, 210, 48, 23, 28, 2 },
/* 3*/ { BARCODE_CODABLOCKF, 2, "A", 0, 20, 2, 101, 210, 48, 22, 28, 4 }, // Same as default
/* 4*/ { BARCODE_CODABLOCKF, 3, "A", 0, 20, 2, 101, 210, 48, 21, 28, 6 },
/* 5*/ { BARCODE_CODABLOCKF, 4, "A", 0, 20, 2, 101, 210, 48, 20, 28, 8 },
/* 6*/ { BARCODE_CODABLOCKF, 5, "A", 0, 20, 2, 101, 210, 48, 22, 28, 4 }, // > 4 ignored, same as default
/* 0*/ { BARCODE_CODABLOCKF, -1, -1, "A", 0, 20, 2, 101, 242, 44, 21, 42, 2 },
/* 1*/ { BARCODE_CODABLOCKF, -1, 0, "A", 0, 20, 2, 101, 242, 44, 21, 42, 2 }, // Same as default
/* 2*/ { BARCODE_CODABLOCKF, -1, 1, "A", 0, 20, 2, 101, 242, 44, 21, 42, 2 }, // Same as default
/* 3*/ { BARCODE_CODABLOCKF, -1, 2, "A", 0, 20, 2, 101, 242, 44, 20, 42, 4 },
/* 4*/ { BARCODE_CODABLOCKF, -1, 3, "A", 0, 20, 2, 101, 242, 44, 19, 42, 6 },
/* 5*/ { BARCODE_CODABLOCKF, -1, 4, "A", 0, 20, 2, 101, 242, 44, 18, 42, 8 },
/* 6*/ { BARCODE_CODABLOCKF, -1, 5, "A", 0, 20, 2, 101, 242, 44, 21, 42, 2 }, // > 4 ignored, same as default
/* 7*/ { BARCODE_CODABLOCKF, 1, -1, "A", 0, 5, 1, 46, 132, 14, 0, 20 + 2, 2 }, // CODE128 top separator, add 2 to skip over end of start char
};
int data_size = ARRAY_SIZE(data);
@ -148,7 +375,7 @@ static void test_row_separator(int index, int debug) {
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, data[i].option_3, -1 /*output_options*/, data[i].data, -1, debug);
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, data[i].option_1, -1, data[i].option_3, -1 /*output_options*/, data[i].data, -1, debug);
ret = ZBarcode_Encode_and_Buffer(symbol, data[i].data, length, 0);
assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret);
@ -162,17 +389,21 @@ static void test_row_separator(int index, int debug) {
int j, separator_bits_set;
//testUtilBitmapPrint(symbol);
for (j = data[i].expected_separator_row; j < data[i].expected_separator_row + data[i].expected_separator_height; j++) {
separator_bits_set = is_row_column_black(symbol, j, data[i].expected_separator_col);
assert_nonzero(separator_bits_set, "i:%d (%d) separator_bits_set (%d, %d) zero\n", i, data[i].symbology, j, data[i].expected_separator_col);
}
j = data[i].expected_separator_row - 1;
separator_bits_set = is_row_column_black(symbol, j, data[i].expected_separator_col);
assert_zero(separator_bits_set, "i:%d (%d) separator_bits_set (%d, %d) before non-zero\n", i, data[i].symbology, j, data[i].expected_separator_col);
if (symbol->rows > 1) {
j = data[i].expected_separator_row - 1;
separator_bits_set = is_row_column_black(symbol, j, data[i].expected_separator_col + 2); // Need to add 2 to skip to 1st blank of start row character
assert_zero(separator_bits_set, "i:%d (%d) separator_bits_set (%d, %d) before non-zero\n", i, data[i].symbology, j, data[i].expected_separator_col);
}
j = data[i].expected_separator_row + data[i].expected_separator_height;
separator_bits_set = is_row_column_black(symbol, j, data[i].expected_separator_col);
separator_bits_set = is_row_column_black(symbol, j, data[i].expected_separator_col + 2); // Need to add 2 to skip to 1st blank of start row character
assert_zero(separator_bits_set, "i:%d (%d) separator_bits_set (%d, %d) after non-zero\n", i, data[i].symbology, j, data[i].expected_separator_col);
ZBarcode_Delete(symbol);
@ -181,11 +412,87 @@ static void test_row_separator(int index, int debug) {
testFinish();
}
static void test_draw_string_wrap(int index, int debug) {
testStart("");
int ret;
struct item {
int symbology;
int output_options;
unsigned char *data;
unsigned char* text;
int expected_height;
int expected_rows;
int expected_width;
int expected_bitmap_width;
int expected_bitmap_height;
int expected_no_text_row;
int expected_no_text_col;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_CODE128, -1, "12", " E", 50, 1, 46, 92, 118, 104, 0 },
/* 1*/ { BARCODE_CODE128, BOLD_TEXT, "12", " E", 50, 1, 46, 92, 118, 104, 0 },
/* 2*/ { BARCODE_CODE128, SMALL_TEXT, "12", " E", 50, 1, 46, 92, 118, 103, 0 },
};
int data_size = sizeof(data) / sizeof(struct item);
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, data[i].output_options, data[i].data, -1, debug);
ret = ZBarcode_Encode(symbol, data[i].data, length);
assert_zero(ret, "i:%d ZBarcode_Encode(%d) ret %d != 0 %s\n", i, data[i].symbology, ret, symbol->errtxt);
// Cheat by overwriting text
strcpy(symbol->text, data[i].text);
ret = ZBarcode_Buffer(symbol, 0);
assert_zero(ret, "i:%d ZBarcode_Buffer(%d) ret %d != 0\n", i, data[i].symbology, ret);
assert_nonnull(symbol->bitmap, "i:%d (%d) symbol->bitmap NULL\n", i, data[i].symbology);
assert_equal(symbol->height, data[i].expected_height, "i:%d (%d) symbol->height %d != %d\n", i, data[i].symbology, symbol->height, data[i].expected_height);
assert_equal(symbol->rows, data[i].expected_rows, "i:%d (%d) symbol->rows %d != %d\n", i, data[i].symbology, symbol->rows, data[i].expected_rows);
assert_equal(symbol->width, data[i].expected_width, "i:%d (%d) symbol->width %d != %d\n", i, data[i].symbology, symbol->width, data[i].expected_width);
assert_equal(symbol->bitmap_width, data[i].expected_bitmap_width, "i:%d (%d) symbol->bitmap_width %d != %d\n", i, data[i].symbology, symbol->bitmap_width, data[i].expected_bitmap_width);
assert_equal(symbol->bitmap_height, data[i].expected_bitmap_height, "i:%d (%d) symbol->bitmap_height %d != %d\n", i, data[i].symbology, symbol->bitmap_height, data[i].expected_bitmap_height);
//testUtilBitmapPrint(symbol);
ret = ZBarcode_Print(symbol, 0);
assert_zero(ret, "i:%d ZBarcode_Print(%d) ret %d != 0\n", i, data[i].symbology, ret);
int text_bits_set = 0;
int row = data[i].expected_no_text_row;
for (int column = data[i].expected_no_text_col; column < data[i].expected_no_text_col + 16; column++) {
if (is_row_column_black(symbol, row, column)) {
text_bits_set = 1;
break;
}
}
assert_zero(text_bits_set, "i:%d (%d) text_bits_set non-zero\n", i, data[i].symbology);
ZBarcode_Delete(symbol);
}
testFinish();
}
int main(int argc, char *argv[]) {
testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */
{ "test_options", test_options, 1, 0, 1 },
{ "test_buffer", test_buffer, 1, 1, 1 },
{ "test_chk_extendable", test_chk_extendable, 1, 0, 1 },
{ "test_row_separator", test_row_separator, 1, 0, 1 },
{ "test_draw_string_wrap", test_draw_string_wrap, 1, 0, 1 },
};
testRun(argc, argv, funcs, ARRAY_SIZE(funcs));

View file

@ -60,6 +60,67 @@ static struct zint_vector_rect *find_rect(struct zint_symbol *symbol, int x, int
return rect;
}
static void test_options(int index, int debug) {
testStart("");
int ret;
struct item {
int symbology;
char *fgcolour;
char *bgcolour;
int rotate_angle;
unsigned char *data;
int ret;
int expected_rows;
int expected_width;
float expected_vector_width;
float expected_vector_height;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_CODE128, "123456", "7890ab", 0, "A", 0, 1, 46, 92, 118 },
/* 1*/ { BARCODE_CODE128, "12345", NULL, 0, "A", ZINT_ERROR_INVALID_OPTION, -1, -1, -1, -1 },
/* 2*/ { BARCODE_CODE128, NULL, "1234567", 0, "A", ZINT_ERROR_INVALID_OPTION, -1, -1, -1, -1 },
/* 3*/ { BARCODE_CODE128, "12345 ", NULL, 0, "A", ZINT_ERROR_INVALID_OPTION, -1, -1, -1, -1 },
/* 4*/ { BARCODE_CODE128, NULL, "EEFFGG", 0, "A", ZINT_ERROR_INVALID_OPTION, -1, -1, -1, -1 },
};
int data_size = ARRAY_SIZE(data);
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, BARCODE_CODE128, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
if (data[i].fgcolour) {
strcpy(symbol->fgcolour, data[i].fgcolour);
}
if (data[i].bgcolour) {
strcpy(symbol->bgcolour, data[i].bgcolour);
}
ret = ZBarcode_Encode_and_Buffer_Vector(symbol, data[i].data, length, data[i].rotate_angle);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < 5) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
assert_equal(symbol->vector->width, data[i].expected_vector_width, "i:%d (%s) symbol->vector->width %f != %f\n",
i, testUtilBarcodeName(data[i].symbology), symbol->vector->width, data[i].expected_vector_width);
assert_equal(symbol->vector->height, data[i].expected_vector_height, "i:%d (%s) symbol->vector->height %f != %f\n",
i, testUtilBarcodeName(data[i].symbology), symbol->vector->height, data[i].expected_vector_height);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_buffer_vector(int index, int generate, int debug) {
testStart("");
@ -92,8 +153,8 @@ static void test_buffer_vector(int index, int generate, int debug) {
/* 12*/ { BARCODE_CODE128, "0000000000", "", 50, 1, 90, 180.0, 118.0 },
/* 13*/ { BARCODE_DPLEIT, "1234567890123", "", 50, 1, 135, 270.0, 118.0 },
/* 14*/ { BARCODE_DPIDENT, "12345678901", "", 50, 1, 117, 234.0, 118.0 },
/* 15*/ { BARCODE_CODE16K, "0000000000", "", 20, 2, 70, 212.0, 48.0 },
/* 16*/ { BARCODE_CODE49, "0000000000", "", 20, 2, 70, 188.0, 48.0 },
/* 15*/ { BARCODE_CODE16K, "0000000000", "", 20, 2, 70, 162.0, 44.0 },
/* 16*/ { BARCODE_CODE49, "0000000000", "", 20, 2, 70, 162.0, 44.0 },
/* 17*/ { BARCODE_CODE93, "0000000000", "", 50, 1, 127, 254.0, 118.0 },
/* 18*/ { BARCODE_FLAT, "1234567890", "", 50, 1, 90, 180.0, 100.0 },
/* 19*/ { BARCODE_RSS14, "1234567890123", "", 50, 1, 96, 192.0, 118.0 },
@ -125,7 +186,7 @@ static void test_buffer_vector(int index, int generate, int debug) {
/* 45*/ { BARCODE_DATAMATRIX, "ABC", "", 10, 10, 10, 20.0, 20.0 },
/* 46*/ { BARCODE_EAN14, "1234567890123", "", 50, 1, 134, 268.0, 118.0 },
/* 47*/ { BARCODE_VIN, "00000000000000000", "", 50, 1, 246, 492.0, 118.0 },
/* 48*/ { BARCODE_CODABLOCKF, "0000000000", "", 20, 2, 101, 210.0, 48.0 },
/* 48*/ { BARCODE_CODABLOCKF, "0000000000", "", 20, 2, 101, 242.0, 44.0 },
/* 49*/ { BARCODE_NVE18, "12345678901234567", "", 50, 1, 156, 312.0, 118.0 },
/* 50*/ { BARCODE_JAPANPOST, "0000000000", "", 8, 3, 133, 266.0, 16.0 },
/* 51*/ { BARCODE_KOREAPOST, "123456", "", 50, 1, 167, 334.0, 118.0 },
@ -148,7 +209,7 @@ static void test_buffer_vector(int index, int generate, int debug) {
/* 68*/ { BARCODE_HIBC_QR, "1234567890AB", "", 21, 21, 21, 42.0, 42.0 },
/* 69*/ { BARCODE_HIBC_PDF, "0000000000", "", 27, 9, 103, 206.0, 54.0 },
/* 70*/ { BARCODE_HIBC_MICPDF, "0000000000", "", 34, 17, 38, 76.0, 68.0 },
/* 71*/ { BARCODE_HIBC_BLOCKF, "0000000000", "", 30, 3, 101, 210.0, 68.0 },
/* 71*/ { BARCODE_HIBC_BLOCKF, "0000000000", "", 30, 3, 101, 242.0, 64.0 },
/* 72*/ { BARCODE_HIBC_AZTEC, "1234567890AB", "", 19, 19, 19, 38.0, 38.0 },
/* 73*/ { BARCODE_DOTCODE, "ABC", "", 11, 11, 16, 32.0, 22.0 },
/* 74*/ { BARCODE_HANXIN, "1234567890AB", "", 23, 23, 23, 46.0, 46.0 },
@ -169,7 +230,8 @@ static void test_buffer_vector(int index, int generate, int debug) {
/* 89*/ { BARCODE_CODEONE, "12345678901234567890", "", 22, 22, 22, 44.0, 44.0 },
/* 90*/ { BARCODE_GRIDMATRIX, "ABC", "", 18, 18, 18, 36.0, 36.0 },
/* 91*/ { BARCODE_UPNQR, "1234567890AB", "", 77, 77, 77, 154.0, 154.0 },
/* 92*/ { BARCODE_RMQR, "12345", "", 11, 11, 27, 54.0, 22.0 },
/* 92*/ { BARCODE_ULTRA, "0000000000", "", 13, 13, 18, 36.0, 26.0 },
/* 93*/ { BARCODE_RMQR, "12345", "", 11, 11, 27, 54.0, 22.0 },
};
int data_size = sizeof(data) / sizeof(struct item);
@ -347,6 +409,7 @@ static void test_row_separator(int index, int debug) {
int ret;
struct item {
int symbology;
int option_1;
int option_3;
unsigned char *data;
int ret;
@ -360,13 +423,14 @@ static void test_row_separator(int index, int debug) {
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_CODABLOCKF, -1, "A", 0, 20, 2, 101, 22, 26, 4 },
/* 1*/ { BARCODE_CODABLOCKF, 0, "A", 0, 20, 2, 101, 22, 26, 4 }, // Same as default
/* 2*/ { BARCODE_CODABLOCKF, 1, "A", 0, 20, 2, 101, 23, 26, 2 },
/* 3*/ { BARCODE_CODABLOCKF, 2, "A", 0, 20, 2, 101, 22, 26, 4 }, // Same as default
/* 4*/ { BARCODE_CODABLOCKF, 3, "A", 0, 20, 2, 101, 21, 26, 6 },
/* 5*/ { BARCODE_CODABLOCKF, 4, "A", 0, 20, 2, 101, 20, 26, 8 },
/* 6*/ { BARCODE_CODABLOCKF, 5, "A", 0, 20, 2, 101, 22, 26, 4 }, // > 4 ignored, same as default
/* 0*/ { BARCODE_CODABLOCKF, -1, -1, "A", 0, 20, 2, 101, 21, 42, 2 },
/* 1*/ { BARCODE_CODABLOCKF, -1, 0, "A", 0, 20, 2, 101, 21, 42, 2 }, // Same as default
/* 2*/ { BARCODE_CODABLOCKF, -1, 1, "A", 0, 20, 2, 101, 21, 42, 2 }, // Same as default
/* 3*/ { BARCODE_CODABLOCKF, -1, 2, "A", 0, 20, 2, 101, 20, 42, 4 },
/* 4*/ { BARCODE_CODABLOCKF, -1, 3, "A", 0, 20, 2, 101, 19, 42, 6 },
/* 5*/ { BARCODE_CODABLOCKF, -1, 4, "A", 0, 20, 2, 101, 18, 42, 8 },
/* 6*/ { BARCODE_CODABLOCKF, -1, 5, "A", 0, 20, 2, 101, 21, 42, 2 }, // > 4 ignored, same as default
/* 7*/ { BARCODE_CODABLOCKF, 1, -1, "A", 0, 5, 1, 46, 0, 20, 2 }, // CODE128 top separator
};
int data_size = ARRAY_SIZE(data);
@ -379,7 +443,7 @@ static void test_row_separator(int index, int debug) {
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, data[i].option_3, -1 /*output_options*/, data[i].data, -1, debug);
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, data[i].option_1, -1, data[i].option_3, -1 /*output_options*/, data[i].data, -1, debug);
ret = ZBarcode_Encode(symbol, data[i].data, length);
assert_zero(ret, "i:%d ZBarcode_Encode(%d) ret %d != 0 %s\n", i, data[i].symbology, ret, symbol->errtxt);
@ -404,6 +468,7 @@ static void test_row_separator(int index, int debug) {
int main(int argc, char *argv[]) {
testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */
{ "test_options", test_options, 1, 0, 1 },
{ "test_buffer_vector", test_buffer_vector, 1, 1, 1 },
{ "test_noncomposite_string_x", test_noncomposite_string_x, 1, 0, 1 },
{ "test_upcean_whitespace_width", test_upcean_whitespace_width, 1, 0, 1 },

View file

@ -490,6 +490,53 @@ char *testUtilOption3Name(int option_3) {
return "-1";
}
char *testUtilOutputOptionsName(int output_options) {
static char buf[512];
struct item {
char *name;
int define;
int val;
};
struct item data[] = {
{ "BARCODE_NO_ASCII", BARCODE_NO_ASCII, 1 },
{ "BARCODE_BIND", BARCODE_BIND, 2 },
{ "BARCODE_BOX", BARCODE_BOX, 4 },
{ "BARCODE_STDOUT", BARCODE_STDOUT, 8 },
{ "READER_INIT", READER_INIT, 16 },
{ "SMALL_TEXT", SMALL_TEXT, 32 },
{ "BOLD_TEXT", BOLD_TEXT, 64 },
{ "CMYK_COLOUR", CMYK_COLOUR, 128 },
{ "BARCODE_DOTTY_MODE", BARCODE_DOTTY_MODE, 256 },
{ "GS1_GS_SEPARATOR", GS1_GS_SEPARATOR, 512 },
};
int data_size = ARRAY_SIZE(data);
int set = 0;
int i;
if (output_options == -1) {
return "-1";
}
if (output_options == 0) {
return "0";
}
buf[0] = '\0';
for (i = 0; i < data_size; i++) {
if (data[i].define != data[i].val) { // Self-check
fprintf(stderr, "testUtilOutputOptionsName data table out of sync (%d)\n", i);
abort();
}
if (output_options & data[i].define) {
if (set) {
strcat(buf, " | ");
}
strcat(buf, data[i].name);
set = 1;
}
}
return buf;
}
int testUtilDAFTConvert(const struct zint_symbol *symbol, char *buffer, int buffer_size) {
buffer[0] = '\0';
char *b = buffer;
@ -911,6 +958,33 @@ int testUtilModulesDumpHex(const struct zint_symbol *symbol, char dump[], int du
return d - dump;
}
void testUtilBitmapPrint(const struct zint_symbol *symbol) {
static char colour[] = { '0', 'C', 'B', 'M', 'R', 'Y', 'G', '1' };
int row, column, i, j;
fputs(" ", stdout);
for (column = 0; column < symbol->bitmap_width; column += 10) printf("%-3d ", column);
fputs("\n ", stdout);
for (column = 0; column < symbol->bitmap_width; column++) printf("%d", column % 10);
putchar('\n');
for (row = 0; row < symbol->bitmap_height; row++) {
printf("%3d: ", row);
for (column = 0; column < symbol->bitmap_width; column++) {
i = ((row * symbol->bitmap_width) + column) * 3;
j = (symbol->bitmap[i] == 0) + (symbol->bitmap[i + 1] == 0) * 2 + (symbol->bitmap[i + 2] == 0) * 4;
putchar(colour[j]);
}
putchar('\n');
}
fputs(" ", stdout);
for (column = 0; column < symbol->bitmap_width; column++) printf("%d", column % 10);
fputs("\n ", stdout);
for (column = 0; column < symbol->bitmap_width; column += 10) printf("%-3d ", column);
putchar('\n');
}
int testUtilExists(char *filename) {
FILE *fp = fopen(filename, "r");
if (fp == NULL) {

View file

@ -77,6 +77,7 @@ char *testUtilBarcodeName(int symbology);
char *testUtilErrorName(int error_number);
char *testUtilInputModeName(int input_mode);
char *testUtilOption3Name(int option_3);
char *testUtilOutputOptionsName(int output_options);
int testUtilDAFTConvert(const struct zint_symbol *symbol, char *buffer, int buffer_size);
char *testUtilEscape(char *buffer, int length, char *escaped, int escaped_size);
char *testUtilReadCSVField(char *buffer, char *field, int field_size);
@ -88,6 +89,7 @@ void testUtilLargeDump(const char *name, const short reg[]);
void testUtilModulesDump(const struct zint_symbol *symbol, char *prefix, char *postfix);
int testUtilModulesCmp(const struct zint_symbol *symbol, const char *expected, int *row, int *width);
int testUtilModulesDumpHex(const struct zint_symbol *symbol, char dump[], int dump_size);
void testUtilBitmapPrint(const struct zint_symbol *symbol);
int testUtilExists(char *filename);
int testUtilCmpPngs(char *file1, char *file2);
int testUtilCmpTxts(char *txt1, char *txt2);