Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/zint/backend/tests/test_code128.c @ 2:b50eed0cc0ef upstream
ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4.
The directory name has changed: no version number in the expanded directory now.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:43:07 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:1d09e1dec1d9 | 2:b50eed0cc0ef |
|---|---|
| 1 /* | |
| 2 libzint - the open source barcode library | |
| 3 Copyright (C) 2020-2024 Robin Stuart <rstuart114@gmail.com> | |
| 4 | |
| 5 Redistribution and use in source and binary forms, with or without | |
| 6 modification, are permitted provided that the following conditions | |
| 7 are met: | |
| 8 | |
| 9 1. Redistributions of source code must retain the above copyright | |
| 10 notice, this list of conditions and the following disclaimer. | |
| 11 2. Redistributions in binary form must reproduce the above copyright | |
| 12 notice, this list of conditions and the following disclaimer in the | |
| 13 documentation and/or other materials provided with the distribution. | |
| 14 3. Neither the name of the project nor the names of its contributors | |
| 15 may be used to endorse or promote products derived from this software | |
| 16 without specific prior written permission. | |
| 17 | |
| 18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | |
| 19 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 20 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
| 21 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE | |
| 22 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
| 23 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
| 24 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
| 25 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
| 26 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
| 27 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
| 28 SUCH DAMAGE. | |
| 29 */ | |
| 30 /* SPDX-License-Identifier: BSD-3-Clause */ | |
| 31 | |
| 32 /* Note BARCODE_GS1_128, BARCODE_EAN14, BARCODE_NVE18 also tested in test_gs1.c */ | |
| 33 | |
| 34 #include "testcommon.h" | |
| 35 | |
| 36 static void test_large(const testCtx *const p_ctx) { | |
| 37 int debug = p_ctx->debug; | |
| 38 | |
| 39 struct item { | |
| 40 int symbology; | |
| 41 int input_mode; | |
| 42 int output_options; | |
| 43 char *pattern; | |
| 44 int length; | |
| 45 int ret; | |
| 46 int expected_width; | |
| 47 char *expected_errtxt; | |
| 48 }; | |
| 49 /* | |
| 50 é U+00E9 (\351, 233), UTF-8 C3A9, CodeB-only extended ASCII | |
| 51 */ | |
| 52 /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ | |
| 53 static const struct item data[] = { | |
| 54 /* 0*/ { BARCODE_CODE128, -1, -1, "A", 101, 0, 1146, "" }, | |
| 55 /* 1*/ { BARCODE_CODE128, -1, -1, "A", 102, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 103 symbol characters (maximum 102)" }, | |
| 56 /* 2*/ { BARCODE_CODE128, -1, -1, "A", 256, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 257 symbol characters (maximum 102)" }, | |
| 57 /* 3*/ { BARCODE_CODE128, -1, -1, "A", 257, ZINT_ERROR_TOO_LONG, -1, "Error 340: Input length 257 too long (maximum 256)" }, | |
| 58 /* 4*/ { BARCODE_CODE128, -1, -1, "abcd\201\202\203\204", 60, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 103 symbol characters (maximum 102)" }, | |
| 59 /* 5*/ { BARCODE_CODE128, -1, READER_INIT, "A", 100, 0, 1146, "" }, | |
| 60 /* 6*/ { BARCODE_CODE128, -1, READER_INIT, "A", 101, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 103 symbol characters (maximum 102)" }, | |
| 61 /* 7*/ { BARCODE_CODE128, -1, READER_INIT, "A", 256, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 258 symbol characters (maximum 102)" }, | |
| 62 /* 8*/ { BARCODE_CODE128, -1, READER_INIT, "A", 257, ZINT_ERROR_TOO_LONG, -1, "Error 340: Input length 257 too long (maximum 256)" }, | |
| 63 /* 9*/ { BARCODE_CODE128, -1, -1, "\351A", 67, 0, 1146, "" }, | |
| 64 /* 10*/ { BARCODE_CODE128, -1, -1, "\351A", 68, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 103 symbol characters (maximum 102)" }, /* 67 chars (+ 34 shifts) */ | |
| 65 /* 11*/ { BARCODE_CODE128, -1, -1, "\351A", 255, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 384 symbol characters (maximum 102)" }, | |
| 66 /* 12*/ { BARCODE_CODE128, -1, -1, "\351A", 256, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 385 symbol characters (maximum 102)" }, | |
| 67 /* 13*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, READER_INIT, "\\^A\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351", -1, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 510 symbol characters (maximum 102)" }, | |
| 68 /* 14*/ { BARCODE_CODE128, -1, -1, "\351", 99, 0, 1146, "" }, /* Less 2 FNC4s for latch */ | |
| 69 /* 15*/ { BARCODE_CODE128, -1, -1, "\351", 100, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 103 symbol characters (maximum 102)" }, | |
| 70 /* 16*/ { BARCODE_CODE128, -1, -1, "\351", 256, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 259 symbol characters (maximum 102)" }, | |
| 71 /* 17*/ { BARCODE_CODE128, -1, -1, "0", 199, 0, 1146, "" }, | |
| 72 /* 18*/ { BARCODE_CODE128, -1, -1, "0", 200, 0, 1135, "" }, | |
| 73 /* 19*/ { BARCODE_CODE128, -1, -1, "0", 201, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 103 symbol characters (maximum 102)" }, | |
| 74 /* 20*/ { BARCODE_CODE128, -1, -1, "0", 202, 0, 1146, "" }, | |
| 75 /* 21*/ { BARCODE_CODE128, -1, -1, "0", 203, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 104 symbol characters (maximum 102)" }, | |
| 76 /* 22*/ { BARCODE_CODE128, -1, -1, "0", 204, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 103 symbol characters (maximum 102)" }, | |
| 77 /* 23*/ { BARCODE_CODE128, -1, -1, "0", 256, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 129 symbol characters (maximum 102)" }, | |
| 78 /* 24*/ { BARCODE_CODE128, -1, -1, "0", 257, ZINT_ERROR_TOO_LONG, -1, "Error 340: Input length 257 too long (maximum 256)" }, | |
| 79 /* 25*/ { BARCODE_CODE128AB, -1, -1, "A", 101, 0, 1146, "" }, | |
| 80 /* 26*/ { BARCODE_CODE128AB, -1, -1, "A", 102, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 103 symbol characters (maximum 102)" }, | |
| 81 /* 27*/ { BARCODE_CODE128AB, -1, -1, "0", 101, 0, 1146, "" }, | |
| 82 /* 28*/ { BARCODE_CODE128AB, -1, -1, "0", 102, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 103 symbol characters (maximum 102)" }, | |
| 83 /* 29*/ { BARCODE_GS1_128, -1, -1, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678", -1, ZINT_WARN_NONCOMPLIANT, 1135, "Warning 843: Input too long, requires 196 characters (maximum 48)" }, /* StartC + 194 nos + 3 FNC1s */ | |
| 84 /* 30*/ { BARCODE_GS1_128, -1, -1, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", -1, ZINT_ERROR_TOO_LONG, -1, "Error 344: Input too long, requires 103 symbol characters (maximum 102)" }, /* StartC + 194 nos + CodeA + single no. + 3 FNC1s */ | |
| 85 /* 31*/ { BARCODE_GS1_128, -1, -1, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", -1, ZINT_WARN_NONCOMPLIANT, 1146, "Warning 843: Input too long, requires 198 characters (maximum 48)" }, /* StartC + 196 nos + 3 FNC1s */ | |
| 86 /* 32*/ { BARCODE_GS1_128, -1, -1, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234[93]123", -1, ZINT_ERROR_TOO_LONG, -1, "Error 344: Input too long, requires 104 symbol characters (maximum 102)" }, /* StartC + 194 nos + CodeA + single no. + 3 FNC1s */ | |
| 87 /* 33*/ { BARCODE_GS1_128, -1, -1, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]1234567890123456789012345678901234567890123456789012345678901234567890[92]12345678901234567890123456789012345678901234567890123456789012345[93]1", -1, ZINT_ERROR_TOO_LONG, -1, "Error 344: Input too long, requires 132 symbol characters (maximum 102)" }, | |
| 88 /* 34*/ { BARCODE_GS1_128, -1, -1, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]1234567890123456789012345678901234567890123456789012345678901234567890[92]12345678901234567890123456789012345678901234567890123456789012345[93]12", -1, ZINT_ERROR_TOO_LONG, -1, "Error 342: Input length 257 too long (maximum 256)" }, | |
| 89 /* 35*/ { BARCODE_EAN14, -1, -1, "1234567890123", -1, 0, 134, "" }, | |
| 90 /* 36*/ { BARCODE_EAN14, -1, -1, "12345678901234", -1, ZINT_ERROR_TOO_LONG, -1, "Error 345: Input length 14 too long (maximum 13)" }, | |
| 91 /* 37*/ { BARCODE_NVE18, -1, -1, "12345678901234567", -1, 0, 156, "" }, | |
| 92 /* 38*/ { BARCODE_NVE18, -1, -1, "123456789012345678", -1, ZINT_ERROR_TOO_LONG, -1, "Error 345: Input length 18 too long (maximum 17)" }, | |
| 93 /* 39*/ { BARCODE_HIBC_128, -1, -1, "1", 110, 0, 684, "" }, | |
| 94 /* 40*/ { BARCODE_HIBC_128, -1, -1, "1", 111, ZINT_ERROR_TOO_LONG, -1, "Error 202: Input length 111 too long for HIBC LIC (maximum 110)" }, | |
| 95 }; | |
| 96 const int data_size = ARRAY_SIZE(data); | |
| 97 int i, length, ret; | |
| 98 struct zint_symbol *symbol = NULL; | |
| 99 | |
| 100 char data_buf[4096]; | |
| 101 | |
| 102 char escaped[1024]; | |
| 103 char escaped2[1024]; | |
| 104 char cmp_buf[8192]; | |
| 105 char cmp_msg[1024]; | |
| 106 char ret_buf[8192]; | |
| 107 | |
| 108 int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ | |
| 109 int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ | |
| 110 | |
| 111 testStartSymbol("test_large", &symbol); | |
| 112 | |
| 113 for (i = 0; i < data_size; i++) { | |
| 114 | |
| 115 if (testContinue(p_ctx, i)) continue; | |
| 116 | |
| 117 symbol = ZBarcode_Create(); | |
| 118 assert_nonnull(symbol, "Symbol not created\n"); | |
| 119 | |
| 120 if (data[i].length != -1) { | |
| 121 testUtilStrCpyRepeat(data_buf, data[i].pattern, data[i].length); | |
| 122 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)); | |
| 123 } else { | |
| 124 strcpy(data_buf, data[i].pattern); | |
| 125 } | |
| 126 | |
| 127 length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, data[i].output_options, data_buf, data[i].length, debug); | |
| 128 | |
| 129 ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length); | |
| 130 assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); | |
| 131 assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt); | |
| 132 assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt); | |
| 133 | |
| 134 if (ret < ZINT_ERROR) { | |
| 135 assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); | |
| 136 | |
| 137 if (do_bwipp && testUtilCanBwipp(i, symbol, -1, -1, -1, debug)) { | |
| 138 if (data[i].output_options != -1 && (data[i].output_options & READER_INIT)) { | |
| 139 if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d %s not BWIPP compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), "READER_INIT not supported"); | |
| 140 } else { | |
| 141 char modules_dump[4096]; | |
| 142 assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); | |
| 143 ret = testUtilBwipp(i, symbol, -1, -1, -1, data_buf, length, NULL, cmp_buf, sizeof(cmp_buf), NULL); | |
| 144 assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); | |
| 145 | |
| 146 ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, modules_dump); | |
| 147 assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n", | |
| 148 i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, modules_dump); | |
| 149 } | |
| 150 } | |
| 151 if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data_buf, length, debug)) { | |
| 152 int cmp_len, ret_len; | |
| 153 char modules_dump[4096]; | |
| 154 assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); | |
| 155 ret = testUtilZXingCPP(i, symbol, data_buf, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); | |
| 156 assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); | |
| 157 | |
| 158 ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data_buf, length, NULL /*primary*/, ret_buf, &ret_len); | |
| 159 assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %s\nexpected: %s\n", | |
| 160 i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, | |
| 161 testUtilEscape(cmp_buf, cmp_len, escaped, sizeof(escaped)), | |
| 162 testUtilEscape(ret_buf, ret_len, escaped2, sizeof(escaped2))); | |
| 163 } | |
| 164 } | |
| 165 | |
| 166 ZBarcode_Delete(symbol); | |
| 167 } | |
| 168 | |
| 169 testFinish(); | |
| 170 } | |
| 171 | |
| 172 static void test_hrt(const testCtx *const p_ctx) { | |
| 173 int debug = p_ctx->debug; | |
| 174 | |
| 175 struct item { | |
| 176 int symbology; | |
| 177 int input_mode; | |
| 178 int option_2; | |
| 179 char *data; | |
| 180 int length; | |
| 181 | |
| 182 char *expected; | |
| 183 }; | |
| 184 /* | |
| 185 é U+00E9 (\351, 233), UTF-8 C3A9, CodeB-only extended ASCII | |
| 186 */ | |
| 187 /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ | |
| 188 static const struct item data[] = { | |
| 189 /* 0*/ { BARCODE_CODE128, UNICODE_MODE, -1, "1234567890", -1, "1234567890" }, | |
| 190 /* 1*/ { BARCODE_CODE128, UNICODE_MODE, -1, "\000ABC\000DEF\000", 9, " ABC DEF " }, | |
| 191 /* 2*/ { BARCODE_CODE128AB, UNICODE_MODE, -1, "12345\00067890", 11, "12345 67890" }, | |
| 192 /* 3*/ { BARCODE_CODE128, UNICODE_MODE, -1, "12345\01167890\037\177", -1, "12345 67890 " }, | |
| 193 /* 4*/ { BARCODE_CODE128, UNICODE_MODE, -1, "abcdé", -1, "abcdé" }, | |
| 194 /* 5*/ { BARCODE_CODE128, DATA_MODE, -1, "abcd\351", -1, "abcdé" }, | |
| 195 /* 6*/ { BARCODE_CODE128, DATA_MODE, -1, "ab\240cd\351", -1, "ab\302\240cdé" }, /* NBSP */ | |
| 196 /* 7*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, "\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C123456789012345678", -1, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678" }, /* Max length 198 + 19 special escapes = 99 + 19*3 = 255 */ | |
| 197 /* 8*/ { BARCODE_CODE128AB, UNICODE_MODE, -1, "abcdé", -1, "abcdé" }, | |
| 198 /* 9*/ { BARCODE_CODE128AB, DATA_MODE, -1, "abcd\351", -1, "abcdé" }, | |
| 199 /* 10*/ { BARCODE_HIBC_128, UNICODE_MODE, -1, "1234567890", -1, "*+12345678900*" }, | |
| 200 /* 11*/ { BARCODE_HIBC_128, UNICODE_MODE, -1, "a99912345", -1, "*+A999123457*" }, /* Converts to upper */ | |
| 201 /* 12*/ { BARCODE_DPD, UNICODE_MODE, -1, "000393206219912345678101040", -1, "0003 932 0621 9912 3456 78 101 040 9" }, /* DPDAPPD 4.0.2 - Illustration 7 */ | |
| 202 /* 13*/ { BARCODE_DPD, UNICODE_MODE, -1, "007110601782532948375101276", -1, "0071 106 0178 2532 9483 75 101 276 X" }, /* DPDAPPD 4.0.2 - Illustration 6, figure's HRT seems incorrect */ | |
| 203 /* 14*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020028101276", -1, "0081 827 0998 0000 0200 28 101 276 B" }, /* DPDPLS Section 4 */ | |
| 204 /* 15*/ { BARCODE_DPD, UNICODE_MODE, -1, "007110601632532948375179276", -1, "0071 106 0163 2532 9483 75 179 276 A" }, /* DPDPLS Section 4.6 */ | |
| 205 /* 16*/ { BARCODE_DPD, UNICODE_MODE, -1, "001990009980000020084109203", -1, "0019 900 0998 0000 0200 84 109 203 1" }, /* DPDPLS Section 5.1 */ | |
| 206 /* 17*/ { BARCODE_DPD, UNICODE_MODE, 1, "007110601632532948375101276", -1, "0071 106 0163 2532 9483 75 101 276 O" }, /* DPDPLS Section 6.1.2 relabel, figure is actually 8.7.2 with mislabelled HRT */ | |
| 207 /* 18*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020029136276", -1, "0081 827 0998 0000 0200 29 136 276 3" }, /* DPDPLS Section 8.1 */ | |
| 208 /* 19*/ { BARCODE_DPD, UNICODE_MODE, -1, "001234509980000020031105276", -1, "0012 345 0998 0000 0200 31 105 276 L" }, /* DPDPLS Section 8.2 */ | |
| 209 /* 20*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020032154276", -1, "0081 827 0998 0000 0200 32 154 276 J" }, /* DPDPLS Section 8.3 */ | |
| 210 /* 21*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020030109276", -1, "0081 827 0998 0000 0200 30 109 276 W" }, /* DPDPLS Section 8.4 */ | |
| 211 /* 22*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020033350276", -1, "0081 827 0998 0000 0200 33 350 276 C" }, /* DPDPLS Section 8.5.1 */ | |
| 212 /* 23*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020034179276", -1, "0081 827 0998 0000 0200 34 179 276 I" }, /* DPDPLS Section 8.5.2 */ | |
| 213 /* 24*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020035225276", -1, "0081 827 0998 0000 0200 35 225 276 H" }, /* DPDPLS Section 8.5.3 */ | |
| 214 /* 25*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020036155276", -1, "0081 827 0998 0000 0200 36 155 276 5" }, /* DPDPLS Section 8.5.4 */ | |
| 215 /* 26*/ { BARCODE_DPD, UNICODE_MODE, -1, "000280009980000020037155056", -1, "0002 800 0998 0000 0200 37 155 056 6" }, /* DPDPLS Section 8.5.5 */ | |
| 216 /* 27*/ { BARCODE_DPD, UNICODE_MODE, -1, "007855009980000020041302840", -1, "0078 550 0998 0000 0200 41 302 840 U" }, /* DPDPLS Section 8.5.6 */ | |
| 217 /* 28*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020042102276", -1, "0081 827 0998 0000 0200 42 102 276 R" }, /* DPDPLS Section 8.6.1 */ | |
| 218 /* 29*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020043113276", -1, "0081 827 0998 0000 0200 43 113 276 Y" }, /* DPDPLS Section 8.7.1 */ | |
| 219 /* 30*/ { BARCODE_DPD, UNICODE_MODE, 1, "006376209980000020044118276", -1, "0063 762 0998 0000 0200 44 118 276 I" }, /* DPDPLS Section 8.7.2 relabel */ | |
| 220 /* 31*/ { BARCODE_DPD, UNICODE_MODE, -1, "007160009980000020050294276", -1, "0071 600 0998 0000 0200 50 294 276 C" }, /* DPDPLS Section 8.8 */ | |
| 221 /* 32*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020045327276", -1, "0081 827 0998 0000 0200 45 327 276 N" }, /* DPDPLS Section 8.9.1 */ | |
| 222 /* 33*/ { BARCODE_DPD, UNICODE_MODE, -1, "006374309980000020047337276", -1, "0063 743 0998 0000 0200 47 337 276 O" }, /* DPDPLS Section 8.9.2 */ | |
| 223 /* 34*/ { BARCODE_DPD, UNICODE_MODE, 1, "006374109980978004757332276", -1, "0063 741 0998 0978 0047 57 332 276 M" }, /* DPDPLS Section 8.9.3 relabel, figure's HRT seems incorrect */ | |
| 224 /* 35*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020051106276", -1, "0081 827 0998 0000 0200 51 106 276 M" }, /* DPDPLS Section 9.1 */ | |
| 225 /* 36*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020052110276", -1, "0081 827 0998 0000 0200 52 110 276 W" }, /* DPDPLS Section 9.2 */ | |
| 226 /* 37*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020053161276", -1, "0081 827 0998 0000 0200 53 161 276 O" }, /* DPDPLS Section 9.3 */ | |
| 227 /* 38*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020054352276", -1, "0081 827 0998 0000 0200 54 352 276 B" }, /* DPDPLS Section 9.4 */ | |
| 228 /* 39*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020055191276", -1, "0081 827 0998 0000 0200 55 191 276 A" }, /* DPDPLS Section 9.5 */ | |
| 229 /* 40*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020056237276", -1, "0081 827 0998 0000 0200 56 237 276 K" }, /* DPDPLS Section 9.6 */ | |
| 230 /* 41*/ { BARCODE_UPU_S10, UNICODE_MODE, -1, "EE876543216CA", -1, "EE 876 543 216 CA" }, /* UPU S10 Annex A */ | |
| 231 /* BARCODE_GS1_128, BARCODE_EAN14, BARCODE_NVE18 hrt tested in test_gs1.c */ | |
| 232 }; | |
| 233 const int data_size = ARRAY_SIZE(data); | |
| 234 int i, length, ret; | |
| 235 struct zint_symbol *symbol = NULL; | |
| 236 | |
| 237 char escaped[1024]; | |
| 238 char escaped2[1024]; | |
| 239 char cmp_buf[8192]; | |
| 240 char cmp_msg[1024]; | |
| 241 char ret_buf[8192]; | |
| 242 | |
| 243 int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ | |
| 244 int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ | |
| 245 | |
| 246 testStartSymbol("test_hrt", &symbol); | |
| 247 | |
| 248 for (i = 0; i < data_size; i++) { | |
| 249 | |
| 250 if (testContinue(p_ctx, i)) continue; | |
| 251 | |
| 252 symbol = ZBarcode_Create(); | |
| 253 assert_nonnull(symbol, "Symbol not created\n"); | |
| 254 | |
| 255 memset(symbol->text, 0xDD, sizeof(symbol->text)); /* Detect non-NUL terminated HRT */ | |
| 256 | |
| 257 length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, data[i].length, debug); | |
| 258 | |
| 259 ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); | |
| 260 assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt); | |
| 261 | |
| 262 assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected); | |
| 263 | |
| 264 if (ret < ZINT_ERROR) { | |
| 265 if (do_bwipp && testUtilCanBwipp(i, symbol, -1, data[i].option_2, -1, debug)) { | |
| 266 if (data[i].symbology == BARCODE_HIBC_128 | |
| 267 && not_sane(IS_NUM_F | IS_UPR_F | IS_SPC_F | IS_PLS_F | IS_MNS_F | IS_SIL_F, (const unsigned char *) data[i].data, length)) { | |
| 268 if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d %s not BWIPP compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), "BWIPP does not uppercase input"); | |
| 269 } else { | |
| 270 char modules_dump[4096]; | |
| 271 assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); | |
| 272 ret = testUtilBwipp(i, symbol, -1, data[i].option_2, -1, data[i].data, length, NULL, cmp_buf, sizeof(cmp_buf), NULL); | |
| 273 assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); | |
| 274 | |
| 275 ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, modules_dump); | |
| 276 assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n", | |
| 277 i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, modules_dump); | |
| 278 } | |
| 279 } | |
| 280 if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) { | |
| 281 int cmp_len, ret_len; | |
| 282 char modules_dump[4096]; | |
| 283 assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); | |
| 284 ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); | |
| 285 assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); | |
| 286 | |
| 287 ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, ret_buf, &ret_len); | |
| 288 assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %s\nexpected: %s\n", | |
| 289 i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, | |
| 290 testUtilEscape(cmp_buf, cmp_len, escaped, sizeof(escaped)), | |
| 291 testUtilEscape(ret_buf, ret_len, escaped2, sizeof(escaped2))); | |
| 292 } | |
| 293 } | |
| 294 | |
| 295 ZBarcode_Delete(symbol); | |
| 296 } | |
| 297 | |
| 298 testFinish(); | |
| 299 } | |
| 300 | |
| 301 static void test_reader_init(const testCtx *const p_ctx) { | |
| 302 int debug = p_ctx->debug; | |
| 303 | |
| 304 struct item { | |
| 305 int symbology; | |
| 306 int input_mode; | |
| 307 int output_options; | |
| 308 char *data; | |
| 309 int ret; | |
| 310 int expected_rows; | |
| 311 int expected_width; | |
| 312 char *expected; | |
| 313 char *comment; | |
| 314 }; | |
| 315 static const struct item data[] = { | |
| 316 /* 0*/ { BARCODE_CODE128, UNICODE_MODE, READER_INIT, "A", 0, 1, 57, "(5) 104 96 33 60 106", "StartB FNC3 A" }, | |
| 317 /* 1*/ { BARCODE_CODE128, UNICODE_MODE, READER_INIT, "12", 0, 1, 68, "(6) 104 96 99 12 22 106", "StartB FNC3 CodeC 12" }, | |
| 318 /* 2*/ { BARCODE_CODE128, UNICODE_MODE, READER_INIT, "1234", 0, 1, 79, "(7) 104 96 99 12 34 55 106", "StartB FNC3 CodeC 12 34" }, | |
| 319 /* 3*/ { BARCODE_CODE128AB, UNICODE_MODE, READER_INIT, "\0371234", 0, 1, 101, "(9) 103 96 95 17 18 19 20 6 106", "StartA FNC3 US 1 2 3 4" }, | |
| 320 /* 4*/ { BARCODE_GS1_128, GS1_MODE, READER_INIT, "[90]12", ZINT_WARN_INVALID_OPTION, 1, 68, "Warning 845: Cannot use Reader Initialisation in GS1 mode, ignoring", "StartC FNC1 90 12 (Reader Initialise not supported by GS1 barcodes (use CODE128))" }, | |
| 321 /* 5*/ { BARCODE_EAN14, GS1_MODE, READER_INIT, "12", ZINT_WARN_INVALID_OPTION, 1, 134, "Warning 845: Cannot use Reader Initialisation in GS1 mode, ignoring", "StartC FNC1 01 00 (5) 01 23 (Reader Initialise not supported by GS1 barcodes (use CODE128))" }, | |
| 322 /* 6*/ { BARCODE_NVE18, GS1_MODE, READER_INIT, "12", ZINT_WARN_INVALID_OPTION, 1, 156, "Warning 845: Cannot use Reader Initialisation in GS1 mode, ignoring", "StartC FNC1 00 (8) 01 23 (Reader Initialise not supported by GS1 barcodes (use CODE128))" }, | |
| 323 /* 7*/ { BARCODE_HIBC_128, UNICODE_MODE, READER_INIT, "A", 0, 1, 79, "(7) 104 96 11 33 24 5 106", "StartB FNC3 + A 8 (check) (Not sensible, use CODE128)" }, | |
| 324 }; | |
| 325 const int data_size = ARRAY_SIZE(data); | |
| 326 int i, length, ret; | |
| 327 struct zint_symbol *symbol = NULL; | |
| 328 | |
| 329 char escaped[1024]; | |
| 330 char escaped2[1024]; | |
| 331 char cmp_buf[8192]; | |
| 332 char cmp_msg[1024]; | |
| 333 char ret_buf[8192]; | |
| 334 | |
| 335 int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ | |
| 336 | |
| 337 testStartSymbol("test_reader_init", &symbol); | |
| 338 | |
| 339 for (i = 0; i < data_size; i++) { | |
| 340 | |
| 341 if (testContinue(p_ctx, i)) continue; | |
| 342 | |
| 343 symbol = ZBarcode_Create(); | |
| 344 assert_nonnull(symbol, "Symbol not created\n"); | |
| 345 | |
| 346 symbol->debug = ZINT_DEBUG_TEST; /* Needed to get codeword dump in errtxt */ | |
| 347 | |
| 348 length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1 /*option_2*/, -1, data[i].output_options, data[i].data, -1, debug); | |
| 349 | |
| 350 ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); | |
| 351 assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); | |
| 352 | |
| 353 if (p_ctx->generate) { | |
| 354 printf(" /*%3d*/ { %s, %s, %s, \"%s\", %s, %d, %d, \"%s\", \"%s\" },\n", | |
| 355 i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), testUtilOutputOptionsName(data[i].output_options), | |
| 356 testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), | |
| 357 testUtilErrorName(data[i].ret), symbol->rows, symbol->width, symbol->errtxt, data[i].comment); | |
| 358 } else { | |
| 359 assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); | |
| 360 if (ret < ZINT_ERROR) { | |
| 361 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); | |
| 362 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); | |
| 363 | |
| 364 if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) { | |
| 365 int cmp_len, ret_len; | |
| 366 char modules_dump[4096]; | |
| 367 assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); | |
| 368 ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); | |
| 369 assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); | |
| 370 | |
| 371 ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, ret_buf, &ret_len); | |
| 372 assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %s\nexpected: %s\n", | |
| 373 i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, | |
| 374 testUtilEscape(cmp_buf, cmp_len, escaped, sizeof(escaped)), | |
| 375 testUtilEscape(ret_buf, ret_len, escaped2, sizeof(escaped2))); | |
| 376 } | |
| 377 } | |
| 378 } | |
| 379 | |
| 380 ZBarcode_Delete(symbol); | |
| 381 } | |
| 382 | |
| 383 testFinish(); | |
| 384 } | |
| 385 | |
| 386 static void test_input(const testCtx *const p_ctx) { | |
| 387 int debug = p_ctx->debug; | |
| 388 | |
| 389 struct item { | |
| 390 int input_mode; | |
| 391 char *data; | |
| 392 int length; | |
| 393 int ret; | |
| 394 int expected_width; | |
| 395 int bwipp_cmp; | |
| 396 char *expected; | |
| 397 char *comment; | |
| 398 }; | |
| 399 /* | |
| 400 NUL U+0000, CodeA-only | |
| 401 US U+001F (\037, 31), CodeA-only | |
| 402 a U+0061 (\141, 97), CodeB-only | |
| 403 b U+0062 (\142, 98), CodeB-only | |
| 404 PAD U+0080 (\200, 128), UTF-8 C280 (\302\200), CodeA-only extended ASCII, not in ISO 8859-1 | |
| 405 APC U+009F (\237, 159), UTF-8 C29F, CodeA-only extended ASCII, not in ISO 8859-1 | |
| 406 ß U+00DF (\337, 223), UTF-8 C39F, CodeA and CodeB extended ASCII | |
| 407 é U+00E9 (\351, 233), UTF-8 C3A9, CodeB-only extended ASCII | |
| 408 */ | |
| 409 static const struct item data[] = { | |
| 410 /* 0*/ { UNICODE_MODE, "\302\200", -1, ZINT_ERROR_INVALID_DATA, 0, 1, "Error 204: Invalid character in input (ISO/IEC 8859-1 only)", "PAD not in ISO 8859-1" }, | |
| 411 /* 1*/ { DATA_MODE, "\200", -1, 0, 57, 1, "(5) 103 101 64 23 106", "PAD ok using binary" }, | |
| 412 /* 2*/ { UNICODE_MODE, "AIM1234", -1, 0, 101, 1, "(9) 104 33 41 45 99 12 34 87 106", "Example from Annex A.1, check char value 87" }, | |
| 413 /* 3*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "123456789", -1, 0, 101, 1, "(9) 105 12 34 56 78 100 25 79 106", "Ticket #204 ZPL example" }, | |
| 414 /* 4*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B12345\\^C6789", -1, 0, 123, 0, "(11) 104 17 18 19 20 21 99 67 89 11 106", "Ticket #204 ZPL example; BWIPP as above" }, | |
| 415 /* 5*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B12345\\^D6789", -1, 0, 167, 0, "(15) 104 17 18 19 20 21 60 62 36 22 23 24 25 1 106", "Unrecognized extra escape passed thru; BWIPP different encodation" }, | |
| 416 /* 6*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B12345\\^D6789", -1, 0, 167, 0, "(15) 104 17 18 19 20 21 60 62 36 22 23 24 25 1 106", "Unrecognized extra escape passed thru; BWIPP different encodation" }, | |
| 417 /* 7*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A\\^B\\^C", -1, ZINT_ERROR_INVALID_DATA, 0, 1, "Error 842: No input data", "" }, | |
| 418 /* 8*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A\\^^B\\^C", -1, 0, 68, 0, "(6) 103 60 62 34 80 106", "BWIPP different encodation" }, | |
| 419 /* 9*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A\\^B\\^^C", -1, 0, 68, 1, "(6) 104 60 62 35 84 106", "" }, | |
| 420 /* 10*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^^A\\^B\\^^C", -1, 0, 101, 1, "(9) 104 60 62 33 60 62 35 14 106", "" }, | |
| 421 /* 11*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^^A\\^B\\^^C", -1, 0, 101, 1, "(9) 104 60 62 33 60 62 35 14 106", "" }, | |
| 422 /* 12*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^^A", -1, 0, 68, 1, "(6) 104 60 62 33 78 106", "" }, | |
| 423 /* 13*/ { GS1_MODE, "[90]12", -1, ZINT_ERROR_INVALID_OPTION, 0, 1, "Error 220: Selected symbology does not support GS1 mode", "" }, | |
| 424 /* 14*/ { UNICODE_MODE, "1", -1, 0, 46, 1, "(4) 104 17 18 106", "StartB 1" }, | |
| 425 /* 15*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A1", -1, 0, 46, 0, "(4) 103 17 17 106", "StartA 1; BWIPP as above" }, | |
| 426 /* 16*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^C1", -1, 0, 46, 1, "(4) 104 17 18 106", "StartB 1 (manual C ignored as odd)" }, | |
| 427 /* 17*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "1\\^A", -1, 0, 46, 1, "(4) 104 17 18 106", "StartB 1 (escape at end ignored)" }, | |
| 428 /* 18*/ { UNICODE_MODE, "12", -1, 0, 46, 1, "(4) 105 12 14 106", "StartC 12" }, | |
| 429 /* 19*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^C12", -1, 0, 46, 1, "(4) 105 12 14 106", "StartC 12" }, | |
| 430 /* 20*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B12", -1, 0, 57, 0, "(5) 104 17 18 54 106", "StartB 1 2; BWIPP as above" }, | |
| 431 /* 21*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A12", -1, 0, 57, 0, "(5) 103 17 18 53 106", "StartA 1 2; BWIPP as above" }, | |
| 432 /* 22*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A1\\^B2", -1, 0, 68, 0, "(6) 103 17 100 18 65 106", "StartA 1 CodeB 2; BWIPP as above" }, | |
| 433 /* 23*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B1\\^A2", -1, 0, 68, 0, "(6) 104 17 101 18 68 106", "StartB 1 CodeA 2; BWIPP as above" }, | |
| 434 /* 24*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A1\\^C2", -1, 0, 57, 0, "(5) 103 17 18 53 106", "StartA 1 2 (manual C ignored as odd); BWIPP as above" }, | |
| 435 /* 25*/ { UNICODE_MODE, "123", -1, 0, 68, 0, "(6) 105 12 100 19 65 106", "StartC 12 CodeB; BWIPP StartB, same as below" }, | |
| 436 /* 26*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B123", -1, 0, 68, 1, "(6) 104 17 18 19 8 106", "StartB 1 2 3" }, | |
| 437 /* 27*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B1\\^@23", -1, 0, 68, 0, "(6) 104 17 99 23 79 106", "StartB 1 CodeC 23; BWIPP as above" }, | |
| 438 /* 28*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A123", -1, 0, 68, 0, "(6) 103 17 18 19 7 106", "StartA 1 2 3; BWIPP as above" }, | |
| 439 /* 29*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^C123", -1, 0, 68, 0, "(6) 105 12 100 19 65 106", "StartC 12 CodeB 3; BWIPP as above" }, | |
| 440 /* 30*/ { UNICODE_MODE, "1234", -1, 0, 57, 1, "(5) 105 12 34 82 106", "StartC 12 34" }, | |
| 441 /* 31*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B1234", -1, 0, 79, 0, "(7) 104 17 18 19 20 88 106", "StartB 1 2 3 4; BWIPP as above" }, | |
| 442 /* 32*/ { UNICODE_MODE, "12345", -1, 0, 79, 1, "(7) 105 12 34 100 21 54 106", "StartC 12 34 CodeB 5" }, | |
| 443 /* 33*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "1234\\^A5", -1, 0, 79, 0, "(7) 105 12 34 101 21 57 106", "StartC 12 34 CodeA 5; BWIPP as above" }, | |
| 444 /* 34*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B1\\^C2345", -1, 0, 79, 0, "(7) 104 17 99 23 45 53 106", "StartB 1 CodeC 23 45; BWIPP as above" }, | |
| 445 /* 35*/ { UNICODE_MODE, "\037", -1, 0, 46, 1, "(4) 103 95 95 106", "StartA US" }, | |
| 446 /* 36*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B\037", -1, 0, 57, 0, "(5) 104 98 95 83 106", "StartB ShA <US>; BWIPP as above" }, | |
| 447 /* 37*/ { UNICODE_MODE, "1\037", -1, 0, 57, 1, "(5) 103 17 95 1 106", "StartA 1 US" }, | |
| 448 /* 38*/ { UNICODE_MODE, "12\037", -1, 0, 68, 0, "(6) 105 12 101 95 89 106", "StartC 12 CodeA US; BWIPP StartA, same as below" }, | |
| 449 /* 39*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A12\037", -1, 0, 68, 1, "(6) 103 17 18 95 29 106", "StartA 1 2 US" }, | |
| 450 /* 40*/ { UNICODE_MODE, "a\037a", -1, 0, 79, 1, "(7) 104 65 98 95 65 86 106", "StartB a Shift US a" }, | |
| 451 /* 41*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^Aa\037a", -1, 0, 90, 0, "(8) 103 98 65 95 98 65 97 106", "StartA ShB a <US> ShB a; BWIPP as above" }, | |
| 452 /* 42*/ { UNICODE_MODE, "1234\037a", -1, 0, 101, 1, "(9) 105 12 34 100 98 95 65 94 106", "StartC 12 34 CodeB Shift US a" }, | |
| 453 /* 43*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "1234\037\\^Ba", -1, 0, 101, 1, "(9) 105 12 34 100 98 95 65 94 106", "StartC 12 34 CodeB Shift US a" }, | |
| 454 /* 44*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "1234\037\\^Aa", -1, 0, 101, 0, "(9) 105 12 34 101 95 98 65 100 106", "StartC 12 34 CodeA US Shift a; BWIPP as above" }, | |
| 455 /* 45*/ { UNICODE_MODE, "\037AAa\037", -1, 0, 101, 1, "(9) 103 95 33 33 98 65 95 2 106", "StartA US A A Shift a US" }, | |
| 456 /* 46*/ { UNICODE_MODE, "\037AAaa\037", -1, 0, 123, 1, "(11) 104 98 95 33 33 65 65 98 95 3 106", "StartB Shift US A A a a Shift US" }, | |
| 457 /* 47*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\037AAaa\\^A\037", -1, 0, 123, 0, "(11) 104 98 95 33 33 65 65 101 95 24 106", "StartB Shift <US> A A a a CodeA <US>; BWIPP as above" }, | |
| 458 /* 48*/ { UNICODE_MODE, "AAAa12345aAA", -1, 0, 167, 0, "(15) 104 33 33 33 65 99 12 34 100 21 65 33 33 57 106", "StartB A A A a CodeC 12 34 CodeB 5 a A A; BWIPP different encodation" }, | |
| 459 /* 49*/ { UNICODE_MODE, "a\037Aa\037\037a\037aa\037a", -1, 0, 222, 1, "(20) 104 65 98 95 33 65 98 95 98 95 65 98 95 65 65 98 95 65 48 106", "StartB a Shift US a Shift US a Shift US a a Shift US a" }, | |
| 460 /* 50*/ { UNICODE_MODE, "\000\037ß", 4, 0, 79, 1, "(7) 103 64 95 101 63 88 106", "StartA NUL US FNC4 ß" }, | |
| 461 /* 51*/ { UNICODE_MODE, "\000\037é", 4, 0, 90, 1, "(8) 103 64 95 100 100 73 83 106", "StartA NUL US CodeB FNC4 é" }, | |
| 462 /* 52*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\000\037\\^Bé", 7, 0, 90, 1, "(8) 103 64 95 100 100 73 83 106", "StartA NUL US CodeB FNC4 é" }, | |
| 463 /* 53*/ { UNICODE_MODE, "\000\037éa", 5, 0, 101, 1, "(9) 103 64 95 100 100 73 65 61 106", "StartA NUL US CodeB FNC4 é a" }, | |
| 464 /* 54*/ { UNICODE_MODE, "abß", -1, 0, 79, 1, "(7) 104 65 66 100 63 29 106", "StartB a b FNC4 ß" }, | |
| 465 /* 55*/ { DATA_MODE, "\141\142\237", -1, 0, 90, 1, "(8) 104 65 66 100 98 95 26 106", "StartB a b FNC4 Shift APC" }, | |
| 466 /* 56*/ { DATA_MODE, "\141\142\237\037", -1, 0, 101, 1, "(9) 104 65 66 101 101 95 95 96 106", "StartB a b CodeA FNC4 APC US" }, | |
| 467 /* 57*/ { UNICODE_MODE, "ééé", -1, 0, 90, 1, "(8) 104 100 100 73 73 73 44 106", "StartB LatchFNC4 é é é" }, | |
| 468 /* 58*/ { UNICODE_MODE, "aéééb", -1, 0, 123, 1, "(11) 104 65 100 73 100 73 100 73 66 5 106", "StartB a FNC4 é (4) b" }, | |
| 469 /* 59*/ { UNICODE_MODE, "aééééb", -1, 0, 134, 1, "(12) 104 65 100 100 73 73 73 73 100 66 64 106", "StartB a Latch é (4) Shift b" }, | |
| 470 /* 60*/ { UNICODE_MODE, "aéééééb", -1, 0, 145, 1, "(13) 104 65 100 100 73 73 73 73 73 100 66 93 106", "StartB a Latch é (5) Shift b" }, | |
| 471 /* 61*/ { UNICODE_MODE, "aééééébc", -1, 0, 167, 1, "(15) 104 65 100 100 73 73 73 73 73 100 100 66 67 6 106", "StartB a Latch é (5) Unlatch b c" }, | |
| 472 /* 62*/ { UNICODE_MODE, "aééééébcd", -1, 0, 178, 1, "(16) 104 65 100 100 73 73 73 73 73 100 100 66 67 68 66 106", "StartB a Latch é (5) Unlatch b c d" }, | |
| 473 /* 63*/ { UNICODE_MODE, "aééééébcde", -1, 0, 189, 1, "(17) 104 65 100 100 73 73 73 73 73 100 100 66 67 68 69 2 106", "StartB a Latch é (5) Unlatch b c d e" }, | |
| 474 /* 64*/ { UNICODE_MODE, "aééééébcdeé", -1, 0, 211, 1, "(19) 104 65 100 100 73 73 73 73 73 100 100 66 67 68 69 100 73 95 106", "StartB a Latch é (5) Unlatch b c d e FNC4 é" }, | |
| 475 /* 65*/ { UNICODE_MODE, "aééééébcdeéé", -1, 0, 233, 1, "(21) 104 65 100 100 73 73 73 73 73 100 100 66 67 68 69 100 73 100 73 19 106", "StartB a Latch é (5) Unlatch b c d e FNC4 é (2)" }, | |
| 476 /* 66*/ { UNICODE_MODE, "aééééébcdeééé", -1, 0, 244, 1, "(22) 104 65 100 100 73 73 73 73 73 100 100 66 67 68 69 100 100 73 73 73 40 106", "StartB a Latch é (5) Unlatch b c d e Latch é (3)" }, | |
| 477 /* 67*/ { UNICODE_MODE, "aééééébcdefééé", -1, 0, 255, 1, "(23) 104 65 100 100 73 73 73 73 73 100 100 66 67 68 69 70 100 100 73 73 73 67 106", "StartB a Latch é (5) Unlatch b c d e f Latch é (3)" }, | |
| 478 /* 68*/ { DATA_MODE, "\200\200\200\200\200\101\060\060\060\060\101\200", -1, 0, 211, 1, "(19) 103 101 101 64 64 64 64 64 101 33 99 0 0 101 101 33 64 4 106", "StartA Latch PAD (5) FNC4 A CodeC 00 00 Unlatch A PAD" }, | |
| 479 /* 69*/ { UNICODE_MODE, "ÁÁÁÁÁÁ99999999999999", -1, 0, 211, 1, "(19) 104 100 100 33 33 33 33 33 33 99 99 99 99 99 99 99 99 63 106", "Okapi code128/extended-mode-exit-before-code-set-c.png (chose different solution)" }, | |
| 480 /* 70*/ { UNICODE_MODE, "ÁÁÁÁÁÁ99999999999999Á", -1, 0, 233, 1, "(21) 104 100 100 33 33 33 33 33 33 99 99 99 99 99 99 99 99 100 33 91 106", "Above with trailing non-shifted (as still latched) extended" }, | |
| 481 /* 71*/ { DATA_MODE, "@g(\202\202\202\202\2025555\202\202\202\202\202\202\202\202", -1, 0, 288, 1, "(26) 104 32 71 8 101 101 101 66 66 66 66 66 99 55 55 101 66 66 66 66 66 66 66 66 10 106", "Okapi code128/extended-mode-with-short-embedded-code-set-c.png (chose different solution)" }, | |
| 482 /* 72*/ { DATA_MODE, "@g(\202\202\202\202\20255555\202\202\202\202\202\202\202", -1, 0, 299, 1, "(27) 104 32 71 8 101 101 101 66 66 66 66 66 99 55 55 101 101 21 66 66 66 66 66 66 66 50 106", "Above with extra 5" }, | |
| 483 /* 73*/ { DATA_MODE, "@g(\202\202\202\202\202555555\202\202\202\202\202\202\202", -1, 0, 288, 1, "(26) 104 32 71 8 101 101 101 66 66 66 66 66 99 55 55 55 101 66 66 66 66 66 66 66 86 106", "Above with extra 55, one less \\202" }, | |
| 484 /* 74*/ { DATA_MODE, "@g(\202\202\202\202\202555\202\202\202\202\202\202\202\202", -1, 0, 299, 1, "(27) 104 32 71 8 101 101 101 66 66 66 66 66 99 55 101 101 21 66 66 66 66 66 66 66 66 76 106", "Above less one 5" }, | |
| 485 /* 75*/ { UNICODE_MODE, "±±±±1234AA", -1, 0, 189, 0, "(17) 104 100 17 100 17 100 17 100 17 99 12 34 100 33 33 61 106", "BWIPP different encodation (no CodeC), same as beloew" }, | |
| 486 /* 76*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "±±±±\\^B1234AA", -1, 0, 189, 1, "(17) 104 100 17 100 17 100 17 100 17 17 18 19 20 33 33 9 106", "" }, | |
| 487 /* 77*/ { UNICODE_MODE, "ÁÁèÁÁFç7Z", -1, 0, 189, 1, "(17) 104 100 100 33 33 72 33 33 100 100 38 100 71 23 58 78 106", "Okapi code128/extended-mode-shift.png" }, | |
| 488 /* 78*/ { UNICODE_MODE, "m\nm\nm", -1, 0, 112, 1, "(10) 104 77 98 74 77 98 74 77 11 106", "Okapi code128/code-set-b-a-b-a-b.png" }, | |
| 489 /* 79*/ { UNICODE_MODE, "c\naDEF", -1, 0, 112, 1, "(10) 104 67 98 74 65 36 37 38 75 106", "Okapi bug-36-1.png" }, | |
| 490 /* 80*/ { UNICODE_MODE, "\na\nDEF", -1, 0, 112, 1, "(10) 103 74 98 65 74 36 37 38 90 106", "Okapi bug-36-2.png" }, | |
| 491 /* 81*/ { UNICODE_MODE, "ÿ\012àa\0121\012àAà", -1, 0, 222, 1, "(20) 104 100 95 98 74 100 64 65 98 74 17 98 74 100 64 33 100 64 61 106", "" }, | |
| 492 /* 82*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "ÿ\012àa\\^A\0121\012\\^BàAà", -1, 0, 222, 0, "(20) 104 100 95 98 74 100 64 65 101 74 17 74 100 100 64 33 100 64 30 106", "BWIPP as above" }, | |
| 493 /* 83*/ { UNICODE_MODE, "ÿ1234\012àa\0121\0127890àAàDà\012à", -1, 0, 376, 0, "(34) 104 100 95 99 12 34 100 98 74 100 64 65 101 74 17 74 99 78 90 100 100 64 33 100 64 36", "BWIPP as below" }, | |
| 494 /* 84*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "ÿ\\^B1234\\^@\012àa\0121\0127890àAàDà\012à", -1, 0, 376, 1, "(34) 104 100 95 17 18 19 20 98 74 100 64 65 101 74 17 74 99 78 90 100 100 64 33 100 64 36", "Force BWIPP encodation" }, | |
| 495 /* 85*/ { UNICODE_MODE, "yÿ1234\012àa\0121\0127890àAàDà\012à", -1, 0, 387, 0, "(35) 104 89 100 95 99 12 34 100 98 74 100 64 65 101 74 17 74 99 78 90 100 100 64 33 100 64", "BWIPP different encodation" }, | |
| 496 /* 86*/ { UNICODE_MODE, "ÿy1234\012àa\0121\0127890àAàDà\012à", -1, 0, 387, 0, "(35) 104 100 95 89 99 12 34 100 98 74 100 64 65 101 74 17 74 99 78 90 100 100 64 33 100 64", "BWIPP different encodation" }, | |
| 497 /* 87*/ { UNICODE_MODE, "ÿÿ1234\012àa\0121\0127890àAàDà\012à", -1, 0, 398, 0, "(36) 104 100 95 100 95 99 12 34 100 98 74 100 64 65 101 74 17 74 99 78 90 100 100 64 33 100", "BWIPP different encodation" }, | |
| 498 /* 88*/ { UNICODE_MODE, "ÿ12345678\012à12345678abcdef\0121\01223456\012\0127890àAàBCDEFà\012\012à", -1, 0, 662, 0, "(60) 104 100 95 99 12 34 56 78 100 98 74 100 64 99 12 34 56 78 100 65 66 67 68 69 70 101 74", "BWIPP different encodation" }, | |
| 499 /* 89*/ { UNICODE_MODE, " ¡¡¡¡ ¡¡¡¡ ", -1, 0, 200, 1, "(18) 104 0 100 100 1 1 1 1 100 0 1 1 1 1 100 0 91 106", "StartB <SP> Latch <A0> (4) FNC4 <SP> <A0> (4) FNC4 <SP>, adapted from BWIPP PR #272" }, | |
| 500 /* 90*/ { UNICODE_MODE, " ¡¡¡¡ ¡¡¡¡ ", -1, 0, 222, 1, "(20) 104 0 100 100 1 1 1 1 100 0 100 0 1 1 1 1 100 0 63 106", "2 middle spaces" }, | |
| 501 /* 91*/ { UNICODE_MODE, " ¡¡¡¡ ¡¡¡¡ ", -1, 0, 244, 1, "(22) 104 0 100 100 1 1 1 1 100 0 100 0 100 0 1 1 1 1 100 0 29 106", "3 middle spaces" }, | |
| 502 /* 92*/ { UNICODE_MODE, " ¡¡¡¡ ¡¡¡¡ ", -1, 0, 266, 1, "(24) 104 0 100 1 100 1 100 1 100 1 0 0 0 0 100 100 1 1 1 1 100 0 94 106", "4 middle spaces then latch" }, | |
| 503 /* 93*/ { UNICODE_MODE, " ¡¡¡¡ ¡¡¡¡ ", -1, 0, 277, 1, "(25) 104 0 100 1 100 1 100 1 100 1 0 0 0 0 0 100 100 1 1 1 1 100 0 89 106", "5 middle spaces then latch" }, | |
| 504 /* 94*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, " 12\\^1 ", -1, 0, 90, 1, "(8) 104 0 17 18 102 0 85 106", "BWIPP PR #272" }, | |
| 505 /* 95*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, " 1234\\^1567", -1, 0, 123, 1, "(11) 104 0 99 12 34 102 56 100 23 41 106", "BWIPP PR #272" }, | |
| 506 /* 96*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "123\\^14567", -1, 0, 101, 1, "(9) 104 17 99 23 102 45 67 84 106", "BWIPP PR #272" }, | |
| 507 /* 97*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "\\d031\\d031_\\d127\\d159\\d031\\d159\\d159\\d159\\d15912345``\\d255\\d000\\d127\\d255\\d224\\d224\\d159`", -1, 0, 442, 1, "(40) 103 95 95 63 98 95 101 95 95 101 95 101 95 101 95 101 95 99 12 34 100 21 64 64 100 95", "Code set limit chars" }, | |
| 508 /* 98*/ { DATA_MODE, "\200\200\200\200\200A0000A\200", -1, 0, 211, 1, "(19) 103 101 101 64 64 64 64 64 101 33 99 0 0 101 101 33 64 4 106", "" }, | |
| 509 /* 99*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "12\\^1345\\^167\\^18", -1, 0, 145, 1, "(13) 105 12 102 34 100 21 102 22 23 102 24 49 106", "" }, | |
| 510 /*100*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B\\^A12\\^C34\\^A\\^B5\\^C67\\^A\\^B\\^CA\\^B\\^A", -1, 0, 145, 0, "(13) 103 17 18 99 34 100 21 99 67 100 33 69 106", "BWIPP different encodation" }, | |
| 511 /*101*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^C1234ABC12\012", -1, 0, 145, 0, "(13) 105 12 34 101 33 34 35 99 12 101 74 39 106", "StartC 12 34 CodeA A B C CodeC 12 CodeA <LF>; BWIPP different encodation" }, | |
| 512 /*102*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "A\\^", -1, 0, 68, 1, "(6) 104 33 60 62 31 106", "" }, | |
| 513 /*103*/ { UNICODE_MODE, "A\0121234A12\012", -1, 0, 145, 0, "(13) 103 33 74 99 12 34 101 33 17 18 74 99 106", "StartA A <LF> CodeC 12 34 CodeA A 1 2 <LF>; Okapi c128/improved-lookahead-mode-a.png; BWIPP different encodation" }, | |
| 514 /*104*/ { UNICODE_MODE, "21*\015\012M0", -1, 0, 112, 0, "(10) 105 21 101 10 77 74 45 16 79 106", "StartC 21 CodeA * <CR> <LF> M 0; Okapi c128/improved-lookahead-rule-1c.png; BWIPP different encodation" }, | |
| 515 /*105*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^112345\\^11234\\^112345", -1, 0, 178, 1, "(16) 104 102 17 99 23 45 102 12 34 102 12 34 100 21 72 106", "Okapi code128/fnc1-mode-c-fnc1-in-middle.png" }, | |
| 516 /*106*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^1SN123456789012", -1, 0, 145, 1, "(13) 104 102 51 46 99 12 34 56 78 90 12 65 106", "StartA FNC1 S N CodeC 12 34 56 78 90 12" }, | |
| 517 /*107*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B\\^1SN123456789012", -1, 0, 200, 0, "(18) 104 102 51 46 17 18 19 20 21 22 23 24 25 16 17 18 56 106", "StartB FNC1 S N 1 2 3 4 5 6 7 8 9 0 1 2; BWIPP as above" }, | |
| 518 /*108*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "A\\^1BC\\^1DEF\\^1", -1, 0, 134, 1, "(12) 104 33 102 34 35 102 36 37 38 102 9 106", "StartB A FNC1 B C FNC1 D E F FNC1" }, | |
| 519 /*109*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^C12\\^1", -1, 0, 57, 0, "(5) 105 12 102 12 106", "StartC 12 FNC1; BWIPP different encodation" }, | |
| 520 /*110*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "12\\^13", -1, 0, 79, 0, "(7) 105 12 102 100 19 79 106", "StartC 12 FNC1 CodeB 3, StartC so FNC1 recognized as AIM; BWIPP different encodation" }, | |
| 521 /*111*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^C12\\^13", -1, 0, 79, 0, "(7) 105 12 102 100 19 79 106", "Force StartC to ensure FNC1 recognized as AIM; BWIPP different encodation" }, | |
| 522 /*112*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B12\\^13", -1, 0, 79, 0, "(7) 104 17 18 102 19 24 106", "Force StartB to ensure FNC1 not recognized as AIM; BWIPP different encodation" }, | |
| 523 /*113*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "12\\^13\\^1", -1, 0, 90, 0, "(8) 105 12 102 100 19 102 74 106", "StartC 12 FNC1 CodeB 3 FNC1, so FNC1 recognized as AIM; BWIPP different encodation" }, | |
| 524 /*114*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "1\\^123", -1, 0, 79, 0, "(7) 104 17 99 102 23 99 106", "StartB 1 CodeC FNC1 23; BWIPP different encodation" }, | |
| 525 /*115*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "12\\^134", -1, 0, 68, 1, "(6) 105 12 102 34 11 106", "StartC 12 FNC1 34" }, | |
| 526 /*116*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "12\\^134\\^1", -1, 0, 79, 1, "(7) 105 12 102 34 102 7 106", "StartC 12 FNC1 34 FNC1" }, | |
| 527 /*117*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "123\\^145\\^1", -1, 0, 101, 1, "(9) 104 17 99 23 102 45 102 88 106", "StartB 1 CodeC 23 FNC1 45 FNC1" }, | |
| 528 /*118*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "12\\^1345\\^1", -1, 0, 101, 1, "(9) 105 12 102 34 100 21 102 98 106", "StartC 12 FNC1 34 CodeB 5 FNC1" }, | |
| 529 /*119*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "1234\\^156\\^1", -1, 0, 90, 1, "(8) 105 12 34 102 56 102 92 106", "StartC 12 34 FNC1 56 FNC1" }, | |
| 530 /*120*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "1234\\^156789\\^101\\^11\\^1", -1, 0, 178, 1, "(16) 105 12 34 102 56 78 100 25 102 16 17 102 17 102 100 106", "StartC 12 34 FNC1 56 78 CodeB 9 FNC1 0 1 FNC1 1 FNC1" }, | |
| 531 /*121*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^Aaa\\^B\012\012", -1, 0, 134, 0, "(12) 103 98 65 98 65 100 98 74 98 74 27 106", "StartA ShB a ShB a CodeB ShA <LF> ShA <LF>; BWIPP different encodation" }, | |
| 532 /*122*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "\\^A\342\342\\^B\202\202", -1, 0, 156, 0, "(14) 103 101 101 98 66 98 66 100 98 66 98 66 72 106", "StartA FNC4 FNC4 ShB 226(E2) ShB 226(E2) CodeB ShA 130(82) ShA 130(82); BWIPP different encodation" }, | |
| 533 /*123*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "\\^A\342\342\342\342\342\\^Baaaaa", -1, 0, 255, 0, "(23) 103 101 101 98 66 98 66 98 66 98 66 98 66 100 100 100 65 65 65 65 65 46 106", "BWIPP different encodation" }, | |
| 534 /*124*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "\\^A\342\012\342\342\342\\^B\202\342\012\012", -1, 0, 277, 0, "(25) 103 101 98 66 74 101 101 98 66 98 66 98 66 100 98 66 66 100 100 98 74 98 74 41 106", "BWIPP different encodation" }, | |
| 535 }; | |
| 536 const int data_size = ARRAY_SIZE(data); | |
| 537 int i, length, ret; | |
| 538 struct zint_symbol *symbol = NULL; | |
| 539 | |
| 540 char escaped[1024]; | |
| 541 char escaped2[1024]; | |
| 542 char cmp_buf[8192]; | |
| 543 char cmp_msg[1024]; | |
| 544 char ret_buf[8192]; | |
| 545 | |
| 546 int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ | |
| 547 int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ | |
| 548 | |
| 549 testStartSymbol("test_input", &symbol); | |
| 550 | |
| 551 for (i = 0; i < data_size; i++) { | |
| 552 | |
| 553 if (testContinue(p_ctx, i)) continue; | |
| 554 | |
| 555 symbol = ZBarcode_Create(); | |
| 556 assert_nonnull(symbol, "Symbol not created\n"); | |
| 557 | |
| 558 symbol->debug = ZINT_DEBUG_TEST; /* Needed to get codeword dump in errtxt */ | |
| 559 | |
| 560 length = testUtilSetSymbol(symbol, BARCODE_CODE128, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, data[i].length, debug); | |
| 561 | |
| 562 ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); | |
| 563 | |
| 564 if (p_ctx->generate) { | |
| 565 printf(" /*%3d*/ { %s, \"%s\", %d, %s, %d, %d, \"%s\", \"%s\" },\n", | |
| 566 i, testUtilInputModeName(data[i].input_mode), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length, | |
| 567 testUtilErrorName(ret), symbol->width, data[i].bwipp_cmp, symbol->errtxt, data[i].comment); | |
| 568 } else { | |
| 569 assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); | |
| 570 assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0 (width %d)\n", i, symbol->errtxt, data[i].expected, symbol->width); | |
| 571 if (ret < ZINT_ERROR) { | |
| 572 assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", | |
| 573 i, symbol->width, data[i].expected_width, | |
| 574 testUtilEscape(data[i].data, length, escaped, sizeof(escaped))); | |
| 575 | |
| 576 if (do_bwipp && testUtilCanBwipp(i, symbol, -1, -1, -1, debug)) { | |
| 577 if (!data[i].bwipp_cmp) { | |
| 578 if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d %s not BWIPP compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), data[i].comment); | |
| 579 } else { | |
| 580 char modules_dump[4096]; | |
| 581 assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); | |
| 582 ret = testUtilBwipp(i, symbol, -1, -1, -1, data[i].data, length, NULL, cmp_buf, sizeof(cmp_buf), NULL); | |
| 583 assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); | |
| 584 | |
| 585 ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, modules_dump); | |
| 586 assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n", | |
| 587 i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, modules_dump); | |
| 588 } | |
| 589 } | |
| 590 if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) { | |
| 591 int cmp_len, ret_len; | |
| 592 char modules_dump[4096]; | |
| 593 assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); | |
| 594 ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); | |
| 595 assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); | |
| 596 | |
| 597 ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, ret_buf, &ret_len); | |
| 598 assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %s\nexpected: %s\n", | |
| 599 i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, | |
| 600 testUtilEscape(cmp_buf, cmp_len, escaped, sizeof(escaped)), | |
| 601 testUtilEscape(ret_buf, ret_len, escaped2, sizeof(escaped2))); | |
| 602 } | |
| 603 } | |
| 604 } | |
| 605 | |
| 606 ZBarcode_Delete(symbol); | |
| 607 } | |
| 608 | |
| 609 testFinish(); | |
| 610 } | |
| 611 | |
| 612 static void test_gs1_128_input(const testCtx *const p_ctx) { | |
| 613 int debug = p_ctx->debug; | |
| 614 | |
| 615 struct item { | |
| 616 int input_mode; | |
| 617 char *data; | |
| 618 int ret; | |
| 619 int expected_width; | |
| 620 int bwipp_cmp; | |
| 621 char *expected; | |
| 622 char *comment; | |
| 623 }; | |
| 624 static const struct item data[] = { | |
| 625 /* 0*/ { GS1_MODE, "[90]1[90]1", 0, 123, 0, "(11) 105 102 90 100 17 102 25 99 1 56 106", "StartC FNC1 9 0 1 FNC1 9 0 1; BWIPP different encodation (same width)" }, | |
| 626 /* 1*/ { GS1_MODE | GS1PARENS_MODE, "(90)1(90)1", 0, 123, 0, "(11) 105 102 90 100 17 102 25 99 1 56 106", "StartB FNC1 9 0 1 FNC1 9 0 1; BWIPP different encodation (same width)" }, | |
| 627 /* 2*/ { GS1_MODE, "[90]1[90]12", 0, 112, 1, "(10) 104 102 25 99 1 102 90 12 43 106", "StartB FNC1 9 CodeC 01 FNC1 90 12" }, | |
| 628 /* 3*/ { GS1_MODE, "[90]1[90]123", 0, 134, 0, "(12) 105 102 90 100 17 102 25 99 1 23 57 106", "StartB FNC1 9 CodeC 01 FNC1 12 CodeB 3; BWIPP different encodation" }, | |
| 629 /* 4*/ { GS1_MODE, "[90]12[90]1", 0, 112, 1, "(10) 105 102 90 12 102 90 100 17 43 106", "StartC FNC1 90 12 FNC1 90 CodeB 1" }, | |
| 630 /* 5*/ { GS1_MODE, "[90]12[90]12", 0, 101, 1, "(9) 105 102 90 12 102 90 12 14 106", "StartC FNC1 90 12 FNC1 90 12" }, | |
| 631 /* 6*/ { GS1_MODE, "[90]12[90]123", 0, 123, 1, "(11) 105 102 90 12 102 90 12 100 19 42 106", "StartC FNC1 90 12 FNC1 CodeB 9 CodeC 01 23" }, | |
| 632 /* 7*/ { GS1_MODE, "[90]123[90]1", 0, 134, 0, "(12) 105 102 90 12 100 19 102 25 99 1 34 106", "StartC FNC1 90 12 CodeB 3 FNC1 9 0 1; BWIPP different encodation (same width)" }, | |
| 633 /* 8*/ { GS1_MODE, "[90]123[90]1234", 0, 134, 1, "(12) 104 102 25 99 1 23 102 90 12 34 50 106", "StartB FNC1 9 CodeC 01 23 FNC1 90 12 34" }, | |
| 634 /* 9*/ { GS1_MODE, "[90]1[90]1[90]1", 0, 167, 0, "(15) 105 102 90 100 17 102 25 99 1 102 90 100 17 88 106", "StartB FNC1(GS1) 9 0 1 FNC1(29) 9 0 FNC1(29) 9 0 1; BWIPP different encodation (same width)" }, | |
| 635 /* 10*/ { GS1_MODE, "[90]1[90]12[90]1", 0, 156, 1, "(14) 104 102 25 99 1 102 90 12 102 90 100 17 75 106", "StartB FNC1 9 CodeC 01 FNC1 90 12 FNC1 90 CodeB 1" }, | |
| 636 /* 11*/ { GS1_MODE, "[90]1[90]123[90]1", 0, 178, 0, "(16) 105 102 90 100 17 102 25 99 1 23 102 90 100 17 89 106", "StartB FNC1 9 CodeC 01 FNC1 90 12 CodeB 3 FNC1 9 CodeC 01; BWIPP different encodation" }, | |
| 637 /* 12*/ { GS1_MODE, "[90]12[90]123[90]1", 0, 167, 0, "(15) 105 102 90 12 102 90 12 100 19 102 25 99 1 45 106", "BWIPP different encodation (same width)" }, | |
| 638 /* 13*/ { GS1_MODE, "[90]12[90]123[90]12", 0, 167, 0, "(15) 105 102 90 12 102 90 12 100 19 99 102 90 12 100 106", "BWIPP different encodation (same width)" }, | |
| 639 /* 14*/ { GS1_MODE, "[90]123[90]1[90]1", 0, 178, 0, "(16) 105 102 90 12 100 19 102 25 99 1 102 90 100 17 66 106", "BWIPP different encodation (same width)" }, | |
| 640 /* 15*/ { GS1_MODE, "[90]123[90]12[90]1", 0, 167, 1, "(15) 104 102 25 99 1 23 102 90 12 102 90 100 17 85 106", "" }, | |
| 641 /* 16*/ { GS1_MODE, "[90]123[90]123[90]12", 0, 178, 1, "(16) 105 102 90 12 100 19 102 25 99 1 23 102 90 12 47 106", "" }, | |
| 642 /* 17*/ { GS1_MODE, "[90]123[90]1234[90]1", 0, 178, 1, "(16) 104 102 25 99 1 23 102 90 12 34 102 90 100 17 82 106", "StartB FNC1 9 CodeC 01 23 FNC1 90 12 34 FNC1 90 CodeB 1" }, | |
| 643 /* 18*/ { GS1_MODE, "[90]123[90]1234[90]123", 0, 189, 1, "(17) 104 102 25 99 1 23 102 90 12 34 102 90 12 100 19 62 106", "StartB FNC1 9 CodeC 01 23 FNC1 90 12 34 FNC1 90 12 CodeB 3" }, | |
| 644 /* 19*/ { GS1_MODE, "[90]12345[90]1234[90]1", 0, 189, 1, "(17) 104 102 25 99 1 23 45 102 90 12 34 102 90 100 17 75 106", "StartB FNC1 9 CodeC 01 23 45 FNC1 90 12 34 FNC1 90 CodeB 1" }, | |
| 645 /* 20*/ { GS1_MODE, "[90]1A[90]1", 0, 134, 0, "(12) 105 102 90 100 17 33 102 25 99 1 36 106", "BWIPP different encodation (same width)" }, | |
| 646 /* 21*/ { GS1_MODE, "[90]12A[90]123", 0, 145, 1, "(13) 105 102 90 12 100 33 102 25 99 1 23 25 106", "StartC FNC1 90 12 CodeB A FNC1 9 CodeC 01 23" }, | |
| 647 /* 22*/ { GS1_MODE, "[90]123[90]A234[90]123", 0, 222, 1, "(20) 105 102 90 12 100 19 102 25 16 33 18 99 34 102 90 12 100 19 50 106", "" }, | |
| 648 /* 23*/ { GS1_MODE, "[90]12345A12345A", 0, 178, 0, "(16) 105 102 90 12 34 100 21 33 99 12 34 100 21 33 8 106", "BWIPP different encodation (same width)" }, | |
| 649 /* 24*/ { GS1_MODE, "[01]12345678901231[90]12345678901234567890123456789", 0, 321, 1, "(29) 105 102 1 12 34 56 78 90 12 31 90 12 34 56 78 90 12 34 56 78 90 12 34 56 78 100 25 59", "Max length" }, | |
| 650 /* 25*/ { GS1_MODE, "[01]12345678901231[90]123456789012345678901234567890[91]1", ZINT_WARN_NONCOMPLIANT, 354, 1, "Warning 843: Input too long, requires 52 characters (maximum 48)", "Over length" }, | |
| 651 /* 26*/ { GS1_MODE, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]12345678901234567890123456789012345678901234567890123456789012345678901234567890[93]1234", ZINT_WARN_NONCOMPLIANT, 1135, 1, "Warning 843: Input too long, requires 195 characters (maximum 48)", "Max input" }, | |
| 652 /* 27*/ { GS1_MODE, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]12345678901234567890123456789012345678901234567890123456789012345678901234567890[93]12345", ZINT_ERROR_TOO_LONG, 0, 1, "Error 344: Input too long, requires 103 symbol characters (maximum 102)", "" }, | |
| 653 /* 28*/ { GS1_MODE, "[10]12[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[3100]567890[20]34", ZINT_WARN_NONCOMPLIANT, 1146, 1, "Warning (104) 105 102 10 12 102 0 34 56 78 90 12 34 56 78 90 0 34 56 78 90 12 34 56 78 90 0 34 56", "Was test showing HRT truncation warning trumps non-compliant but no longer doable with `text` 200 -> 256" }, | |
| 654 }; | |
| 655 const int data_size = ARRAY_SIZE(data); | |
| 656 int i, length, ret; | |
| 657 struct zint_symbol *symbol = NULL; | |
| 658 | |
| 659 char escaped[1024]; | |
| 660 char escaped2[1024]; | |
| 661 char cmp_buf[8192]; | |
| 662 char cmp_msg[1024]; | |
| 663 char ret_buf[8192]; | |
| 664 | |
| 665 int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ | |
| 666 int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ | |
| 667 | |
| 668 testStartSymbol("test_gs1_128_input", &symbol); | |
| 669 | |
| 670 for (i = 0; i < data_size; i++) { | |
| 671 | |
| 672 if (testContinue(p_ctx, i)) continue; | |
| 673 | |
| 674 symbol = ZBarcode_Create(); | |
| 675 assert_nonnull(symbol, "Symbol not created\n"); | |
| 676 | |
| 677 memset(symbol->text, 0xDD, sizeof(symbol->text)); /* Detect non-NUL terminated HRT */ | |
| 678 | |
| 679 symbol->debug = ZINT_DEBUG_TEST; /* Needed to get codeword dump in errtxt */ | |
| 680 | |
| 681 length = testUtilSetSymbol(symbol, BARCODE_GS1_128, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug); | |
| 682 | |
| 683 ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); | |
| 684 | |
| 685 if (p_ctx->generate) { | |
| 686 printf(" /*%3d*/ { %s, \"%s\", %s, %d, %d, \"%s\", \"%s\" },\n", | |
| 687 i, testUtilInputModeName(data[i].input_mode), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), | |
| 688 testUtilErrorName(data[i].ret), symbol->width, data[i].bwipp_cmp, symbol->errtxt, data[i].comment); | |
| 689 } else { | |
| 690 assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); | |
| 691 assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0 (width %d)\n", i, symbol->errtxt, data[i].expected, symbol->width); | |
| 692 if (ret < ZINT_ERROR) { | |
| 693 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); | |
| 694 if (ret == ZINT_WARN_HRT_TRUNCATED) { | |
| 695 assert_nonzero((int) ustrlen(symbol->text) < (int) strlen(data[i].data), "i:%d len symbol->text(%s) %d >= %d (%s) (%s)\n", | |
| 696 i, symbol->text, (int) ustrlen(symbol->text), (int) strlen(data[i].data), data[i].data, symbol->errtxt); | |
| 697 } else { | |
| 698 assert_equal((int) ustrlen(symbol->text), (int) strlen(data[i].data), "i:%d len symbol->text(%s) %d != %d (%s, %s) (%s)\n", | |
| 699 i, symbol->text, (int) ustrlen(symbol->text), (int) strlen(data[i].data), testUtilErrorName(ret), data[i].data, symbol->errtxt); | |
| 700 } | |
| 701 | |
| 702 if (do_bwipp && testUtilCanBwipp(i, symbol, -1, -1, -1, debug)) { | |
| 703 if (!data[i].bwipp_cmp) { | |
| 704 if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d %s not BWIPP compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), data[i].comment); | |
| 705 } else { | |
| 706 char modules_dump[4096]; | |
| 707 assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); | |
| 708 ret = testUtilBwipp(i, symbol, -1, -1, -1, data[i].data, length, NULL, cmp_buf, sizeof(cmp_buf), NULL); | |
| 709 assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); | |
| 710 | |
| 711 ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, modules_dump); | |
| 712 assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n", | |
| 713 i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, modules_dump); | |
| 714 } | |
| 715 } | |
| 716 if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) { | |
| 717 int cmp_len, ret_len; | |
| 718 char modules_dump[4096]; | |
| 719 assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); | |
| 720 ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); | |
| 721 assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); | |
| 722 | |
| 723 ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, ret_buf, &ret_len); | |
| 724 assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %s\nexpected: %s\n", | |
| 725 i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, | |
| 726 testUtilEscape(cmp_buf, cmp_len, escaped, sizeof(escaped)), | |
| 727 testUtilEscape(ret_buf, ret_len, escaped2, sizeof(escaped2))); | |
| 728 } | |
| 729 } | |
| 730 } | |
| 731 | |
| 732 ZBarcode_Delete(symbol); | |
| 733 } | |
| 734 | |
| 735 testFinish(); | |
| 736 } | |
| 737 | |
| 738 static void test_hibc_input(const testCtx *const p_ctx) { | |
| 739 int debug = p_ctx->debug; | |
| 740 | |
| 741 struct item { | |
| 742 char *data; | |
| 743 int ret; | |
| 744 int expected_width; | |
| 745 int bwipp_cmp; | |
| 746 char *expected; | |
| 747 char *comment; | |
| 748 }; | |
| 749 static const struct item data[] = { | |
| 750 /* 0*/ { ",", ZINT_ERROR_INVALID_DATA, -1, 0, "Error 203: Invalid character at position 1 in input (alphanumerics, space and \"-.$/+%\" only)", "" }, | |
| 751 /* 1*/ { "A99912345/$$52001510X3", 0, 255, 0, "(23) 104 11 33 99 99 91 23 45 100 15 4 4 99 52 0 15 10 100 56 99 33 102 106", "Check digit 3; BWIPP different encodation, same width" }, | |
| 752 /* 2*/ { "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%", 0, 497, 1, "(45) 104 11 99 1 23 45 67 89 100 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51", "Check digit +" }, | |
| 753 /* 3*/ { "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%", 0, 695, 1, "(63) 104 11 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5", "Check digit Q" }, | |
| 754 /* 4*/ { "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%", 0, 1146, 1, "(104) 104 11 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5", "" }, | |
| 755 /* 5*/ { "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%", ZINT_ERROR_TOO_LONG, -1, 0, "Error 341: Input too long, requires 103 symbol characters (maximum 102)", "" }, | |
| 756 /* 6*/ { "10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 0, 684, 1, "(62) 104 11 99 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0", "Check digit %" }, | |
| 757 /* 7*/ { "09AZ-.19AZ-.29AZ-.39AZ-.49AZ-.59AZ-.69AZ-.79AZ-.89AZ-.99AZ", 0, 695, 1, "(63) 104 11 16 25 33 58 13 14 17 25 33 58 13 14 18 25 33 58 13 14 19 25 33 58 13 14 20 25", "Check digit -" }, | |
| 758 }; | |
| 759 const int data_size = ARRAY_SIZE(data); | |
| 760 int i, length, ret; | |
| 761 struct zint_symbol *symbol = NULL; | |
| 762 | |
| 763 char escaped[1024]; | |
| 764 char escaped2[1024]; | |
| 765 char cmp_buf[8192]; | |
| 766 char cmp_msg[1024]; | |
| 767 char ret_buf[8192]; | |
| 768 | |
| 769 int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ | |
| 770 int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ | |
| 771 | |
| 772 testStartSymbol("test_hibc_input", &symbol); | |
| 773 | |
| 774 for (i = 0; i < data_size; i++) { | |
| 775 | |
| 776 if (testContinue(p_ctx, i)) continue; | |
| 777 | |
| 778 symbol = ZBarcode_Create(); | |
| 779 assert_nonnull(symbol, "Symbol not created\n"); | |
| 780 | |
| 781 symbol->debug = ZINT_DEBUG_TEST; /* Needed to get codeword dump in errtxt */ | |
| 782 | |
| 783 length = testUtilSetSymbol(symbol, BARCODE_HIBC_128, UNICODE_MODE, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug); | |
| 784 | |
| 785 ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); | |
| 786 assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); | |
| 787 | |
| 788 if (p_ctx->generate) { | |
| 789 printf(" /*%3d*/ { \"%s\", %s, %d, %d, \"%s\", \"%s\" },\n", | |
| 790 i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), | |
| 791 testUtilErrorName(data[i].ret), symbol->width, data[i].bwipp_cmp, symbol->errtxt, data[i].comment); | |
| 792 } else { | |
| 793 assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0 (width %d)\n", i, symbol->errtxt, data[i].expected, symbol->width); | |
| 794 if (ret < ZINT_ERROR) { | |
| 795 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); | |
| 796 | |
| 797 if (do_bwipp && testUtilCanBwipp(i, symbol, -1, -1, -1, debug)) { | |
| 798 if (!data[i].bwipp_cmp) { | |
| 799 if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d %s not BWIPP compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), data[i].comment); | |
| 800 } else { | |
| 801 char modules_dump[4096]; | |
| 802 assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); | |
| 803 ret = testUtilBwipp(i, symbol, -1, -1, -1, data[i].data, length, NULL, cmp_buf, sizeof(cmp_buf), NULL); | |
| 804 assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); | |
| 805 | |
| 806 ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, modules_dump); | |
| 807 assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n", | |
| 808 i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, modules_dump); | |
| 809 } | |
| 810 } | |
| 811 if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) { | |
| 812 int cmp_len, ret_len; | |
| 813 char modules_dump[4096]; | |
| 814 assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); | |
| 815 ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); | |
| 816 assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); | |
| 817 | |
| 818 ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, ret_buf, &ret_len); | |
| 819 assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %s\nexpected: %s\n", | |
| 820 i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, | |
| 821 testUtilEscape(cmp_buf, cmp_len, escaped, sizeof(escaped)), | |
| 822 testUtilEscape(ret_buf, ret_len, escaped2, sizeof(escaped2))); | |
| 823 } | |
| 824 } | |
| 825 } | |
| 826 | |
| 827 ZBarcode_Delete(symbol); | |
| 828 } | |
| 829 | |
| 830 testFinish(); | |
| 831 } | |
| 832 | |
| 833 static void test_nve18_input(const testCtx *const p_ctx) { | |
| 834 int debug = p_ctx->debug; | |
| 835 | |
| 836 struct item { | |
| 837 int input_mode; | |
| 838 char *data; | |
| 839 int ret; | |
| 840 int expected_width; | |
| 841 char *expected; | |
| 842 char *comment; | |
| 843 }; | |
| 844 static const struct item data[] = { | |
| 845 /* 0*/ { -1, "123456789012345678", ZINT_ERROR_TOO_LONG, -1, "Error 345: Input length 18 too long (maximum 17)", "" }, | |
| 846 /* 1*/ { -1, "1234A568901234567", ZINT_ERROR_INVALID_DATA, -1, "Error 346: Invalid character at position 5 in input (digits only)", "" }, | |
| 847 /* 2*/ { ESCAPE_MODE, "\\d049\\d050\\d051\\d052A568901234567", ZINT_ERROR_INVALID_DATA, -1, "Error 346: Invalid character at position 5 in input (digits only)", "Position does not account for escape sequences" }, | |
| 848 }; | |
| 849 const int data_size = ARRAY_SIZE(data); | |
| 850 int i, length, ret; | |
| 851 struct zint_symbol *symbol = NULL; | |
| 852 | |
| 853 char escaped[1024]; | |
| 854 | |
| 855 testStartSymbol("test_nve18_input", &symbol); | |
| 856 | |
| 857 for (i = 0; i < data_size; i++) { | |
| 858 | |
| 859 if (testContinue(p_ctx, i)) continue; | |
| 860 | |
| 861 symbol = ZBarcode_Create(); | |
| 862 assert_nonnull(symbol, "Symbol not created\n"); | |
| 863 | |
| 864 symbol->debug = ZINT_DEBUG_TEST; /* Needed to get codeword dump in errtxt */ | |
| 865 | |
| 866 length = testUtilSetSymbol(symbol, BARCODE_NVE18, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug); | |
| 867 | |
| 868 ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); | |
| 869 assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); | |
| 870 assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt); | |
| 871 | |
| 872 if (p_ctx->generate) { | |
| 873 printf(" /*%3d*/ { \"%s\", %s, %d, \"%s\", \"%s\" },\n", | |
| 874 i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), | |
| 875 testUtilErrorName(data[i].ret), symbol->width, symbol->errtxt, data[i].comment); | |
| 876 } else { | |
| 877 assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); | |
| 878 if (ret < ZINT_ERROR) { | |
| 879 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); | |
| 880 } | |
| 881 } | |
| 882 | |
| 883 ZBarcode_Delete(symbol); | |
| 884 } | |
| 885 | |
| 886 testFinish(); | |
| 887 } | |
| 888 | |
| 889 static void test_ean14_input(const testCtx *const p_ctx) { | |
| 890 int debug = p_ctx->debug; | |
| 891 | |
| 892 struct item { | |
| 893 char *data; | |
| 894 int ret; | |
| 895 int expected_width; | |
| 896 char *expected; | |
| 897 char *comment; | |
| 898 }; | |
| 899 static const struct item data[] = { | |
| 900 /* 0*/ { "12345678901234", ZINT_ERROR_TOO_LONG, -1, "Error 345: Input length 14 too long (maximum 13)", "" }, | |
| 901 /* 1*/ { "123456789012A", ZINT_ERROR_INVALID_DATA, -1, "Error 346: Invalid character at position 13 in input (digits only)", "" }, | |
| 902 }; | |
| 903 const int data_size = ARRAY_SIZE(data); | |
| 904 int i, length, ret; | |
| 905 struct zint_symbol *symbol = NULL; | |
| 906 | |
| 907 char escaped[1024]; | |
| 908 | |
| 909 testStartSymbol("test_ean14_input", &symbol); | |
| 910 | |
| 911 for (i = 0; i < data_size; i++) { | |
| 912 | |
| 913 if (testContinue(p_ctx, i)) continue; | |
| 914 | |
| 915 symbol = ZBarcode_Create(); | |
| 916 assert_nonnull(symbol, "Symbol not created\n"); | |
| 917 | |
| 918 symbol->debug = ZINT_DEBUG_TEST; /* Needed to get codeword dump in errtxt */ | |
| 919 | |
| 920 length = testUtilSetSymbol(symbol, BARCODE_EAN14, UNICODE_MODE, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug); | |
| 921 | |
| 922 ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); | |
| 923 assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); | |
| 924 | |
| 925 if (p_ctx->generate) { | |
| 926 printf(" /*%3d*/ { \"%s\", %s, %d, \"%s\", \"%s\" },\n", | |
| 927 i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), | |
| 928 testUtilErrorName(data[i].ret), symbol->width, symbol->errtxt, data[i].comment); | |
| 929 } else { | |
| 930 if (ret < ZINT_ERROR) { | |
| 931 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); | |
| 932 } | |
| 933 assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); | |
| 934 } | |
| 935 | |
| 936 ZBarcode_Delete(symbol); | |
| 937 } | |
| 938 | |
| 939 testFinish(); | |
| 940 } | |
| 941 | |
| 942 static void test_dpd_input(const testCtx *const p_ctx) { | |
| 943 int debug = p_ctx->debug; | |
| 944 | |
| 945 struct item { | |
| 946 int option_2; | |
| 947 int output_options; | |
| 948 char *data; | |
| 949 int ret; | |
| 950 int expected_width; | |
| 951 float expected_height; | |
| 952 int bwipp_cmp; | |
| 953 char *expected; | |
| 954 char *comment; | |
| 955 }; | |
| 956 static const struct item data[] = { | |
| 957 /* 0*/ { -1, -1, "12345678901234567890123456", ZINT_ERROR_TOO_LONG, -1, 0, 1, "Error 349: DPD input length 26 wrong (27 or 28 only)", "" }, | |
| 958 /* 1*/ { 1, -1, "12345678901234567890123456", ZINT_ERROR_TOO_LONG, -1, 0, 1, "Error 830: DPD relabel input length 26 wrong (27 only)", "" }, | |
| 959 /* 2*/ { -1, -1, "123456789012345678901234567", 0, 211, 50, 1, "(19) 104 5 17 99 23 45 67 89 1 23 45 67 89 1 23 45 67 51 106", "27 chars ok now, ident tag prefixed" }, | |
| 960 /* 3*/ { -1, -1, "%123456789012345678901234567", 0, 211, 50, 1, "(19) 104 5 17 99 23 45 67 89 1 23 45 67 89 1 23 45 67 51 106", "" }, | |
| 961 /* 4*/ { 1, -1, "123456789012345678901234567", 0, 200, 25, 1, "(18) 105 12 34 56 78 90 12 34 56 78 90 12 34 56 100 23 102 106", "27 chars also ok (and necessary) for relabel" }, | |
| 962 /* 5*/ { -1, -1, "12345678901234567890123456789", ZINT_ERROR_TOO_LONG, -1, 0, 1, "Error 349: DPD input length 29 wrong (27 or 28 only)", "" }, | |
| 963 /* 6*/ { 1, -1, "1234567890123456789012345678", ZINT_ERROR_TOO_LONG, -1, 0, 1, "Error 830: DPD relabel input length 28 wrong (27 only)", "" }, | |
| 964 /* 7*/ { -1, -1, "123456789012345678901234567,", ZINT_ERROR_INVALID_DATA, -1, 0, 1, "Error 299: Invalid character at position 27 in input (alphanumerics only after first)", "Alphanumerics only in body" }, | |
| 965 /* 8*/ { -1, -1, "12345678901234567890123456,", ZINT_ERROR_INVALID_DATA, -1, 0, 1, "Error 300: Invalid character at position 27 in input (alphanumerics only)", "Alphanumerics only" }, | |
| 966 /* 9*/ { -1, -1, ",234567890123456789012345678", 0, 211, 50, 1, "(19) 104 12 18 99 34 56 78 90 12 34 56 78 90 12 34 56 78 64 106", "Non-alphanumeric DPD ident tag (Barcode ID) allowed" }, | |
| 967 /* 10*/ { -1, -1, "\037234567890123456789012345678", ZINT_ERROR_INVALID_DATA, -1, 0, 1, "Error 343: Invalid DPD identification tag (first character), ASCII values 32 to 127 only", "Control char <US> as DPD ident tag" }, | |
| 968 /* 11*/ { -1, -1, "é234567890123456789012345678", ZINT_ERROR_INVALID_DATA, -1, 0, 1, "Error 343: Invalid DPD identification tag (first character), ASCII values 32 to 127 only", "Extended ASCII as DPD ident tag" }, | |
| 969 /* 12*/ { -1, -1, "12345678901234567890123456A", ZINT_WARN_NONCOMPLIANT, 222, 50, 1, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "" }, | |
| 970 /* 13*/ { -1, -1, "%12345678901234567890123456A", ZINT_WARN_NONCOMPLIANT, 222, 50, 1, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "" }, | |
| 971 /* 14*/ { 1, -1, "12345678901234567890123456A", ZINT_WARN_NONCOMPLIANT, 200, 25, 1, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "" }, | |
| 972 /* 15*/ { -1, -1, "123456789012345678901234A67", ZINT_WARN_NONCOMPLIANT, 233, 50, 0, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "BWIPP different encodation (same width)" }, | |
| 973 /* 16*/ { -1, -1, "%123456789012345678901234A67", ZINT_WARN_NONCOMPLIANT, 233, 50, 0, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "BWIPP different encodation (same width)" }, | |
| 974 /* 17*/ { 1, -1, "123456789012345678901234A67", ZINT_WARN_NONCOMPLIANT, 211, 25, 1, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "" }, | |
| 975 /* 18*/ { -1, -1, "12345678901234567890123A567", ZINT_WARN_NONCOMPLIANT, 244, 50, 0, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "BWIPP different encodation (same width)" }, | |
| 976 /* 19*/ { -1, -1, "%12345678901234567890123A567", ZINT_WARN_NONCOMPLIANT, 244, 50, 0, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "BWIPP different encodation (same width)" }, | |
| 977 /* 20*/ { 1, -1, "12345678901234567890123A567", ZINT_WARN_NONCOMPLIANT, 222, 25, 1, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "" }, | |
| 978 /* 21*/ { -1, -1, "123456789012345678901A34567", ZINT_WARN_NONCOMPLIANT, 244, 50, 0, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "BWIPP different encodation (same width)" }, | |
| 979 /* 22*/ { -1, -1, "%123456789012345678901A34567", ZINT_WARN_NONCOMPLIANT, 244, 50, 0, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "BWIPP different encodation (same width)" }, | |
| 980 /* 23*/ { 1, -1, "123456789012345678901A34567", ZINT_WARN_NONCOMPLIANT, 222, 25, 1, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "" }, | |
| 981 /* 24*/ { -1, -1, "12345678901234567890A234567", ZINT_WARN_NONCOMPLIANT, 233, 50, 1, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" }, | |
| 982 /* 25*/ { -1, -1, "%12345678901234567890A234567", ZINT_WARN_NONCOMPLIANT, 233, 50, 1, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" }, | |
| 983 /* 26*/ { 1, -1, "12345678901234567890A234567", ZINT_WARN_NONCOMPLIANT, 211, 25, 1, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" }, | |
| 984 /* 27*/ { -1, -1, "12345678901A345678901234567", ZINT_WARN_NONCOMPLIANT, 244, 50, 0, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "BWIPP different encodation (same width)" }, | |
| 985 /* 28*/ { -1, -1, "%12345678901A345678901234567", ZINT_WARN_NONCOMPLIANT, 244, 50, 0, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "BWIPP different encodation (same width)" }, | |
| 986 /* 29*/ { 1, -1, "12345678901A345678901234567", ZINT_WARN_NONCOMPLIANT, 222, 25, 1, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" }, | |
| 987 /* 30*/ { 1, COMPLIANT_HEIGHT, "12345678901A345678901234567", ZINT_WARN_NONCOMPLIANT, 222, 33.333332, 1, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" }, | |
| 988 }; | |
| 989 const int data_size = ARRAY_SIZE(data); | |
| 990 int i, length, ret; | |
| 991 struct zint_symbol *symbol = NULL; | |
| 992 | |
| 993 char escaped[1024]; | |
| 994 char escaped2[1024]; | |
| 995 char cmp_buf[8192]; | |
| 996 char cmp_msg[1024]; | |
| 997 char ret_buf[8192]; | |
| 998 | |
| 999 int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ | |
| 1000 int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ | |
| 1001 | |
| 1002 testStartSymbol("test_dpd_input", &symbol); | |
| 1003 | |
| 1004 for (i = 0; i < data_size; i++) { | |
| 1005 | |
| 1006 if (testContinue(p_ctx, i)) continue; | |
| 1007 | |
| 1008 symbol = ZBarcode_Create(); | |
| 1009 assert_nonnull(symbol, "Symbol not created\n"); | |
| 1010 | |
| 1011 symbol->debug = ZINT_DEBUG_TEST; /* Needed to get codeword dump in errtxt */ | |
| 1012 | |
| 1013 length = testUtilSetSymbol(symbol, BARCODE_DPD, UNICODE_MODE, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, data[i].output_options, data[i].data, -1, debug); | |
| 1014 | |
| 1015 ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); | |
| 1016 assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); | |
| 1017 | |
| 1018 if (p_ctx->generate) { | |
| 1019 printf(" /*%3d*/ { %d, %s, \"%s\", %s, %d, %.8g, %d, \"%s\", \"%s\" },\n", | |
| 1020 i, data[i].option_2, testUtilOutputOptionsName(data[i].output_options), | |
| 1021 testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), | |
| 1022 testUtilErrorName(data[i].ret), symbol->width, symbol->height, data[i].bwipp_cmp, symbol->errtxt, data[i].comment); | |
| 1023 } else { | |
| 1024 assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); | |
| 1025 if (ret < ZINT_ERROR) { | |
| 1026 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); | |
| 1027 assert_equal(symbol->height, data[i].expected_height, "i:%d symbol->height %.8g != %.8g (%s)\n", i, symbol->height, data[i].expected_height, data[i].data); | |
| 1028 | |
| 1029 if (do_bwipp && testUtilCanBwipp(i, symbol, -1, -1, data[i].option_2, debug)) { | |
| 1030 if (!data[i].bwipp_cmp) { | |
| 1031 if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d %s not BWIPP compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), data[i].comment); | |
| 1032 } else { | |
| 1033 char modules_dump[4096]; | |
| 1034 assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); | |
| 1035 ret = testUtilBwipp(i, symbol, -1, data[i].option_2, -1, data[i].data, length, NULL, cmp_buf, sizeof(cmp_buf), NULL); | |
| 1036 assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); | |
| 1037 | |
| 1038 ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, modules_dump); | |
| 1039 assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n", | |
| 1040 i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, modules_dump); | |
| 1041 } | |
| 1042 } | |
| 1043 if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) { | |
| 1044 int cmp_len, ret_len; | |
| 1045 char modules_dump[4096]; | |
| 1046 assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); | |
| 1047 ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); | |
| 1048 assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); | |
| 1049 | |
| 1050 ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, ret_buf, &ret_len); | |
| 1051 assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %s\nexpected: %s\n", | |
| 1052 i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, | |
| 1053 testUtilEscape(cmp_buf, cmp_len, escaped, sizeof(escaped)), | |
| 1054 testUtilEscape(ret_buf, ret_len, escaped2, sizeof(escaped2))); | |
| 1055 } | |
| 1056 } | |
| 1057 } | |
| 1058 | |
| 1059 ZBarcode_Delete(symbol); | |
| 1060 } | |
| 1061 | |
| 1062 testFinish(); | |
| 1063 } | |
| 1064 | |
| 1065 static void test_upu_s10_input(const testCtx *const p_ctx) { | |
| 1066 int debug = p_ctx->debug; | |
| 1067 | |
| 1068 struct item { | |
| 1069 char *data; | |
| 1070 int ret; | |
| 1071 int expected_width; | |
| 1072 char *expected; | |
| 1073 char *comment; | |
| 1074 }; | |
| 1075 static const struct item data[] = { | |
| 1076 /* 0*/ { "AB123456789ABC", ZINT_ERROR_TOO_LONG, 0, "Error 834: Input length 14 wrong (12 or 13 only)", "" }, | |
| 1077 /* 1*/ { "AB1234567AB", ZINT_ERROR_TOO_LONG, 0, "Error 834: Input length 11 wrong (12 or 13 only)", "" }, | |
| 1078 /* 2*/ { "1B123456789AB", ZINT_ERROR_INVALID_DATA, 0, "Error 835: Invalid character in Service Indictor (first 2 characters) (alphabetic only)", "" }, | |
| 1079 /* 3*/ { "1B12345678AB", ZINT_ERROR_INVALID_DATA, 0, "Error 835: Invalid character in Service Indictor (first 2 characters) (alphabetic only)", "" }, | |
| 1080 /* 4*/ { "A2123456789AB", ZINT_ERROR_INVALID_DATA, 0, "Error 835: Invalid character in Service Indictor (first 2 characters) (alphabetic only)", "" }, | |
| 1081 /* 5*/ { "A212345678AB", ZINT_ERROR_INVALID_DATA, 0, "Error 835: Invalid character in Service Indictor (first 2 characters) (alphabetic only)", "" }, | |
| 1082 /* 6*/ { "ABX23456789AB", ZINT_ERROR_INVALID_DATA, 0, "Error 836: Invalid character in Serial Number (middle 9 characters) (digits only)", "" }, | |
| 1083 /* 7*/ { "AB12345678XAB", ZINT_ERROR_INVALID_DATA, 0, "Error 836: Invalid character in Serial Number (middle 9 characters) (digits only)", "" }, | |
| 1084 /* 8*/ { "ABX2345678AB", ZINT_ERROR_INVALID_DATA, 0, "Error 836: Invalid character in Serial Number (middle 8 characters) (digits only)", "" }, | |
| 1085 /* 9*/ { "AB1234567XAB", ZINT_ERROR_INVALID_DATA, 0, "Error 836: Invalid character in Serial Number (middle 8 characters) (digits only)", "" }, | |
| 1086 /* 10*/ { "AB1234567891B", ZINT_ERROR_INVALID_DATA, 0, "Error 837: Invalid character in Country Code (last 2 characters) (alphabetic only)", "" }, | |
| 1087 /* 11*/ { "AB123456781B", ZINT_ERROR_INVALID_DATA, 0, "Error 837: Invalid character in Country Code (last 2 characters) (alphabetic only)", "" }, | |
| 1088 /* 12*/ { "AB123456789A2", ZINT_ERROR_INVALID_DATA, 0, "Error 837: Invalid character in Country Code (last 2 characters) (alphabetic only)", "" }, | |
| 1089 /* 13*/ { "AB12345678A2", ZINT_ERROR_INVALID_DATA, 0, "Error 837: Invalid character in Country Code (last 2 characters) (alphabetic only)", "" }, | |
| 1090 /* 14*/ { "AB123456789AB", ZINT_ERROR_INVALID_CHECK, 0, "Error 838: Invalid check digit '9', expecting '5'", "" }, | |
| 1091 /* 15*/ { "JB123456785AB", ZINT_WARN_NONCOMPLIANT, 156, "Warning 839: Invalid Service Indicator (first character should not be any of \"JKSTW\")", "" }, | |
| 1092 /* 16*/ { "FB123456785AB", ZINT_WARN_NONCOMPLIANT, 156, "Warning 840: Non-standard Service Indicator (first 2 characters)", "" }, | |
| 1093 /* 17*/ { "AB123456785AB", ZINT_WARN_NONCOMPLIANT, 156, "Warning 841: Country code (last two characters) is not ISO 3166-1", "" }, | |
| 1094 /* 18*/ { "AB123100000IE", 0, 156, "", "Check digit 10 -> 0" }, | |
| 1095 /* 19*/ { "AB000000005IE", 0, 156, "", "Check digit 11 -> 5" }, | |
| 1096 }; | |
| 1097 const int data_size = ARRAY_SIZE(data); | |
| 1098 int i, length, ret; | |
| 1099 struct zint_symbol *symbol = NULL; | |
| 1100 | |
| 1101 char escaped[1024]; | |
| 1102 char escaped2[1024]; | |
| 1103 char cmp_buf[8192]; | |
| 1104 char cmp_msg[1024]; | |
| 1105 char ret_buf[8192]; | |
| 1106 | |
| 1107 int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ | |
| 1108 | |
| 1109 testStartSymbol("test_upu_s10_input", &symbol); | |
| 1110 | |
| 1111 for (i = 0; i < data_size; i++) { | |
| 1112 | |
| 1113 if (testContinue(p_ctx, i)) continue; | |
| 1114 | |
| 1115 symbol = ZBarcode_Create(); | |
| 1116 assert_nonnull(symbol, "Symbol not created\n"); | |
| 1117 | |
| 1118 length = testUtilSetSymbol(symbol, BARCODE_UPU_S10, UNICODE_MODE, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug); | |
| 1119 | |
| 1120 ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); | |
| 1121 assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); | |
| 1122 | |
| 1123 if (p_ctx->generate) { | |
| 1124 printf(" /*%3d*/ { \"%s\", %s, %d, \"%s\", \"%s\" },\n", | |
| 1125 i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), | |
| 1126 testUtilErrorName(data[i].ret), symbol->width, | |
| 1127 testUtilEscape(symbol->errtxt, (int) strlen(symbol->errtxt), escaped2, sizeof(escaped2)), data[i].comment); | |
| 1128 } else { | |
| 1129 assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); | |
| 1130 if (ret < ZINT_ERROR) { | |
| 1131 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); | |
| 1132 | |
| 1133 if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) { | |
| 1134 int cmp_len, ret_len; | |
| 1135 char modules_dump[4096]; | |
| 1136 assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); | |
| 1137 ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); | |
| 1138 assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); | |
| 1139 | |
| 1140 ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, ret_buf, &ret_len); | |
| 1141 assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %s\nexpected: %s\n", | |
| 1142 i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, | |
| 1143 testUtilEscape(cmp_buf, cmp_len, escaped, sizeof(escaped)), | |
| 1144 testUtilEscape(ret_buf, ret_len, escaped2, sizeof(escaped2))); | |
| 1145 } | |
| 1146 } | |
| 1147 } | |
| 1148 | |
| 1149 ZBarcode_Delete(symbol); | |
| 1150 } | |
| 1151 | |
| 1152 testFinish(); | |
| 1153 } | |
| 1154 | |
| 1155 static void test_encode(const testCtx *const p_ctx) { | |
| 1156 int debug = p_ctx->debug; | |
| 1157 | |
| 1158 struct item { | |
| 1159 int symbology; | |
| 1160 int input_mode; | |
| 1161 int option_2; | |
| 1162 char *data; | |
| 1163 int ret; | |
| 1164 | |
| 1165 int expected_rows; | |
| 1166 int expected_width; | |
| 1167 int bwipp_cmp; | |
| 1168 char *comment; | |
| 1169 char *expected; | |
| 1170 }; | |
| 1171 /* BARCODE_GS1_128 examples verified manually against GS1 General Specifications 21.0.1 (GGS) */ | |
| 1172 /* BARCODE_DPD examples Specification DPD and primetime Parcel Despatch (DPDAPPD) Version 4.0.2, also | |
| 1173 DPD Parcel Label Specification (DPDPLS) Version 2.4.1 (19.01.2021) */ | |
| 1174 static const struct item data[] = { | |
| 1175 /* 0*/ { BARCODE_CODE128, UNICODE_MODE, -1, "AIM", 0, 1, 68, 1, "ISO/IEC 15417:2007 Figure 1", | |
| 1176 "11010010000101000110001100010001010111011000101110110001100011101011" | |
| 1177 }, | |
| 1178 /* 1*/ { BARCODE_CODE128AB, UNICODE_MODE, -1, "AIM", 0, 1, 68, 1, "128B same", | |
| 1179 "11010010000101000110001100010001010111011000101110110001100011101011" | |
| 1180 }, | |
| 1181 /* 2*/ { BARCODE_CODE128, UNICODE_MODE, -1, "1234567890", 0, 1, 90, 1, "", | |
| 1182 "110100111001011001110010001011000111000101101100001010011011110110100111100101100011101011" | |
| 1183 }, | |
| 1184 /* 3*/ { BARCODE_CODE128AB, UNICODE_MODE, -1, "1234567890", 0, 1, 145, 1, "", | |
| 1185 "1101001000010011100110110011100101100101110011001001110110111001001100111010011101101110111010011001110010110010011101100101000110001100011101011" | |
| 1186 }, | |
| 1187 /* 4*/ { BARCODE_CODE128, DATA_MODE, -1, "\101\102\103\104\105\106\200\200\200\200\200", 0, 1, 178, 1, "", | |
| 1188 "1101000010010100011000100010110001000100011010110001000100011010001000110001011101011110111010111101010000110010100001100101000011001010000110010100001100110110110001100011101011" | |
| 1189 }, | |
| 1190 /* 5*/ { BARCODE_CODE128, DATA_MODE, -1, "\101\102\103\144\012\105\061\062\063\110\111\112\064\065\066\067\114\115\120\141\127\012\130\131\132\141\142\012\012\145\012\012\146\147\012\175\061\062\012\012\064\065\066\012\202\302\012\012\342\061\062\012\012\012\012\061\062\063\012\012\012\012\012\012\061\062\063\064\012\012\012\012\342\342\342\061\062\063\064\342\342\342", 0, 1, 1091, 0, "BWIPP different encodation", | |
| 1191 "11010010000101000110001000101100010001000110100001001101111010001010000110010100011010001001110011011001110010110010111001100010100011000100010101101110001011101111010111011000100001011001011110111010001101110101110110001110111011010010110000111010001101111010001010000110010111000101101110110100011101100010100101100001001000011011101011110100001100101000011001011110100010101100100001000011001010000110010101111011101011000010010011010000111101000101000011001010100011110101110111101011001110011101011110100001100101000011001011001001110110111001001100111010010000110010111010111101001000011011101011110100010110001000011001010000110010111010111101111010001010010000110100111001101100111001010000110010100001100101000011001010000110010100111001101100111001011001011100100001100101000011001010000110010100001100101000011001010000110010101110111101011001110010001011000111010111101000011001010000110010100001100101000011001010111101110101111011101011110111010010000110100100001101001000011010111011110101100111001000101100010111101110100100001101001000011010010000110101111001001100011101011" | |
| 1192 }, | |
| 1193 /* 6*/ { BARCODE_GS1_128, GS1_MODE, -1, "[8018]950110153123456781", 0, 1, 167, 1, "GGS Figure 2.5.2-1", | |
| 1194 "11010011100111101011101010011110011001110010101111010001100110110011001000100101110011001101100011011101101110101110110001000010110010010111100101111001001100011101011" | |
| 1195 }, | |
| 1196 /* 7*/ { BARCODE_GS1_128, GS1_MODE, -1, "[415]5412345678908[3911]710125", 0, 1, 189, 1, "GGS Figure 2.6.6-1 top", | |
| 1197 "110100111001111010111011000100010111010001101100010001011101101110101110110001000010110011011011110100011001001101000100011000100100100110100001100110110011100101100100001001101100011101011" | |
| 1198 }, | |
| 1199 /* 8*/ { BARCODE_GS1_128, GS1_MODE, -1, "[12]010425[8020]ABC123", 0, 1, 189, 0, "GGS Figure 2.6.6-1 bottom **NOT SAME**, different encodation, same width; BWIPP as standard", | |
| 1200 "110100111001111010111010110011100110011011001001000110011100101100101001111001100100111010111101110101000110001000101100010001000110100111001101011101111011101101110111101000101100011101011" | |
| 1201 }, | |
| 1202 /* 9*/ { BARCODE_GS1_128, GS1_MODE, -1, "[253]950110153005812345678901", 0, 1, 211, 1, "GGS Figure 2.6.9-1 **NOT SAME**, different encodation, same width", | |
| 1203 "1101001110011110101110111001011001101000100011000101110110001001001100110110011011101110110110011001110110001010110011100100010110001110001011011000010100110111101101011110111010011100110101110110001100011101011" | |
| 1204 }, | |
| 1205 /* 10*/ { BARCODE_GS1_128, GS1_MODE, -1, "[253]950110153006567890543210987", 0, 1, 211, 1, "GGS Figure 2.6.9-2", | |
| 1206 "1101001110011110101110111001011001101000100011000101110110001001001100110110011011101110110110011001001011000010000101100110110111101000100110010110001110110111001001100100100011110010100101110011001100011101011" | |
| 1207 }, | |
| 1208 /* 11*/ { BARCODE_GS1_128, GS1_MODE, -1, "[253]95011015300657654321", 0, 1, 189, 1, "GGS Figure 2.6.9-3", | |
| 1209 "110100111001111010111011100101100110100010001100010111011000100100110011011001101110111011011001100100101100001100101000011101011000110001101101011110111010011100110111001001101100011101011" | |
| 1210 }, | |
| 1211 /* 12*/ { BARCODE_GS1_128, GS1_MODE, -1, "[253]9501101530065123456", 0, 1, 167, 1, "GGS Figure 2.6.9-4", | |
| 1212 "11010011100111101011101110010110011010001000110001011101100010010011001101100110111011101101100110010010110000101100111001000101100011100010110100011110101100011101011" | |
| 1213 }, | |
| 1214 /* 13*/ { BARCODE_GS1_128, GS1_MODE, -1, "[01]10857674002017[10]1152KMB", 0, 1, 211, 1, "GGS Figure 4.15.1-1", | |
| 1215 "1101001110011110101110110011011001100100010010011110010110010100001000011001011011001100110010011101001110011011001000100110001001001101110001010111101110101100011101011101100010001011000100111001101100011101011" | |
| 1216 }, | |
| 1217 /* 14*/ { BARCODE_GS1_128, GS1_MODE, -1, "[01]09501101530003", 0, 1, 134, 1, "GGS Figure 5.1-3", | |
| 1218 "11010011100111101011101100110110011001001000110001011101100010010011001101100110111011101101100110010010011000100110100001100011101011" | |
| 1219 }, | |
| 1220 /* 15*/ { BARCODE_GS1_128, GS1_MODE, -1, "[00]395123451234567895", 0, 1, 156, 1, "GGS Figure 5.4.2-1", | |
| 1221 "110100111001111010111011011001100110100010001101110100011101101110101110110001011001110010001011000111000101101100001010010111101000101111000101100011101011" | |
| 1222 }, | |
| 1223 /* 16*/ { BARCODE_GS1_128, GS1_MODE, -1, "[00]006141411234567890", 0, 1, 156, 1, "GGS Figure 6.6.5-1. (and Figures 6.6.5-3 bottom, 6.6.5-4 bottom)", | |
| 1224 "110100111001111010111011011001100110110011001100100001011000100010110001000101011001110010001011000111000101101100001010011011110110110110110001100011101011" | |
| 1225 }, | |
| 1226 /* 17*/ { BARCODE_GS1_128, GS1_MODE, -1, "[403]402621[401]950110153B01001", 0, 1, 255, 1, "GGS Figure 6.6.5-2 top, same", | |
| 1227 "110100100001111010111011001001110101110111101001001100011000101000111001001101101110010011110101110110001010001100101110011000101110110001001001100110110011011101110101111011101000101100010011101100101110111101100100010011001101100110001101101100011101011" | |
| 1228 }, | |
| 1229 /* 18*/ { BARCODE_GS1_128, GS1_MODE, -1, "[00]395011015300000011", 0, 1, 156, 1, "GGS Figure 6.6.5-2 bottom", | |
| 1230 "110100111001111010111011011001100110100010001100010111011000100100110011011001101110111011011001100110110011001101100110011000100100100011101101100011101011" | |
| 1231 }, | |
| 1232 /* 19*/ { BARCODE_GS1_128, GS1_MODE, -1, "[420]45458", 0, 1, 90, 1, "GGS Figure 6.6.5-3 top", | |
| 1233 "110100111001111010111010110111000100100011001110101100011101100010111100100101100011101011" | |
| 1234 }, | |
| 1235 /* 20*/ { BARCODE_GS1_128, GS1_MODE, -1, "[02]00614141000418[15]210228[10]451214[37]20", 0, 1, 255, 1, "GGS Figure 6.6.5-4 top", | |
| 1236 "110100111001111010111011001100110110110011001100100001011000100010110001000101101100110010010001100110011100101011100110011011100100110011001101110011010011001000100101110110001011001110010011001110111101011101000110100011001001110100011110101100011101011" | |
| 1237 }, | |
| 1238 /* 21*/ { BARCODE_GS1_128, GS1_MODE, -1, "[420]87109", 0, 1, 90, 1, "GGS Figure 6.6.5-5 top", | |
| 1239 "110100111001111010111010110111000100011001001001101000011001001000111001001101100011101011" | |
| 1240 }, | |
| 1241 /* 22*/ { BARCODE_GS1_128, GS1_MODE, -1, "[90]1528", 0, 1, 79, 1, "GGS Figure 6.6.5-5 middle", | |
| 1242 "1101001110011110101110110111101101011100110011100110100111001100101100011101011" | |
| 1243 }, | |
| 1244 /* 23*/ { BARCODE_GS1_128, GS1_MODE, -1, "[00]000521775138957172", 0, 1, 156, 1, "GGS Figure 6.6.5-5 bottom", | |
| 1245 "110100111001111010111011011001100110110011001000100110011011100100111101110101101110100010001100010101111010001001101000010011000010110011011001100011101011" | |
| 1246 }, | |
| 1247 /* 24*/ { BARCODE_GS1_128, GS1_MODE, -1, "[00]395011010013000129", 0, 1, 156, 1, "GGS Figure 6.6.5-6", | |
| 1248 "110100111001111010111011011001100110100010001100010111011000100100110011011001101100110010011011100110110011001100110110011100110010111101101101100011101011" | |
| 1249 }, | |
| 1250 /* 25*/ { BARCODE_GS1_128, GS1_MODE, -1, "[00]395011010013000129", 0, 1, 156, 1, "GGS Figure 6.6.5-6", | |
| 1251 "110100111001111010111011011001100110100010001100010111011000100100110011011001101100110010011011100110110011001100110110011100110010111101101101100011101011" | |
| 1252 }, | |
| 1253 /* 26*/ { BARCODE_GS1_128, GS1_MODE, -1, "[401]931234518430GR", 0, 1, 167, 1, "GGS Figure 6.6.5-7 top", | |
| 1254 "11010011100111101011101100010100011001011100110110001101110110111010111011000110011100101011000111010111101110100111011001101000100011000101110100110111001100011101011" | |
| 1255 }, | |
| 1256 /* 27*/ { BARCODE_GS1_128, GS1_MODE, -1, "[00]093123450000000012", 0, 1, 156, 1, "GGS Figure 6.6.5-7 bottom", | |
| 1257 "110100111001111010111011011001100110010010001101100011011101101110101110110001101100110011011001100110110011001101100110010110011100110111010001100011101011" | |
| 1258 }, | |
| 1259 /* 28*/ { BARCODE_GS1_128, GS1_MODE, -1, "[01]95012345678903", 0, 1, 134, 1, "GGS Figure 7.8.5.1-1 1st", | |
| 1260 "11010011100111101011101100110110010111101000110011011001110110111010111011000100001011001101101111010010011000110110001101100011101011" | |
| 1261 }, | |
| 1262 /* 29*/ { BARCODE_GS1_128, GS1_MODE, -1, "[3102]000400", 0, 1, 101, 1, "GGS Figure 7.8.5.1-1 2nd", | |
| 1263 "11010011100111101011101101100011011001100110110110011001001000110011011001100110110111101100011101011" | |
| 1264 }, | |
| 1265 /* 30*/ { BARCODE_GS1_128, GS1_MODE, -1, "[01]95012345678903[3102]000400", 0, 1, 189, 1, "GGS Figure 7.8.5.1-2", | |
| 1266 "110100111001111010111011001101100101111010001100110110011101101110101110110001000010110011011011110100100110001101100011011001100110110110011001001000110011011001100100100110001100011101011" | |
| 1267 }, | |
| 1268 /* 31*/ { BARCODE_GS1_128, GS1_MODE, -1, "[8005]000365", 0, 1, 101, 1, "GGS Figure 7.8.5.2-1 1st", | |
| 1269 "11010011100111101011101010011110010001001100110110011001001001100010010110000100100001101100011101011" | |
| 1270 }, | |
| 1271 /* 32*/ { BARCODE_GS1_128, GS1_MODE, -1, "[10]123456", 0, 1, 90, 1, "GGS Figure 7.8.5.2-1 2nd", | |
| 1272 "110100111001111010111011001000100101100111001000101100011100010110110010000101100011101011" | |
| 1273 }, | |
| 1274 /* 33*/ { BARCODE_GS1_128, GS1_MODE, -1, "[8005]000365[10]123456", 0, 1, 156, 1, "GGS Figure 7.8.5.2-2", | |
| 1275 "110100111001111010111010100111100100010011001101100110010010011000100101100001111010111011001000100101100111001000101100011100010110101100001001100011101011" | |
| 1276 }, | |
| 1277 /* 34*/ { BARCODE_GS1_128, GS1_MODE, -1, "[403]27653113+99000900090010", 0, 1, 222, 1, "DHL Leitcode https://www.dhl.de/de/geschaeftskunden/paket/information/geschaeftskunden/abrechnung/leitcodierung.html", | |
| 1278 "110100111001111010111011000101000110001101101100101000011011101110110001001001011110111011001011100110001001001011101111010111011110110110011001100100100011011001100110010010001101100110011001000100110001000101100011101011" | |
| 1279 }, | |
| 1280 /* 35*/ { BARCODE_GS1_128, GS1_MODE, -1, "[00]340433935039756615", 0, 1, 156, 1, "DHL Identcode https://www.dhl.de/de/geschaeftskunden/paket/information/geschaeftskunden/abrechnung/leitcodierung.html", | |
| 1281 "110100111001111010111011011001100100010110001001000110010100011000101000111101100010111011010001000110000100101001000011010111001100100111001101100011101011" | |
| 1282 }, | |
| 1283 /* 36*/ { BARCODE_GS1_128, GS1_MODE, -1, "[90]ABCDEfGHI", 0, 1, 167, 0, "Shift A; BWIPP different encodation", | |
| 1284 "11010011100111101011101101111011010111101110101000110001000101100010001000110101100010001000110100010110000100110100010001100010100011000100010100010111101100011101011" | |
| 1285 }, | |
| 1286 /* 37*/ { BARCODE_GS1_128, GS1_MODE, -1, "[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[3100]121212[20]34[20]78", ZINT_WARN_NONCOMPLIANT, 1, 1135, 1, "", | |
| 1287 "1101001110011110101110110110011001000101100011100010110110000101001101111011010110011100100010110001110001011011000010100110111101101101100110010001011000111000101101100001010011011110110101100111001000101100011100010110110000101001101111011011011001100100010110001110001011011000010100110111101101011001110010001011000111000101101100001010011011110110110110011001000101100011100010110110000101001101111011010110011100100010110001110001011011000010100110111101101101100110010001011000111000101101100001010011011110110101100111001000101100011100010110110000101001101111011011011001100100010110001110001011011000010100110111101101011001110010001011000111000101101100001010011011110110110110011001000101100011100010110110000101001101111011010110011100100010110001110001011011000010100110111101101101100110010001011000111000101101100001010011011110110101100111001000101100011100010110110000101001101111011011011001100100010110001110001011011000010100110111101101011001110010001011000111000101101100001010011011110110110110001101101100110010110011100101100111001011001110011001001110100010110001100100111011000010100100100110001100011101011" | |
| 1288 }, | |
| 1289 /* 38*/ { BARCODE_GS1_128, GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, "(21)12345670[23]4931", 0, 1, 189, 1, "Ticket #319, square bracket treated as FNC1 in parens mode, props Moli Sojet", | |
| 1290 "110100111001111010111011011100100101100111001000101100011100010110101100001001011110111011100011010110011100101100101110011001000010101110111101101000111011011000110100110111001100011101011" | |
| 1291 }, | |
| 1292 /* 39*/ { BARCODE_EAN14, GS1_MODE, -1, "4070071967072", 0, 1, 134, 1, "Verified manually against TEC-IT", | |
| 1293 "11010011100111101011101100110110011000101000101100001001001100010011001011100100001011001001100010011001001110110111001001100011101011" | |
| 1294 }, | |
| 1295 /* 40*/ { BARCODE_NVE18, GS1_MODE, -1, "40700000071967072", 0, 1, 156, 1, "", | |
| 1296 "110100111001111010111011011001100110001010001011000010011011001100110110011001001100010011001011100100001011001001100010011001001110110111011101100011101011" | |
| 1297 }, | |
| 1298 /* 41*/ { BARCODE_HIBC_128, UNICODE_MODE, -1, "83278F8G9H0J2G", 0, 1, 211, 0, "ANSI/HIBC 2.6 - 2016 Section 4.1, same; BWIPP different encodation, same width", | |
| 1299 "1101001000011000100100101110111101011110010011101100100101111011101110100110010001100010111010011001101000100011100101100110001010001001110110010110111000110011100101101000100010001001100110100010001100011101011" | |
| 1300 }, | |
| 1301 /* 42*/ { BARCODE_HIBC_128, UNICODE_MODE, -1, "A123BJC5D6E71", 0, 1, 200, 1, "ANSI/HIBC 2.6 - 2016 Figure 1, same", | |
| 1302 "11010010000110001001001010001100010011100110110011100101100101110010001011000101101110001000100011011011100100101100010001100111010010001101000111011011101001110011011010001000110001101101100011101011" | |
| 1303 }, | |
| 1304 /* 43*/ { BARCODE_HIBC_128, UNICODE_MODE, -1, "$$52001510X3G", 0, 1, 178, 1, "ANSI/HIBC 2.6 - 2016 Figure 5, same", | |
| 1305 "1101001000011000100100100100011001001000110010111011110110111000101101100110010111001100110010001001011110111011100010110110010111001101000100010110001000100011110101100011101011" | |
| 1306 }, | |
| 1307 /* 44*/ { BARCODE_DPD, UNICODE_MODE, -1, "%000393206219912345678101040", 0, 1, 211, 1, "DPDAPPD 4.0.2 - Illustrations 2, 7, 8, same; NOTE: correct HRT given by Illustration 7 only", | |
| 1308 "1101001000010001001100100111011001011101111011011001100110100010001100011011010011001000110111001001011101111010110011100100010110001110001011011000010100110010001001100100010011000101000101011110001100011101011" | |
| 1309 }, | |
| 1310 /* 45*/ { BARCODE_DPD, UNICODE_MODE, -1, "%007110601782532948375101276", 0, 1, 211, 1, "DPDAPPD 4.0.2 - Illustration 6 **NOT SAME** HRT incorrect, also uses CodeA and inefficient encoding; verified against TEC-IT", | |
| 1311 "1101001000010001001100100111011001011101111010011000100110001001001001100100011001101100110000101001110010110011000110110100010111101011110010011000010010110010001001011001110011001010000100010111101100011101011" | |
| 1312 }, | |
| 1313 /* 46*/ { BARCODE_DPD, UNICODE_MODE, -1, "0123456789012345678901234567", 0, 1, 189, 1, "DPDAPPD 4.0.2 - Illustration 9, same (allowing for literal HRT)", | |
| 1314 "110100111001100110110011101101110101110110001000010110011011011110110011011001110110111010111011000100001011001101101111011001101100111011011101011101100010000101100101011110001100011101011" | |
| 1315 }, | |
| 1316 /* 47*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020028101276", 0, 1, 211, 1, "DPDPLS Section 4, **NOT SAME**, figure switches to CodeC after 1st char (%), zint after 2nd (0)", | |
| 1317 "1101001000010001001100100111011001011101111010001100100110011100101110110010011001001000111101000101101100110011011001100110011001101101100110011100110100110010001001011001110011001010000101011110001100011101011" | |
| 1318 }, | |
| 1319 /* 48*/ { BARCODE_DPD, UNICODE_MODE, -1, "007110601632532948375179276", 0, 1, 211, 1, "DPDPLS Section 4.6, **NOT SAME**, figure StartA & switches as above, zint StartB & switches as above", | |
| 1320 "1101001000010001001100100111011001011101111010011000100110001001001001100100011001101100101001100001110010110011000110110100010111101011110010011000010010100111001101010111100011001010000101100010001100011101011" | |
| 1321 }, | |
| 1322 /* 49*/ { BARCODE_DPD, UNICODE_MODE, -1, "001990009980000020084109203", 0, 1, 211, 1, "DPDPLS Section 5.1, **NOT SAME**, figure switches to CodeC after 1st char (%), zint after 2nd (0)", | |
| 1323 "1101001000010001001100100111011001011101111011001101100101110111101101100110011001001000111101000101101100110011011001100110011001101101100110010011110100110010001001010111100010010011000100011010001100011101011" | |
| 1324 }, | |
| 1325 /* 50*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020029136276", 0, 1, 211, 1, "DPDPLS Section 6.1, **NOT SAME**, as above", | |
| 1326 "1101001000010001001100100111011001011101111010001100100110011100101110110010011001001000111101000101101100110011011001100110011001101101100110011100110010100110111001111000101011001010000100001101001100011101011" | |
| 1327 }, | |
| 1328 /* 51*/ { BARCODE_DPD, UNICODE_MODE, 1, "006376209980000020044118276", 0, 1, 200, 1, "DPDPLS Section 8.7.2 relabel, **NOT SAME**, figure begins StartB then immediate CodeC, zint begins StartC (shorter)", | |
| 1329 "11010011100110110011001010011000011001010000110010011101011101111010100111100110110011001101100110011001001110100100011001100010001011001110010111011001001011110111011001110100110111011101100011101011" | |
| 1330 }, | |
| 1331 /* 52*/ { BARCODE_UPU_S10, UNICODE_MODE, -1, "EE876543216CA", 0, 1, 156, 1, "", | |
| 1332 "110100100001000110100010001101000101110111101111001010010010110000101100011101101110010010111101110110011101001000100011010100011000100010011001100011101011" | |
| 1333 }, | |
| 1334 }; | |
| 1335 const int data_size = ARRAY_SIZE(data); | |
| 1336 int i, length, ret; | |
| 1337 struct zint_symbol *symbol = NULL; | |
| 1338 | |
| 1339 char escaped[1024]; | |
| 1340 char escaped2[1024]; | |
| 1341 char cmp_buf[8192]; | |
| 1342 char cmp_msg[1024]; | |
| 1343 char ret_buf[8192]; | |
| 1344 | |
| 1345 int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ | |
| 1346 int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ | |
| 1347 | |
| 1348 testStartSymbol("test_encode", &symbol); | |
| 1349 | |
| 1350 for (i = 0; i < data_size; i++) { | |
| 1351 | |
| 1352 if (testContinue(p_ctx, i)) continue; | |
| 1353 | |
| 1354 symbol = ZBarcode_Create(); | |
| 1355 assert_nonnull(symbol, "Symbol not created\n"); | |
| 1356 | |
| 1357 length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug); | |
| 1358 | |
| 1359 ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); | |
| 1360 assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); | |
| 1361 | |
| 1362 if (p_ctx->generate) { | |
| 1363 printf(" /*%3d*/ { %s, %s, %d, \"%s\", %s, %d, %d, %d, \"%s\",\n", | |
| 1364 i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), data[i].option_2, | |
| 1365 testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), | |
| 1366 testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].comment); | |
| 1367 testUtilModulesPrint(symbol, " ", "\n"); | |
| 1368 printf(" },\n"); | |
| 1369 } else { | |
| 1370 if (ret < ZINT_ERROR) { | |
| 1371 int width, row; | |
| 1372 | |
| 1373 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); | |
| 1374 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); | |
| 1375 | |
| 1376 ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row); | |
| 1377 assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data); | |
| 1378 | |
| 1379 if (do_bwipp && testUtilCanBwipp(i, symbol, -1, data[i].option_2, -1, debug)) { | |
| 1380 if (!data[i].bwipp_cmp) { | |
| 1381 if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d %s not BWIPP compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), data[i].comment); | |
| 1382 } else { | |
| 1383 ret = testUtilBwipp(i, symbol, -1, data[i].option_2, -1, data[i].data, length, NULL, cmp_buf, sizeof(cmp_buf), NULL); | |
| 1384 assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); | |
| 1385 | |
| 1386 ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, data[i].expected); | |
| 1387 assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n", | |
| 1388 i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, data[i].expected); | |
| 1389 } | |
| 1390 } | |
| 1391 if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) { | |
| 1392 int cmp_len, ret_len; | |
| 1393 char modules_dump[17984 + 1]; | |
| 1394 assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); | |
| 1395 ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); | |
| 1396 assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); | |
| 1397 | |
| 1398 ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, ret_buf, &ret_len); | |
| 1399 assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %s\nexpected: %s\n", | |
| 1400 i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, | |
| 1401 testUtilEscape(cmp_buf, cmp_len, escaped, sizeof(escaped)), | |
| 1402 testUtilEscape(ret_buf, ret_len, escaped2, sizeof(escaped2))); | |
| 1403 } | |
| 1404 } | |
| 1405 } | |
| 1406 | |
| 1407 ZBarcode_Delete(symbol); | |
| 1408 } | |
| 1409 | |
| 1410 testFinish(); | |
| 1411 } | |
| 1412 | |
| 1413 #include <time.h> | |
| 1414 | |
| 1415 #define TEST_PERF_ITER_MILLES 10 | |
| 1416 #define TEST_PERF_ITERATIONS (TEST_PERF_ITER_MILLES * 1000) | |
| 1417 #define TEST_PERF_TIME(arg) (((arg) * 1000.0) / CLOCKS_PER_SEC) | |
| 1418 | |
| 1419 /* Not a real test, just performance indicator */ | |
| 1420 static void test_perf(const testCtx *const p_ctx) { | |
| 1421 int debug = p_ctx->debug; | |
| 1422 | |
| 1423 struct item { | |
| 1424 int symbology; | |
| 1425 char *data; | |
| 1426 int ret; | |
| 1427 | |
| 1428 int expected_rows; | |
| 1429 int expected_width; | |
| 1430 char *comment; | |
| 1431 }; | |
| 1432 static const struct item data[] = { | |
| 1433 /* 0*/ { BARCODE_CODE128, "123456ABCD123456ABCD123456ABCD123456ABCD123456ABCD123456ABCD", 0, 1, 618, "CODE128 60" }, | |
| 1434 /* 1*/ { BARCODE_CODE128, "123456ABCD", 0, 1, 123, "CODE128 10" }, | |
| 1435 /* 2*/ { BARCODE_GS1_128, "[01]09501101530003", 0, 1, 134, "GS1_128 (01)" }, | |
| 1436 }; | |
| 1437 const int data_size = ARRAY_SIZE(data); | |
| 1438 int i, length, ret; | |
| 1439 struct zint_symbol *symbol; | |
| 1440 | |
| 1441 clock_t start; | |
| 1442 clock_t total_create = 0, total_encode = 0, total_buffer = 0, total_buf_inter = 0, total_print = 0; | |
| 1443 clock_t diff_create, diff_encode, diff_buffer, diff_buf_inter, diff_print; | |
| 1444 int comment_max = 0; | |
| 1445 | |
| 1446 if (!(debug & ZINT_DEBUG_TEST_PERFORMANCE)) { /* -d 256 */ | |
| 1447 return; | |
| 1448 } | |
| 1449 | |
| 1450 for (i = 0; i < data_size; i++) if ((int) strlen(data[i].comment) > comment_max) comment_max = (int) strlen(data[i].comment); | |
| 1451 | |
| 1452 printf("Iterations %d\n", TEST_PERF_ITERATIONS); | |
| 1453 | |
| 1454 for (i = 0; i < data_size; i++) { | |
| 1455 int j; | |
| 1456 | |
| 1457 if (testContinue(p_ctx, i)) continue; | |
| 1458 | |
| 1459 diff_create = diff_encode = diff_buffer = diff_buf_inter = diff_print = 0; | |
| 1460 | |
| 1461 for (j = 0; j < TEST_PERF_ITERATIONS; j++) { | |
| 1462 start = clock(); | |
| 1463 symbol = ZBarcode_Create(); | |
| 1464 diff_create += clock() - start; | |
| 1465 assert_nonnull(symbol, "Symbol not created\n"); | |
| 1466 | |
| 1467 length = testUtilSetSymbol(symbol, data[i].symbology, DATA_MODE, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug); | |
| 1468 | |
| 1469 start = clock(); | |
| 1470 ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); | |
| 1471 diff_encode += clock() - start; | |
| 1472 assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); | |
| 1473 | |
| 1474 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); | |
| 1475 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); | |
| 1476 | |
| 1477 #if 0 | |
| 1478 start = clock(); | |
| 1479 ret = ZBarcode_Buffer(symbol, 0 /*rotate_angle*/); | |
| 1480 diff_buffer += clock() - start; | |
| 1481 assert_zero(ret, "i:%d ZBarcode_Buffer ret %d != 0 (%s)\n", i, ret, symbol->errtxt); | |
| 1482 | |
| 1483 symbol->output_options |= OUT_BUFFER_INTERMEDIATE; | |
| 1484 start = clock(); | |
| 1485 ret = ZBarcode_Buffer(symbol, 0 /*rotate_angle*/); | |
| 1486 diff_buf_inter += clock() - start; | |
| 1487 assert_zero(ret, "i:%d ZBarcode_Buffer OUT_BUFFER_INTERMEDIATE ret %d != 0 (%s)\n", i, ret, symbol->errtxt); | |
| 1488 symbol->output_options &= ~OUT_BUFFER_INTERMEDIATE; /* Undo */ | |
| 1489 | |
| 1490 start = clock(); | |
| 1491 ret = ZBarcode_Print(symbol, 0 /*rotate_angle*/); | |
| 1492 diff_print += clock() - start; | |
| 1493 assert_zero(ret, "i:%d ZBarcode_Print ret %d != 0 (%s)\n", i, ret, symbol->errtxt); | |
| 1494 assert_zero(testUtilRemove(symbol->outfile), "i:%d testUtilRemove(%s) != 0\n", i, symbol->outfile); | |
| 1495 #endif | |
| 1496 | |
| 1497 ZBarcode_Delete(symbol); | |
| 1498 } | |
| 1499 | |
| 1500 printf("%*s: encode % 8gms, buffer % 8gms, buf_inter % 8gms, print % 8gms, create % 8gms\n", | |
| 1501 comment_max, data[i].comment, | |
| 1502 TEST_PERF_TIME(diff_encode), TEST_PERF_TIME(diff_buffer), TEST_PERF_TIME(diff_buf_inter), | |
| 1503 TEST_PERF_TIME(diff_print), TEST_PERF_TIME(diff_create)); | |
| 1504 | |
| 1505 total_create += diff_create; | |
| 1506 total_encode += diff_encode; | |
| 1507 total_buffer += diff_buffer; | |
| 1508 total_buf_inter += diff_buf_inter; | |
| 1509 total_print += diff_print; | |
| 1510 } | |
| 1511 if (p_ctx->index == -1) { | |
| 1512 printf("%*s: encode % 8gms, buffer % 8gms, buf_inter % 8gms, print % 8gms, create % 8gms\n", | |
| 1513 comment_max, "totals", | |
| 1514 TEST_PERF_TIME(total_encode), TEST_PERF_TIME(total_buffer), TEST_PERF_TIME(total_buf_inter), | |
| 1515 TEST_PERF_TIME(total_print), TEST_PERF_TIME(total_create)); | |
| 1516 } | |
| 1517 } | |
| 1518 | |
| 1519 int main(int argc, char *argv[]) { | |
| 1520 | |
| 1521 testFunction funcs[] = { /* name, func */ | |
| 1522 { "test_large", test_large }, | |
| 1523 { "test_hrt", test_hrt }, | |
| 1524 { "test_reader_init", test_reader_init }, | |
| 1525 { "test_input", test_input }, | |
| 1526 { "test_gs1_128_input", test_gs1_128_input }, | |
| 1527 { "test_hibc_input", test_hibc_input }, | |
| 1528 { "test_nve18_input", test_nve18_input }, | |
| 1529 { "test_ean14_input", test_ean14_input }, | |
| 1530 { "test_dpd_input", test_dpd_input }, | |
| 1531 { "test_upu_s10_input", test_upu_s10_input }, | |
| 1532 { "test_encode", test_encode }, | |
| 1533 { "test_perf", test_perf }, | |
| 1534 }; | |
| 1535 | |
| 1536 testRun(argc, argv, funcs, ARRAY_SIZE(funcs)); | |
| 1537 | |
| 1538 testReport(); | |
| 1539 | |
| 1540 return 0; | |
| 1541 } | |
| 1542 | |
| 1543 /* vim: set ts=4 sw=4 et : */ |
