1
0
mirror of https://git.code.sf.net/p/zint/code synced 2026-01-27 22:05:57 +00:00

general: raw_segs -> content_segs, BARCODE_RAW_TEXT ->

`BARCODE_CONTENT_SEGS`, `z_rt_XXX()` -> `z_ct_XXX()`;
  move `encoded_data`/`row_height` to end of `zint_symbol`
  (see ZXing-C++ issue #883)
manual: update re `content_segs`; `my_symbol` -> `symbol`;
  improve MicroPDF417 description
This commit is contained in:
gitlost
2025-11-04 23:02:10 +00:00
parent 543696cb06
commit f0c7248b62
82 changed files with 2203 additions and 2187 deletions

View File

@@ -103,45 +103,45 @@ static void test_hrt(const testCtx *const p_ctx) {
const char *data;
const char *expected;
const char *expected_raw;
const char *expected_content;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 0*/ { BARCODE_PHARMA, -1, -1, "123456", "", "" }, /* None */
/* 1*/ { BARCODE_PHARMA, -1, BARCODE_RAW_TEXT, "123456", "", "123456" },
/* 1*/ { BARCODE_PHARMA, -1, BARCODE_CONTENT_SEGS, "123456", "", "123456" },
/* 2*/ { BARCODE_PHARMA_TWO, -1, -1, "123456", "", "" }, /* None */
/* 3*/ { BARCODE_PHARMA_TWO, -1, BARCODE_RAW_TEXT, "123456", "", "123456" },
/* 3*/ { BARCODE_PHARMA_TWO, -1, BARCODE_CONTENT_SEGS, "123456", "", "123456" },
/* 4*/ { BARCODE_CODE32, -1, -1, "123456", "A001234564", "" },
/* 5*/ { BARCODE_CODE32, -1, BARCODE_RAW_TEXT, "123456", "A001234564", "015PN4" }, /* Actual encoded CODE39 value */
/* 5*/ { BARCODE_CODE32, -1, BARCODE_CONTENT_SEGS, "123456", "A001234564", "015PN4" }, /* Actual encoded CODE39 value */
/* 6*/ { BARCODE_CODE32, -1, -1, "12345678", "A123456788", "" },
/* 7*/ { BARCODE_CODE32, -1, BARCODE_RAW_TEXT, "12345678", "A123456788", "3PRM8N" },
/* 7*/ { BARCODE_CODE32, -1, BARCODE_CONTENT_SEGS, "12345678", "A123456788", "3PRM8N" },
/* 8*/ { BARCODE_CODE32, 1, -1, "12345678", "A123456788", "" }, /* Ignore option_2 re check digits */
/* 9*/ { BARCODE_CODE32, 1, BARCODE_RAW_TEXT, "12345678", "A123456788", "3PRM8N" },
/* 9*/ { BARCODE_CODE32, 1, BARCODE_CONTENT_SEGS, "12345678", "A123456788", "3PRM8N" },
/* 10*/ { BARCODE_CODE32, 2, -1, "12345678", "A123456788", "" }, /* Ignore option_2 re check digits */
/* 11*/ { BARCODE_CODE32, 2, BARCODE_RAW_TEXT, "12345678", "A123456788", "3PRM8N" },
/* 11*/ { BARCODE_CODE32, 2, BARCODE_CONTENT_SEGS, "12345678", "A123456788", "3PRM8N" },
/* 12*/ { BARCODE_PZN, -1, -1, "12345", "PZN - 00123458", "" }, /* Pads with zeroes if length < 7 */
/* 13*/ { BARCODE_PZN, -1, BARCODE_RAW_TEXT, "12345", "PZN - 00123458", "-00123458" }, /* Actual encoded CODE39 value */
/* 13*/ { BARCODE_PZN, -1, BARCODE_CONTENT_SEGS, "12345", "PZN - 00123458", "-00123458" }, /* Actual encoded CODE39 value */
/* 14*/ { BARCODE_PZN, -1, -1, "123456", "PZN - 01234562", "" },
/* 15*/ { BARCODE_PZN, -1, BARCODE_RAW_TEXT, "123456", "PZN - 01234562", "-01234562" },
/* 15*/ { BARCODE_PZN, -1, BARCODE_CONTENT_SEGS, "123456", "PZN - 01234562", "-01234562" },
/* 16*/ { BARCODE_PZN, -1, -1, "1234567", "PZN - 12345678", "" },
/* 17*/ { BARCODE_PZN, -1, BARCODE_RAW_TEXT, "1234567", "PZN - 12345678", "-12345678" },
/* 17*/ { BARCODE_PZN, -1, BARCODE_CONTENT_SEGS, "1234567", "PZN - 12345678", "-12345678" },
/* 18*/ { BARCODE_PZN, -1, -1, "12345678", "PZN - 12345678", "" },
/* 19*/ { BARCODE_PZN, -1, BARCODE_RAW_TEXT, "12345678", "PZN - 12345678", "-12345678" },
/* 19*/ { BARCODE_PZN, -1, BARCODE_CONTENT_SEGS, "12345678", "PZN - 12345678", "-12345678" },
/* 20*/ { BARCODE_PZN, 1, -1, "1234", "PZN - 0012345", "" }, /* PZN7, pads with zeroes if length < 6 */
/* 21*/ { BARCODE_PZN, 1, BARCODE_RAW_TEXT, "1234", "PZN - 0012345", "-0012345" },
/* 21*/ { BARCODE_PZN, 1, BARCODE_CONTENT_SEGS, "1234", "PZN - 0012345", "-0012345" },
/* 22*/ { BARCODE_PZN, 1, -1, "12345", "PZN - 0123458", "" },
/* 23*/ { BARCODE_PZN, 1, BARCODE_RAW_TEXT, "12345", "PZN - 0123458", "-0123458" },
/* 23*/ { BARCODE_PZN, 1, BARCODE_CONTENT_SEGS, "12345", "PZN - 0123458", "-0123458" },
/* 24*/ { BARCODE_PZN, 1, -1, "123456", "PZN - 1234562", "" },
/* 25*/ { BARCODE_PZN, 1, BARCODE_RAW_TEXT, "123456", "PZN - 1234562", "-1234562" },
/* 25*/ { BARCODE_PZN, 1, BARCODE_CONTENT_SEGS, "123456", "PZN - 1234562", "-1234562" },
/* 26*/ { BARCODE_PZN, 1, -1, "1234562", "PZN - 1234562", "" },
/* 27*/ { BARCODE_PZN, 1, BARCODE_RAW_TEXT, "1234562", "PZN - 1234562", "-1234562" },
/* 27*/ { BARCODE_PZN, 1, BARCODE_CONTENT_SEGS, "1234562", "PZN - 1234562", "-1234562" },
/* 28*/ { BARCODE_PZN, 2, -1, "12345", "PZN - 00123458", "" }, /* Ignore option_2 re check digits */
/* 29*/ { BARCODE_PZN, 2, BARCODE_RAW_TEXT, "12345", "PZN - 00123458", "-00123458" },
/* 29*/ { BARCODE_PZN, 2, BARCODE_CONTENT_SEGS, "12345", "PZN - 00123458", "-00123458" },
};
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
int expected_length, expected_raw_length;
int expected_length, expected_content_length;
testStartSymbol(p_ctx->func_name, &symbol);
@@ -156,7 +156,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);
expected_content_length = (int) strlen(data[i].expected_content);
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);
@@ -165,18 +165,18 @@ static void test_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),
if (symbol->output_options & BARCODE_CONTENT_SEGS) {
assert_nonnull(symbol->content_segs, "i:%d content_segs NULL\n", i);
assert_nonnull(symbol->content_segs[0].source, "i:%d content_segs[0].source NULL\n", i);
assert_equal(symbol->content_segs[0].length, expected_content_length,
"i:%d content_segs[0].length %d != expected_content_length %d\n",
i, symbol->content_segs[0].length, expected_content_length);
assert_zero(memcmp(symbol->content_segs[0].source, data[i].expected_content, expected_content_length),
"i:%d memcmp(%.*s, %s, %d) != 0\n",
i, symbol->raw_segs[0].length, symbol->raw_segs[0].source, data[i].expected_raw,
expected_raw_length);
i, symbol->content_segs[0].length, symbol->content_segs[0].source, data[i].expected_content,
expected_content_length);
} else {
assert_null(symbol->raw_segs, "i:%d raw_segs not NULL\n", i);
assert_null(symbol->content_segs, "i:%d content_segs not NULL\n", i);
}
ZBarcode_Delete(symbol);