mirror of
https://git.code.sf.net/p/zint/code
synced 2025-05-22 03:05:11 -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
|
@ -3599,96 +3599,6 @@ static void test_fuzz(const testCtx *const p_ctx) {
|
|||
testFinish();
|
||||
}
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#define TEST_PERF_ITERATIONS 1000
|
||||
|
||||
/* 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 option_1;
|
||||
const char *data;
|
||||
const char *composite;
|
||||
int ret;
|
||||
|
||||
int expected_rows;
|
||||
int expected_width;
|
||||
const char *comment;
|
||||
};
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { BARCODE_EANX_CC, 1, "123456789012",
|
||||
"[91]123456789012345678901234567890123456789012345678901234",
|
||||
0, 11, 99, "58 chars CC-A" },
|
||||
/* 1*/ { BARCODE_UPCA_CC, 2, "12345678901",
|
||||
"[91]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
|
||||
"[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
|
||||
"[93]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
|
||||
"[94]12345678901234567890123456789012345678901234567890",
|
||||
0, 48, 99, "336 chars CC-B" },
|
||||
/* 2*/ { BARCODE_GS1_128_CC, 3, "[01]12345678901231",
|
||||
"[91]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
|
||||
"[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
|
||||
"[93]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
|
||||
"[94]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
|
||||
"[95]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
|
||||
"[96]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
|
||||
0, 32, 205, "564 chars CC-C" },
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, composite_length, ret;
|
||||
|
||||
clock_t start, total_encode = 0, total_buffer = 0, diff_encode, diff_buffer;
|
||||
|
||||
if (!(debug & ZINT_DEBUG_TEST_PERFORMANCE)) { /* -d 256 */
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < data_size; i++) {
|
||||
int j;
|
||||
|
||||
if (testContinue(p_ctx, i)) continue;
|
||||
|
||||
diff_encode = diff_buffer = 0;
|
||||
|
||||
for (j = 0; j < TEST_PERF_ITERATIONS; j++) {
|
||||
struct zint_symbol *symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, data[i].option_1, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||
assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length);
|
||||
strcpy(symbol->primary, data[i].data);
|
||||
|
||||
composite_length = (int) strlen(data[i].composite);
|
||||
|
||||
start = clock();
|
||||
ret = ZBarcode_Encode(symbol, TCU(data[i].composite), composite_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);
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
}
|
||||
|
||||
printf("%s: diff_encode %gms, diff_buffer %gms\n", data[i].comment, diff_encode * 1000.0 / CLOCKS_PER_SEC, diff_buffer * 1000.0 / CLOCKS_PER_SEC);
|
||||
|
||||
total_encode += diff_encode;
|
||||
total_buffer += diff_buffer;
|
||||
}
|
||||
if (p_ctx->index != -1) {
|
||||
printf("totals: encode %gms, buffer %gms\n", total_encode * 1000.0 / CLOCKS_PER_SEC, total_buffer * 1000.0 / CLOCKS_PER_SEC);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
testFunction funcs[] = { /* name, func */
|
||||
|
@ -3705,7 +3615,6 @@ int main(int argc, char *argv[]) {
|
|||
{ "test_hrt", test_hrt },
|
||||
{ "test_input", test_input },
|
||||
{ "test_fuzz", test_fuzz },
|
||||
{ "test_perf", test_perf },
|
||||
};
|
||||
|
||||
testRun(argc, argv, funcs, ARRAY_SIZE(funcs));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue