mirror of
https://git.code.sf.net/p/zint/code
synced 2025-05-15 07:34:35 -04:00
Add Structured Append support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, MAXICODE, MICROPDF417, PDF417, QRCODE, ULTRA DOTCODE: use pre-calculated generator poly coeffs in Reed-Solomon for performance improvement PDF417/MICROPDF417: use common routine pdf417_initial() GUI: code lines <= 118, shorthand widget_obj(), shorten calling upcean_addon_gap(), upcean_guard_descent() various backend: var name debug -> debug_print
This commit is contained in:
parent
e8b1f7a12e
commit
c0791ad85e
69 changed files with 6738 additions and 1822 deletions
|
@ -83,25 +83,33 @@ static void test_options(int index, int debug) {
|
|||
int output_options;
|
||||
int option_2;
|
||||
int option_3;
|
||||
struct zint_structapp structapp;
|
||||
char *data;
|
||||
int ret;
|
||||
|
||||
int expected_rows;
|
||||
int expected_width;
|
||||
const char *expected_errtxt;
|
||||
};
|
||||
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
|
||||
struct item data[] = {
|
||||
/* 0*/ { -1, -1, -1, -1, "1", 0, 9, 14 },
|
||||
/* 1*/ { -1, -1, -1, -1, "1234567890", 0, 12, 19 },
|
||||
/* 2*/ { -1, -1, 19, -1, "1234567890", 0, 12, 19 },
|
||||
/* 3*/ { -1, -1, 12, -1, "1234567890", 0, 19, 12 },
|
||||
/* 4*/ { -1, -1, 5, -1, "1234567890", 0, 44, 5 },
|
||||
/* 5*/ { -1, -1, 4, -1, "1234567890", ZINT_ERROR_INVALID_OPTION, -1, -1 }, // Cols < 5
|
||||
/* 6*/ { -1, -1, 200, -1, "1234567890", ZINT_ERROR_INVALID_OPTION, -1, -1 }, // Not enough data - height 3 too small
|
||||
/* 7*/ { -1, -1, 200, -1, "1234567890123456789012345678901234567890", 0, 5, 200 }, // Cols 200 max
|
||||
/* 8*/ { -1, -1, 200, -1, "12345678901234567890123456789012345678901234567890123456789012345678901234567890", 0, 7, 200 },
|
||||
/* 9*/ { -1, -1, 201, -1, "12345678901234567890123456789012345678901234567890123456789012345678901234567890", ZINT_ERROR_INVALID_OPTION, -1, -1 },
|
||||
/* 10*/ { -1, -1, -1, 10 << 8, "1", 0, 9, 14 }, // Mask > 8 + 1 ignored
|
||||
/* 0*/ { -1, -1, -1, -1, { 0, 0, "" }, "1", 0, 9, 14, "" },
|
||||
/* 1*/ { -1, -1, -1, -1, { 0, 0, "" }, "1234567890", 0, 12, 19, "" },
|
||||
/* 2*/ { -1, -1, 19, -1, { 0, 0, "" }, "1234567890", 0, 12, 19, "" },
|
||||
/* 3*/ { -1, -1, 12, -1, { 0, 0, "" }, "1234567890", 0, 19, 12, "" },
|
||||
/* 4*/ { -1, -1, 5, -1, { 0, 0, "" }, "1234567890", 0, 44, 5, "" },
|
||||
/* 5*/ { -1, -1, 4, -1, { 0, 0, "" }, "1234567890", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 529: Symbol width 4 is too small" }, // Cols < 5
|
||||
/* 6*/ { -1, -1, 200, -1, { 0, 0, "" }, "1234567890", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 529: Symbol height 3 is too small" }, // Not enough data - height 3 too small
|
||||
/* 7*/ { -1, -1, 200, -1, { 0, 0, "" }, "1234567890123456789012345678901234567890", 0, 5, 200, "" }, // Cols 200 max
|
||||
/* 8*/ { -1, -1, 200, -1, { 0, 0, "" }, "12345678901234567890123456789012345678901234567890123456789012345678901234567890", 0, 7, 200, "" },
|
||||
/* 9*/ { -1, -1, 201, -1, { 0, 0, "" }, "12345678901234567890123456789012345678901234567890123456789012345678901234567890", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 528: Symbol width 201 is too large" },
|
||||
/* 10*/ { -1, -1, -1, 10 << 8, { 0, 0, "" }, "1", 0, 9, 14, "" }, // Mask > 8 + 1 ignored
|
||||
/* 11*/ { -1, -1, 19, -1, { 0, 0, "" }, "ABCDE", 0, 12, 19, "" },
|
||||
/* 12*/ { -1, -1, 19, -1, { 35, 35, "" }, "ABCDE", 0, 16, 19, "" },
|
||||
/* 13*/ { -1, -1, 19, -1, { 1, 1, "" }, "ABCDE", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 730: Structured Append count out of range (2-35)" },
|
||||
/* 14*/ { -1, -1, 19, -1, { 1, 36, "" }, "ABCDE", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 730: Structured Append count out of range (2-35)" },
|
||||
/* 15*/ { -1, -1, 19, -1, { 3, 2, "" }, "ABCDE", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 731: Structured Append index out of range (1-2)" },
|
||||
/* 16*/ { -1, -1, 19, -1, { 1, 2, "1" }, "ABCDE", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 732: Structured Append ID not available for DotCode" },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
|
@ -117,6 +125,9 @@ static void test_options(int index, int debug) {
|
|||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
length = testUtilSetSymbol(symbol, BARCODE_DOTCODE, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, data[i].option_3, data[i].output_options, data[i].data, -1, debug);
|
||||
if (data[i].structapp.count) {
|
||||
symbol->structapp = data[i].structapp;
|
||||
}
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) 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);
|
||||
|
@ -125,6 +136,7 @@ static void test_options(int index, int debug) {
|
|||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, symbol->errtxt);
|
||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, symbol->errtxt);
|
||||
}
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
}
|
||||
|
@ -137,6 +149,7 @@ static void test_input(int index, int generate, int debug) {
|
|||
struct item {
|
||||
int input_mode;
|
||||
int eci;
|
||||
struct zint_structapp structapp;
|
||||
char *data;
|
||||
int length;
|
||||
int ret;
|
||||
|
@ -144,44 +157,48 @@ static void test_input(int index, int generate, int debug) {
|
|||
char *comment;
|
||||
};
|
||||
struct item data[] = {
|
||||
/* 0*/ { UNICODE_MODE, -1, "A", -1, 0, "66 21", "" },
|
||||
/* 1*/ { UNICODE_MODE, 3, "A", -1, 0, "6C 03 66 21", "" },
|
||||
/* 2*/ { UNICODE_MODE, 40, "A", -1, 0, "6C 28 00 00 66 21", "" },
|
||||
/* 3*/ { UNICODE_MODE, 113, "A", -1, 0, "6C 28 00 49 66 21", "" },
|
||||
/* 4*/ { UNICODE_MODE, 899, "A", -1, 0, "6C 28 07 44 66 21", "" },
|
||||
/* 5*/ { UNICODE_MODE, 12769, "A", -1, 0, "6C 28 70 49 66 21", "" },
|
||||
/* 6*/ { UNICODE_MODE, 811799, "A", -1, 0, "6C 67 40 50 66 21", "" },
|
||||
/* 7*/ { UNICODE_MODE, 811800, "A", -1, ZINT_ERROR_INVALID_OPTION, "", "" },
|
||||
/* 8*/ { UNICODE_MODE, -1, "\000", 1, 0, "65 40", "LatchA (0x65) NUL" },
|
||||
/* 9*/ { UNICODE_MODE, -1, "\010", -1, 0, "65 48", "LatchA (0x65) BS" },
|
||||
/* 10*/ { UNICODE_MODE, -1, "\011", -1, 0, "65 49", "Lead special; LatchA (0x65) HT" },
|
||||
/* 11*/ { UNICODE_MODE, -1, "\034", -1, 0, "65 5C", "Lead special; LatchA (0x65) FS" },
|
||||
/* 12*/ { UNICODE_MODE, -1, "\035", -1, 0, "65 5D", "Lead special; LatchA (0x65) GS" },
|
||||
/* 13*/ { UNICODE_MODE, -1, "\036", -1, 0, "65 5E", "Lead special; LatchA (0x65) RS" },
|
||||
/* 14*/ { UNICODE_MODE, -1, "\037", -1, 0, "65 5F", "LatchA (0x65) US" },
|
||||
/* 15*/ { UNICODE_MODE, -1, "\177", -1, 0, "66 5F", "ShiftB (0x66) DEL" },
|
||||
/* 16*/ { UNICODE_MODE, -1, "[)>\03605\035A\036\004", -1, 0, "6A 61 21", "[)>RS 05 GS A RS EOT; LatchB (0x6A) Macro97 (0x61) A" },
|
||||
/* 17*/ { UNICODE_MODE, -1, "[)>\03606\035\011\034\035\036\036\004", -1, 0, "6A 62 61 62 63 64", "[)>RS 06 GS HT FS GS RS RS EOT; LatchB (0x6A) Macro98 (0x62) HT FS GS RS" },
|
||||
/* 18*/ { UNICODE_MODE, -1, "[)>\03612\03512345\036\004", -1, 0, "6A 63 11 67 17 2D", "[)>RS 12 GS A RS EOT; LatchB (0x6A) Macro99 (0x63) 1 2xShiftC (0x67) 23 45" },
|
||||
/* 19*/ { UNICODE_MODE, -1, "[)>\03601Blah\004", -1, 0, "6A 64 10 11 22 4C 41 48", "[)>RS 01 Blah EOT; LatchB (0x6A) Macro100 (0x64) 0 1 B l a h" },
|
||||
/* 20*/ { UNICODE_MODE, -1, "[)>\03605\035A\004", -1, 0, "6A 64 10 15 63 21", "[)>RS 05 GS A EOT; LatchB (0x6A) Macro100 (0x64) 0 5 HT A" },
|
||||
/* 21*/ { UNICODE_MODE, -1, "[)>\03606A\004", -1, 0, "6A 64 10 16 21", "[)>RS 06 A EOT; LatchB (0x6A) Macro100 (0x64) 0 6 A" },
|
||||
/* 22*/ { UNICODE_MODE, -1, "[)>\036991\036\004", -1, 0, "6A 64 19 19 11 64", "[)>RS 99 1 RS EOT; LatchB (0x6A) Macro100 (0x64) 9 9 1 RS" },
|
||||
/* 23*/ { UNICODE_MODE, -1, "1712345610", -1, 0, "6B 64 0C 22 38", "FNC1 (0x6B) 17..10 12 34 56" },
|
||||
/* 24*/ { GS1_MODE, -1, "[17]123456[10]123", -1, ZINT_WARN_NONCOMPLIANT, "64 0C 22 38 0C 66 13", "17..10 12 34 56 12 ShiftB (0x66) 3" },
|
||||
/* 25*/ { GS1_MODE, -1, "[90]ABC[90]abc[90]123", -1, 0, "5A 6A 21 22 23 6B 19 10 41 42 43 6B 19 67 01 17", "90 LatchB (0x6A) A B C FNC1 (0x6B) 9 0 a b c FNC1 (0x6B) 9 2xShitfC (0x67) 01 23" },
|
||||
/* 26*/ { GS1_MODE | GS1PARENS_MODE, -1, "(90)ABC(90)abc(90)123", -1, 0, "5A 6A 21 22 23 6B 19 10 41 42 43 6B 19 67 01 17", "90 LatchB (0x6A) A B C FNC1 (0x6B) 9 0 a b c FNC1 (0x6B) 9 2xShitfC (0x67) 01 23" },
|
||||
/* 27*/ { UNICODE_MODE, -1, "99aA[{00\000", 9, 0, "6B 63 6A 41 21 3B 5B 10 10 65 40", "FNC1 (0x6B) 99 LatchB (0x6A) a A [ { 0 0 ShiftA (0x65) NUL" },
|
||||
/* 28*/ { UNICODE_MODE, -1, "\015\012", -1, 0, "66 60", "ShiftB (0x66) CR/LF" },
|
||||
/* 29*/ { UNICODE_MODE, -1, "A\015\012", -1, 0, "67 21 60", "2xShiftB (0x67) A CR/LF" },
|
||||
/* 30*/ { UNICODE_MODE, -1, "\015\015\012", -1, 0, "65 4D 4D 4A", "LatchA (0x65) CR CR LF" },
|
||||
/* 31*/ { UNICODE_MODE, -1, "ABCDE12345678", -1, 0, "6A 21 22 23 24 25 69 0C 22 38 4E", "LatchB (0x6A) A B C D 4xShiftC 12 34 56 78" },
|
||||
/* 32*/ { UNICODE_MODE, -1, "\000ABCD1234567890", 15, 0, "65 40 21 22 23 24 6A 0C 22 38 4E 5A", "LatchA (0x65) NULL A B C D LatchC (0x6A) 12 34 56 78 90" },
|
||||
/* 33*/ { DATA_MODE, -1, "\141\142\143\144\145\200\201\202\203\204\377", -1, 0, "6A 41 42 43 44 45 70 31 5A 35 21 5A 5F 02 31", "LatchB (0x6A) a b c d e BinaryLatch (0x70) 0x80 0x81 0x82 0x83 0x84 0xFF" },
|
||||
/* 34*/ { DATA_MODE, -1, "\200\061\062\240\063\064\201\202\065\066", -1, 0, "6E 40 0C 6F 00 22 70 03 10 42 6E 15 16", "UpperShiftA (0x6E) NUL 12 UpperShiftB (0x6F) SP 34 BinaryLatch (0x70) 0x81 0x82 TermB (0x6E) 5 6" },
|
||||
/* 35*/ { DATA_MODE, -1, "\200\201\202\203\061\062\063\064", -1, 0, "70 13 56 0A 59 2C 67 0C 22", "BinaryLatch (0x70) 0x80 0x81 0x82 0x83 Intr2xShiftC (0x67) 12 3" },
|
||||
/* 36*/ { DATA_MODE, -1, "\001\200\201\202\203\204\200\201\202\203\204", -1, 0, "65 41 70 31 5A 35 21 5A 5F 31 5A 35 21 5A 5F", "LatchA (0x65) SOH BinaryLatch (0x70) 0x80 0x81 0x82 0x83 0x80 0x81 0x82 0x83" },
|
||||
/* 37*/ { UNICODE_MODE, -1, "\001abc\011\015\012\036", -1, 0, "65 41 65 41 42 43 61 60 64", "LatchA (0x65) SOH 6xShiftB (0x65) a b c HT CR/LF RS" },
|
||||
/* 0*/ { UNICODE_MODE, -1, { 0, 0, "" }, "A", -1, 0, "66 21", "" },
|
||||
/* 1*/ { UNICODE_MODE, 3, { 0, 0, "" }, "A", -1, 0, "6C 03 66 21", "" },
|
||||
/* 2*/ { UNICODE_MODE, 40, { 0, 0, "" }, "A", -1, 0, "6C 28 00 00 66 21", "" },
|
||||
/* 3*/ { UNICODE_MODE, 113, { 0, 0, "" }, "A", -1, 0, "6C 28 00 49 66 21", "" },
|
||||
/* 4*/ { UNICODE_MODE, 899, { 0, 0, "" }, "A", -1, 0, "6C 28 07 44 66 21", "" },
|
||||
/* 5*/ { UNICODE_MODE, 12769, { 0, 0, "" }, "A", -1, 0, "6C 28 70 49 66 21", "" },
|
||||
/* 6*/ { UNICODE_MODE, 811799, { 0, 0, "" }, "A", -1, 0, "6C 67 40 50 66 21", "" },
|
||||
/* 7*/ { UNICODE_MODE, 811800, { 0, 0, "" }, "A", -1, ZINT_ERROR_INVALID_OPTION, "Error 525: Invalid ECI", "" },
|
||||
/* 8*/ { UNICODE_MODE, -1, { 0, 0, "" }, "\000", 1, 0, "65 40", "LatchA (0x65) NUL" },
|
||||
/* 9*/ { UNICODE_MODE, -1, { 0, 0, "" }, "\010", -1, 0, "65 48", "LatchA (0x65) BS" },
|
||||
/* 10*/ { UNICODE_MODE, -1, { 0, 0, "" }, "\011", -1, 0, "65 49", "Lead special; LatchA (0x65) HT" },
|
||||
/* 11*/ { UNICODE_MODE, -1, { 0, 0, "" }, "\034", -1, 0, "65 5C", "Lead special; LatchA (0x65) FS" },
|
||||
/* 12*/ { UNICODE_MODE, -1, { 0, 0, "" }, "\035", -1, 0, "65 5D", "Lead special; LatchA (0x65) GS" },
|
||||
/* 13*/ { UNICODE_MODE, -1, { 0, 0, "" }, "\036", -1, 0, "65 5E", "Lead special; LatchA (0x65) RS" },
|
||||
/* 14*/ { UNICODE_MODE, -1, { 0, 0, "" }, "\037", -1, 0, "65 5F", "LatchA (0x65) US" },
|
||||
/* 15*/ { UNICODE_MODE, -1, { 0, 0, "" }, "\177", -1, 0, "66 5F", "ShiftB (0x66) DEL" },
|
||||
/* 16*/ { UNICODE_MODE, -1, { 0, 0, "" }, "[)>\03605\035A\036\004", -1, 0, "6A 61 21", "[)>RS 05 GS A RS EOT; LatchB (0x6A) Macro97 (0x61) A" },
|
||||
/* 17*/ { UNICODE_MODE, -1, { 0, 0, "" }, "[)>\03606\035\011\034\035\036\036\004", -1, 0, "6A 62 61 62 63 64", "[)>RS 06 GS HT FS GS RS RS EOT; LatchB (0x6A) Macro98 (0x62) HT FS GS RS" },
|
||||
/* 18*/ { UNICODE_MODE, -1, { 0, 0, "" }, "[)>\03612\03512345\036\004", -1, 0, "6A 63 11 67 17 2D", "[)>RS 12 GS A RS EOT; LatchB (0x6A) Macro99 (0x63) 1 2xShiftC (0x67) 23 45" },
|
||||
/* 19*/ { UNICODE_MODE, -1, { 0, 0, "" }, "[)>\03601Blah\004", -1, 0, "6A 64 10 11 22 4C 41 48", "[)>RS 01 Blah EOT; LatchB (0x6A) Macro100 (0x64) 0 1 B l a h" },
|
||||
/* 20*/ { UNICODE_MODE, -1, { 0, 0, "" }, "[)>\03605\035A\004", -1, 0, "6A 64 10 15 63 21", "[)>RS 05 GS A EOT; LatchB (0x6A) Macro100 (0x64) 0 5 HT A" },
|
||||
/* 21*/ { UNICODE_MODE, -1, { 0, 0, "" }, "[)>\03606A\004", -1, 0, "6A 64 10 16 21", "[)>RS 06 A EOT; LatchB (0x6A) Macro100 (0x64) 0 6 A" },
|
||||
/* 22*/ { UNICODE_MODE, -1, { 0, 0, "" }, "[)>\036991\036\004", -1, 0, "6A 64 19 19 11 64", "[)>RS 99 1 RS EOT; LatchB (0x6A) Macro100 (0x64) 9 9 1 RS" },
|
||||
/* 23*/ { UNICODE_MODE, -1, { 0, 0, "" }, "1712345610", -1, 0, "6B 64 0C 22 38", "FNC1 (0x6B) 17..10 12 34 56" },
|
||||
/* 24*/ { GS1_MODE, -1, { 0, 0, "" }, "[17]123456[10]123", -1, ZINT_WARN_NONCOMPLIANT, "64 0C 22 38 0C 66 13", "17..10 12 34 56 12 ShiftB (0x66) 3" },
|
||||
/* 25*/ { GS1_MODE, -1, { 0, 0, "" }, "[90]ABC[90]abc[90]123", -1, 0, "5A 6A 21 22 23 6B 19 10 41 42 43 6B 19 67 01 17", "90 LatchB (0x6A) A B C FNC1 (0x6B) 9 0 a b c FNC1 (0x6B) 9 2xShitfC (0x67) 01 23" },
|
||||
/* 26*/ { GS1_MODE | GS1PARENS_MODE, -1, { 0, 0, "" }, "(90)ABC(90)abc(90)123", -1, 0, "5A 6A 21 22 23 6B 19 10 41 42 43 6B 19 67 01 17", "90 LatchB (0x6A) A B C FNC1 (0x6B) 9 0 a b c FNC1 (0x6B) 9 2xShitfC (0x67) 01 23" },
|
||||
/* 27*/ { UNICODE_MODE, -1, { 0, 0, "" }, "99aA[{00\000", 9, 0, "6B 63 6A 41 21 3B 5B 10 10 65 40", "FNC1 (0x6B) 99 LatchB (0x6A) a A [ { 0 0 ShiftA (0x65) NUL" },
|
||||
/* 28*/ { UNICODE_MODE, -1, { 0, 0, "" }, "\015\012", -1, 0, "66 60", "ShiftB (0x66) CR/LF" },
|
||||
/* 29*/ { UNICODE_MODE, -1, { 0, 0, "" }, "A\015\012", -1, 0, "67 21 60", "2xShiftB (0x67) A CR/LF" },
|
||||
/* 30*/ { UNICODE_MODE, -1, { 0, 0, "" }, "\015\015\012", -1, 0, "65 4D 4D 4A", "LatchA (0x65) CR CR LF" },
|
||||
/* 31*/ { UNICODE_MODE, -1, { 0, 0, "" }, "ABCDE12345678", -1, 0, "6A 21 22 23 24 25 69 0C 22 38 4E", "LatchB (0x6A) A B C D 4xShiftC 12 34 56 78" },
|
||||
/* 32*/ { UNICODE_MODE, -1, { 0, 0, "" }, "\000ABCD1234567890", 15, 0, "65 40 21 22 23 24 6A 0C 22 38 4E 5A", "LatchA (0x65) NULL A B C D LatchC (0x6A) 12 34 56 78 90" },
|
||||
/* 33*/ { DATA_MODE, -1, { 0, 0, "" }, "\141\142\143\144\145\200\201\202\203\204\377", -1, 0, "6A 41 42 43 44 45 70 31 5A 35 21 5A 5F 02 31", "LatchB (0x6A) a b c d e BinaryLatch (0x70) 0x80 0x81 0x82 0x83 0x84 0xFF" },
|
||||
/* 34*/ { DATA_MODE, -1, { 0, 0, "" }, "\200\061\062\240\063\064\201\202\065\066", -1, 0, "6E 40 0C 6F 00 22 70 03 10 42 6E 15 16", "UpperShiftA (0x6E) NUL 12 UpperShiftB (0x6F) SP 34 BinaryLatch (0x70) 0x81 0x82 TermB (0x6E) 5 6" },
|
||||
/* 35*/ { DATA_MODE, -1, { 0, 0, "" }, "\200\201\202\203\061\062\063\064", -1, 0, "70 13 56 0A 59 2C 67 0C 22", "BinaryLatch (0x70) 0x80 0x81 0x82 0x83 Intr2xShiftC (0x67) 12 3" },
|
||||
/* 36*/ { DATA_MODE, -1, { 0, 0, "" }, "\001\200\201\202\203\204\200\201\202\203\204", -1, 0, "65 41 70 31 5A 35 21 5A 5F 31 5A 35 21 5A 5F", "LatchA (0x65) SOH BinaryLatch (0x70) 0x80 0x81 0x82 0x83 0x80 0x81 0x82 0x83" },
|
||||
/* 37*/ { UNICODE_MODE, -1, { 0, 0, "" }, "\001abc\011\015\012\036", -1, 0, "65 41 65 41 42 43 61 60 64", "LatchA (0x65) SOH 6xShiftB (0x65) a b c HT CR/LF RS" },
|
||||
/* 38*/ { UNICODE_MODE, -1, { 35, 35, "" }, "ABCDE", -1, 0, "6A 21 22 23 24 25 3A 3A 6C", "LatchB (0x6A) A B C D E Z Z FNC2" },
|
||||
/* 39*/ { UNICODE_MODE, -1, { 9, 10, "" }, "1234567890", -1, 0, "6B 0C 22 38 4E 5A 65 19 21 6C", "FNC1 (0x6B) 12 34 56 78 90 LatchA (0x65) 9 A FNC2" },
|
||||
/* 40*/ { UNICODE_MODE, -1, { 2, 3, "" }, "\001\002\003\004", -1, 0, "65 41 42 43 44 12 13 6C", "LatchA (0x65) <SOH> <STX> <ETX> <EOT> 2 3 FNC2" },
|
||||
/* 41*/ { DATA_MODE, -1, { 1, 34, "" }, "\200\201\202\203", -1, 0, "70 13 56 0A 59 2C 6D 11 39 6C", "BinaryLatch (0x70) (...) TermA (0x6D) 1 Y FNC2" },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
|
@ -201,18 +218,21 @@ static void test_input(int index, int generate, int debug) {
|
|||
debug |= ZINT_DEBUG_TEST; // Needed to get codeword dump in errtxt
|
||||
|
||||
length = testUtilSetSymbol(symbol, BARCODE_DOTCODE, data[i].input_mode, data[i].eci, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
|
||||
if (data[i].structapp.count) {
|
||||
symbol->structapp = data[i].structapp;
|
||||
}
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) 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 (generate) {
|
||||
printf(" /*%3d*/ { %s, %d, \"%s\", %d, %s, \"%s\", \"%s\" },\n",
|
||||
i, testUtilInputModeName(data[i].input_mode), data[i].eci, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
||||
printf(" /*%3d*/ { %s, %d, { %d, %d, \"%s\" }, \"%s\", %d, %s, \"%s\", \"%s\" },\n",
|
||||
i, testUtilInputModeName(data[i].input_mode), data[i].eci,
|
||||
data[i].structapp.index, data[i].structapp.count, data[i].structapp.id,
|
||||
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
||||
data[i].length, testUtilErrorName(data[i].ret), symbol->errtxt, data[i].comment);
|
||||
} else {
|
||||
if (ret < ZINT_ERROR) {
|
||||
assert_zero(strcmp((char *) symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
assert_zero(strcmp((char *) symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||
}
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
|
@ -227,6 +247,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
int input_mode;
|
||||
int option_2;
|
||||
int option_3;
|
||||
struct zint_structapp structapp;
|
||||
char *data;
|
||||
int length;
|
||||
int ret;
|
||||
|
@ -239,7 +260,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
};
|
||||
// ISS DotCode, Rev 4.0, DRAFT 0.15, TSC Pre-PR #5, MAY 28, 2019
|
||||
struct item data[] = {
|
||||
/* 0*/ { GS1_MODE, 64, -1, "[01]00012345678905[17]201231[10]ABC123456", -1, 0, 9, 64, 1, "ISS DotCode Rev 4.0 Figure 1 (left), same",
|
||||
/* 0*/ { GS1_MODE, 64, -1, { 0, 0, "" }, "[01]00012345678905[17]201231[10]ABC123456", -1, 0, 9, 64, 1, "ISS DotCode Rev 4.0 Figure 1 (left), same",
|
||||
"1010000000101000101010000010000010001010100010101000101000001010"
|
||||
"0100010001010001010001000001010100010100010001000100010101000001"
|
||||
"1010001010000000101010100010001010000010101000000010100010100000"
|
||||
|
@ -250,7 +271,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"0001010100010001010100010001010000010001010000000101010001010101"
|
||||
"1000100010001000100010100010001010001000101000101000100010000010"
|
||||
},
|
||||
/* 1*/ { GS1_MODE, -1, -1, "[01]00012345678905[17]201231[10]ABC123456", -1, 0, 20, 29, 1, "ISS DotCode Rev 4.0 Figure 1 (right) (and Figure 10), same",
|
||||
/* 1*/ { GS1_MODE, -1, -1, { 0, 0, "" }, "[01]00012345678905[17]201231[10]ABC123456", -1, 0, 20, 29, 1, "ISS DotCode Rev 4.0 Figure 1 (right) (and Figure 10), same",
|
||||
"10101000101010100010101000101"
|
||||
"00010100010100010100000001010"
|
||||
"00001010100010000000101010000"
|
||||
|
@ -272,7 +293,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"10000010101000100000001000001"
|
||||
"01000100010101010000000101010"
|
||||
},
|
||||
/* 2*/ { GS1_MODE, -1, 1 << 8, "[17]070620[10]ABC123456", -1, 0, 16, 23, 1, "ISS DotCode Rev 4.0 Figure 5 (and Figure 6 top-left) when Mask = 0, same",
|
||||
/* 2*/ { GS1_MODE, -1, 1 << 8, { 0, 0, "" }, "[17]070620[10]ABC123456", -1, 0, 16, 23, 1, "ISS DotCode Rev 4.0 Figure 5 (and Figure 6 top-left) when Mask = 0, same",
|
||||
"10101000100010000000001"
|
||||
"01000101010001010000000"
|
||||
"00100010001000101000100"
|
||||
|
@ -290,7 +311,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"10101000001000101010001"
|
||||
"01000001010101010000010"
|
||||
},
|
||||
/* 3*/ { GS1_MODE, -1, 2 << 8, "[17]070620[10]ABC123456", -1, 0, 16, 23, 1, "ISS DotCode Rev 4.0 Figure 6 top-right Mask = 1, same",
|
||||
/* 3*/ { GS1_MODE, -1, 2 << 8, { 0, 0, "" }, "[17]070620[10]ABC123456", -1, 0, 16, 23, 1, "ISS DotCode Rev 4.0 Figure 6 top-right Mask = 1, same",
|
||||
"10000000001010001000101"
|
||||
"01010101000100000101000"
|
||||
"00100010000000100000001"
|
||||
|
@ -308,7 +329,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"10000010101010100010101"
|
||||
"01000101000101010101010"
|
||||
},
|
||||
/* 4*/ { GS1_MODE, -1, 3 << 8, "[17]070620[10]ABC123456", -1, 0, 16, 23, 1, "ISS DotCode Rev 4.0 Figure 6 bottom-left Mask = 2, same",
|
||||
/* 4*/ { GS1_MODE, -1, 3 << 8, { 0, 0, "" }, "[17]070620[10]ABC123456", -1, 0, 16, 23, 1, "ISS DotCode Rev 4.0 Figure 6 bottom-left Mask = 2, same",
|
||||
"10100000101010100010001"
|
||||
"01000101000100000000010"
|
||||
"10101010001010000010000"
|
||||
|
@ -326,7 +347,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"10101010000000001010001"
|
||||
"01010101000001000101010"
|
||||
},
|
||||
/* 5*/ { GS1_MODE, -1, 4 << 8, "[17]070620[10]ABC123456", -1, 0, 16, 23, 1, "ISS DotCode Rev 4.0 Figure 6 bottom-right Mask = 3, same",
|
||||
/* 5*/ { GS1_MODE, -1, 4 << 8, { 0, 0, "" }, "[17]070620[10]ABC123456", -1, 0, 16, 23, 1, "ISS DotCode Rev 4.0 Figure 6 bottom-right Mask = 3, same",
|
||||
"10000000100000001010101"
|
||||
"01010001010100010001000"
|
||||
"10001000001010101010100"
|
||||
|
@ -344,7 +365,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"10001000001010001000001"
|
||||
"01010100000101000100010"
|
||||
},
|
||||
/* 6*/ { GS1_MODE, -1, -1, "[17]070620[10]ABC123456", -1, 0, 16, 23, 1, "ISS DotCode Rev 4.0 Figure 6 top-right, auto Mask = 1, same",
|
||||
/* 6*/ { GS1_MODE, -1, -1, { 0, 0, "" }, "[17]070620[10]ABC123456", -1, 0, 16, 23, 1, "ISS DotCode Rev 4.0 Figure 6 top-right, auto Mask = 1, same",
|
||||
"10000000001010001000101"
|
||||
"01010101000100000101000"
|
||||
"00100010000000100000001"
|
||||
|
@ -362,7 +383,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"10000010101010100010101"
|
||||
"01000101000101010101010"
|
||||
},
|
||||
/* 7*/ { UNICODE_MODE, -1, 1 << 8, "2741", -1, 0, 10, 13, 0, "ISS DotCode Rev 4.0 Figure 7A top-left Mask = 0, same; BWIPP automatically primes mask",
|
||||
/* 7*/ { UNICODE_MODE, -1, 1 << 8, { 0, 0, "" }, "2741", -1, 0, 10, 13, 0, "ISS DotCode Rev 4.0 Figure 7A top-left Mask = 0, same; BWIPP automatically primes mask",
|
||||
"1010101010100"
|
||||
"0000010001010"
|
||||
"0000101000101"
|
||||
|
@ -374,7 +395,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"1000100010001"
|
||||
"0000000000000"
|
||||
},
|
||||
/* 8*/ { UNICODE_MODE, -1, 2 << 8, "2741", -1, 0, 10, 13, 0, "ISS DotCode Rev 4.0 Figure 7A top-right Mask = 1, same; BWIPP automatically primes mask",
|
||||
/* 8*/ { UNICODE_MODE, -1, 2 << 8, { 0, 0, "" }, "2741", -1, 0, 10, 13, 0, "ISS DotCode Rev 4.0 Figure 7A top-right Mask = 1, same; BWIPP automatically primes mask",
|
||||
"1010001000101"
|
||||
"0000000100010"
|
||||
"0000100000001"
|
||||
|
@ -386,7 +407,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"0000000010001"
|
||||
"0001000001000"
|
||||
},
|
||||
/* 9*/ { UNICODE_MODE, -1, 3 << 8, "2741", -1, 0, 10, 13, 0, "ISS DotCode Rev 4.0 Figure 7A bottom-left Mask = 2, same; BWIPP automatically primes mask",
|
||||
/* 9*/ { UNICODE_MODE, -1, 3 << 8, { 0, 0, "" }, "2741", -1, 0, 10, 13, 0, "ISS DotCode Rev 4.0 Figure 7A bottom-left Mask = 2, same; BWIPP automatically primes mask",
|
||||
"1010001010100"
|
||||
"0001000000000"
|
||||
"1000100010101"
|
||||
|
@ -398,7 +419,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"1000100010101"
|
||||
"0001000100000"
|
||||
},
|
||||
/* 10*/ { UNICODE_MODE, -1, 4 << 8, "2741", -1, 0, 10, 13, 0, "ISS DotCode Rev 4.0 Figure 7A bottom-right Mask = 3, same; BWIPP automatically primes mask",
|
||||
/* 10*/ { UNICODE_MODE, -1, 4 << 8, { 0, 0, "" }, "2741", -1, 0, 10, 13, 0, "ISS DotCode Rev 4.0 Figure 7A bottom-right Mask = 3, same; BWIPP automatically primes mask",
|
||||
"1010001000100"
|
||||
"0001000001010"
|
||||
"1000001000000"
|
||||
|
@ -410,7 +431,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"1000001010001"
|
||||
"0101010101010"
|
||||
},
|
||||
/* 11*/ { UNICODE_MODE, -1, 5 << 8, "2741", -1, 0, 10, 13, 1, "ISS DotCode Rev 4.0 Figure 7B top-left Mask = 0' (4), same",
|
||||
/* 11*/ { UNICODE_MODE, -1, 5 << 8, { 0, 0, "" }, "2741", -1, 0, 10, 13, 1, "ISS DotCode Rev 4.0 Figure 7B top-left Mask = 0' (4), same",
|
||||
"1010101010101"
|
||||
"0000010001010"
|
||||
"0000101000101"
|
||||
|
@ -422,7 +443,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"1000100010001"
|
||||
"0100000000010"
|
||||
},
|
||||
/* 12*/ { UNICODE_MODE, -1, 6 << 8, "2741", -1, 0, 10, 13, 1, "ISS DotCode Rev 4.0 Figure 7B top-right Mask = 1' (5), same",
|
||||
/* 12*/ { UNICODE_MODE, -1, 6 << 8, { 0, 0, "" }, "2741", -1, 0, 10, 13, 1, "ISS DotCode Rev 4.0 Figure 7B top-right Mask = 1' (5), same",
|
||||
"1010001000101"
|
||||
"0000000100010"
|
||||
"0000100000001"
|
||||
|
@ -434,7 +455,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"1000000010001"
|
||||
"0101000001010"
|
||||
},
|
||||
/* 13*/ { UNICODE_MODE, -1, 7 << 8, "2741", -1, 0, 10, 13, 1, "ISS DotCode Rev 4.0 Figure 7B bottom-left Mask = 2' (6), same",
|
||||
/* 13*/ { UNICODE_MODE, -1, 7 << 8, { 0, 0, "" }, "2741", -1, 0, 10, 13, 1, "ISS DotCode Rev 4.0 Figure 7B bottom-left Mask = 2' (6), same",
|
||||
"1010001010101"
|
||||
"0001000000000"
|
||||
"1000100010101"
|
||||
|
@ -446,7 +467,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"1000100010101"
|
||||
"0101000100010"
|
||||
},
|
||||
/* 14*/ { UNICODE_MODE, -1, 8 << 8, "2741", -1, 0, 10, 13, 1, "ISS DotCode Rev 4.0 Figure 7B bottom-right Mask = 3' (7), same",
|
||||
/* 14*/ { UNICODE_MODE, -1, 8 << 8, { 0, 0, "" }, "2741", -1, 0, 10, 13, 1, "ISS DotCode Rev 4.0 Figure 7B bottom-right Mask = 3' (7), same",
|
||||
"1010001000101"
|
||||
"0001000001010"
|
||||
"1000001000000"
|
||||
|
@ -458,7 +479,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"1000001010001"
|
||||
"0101010101010"
|
||||
},
|
||||
/* 15*/ { UNICODE_MODE, -1, -1, "2741", -1, 0, 10, 13, 1, "ISS DotCode Rev 4.0 Figure 7B bottom-left auto Mask = 2' (6), same",
|
||||
/* 15*/ { UNICODE_MODE, -1, -1, { 0, 0, "" }, "2741", -1, 0, 10, 13, 1, "ISS DotCode Rev 4.0 Figure 7B bottom-left auto Mask = 2' (6), same",
|
||||
"1010001010101"
|
||||
"0001000000000"
|
||||
"1000100010101"
|
||||
|
@ -470,7 +491,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"1000100010101"
|
||||
"0101000100010"
|
||||
},
|
||||
/* 16*/ { GS1_MODE, 40, -1, "[01]00012345678905", -1, 0, 7, 40, 1, "ISS DotCode Rev 4.0 Figure 8 top-left 7x40, Mask = 1, same",
|
||||
/* 16*/ { GS1_MODE, 40, -1, { 0, 0, "" }, "[01]00012345678905", -1, 0, 7, 40, 1, "ISS DotCode Rev 4.0 Figure 8 top-left 7x40, Mask = 1, same",
|
||||
"1010101010001000100010100010101000001000"
|
||||
"0000010101000100010100010000010001000001"
|
||||
"1010001000001000001000101010001000101000"
|
||||
|
@ -479,7 +500,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"0001010001010001000100000001010100010001"
|
||||
"1000100010001000100010100010001010001000"
|
||||
},
|
||||
/* 17*/ { GS1_MODE, 18, -1, "[01]00012345678905", -1, 0, 17, 18, 1, "ISS DotCode Rev 4.0 Figure 8 top-right 17x18 **NOT SAME** no matter what mask; but same as BWIPP and verified manually against tec-it",
|
||||
/* 17*/ { GS1_MODE, 18, -1, { 0, 0, "" }, "[01]00012345678905", -1, 0, 17, 18, 1, "ISS DotCode Rev 4.0 Figure 8 top-right 17x18 **NOT SAME** no matter what mask; but same as BWIPP and verified manually against tec-it",
|
||||
"101000001000101010"
|
||||
"010100000101010001"
|
||||
"000000101000001010"
|
||||
|
@ -498,7 +519,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"010001010001000101"
|
||||
"100010001000100010"
|
||||
},
|
||||
/* 18*/ { GS1_MODE, 35, -1, "[01]00012345678905", -1, 0, 8, 35, 1, "ISS DotCode Rev 4.0 Figure 8 bottom-left 8x35, Mask = 3, same",
|
||||
/* 18*/ { GS1_MODE, 35, -1, { 0, 0, "" }, "[01]00012345678905", -1, 0, 8, 35, 1, "ISS DotCode Rev 4.0 Figure 8 bottom-left 8x35, Mask = 3, same",
|
||||
"10100010000000000010100000100010101"
|
||||
"00010101010001000000010100010100000"
|
||||
"10001000101010101010001010000010101"
|
||||
|
@ -508,7 +529,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"10000010101010101010000010000010001"
|
||||
"01000001000101000100010100010001000"
|
||||
},
|
||||
/* 19*/ { GS1_MODE, 17, -1, "[01]00012345678905", -1, 0, 18, 17, 1, "ISS DotCode Rev 4.0 Figure 8 bottom-right 18x17 **NOT SAME** no matter what mask; same as BWIPP; verified manually against tec-it",
|
||||
/* 19*/ { GS1_MODE, 17, -1, { 0, 0, "" }, "[01]00012345678905", -1, 0, 18, 17, 1, "ISS DotCode Rev 4.0 Figure 8 bottom-right 18x17 **NOT SAME** no matter what mask; same as BWIPP; verified manually against tec-it",
|
||||
"10101000001000001"
|
||||
"01000001010100010"
|
||||
"00000000100010001"
|
||||
|
@ -528,7 +549,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"10101010101010101"
|
||||
"01010101000101010"
|
||||
},
|
||||
/* 20*/ { UNICODE_MODE, 35, -1, "Dots can be Square!", -1, 0, 18, 35, 1, "ISS DotCode Rev 4.0 Figure 11 **NOT SAME**; same as BWIPP; verified manually against tec-it",
|
||||
/* 20*/ { UNICODE_MODE, 35, -1, { 0, 0, "" }, "Dots can be Square!", -1, 0, 18, 35, 1, "ISS DotCode Rev 4.0 Figure 11 **NOT SAME**; same as BWIPP; verified manually against tec-it",
|
||||
"10000010101000000000000000101010101"
|
||||
"01010101000101000100010100000001000"
|
||||
"00001000000010101000101010101010000"
|
||||
|
@ -548,7 +569,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"10101000101000001000100010101000101"
|
||||
"01000001000001000101010001000000010"
|
||||
},
|
||||
/* 21*/ { GS1_MODE, -1, 1 << 8, "[99]8766", -1, 0, 10, 13, 0, "ISS DotCode Rev 4.0 Table G.1 Mask 0, same; BWIPP automatically primes mask",
|
||||
/* 21*/ { GS1_MODE, -1, 1 << 8, { 0, 0, "" }, "[99]8766", -1, 0, 10, 13, 0, "ISS DotCode Rev 4.0 Table G.1 Mask 0, same; BWIPP automatically primes mask",
|
||||
"0000001010000"
|
||||
"0001010000010"
|
||||
"0000000010001"
|
||||
|
@ -560,7 +581,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"0010000000101"
|
||||
"0101000101010"
|
||||
},
|
||||
/* 22*/ { GS1_MODE, -1, 2 << 8, "[99]8766", -1, 0, 10, 13, 0, "ISS DotCode Rev 4.0 Table G.1 Mask 1, same; BWIPP automatically primes mask",
|
||||
/* 22*/ { GS1_MODE, -1, 2 << 8, { 0, 0, "" }, "[99]8766", -1, 0, 10, 13, 0, "ISS DotCode Rev 4.0 Table G.1 Mask 1, same; BWIPP automatically primes mask",
|
||||
"0000100000001"
|
||||
"0001010000000"
|
||||
"0000000000001"
|
||||
|
@ -572,7 +593,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"0010101000101"
|
||||
"0100010101000"
|
||||
},
|
||||
/* 23*/ { GS1_MODE, -1, 3 << 8, "[99]8766", -1, 0, 10, 13, 0, "ISS DotCode Rev 4.0 Table G.1 Mask 2, same; BWIPP automatically primes mask",
|
||||
/* 23*/ { GS1_MODE, -1, 3 << 8, { 0, 0, "" }, "[99]8766", -1, 0, 10, 13, 0, "ISS DotCode Rev 4.0 Table G.1 Mask 2, same; BWIPP automatically primes mask",
|
||||
"0000100010100"
|
||||
"0000000000000"
|
||||
"1000101010101"
|
||||
|
@ -584,7 +605,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"0000000010001"
|
||||
"0100000001010"
|
||||
},
|
||||
/* 24*/ { GS1_MODE, -1, 4 << 8, "[99]8766", -1, 0, 10, 13, 0, "ISS DotCode Rev 4.0 Table G.1 Mask 3, same; BWIPP automatically primes mask",
|
||||
/* 24*/ { GS1_MODE, -1, 4 << 8, { 0, 0, "" }, "[99]8766", -1, 0, 10, 13, 0, "ISS DotCode Rev 4.0 Table G.1 Mask 3, same; BWIPP automatically primes mask",
|
||||
"0000000000000"
|
||||
"0001010001000"
|
||||
"1000001010000"
|
||||
|
@ -596,7 +617,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"1000000010000"
|
||||
"0100000000010"
|
||||
},
|
||||
/* 25*/ { GS1_MODE, -1, 5 << 8, "[99]8766", -1, 0, 10, 13, 1, "ISS DotCode Rev 4.0 Table G.1 Mask 0' (4), same",
|
||||
/* 25*/ { GS1_MODE, -1, 5 << 8, { 0, 0, "" }, "[99]8766", -1, 0, 10, 13, 1, "ISS DotCode Rev 4.0 Table G.1 Mask 0' (4), same",
|
||||
"1000001010001"
|
||||
"0001010000010"
|
||||
"0000000010001"
|
||||
|
@ -608,7 +629,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"1010000000101"
|
||||
"0101000101010"
|
||||
},
|
||||
/* 26*/ { GS1_MODE, -1, 6 << 8, "[99]8766", -1, 0, 10, 13, 1, "ISS DotCode Rev 4.0 Table G.1 Mask 1' (5), same",
|
||||
/* 26*/ { GS1_MODE, -1, 6 << 8, { 0, 0, "" }, "[99]8766", -1, 0, 10, 13, 1, "ISS DotCode Rev 4.0 Table G.1 Mask 1' (5), same",
|
||||
"1000100000001"
|
||||
"0001010000000"
|
||||
"0000000000001"
|
||||
|
@ -620,7 +641,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"1010101000101"
|
||||
"0100010101010"
|
||||
},
|
||||
/* 27*/ { GS1_MODE, -1, 7 << 8, "[99]8766", -1, 0, 10, 13, 1, "ISS DotCode Rev 4.0 Table G.1 Mask 2' (6), same",
|
||||
/* 27*/ { GS1_MODE, -1, 7 << 8, { 0, 0, "" }, "[99]8766", -1, 0, 10, 13, 1, "ISS DotCode Rev 4.0 Table G.1 Mask 2' (6), same",
|
||||
"1000100010101"
|
||||
"0000000000000"
|
||||
"1000101010101"
|
||||
|
@ -632,7 +653,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"1000000010001"
|
||||
"0100000001010"
|
||||
},
|
||||
/* 28*/ { GS1_MODE, -1, 8 << 8, "[99]8766", -1, 0, 10, 13, 1, "ISS DotCode Rev 4.0 Table G.1 Mask 3' (7), same",
|
||||
/* 28*/ { GS1_MODE, -1, 8 << 8, { 0, 0, "" }, "[99]8766", -1, 0, 10, 13, 1, "ISS DotCode Rev 4.0 Table G.1 Mask 3' (7), same",
|
||||
"1000000000001"
|
||||
"0001010001000"
|
||||
"1000001010000"
|
||||
|
@ -644,7 +665,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"1000000010001"
|
||||
"0100000000010"
|
||||
},
|
||||
/* 29*/ { GS1_MODE, -1, -1, "[99]8766", -1, 0, 10, 13, 1, "ISS DotCode Rev 4.0 Table G.1 auto Mask 0' (4); all mask scores match Table G.1",
|
||||
/* 29*/ { GS1_MODE, -1, -1, { 0, 0, "" }, "[99]8766", -1, 0, 10, 13, 1, "ISS DotCode Rev 4.0 Table G.1 auto Mask 0' (4); all mask scores match Table G.1",
|
||||
"1000001010001"
|
||||
"0001010000010"
|
||||
"0000000010001"
|
||||
|
@ -656,7 +677,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"1010000000101"
|
||||
"0101000101010"
|
||||
},
|
||||
/* 30*/ { UNICODE_MODE, 6, -1, "A", -1, 0, 19, 6, 1, "ISS DotCode Rev 4.0 5.2.1.4 2) Table 4, 1 padding dot available; verified manually against tec-it",
|
||||
/* 30*/ { UNICODE_MODE, 6, -1, { 0, 0, "" }, "A", -1, 0, 19, 6, 1, "ISS DotCode Rev 4.0 5.2.1.4 2) Table 4, 1 padding dot available; verified manually against tec-it",
|
||||
"101000"
|
||||
"000101"
|
||||
"101010"
|
||||
|
@ -677,7 +698,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"010000"
|
||||
"101000"
|
||||
},
|
||||
/* 31*/ { UNICODE_MODE, 94, -1, "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRS", -1, 0, 37, 94, 1, "Interleaved R-S; verified manually against tec-it",
|
||||
/* 31*/ { UNICODE_MODE, 94, -1, { 0, 0, "" }, "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRS", -1, 0, 37, 94, 1, "Interleaved R-S; verified manually against tec-it",
|
||||
"1000001010000000100010000010101010101000001000100000001010101000001000001000101010001000101010"
|
||||
"0101010000000101000001010001010001010100010001000001000000010101010000000101010100010001010100"
|
||||
"0010101000100010000010101010000000101010000010101000001000100010100000100010100010001000101000"
|
||||
|
@ -716,7 +737,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"0001000101010100000001010101000001010000010001010001000100010000010001000101010001010001000001"
|
||||
"0010001000001010101000000010101000101000001000001010100000101010001000000010100000001010101000"
|
||||
},
|
||||
/* 32*/ { GS1_MODE, 50, -1, "[17]070620[10]ABC123456", -1, 0, 7, 50, 1, "GS1 Gen Spec Figure 5.1-8.",
|
||||
/* 32*/ { GS1_MODE, 50, -1, { 0, 0, "" }, "[17]070620[10]ABC123456", -1, 0, 7, 50, 1, "GS1 Gen Spec Figure 5.1-8.",
|
||||
"10000010101000100010101010001000000010100000100000"
|
||||
"01000101000101010100000100010000010001000001010101"
|
||||
"00001010001000101000101000100010001010100000000010"
|
||||
|
@ -725,14 +746,14 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"00010001010000000100010101000100010001010001000101"
|
||||
"10001000001010101000001000100010100010100000101010"
|
||||
},
|
||||
/* 33*/ { UNICODE_MODE, 200, -1, "123456789012345678901234567890123456789012345678901234567890", -1, 0, 5, 200, 1, "Max cols",
|
||||
/* 33*/ { UNICODE_MODE, 200, -1, { 0, 0, "" }, "123456789012345678901234567890123456789012345678901234567890", -1, 0, 5, 200, 1, "Max cols",
|
||||
"10101000100010101010000010101000000010001000100000101010100010100000101000100010000000101000101010001010100000100000101010100000001000101000001010100010001010000010001010001010100000100010101000000010"
|
||||
"00010101010000000101000100010001000101000101000100010001000001010001000001010100000001000101010000000101010100010101010000010001000101010001000001000001010000010100010001010101000001000001010100000001"
|
||||
"10100010000000100010101000101010100000001010001000100000101000101000001000101010001000000010101010100010101000000010100010001000001010100000101000100000101010100010000000001000001010101000101010100000"
|
||||
"00010001010001010000000101000100010001010000010000010100010100000100010101010001000101000000010100010001010100010000010100000101000100010100000101010000000101000001010100010100010001000101000001010001"
|
||||
"10100010001010101000000010001000001010001010001000001010100010000000101010001010000010101010000000101000100010100010100000100010100010001010100000001010101000001010000000001000101000101010000010101010"
|
||||
},
|
||||
/* 34*/ { UNICODE_MODE, 19, -1, "4", -1, 0, 6, 19, 1, "Mask 1 selected",
|
||||
/* 34*/ { UNICODE_MODE, 19, -1, { 0, 0, "" }, "4", -1, 0, 6, 19, 1, "Mask 1 selected",
|
||||
"1010100000101000101"
|
||||
"0100000000010001010"
|
||||
"0010101010000000000"
|
||||
|
@ -740,7 +761,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"1000100010001010001"
|
||||
"0001010101010101010"
|
||||
},
|
||||
/* 35*/ { UNICODE_MODE, 19, 3 << 8, "4", -1, 0, 6, 19, 0, "Mask 2 specified, unlit right edge mask; BWIPP automatically primes mask",
|
||||
/* 35*/ { UNICODE_MODE, 19, 3 << 8, { 0, 0, "" }, "4", -1, 0, 6, 19, 0, "Mask 2 specified, unlit right edge mask; BWIPP automatically primes mask",
|
||||
"1010101010000000100"
|
||||
"0000000101000100010"
|
||||
"1010100000001010100"
|
||||
|
@ -748,7 +769,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"1000001010100010100"
|
||||
"0101000100010001010"
|
||||
},
|
||||
/* 36*/ { UNICODE_MODE, 19, 7 << 8, "4", -1, 0, 6, 19, 1, "Mask 2' specified",
|
||||
/* 36*/ { UNICODE_MODE, 19, 7 << 8, { 0, 0, "" }, "4", -1, 0, 6, 19, 1, "Mask 2' specified",
|
||||
"1010101010000000101"
|
||||
"0000000101000100010"
|
||||
"1010100000001010100"
|
||||
|
@ -756,7 +777,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"1000001010100010101"
|
||||
"0101000100010001010"
|
||||
},
|
||||
/* 37*/ { GS1_MODE, -1, -1, "[10]12[20]12", -1, 0, 12, 17, 1, "Code Set C with FNC1",
|
||||
/* 37*/ { GS1_MODE, -1, -1, { 0, 0, "" }, "[10]12[20]12", -1, 0, 12, 17, 1, "Code Set C with FNC1",
|
||||
"10100000001000001"
|
||||
"00010100010101010"
|
||||
"10001000100000001"
|
||||
|
@ -770,7 +791,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"10000010100000101"
|
||||
"01000100010101010"
|
||||
},
|
||||
/* 38*/ { UNICODE_MODE, -1, -1, "1234\011\034\035\036", -1, 0, 14, 21, 1, "Code Set B HT FS GS RS",
|
||||
/* 38*/ { UNICODE_MODE, -1, -1, { 0, 0, "" }, "1234\011\034\035\036", -1, 0, 14, 21, 1, "Code Set B HT FS GS RS",
|
||||
"100010001000001010101"
|
||||
"010001000001000001000"
|
||||
"100010100010101010001"
|
||||
|
@ -786,7 +807,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"001010101000101010001"
|
||||
"010101010001000101000"
|
||||
},
|
||||
/* 39*/ { UNICODE_MODE, 17, -1, "abcd\015\012", -1, 0, 14, 17, 1, "Code Set B CRLF",
|
||||
/* 39*/ { UNICODE_MODE, 17, -1, { 0, 0, "" }, "abcd\015\012", -1, 0, 14, 17, 1, "Code Set B CRLF",
|
||||
"00001000001000101"
|
||||
"01000101010001000"
|
||||
"10100000100010101"
|
||||
|
@ -802,7 +823,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"10100000001010000"
|
||||
"01010001000101000"
|
||||
},
|
||||
/* 40*/ { DATA_MODE, -1, -1, "\101\102\103\104\105\106\107\200\101\102\240\101", -1, 0, 18, 27, 1, "Code Set B Upper Shift A Upper Shift B",
|
||||
/* 40*/ { DATA_MODE, -1, -1, { 0, 0, "" }, "\101\102\103\104\105\106\107\200\101\102\240\101", -1, 0, 18, 27, 1, "Code Set B Upper Shift A Upper Shift B",
|
||||
"101010100000101000101000001"
|
||||
"010100010101000100010101000"
|
||||
"000010001010100000101010101"
|
||||
|
@ -822,7 +843,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"100010101000000010001000001"
|
||||
"010001000100000101000001010"
|
||||
},
|
||||
/* 41*/ { UNICODE_MODE, -1, -1, "ABCDEF\001G1234H", -1, 0, 16, 25, 1, "Code Set A 4x Shift C",
|
||||
/* 41*/ { UNICODE_MODE, -1, -1, { 0, 0, "" }, "ABCDEF\001G1234H", -1, 0, 16, 25, 1, "Code Set A 4x Shift C",
|
||||
"0010101010100000100000101"
|
||||
"0000000100010101000001000"
|
||||
"1000100000101000100000101"
|
||||
|
@ -840,7 +861,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"1010101010001000101000000"
|
||||
"0000010100010101000101010"
|
||||
},
|
||||
/* 42*/ { UNICODE_MODE, -1, -1, "ABCDEF\001ab\011\034\035\036\001A", -1, 0, 19, 28, 1, "Code Set A 6x Shift B HT FS GS RS",
|
||||
/* 42*/ { UNICODE_MODE, -1, -1, { 0, 0, "" }, "ABCDEF\001ab\011\034\035\036\001A", -1, 0, 19, 28, 1, "Code Set A 6x Shift B HT FS GS RS",
|
||||
"1000001010100010101010101010"
|
||||
"0101000000010100010101010001"
|
||||
"0010001010100000101000001010"
|
||||
|
@ -861,7 +882,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"0001010000010100000100010101"
|
||||
"1010100010000000101010101010"
|
||||
},
|
||||
/* 43*/ { UNICODE_MODE, -1, -1, "ABCDEF\001abcdefgA", -1, 0, 19, 28, 1, "Code Set A Latch B",
|
||||
/* 43*/ { UNICODE_MODE, -1, -1, { 0, 0, "" }, "ABCDEF\001abcdefgA", -1, 0, 19, 28, 1, "Code Set A Latch B",
|
||||
"1010001010100010101010101010"
|
||||
"0100010101010000000100010001"
|
||||
"1010000010100000100010101000"
|
||||
|
@ -882,7 +903,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"0001010000010100000100010101"
|
||||
"1010100010000000101010101010"
|
||||
},
|
||||
/* 44*/ { DATA_MODE, -1, -1, "\200\200\200\200\061\062\063\064\065\066\067\070\071\060\061\062\063\064\065\066\200", -1, 0, 20, 29, 1, "Binary Latch C",
|
||||
/* 44*/ { DATA_MODE, -1, -1, { 0, 0, "" }, "\200\200\200\200\061\062\063\064\065\066\067\070\071\060\061\062\063\064\065\066\200", -1, 0, 20, 29, 1, "Binary Latch C",
|
||||
"10101010000010100010101010001"
|
||||
"01010001000101010001000000010"
|
||||
"00001010101000101010001000001"
|
||||
|
@ -904,6 +925,36 @@ static void test_encode(int index, int generate, int debug) {
|
|||
"10000010100010000010001000101"
|
||||
"01000100000100010001010101010"
|
||||
},
|
||||
/* 45*/ { UNICODE_MODE, -1, -1, { 11, 24, "" }, "ABCDEFG", -1, 0, 16, 23, 1, "Structured Append",
|
||||
"10101000001000101000001"
|
||||
"01010101000001010001010"
|
||||
"10101010100010000000001"
|
||||
"01000001010000010100010"
|
||||
"10000000101010100010101"
|
||||
"01010100010101010101000"
|
||||
"10000010101010101000101"
|
||||
"00010100010100000000010"
|
||||
"00101000100000001010001"
|
||||
"00010100000001000100000"
|
||||
"00100010000000001010101"
|
||||
"01010101010001010101000"
|
||||
"10000000001010000000001"
|
||||
"00000000010100010001010"
|
||||
"10001010101000100010001"
|
||||
"01000001000100010101010"
|
||||
},
|
||||
/* 46*/ { UNICODE_MODE, -1, -1, { 0, 0, "" }, "1234", -1, 0, 10, 13, 1, "",
|
||||
"0010100000001"
|
||||
"0000000001010"
|
||||
"1000000010101"
|
||||
"0101010101000"
|
||||
"1000101000000"
|
||||
"0100010100010"
|
||||
"1000000010100"
|
||||
"0101010000010"
|
||||
"1000101000001"
|
||||
"0101010101000"
|
||||
},
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
|
@ -920,18 +971,23 @@ static void test_encode(int index, int generate, int debug) {
|
|||
for (i = 0; i < data_size; i++) {
|
||||
|
||||
if (index != -1 && i != index) continue;
|
||||
if ((debug & ZINT_DEBUG_TEST_PRINT) && !(debug & ZINT_DEBUG_TEST_LESS_NOISY)) printf("i:%d\n", i);
|
||||
|
||||
symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
length = testUtilSetSymbol(symbol, BARCODE_DOTCODE, data[i].input_mode, -1 /*eci*/, -1, data[i].option_2, data[i].option_3, -1 /*output_options*/, data[i].data, data[i].length, debug);
|
||||
if (data[i].structapp.count) {
|
||||
symbol->structapp = data[i].structapp;
|
||||
}
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) 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 (generate) {
|
||||
printf(" /*%3d*/ { %s, %d, %s, \"%s\", %d, %s, %d, %d, %d, \"%s\",\n",
|
||||
printf(" /*%3d*/ { %s, %d, %s, { %d, %d, \"%s\" }, \"%s\", %d, %s, %d, %d, %d, \"%s\",\n",
|
||||
i, testUtilInputModeName(data[i].input_mode), data[i].option_2, testUtilOption3Name(data[i].option_3),
|
||||
data[i].structapp.index, data[i].structapp.count, data[i].structapp.id,
|
||||
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length,
|
||||
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].comment);
|
||||
testUtilModulesPrint(symbol, " ", "\n");
|
||||
|
@ -1025,6 +1081,140 @@ static void test_fuzz(int index, int debug) {
|
|||
testFinish();
|
||||
}
|
||||
|
||||
#define GF 113
|
||||
|
||||
// Dummy to generate pre-calculated coefficients for GF(113) of generator polys of degree 3 to 39
|
||||
static void test_generate(int generate) {
|
||||
|
||||
// roots (antilogs): root[0] = 1; for (i = 1; i < GF - 1; i++) root[i] = (PM * root[i - 1]) % GF;
|
||||
static int root[GF - 1] = {
|
||||
1, 3, 9, 27, 81, 17, 51, 40, 7, 21,
|
||||
63, 76, 2, 6, 18, 54, 49, 34, 102, 80,
|
||||
14, 42, 13, 39, 4, 12, 36, 108, 98, 68,
|
||||
91, 47, 28, 84, 26, 78, 8, 24, 72, 103,
|
||||
83, 23, 69, 94, 56, 55, 52, 43, 16, 48,
|
||||
31, 93, 53, 46, 25, 75, 112, 110, 104, 86,
|
||||
32, 96, 62, 73, 106, 92, 50, 37, 111, 107,
|
||||
95, 59, 64, 79, 11, 33, 99, 71, 100, 74,
|
||||
109, 101, 77, 5, 15, 45, 22, 66, 85, 29,
|
||||
87, 35, 105, 89, 41, 10, 30, 90, 44, 19,
|
||||
57, 58, 61, 70, 97, 65, 82, 20, 60, 67,
|
||||
88, 38
|
||||
};
|
||||
int i, j, nc, cind, ci;
|
||||
|
||||
// Degree nc has nc + 1 terms
|
||||
char coefs[820 - 5] = {0}; // 40*(41 + 1)/2 == 820 less 2 + 3 (degrees 1 and 2)
|
||||
int cinds[39 - 2] = {0};
|
||||
|
||||
if (!generate) {
|
||||
return;
|
||||
}
|
||||
|
||||
printf(" static const char coefs[820 - 5] = { /* 40*(41 + 1)/2 == 820 less 2 + 3 (degrees 1 and 2) */\n");
|
||||
for (nc = 3, cind = 0, ci = 0; nc <= 39; cind += nc + 1, ci++, nc++) {
|
||||
cinds[ci] = cind;
|
||||
|
||||
coefs[cind] = 1;
|
||||
for (i = 1; i <= nc; i++) {
|
||||
for (j = nc; j >= 1; j--) {
|
||||
coefs[cind + j] = (GF + coefs[cind + j] - (root[i] * coefs[cind + j - 1]) % GF) % GF;
|
||||
}
|
||||
}
|
||||
printf(" ");
|
||||
for (i = 0; i <= nc; i++) {
|
||||
if (i == 22) printf("\n ");
|
||||
printf(" %3d,", coefs[cinds[ci] + i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
printf(" };\n");
|
||||
|
||||
printf(" static const short cinds[39 - 2] = { /* Indexes into above coefs[] array */\n ");
|
||||
for (i = 0; i < ARRAY_SIZE(cinds); i++) {
|
||||
if (i == 22) printf("\n ");
|
||||
printf(" %3d,", cinds[i]);
|
||||
}
|
||||
printf("\n };\n");
|
||||
}
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#define TEST_PERF_ITERATIONS 1000
|
||||
|
||||
// Not a real test, just performance indicator
|
||||
static void test_perf(int index, int debug) {
|
||||
|
||||
struct item {
|
||||
int symbology;
|
||||
int input_mode;
|
||||
int option_1;
|
||||
int option_2;
|
||||
char *data;
|
||||
int ret;
|
||||
|
||||
int expected_rows;
|
||||
int expected_width;
|
||||
char *comment;
|
||||
};
|
||||
struct item data[] = {
|
||||
/* 0*/ { BARCODE_DOTCODE, -1, -1, -1,
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz&,:#-.$/+%*=^ABCDEFGHIJKLMNOPQRSTUVWXYZ12345678901234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLM"
|
||||
"NOPQRSTUVWXYZ;<>@[]_`~!||()?{}'123456789012345678901234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJK"
|
||||
"LMNOPQRSTUVWXYZ12345678912345678912345678912345678900001234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFG"
|
||||
"HIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ12345678901234567"
|
||||
"890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcde"
|
||||
"fghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNO",
|
||||
0, 124, 185, "960 chars, text/numeric" },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, 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 (index != -1 && i != index) 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, data[i].input_mode, -1 /*eci*/, data[i].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);
|
||||
|
||||
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 (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, has_index, has_generate, has_debug */
|
||||
|
@ -1033,6 +1223,9 @@ int main(int argc, char *argv[]) {
|
|||
{ "test_input", test_input, 1, 1, 1 },
|
||||
{ "test_encode", test_encode, 1, 1, 1 },
|
||||
{ "test_fuzz", test_fuzz, 1, 0, 1 },
|
||||
{ "test_fuzz", test_fuzz, 1, 0, 1 },
|
||||
{ "test_generate", test_generate, 0, 1, 0 },
|
||||
{ "test_perf", test_perf, 1, 0, 1 },
|
||||
};
|
||||
|
||||
testRun(argc, argv, funcs, ARRAY_SIZE(funcs));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue