mirror of
https://git.code.sf.net/p/zint/code
synced 2025-05-21 02:35:14 -04:00
- CODABLOCKF: fix misencodation of extended ASCII 0xB0-0xB9 when
followed by digit (ignore 2nd byte of FNC4 when categorizing Code C characters) - New `ZBarcode_Cap()` flag `ZINT_CAP_BINDABLE`, differentiated from `ZINT_CAP_STACKABLE`, and new Qt Backend method `isBindable()` - CLI: fix `separator` check to use new `ZINT_CAP_BINDABLE` instead of `ZINT_CAP_STACKABLE` - ZBarcode_Cap: add missing symbologies to `ZINT_CAP_BINDABLE` (was `ZINT_CAP_STACKABLE`) - DOTCODE: pad rows if given number of columns instead of failing if rows below min (5) - DBAR/composites: ensure stacked symbologies and composites are not stacked (set `symbol->rows` to 0) - test suite: move `test_perf` routines into single test "test_perf"; new "test_random" (based on "test_bwipp") to test various symbologies with random binary - discovered CODABLOCKF bug; expand "test_bwipp" manual: Feeback: mention AZTEC -1 meaning min & MICROPDF417: doc new `ZINT_CAP_BINDABLE` general: various code fiddlings and re-formattings
This commit is contained in:
parent
2370fbfbb7
commit
a74871a7de
60 changed files with 3509 additions and 3267 deletions
|
@ -398,10 +398,18 @@ static void test_large(const testCtx *const p_ctx) {
|
|||
testUtilEscape(data[i].pattern, (int) strlen(data[i].pattern), escaped, sizeof(escaped)),
|
||||
data[i].length, testUtilErrorName(ret), symbol->rows, symbol->width, data[i].zxingcpp_cmp,
|
||||
errtxt);
|
||||
|
||||
ZBarcode_Clear(symbol);
|
||||
symbol->input_mode |= FAST_MODE;
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, FAST_MODE /*input_mode*/, -1 /*eci*/,
|
||||
-1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/,
|
||||
data_buf, data[i].length, debug);
|
||||
if (data[i].structapp.count) {
|
||||
symbol->structapp = data[i].structapp;
|
||||
}
|
||||
|
||||
(void) ZBarcode_Encode(symbol, TCU(data_buf), length);
|
||||
printf(" \"%s\", \"%s\" },\n", strcmp(errtxt, symbol->errtxt) != 0 ? symbol->errtxt : "", data[i].comment);
|
||||
printf(" \"%s\", \"%s\" },\n",
|
||||
strcmp(errtxt, symbol->errtxt) != 0 ? symbol->errtxt : "", data[i].comment);
|
||||
} else {
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n",
|
||||
i, ret, data[i].ret, symbol->errtxt);
|
||||
|
@ -435,7 +443,13 @@ static void test_large(const testCtx *const p_ctx) {
|
|||
}
|
||||
|
||||
ZBarcode_Clear(symbol);
|
||||
symbol->input_mode |= FAST_MODE;
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, FAST_MODE /*input_mode*/, -1 /*eci*/,
|
||||
-1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/,
|
||||
data_buf, data[i].length, debug);
|
||||
if (data[i].structapp.count) {
|
||||
symbol->structapp = data[i].structapp;
|
||||
}
|
||||
|
||||
ret = ZBarcode_Encode(symbol, TCU(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);
|
||||
|
@ -519,18 +533,26 @@ static void test_buffer(const testCtx *const p_ctx) {
|
|||
symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
length = testUtilSetSymbol(symbol, BARCODE_DATAMATRIX, data[i].input_mode, data[i].eci, -1 /*option_1*/, -1, -1, data[i].output_options, data[i].data, -1, debug);
|
||||
length = testUtilSetSymbol(symbol, BARCODE_DATAMATRIX, data[i].input_mode, data[i].eci,
|
||||
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options,
|
||||
data[i].data, -1, debug);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret);
|
||||
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, -1, -1, debug)) {
|
||||
if (!data[i].bwipp_cmp) {
|
||||
if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d %s not BWIPP compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), data[i].comment);
|
||||
if (debug & ZINT_DEBUG_TEST_PRINT) {
|
||||
printf("i:%d %s not BWIPP compatible (%s)\n",
|
||||
i, testUtilBarcodeName(symbol->symbology), data[i].comment);
|
||||
}
|
||||
} else {
|
||||
char modules_dump[144 * 144 + 1];
|
||||
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i);
|
||||
ret = testUtilBwipp(i, symbol, -1, -1, -1, data[i].data, length, NULL, cmp_buf, sizeof(cmp_buf), NULL);
|
||||
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
|
||||
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1,
|
||||
"i:%d testUtilModulesDump == -1\n", i);
|
||||
ret = testUtilBwipp(i, symbol, -1, -1, -1, data[i].data, length, NULL, cmp_buf, sizeof(cmp_buf),
|
||||
NULL);
|
||||
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n",
|
||||
i, testUtilBarcodeName(symbol->symbology), ret);
|
||||
|
||||
ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, modules_dump);
|
||||
assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n",
|
||||
|
@ -705,13 +727,16 @@ static void test_options(const testCtx *const p_ctx) {
|
|||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
debug &= ~ZINT_DEBUG_TEST; /* Want real errtxt */
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, data[i].option_1, data[i].option_2, data[i].option_3, data[i].output_options, data[i].data, -1, debug);
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/,
|
||||
data[i].option_1, data[i].option_2, data[i].option_3, data[i].output_options,
|
||||
data[i].data, -1, debug);
|
||||
if (data[i].structapp.count) {
|
||||
symbol->structapp = data[i].structapp;
|
||||
}
|
||||
|
||||
ret = ZBarcode_Encode(symbol, TCU(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);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n",
|
||||
i, ret, data[i].ret, symbol->errtxt);
|
||||
|
||||
if (ret < ZINT_ERROR) {
|
||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (width %d) (%s)\n",
|
||||
|
@ -720,12 +745,18 @@ static void test_options(const testCtx *const p_ctx) {
|
|||
i, symbol->width, data[i].expected_width, symbol->errtxt);
|
||||
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, data[i].option_2, data[i].option_3, debug)) {
|
||||
if (!data[i].bwipp_cmp) {
|
||||
if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d %s not BWIPP compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), data[i].comment);
|
||||
if (debug & ZINT_DEBUG_TEST_PRINT) {
|
||||
printf("i:%d %s not BWIPP compatible (%s)\n",
|
||||
i, testUtilBarcodeName(symbol->symbology), data[i].comment);
|
||||
}
|
||||
} else {
|
||||
char modules_dump[144 * 144 + 1];
|
||||
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i);
|
||||
ret = testUtilBwipp(i, symbol, -1, data[i].option_2, data[i].option_3, data[i].data, length, NULL, cmp_buf, sizeof(cmp_buf), NULL);
|
||||
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
|
||||
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1,
|
||||
"i:%d testUtilModulesDump == -1\n", i);
|
||||
ret = testUtilBwipp(i, symbol, -1, data[i].option_2, data[i].option_3, data[i].data, length, NULL,
|
||||
cmp_buf, sizeof(cmp_buf), NULL);
|
||||
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n",
|
||||
i, testUtilBarcodeName(symbol->symbology), ret);
|
||||
|
||||
ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, modules_dump);
|
||||
assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n",
|
||||
|
@ -760,15 +791,26 @@ static void test_options(const testCtx *const p_ctx) {
|
|||
assert_zero(symbol->option_3, "i:%d symbol->option_3 %d != 0\n", i, symbol->option_3); /* Unchanged */
|
||||
}
|
||||
|
||||
symbol->input_mode |= FAST_MODE;
|
||||
ZBarcode_Clear(symbol);
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode | FAST_MODE, -1 /*eci*/,
|
||||
data[i].option_1, data[i].option_2, data[i].option_3, data[i].output_options,
|
||||
data[i].data, -1, debug);
|
||||
if (data[i].structapp.count) {
|
||||
symbol->structapp = data[i].structapp;
|
||||
}
|
||||
|
||||
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode FAST_MODE ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode FAST_MODE ret %d != %d (%s)\n",
|
||||
i, ret, data[i].ret, symbol->errtxt);
|
||||
|
||||
if (ret < ZINT_ERROR) {
|
||||
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);
|
||||
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);
|
||||
}
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d symbol->errtxt %s != %s\n", i, symbol->errtxt, data[i].expected_errtxt);
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d symbol->errtxt %s != %s\n",
|
||||
i, symbol->errtxt, data[i].expected_errtxt);
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
}
|
||||
|
@ -817,10 +859,13 @@ static void test_reader_init(const testCtx *const p_ctx) {
|
|||
|
||||
symbol->debug = ZINT_DEBUG_TEST; /* Needed to get codeword dump in errtxt */
|
||||
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1 /*option_2*/, -1, data[i].output_options, data[i].data, -1, debug);
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, 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, TCU(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);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n",
|
||||
i, ret, data[i].ret, symbol->errtxt);
|
||||
|
||||
if (p_ctx->generate) {
|
||||
printf(" /*%3d*/ { %s, %s, %s, \"%s\", %s, %d, %d, \"%s\", \"%s\" },\n",
|
||||
|
@ -838,8 +883,10 @@ static void test_reader_init(const testCtx *const p_ctx) {
|
|||
char modules_dump[144 * 144 + 1];
|
||||
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1,
|
||||
"i:%d testUtilModulesDump == -1\n", i);
|
||||
ret = testUtilBwipp(i, symbol, -1, -1, -1, data[i].data, length, NULL, cmp_buf, sizeof(cmp_buf), NULL);
|
||||
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
|
||||
ret = testUtilBwipp(i, symbol, -1, -1, -1, data[i].data, length, NULL, cmp_buf, sizeof(cmp_buf),
|
||||
NULL);
|
||||
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n",
|
||||
i, testUtilBarcodeName(symbol->symbology), ret);
|
||||
|
||||
ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, modules_dump);
|
||||
assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n",
|
||||
|
@ -862,7 +909,8 @@ static void test_reader_init(const testCtx *const p_ctx) {
|
|||
escaped);
|
||||
}
|
||||
}
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
|
||||
i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
|
@ -1180,7 +1228,8 @@ static void test_input(const testCtx *const p_ctx) {
|
|||
}
|
||||
|
||||
ret = ZBarcode_Encode(symbol, TCU(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);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n",
|
||||
i, ret, data[i].ret, symbol->errtxt);
|
||||
|
||||
if (p_ctx->generate) {
|
||||
printf(" /*%3d*/ { %s, %d, %d, %s, %s, { %d, %d, \"%s\" }, \"%s\", %s, %d, %d, %d, %d, %d, \"%s\", \"%s\", %d },\n",
|
||||
|
@ -1193,25 +1242,35 @@ static void test_input(const testCtx *const p_ctx) {
|
|||
data[i].bwipp_cmp, data[i].zxingcpp_cmp, symbol->errtxt, data[i].comment, data[i].expected_diff);
|
||||
} else {
|
||||
if (ret < ZINT_ERROR) {
|
||||
assert_equal(symbol->eci, data[i].expected_eci, "i:%d eci %d != %d\n", i, symbol->eci, data[i].expected_eci);
|
||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
||||
assert_equal(symbol->width, data[i].expected_width, "i:%d width %d != %d\n", i, symbol->width, data[i].expected_width);
|
||||
assert_equal(symbol->eci, data[i].expected_eci, "i:%d eci %d != %d\n",
|
||||
i, symbol->eci, data[i].expected_eci);
|
||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d rows %d != %d\n",
|
||||
i, symbol->rows, data[i].expected_rows);
|
||||
assert_equal(symbol->width, data[i].expected_width, "i:%d width %d != %d\n",
|
||||
i, symbol->width, data[i].expected_width);
|
||||
}
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
|
||||
i, symbol->errtxt, data[i].expected);
|
||||
|
||||
if (ret < ZINT_ERROR) {
|
||||
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, data[i].option_2, data[i].option_3, debug)) {
|
||||
if (!data[i].bwipp_cmp) {
|
||||
if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d %s not BWIPP compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), data[i].comment);
|
||||
if (debug & ZINT_DEBUG_TEST_PRINT) {
|
||||
printf("i:%d %s not BWIPP compatible (%s)\n",
|
||||
i, testUtilBarcodeName(symbol->symbology), data[i].comment);
|
||||
}
|
||||
} else {
|
||||
char modules_dump[144 * 144 + 1];
|
||||
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i);
|
||||
ret = testUtilBwipp(i, symbol, -1, data[i].option_2, data[i].option_3, data[i].data, length, NULL, cmp_buf, sizeof(cmp_buf), NULL);
|
||||
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
|
||||
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1,
|
||||
"i:%d testUtilModulesDump == -1\n", i);
|
||||
ret = testUtilBwipp(i, symbol, -1, data[i].option_2, data[i].option_3, data[i].data, length,
|
||||
NULL, cmp_buf, sizeof(cmp_buf), NULL);
|
||||
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n",
|
||||
i, testUtilBarcodeName(symbol->symbology), ret);
|
||||
|
||||
ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, modules_dump);
|
||||
assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n",
|
||||
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, modules_dump);
|
||||
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, modules_dump);
|
||||
}
|
||||
}
|
||||
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) {
|
||||
|
@ -1235,9 +1294,11 @@ static void test_input(const testCtx *const p_ctx) {
|
|||
|
||||
#ifdef ZINT_TEST_ENCODING
|
||||
if (ret < ZINT_ERROR) {
|
||||
if (i && (data[i].input_mode & 0x07) == (data[i - 1].input_mode & 0x07) && !(data[i].input_mode & FAST_MODE) && (data[i - 1].input_mode & FAST_MODE)
|
||||
if (i && (data[i].input_mode & 0x07) == (data[i - 1].input_mode & 0x07)
|
||||
&& !(data[i].input_mode & FAST_MODE) && (data[i - 1].input_mode & FAST_MODE)
|
||||
&& data[i].eci == data[i - 1].eci && data[i].option_2 == data[i - 1].option_2
|
||||
&& data[i].option_3 == data[i - 1].option_3 && data[i].output_options == data[i - 1].output_options
|
||||
&& data[i].option_3 == data[i - 1].option_3
|
||||
&& data[i].output_options == data[i - 1].output_options
|
||||
&& strcmp(data[i].data, data[i - 1].data) == 0) {
|
||||
unsigned char binary[2][2200];
|
||||
int gs1;
|
||||
|
@ -1246,10 +1307,12 @@ static void test_input(const testCtx *const p_ctx) {
|
|||
unsigned char reduced[1000];
|
||||
unsigned char *text;
|
||||
const int last_seg = 1;
|
||||
const int expected_rows_width = data[i].expected_rows * data[i].expected_width;
|
||||
const int prev_expected_rows_width = data[i - 1].expected_rows * data[i - 1].expected_width;
|
||||
|
||||
assert_equal(data[i].expected_rows * data[i].expected_width <= data[i - 1].expected_rows * data[i - 1].expected_width, 1,
|
||||
"i:%d data[i].expected_rows * data[i].expected_width %d > data[i - 1].expected_rows * data[i - 1].expected_width %d\n", i,
|
||||
data[i].expected_rows * data[i].expected_width, data[i - 1].expected_rows * data[i - 1].expected_width);
|
||||
assert_equal(expected_rows_width <= prev_expected_rows_width, 1,
|
||||
"i:%d expected_rows_width %d > prev_expected_rows_width %d\n",
|
||||
i, expected_rows_width, prev_expected_rows_width);
|
||||
|
||||
if ((data[i].input_mode & 0x07) == GS1_MODE) {
|
||||
ret = gs1_verify(symbol, (unsigned char *) data[i].data, length, reduced, &length);
|
||||
|
@ -1261,7 +1324,8 @@ static void test_input(const testCtx *const p_ctx) {
|
|||
binlen = 0;
|
||||
symbol->input_mode = data[i - 1].input_mode;
|
||||
symbol->option_2 = data[i].option_2 != -1 ? data[i].option_2 : 0; /* Restore option_2 */
|
||||
gs1 = (symbol->input_mode & 0x07) != GS1_MODE ? 0 : (symbol->output_options & GS1_GS_SEPARATOR) ? 2 : 1;
|
||||
gs1 = (symbol->input_mode & 0x07) != GS1_MODE ? 0 :
|
||||
(symbol->output_options & GS1_GS_SEPARATOR) ? 2 : 1;
|
||||
ret = dm_encode_test(symbol, text, length, symbol->eci, last_seg, gs1, binary[0], &binlen);
|
||||
assert_zero(ret, "i:%d dm_encode() FAST_MODE ret %d != 0 (%s)\n", i, ret, symbol->errtxt);
|
||||
|
||||
|
@ -1269,17 +1333,20 @@ static void test_input(const testCtx *const p_ctx) {
|
|||
|
||||
binlen = 0;
|
||||
symbol->input_mode = data[i].input_mode;
|
||||
gs1 = (symbol->input_mode & 0x07) != GS1_MODE ? 0 : (symbol->output_options & GS1_GS_SEPARATOR) ? 2 : 1;
|
||||
gs1 = (symbol->input_mode & 0x07) != GS1_MODE ? 0 :
|
||||
(symbol->output_options & GS1_GS_SEPARATOR) ? 2 : 1;
|
||||
symbol->option_2 = data[i].option_2 != -1 ? data[i].option_2 : 0; /* Restore option_2 */
|
||||
ret = dm_encode_test(symbol, text, length, symbol->eci, last_seg, gs1, binary[1], &binlen);
|
||||
assert_zero(ret, "i:%d dm_encode() minimal ret %d != 0 (%s)\n", i, ret, symbol->errtxt);
|
||||
|
||||
binlens[1] = binlen;
|
||||
|
||||
assert_equal(binlens[0], binlens[1] + data[i].expected_diff, "i:%d binlens[0] %d != %d binlens[1] (%d) + expected_diff (%d)\n",
|
||||
assert_equal(binlens[0], binlens[1] + data[i].expected_diff,
|
||||
"i:%d binlens[0] %d != %d binlens[1] (%d) + expected_diff (%d)\n",
|
||||
i, binlens[0], binlens[1] + data[i].expected_diff, binlens[1], data[i].expected_diff);
|
||||
if (data[i].expected_diff >= 0) {
|
||||
assert_equal(binlens[1] <= binlens[0], 1, "i:%d binlens[1] %d > binlens[0] %d\n", i, binlens[1], binlens[0]);
|
||||
assert_equal(binlens[1] <= binlens[0], 1, "i:%d binlens[1] %d > binlens[0] %d\n",
|
||||
i, binlens[1], binlens[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5777,22 +5844,31 @@ static void test_encode(const testCtx *const p_ctx) {
|
|||
if (ret < ZINT_ERROR) {
|
||||
int width, row;
|
||||
|
||||
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->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);
|
||||
|
||||
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);
|
||||
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n",
|
||||
i, ret, width, row, data[i].data);
|
||||
|
||||
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, data[i].option_2, data[i].option_3, debug)) {
|
||||
if (!data[i].bwipp_cmp) {
|
||||
if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d %s not BWIPP compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), data[i].comment);
|
||||
if (debug & ZINT_DEBUG_TEST_PRINT) {
|
||||
printf("i:%d %s not BWIPP compatible (%s)\n",
|
||||
i, testUtilBarcodeName(symbol->symbology), data[i].comment);
|
||||
}
|
||||
} else {
|
||||
ret = testUtilBwipp(i, symbol, -1, data[i].option_2, data[i].option_3, data[i].data, length, NULL, cmp_buf, sizeof(cmp_buf), NULL);
|
||||
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
|
||||
ret = testUtilBwipp(i, symbol, -1, data[i].option_2, data[i].option_3, data[i].data, length,
|
||||
NULL, cmp_buf, sizeof(cmp_buf), NULL);
|
||||
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n",
|
||||
i, testUtilBarcodeName(symbol->symbology), ret);
|
||||
|
||||
ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, data[i].expected);
|
||||
assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n",
|
||||
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, data[i].expected);
|
||||
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf,
|
||||
data[i].expected);
|
||||
}
|
||||
}
|
||||
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) {
|
||||
|
@ -5814,23 +5890,28 @@ static void test_encode(const testCtx *const p_ctx) {
|
|||
}
|
||||
|
||||
#ifdef ZINT_TEST_ENCODING
|
||||
if (i && (data[i].input_mode & 0x07) == (data[i - 1].input_mode & 0x07) && !(data[i].input_mode & FAST_MODE) && (data[i - 1].input_mode & FAST_MODE)
|
||||
if (i && (data[i].input_mode & 0x07) == (data[i - 1].input_mode & 0x07)
|
||||
&& !(data[i].input_mode & FAST_MODE) && (data[i - 1].input_mode & FAST_MODE)
|
||||
&& data[i].eci == data[i - 1].eci && data[i].option_2 == data[i - 1].option_2
|
||||
&& data[i].option_3 == data[i - 1].option_3 && data[i].output_options == data[i - 1].output_options
|
||||
&& data[i].option_3 == data[i - 1].option_3
|
||||
&& data[i].output_options == data[i - 1].output_options
|
||||
&& strcmp(data[i].data, data[i - 1].data) == 0) {
|
||||
unsigned char binary[2][2200];
|
||||
int gs1;
|
||||
int binlen;
|
||||
int binlens[2] = {0};
|
||||
const int last_seg = 1;
|
||||
const int expected_rows_width = data[i].expected_rows * data[i].expected_width;
|
||||
const int prev_expected_rows_width = data[i - 1].expected_rows * data[i - 1].expected_width;
|
||||
|
||||
assert_equal(data[i].expected_rows * data[i].expected_width <= data[i - 1].expected_rows * data[i - 1].expected_width, 1,
|
||||
"i:%d data[i].expected_rows * data[i].expected_width %d > data[i - 1].expected_rows * data[i - 1].expected_width %d\n", i,
|
||||
data[i].expected_rows * data[i].expected_width, data[i - 1].expected_rows * data[i - 1].expected_width);
|
||||
assert_equal(expected_rows_width <= prev_expected_rows_width, 1,
|
||||
"i:%d expected_rows_width %d > prev_expected_rows_width %d\n", i,
|
||||
expected_rows_width, prev_expected_rows_width);
|
||||
|
||||
binlen = 0;
|
||||
symbol->input_mode = data[i - 1].input_mode;
|
||||
gs1 = (symbol->input_mode & 0x07) != GS1_MODE ? 0 : (symbol->output_options & GS1_GS_SEPARATOR) ? 2 : 1;
|
||||
gs1 = (symbol->input_mode & 0x07) != GS1_MODE ? 0 :
|
||||
(symbol->output_options & GS1_GS_SEPARATOR) ? 2 : 1;
|
||||
ret = dm_encode_test(symbol, (unsigned char *) data[i].data, length, symbol->eci, last_seg, gs1,
|
||||
binary[0], &binlen);
|
||||
assert_zero(ret, "i:%d dm_encode() FAST_MODE ret %d != 0 (%s)\n", i, ret, symbol->errtxt);
|
||||
|
@ -5839,14 +5920,16 @@ static void test_encode(const testCtx *const p_ctx) {
|
|||
|
||||
binlen = 0;
|
||||
symbol->input_mode = data[i].input_mode;
|
||||
gs1 = (symbol->input_mode & 0x07) != GS1_MODE ? 0 : (symbol->output_options & GS1_GS_SEPARATOR) ? 2 : 1;
|
||||
gs1 = (symbol->input_mode & 0x07) != GS1_MODE ? 0 :
|
||||
(symbol->output_options & GS1_GS_SEPARATOR) ? 2 : 1;
|
||||
ret = dm_encode_test(symbol, (unsigned char *) data[i].data, length, symbol->eci, last_seg, gs1,
|
||||
binary[1], &binlen);
|
||||
assert_zero(ret, "i:%d dm_encode() minimal ret %d != 0 (%s)\n", i, ret, symbol->errtxt);
|
||||
|
||||
binlens[1] = binlen;
|
||||
|
||||
assert_equal(binlens[1] <= binlens[0], 1, "i:%d binlens[1] %d > binlens[0] %d\n", i, binlens[1], binlens[0]);
|
||||
assert_equal(binlens[1] <= binlens[0], 1, "i:%d binlens[1] %d > binlens[0] %d\n",
|
||||
i, binlens[1], binlens[0]);
|
||||
assert_equal(binlens[0], binlens[1] + data[i].expected_diff,
|
||||
"i:%d binlens[0] %d != %d binlens[1] (%d) + expected_diff (%d)\n",
|
||||
i, binlens[0], binlens[1] + data[i].expected_diff, binlens[1], data[i].expected_diff);
|
||||
|
@ -6198,8 +6281,9 @@ static void test_encode_segs(const testCtx *const p_ctx) {
|
|||
char cmp_buf[32768];
|
||||
char cmp_msg[1024];
|
||||
|
||||
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
|
||||
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */
|
||||
/* Only do BWIPP/ZXing-C++ tests if asked, too slow otherwise */
|
||||
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript();
|
||||
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder();
|
||||
|
||||
testStartSymbol(p_ctx->func_name, &symbol);
|
||||
|
||||
|
@ -6211,15 +6295,16 @@ static void test_encode_segs(const testCtx *const p_ctx) {
|
|||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/,
|
||||
-1 /*option_1*/, data[i].option_2, data[i].option_3, data[i].output_options,
|
||||
NULL, 0, debug);
|
||||
-1 /*option_1*/, data[i].option_2, data[i].option_3, data[i].output_options,
|
||||
NULL, 0, debug);
|
||||
if (data[i].structapp.count) {
|
||||
symbol->structapp = data[i].structapp;
|
||||
}
|
||||
for (j = 0, seg_count = 0; j < 3 && data[i].segs[j].length; j++, seg_count++);
|
||||
|
||||
ret = ZBarcode_Encode_Segs(symbol, data[i].segs, seg_count);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode_Segs ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode_Segs ret %d != %d (%s)\n",
|
||||
i, ret, data[i].ret, symbol->errtxt);
|
||||
|
||||
if (p_ctx->generate) {
|
||||
char escaped1[4096];
|
||||
|
@ -6232,9 +6317,12 @@ static void test_encode_segs(const testCtx *const p_ctx) {
|
|||
testUtilOutputOptionsName(data[i].output_options),
|
||||
data[i].option_2, testUtilOption3Name(data[i].symbology, data[i].option_3),
|
||||
data[i].structapp.index, data[i].structapp.count, data[i].structapp.id,
|
||||
testUtilEscape((const char *) data[i].segs[0].source, length, escaped, sizeof(escaped)), data[i].segs[0].length, data[i].segs[0].eci,
|
||||
testUtilEscape((const char *) data[i].segs[1].source, length1, escaped1, sizeof(escaped1)), data[i].segs[1].length, data[i].segs[1].eci,
|
||||
testUtilEscape((const char *) data[i].segs[2].source, length2, escaped2, sizeof(escaped2)), data[i].segs[2].length, data[i].segs[2].eci,
|
||||
testUtilEscape((const char *) data[i].segs[0].source, length, escaped, sizeof(escaped)),
|
||||
data[i].segs[0].length, data[i].segs[0].eci,
|
||||
testUtilEscape((const char *) data[i].segs[1].source, length1, escaped1, sizeof(escaped1)),
|
||||
data[i].segs[1].length, data[i].segs[1].eci,
|
||||
testUtilEscape((const char *) data[i].segs[2].source, length2, escaped2, sizeof(escaped2)),
|
||||
data[i].segs[2].length, data[i].segs[2].eci,
|
||||
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].comment);
|
||||
testUtilModulesPrint(symbol, " ", "\n");
|
||||
printf(" },\n");
|
||||
|
@ -6242,25 +6330,34 @@ static void test_encode_segs(const testCtx *const p_ctx) {
|
|||
if (ret < ZINT_ERROR) {
|
||||
int width, row;
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
|
||||
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d\n", i, ret, width, row);
|
||||
|
||||
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, data[i].option_2, data[i].option_3, debug)) {
|
||||
if (!data[i].bwipp_cmp) {
|
||||
if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d %s not BWIPP compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), data[i].comment);
|
||||
if (debug & ZINT_DEBUG_TEST_PRINT) {
|
||||
printf("i:%d %s not BWIPP compatible (%s)\n",
|
||||
i, testUtilBarcodeName(symbol->symbology), data[i].comment);
|
||||
}
|
||||
} else {
|
||||
ret = testUtilBwippSegs(i, symbol, -1, data[i].option_2, data[i].option_3, data[i].segs, seg_count, NULL, cmp_buf, sizeof(cmp_buf));
|
||||
assert_zero(ret, "i:%d %s testUtilBwippSegs ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
|
||||
ret = testUtilBwippSegs(i, symbol, -1, data[i].option_2, data[i].option_3, data[i].segs,
|
||||
seg_count, NULL, cmp_buf, sizeof(cmp_buf));
|
||||
assert_zero(ret, "i:%d %s testUtilBwippSegs ret %d != 0\n",
|
||||
i, testUtilBarcodeName(symbol->symbology), ret);
|
||||
|
||||
ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, data[i].expected);
|
||||
assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n",
|
||||
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, data[i].expected);
|
||||
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf,
|
||||
data[i].expected);
|
||||
}
|
||||
}
|
||||
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, (const char *) data[i].segs[0].source, data[i].segs[0].length, debug)) {
|
||||
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, (const char *) data[i].segs[0].source,
|
||||
data[i].segs[0].length, debug)) {
|
||||
if (data[i].input_mode == DATA_MODE) {
|
||||
if (debug & ZINT_DEBUG_TEST_PRINT) {
|
||||
printf("i:%d %s multiple segments in DATA_MODE not currently supported for ZXing-C++ testing\n",
|
||||
|
@ -6269,14 +6366,18 @@ static void test_encode_segs(const testCtx *const p_ctx) {
|
|||
} else {
|
||||
int cmp_len, ret_len;
|
||||
char modules_dump[144 * 144 + 1];
|
||||
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i);
|
||||
ret = testUtilZXingCPP(i, symbol, (const char *) data[i].segs[0].source, data[i].segs[0].length,
|
||||
modules_dump, 1 /*zxingcpp_cmp*/, cmp_buf, sizeof(cmp_buf), &cmp_len);
|
||||
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
|
||||
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1,
|
||||
"i:%d testUtilModulesDump == -1\n", i);
|
||||
ret = testUtilZXingCPP(i, symbol, (const char *) data[i].segs[0].source,
|
||||
data[i].segs[0].length, modules_dump, 1 /*zxingcpp_cmp*/, cmp_buf, sizeof(cmp_buf),
|
||||
&cmp_len);
|
||||
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n",
|
||||
i, testUtilBarcodeName(symbol->symbology), ret);
|
||||
|
||||
ret = testUtilZXingCPPCmpSegs(symbol, cmp_msg, cmp_buf, cmp_len, data[i].segs, seg_count,
|
||||
NULL /*primary*/, escaped, &ret_len);
|
||||
assert_zero(ret, "i:%d %s testUtilZXingCPPCmpSegs %d != 0 %s\n actual: %.*s\nexpected: %.*s\n",
|
||||
assert_zero(ret,
|
||||
"i:%d %s testUtilZXingCPPCmpSegs %d != 0 %s\n actual: %.*s\nexpected: %.*s\n",
|
||||
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len,
|
||||
escaped);
|
||||
}
|
||||
|
@ -7524,26 +7625,33 @@ static void test_minimalenc(const testCtx *const p_ctx) {
|
|||
symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, data[i].output_options, data[i].data, data[i].length, debug);
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/,
|
||||
-1 /*option_1*/, data[i].option_2, -1, data[i].output_options,
|
||||
data[i].data, data[i].length, debug);
|
||||
|
||||
binlen = 0;
|
||||
symbol->input_mode |= FAST_MODE;
|
||||
gs1 = (symbol->input_mode & 0x07) != GS1_MODE ? 0 : (symbol->output_options & GS1_GS_SEPARATOR) ? 2 : 1;
|
||||
ret = dm_encode_test(symbol, (unsigned char *) data[i].data, length, symbol->eci, last_seg, gs1, binary[0], &binlen);
|
||||
assert_equal(ret, data[i].ret, "i:%d dm_encode() FAST_MODE ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||
ret = dm_encode_test(symbol, (unsigned char *) data[i].data, length, symbol->eci, last_seg, gs1, binary[0],
|
||||
&binlen);
|
||||
assert_equal(ret, data[i].ret, "i:%d dm_encode() FAST_MODE ret %d != %d (%s)\n",
|
||||
i, ret, data[i].ret, symbol->errtxt);
|
||||
|
||||
binlens[0] = binlen;
|
||||
|
||||
binlen = 0;
|
||||
symbol->input_mode &= ~FAST_MODE;
|
||||
gs1 = (symbol->input_mode & 0x07) != GS1_MODE ? 0 : (symbol->output_options & GS1_GS_SEPARATOR) ? 2 : 1;
|
||||
ret = dm_encode_test(symbol, (unsigned char *) data[i].data, length, symbol->eci, last_seg, gs1, binary[1], &binlen);
|
||||
assert_equal(ret, data[i].ret, "i:%d dm_encode() minimal ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||
ret = dm_encode_test(symbol, (unsigned char *) data[i].data, length, symbol->eci, last_seg, gs1, binary[1],
|
||||
&binlen);
|
||||
assert_equal(ret, data[i].ret, "i:%d dm_encode() minimal ret %d != %d (%s)\n",
|
||||
i, ret, data[i].ret, symbol->errtxt);
|
||||
|
||||
binlens[1] = binlen;
|
||||
|
||||
fflush(stdout);
|
||||
assert_equal(binlens[0], binlens[1] + data[i].expected_diff, "i:%d binlens[0] %d != %d binlens[1] (%d) + expected_diff (%d)\n",
|
||||
assert_equal(binlens[0], binlens[1] + data[i].expected_diff,
|
||||
"i:%d binlens[0] %d != %d binlens[1] (%d) + expected_diff (%d)\n",
|
||||
i, binlens[0], binlens[1] + data[i].expected_diff, binlens[1], data[i].expected_diff);
|
||||
|
||||
if (debug & ZINT_DEBUG_TEST_PRINT) {
|
||||
|
@ -7563,180 +7671,6 @@ static void test_minimalenc(const testCtx *const p_ctx) {
|
|||
}
|
||||
#endif
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#if 1
|
||||
#define TEST_PERF_ITER_MILLES 5
|
||||
#define TEST_PERF_ITERATIONS (TEST_PERF_ITER_MILLES * 1000)
|
||||
#else
|
||||
#define TEST_PERF_ITERATIONS 100 /* For valgrind */
|
||||
#endif
|
||||
#define TEST_PERF_TIME(arg) (((arg) * 1000.0) / CLOCKS_PER_SEC)
|
||||
|
||||
/* Not a real test, just performance indicator */
|
||||
static void test_perf(const testCtx *const p_ctx) {
|
||||
int debug = p_ctx->debug;
|
||||
|
||||
struct item {
|
||||
int symbology;
|
||||
int input_mode;
|
||||
int option_2;
|
||||
int option_3;
|
||||
const char *data;
|
||||
int ret;
|
||||
|
||||
int expected_rows;
|
||||
int expected_width;
|
||||
const char *comment;
|
||||
};
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { BARCODE_DATAMATRIX, FAST_MODE, -1, -1,
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz&,:#-.$/+%*=^ABCDEFGHIJKLMNOPQRSTUVWXYZ12345678901234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLM"
|
||||
"NOPQRSTUVWXYZ;<>@[]_`~!||()?{}'123456789012345678901234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJK"
|
||||
"LMNOPQRSTUVWXYZ12345678912345678912345678912345678900001234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFG"
|
||||
"HIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ12345678901234567"
|
||||
"890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcde"
|
||||
"fghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNO",
|
||||
0, 96, 96, "960 chars, text/numeric" },
|
||||
/* 1*/ { BARCODE_DATAMATRIX, -1, -1, -1,
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz&,:#-.$/+%*=^ABCDEFGHIJKLMNOPQRSTUVWXYZ12345678901234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLM"
|
||||
"NOPQRSTUVWXYZ;<>@[]_`~!||()?{}'123456789012345678901234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJK"
|
||||
"LMNOPQRSTUVWXYZ12345678912345678912345678912345678900001234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFG"
|
||||
"HIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ12345678901234567"
|
||||
"890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcde"
|
||||
"fghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNO",
|
||||
0, 96, 96, "960 chars, text/numeric" },
|
||||
/* 2*/ { BARCODE_DATAMATRIX, DATA_MODE | FAST_MODE, -1, -1,
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240",
|
||||
0, 120, 120, "960 chars, byte" },
|
||||
/* 3*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, -1,
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
|
||||
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240",
|
||||
0, 120, 120, "960 chars, byte" },
|
||||
/* 4*/ { BARCODE_DATAMATRIX, FAST_MODE, -1, -1, "https://example.com/01/09506000134369", 0, 22, 22, "37 chars, text/numeric" },
|
||||
/* 5*/ { BARCODE_DATAMATRIX, -1, -1, -1, "https://example.com/01/09506000134369", 0, 22, 22, "37 chars, text/numeric" },
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
struct zint_symbol *symbol;
|
||||
|
||||
clock_t start;
|
||||
clock_t total_create = 0, total_encode = 0, total_buffer = 0, total_buf_inter = 0, total_print = 0;
|
||||
clock_t diff_create, diff_encode, diff_buffer, diff_buf_inter, diff_print;
|
||||
int comment_max = 0;
|
||||
|
||||
if (!(debug & ZINT_DEBUG_TEST_PERFORMANCE)) { /* -d 256 */
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < data_size; i++) if ((int) strlen(data[i].comment) > comment_max) comment_max = (int) strlen(data[i].comment);
|
||||
|
||||
printf("Iterations %d\n", TEST_PERF_ITERATIONS);
|
||||
|
||||
for (i = 0; i < data_size; i++) {
|
||||
int j;
|
||||
|
||||
if (testContinue(p_ctx, i)) continue;
|
||||
|
||||
diff_create = diff_encode = diff_buffer = diff_buf_inter = diff_print = 0;
|
||||
|
||||
for (j = 0; j < TEST_PERF_ITERATIONS; j++) {
|
||||
start = clock();
|
||||
symbol = ZBarcode_Create();
|
||||
diff_create += clock() - start;
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, data[i].option_3, -1 /*output_options*/, data[i].data, -1, debug);
|
||||
|
||||
start = clock();
|
||||
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
|
||||
diff_encode += clock() - start;
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||
|
||||
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);
|
||||
|
||||
start = clock();
|
||||
ret = ZBarcode_Buffer(symbol, 0 /*rotate_angle*/);
|
||||
diff_buffer += clock() - start;
|
||||
assert_zero(ret, "i:%d ZBarcode_Buffer ret %d != 0 (%s)\n", i, ret, symbol->errtxt);
|
||||
|
||||
symbol->output_options |= OUT_BUFFER_INTERMEDIATE;
|
||||
start = clock();
|
||||
ret = ZBarcode_Buffer(symbol, 0 /*rotate_angle*/);
|
||||
diff_buf_inter += clock() - start;
|
||||
assert_zero(ret, "i:%d ZBarcode_Buffer OUT_BUFFER_INTERMEDIATE ret %d != 0 (%s)\n", i, ret, symbol->errtxt);
|
||||
symbol->output_options &= ~OUT_BUFFER_INTERMEDIATE; /* Undo */
|
||||
|
||||
start = clock();
|
||||
ret = ZBarcode_Print(symbol, 0 /*rotate_angle*/);
|
||||
diff_print += clock() - start;
|
||||
assert_zero(ret, "i:%d ZBarcode_Print ret %d != 0 (%s)\n", i, ret, symbol->errtxt);
|
||||
assert_zero(testUtilRemove(symbol->outfile), "i:%d testUtilRemove(%s) != 0\n", i, symbol->outfile);
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
}
|
||||
|
||||
printf("%*s: encode % 8gms, buffer % 8gms, buf_inter % 8gms, print % 8gms, create % 8gms\n", comment_max, data[i].comment,
|
||||
TEST_PERF_TIME(diff_encode), TEST_PERF_TIME(diff_buffer), TEST_PERF_TIME(diff_buf_inter), TEST_PERF_TIME(diff_print), TEST_PERF_TIME(diff_create));
|
||||
|
||||
total_create += diff_create;
|
||||
total_encode += diff_encode;
|
||||
total_buffer += diff_buffer;
|
||||
total_buf_inter += diff_buf_inter;
|
||||
total_print += diff_print;
|
||||
}
|
||||
if (p_ctx->index == -1) {
|
||||
printf("%*s: encode % 8gms, buffer % 8gms, buf_inter % 8gms, print % 8gms, create % 8gms\n", comment_max, "totals",
|
||||
TEST_PERF_TIME(total_encode), TEST_PERF_TIME(total_buffer), TEST_PERF_TIME(total_buf_inter), TEST_PERF_TIME(total_print), TEST_PERF_TIME(total_create));
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
testFunction funcs[] = { /* name, func */
|
||||
|
@ -7752,7 +7686,6 @@ int main(int argc, char *argv[]) {
|
|||
#ifdef ZINT_TEST_ENCODING
|
||||
{ "test_minimalenc", test_minimalenc },
|
||||
#endif
|
||||
{ "test_perf", test_perf },
|
||||
};
|
||||
|
||||
testRun(argc, argv, funcs, ARRAY_SIZE(funcs));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue