mirror of
https://git.code.sf.net/p/zint/code
synced 2025-06-02 16:09:51 -04: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:
parent
d1bf02e156
commit
a6c225447e
120 changed files with 10511 additions and 5620 deletions
|
@ -39,26 +39,27 @@ static void test_4s_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*/ { -1, "1100000000000XY11", "" }, /* None */
|
||||
/* 1*/ { BARCODE_RAW_TEXT, "1100000000000XY11", "1100000000000XY11 " },
|
||||
/* 2*/ { -1, "1100000000000XY11 ", "" }, /* None */
|
||||
/* 3*/ { BARCODE_RAW_TEXT, "1100000000000XY11 ", "1100000000000XY11 " },
|
||||
/* 4*/ { -1, "0100000000000A00AA0A", "" }, /* None */
|
||||
/* 5*/ { BARCODE_RAW_TEXT, "0100000000000A00AA0A", "0100000000000A00AA0A " }, /* None */
|
||||
/* 6*/ { -1, "41038422416563762XY11 ", "" }, /* None */
|
||||
/* 7*/ { BARCODE_RAW_TEXT, "41038422416563762XY11 ", "41038422416563762XY11 " },
|
||||
/* 8*/ { -1, "01000000000000000AA000AA0A", "" }, /* None */
|
||||
/* 9*/ { BARCODE_RAW_TEXT, "01000000000000000AA000AA0A", "01000000000000000AA000AA0A" },
|
||||
/* 0*/ { -1, "1100000000000XY11", "", "" }, /* None */
|
||||
/* 1*/ { BARCODE_RAW_TEXT, "1100000000000XY11", "", "1100000000000XY11 " },
|
||||
/* 2*/ { -1, "1100000000000XY11 ", "", "" }, /* None */
|
||||
/* 3*/ { BARCODE_RAW_TEXT, "1100000000000XY11 ", "", "1100000000000XY11 " },
|
||||
/* 4*/ { -1, "0100000000000A00AA0A", "", "" }, /* None */
|
||||
/* 5*/ { BARCODE_RAW_TEXT, "0100000000000A00AA0A", "", "0100000000000A00AA0A " }, /* None */
|
||||
/* 6*/ { -1, "41038422416563762XY11 ", "", "" }, /* None */
|
||||
/* 7*/ { BARCODE_RAW_TEXT, "41038422416563762XY11 ", "", "41038422416563762XY11 " },
|
||||
/* 8*/ { -1, "01000000000000000AA000AA0A", "", "" }, /* None */
|
||||
/* 9*/ { BARCODE_RAW_TEXT, "01000000000000000AA000AA0A", "", "01000000000000000AA000AA0A" },
|
||||
};
|
||||
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_4s_hrt", &symbol);
|
||||
testStartSymbol(p_ctx->func_name, &symbol);
|
||||
|
||||
for (i = 0; i < data_size; i++) {
|
||||
|
||||
|
@ -71,6 +72,7 @@ static void test_4s_hrt(const testCtx *const p_ctx) {
|
|||
-1 /*option_1*/, -1 /*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);
|
||||
|
@ -79,6 +81,18 @@ static void test_4s_hrt(const testCtx *const p_ctx) {
|
|||
i, symbol->text_length, expected_length, symbol->text);
|
||||
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);
|
||||
}
|
||||
|
@ -159,7 +173,7 @@ static void test_4s_input(const testCtx *const p_ctx) {
|
|||
int i, length, ret;
|
||||
struct zint_symbol *symbol = NULL;
|
||||
|
||||
testStartSymbol("test_4s_input", &symbol);
|
||||
testStartSymbol(p_ctx->func_name, &symbol);
|
||||
|
||||
for (i = 0; i < data_size; i++) {
|
||||
|
||||
|
@ -229,7 +243,7 @@ static void test_4s_encode_vector(const testCtx *const p_ctx) {
|
|||
|
||||
char actual_daft[80];
|
||||
|
||||
testStartSymbol("test_4s_encode_vector", &symbol);
|
||||
testStartSymbol(p_ctx->func_name, &symbol);
|
||||
|
||||
for (i = 0; i < data_size; i++) {
|
||||
|
||||
|
@ -283,7 +297,7 @@ static void test_4s_encode(const testCtx *const p_ctx) {
|
|||
|
||||
char escaped[1024];
|
||||
|
||||
testStartSymbol("test_4s_encode", &symbol);
|
||||
testStartSymbol(p_ctx->func_name, &symbol);
|
||||
|
||||
for (i = 0; i < data_size; i++) {
|
||||
|
||||
|
@ -374,7 +388,7 @@ static void test_2d_input(const testCtx *const p_ctx) {
|
|||
int i, length, ret;
|
||||
struct zint_symbol *symbol = NULL;
|
||||
|
||||
testStartSymbol("test_2d_input", &symbol);
|
||||
testStartSymbol(p_ctx->func_name, &symbol);
|
||||
|
||||
for (i = 0; i < data_size; i++) {
|
||||
|
||||
|
@ -597,10 +611,11 @@ static void test_2d_encode(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("test_2d_encode", &symbol);
|
||||
testStartSymbol(p_ctx->func_name, &symbol);
|
||||
|
||||
for (i = 0; i < data_size; i++) {
|
||||
|
||||
|
@ -646,12 +661,14 @@ static void test_2d_encode(const testCtx *const p_ctx) {
|
|||
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, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len);
|
||||
ret = testUtilZXingCPP(i, symbol, data[i].data, 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 = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len);
|
||||
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);
|
||||
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len,
|
||||
escaped);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -662,6 +679,81 @@ static void test_2d_encode(const testCtx *const p_ctx) {
|
|||
testFinish();
|
||||
}
|
||||
|
||||
static void test_2d_rt(const testCtx *const p_ctx) {
|
||||
int debug = p_ctx->debug;
|
||||
|
||||
struct item {
|
||||
int input_mode;
|
||||
int output_options;
|
||||
const char *data;
|
||||
int length;
|
||||
int ret;
|
||||
int expected_eci;
|
||||
const char *expected;
|
||||
int expected_length;
|
||||
int expected_raw_eci;
|
||||
};
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { UNICODE_MODE, -1, "jgb 012100123412345678ab19xy1a 0", -1, 0, 0, "", -1, 0 },
|
||||
/* 1*/ { UNICODE_MODE, BARCODE_RAW_TEXT, "jgb 012100123412345678ab19xy1a 0", -1, 0, 0, "JGB 012100123412345678AB19XY1A 0 ", -1, 3 },
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
struct zint_symbol *symbol = NULL;
|
||||
|
||||
int expected_length;
|
||||
|
||||
char escaped[4096];
|
||||
char escaped2[4096];
|
||||
|
||||
testStartSymbol(p_ctx->func_name, &symbol);
|
||||
|
||||
for (i = 0; i < data_size; i++) {
|
||||
|
||||
if (testContinue(p_ctx, i)) continue;
|
||||
|
||||
symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
length = testUtilSetSymbol(symbol, BARCODE_MAILMARK_2D, data[i].input_mode, -1 /*eci*/,
|
||||
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options,
|
||||
data[i].data, data[i].length, debug);
|
||||
expected_length = data[i].expected_length == -1 ? (int) strlen(data[i].expected) : data[i].expected_length;
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
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_length,
|
||||
"i:%d raw_segs[0].length %d != expected_length %d\n",
|
||||
i, symbol->raw_segs[0].length, expected_length);
|
||||
assert_zero(memcmp(symbol->raw_segs[0].source, data[i].expected, expected_length),
|
||||
"i:%d raw_segs[0].source memcmp(%s, %s, %d) != 0\n", i,
|
||||
testUtilEscape((const char *) symbol->raw_segs[0].source, symbol->raw_segs[0].length,
|
||||
escaped, sizeof(escaped)),
|
||||
testUtilEscape(data[i].expected, expected_length, escaped2, sizeof(escaped2)),
|
||||
expected_length);
|
||||
assert_equal(symbol->raw_segs[0].eci, data[i].expected_raw_eci,
|
||||
"i:%d raw_segs[0].eci %d != expected_raw_eci %d\n",
|
||||
i, symbol->raw_segs[0].eci, data[i].expected_raw_eci);
|
||||
} else {
|
||||
assert_null(symbol->raw_segs, "i:%d raw_segs not NULL\n", i);
|
||||
}
|
||||
}
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
}
|
||||
|
||||
testFinish();
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
testFunction funcs[] = { /* name, func */
|
||||
|
@ -671,6 +763,7 @@ int main(int argc, char *argv[]) {
|
|||
{ "test_4s_encode", test_4s_encode },
|
||||
{ "test_2d_input", test_2d_input },
|
||||
{ "test_2d_encode", test_2d_encode },
|
||||
{ "test_2d_rt", test_2d_rt },
|
||||
};
|
||||
|
||||
testRun(argc, argv, funcs, ARRAY_SIZE(funcs));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue