2020-06-05 05:45:25 +12:00
|
|
|
/*
|
|
|
|
libzint - the open source barcode library
|
2022-04-10 22:12:18 +12:00
|
|
|
Copyright (C) 2020-2022 Robin Stuart <rstuart114@gmail.com>
|
2020-06-05 05:45:25 +12:00
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
2022-09-13 06:26:04 +12:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause */
|
2020-06-05 05:45:25 +12:00
|
|
|
|
|
|
|
#include "testcommon.h"
|
|
|
|
|
2022-09-13 06:26:04 +12:00
|
|
|
static void test_large(const testCtx *const p_ctx) {
|
|
|
|
int debug = p_ctx->debug;
|
2020-06-05 05:45:25 +12:00
|
|
|
|
|
|
|
struct item {
|
|
|
|
int symbology;
|
2021-05-18 07:04:00 +12:00
|
|
|
int option_2;
|
2020-10-04 10:51:08 +13:00
|
|
|
char *pattern;
|
2020-06-05 05:45:25 +12:00
|
|
|
int length;
|
|
|
|
int ret;
|
|
|
|
int expected_rows;
|
|
|
|
int expected_width;
|
|
|
|
};
|
2022-09-13 06:26:04 +12:00
|
|
|
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
2020-06-05 05:45:25 +12:00
|
|
|
struct item data[] = {
|
2021-05-18 07:04:00 +12:00
|
|
|
/* 0*/ { BARCODE_C25STANDARD, -1, "1", 80, 0, 1, 817 },
|
|
|
|
/* 1*/ { BARCODE_C25STANDARD, -1, "1", 81, ZINT_ERROR_TOO_LONG, -1, -1 },
|
|
|
|
/* 2*/ { BARCODE_C25STANDARD, 1, "1", 80, 0, 1, 827 },
|
|
|
|
/* 3*/ { BARCODE_C25STANDARD, 1, "1", 81, ZINT_ERROR_TOO_LONG, -1, -1 },
|
|
|
|
/* 4*/ { BARCODE_C25INTER, -1, "1", 90, 0, 1, 819 },
|
|
|
|
/* 5*/ { BARCODE_C25INTER, -1, "1", 91, ZINT_ERROR_TOO_LONG, -1, -1 },
|
|
|
|
/* 6*/ { BARCODE_C25INTER, 1, "1", 90, 0, 1, 837 },
|
|
|
|
/* 7*/ { BARCODE_C25INTER, 1, "1", 91, ZINT_ERROR_TOO_LONG, -1, -1 },
|
|
|
|
/* 8*/ { BARCODE_C25IATA, -1, "1", 45, 0, 1, 639 },
|
|
|
|
/* 9*/ { BARCODE_C25IATA, -1, "1", 46, ZINT_ERROR_TOO_LONG, -1, -1 },
|
|
|
|
/* 10*/ { BARCODE_C25IATA, 1, "1", 45, 0, 1, 653 },
|
|
|
|
/* 11*/ { BARCODE_C25IATA, 1, "1", 46, ZINT_ERROR_TOO_LONG, -1, -1 },
|
|
|
|
/* 12*/ { BARCODE_C25LOGIC, -1, "1", 80, 0, 1, 809 },
|
|
|
|
/* 13*/ { BARCODE_C25LOGIC, -1, "1", 81, ZINT_ERROR_TOO_LONG, -1, -1 },
|
|
|
|
/* 14*/ { BARCODE_C25LOGIC, 1, "1", 80, 0, 1, 819 },
|
|
|
|
/* 15*/ { BARCODE_C25LOGIC, 1, "1", 81, ZINT_ERROR_TOO_LONG, -1, -1 },
|
|
|
|
/* 16*/ { BARCODE_C25IND, -1, "1", 45, 0, 1, 649 },
|
|
|
|
/* 17*/ { BARCODE_C25IND, -1, "1", 46, ZINT_ERROR_TOO_LONG, -1, -1 },
|
|
|
|
/* 18*/ { BARCODE_C25IND, 1, "1", 45, 0, 1, 663 },
|
|
|
|
/* 19*/ { BARCODE_C25IND, 1, "1", 46, ZINT_ERROR_TOO_LONG, -1, -1 },
|
|
|
|
/* 20*/ { BARCODE_DPLEIT, -1, "1", 13, 0, 1, 135 },
|
|
|
|
/* 21*/ { BARCODE_DPLEIT, -1, "1", 14, ZINT_ERROR_TOO_LONG, -1, -1 },
|
|
|
|
/* 22*/ { BARCODE_DPIDENT, -1, "1", 11, 0, 1, 117 },
|
|
|
|
/* 23*/ { BARCODE_DPIDENT, -1, "1", 12, ZINT_ERROR_TOO_LONG, -1, -1 },
|
|
|
|
/* 24*/ { BARCODE_ITF14, -1, "1", 13, 0, 1, 135 },
|
|
|
|
/* 25*/ { BARCODE_ITF14, -1, "1", 14, ZINT_ERROR_TOO_LONG, -1, -1 },
|
2020-06-05 05:45:25 +12:00
|
|
|
};
|
|
|
|
int data_size = ARRAY_SIZE(data);
|
2021-06-24 02:00:49 +12:00
|
|
|
int i, length, ret;
|
|
|
|
struct zint_symbol *symbol;
|
2020-06-05 05:45:25 +12:00
|
|
|
|
|
|
|
char data_buf[4096];
|
|
|
|
|
2021-06-24 02:00:49 +12:00
|
|
|
testStart("test_large");
|
|
|
|
|
|
|
|
for (i = 0; i < data_size; i++) {
|
2020-06-05 05:45:25 +12:00
|
|
|
|
2022-09-13 06:26:04 +12:00
|
|
|
if (testContinue(p_ctx, i)) continue;
|
2020-06-05 05:45:25 +12:00
|
|
|
|
2021-06-24 02:00:49 +12:00
|
|
|
symbol = ZBarcode_Create();
|
2020-06-05 05:45:25 +12:00
|
|
|
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));
|
|
|
|
|
2021-06-24 02:00:49 +12:00
|
|
|
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data_buf, data[i].length, debug);
|
2020-06-05 05:45:25 +12:00
|
|
|
|
2020-10-04 10:51:08 +13:00
|
|
|
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
|
2020-06-05 05:45:25 +12:00
|
|
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
|
|
|
|
2021-02-23 13:01:15 +13:00
|
|
|
if (ret < ZINT_ERROR) {
|
2020-06-05 05:45:25 +12:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2022-09-13 06:26:04 +12:00
|
|
|
static void test_hrt(const testCtx *const p_ctx) {
|
|
|
|
int debug = p_ctx->debug;
|
2020-06-05 05:45:25 +12:00
|
|
|
|
|
|
|
struct item {
|
|
|
|
int symbology;
|
2021-05-18 07:04:00 +12:00
|
|
|
int option_2;
|
2020-10-04 10:51:08 +13:00
|
|
|
char *data;
|
|
|
|
char *expected;
|
2020-06-05 05:45:25 +12:00
|
|
|
};
|
2022-09-13 06:26:04 +12:00
|
|
|
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
2020-06-05 05:45:25 +12:00
|
|
|
struct item data[] = {
|
2021-05-18 07:04:00 +12:00
|
|
|
/* 0*/ { BARCODE_C25STANDARD, -1, "123456789", "123456789" },
|
|
|
|
/* 1*/ { BARCODE_C25STANDARD, 1, "123456789", "1234567895" },
|
2022-09-13 06:26:04 +12:00
|
|
|
/* 2*/ { BARCODE_C25STANDARD, 2, "123456789", "123456789" }, /* Suppresses printing of check digit */
|
|
|
|
/* 3*/ { BARCODE_C25INTER, -1, "123456789", "0123456789" }, /* Adds leading zero if odd */
|
|
|
|
/* 4*/ { BARCODE_C25INTER, 1, "123456789", "1234567895" }, /* Unless check digit added when it becomes even */
|
2021-05-18 07:04:00 +12:00
|
|
|
/* 5*/ { BARCODE_C25INTER, 2, "123456789", "123456789" },
|
2022-09-13 06:26:04 +12:00
|
|
|
/* 6*/ { BARCODE_C25INTER, -1, "1234567890", "1234567890" }, /* No leading zero if even */
|
|
|
|
/* 7*/ { BARCODE_C25INTER, 1, "1234567890", "012345678905" }, /* Unless check digit added when it becomes odd */
|
2021-05-18 07:04:00 +12:00
|
|
|
/* 8*/ { BARCODE_C25INTER, 2, "1234567890", "01234567890" },
|
|
|
|
/* 9*/ { BARCODE_C25IATA, -1, "123456789", "123456789" },
|
|
|
|
/* 10*/ { BARCODE_C25IATA, 1, "123456789", "1234567895" },
|
|
|
|
/* 11*/ { BARCODE_C25IATA, 2, "123456789", "123456789" },
|
|
|
|
/* 12*/ { BARCODE_C25LOGIC, -1, "123456789", "123456789" },
|
|
|
|
/* 13*/ { BARCODE_C25LOGIC, 1, "123456789", "1234567895" },
|
|
|
|
/* 14*/ { BARCODE_C25LOGIC, 2, "123456789", "123456789" },
|
|
|
|
/* 15*/ { BARCODE_C25IND, -1, "123456789", "123456789" },
|
|
|
|
/* 16*/ { BARCODE_C25IND, 1, "123456789", "1234567895" },
|
|
|
|
/* 17*/ { BARCODE_C25IND, 2, "123456789", "123456789" },
|
- API: add new zint_symbol `dpmm` field for output resolution (BMP/
EMF/PCX/PNG/TIF only, i.e. excluding EPS, GIF & SVG)
- Add support for specifying scale by X-dimension and resolution
with new option `--scalexdimdp` for CLI/Tcl & new API function
`ZBarcode_Scale_From_XdimDp()` (+ `ZBarcode_XdimDp_From_Scale()`
& `ZBarcode_Default_Xdim()`) and new GUI popup; manual: document
- BMP/EMF/PCX/PNG/TIF: use new `dpmm` resolution field (for EMF
following Inkscape)
- backend_qt: add `dpmm()`, `vectorWidth()`, `vectorHeight()`,
`noPng()`, `getVersion()`, `takesGS1AIData()`, & `XdimDp` stuff
incl. new `QZintXdimDp` struct for passing around scale vars &
use in `getAsCLI()`; add comments
- Raise `scale` limit to 200 (from 100) to allow for large dpmm
- output: create directories & subdirectories as necessary for
output path using new function `out_fopen()` and use in BMP/EMF/
EPS/GIF/PCX/PNG/SVG/TIF
- DPLEIT/DPIDENT: format HRT according to (incomplete)
documentation, and set default height to 72X (from 50X)
- CODE128B renamed to CODE128AB as can use subsets A and/or B
- CODABAR: fix minimum height calc
- EMF: fix indexing of handles (zero-based not 1-based)
- GUI: fix symbology zap (previous technique of clearing and
re-loading settings without doing a sync no longer works);
fix UPCEAN guard descent enable
- MAILMARK: better error message if input < 14 characters
- GUI: add "Default" button for DAFT tracker ratio & enable/disable
various default buttons; use new `takesGS1AIData()` to
enable/disable GS1-specific checkboxes
- CLI: use new `validate_float()` to parse float options (7
significant digits allowed only, no scientific notation)
- DATAMATRIX/GRIDMATRIX/PDF417/QR/ULTRA: micro-optimize structapp
ID parse
- library/CLI: fiddle with static asserts (make CHAR_BIT sensitive,
supposedly)
- win32/README: update building libpng (assembly removed)
- README.linux: document incompatibility of Qt6 >= 6.3
- manual: expand Barcode Studio waffle
- test suite: change range separator to hyphen and allow multiple
excludes
2022-12-03 10:39:01 +13:00
|
|
|
/* 18*/ { BARCODE_DPLEIT, -1, "123456789", "00001.234.567.890" }, /* Leading zeroes added to make 13 + appended checksum */
|
|
|
|
/* 19*/ { BARCODE_DPLEIT, -1, "1234567890123", "12345.678.901.236" },
|
|
|
|
/* 20*/ { BARCODE_DPIDENT, -1, "123456789", "00.12 3.456.789 0" }, /* Leading zeroes added to make 11 + appended checksum */
|
|
|
|
/* 21*/ { BARCODE_DPIDENT, -1, "12345678901", "12.34 5.678.901 6" },
|
2022-09-13 06:26:04 +12:00
|
|
|
/* 22*/ { BARCODE_ITF14, -1, "123456789", "00001234567895" }, /* Leading zeroes added to make 13 + appended checksum */
|
2021-05-18 07:04:00 +12:00
|
|
|
/* 23*/ { BARCODE_ITF14, -1, "1234567890123", "12345678901231" },
|
2020-06-05 05:45:25 +12:00
|
|
|
};
|
|
|
|
int data_size = ARRAY_SIZE(data);
|
2021-06-24 02:00:49 +12:00
|
|
|
int i, length, ret;
|
|
|
|
struct zint_symbol *symbol;
|
|
|
|
|
|
|
|
testStart("test_hrt");
|
2020-06-05 05:45:25 +12:00
|
|
|
|
2021-06-24 02:00:49 +12:00
|
|
|
for (i = 0; i < data_size; i++) {
|
2020-06-05 05:45:25 +12:00
|
|
|
|
2022-09-13 06:26:04 +12:00
|
|
|
if (testContinue(p_ctx, i)) continue;
|
2020-06-05 05:45:25 +12:00
|
|
|
|
2021-06-24 02:00:49 +12:00
|
|
|
symbol = ZBarcode_Create();
|
2020-06-05 05:45:25 +12:00
|
|
|
assert_nonnull(symbol, "Symbol not created\n");
|
|
|
|
|
2021-06-24 02:00:49 +12:00
|
|
|
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
2020-06-05 05:45:25 +12:00
|
|
|
|
2020-10-04 10:51:08 +13:00
|
|
|
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
2020-06-05 05:45:25 +12:00
|
|
|
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
|
|
|
|
|
2020-10-04 10:51:08 +13:00
|
|
|
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
|
2020-06-05 05:45:25 +12:00
|
|
|
|
|
|
|
ZBarcode_Delete(symbol);
|
|
|
|
}
|
|
|
|
|
|
|
|
testFinish();
|
|
|
|
}
|
|
|
|
|
2022-09-13 06:26:04 +12:00
|
|
|
static void test_input(const testCtx *const p_ctx) {
|
|
|
|
int debug = p_ctx->debug;
|
2020-06-05 05:45:25 +12:00
|
|
|
|
|
|
|
struct item {
|
|
|
|
int symbology;
|
2020-10-04 10:51:08 +13:00
|
|
|
char *data;
|
2020-06-05 05:45:25 +12:00
|
|
|
int ret;
|
|
|
|
int expected_rows;
|
|
|
|
int expected_width;
|
|
|
|
};
|
2022-09-13 06:26:04 +12:00
|
|
|
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
2020-06-05 05:45:25 +12:00
|
|
|
struct item data[] = {
|
2020-07-30 07:43:08 +12:00
|
|
|
/* 0*/ { BARCODE_C25STANDARD, "A", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
2020-06-05 05:45:25 +12:00
|
|
|
/* 1*/ { BARCODE_C25INTER, "A", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
|
|
|
/* 2*/ { BARCODE_C25IATA, "A", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
|
|
|
/* 3*/ { BARCODE_C25LOGIC, "A", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
|
|
|
/* 4*/ { BARCODE_C25IND, "A", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
|
|
|
/* 5*/ { BARCODE_DPLEIT, "A", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
|
|
|
/* 6*/ { BARCODE_DPIDENT, "A", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
|
|
|
/* 7*/ { BARCODE_ITF14, "A", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
|
|
|
};
|
|
|
|
int data_size = ARRAY_SIZE(data);
|
2021-06-24 02:00:49 +12:00
|
|
|
int i, length, ret;
|
|
|
|
struct zint_symbol *symbol;
|
|
|
|
|
|
|
|
testStart("test_input");
|
2020-06-05 05:45:25 +12:00
|
|
|
|
2021-06-24 02:00:49 +12:00
|
|
|
for (i = 0; i < data_size; i++) {
|
2020-06-05 05:45:25 +12:00
|
|
|
|
2022-09-13 06:26:04 +12:00
|
|
|
if (testContinue(p_ctx, i)) continue;
|
2020-06-05 05:45:25 +12:00
|
|
|
|
2021-06-24 02:00:49 +12:00
|
|
|
symbol = ZBarcode_Create();
|
2020-06-05 05:45:25 +12:00
|
|
|
assert_nonnull(symbol, "Symbol not created\n");
|
|
|
|
|
2021-06-24 02:00:49 +12:00
|
|
|
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1 /*option_2*/, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
2020-06-05 05:45:25 +12:00
|
|
|
|
2020-10-04 10:51:08 +13:00
|
|
|
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
2020-06-05 05:45:25 +12:00
|
|
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
|
|
|
|
2021-02-23 13:01:15 +13:00
|
|
|
if (ret < ZINT_ERROR) {
|
2020-06-05 05:45:25 +12:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2022-09-13 06:26:04 +12:00
|
|
|
static void test_encode(const testCtx *const p_ctx) {
|
|
|
|
int debug = p_ctx->debug;
|
2020-06-05 05:45:25 +12:00
|
|
|
|
|
|
|
struct item {
|
|
|
|
int symbology;
|
2021-05-18 07:04:00 +12:00
|
|
|
int option_2;
|
2020-10-04 10:51:08 +13:00
|
|
|
char *data;
|
2020-06-05 05:45:25 +12:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
int expected_rows;
|
|
|
|
int expected_width;
|
|
|
|
char *comment;
|
|
|
|
char *expected;
|
|
|
|
};
|
2022-09-13 06:26:04 +12:00
|
|
|
/* BARCODE_ITF14 examples verified manually against GS1 General Specifications 21.0.1 */
|
2020-06-05 05:45:25 +12:00
|
|
|
struct item data[] = {
|
2021-05-18 07:04:00 +12:00
|
|
|
/* 0*/ { BARCODE_C25STANDARD, -1, "87654321", 0, 1, 97, "Standard Code 2 of 5; note zint uses 4X start/end wides while BWIPP uses 3X",
|
2020-06-05 05:45:25 +12:00
|
|
|
"1111010101110100010101000111010001110101110111010101110111011100010101000101110111010111011110101"
|
|
|
|
},
|
2021-05-18 07:04:00 +12:00
|
|
|
/* 1*/ { BARCODE_C25STANDARD, 1, "87654321", 0, 1, 107, "With check digit",
|
|
|
|
"11110101011101000101010001110100011101011101110101011101110111000101010001011101110101110100010111011110101"
|
|
|
|
},
|
2021-10-21 11:05:30 +13:00
|
|
|
/* 2*/ { BARCODE_C25STANDARD, -1, "1234567890", 0, 1, 117, "",
|
|
|
|
"111101010111010111010001011101110001010101110111011101110101000111010101000111011101000101000100010101110001011110101"
|
|
|
|
},
|
|
|
|
/* 3*/ { BARCODE_C25INTER, -1, "87654321", 0, 1, 81, "Interleaved Code 2 of 5, even; verified manually against tec-it",
|
2020-06-05 05:45:25 +12:00
|
|
|
"101011101010111000100010001110111000101010001000111010111010001110101011100011101"
|
|
|
|
},
|
2021-10-21 11:05:30 +13:00
|
|
|
/* 4*/ { BARCODE_C25INTER, 1, "87654321", 0, 1, 99, "With check digit",
|
2021-05-18 07:04:00 +12:00
|
|
|
"101010001011101110001010100010001110111011101011100010100011101110001010100011101000101011100011101"
|
|
|
|
},
|
2021-10-21 11:05:30 +13:00
|
|
|
/* 5*/ { BARCODE_C25INTER, -1, "7654321", 0, 1, 81, "Interleaved Code 2 of 5, odd",
|
2021-05-18 07:04:00 +12:00
|
|
|
"101010101110111000100010001110111000101010001000111010111010001110101011100011101"
|
|
|
|
},
|
2021-10-21 11:05:30 +13:00
|
|
|
/* 6*/ { BARCODE_C25INTER, 1, "7654321", 0, 1, 81, "With check digit",
|
2021-05-18 07:04:00 +12:00
|
|
|
"101010100010001110111011101011100010100011101110001010100011101010001000111011101"
|
|
|
|
},
|
2021-10-21 11:05:30 +13:00
|
|
|
/* 7*/ { BARCODE_C25INTER, -1, "602003", 0, 1, 63, "DX cartridge barcode https://en.wikipedia.org/wiki/Interleaved_2_of_5 example",
|
2020-06-05 05:45:25 +12:00
|
|
|
"101010111011100010001010111010001000111010001000111011101011101"
|
|
|
|
},
|
2021-10-21 11:05:30 +13:00
|
|
|
/* 8*/ { BARCODE_C25IATA, -1, "87654321", 0, 1, 121, "IATA Code 2 of 5; verified manually against tec-it",
|
2020-06-05 05:45:25 +12:00
|
|
|
"1010111010101110101010101110111010111011101010111010111010101010111010111011101110101010101110101011101110101010111011101"
|
|
|
|
},
|
2021-10-21 11:05:30 +13:00
|
|
|
/* 9*/ { BARCODE_C25IATA, 1, "87654321", 0, 1, 135, "With check digit",
|
2021-05-18 07:04:00 +12:00
|
|
|
"101011101010111010101010111011101011101110101011101011101010101011101011101110111010101010111010101110111010101011101011101010111011101"
|
|
|
|
},
|
2021-10-21 11:05:30 +13:00
|
|
|
/* 10*/ { BARCODE_C25LOGIC, -1, "87654321", 0, 1, 89, "Code 2 of 5 Data Logic; verified manually against tec-it",
|
2020-06-05 05:45:25 +12:00
|
|
|
"10101110100010101000111010001110101110111010101110111011100010101000101110111010111011101"
|
|
|
|
},
|
2021-10-21 11:05:30 +13:00
|
|
|
/* 11*/ { BARCODE_C25LOGIC, 1, "87654321", 0, 1, 99, "With check digit",
|
2021-05-18 07:04:00 +12:00
|
|
|
"101011101000101010001110100011101011101110101011101110111000101010001011101110101110100010111011101"
|
|
|
|
},
|
2021-10-21 11:05:30 +13:00
|
|
|
/* 12*/ { BARCODE_C25IND, -1, "87654321", 0, 1, 131, "Industrial Code 2 of 5; verified manually against tec-it",
|
2020-06-05 05:45:25 +12:00
|
|
|
"11101110101110101011101010101011101110101110111010101110101110101010101110101110111011101010101011101010111011101010101110111010111"
|
|
|
|
},
|
2021-10-21 11:05:30 +13:00
|
|
|
/* 13*/ { BARCODE_C25IND, 1, "87654321", 0, 1, 145, "With check digit",
|
2021-05-18 07:04:00 +12:00
|
|
|
"1110111010111010101110101010101110111010111011101010111010111010101010111010111011101110101010101110101011101110101010111010111010101110111010111"
|
|
|
|
},
|
2021-10-21 11:05:30 +13:00
|
|
|
/* 14*/ { BARCODE_C25IND, -1, "1234567890", 0, 1, 159, "",
|
|
|
|
"111011101011101010101110101110101011101110111010101010101110101110111010111010101011101110101010101011101110111010101110101011101011101010101110111010111010111"
|
|
|
|
},
|
|
|
|
/* 15*/ { BARCODE_DPLEIT, -1, "0000087654321", 0, 1, 135, "Deutsche Post Leitcode; verified manually against tec-it",
|
2020-06-05 05:45:25 +12:00
|
|
|
"101010101110001110001010101110001110001010001011101110001010100010001110111011101011100010100011101110001010100011101000100010111011101"
|
|
|
|
},
|
- API: add new zint_symbol `dpmm` field for output resolution (BMP/
EMF/PCX/PNG/TIF only, i.e. excluding EPS, GIF & SVG)
- Add support for specifying scale by X-dimension and resolution
with new option `--scalexdimdp` for CLI/Tcl & new API function
`ZBarcode_Scale_From_XdimDp()` (+ `ZBarcode_XdimDp_From_Scale()`
& `ZBarcode_Default_Xdim()`) and new GUI popup; manual: document
- BMP/EMF/PCX/PNG/TIF: use new `dpmm` resolution field (for EMF
following Inkscape)
- backend_qt: add `dpmm()`, `vectorWidth()`, `vectorHeight()`,
`noPng()`, `getVersion()`, `takesGS1AIData()`, & `XdimDp` stuff
incl. new `QZintXdimDp` struct for passing around scale vars &
use in `getAsCLI()`; add comments
- Raise `scale` limit to 200 (from 100) to allow for large dpmm
- output: create directories & subdirectories as necessary for
output path using new function `out_fopen()` and use in BMP/EMF/
EPS/GIF/PCX/PNG/SVG/TIF
- DPLEIT/DPIDENT: format HRT according to (incomplete)
documentation, and set default height to 72X (from 50X)
- CODE128B renamed to CODE128AB as can use subsets A and/or B
- CODABAR: fix minimum height calc
- EMF: fix indexing of handles (zero-based not 1-based)
- GUI: fix symbology zap (previous technique of clearing and
re-loading settings without doing a sync no longer works);
fix UPCEAN guard descent enable
- MAILMARK: better error message if input < 14 characters
- GUI: add "Default" button for DAFT tracker ratio & enable/disable
various default buttons; use new `takesGS1AIData()` to
enable/disable GS1-specific checkboxes
- CLI: use new `validate_float()` to parse float options (7
significant digits allowed only, no scientific notation)
- DATAMATRIX/GRIDMATRIX/PDF417/QR/ULTRA: micro-optimize structapp
ID parse
- library/CLI: fiddle with static asserts (make CHAR_BIT sensitive,
supposedly)
- win32/README: update building libpng (assembly removed)
- README.linux: document incompatibility of Qt6 >= 6.3
- manual: expand Barcode Studio waffle
- test suite: change range separator to hyphen and allow multiple
excludes
2022-12-03 10:39:01 +13:00
|
|
|
/* 16*/ { BARCODE_DPLEIT, -1, "2045703000360", 0, 1, 135, "Deutsche Post DIALOGPOST SCHWER brochure 3.1 example",
|
|
|
|
"101010111010001000111010001011100010111010101000111000111011101110100010001010101110001110001011101110001000101010001011100011101011101"
|
|
|
|
},
|
|
|
|
/* 17*/ { BARCODE_DPLEIT, -1, "5082300702800", 0, 1, 135, "Deutsche Post Leitcode https://de.wikipedia.org/wiki/Leitcode example",
|
2020-06-05 05:45:25 +12:00
|
|
|
"101011101011100010001011101000101110100011101110100010001010101110111000100010100011101110100011101010001110001010001011100011101011101"
|
|
|
|
},
|
- API: add new zint_symbol `dpmm` field for output resolution (BMP/
EMF/PCX/PNG/TIF only, i.e. excluding EPS, GIF & SVG)
- Add support for specifying scale by X-dimension and resolution
with new option `--scalexdimdp` for CLI/Tcl & new API function
`ZBarcode_Scale_From_XdimDp()` (+ `ZBarcode_XdimDp_From_Scale()`
& `ZBarcode_Default_Xdim()`) and new GUI popup; manual: document
- BMP/EMF/PCX/PNG/TIF: use new `dpmm` resolution field (for EMF
following Inkscape)
- backend_qt: add `dpmm()`, `vectorWidth()`, `vectorHeight()`,
`noPng()`, `getVersion()`, `takesGS1AIData()`, & `XdimDp` stuff
incl. new `QZintXdimDp` struct for passing around scale vars &
use in `getAsCLI()`; add comments
- Raise `scale` limit to 200 (from 100) to allow for large dpmm
- output: create directories & subdirectories as necessary for
output path using new function `out_fopen()` and use in BMP/EMF/
EPS/GIF/PCX/PNG/SVG/TIF
- DPLEIT/DPIDENT: format HRT according to (incomplete)
documentation, and set default height to 72X (from 50X)
- CODE128B renamed to CODE128AB as can use subsets A and/or B
- CODABAR: fix minimum height calc
- EMF: fix indexing of handles (zero-based not 1-based)
- GUI: fix symbology zap (previous technique of clearing and
re-loading settings without doing a sync no longer works);
fix UPCEAN guard descent enable
- MAILMARK: better error message if input < 14 characters
- GUI: add "Default" button for DAFT tracker ratio & enable/disable
various default buttons; use new `takesGS1AIData()` to
enable/disable GS1-specific checkboxes
- CLI: use new `validate_float()` to parse float options (7
significant digits allowed only, no scientific notation)
- DATAMATRIX/GRIDMATRIX/PDF417/QR/ULTRA: micro-optimize structapp
ID parse
- library/CLI: fiddle with static asserts (make CHAR_BIT sensitive,
supposedly)
- win32/README: update building libpng (assembly removed)
- README.linux: document incompatibility of Qt6 >= 6.3
- manual: expand Barcode Studio waffle
- test suite: change range separator to hyphen and allow multiple
excludes
2022-12-03 10:39:01 +13:00
|
|
|
/* 18*/ { BARCODE_DPIDENT, -1, "00087654321", 0, 1, 117, "Deutsche Post Identcode; verified manually against tec-it (HRT differently formatted)",
|
2020-06-05 05:45:25 +12:00
|
|
|
"101010101110001110001010001011101110001010100010001110111011101011100010100011101110001010100011101000100010111011101"
|
|
|
|
},
|
- API: add new zint_symbol `dpmm` field for output resolution (BMP/
EMF/PCX/PNG/TIF only, i.e. excluding EPS, GIF & SVG)
- Add support for specifying scale by X-dimension and resolution
with new option `--scalexdimdp` for CLI/Tcl & new API function
`ZBarcode_Scale_From_XdimDp()` (+ `ZBarcode_XdimDp_From_Scale()`
& `ZBarcode_Default_Xdim()`) and new GUI popup; manual: document
- BMP/EMF/PCX/PNG/TIF: use new `dpmm` resolution field (for EMF
following Inkscape)
- backend_qt: add `dpmm()`, `vectorWidth()`, `vectorHeight()`,
`noPng()`, `getVersion()`, `takesGS1AIData()`, & `XdimDp` stuff
incl. new `QZintXdimDp` struct for passing around scale vars &
use in `getAsCLI()`; add comments
- Raise `scale` limit to 200 (from 100) to allow for large dpmm
- output: create directories & subdirectories as necessary for
output path using new function `out_fopen()` and use in BMP/EMF/
EPS/GIF/PCX/PNG/SVG/TIF
- DPLEIT/DPIDENT: format HRT according to (incomplete)
documentation, and set default height to 72X (from 50X)
- CODE128B renamed to CODE128AB as can use subsets A and/or B
- CODABAR: fix minimum height calc
- EMF: fix indexing of handles (zero-based not 1-based)
- GUI: fix symbology zap (previous technique of clearing and
re-loading settings without doing a sync no longer works);
fix UPCEAN guard descent enable
- MAILMARK: better error message if input < 14 characters
- GUI: add "Default" button for DAFT tracker ratio & enable/disable
various default buttons; use new `takesGS1AIData()` to
enable/disable GS1-specific checkboxes
- CLI: use new `validate_float()` to parse float options (7
significant digits allowed only, no scientific notation)
- DATAMATRIX/GRIDMATRIX/PDF417/QR/ULTRA: micro-optimize structapp
ID parse
- library/CLI: fiddle with static asserts (make CHAR_BIT sensitive,
supposedly)
- win32/README: update building libpng (assembly removed)
- README.linux: document incompatibility of Qt6 >= 6.3
- manual: expand Barcode Studio waffle
- test suite: change range separator to hyphen and allow multiple
excludes
2022-12-03 10:39:01 +13:00
|
|
|
/* 19*/ { BARCODE_DPIDENT, -1, "80420000001", 0, 1, 117, "Deutsche Post DIALOGPOST SCHWER brochure 3.1 example",
|
|
|
|
"101011101010001110001010100011101011100010101110001110001010101110001110001010101110001110001011101010001000111011101"
|
|
|
|
},
|
|
|
|
/* 20*/ { BARCODE_DPIDENT, -1, "39601313414", 0, 1, 117, "Deutsche Post Identcode https://de.wikipedia.org/wiki/Leitcode example",
|
2020-06-05 05:45:25 +12:00
|
|
|
"101011101110001010001010111011100010001011100010001010111011100010001010111010001011101011100010101110001000111011101"
|
|
|
|
},
|
- API: add new zint_symbol `dpmm` field for output resolution (BMP/
EMF/PCX/PNG/TIF only, i.e. excluding EPS, GIF & SVG)
- Add support for specifying scale by X-dimension and resolution
with new option `--scalexdimdp` for CLI/Tcl & new API function
`ZBarcode_Scale_From_XdimDp()` (+ `ZBarcode_XdimDp_From_Scale()`
& `ZBarcode_Default_Xdim()`) and new GUI popup; manual: document
- BMP/EMF/PCX/PNG/TIF: use new `dpmm` resolution field (for EMF
following Inkscape)
- backend_qt: add `dpmm()`, `vectorWidth()`, `vectorHeight()`,
`noPng()`, `getVersion()`, `takesGS1AIData()`, & `XdimDp` stuff
incl. new `QZintXdimDp` struct for passing around scale vars &
use in `getAsCLI()`; add comments
- Raise `scale` limit to 200 (from 100) to allow for large dpmm
- output: create directories & subdirectories as necessary for
output path using new function `out_fopen()` and use in BMP/EMF/
EPS/GIF/PCX/PNG/SVG/TIF
- DPLEIT/DPIDENT: format HRT according to (incomplete)
documentation, and set default height to 72X (from 50X)
- CODE128B renamed to CODE128AB as can use subsets A and/or B
- CODABAR: fix minimum height calc
- EMF: fix indexing of handles (zero-based not 1-based)
- GUI: fix symbology zap (previous technique of clearing and
re-loading settings without doing a sync no longer works);
fix UPCEAN guard descent enable
- MAILMARK: better error message if input < 14 characters
- GUI: add "Default" button for DAFT tracker ratio & enable/disable
various default buttons; use new `takesGS1AIData()` to
enable/disable GS1-specific checkboxes
- CLI: use new `validate_float()` to parse float options (7
significant digits allowed only, no scientific notation)
- DATAMATRIX/GRIDMATRIX/PDF417/QR/ULTRA: micro-optimize structapp
ID parse
- library/CLI: fiddle with static asserts (make CHAR_BIT sensitive,
supposedly)
- win32/README: update building libpng (assembly removed)
- README.linux: document incompatibility of Qt6 >= 6.3
- manual: expand Barcode Studio waffle
- test suite: change range separator to hyphen and allow multiple
excludes
2022-12-03 10:39:01 +13:00
|
|
|
/* 21*/ { BARCODE_ITF14, -1, "0000087654321", 0, 1, 135, "ITF-14; verified manually against tec-it",
|
2020-06-05 05:45:25 +12:00
|
|
|
"101010101110001110001010101110001110001010001011101110001010100010001110111011101011100010100011101110001010100011101000101011100011101"
|
|
|
|
},
|
- API: add new zint_symbol `dpmm` field for output resolution (BMP/
EMF/PCX/PNG/TIF only, i.e. excluding EPS, GIF & SVG)
- Add support for specifying scale by X-dimension and resolution
with new option `--scalexdimdp` for CLI/Tcl & new API function
`ZBarcode_Scale_From_XdimDp()` (+ `ZBarcode_XdimDp_From_Scale()`
& `ZBarcode_Default_Xdim()`) and new GUI popup; manual: document
- BMP/EMF/PCX/PNG/TIF: use new `dpmm` resolution field (for EMF
following Inkscape)
- backend_qt: add `dpmm()`, `vectorWidth()`, `vectorHeight()`,
`noPng()`, `getVersion()`, `takesGS1AIData()`, & `XdimDp` stuff
incl. new `QZintXdimDp` struct for passing around scale vars &
use in `getAsCLI()`; add comments
- Raise `scale` limit to 200 (from 100) to allow for large dpmm
- output: create directories & subdirectories as necessary for
output path using new function `out_fopen()` and use in BMP/EMF/
EPS/GIF/PCX/PNG/SVG/TIF
- DPLEIT/DPIDENT: format HRT according to (incomplete)
documentation, and set default height to 72X (from 50X)
- CODE128B renamed to CODE128AB as can use subsets A and/or B
- CODABAR: fix minimum height calc
- EMF: fix indexing of handles (zero-based not 1-based)
- GUI: fix symbology zap (previous technique of clearing and
re-loading settings without doing a sync no longer works);
fix UPCEAN guard descent enable
- MAILMARK: better error message if input < 14 characters
- GUI: add "Default" button for DAFT tracker ratio & enable/disable
various default buttons; use new `takesGS1AIData()` to
enable/disable GS1-specific checkboxes
- CLI: use new `validate_float()` to parse float options (7
significant digits allowed only, no scientific notation)
- DATAMATRIX/GRIDMATRIX/PDF417/QR/ULTRA: micro-optimize structapp
ID parse
- library/CLI: fiddle with static asserts (make CHAR_BIT sensitive,
supposedly)
- win32/README: update building libpng (assembly removed)
- README.linux: document incompatibility of Qt6 >= 6.3
- manual: expand Barcode Studio waffle
- test suite: change range separator to hyphen and allow multiple
excludes
2022-12-03 10:39:01 +13:00
|
|
|
/* 22*/ { BARCODE_ITF14, -1, "0950110153000", 0, 1, 135, "GS1 General Specifications Figure 5.1-2",
|
2020-06-05 05:45:25 +12:00
|
|
|
"101010100011101110001011101011100010001011100010101011100010001011101110100011100010001110101010101110001110001010001000111011101011101"
|
|
|
|
},
|
- API: add new zint_symbol `dpmm` field for output resolution (BMP/
EMF/PCX/PNG/TIF only, i.e. excluding EPS, GIF & SVG)
- Add support for specifying scale by X-dimension and resolution
with new option `--scalexdimdp` for CLI/Tcl & new API function
`ZBarcode_Scale_From_XdimDp()` (+ `ZBarcode_XdimDp_From_Scale()`
& `ZBarcode_Default_Xdim()`) and new GUI popup; manual: document
- BMP/EMF/PCX/PNG/TIF: use new `dpmm` resolution field (for EMF
following Inkscape)
- backend_qt: add `dpmm()`, `vectorWidth()`, `vectorHeight()`,
`noPng()`, `getVersion()`, `takesGS1AIData()`, & `XdimDp` stuff
incl. new `QZintXdimDp` struct for passing around scale vars &
use in `getAsCLI()`; add comments
- Raise `scale` limit to 200 (from 100) to allow for large dpmm
- output: create directories & subdirectories as necessary for
output path using new function `out_fopen()` and use in BMP/EMF/
EPS/GIF/PCX/PNG/SVG/TIF
- DPLEIT/DPIDENT: format HRT according to (incomplete)
documentation, and set default height to 72X (from 50X)
- CODE128B renamed to CODE128AB as can use subsets A and/or B
- CODABAR: fix minimum height calc
- EMF: fix indexing of handles (zero-based not 1-based)
- GUI: fix symbology zap (previous technique of clearing and
re-loading settings without doing a sync no longer works);
fix UPCEAN guard descent enable
- MAILMARK: better error message if input < 14 characters
- GUI: add "Default" button for DAFT tracker ratio & enable/disable
various default buttons; use new `takesGS1AIData()` to
enable/disable GS1-specific checkboxes
- CLI: use new `validate_float()` to parse float options (7
significant digits allowed only, no scientific notation)
- DATAMATRIX/GRIDMATRIX/PDF417/QR/ULTRA: micro-optimize structapp
ID parse
- library/CLI: fiddle with static asserts (make CHAR_BIT sensitive,
supposedly)
- win32/README: update building libpng (assembly removed)
- README.linux: document incompatibility of Qt6 >= 6.3
- manual: expand Barcode Studio waffle
- test suite: change range separator to hyphen and allow multiple
excludes
2022-12-03 10:39:01 +13:00
|
|
|
/* 23*/ { BARCODE_ITF14, -1, "1540014128876", 0, 1, 135, "GS1 General Specifications Figure 5.3.2.4-1",
|
2020-06-05 05:45:25 +12:00
|
|
|
"101011100010100010111010101110001000111010001011101110100010001011101011100010001110101000111011101010111000100010001110001110101011101"
|
|
|
|
},
|
- API: add new zint_symbol `dpmm` field for output resolution (BMP/
EMF/PCX/PNG/TIF only, i.e. excluding EPS, GIF & SVG)
- Add support for specifying scale by X-dimension and resolution
with new option `--scalexdimdp` for CLI/Tcl & new API function
`ZBarcode_Scale_From_XdimDp()` (+ `ZBarcode_XdimDp_From_Scale()`
& `ZBarcode_Default_Xdim()`) and new GUI popup; manual: document
- BMP/EMF/PCX/PNG/TIF: use new `dpmm` resolution field (for EMF
following Inkscape)
- backend_qt: add `dpmm()`, `vectorWidth()`, `vectorHeight()`,
`noPng()`, `getVersion()`, `takesGS1AIData()`, & `XdimDp` stuff
incl. new `QZintXdimDp` struct for passing around scale vars &
use in `getAsCLI()`; add comments
- Raise `scale` limit to 200 (from 100) to allow for large dpmm
- output: create directories & subdirectories as necessary for
output path using new function `out_fopen()` and use in BMP/EMF/
EPS/GIF/PCX/PNG/SVG/TIF
- DPLEIT/DPIDENT: format HRT according to (incomplete)
documentation, and set default height to 72X (from 50X)
- CODE128B renamed to CODE128AB as can use subsets A and/or B
- CODABAR: fix minimum height calc
- EMF: fix indexing of handles (zero-based not 1-based)
- GUI: fix symbology zap (previous technique of clearing and
re-loading settings without doing a sync no longer works);
fix UPCEAN guard descent enable
- MAILMARK: better error message if input < 14 characters
- GUI: add "Default" button for DAFT tracker ratio & enable/disable
various default buttons; use new `takesGS1AIData()` to
enable/disable GS1-specific checkboxes
- CLI: use new `validate_float()` to parse float options (7
significant digits allowed only, no scientific notation)
- DATAMATRIX/GRIDMATRIX/PDF417/QR/ULTRA: micro-optimize structapp
ID parse
- library/CLI: fiddle with static asserts (make CHAR_BIT sensitive,
supposedly)
- win32/README: update building libpng (assembly removed)
- README.linux: document incompatibility of Qt6 >= 6.3
- manual: expand Barcode Studio waffle
- test suite: change range separator to hyphen and allow multiple
excludes
2022-12-03 10:39:01 +13:00
|
|
|
/* 24*/ { BARCODE_ITF14, -1, "0950110153001", 0, 1, 135, "GS1 General Specifications Figure 5.3.6-1",
|
2020-06-05 05:45:25 +12:00
|
|
|
"101010100011101110001011101011100010001011100010101011100010001011101110100011100010001110101010101110001110001011101010001000111011101"
|
|
|
|
},
|
|
|
|
};
|
|
|
|
int data_size = ARRAY_SIZE(data);
|
|
|
|
|
|
|
|
char escaped[1024];
|
2021-12-09 07:12:20 +13:00
|
|
|
char cmp_buf[4096];
|
|
|
|
char cmp_msg[1024];
|
2021-06-24 02:00:49 +12:00
|
|
|
int i, length, ret;
|
|
|
|
struct zint_symbol *symbol;
|
|
|
|
|
2022-09-13 06:26:04 +12:00
|
|
|
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 */
|
2021-06-24 02:00:49 +12:00
|
|
|
|
|
|
|
testStart("test_encode");
|
2020-06-05 05:45:25 +12:00
|
|
|
|
2021-06-24 02:00:49 +12:00
|
|
|
for (i = 0; i < data_size; i++) {
|
2020-06-05 05:45:25 +12:00
|
|
|
|
2022-09-13 06:26:04 +12:00
|
|
|
if (testContinue(p_ctx, i)) continue;
|
2020-06-05 05:45:25 +12:00
|
|
|
|
2021-06-24 02:00:49 +12:00
|
|
|
symbol = ZBarcode_Create();
|
2020-06-05 05:45:25 +12:00
|
|
|
assert_nonnull(symbol, "Symbol not created\n");
|
|
|
|
|
2021-06-24 02:00:49 +12:00
|
|
|
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
2020-06-05 05:45:25 +12:00
|
|
|
|
2020-10-04 10:51:08 +13:00
|
|
|
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
2020-06-05 05:45:25 +12:00
|
|
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
|
|
|
|
2022-09-13 06:26:04 +12:00
|
|
|
if (p_ctx->generate) {
|
2021-05-18 07:04:00 +12:00
|
|
|
printf(" /*%3d*/ { %s, %d, \"%s\", %s, %d, %d, \"%s\",\n",
|
|
|
|
i, testUtilBarcodeName(data[i].symbology), data[i].option_2, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
2020-06-05 05:45:25 +12:00
|
|
|
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
|
2021-02-23 13:01:15 +13:00
|
|
|
testUtilModulesPrint(symbol, " ", "\n");
|
2020-06-05 05:45:25 +12:00
|
|
|
printf(" },\n");
|
|
|
|
} else {
|
2021-02-23 13:01:15 +13:00
|
|
|
if (ret < ZINT_ERROR) {
|
2021-06-24 02:00:49 +12:00
|
|
|
int width, row;
|
|
|
|
|
2020-06-05 05:45:25 +12:00
|
|
|
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);
|
|
|
|
|
2020-10-01 00:19:12 +13:00
|
|
|
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);
|
2020-07-16 06:00:12 +12:00
|
|
|
|
2021-05-18 07:04:00 +12:00
|
|
|
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, data[i].option_2, -1, debug)) {
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
ret = testUtilBwipp(i, symbol, -1, data[i].option_2, -1, data[i].data, length, NULL, cmp_buf, sizeof(cmp_buf), NULL);
|
2020-10-01 00:19:12 +13:00
|
|
|
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
|
2020-07-16 06:00:12 +12:00
|
|
|
|
2021-12-09 07:12:20 +13:00
|
|
|
ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, data[i].expected);
|
2020-07-16 06:00:12 +12:00
|
|
|
assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n",
|
2021-12-09 07:12:20 +13:00
|
|
|
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, data[i].expected);
|
|
|
|
}
|
2022-04-10 22:12:18 +12:00
|
|
|
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) {
|
2021-12-09 07:12:20 +13:00
|
|
|
int cmp_len, ret_len;
|
|
|
|
char modules_dump[8192 + 1];
|
|
|
|
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i);
|
2022-04-10 22:12:18 +12:00
|
|
|
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len);
|
2021-12-09 07:12:20 +13:00
|
|
|
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
|
|
|
|
|
|
|
|
ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len);
|
|
|
|
assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n",
|
|
|
|
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, escaped);
|
2020-07-16 06:00:12 +12:00
|
|
|
}
|
2020-06-05 05:45:25 +12:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ZBarcode_Delete(symbol);
|
|
|
|
}
|
|
|
|
|
|
|
|
testFinish();
|
|
|
|
}
|
|
|
|
|
2021-10-21 11:05:30 +13:00
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
#define TEST_PERF_ITER_MILLES 5
|
|
|
|
#define TEST_PERF_ITERATIONS (TEST_PERF_ITER_MILLES * 1000)
|
|
|
|
#define TEST_PERF_TIME(arg) ((arg) * 1000.0 / CLOCKS_PER_SEC)
|
|
|
|
|
2022-09-13 06:26:04 +12:00
|
|
|
/* Not a real test, just performance indicator */
|
|
|
|
static void test_perf(const testCtx *const p_ctx) {
|
|
|
|
int debug = p_ctx->debug;
|
2021-10-21 11:05:30 +13:00
|
|
|
|
|
|
|
struct item {
|
|
|
|
int symbology;
|
|
|
|
int option_2;
|
|
|
|
char *data;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
int expected_rows;
|
|
|
|
int expected_width;
|
|
|
|
char *comment;
|
|
|
|
};
|
|
|
|
struct item data[] = {
|
|
|
|
/* 0*/ { BARCODE_C25INTER, -1, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", 0, 1, 819, "C25INTER 90" },
|
|
|
|
/* 1*/ { BARCODE_C25INTER, -1, "1234567890", 0, 1, 99, "C25INTER 10" },
|
|
|
|
/* 2*/ { BARCODE_C25STANDARD, -1, "12345678901234567890123456789012345678901234567890123456789012345678901234567890", 0, 1, 817, "C25STANDARD 80" },
|
|
|
|
/* 3*/ { BARCODE_C25STANDARD, -1, "1234567890", 0, 1, 117, "C25STANDARD 10" },
|
|
|
|
};
|
|
|
|
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;
|
|
|
|
|
2022-09-13 06:26:04 +12:00
|
|
|
if (testContinue(p_ctx, i)) continue;
|
2021-10-21 11:05:30 +13:00
|
|
|
|
|
|
|
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_MODE, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
|
|
|
|
|
|
|
start = clock();
|
|
|
|
ret = ZBarcode_Encode(symbol, (unsigned char *) 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);
|
2022-09-13 06:26:04 +12:00
|
|
|
symbol->output_options &= ~OUT_BUFFER_INTERMEDIATE; /* Undo */
|
2021-10-21 11:05:30 +13:00
|
|
|
|
|
|
|
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(remove(symbol->outfile), "i:%d remove(%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;
|
|
|
|
}
|
2022-09-13 06:26:04 +12:00
|
|
|
if (p_ctx->index == -1) {
|
2021-10-21 11:05:30 +13:00
|
|
|
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));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-05 05:45:25 +12:00
|
|
|
int main(int argc, char *argv[]) {
|
|
|
|
|
2022-09-13 06:26:04 +12:00
|
|
|
testFunction funcs[] = { /* name, func */
|
|
|
|
{ "test_large", test_large },
|
|
|
|
{ "test_hrt", test_hrt },
|
|
|
|
{ "test_input", test_input },
|
|
|
|
{ "test_encode", test_encode },
|
|
|
|
{ "test_perf", test_perf },
|
2020-06-05 05:45:25 +12:00
|
|
|
};
|
|
|
|
|
|
|
|
testRun(argc, argv, funcs, ARRAY_SIZE(funcs));
|
|
|
|
|
|
|
|
testReport();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2022-04-10 22:12:18 +12:00
|
|
|
|
|
|
|
/* vim: set ts=4 sw=4 et : */
|