1
0
mirror of https://git.code.sf.net/p/zint/code synced 2026-01-08 12:32:01 +00:00

general: change BARCODE_RAW_TEXT to write to new zint_symbol

fields `raw_segs` and `raw_seg_count` instead of `text`, and to
  do so for all symbologies, using new common funcs `rt_cpy()` etc.
MICROPDF417: return ECC percentage in top byte of `option_1`
DBAR_EXP_STK: return `option_2`/`option_3` feedback
CLI: change warning text "ignoring" -> "**IGNORED**"
GUI: show feedback for DBAR_EXP_STK, MICROPDF417, UPNQR
ctest: fix recent inability to run tests via "ctest" on Windows
  (MSVC) by using cmake 3.22 feature `ENVIRONMENT_MODIFICATION`
manual: document feedback and RAW_TEXT in new "Feedback" section;
  rephrase some symbology descriptions
test suite: new general-use arg "-a"; add `func_name` to context;
  new "test_bwipp" test for testing BWIPP against ZXing-C++
This commit is contained in:
gitlost
2025-03-28 10:02:19 +00:00
parent d1bf02e156
commit a6c225447e
120 changed files with 10511 additions and 5620 deletions

View File

@@ -84,7 +84,7 @@ static void test_large(const testCtx *const p_ctx) {
char data_buf[4096] = {0}; /* Suppress clang -fsanitize=memory false positive */
testStartSymbol("test_large", &symbol);
testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) {
@@ -132,7 +132,7 @@ static void test_koreapost(const testCtx *const p_ctx) {
int i, length, ret;
struct zint_symbol *symbol = NULL;
testStartSymbol("test_koreapost", &symbol);
testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) {
@@ -185,7 +185,7 @@ static void test_japanpost(const testCtx *const p_ctx) {
int i, length, ret;
struct zint_symbol *symbol = NULL;
testStartSymbol("test_japanpost", &symbol);
testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) {
@@ -224,37 +224,38 @@ static void test_hrt(const testCtx *const p_ctx) {
const char *data;
const char *expected;
const char *expected_raw;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 0*/ { BARCODE_FLAT, -1, -1, "12345", "" }, /* None */
/* 1*/ { BARCODE_FLAT, -1, BARCODE_RAW_TEXT, "12345", "12345" },
/* 2*/ { BARCODE_POSTNET, -1, -1, "12345", "" }, /* None */
/* 3*/ { BARCODE_POSTNET, -1, BARCODE_RAW_TEXT, "12345", "123455" },
/* 4*/ { BARCODE_FIM, -1, -1, "e", "" }, /* None */
/* 5*/ { BARCODE_FIM, -1, BARCODE_RAW_TEXT, "e", "E" },
/* 6*/ { BARCODE_CEPNET, -1, -1, "12345678", "" }, /* None */
/* 7*/ { BARCODE_CEPNET, -1, BARCODE_RAW_TEXT, "12345678", "123456784" },
/* 8*/ { BARCODE_RM4SCC, -1, -1, "BX11LT1A", "" }, /* None*/
/* 9*/ { BARCODE_RM4SCC, -1, BARCODE_RAW_TEXT, "BX11LT1A", "BX11LT1AI" },
/* 10*/ { BARCODE_JAPANPOST, -1, -1, "1234", "" }, /* None*/
/* 11*/ { BARCODE_JAPANPOST, -1, BARCODE_RAW_TEXT, "1234", "1234" }, /* Note check char not included */
/* 12*/ { BARCODE_JAPANPOST, -1, BARCODE_RAW_TEXT, "123456-AB", "123456-AB" }, /* Ditto */
/* 13*/ { BARCODE_KOREAPOST, -1, -1, "123456", "1234569" },
/* 14*/ { BARCODE_KOREAPOST, -1, BARCODE_RAW_TEXT, "123456", "1234569" }, /* No difference */
/* 15*/ { BARCODE_PLANET, -1, -1, "12345678901", "" }, /* None */
/* 16*/ { BARCODE_PLANET, -1, BARCODE_RAW_TEXT, "12345678901", "123456789014" },
/* 17*/ { BARCODE_KIX, -1, -1, "0123456789ABCDEFGH", "" }, /* None */
/* 18*/ { BARCODE_KIX, -1, BARCODE_RAW_TEXT, "0123456789ABCDEFGH", "0123456789ABCDEFGH" },
/* 19*/ { BARCODE_DAFT, -1, -1, "DAFT", "" }, /* None */
/* 20*/ { BARCODE_DAFT, -1, BARCODE_RAW_TEXT, "DAFT", "DAFT" },
/* 0*/ { BARCODE_FLAT, -1, -1, "12345", "", "" }, /* None */
/* 1*/ { BARCODE_FLAT, -1, BARCODE_RAW_TEXT, "12345", "", "12345" },
/* 2*/ { BARCODE_POSTNET, -1, -1, "12345", "", "" }, /* None */
/* 3*/ { BARCODE_POSTNET, -1, BARCODE_RAW_TEXT, "12345", "", "123455" },
/* 4*/ { BARCODE_FIM, -1, -1, "e", "", "" }, /* None */
/* 5*/ { BARCODE_FIM, -1, BARCODE_RAW_TEXT, "e", "", "E" },
/* 6*/ { BARCODE_CEPNET, -1, -1, "12345678", "", "" }, /* None */
/* 7*/ { BARCODE_CEPNET, -1, BARCODE_RAW_TEXT, "12345678", "", "123456784" },
/* 8*/ { BARCODE_RM4SCC, -1, -1, "BX11LT1A", "", "" }, /* None*/
/* 9*/ { BARCODE_RM4SCC, -1, BARCODE_RAW_TEXT, "BX11LT1A", "", "BX11LT1AI" },
/* 10*/ { BARCODE_JAPANPOST, -1, -1, "1234", "", "" }, /* None*/
/* 11*/ { BARCODE_JAPANPOST, -1, BARCODE_RAW_TEXT, "1234", "", "1234" }, /* Note check char not included */
/* 12*/ { BARCODE_JAPANPOST, -1, BARCODE_RAW_TEXT, "123456-AB", "", "123456-AB" }, /* Ditto */
/* 13*/ { BARCODE_KOREAPOST, -1, -1, "123456", "1234569", "" },
/* 14*/ { BARCODE_KOREAPOST, -1, BARCODE_RAW_TEXT, "123456", "1234569", "1234569" }, /* No difference */
/* 15*/ { BARCODE_PLANET, -1, -1, "12345678901", "", "" }, /* None */
/* 16*/ { BARCODE_PLANET, -1, BARCODE_RAW_TEXT, "12345678901", "", "123456789014" },
/* 17*/ { BARCODE_KIX, -1, -1, "0123456789ABCDEFGH", "", "" }, /* None */
/* 18*/ { BARCODE_KIX, -1, BARCODE_RAW_TEXT, "0123456789ABCDEFGH", "", "0123456789ABCDEFGH" },
/* 19*/ { BARCODE_DAFT, -1, -1, "DAFT", "", "" }, /* None */
/* 20*/ { BARCODE_DAFT, -1, BARCODE_RAW_TEXT, "DAFT", "", "DAFT" },
};
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
int expected_length;
int expected_length, expected_raw_length;
testStartSymbol("test_hrt", &symbol);
testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) {
@@ -267,6 +268,7 @@ static void test_hrt(const testCtx *const p_ctx) {
-1 /*option_1*/, data[i].option_2, -1 /*option_3*/, data[i].output_options,
data[i].data, -1, debug);
expected_length = (int) strlen(data[i].expected);
expected_raw_length = (int) strlen(data[i].expected_raw);
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
@@ -275,6 +277,18 @@ static void test_hrt(const testCtx *const p_ctx) {
i, symbol->text_length, expected_length);
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
i, symbol->text, data[i].expected);
if (symbol->output_options & BARCODE_RAW_TEXT) {
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
assert_nonnull(symbol->raw_segs[0].source, "i:%d raw_segs[0].source NULL\n", i);
assert_equal(symbol->raw_segs[0].length, expected_raw_length,
"i:%d raw_segs[0].length %d != expected_raw_length %d\n",
i, symbol->raw_segs[0].length, expected_raw_length);
assert_zero(memcmp(symbol->raw_segs[0].source, data[i].expected_raw, expected_raw_length),
"i:%d memcmp(%s, %s, %d) != 0\n",
i, symbol->raw_segs[0].source, data[i].expected_raw, expected_raw_length);
} else {
assert_null(symbol->raw_segs, "i:%d raw_segs not NULL\n", i);
}
ZBarcode_Delete(symbol);
}
@@ -357,7 +371,7 @@ static void test_input(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
testStartSymbol("test_input", &symbol);
testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) {
@@ -555,7 +569,7 @@ static void test_encode(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
testStartSymbol("test_encode", &symbol);
testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) {