Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/zint/backend/tests/test_dotcode.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) 2019-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 #include "testcommon.h" | |
| 33 | |
| 34 static void test_large(const testCtx *const p_ctx) { | |
| 35 int debug = p_ctx->debug; | |
| 36 | |
| 37 struct item { | |
| 38 int option_2; | |
| 39 char datum; | |
| 40 int length; | |
| 41 int ret; | |
| 42 char *expected_errtxt; | |
| 43 }; | |
| 44 /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ | |
| 45 static const struct item data[] = { | |
| 46 /* 0*/ { 200, '0', 2940, 0, "" }, /* 2940 largest Code Set C data that fits in 200x199 HxW */ | |
| 47 /* 1*/ { 200, '0', 2941, ZINT_ERROR_INVALID_OPTION, "Error 528: Symbol height '201' is too large" }, | |
| 48 /* 2*/ { 200, '9', 200, 0, "" }, /* Changes a number of mask scores re pre-Rev. 4 version, but best score still the same (7) */ | |
| 49 /* 3*/ { 201, '0', 2940, ZINT_ERROR_INVALID_OPTION, "Error 528: Symbol width '201' is too large" }, | |
| 50 /* 4*/ { 201, '0', 2974, ZINT_ERROR_INVALID_OPTION, "Error 526: Symbol size '201x202' (WxH) is too large" }, /* Height > 200 also */ | |
| 51 /* 5*/ { 30, '\001', 71, 0, "" }, /* Codeword length 72, ECC length 39, for ND + 1 == 112 */ | |
| 52 }; | |
| 53 const int data_size = ARRAY_SIZE(data); | |
| 54 int i, length, ret; | |
| 55 struct zint_symbol *symbol = NULL; | |
| 56 | |
| 57 char data_buf[4096]; | |
| 58 | |
| 59 testStartSymbol("test_large", &symbol); | |
| 60 | |
| 61 for (i = 0; i < data_size; i++) { | |
| 62 | |
| 63 if (testContinue(p_ctx, i)) continue; | |
| 64 | |
| 65 symbol = ZBarcode_Create(); | |
| 66 assert_nonnull(symbol, "Symbol not created\n"); | |
| 67 | |
| 68 memset(data_buf, data[i].datum, data[i].length); | |
| 69 | |
| 70 length = testUtilSetSymbol(symbol, BARCODE_DOTCODE, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data_buf, data[i].length, debug); | |
| 71 | |
| 72 ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length); | |
| 73 assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); | |
| 74 assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt); | |
| 75 | |
| 76 ZBarcode_Delete(symbol); | |
| 77 } | |
| 78 | |
| 79 testFinish(); | |
| 80 } | |
| 81 | |
| 82 static void test_options(const testCtx *const p_ctx) { | |
| 83 int debug = p_ctx->debug; | |
| 84 | |
| 85 struct item { | |
| 86 int input_mode; | |
| 87 int eci; | |
| 88 int output_options; | |
| 89 int option_2; | |
| 90 int option_3; | |
| 91 struct zint_structapp structapp; | |
| 92 char *data; | |
| 93 int ret; | |
| 94 | |
| 95 int expected_rows; | |
| 96 int expected_width; | |
| 97 const char *expected_errtxt; | |
| 98 }; | |
| 99 /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ | |
| 100 static const struct item data[] = { | |
| 101 /* 0*/ { -1, -1, -1, -1, -1, { 0, 0, "" }, "1", 0, 9, 14, "" }, | |
| 102 /* 1*/ { -1, -1, -1, -1, -1, { 0, 0, "" }, "1234567890", 0, 12, 19, "" }, | |
| 103 /* 2*/ { -1, -1, -1, 19, -1, { 0, 0, "" }, "1234567890", 0, 12, 19, "" }, | |
| 104 /* 3*/ { -1, -1, -1, 12, -1, { 0, 0, "" }, "1234567890", 0, 19, 12, "" }, | |
| 105 /* 4*/ { -1, -1, -1, 5, -1, { 0, 0, "" }, "1234567890", 0, 44, 5, "" }, | |
| 106 /* 5*/ { -1, -1, -1, 4, -1, { 0, 0, "" }, "1234567890", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 529: Symbol width '4' is too small" }, /* Cols < 5 */ | |
| 107 /* 6*/ { -1, -1, -1, 200, -1, { 0, 0, "" }, "1234567890", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 529: Symbol height '3' is too small" }, /* Not enough data - height 3 too small */ | |
| 108 /* 7*/ { -1, -1, -1, 200, -1, { 0, 0, "" }, "1234567890123456789012345678901234567890", 0, 5, 200, "" }, /* Cols 200 max */ | |
| 109 /* 8*/ { -1, -1, -1, 200, -1, { 0, 0, "" }, "12345678901234567890123456789012345678901234567890123456789012345678901234567890", 0, 7, 200, "" }, | |
| 110 /* 9*/ { -1, -1, -1, 201, -1, { 0, 0, "" }, "12345678901234567890123456789012345678901234567890123456789012345678901234567890", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 528: Symbol width '201' is too large" }, | |
| 111 /* 10*/ { -1, -1, -1, -1, 10 << 8, { 0, 0, "" }, "1", 0, 9, 14, "" }, /* Mask > 8 + 1 ignored */ | |
| 112 /* 11*/ { -1, -1, -1, 19, -1, { 0, 0, "" }, "ABCDE", 0, 12, 19, "" }, | |
| 113 /* 12*/ { -1, -1, -1, 19, -1, { 35, 35, "" }, "ABCDE", 0, 16, 19, "" }, | |
| 114 /* 13*/ { -1, -1, -1, 19, -1, { 1, 1, "" }, "ABCDE", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 730: Structured Append count '1' out of range (2 to 35)" }, | |
| 115 /* 14*/ { -1, -1, -1, 19, -1, { 1, 36, "" }, "ABCDE", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 730: Structured Append count '36' out of range (2 to 35)" }, | |
| 116 /* 15*/ { -1, -1, -1, 19, -1, { 3, 2, "" }, "ABCDE", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 731: Structured Append index '3' out of range (1 to count 2)" }, | |
| 117 /* 16*/ { -1, -1, -1, 19, -1, { 1, 2, "1" }, "ABCDE", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 732: Structured Append ID not available for DotCode" }, | |
| 118 /* 17*/ { GS1_MODE, 3, -1, -1, -1, { 0, 0, "" }, "[20]01", ZINT_WARN_NONCOMPLIANT, 11, 16, "Warning 733: Using ECI in GS1 mode not supported by GS1 standards" }, | |
| 119 /* 18*/ { GS1_MODE, -1, -1, -1, -1, { 1, 2, "" }, "[20]01", ZINT_WARN_NONCOMPLIANT, 12, 19, "Warning 734: Using Structured Append in GS1 mode not supported by GS1 standards" }, | |
| 120 /* 19*/ { GS1_MODE, 3, -1, -1, -1, { 1, 2, "" }, "[20]01", ZINT_WARN_NONCOMPLIANT, 14, 21, "Warning 733: Using ECI in GS1 mode not supported by GS1 standards" }, /* ECI trumps Structured Append */ | |
| 121 }; | |
| 122 const int data_size = ARRAY_SIZE(data); | |
| 123 int i, length, ret; | |
| 124 struct zint_symbol *symbol = NULL; | |
| 125 | |
| 126 testStartSymbol("test_options", &symbol); | |
| 127 | |
| 128 for (i = 0; i < data_size; i++) { | |
| 129 | |
| 130 if (testContinue(p_ctx, i)) continue; | |
| 131 | |
| 132 symbol = ZBarcode_Create(); | |
| 133 assert_nonnull(symbol, "Symbol not created\n"); | |
| 134 | |
| 135 length = testUtilSetSymbol(symbol, BARCODE_DOTCODE, data[i].input_mode, data[i].eci, -1 /*option_1*/, data[i].option_2, data[i].option_3, data[i].output_options, data[i].data, -1, debug); | |
| 136 if (data[i].structapp.count) { | |
| 137 symbol->structapp = data[i].structapp; | |
| 138 } | |
| 139 | |
| 140 ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); | |
| 141 assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); | |
| 142 | |
| 143 if (ret < ZINT_ERROR) { | |
| 144 assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, symbol->errtxt); | |
| 145 assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, symbol->errtxt); | |
| 146 } | |
| 147 assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt); | |
| 148 | |
| 149 ZBarcode_Delete(symbol); | |
| 150 } | |
| 151 | |
| 152 testFinish(); | |
| 153 } | |
| 154 | |
| 155 static void test_input(const testCtx *const p_ctx) { | |
| 156 int debug = p_ctx->debug; | |
| 157 | |
| 158 struct item { | |
| 159 int input_mode; | |
| 160 int eci; | |
| 161 int option_2; | |
| 162 int option_3; | |
| 163 struct zint_structapp structapp; | |
| 164 char *data; | |
| 165 int length; | |
| 166 int ret; | |
| 167 char *expected; | |
| 168 int bwipp_cmp; | |
| 169 char *comment; | |
| 170 }; | |
| 171 static const struct item data[] = { | |
| 172 /* 0*/ { UNICODE_MODE, -1, 13, -1, { 0, 0, "" }, "A", -1, 0, "66 21 6A", 1, "" }, | |
| 173 /* 1*/ { UNICODE_MODE, 3, -1, -1, { 0, 0, "" }, "A", -1, 0, "6C 03 66 21", 1, "" }, | |
| 174 /* 2*/ { UNICODE_MODE, 40, 18, -1, { 0, 0, "" }, "A", -1, 0, "6C 28 00 00 66 21", 1, "" }, | |
| 175 /* 3*/ { UNICODE_MODE, 113, 18, -1, { 0, 0, "" }, "A", -1, 0, "6C 28 00 49 66 21", 1, "" }, | |
| 176 /* 4*/ { UNICODE_MODE, 899, 18, -1, { 0, 0, "" }, "A", -1, 0, "6C 28 07 44 66 21", 1, "" }, | |
| 177 /* 5*/ { UNICODE_MODE, 12769, 18, 8 << 8, { 0, 0, "" }, "A", -1, 0, "6C 28 70 49 66 21", 1, "" }, | |
| 178 /* 6*/ { UNICODE_MODE, 811799, 18, -1, { 0, 0, "" }, "A", -1, 0, "6C 67 40 50 66 21", 1, "" }, | |
| 179 /* 7*/ { UNICODE_MODE, 811800, -1, -1, { 0, 0, "" }, "A", -1, ZINT_ERROR_INVALID_OPTION, "Error 525: ECI code '811800' out of range (0 to 811799)", 1, "" }, | |
| 180 /* 8*/ { UNICODE_MODE, -1, 13, -1, { 0, 0, "" }, "\000", 1, 0, "65 40 6A", 1, "LatchA (0x65) NUL PAD" }, | |
| 181 /* 9*/ { UNICODE_MODE, -1, 13, -1, { 0, 0, "" }, "\010", -1, 0, "65 48 6A", 1, "LatchA (0x65) BS PAD" }, | |
| 182 /* 10*/ { UNICODE_MODE, -1, 13, -1, { 0, 0, "" }, "\011", -1, 0, "65 49 6A", 1, "Lead special; LatchA (0x65) HT PAD" }, | |
| 183 /* 11*/ { UNICODE_MODE, -1, 13, -1, { 0, 0, "" }, "\034", -1, 0, "65 5C 6A", 1, "Lead special; LatchA (0x65) FS PAD" }, | |
| 184 /* 12*/ { UNICODE_MODE, -1, 13, -1, { 0, 0, "" }, "\035", -1, 0, "65 5D 6A", 1, "Lead special; LatchA (0x65) GS PAD" }, | |
| 185 /* 13*/ { UNICODE_MODE, -1, 13, -1, { 0, 0, "" }, "\036", -1, 0, "65 5E 6A", 1, "Lead special; LatchA (0x65) RS PAD" }, | |
| 186 /* 14*/ { UNICODE_MODE, -1, 13, -1, { 0, 0, "" }, "\037", -1, 0, "65 5F 6A", 1, "LatchA (0x65) US PAD" }, | |
| 187 /* 15*/ { UNICODE_MODE, -1, 13, -1, { 0, 0, "" }, "\177", -1, 0, "66 5F 6A", 1, "ShiftB (0x66) DEL PAD" }, | |
| 188 /* 16*/ { UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "[)>\03605\035A\036\004", -1, 0, "6A 61 21", 1, "[)>RS 05 GS A RS EOT; LatchB (0x6A) Macro97 (0x61) A" }, | |
| 189 /* 17*/ { UNICODE_MODE, -1, 17, -1, { 0, 0, "" }, "[)>\03606\035\011\034\035\036\036\004", -1, 0, "6A 62 61 62 63 64 6A", 1, "[)>RS 06 GS HT FS GS RS RS EOT; LatchB (0x6A) Macro98 (0x62) HT FS GS RS PAD" }, | |
| 190 /* 18*/ { UNICODE_MODE, -1, 17, -1, { 0, 0, "" }, "[)>\03612\03512345\036\004", -1, 0, "6A 63 11 67 17 2D 6A", 1, "[)>RS 12 GS A RS EOT; LatchB (0x6A) Macro99 (0x63) 1 2xShiftC (0x67) 23 45 PAD" }, | |
| 191 /* 19*/ { UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "[)>\03601Blah\004", -1, 0, "6A 64 10 11 22 4C 41 48 6A", 1, "[)>RS 01 Blah EOT; LatchB (0x6A) Macro100 (0x64) 0 1 B l a h PAD" }, | |
| 192 /* 20*/ { UNICODE_MODE, -1, 22, -1, { 0, 0, "" }, "[)>\03605\035A\004", -1, 0, "65 3B 09 1E 5E 10 15 5D 21 44", 1, "NOTE: no longer using Macro for malformed 05/06/12" }, | |
| 193 /* 21*/ { UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "[)>\03606A\004", -1, 0, "65 3B 09 1E 5E 10 16 21 44", 1, "NOTE: no longer using Macro for malformed 05/06/12" }, | |
| 194 /* 22*/ { UNICODE_MODE, -1, 13, -1, { 0, 0, "" }, "[)>\036991\036\004", -1, 0, "6A 64 19 19 11 64", 1, "[)>RS 99 1 RS EOT; LatchB (0x6A) Macro100 (0x64) 9 9 1 RS" }, | |
| 195 /* 23*/ { UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "1712345610", -1, 0, "6B 64 0C 22 38", 1, "FNC1 (0x6B) 17..10 12 34 56" }, | |
| 196 /* 24*/ { GS1_MODE, -1, -1, -1, { 0, 0, "" }, "[17]123456[10]123", -1, ZINT_WARN_NONCOMPLIANT, "64 0C 22 38 0C 66 13", 0, "17..10 12 34 56 12 ShiftB (0x66) 3; BWIPP does not allow bad month" }, | |
| 197 /* 25*/ { GS1_MODE, -1, -1, -1, { 0, 0, "" }, "[90]ABC[90]abc[90]123", -1, 0, "5A 6A 21 22 23 6B 19 10 41 42 43 6B 19 67 01 17 6A", 1, "90 LatchB (0x6A) A B C FNC1 (0x6B) 9 0 a b c FNC1 (0x6B) 9 2xShitfC (0x67) 01 23 PAD" }, | |
| 198 /* 26*/ { GS1_MODE | GS1PARENS_MODE, -1, -1, -1, { 0, 0, "" }, "(90)ABC(90)abc(90)123", -1, 0, "5A 6A 21 22 23 6B 19 10 41 42 43 6B 19 67 01 17 6A", 1, "90 LatchB (0x6A) A B C FNC1 (0x6B) 9 0 a b c FNC1 (0x6B) 9 2xShitfC (0x67) 01 23 PAD" }, | |
| 199 /* 27*/ { UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "99aA[{00\000", 9, 0, "6B 63 6A 41 21 3B 5B 10 10 65 40", 1, "FNC1 (0x6B) 99 LatchB (0x6A) a A [ { 0 0 ShiftA (0x65) NUL" }, | |
| 200 /* 28*/ { UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "\015\012", -1, 0, "66 60", 0, "ShiftB (0x66) CR/LF; BWIPP different encodation" }, | |
| 201 /* 29*/ { UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "A\015\012", -1, 0, "67 21 60", 0, "2xShiftB (0x67) A CR/LF; BWIPP different encodation" }, | |
| 202 /* 30*/ { UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "\015\015\012", -1, 0, "65 4D 4D 4A", 1, "LatchA (0x65) CR CR LF" }, | |
| 203 /* 31*/ { UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "ABCDE12345678", -1, 0, "6A 21 22 23 24 25 69 0C 22 38 4E", 1, "LatchB (0x6A) A B C D 4xShiftC 12 34 56 78" }, | |
| 204 /* 32*/ { UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "\000ABCD1234567890", 15, 0, "65 40 21 22 23 24 6A 0C 22 38 4E 5A 6A", 1, "LatchA (0x65) NULL A B C D LatchC (0x6A) 12 34 56 78 90 PAD" }, | |
| 205 /* 33*/ { DATA_MODE, -1, -1, 2 << 8, { 0, 0, "" }, "\141\142\143\144\145\200\201\202\203\204\377", -1, 0, "6A 41 42 43 44 45 70 31 5A 35 21 5A 5F 02 31", 1, "LatchB (0x6A) a b c d e BinaryLatch (0x70) 0x80 0x81 0x82 0x83 0x84 0xFF" }, | |
| 206 /* 34*/ { DATA_MODE, -1, -1, -1, { 0, 0, "" }, "\200\061\062\240\063\064\201\202\065\066", -1, 0, "6E 40 0C 6F 00 22 70 03 10 42 6E 15 16", 1, "UpperShiftA (0x6E) NUL 12 UpperShiftB (0x6F) SP 34 BinaryLatch (0x70) 0x81 0x82 TermB (0x6E) 5 6" }, | |
| 207 /* 35*/ { DATA_MODE, -1, -1, -1, { 0, 0, "" }, "\200\201\202\203\061\062\063\064", -1, 0, "70 13 56 0A 59 2C 67 0C 22", 1, "BinaryLatch (0x70) 0x80 0x81 0x82 0x83 Intr2xShiftC (0x67) 12 3" }, | |
| 208 /* 36*/ { DATA_MODE, -1, -1, -1, { 0, 0, "" }, "\001\200\201\202\203\204\200\201\202\203\204", -1, 0, "65 41 70 31 5A 35 21 5A 5F 31 5A 35 21 5A 5F", 1, "LatchA (0x65) SOH BinaryLatch (0x70) 0x80 0x81 0x82 0x83 0x80 0x81 0x82 0x83" }, | |
| 209 /* 37*/ { UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "\001abc\011\015\012\036", -1, 0, "65 41 65 41 42 43 61 60 64", 1, "LatchA (0x65) SOH 6xShiftB (0x65) a b c HT CR/LF RS" }, | |
| 210 /* 38*/ { UNICODE_MODE, -1, -1, -1, { 35, 35, "" }, "ABCDE", -1, 0, "6A 21 22 23 24 25 3A 3A 6C", 1, "LatchB (0x6A) A B C D E Z Z FNC2" }, | |
| 211 /* 39*/ { UNICODE_MODE, -1, -1, -1, { 9, 10, "" }, "1234567890", -1, 0, "6B 0C 22 38 4E 5A 65 19 21 6C", 1, "FNC1 (0x6B) 12 34 56 78 90 LatchA (0x65) 9 A FNC2" }, | |
| 212 /* 40*/ { UNICODE_MODE, -1, -1, -1, { 2, 3, "" }, "\001\002\003\004", -1, 0, "65 41 42 43 44 6A 12 13 6C", 1, "LatchA (0x65) <SOH> <STX> <ETX> <EOT> PAD 2 3 FNC2" }, | |
| 213 /* 41*/ { DATA_MODE, -1, -1, -1, { 1, 34, "" }, "\200\201\202\203", -1, 0, "70 13 56 0A 59 2C 6D 11 39 6C", 1, "BinaryLatch (0x70) (...) TermA (0x6D) 1 Y FNC2" }, | |
| 214 }; | |
| 215 const int data_size = ARRAY_SIZE(data); | |
| 216 int i, length, ret; | |
| 217 struct zint_symbol *symbol = NULL; | |
| 218 | |
| 219 char escaped[1024]; | |
| 220 char cmp_buf[32768]; | |
| 221 char cmp_msg[1024]; | |
| 222 | |
| 223 int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ | |
| 224 int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ | |
| 225 | |
| 226 testStartSymbol("test_input", &symbol); | |
| 227 | |
| 228 for (i = 0; i < data_size; i++) { | |
| 229 | |
| 230 if (testContinue(p_ctx, i)) continue; | |
| 231 | |
| 232 symbol = ZBarcode_Create(); | |
| 233 assert_nonnull(symbol, "Symbol not created\n"); | |
| 234 | |
| 235 debug |= ZINT_DEBUG_TEST; /* Needed to get codeword dump in errtxt */ | |
| 236 | |
| 237 length = testUtilSetSymbol(symbol, BARCODE_DOTCODE, data[i].input_mode, data[i].eci, | |
| 238 -1 /*option_1*/, data[i].option_2, data[i].option_3, -1 /*output_options*/, | |
| 239 data[i].data, data[i].length, debug); | |
| 240 if (data[i].structapp.count) { | |
| 241 symbol->structapp = data[i].structapp; | |
| 242 } | |
| 243 | |
| 244 ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); | |
| 245 assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); | |
| 246 | |
| 247 if (p_ctx->generate) { | |
| 248 printf(" /*%3d*/ { %s, %d, %d, %d, { %d, %d, \"%s\" }, \"%s\", %d, %s, \"%s\", %d, \"%s\" },\n", | |
| 249 i, testUtilInputModeName(data[i].input_mode), data[i].eci, data[i].option_2, data[i].option_3, | |
| 250 data[i].structapp.index, data[i].structapp.count, data[i].structapp.id, | |
| 251 testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), | |
| 252 data[i].length, testUtilErrorName(data[i].ret), symbol->errtxt, data[i].bwipp_cmp, data[i].comment); | |
| 253 } else { | |
| 254 assert_zero(strcmp((char *) symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); | |
| 255 | |
| 256 if (ret < ZINT_ERROR) { | |
| 257 if (do_bwipp && testUtilCanBwipp(i, symbol, -1, data[i].option_2, data[i].option_3, debug)) { | |
| 258 if (!data[i].bwipp_cmp) { | |
| 259 if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d %s not BWIPP compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), data[i].comment); | |
| 260 } else { | |
| 261 char modules_dump[200 * 200 + 1]; | |
| 262 assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); | |
| 263 ret = testUtilBwipp(i, symbol, -1, data[i].option_2, data[i].option_3, data[i].data, length, NULL, cmp_buf, sizeof(cmp_buf), NULL); | |
| 264 assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); | |
| 265 | |
| 266 ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, modules_dump); | |
| 267 assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n", | |
| 268 i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, modules_dump); | |
| 269 } | |
| 270 } | |
| 271 if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) { | |
| 272 int cmp_len, ret_len; | |
| 273 char modules_dump[200 * 200 + 1]; | |
| 274 assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); | |
| 275 ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); | |
| 276 assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); | |
| 277 | |
| 278 ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len); | |
| 279 assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", | |
| 280 i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, escaped); | |
| 281 } | |
| 282 } | |
| 283 } | |
| 284 | |
| 285 ZBarcode_Delete(symbol); | |
| 286 } | |
| 287 | |
| 288 testFinish(); | |
| 289 } | |
| 290 | |
| 291 static void test_encode(const testCtx *const p_ctx) { | |
| 292 int debug = p_ctx->debug; | |
| 293 | |
| 294 struct item { | |
| 295 int input_mode; | |
| 296 int option_2; | |
| 297 int option_3; | |
| 298 struct zint_structapp structapp; | |
| 299 char *data; | |
| 300 int length; | |
| 301 int ret; | |
| 302 | |
| 303 int expected_rows; | |
| 304 int expected_width; | |
| 305 int bwipp_cmp; | |
| 306 int zxingcpp_cmp; | |
| 307 char *comment; | |
| 308 char *expected; | |
| 309 }; | |
| 310 /* ISS DotCode, Rev 4.0, DRAFT 0.15, TSC Pre-PR #5, MAY 28, 2019 */ | |
| 311 static const struct item data[] = { | |
| 312 /* 0*/ { GS1_MODE, 64, -1, { 0, 0, "" }, "[01]00012345678905[17]201231[10]ABC123456", -1, 0, 9, 64, 1, 1, "ISS DotCode Rev 4.0 Figure 1 (left), same", | |
| 313 "1010000000101000101010000010000010001010100010101000101000001010" | |
| 314 "0100010001010001010001000001010100010100010001000100010101000001" | |
| 315 "1010001010000000101010100010001010000010101000000010100010100000" | |
| 316 "0000000101000101010001010100000001000100010001000100010100000001" | |
| 317 "1000001000000010100010101000001010100000101010100000100010001010" | |
| 318 "0101000101000001000001010001010100000001000100010101000101010001" | |
| 319 "1000000010100010001000001000100010101000100010000010101000100000" | |
| 320 "0001010100010001010100010001010000010001010000000101010001010101" | |
| 321 "1000100010001000100010100010001010001000101000101000100010000010" | |
| 322 }, | |
| 323 /* 1*/ { GS1_MODE, -1, -1, { 0, 0, "" }, "[01]00012345678905[17]201231[10]ABC123456", -1, 0, 20, 29, 1, 1, "ISS DotCode Rev 4.0 Figure 1 (right) (and Figure 10), same", | |
| 324 "10101000101010100010101000101" | |
| 325 "00010100010100010100000001010" | |
| 326 "00001010100010000000101010000" | |
| 327 "01000001010101010101010101000" | |
| 328 "10101010100000000010100010101" | |
| 329 "01000100000000000101010101010" | |
| 330 "00100010001010101000100000101" | |
| 331 "00000101010000000001010000010" | |
| 332 "10001010100010101010001010100" | |
| 333 "01010000000000010000000100010" | |
| 334 "00100000000010100000100000000" | |
| 335 "00010000000101000001000001000" | |
| 336 "10101000101000001010001010001" | |
| 337 "01010001010001010101000000010" | |
| 338 "00001000001010001010100000101" | |
| 339 "01000100010100000000010100010" | |
| 340 "10100010000010101000101010001" | |
| 341 "00010101000001010100010100010" | |
| 342 "10000010101000100000001000001" | |
| 343 "01000100010101010000000101010" | |
| 344 }, | |
| 345 /* 2*/ { GS1_MODE, -1, 1 << 8, { 0, 0, "" }, "[17]070620[10]ABC123456", -1, 0, 16, 23, 1, 1, "ISS DotCode Rev 4.0 Figure 5 (and Figure 6 top-left) when Mask = 0, same", | |
| 346 "10101000100010000000001" | |
| 347 "01000101010001010000000" | |
| 348 "00100010001000101000100" | |
| 349 "01010001010000000101010" | |
| 350 "00001000100010100010101" | |
| 351 "00000101010101010000010" | |
| 352 "00100010101000000010001" | |
| 353 "00010100000101000100010" | |
| 354 "00001000001000001010101" | |
| 355 "01010101010001000001010" | |
| 356 "10100000100010001000101" | |
| 357 "01000100000100010101000" | |
| 358 "10000010000010100010001" | |
| 359 "00010000010100010101010" | |
| 360 "10101000001000101010001" | |
| 361 "01000001010101010000010" | |
| 362 }, | |
| 363 /* 3*/ { GS1_MODE, -1, 2 << 8, { 0, 0, "" }, "[17]070620[10]ABC123456", -1, 0, 16, 23, 1, 1, "ISS DotCode Rev 4.0 Figure 6 top-right Mask = 1, same", | |
| 364 "10000000001010001000101" | |
| 365 "01010101000100000101000" | |
| 366 "00100010000000100000001" | |
| 367 "01010001000001000001000" | |
| 368 "10101010100000001010101" | |
| 369 "00000100010100000100010" | |
| 370 "00000000001010101010001" | |
| 371 "00010001010001000001000" | |
| 372 "00101010101000001010001" | |
| 373 "01000100000001010000000" | |
| 374 "10101000101000101000001" | |
| 375 "00010101000100010101010" | |
| 376 "10001000001010100000101" | |
| 377 "01010001010001000001010" | |
| 378 "10000010101010100010101" | |
| 379 "01000101000101010101010" | |
| 380 }, | |
| 381 /* 4*/ { GS1_MODE, -1, 3 << 8, { 0, 0, "" }, "[17]070620[10]ABC123456", -1, 0, 16, 23, 1, 1, "ISS DotCode Rev 4.0 Figure 6 bottom-left Mask = 2, same", | |
| 382 "10100000101010100010001" | |
| 383 "01000101000100000000010" | |
| 384 "10101010001010000010000" | |
| 385 "01010100010000010101010" | |
| 386 "00001000101000001000101" | |
| 387 "00000000000001010000010" | |
| 388 "00100010101010101000001" | |
| 389 "00010101010100010000000" | |
| 390 "00001000100010101010001" | |
| 391 "01000000010101010101000" | |
| 392 "10100010100000101000101" | |
| 393 "00000000000101000001010" | |
| 394 "10000010000010100010101" | |
| 395 "01010100010100010001010" | |
| 396 "10101010000000001010001" | |
| 397 "01010101000001000101010" | |
| 398 }, | |
| 399 /* 5*/ { GS1_MODE, -1, 4 << 8, { 0, 0, "" }, "[17]070620[10]ABC123456", -1, 0, 16, 23, 1, 1, "ISS DotCode Rev 4.0 Figure 6 bottom-right Mask = 3, same", | |
| 400 "10000000100000001010101" | |
| 401 "01010001010100010001000" | |
| 402 "10001000001010101010100" | |
| 403 "01010101000101010000010" | |
| 404 "10101010001000000010101" | |
| 405 "00000100000100010101000" | |
| 406 "00001000101010101000101" | |
| 407 "00000001010000000101010" | |
| 408 "00100010000000000000001" | |
| 409 "01010100010101010101010" | |
| 410 "10000000101010100010001" | |
| 411 "01010101000001010000010" | |
| 412 "10101010100000001000001" | |
| 413 "01000001010001000001010" | |
| 414 "10001000001010001000001" | |
| 415 "01010100000101000100010" | |
| 416 }, | |
| 417 /* 6*/ { GS1_MODE, -1, -1, { 0, 0, "" }, "[17]070620[10]ABC123456", -1, 0, 16, 23, 1, 1, "ISS DotCode Rev 4.0 Figure 6 top-right, auto Mask = 1, same", | |
| 418 "10000000001010001000101" | |
| 419 "01010101000100000101000" | |
| 420 "00100010000000100000001" | |
| 421 "01010001000001000001000" | |
| 422 "10101010100000001010101" | |
| 423 "00000100010100000100010" | |
| 424 "00000000001010101010001" | |
| 425 "00010001010001000001000" | |
| 426 "00101010101000001010001" | |
| 427 "01000100000001010000000" | |
| 428 "10101000101000101000001" | |
| 429 "00010101000100010101010" | |
| 430 "10001000001010100000101" | |
| 431 "01010001010001000001010" | |
| 432 "10000010101010100010101" | |
| 433 "01000101000101010101010" | |
| 434 }, | |
| 435 /* 7*/ { UNICODE_MODE, -1, 1 << 8, { 0, 0, "" }, "2741", -1, 0, 10, 13, 0, 0, "ISS DotCode Rev 4.0 Figure 7A top-left Mask = 0, same; BWIPP automatically primes mask; ZXing-C++ can't handle zero row", | |
| 436 "1010101010100" | |
| 437 "0000010001010" | |
| 438 "0000101000101" | |
| 439 "0101000000000" | |
| 440 "0000101010100" | |
| 441 "0100010101000" | |
| 442 "1000001000001" | |
| 443 "0101000101010" | |
| 444 "1000100010001" | |
| 445 "0000000000000" | |
| 446 }, | |
| 447 /* 8*/ { UNICODE_MODE, -1, 2 << 8, { 0, 0, "" }, "2741", -1, 0, 10, 13, 0, 1, "ISS DotCode Rev 4.0 Figure 7A top-right Mask = 1, same; BWIPP automatically primes mask", | |
| 448 "1010001000101" | |
| 449 "0000000100010" | |
| 450 "0000100000001" | |
| 451 "0101010001000" | |
| 452 "1000101000000" | |
| 453 "0101010101010" | |
| 454 "1000101000101" | |
| 455 "0100010101010" | |
| 456 "0000000010001" | |
| 457 "0001000001000" | |
| 458 }, | |
| 459 /* 9*/ { UNICODE_MODE, -1, 3 << 8, { 0, 0, "" }, "2741", -1, 0, 10, 13, 0, 1, "ISS DotCode Rev 4.0 Figure 7A bottom-left Mask = 2, same; BWIPP automatically primes mask", | |
| 460 "1010001010100" | |
| 461 "0001000000000" | |
| 462 "1000100010101" | |
| 463 "0100000101000" | |
| 464 "0000101000100" | |
| 465 "0100010000010" | |
| 466 "1000101010001" | |
| 467 "0101010001000" | |
| 468 "1000100010101" | |
| 469 "0001000100000" | |
| 470 }, | |
| 471 /* 10*/ { UNICODE_MODE, -1, 4 << 8, { 0, 0, "" }, "2741", -1, 0, 10, 13, 0, 1, "ISS DotCode Rev 4.0 Figure 7A bottom-right Mask = 3, same; BWIPP automatically primes mask", | |
| 472 "1010001000100" | |
| 473 "0001000001010" | |
| 474 "1000001000000" | |
| 475 "0101000100010" | |
| 476 "1000101010100" | |
| 477 "0101010000010" | |
| 478 "1000100000000" | |
| 479 "0100000101000" | |
| 480 "1000001010001" | |
| 481 "0101010101010" | |
| 482 }, | |
| 483 /* 11*/ { UNICODE_MODE, -1, 5 << 8, { 0, 0, "" }, "2741", -1, 0, 10, 13, 1, 1, "ISS DotCode Rev 4.0 Figure 7B top-left Mask = 0' (4), same", | |
| 484 "1010101010101" | |
| 485 "0000010001010" | |
| 486 "0000101000101" | |
| 487 "0101000000000" | |
| 488 "0000101010100" | |
| 489 "0100010101000" | |
| 490 "1000001000001" | |
| 491 "0101000101010" | |
| 492 "1000100010001" | |
| 493 "0100000000010" | |
| 494 }, | |
| 495 /* 12*/ { UNICODE_MODE, -1, 6 << 8, { 0, 0, "" }, "2741", -1, 0, 10, 13, 1, 1, "ISS DotCode Rev 4.0 Figure 7B top-right Mask = 1' (5), same", | |
| 496 "1010001000101" | |
| 497 "0000000100010" | |
| 498 "0000100000001" | |
| 499 "0101010001000" | |
| 500 "1000101000000" | |
| 501 "0101010101010" | |
| 502 "1000101000101" | |
| 503 "0100010101010" | |
| 504 "1000000010001" | |
| 505 "0101000001010" | |
| 506 }, | |
| 507 /* 13*/ { UNICODE_MODE, -1, 7 << 8, { 0, 0, "" }, "2741", -1, 0, 10, 13, 1, 1, "ISS DotCode Rev 4.0 Figure 7B bottom-left Mask = 2' (6), same", | |
| 508 "1010001010101" | |
| 509 "0001000000000" | |
| 510 "1000100010101" | |
| 511 "0100000101000" | |
| 512 "0000101000100" | |
| 513 "0100010000010" | |
| 514 "1000101010001" | |
| 515 "0101010001000" | |
| 516 "1000100010101" | |
| 517 "0101000100010" | |
| 518 }, | |
| 519 /* 14*/ { UNICODE_MODE, -1, 8 << 8, { 0, 0, "" }, "2741", -1, 0, 10, 13, 1, 1, "ISS DotCode Rev 4.0 Figure 7B bottom-right Mask = 3' (7), same", | |
| 520 "1010001000101" | |
| 521 "0001000001010" | |
| 522 "1000001000000" | |
| 523 "0101000100010" | |
| 524 "1000101010100" | |
| 525 "0101010000010" | |
| 526 "1000100000000" | |
| 527 "0100000101000" | |
| 528 "1000001010001" | |
| 529 "0101010101010" | |
| 530 }, | |
| 531 /* 15*/ { UNICODE_MODE, -1, -1, { 0, 0, "" }, "2741", -1, 0, 10, 13, 1, 1, "ISS DotCode Rev 4.0 Figure 7B bottom-left auto Mask = 2' (6), same", | |
| 532 "1010001010101" | |
| 533 "0001000000000" | |
| 534 "1000100010101" | |
| 535 "0100000101000" | |
| 536 "0000101000100" | |
| 537 "0100010000010" | |
| 538 "1000101010001" | |
| 539 "0101010001000" | |
| 540 "1000100010101" | |
| 541 "0101000100010" | |
| 542 }, | |
| 543 /* 16*/ { GS1_MODE, 40, -1, { 0, 0, "" }, "[01]00012345678905", -1, 0, 7, 40, 1, 1, "ISS DotCode Rev 4.0 Figure 8 top-left 7x40, Mask = 1, same", | |
| 544 "1010101010001000100010100010101000001000" | |
| 545 "0000010101000100010100010000010001000001" | |
| 546 "1010001000001000001000101010001000101000" | |
| 547 "0001010101000000010100010001000001010001" | |
| 548 "1010100010001010000010001010000000101010" | |
| 549 "0001010001010001000100000001010100010001" | |
| 550 "1000100010001000100010100010001010001000" | |
| 551 }, | |
| 552 /* 17*/ { GS1_MODE, 18, -1, { 0, 0, "" }, "[01]00012345678905", -1, 0, 17, 18, 1, 1, "ISS DotCode Rev 4.0 Figure 8 top-right 17x18 **NOT SAME** no matter what mask; but same as BWIPP and verified manually against tec-it", | |
| 553 "101000001000101010" | |
| 554 "010100000101010001" | |
| 555 "000000101000001010" | |
| 556 "000100010101000101" | |
| 557 "001010000000100010" | |
| 558 "010100000100010101" | |
| 559 "100010001000001010" | |
| 560 "010001000100010100" | |
| 561 "001000001010000010" | |
| 562 "010100000001010001" | |
| 563 "000000101010001010" | |
| 564 "000101000001000101" | |
| 565 "100010001010100010" | |
| 566 "000100010000000101" | |
| 567 "100010001010001010" | |
| 568 "010001010001000101" | |
| 569 "100010001000100010" | |
| 570 }, | |
| 571 /* 18*/ { GS1_MODE, 35, -1, { 0, 0, "" }, "[01]00012345678905", -1, 0, 8, 35, 1, 1, "ISS DotCode Rev 4.0 Figure 8 bottom-left 8x35, Mask = 3, same", | |
| 572 "10100010000000000010100000100010101" | |
| 573 "00010101010001000000010100010100000" | |
| 574 "10001000101010101010001010000010101" | |
| 575 "01010001000100000101000100010101010" | |
| 576 "10101000100000101000100010001000001" | |
| 577 "00010100010000010001010001010000000" | |
| 578 "10000010101010101010000010000010001" | |
| 579 "01000001000101000100010100010001000" | |
| 580 }, | |
| 581 /* 19*/ { GS1_MODE, 17, -1, { 0, 0, "" }, "[01]00012345678905", -1, 0, 18, 17, 1, 1, "ISS DotCode Rev 4.0 Figure 8 bottom-right 18x17 **NOT SAME** no matter what mask; same as BWIPP; verified manually against tec-it", | |
| 582 "10101000001000001" | |
| 583 "01000001010100010" | |
| 584 "00000000100010001" | |
| 585 "00010101000101010" | |
| 586 "10101000001010000" | |
| 587 "01000100010000000" | |
| 588 "00000010000000100" | |
| 589 "01010000000001000" | |
| 590 "10101010101000101" | |
| 591 "00000000010101010" | |
| 592 "00101010100000000" | |
| 593 "01000101000001010" | |
| 594 "10001000000010001" | |
| 595 "00000001010100010" | |
| 596 "00100010001000101" | |
| 597 "01010100010101000" | |
| 598 "10101010101010101" | |
| 599 "01010101000101010" | |
| 600 }, | |
| 601 /* 20*/ { UNICODE_MODE, 35, -1, { 0, 0, "" }, "Dots can be Square!", -1, 0, 18, 35, 1, 1, "ISS DotCode Rev 4.0 Figure 11 **NOT SAME**; same as BWIPP; verified manually against tec-it", | |
| 602 "10000010101000000000000000101010101" | |
| 603 "01010101000101000100010100000001000" | |
| 604 "00001000000010101000101010101010000" | |
| 605 "01000001000100000001010001000000000" | |
| 606 "00100010101010101000000010100000101" | |
| 607 "00000001010001010101010100010101000" | |
| 608 "10101000100010000010101010001010001" | |
| 609 "00010001010100010101000101000101010" | |
| 610 "00101010001000001010101000100000101" | |
| 611 "00010100010001010000000001010001010" | |
| 612 "00101000100010100000100000000000101" | |
| 613 "01010100010001010100010100000100000" | |
| 614 "10000010000000000010001000101010100" | |
| 615 "00010000000100010001000000010001010" | |
| 616 "10001000001010101010001010101000001" | |
| 617 "01000101010101000100000100010101000" | |
| 618 "10101000101000001000100010101000101" | |
| 619 "01000001000001000101010001000000010" | |
| 620 }, | |
| 621 /* 21*/ { GS1_MODE, -1, 1 << 8, { 0, 0, "" }, "[99]8766", -1, 0, 10, 13, 0, 0, "ISS DotCode Rev 4.0 Table G.1 Mask 0, same; BWIPP automatically primes mask; ZXing-C++ can't handle zero col", | |
| 622 "0000001010000" | |
| 623 "0001010000010" | |
| 624 "0000000010001" | |
| 625 "0100010101000" | |
| 626 "0010101000101" | |
| 627 "0100010101010" | |
| 628 "0010000010000" | |
| 629 "0101010000010" | |
| 630 "0010000000101" | |
| 631 "0101000101010" | |
| 632 }, | |
| 633 /* 22*/ { GS1_MODE, -1, 2 << 8, { 0, 0, "" }, "[99]8766", -1, 0, 10, 13, 0, 1, "ISS DotCode Rev 4.0 Table G.1 Mask 1, same; BWIPP automatically primes mask", | |
| 634 "0000100000001" | |
| 635 "0001010000000" | |
| 636 "0000000000001" | |
| 637 "0101010000010" | |
| 638 "1010101010101" | |
| 639 "0100000101010" | |
| 640 "0010000010100" | |
| 641 "0100010101000" | |
| 642 "0010101000101" | |
| 643 "0100010101000" | |
| 644 }, | |
| 645 /* 23*/ { GS1_MODE, -1, 3 << 8, { 0, 0, "" }, "[99]8766", -1, 0, 10, 13, 0, 1, "ISS DotCode Rev 4.0 Table G.1 Mask 2, same; BWIPP automatically primes mask", | |
| 646 "0000100010100" | |
| 647 "0000000000000" | |
| 648 "1000101010101" | |
| 649 "0100010101010" | |
| 650 "0010101000101" | |
| 651 "0101010101010" | |
| 652 "0010100000000" | |
| 653 "0101010100000" | |
| 654 "0000000010001" | |
| 655 "0100000001010" | |
| 656 }, | |
| 657 /* 24*/ { GS1_MODE, -1, 4 << 8, { 0, 0, "" }, "[99]8766", -1, 0, 10, 13, 0, 0, "ISS DotCode Rev 4.0 Table G.1 Mask 3, same; BWIPP automatically primes mask; ZXing-C++ can't handle zero col", | |
| 658 "0000000000000" | |
| 659 "0001010001000" | |
| 660 "1000001010000" | |
| 661 "0101010100010" | |
| 662 "1010101000101" | |
| 663 "0101010101010" | |
| 664 "0010001000101" | |
| 665 "0101010101010" | |
| 666 "1000000010000" | |
| 667 "0100000000010" | |
| 668 }, | |
| 669 /* 25*/ { GS1_MODE, -1, 5 << 8, { 0, 0, "" }, "[99]8766", -1, 0, 10, 13, 1, 1, "ISS DotCode Rev 4.0 Table G.1 Mask 0' (4), same", | |
| 670 "1000001010001" | |
| 671 "0001010000010" | |
| 672 "0000000010001" | |
| 673 "0100010101000" | |
| 674 "0010101000101" | |
| 675 "0100010101010" | |
| 676 "0010000010000" | |
| 677 "0101010000010" | |
| 678 "1010000000101" | |
| 679 "0101000101010" | |
| 680 }, | |
| 681 /* 26*/ { GS1_MODE, -1, 6 << 8, { 0, 0, "" }, "[99]8766", -1, 0, 10, 13, 1, 1, "ISS DotCode Rev 4.0 Table G.1 Mask 1' (5), same", | |
| 682 "1000100000001" | |
| 683 "0001010000000" | |
| 684 "0000000000001" | |
| 685 "0101010000010" | |
| 686 "1010101010101" | |
| 687 "0100000101010" | |
| 688 "0010000010100" | |
| 689 "0100010101000" | |
| 690 "1010101000101" | |
| 691 "0100010101010" | |
| 692 }, | |
| 693 /* 27*/ { GS1_MODE, -1, 7 << 8, { 0, 0, "" }, "[99]8766", -1, 0, 10, 13, 1, 1, "ISS DotCode Rev 4.0 Table G.1 Mask 2' (6), same", | |
| 694 "1000100010101" | |
| 695 "0000000000000" | |
| 696 "1000101010101" | |
| 697 "0100010101010" | |
| 698 "0010101000101" | |
| 699 "0101010101010" | |
| 700 "0010100000000" | |
| 701 "0101010100000" | |
| 702 "1000000010001" | |
| 703 "0100000001010" | |
| 704 }, | |
| 705 /* 28*/ { GS1_MODE, -1, 8 << 8, { 0, 0, "" }, "[99]8766", -1, 0, 10, 13, 1, 1, "ISS DotCode Rev 4.0 Table G.1 Mask 3' (7), same", | |
| 706 "1000000000001" | |
| 707 "0001010001000" | |
| 708 "1000001010000" | |
| 709 "0101010100010" | |
| 710 "1010101000101" | |
| 711 "0101010101010" | |
| 712 "0010001000101" | |
| 713 "0101010101010" | |
| 714 "1000000010001" | |
| 715 "0100000000010" | |
| 716 }, | |
| 717 /* 29*/ { GS1_MODE, -1, -1, { 0, 0, "" }, "[99]8766", -1, 0, 10, 13, 1, 1, "ISS DotCode Rev 4.0 Table G.1 auto Mask 0' (4); all mask scores match Table G.1", | |
| 718 "1000001010001" | |
| 719 "0001010000010" | |
| 720 "0000000010001" | |
| 721 "0100010101000" | |
| 722 "0010101000101" | |
| 723 "0100010101010" | |
| 724 "0010000010000" | |
| 725 "0101010000010" | |
| 726 "1010000000101" | |
| 727 "0101000101010" | |
| 728 }, | |
| 729 /* 30*/ { UNICODE_MODE, 6, -1, { 0, 0, "" }, "A", -1, 0, 19, 6, 1, 1, "ISS DotCode Rev 4.0 5.2.1.4 2) Table 4, 1 padding dot available; verified manually against tec-it", | |
| 730 "101000" | |
| 731 "000101" | |
| 732 "101010" | |
| 733 "000001" | |
| 734 "100010" | |
| 735 "000100" | |
| 736 "001010" | |
| 737 "000101" | |
| 738 "101000" | |
| 739 "010000" | |
| 740 "100010" | |
| 741 "010000" | |
| 742 "000010" | |
| 743 "000101" | |
| 744 "101010" | |
| 745 "000001" | |
| 746 "101000" | |
| 747 "010000" | |
| 748 "101000" | |
| 749 }, | |
| 750 /* 31*/ { UNICODE_MODE, 94, -1, { 0, 0, "" }, "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRS", -1, 0, 37, 94, 1, 1, "Interleaved R-S; verified manually against tec-it", | |
| 751 "1000001010000000100010000010101010101000001000100000001010101000001000001000101010001000101010" | |
| 752 "0101010000000101000001010001010001010100010001000001000000010101010000000101010100010001010100" | |
| 753 "0010101000100010000010101010000000101010000010101000001000100010100000100010100010001000101000" | |
| 754 "0000000100010101000001010000010000010101010100010100000100000101000100010001000001010001010001" | |
| 755 "0010100000100010101000001000101010000010001000001010100000101000101010000010001000101010100010" | |
| 756 "0100000101010001010001000101000001000100000101010001000101000100010100000100010100010001010100" | |
| 757 "1010000000100010100000101010000010101000001000001010001010000010001010100000101010100000100000" | |
| 758 "0001010100000101000001000000010001010100000101000100010101000001000101000100010000010101010001" | |
| 759 "1010001010001010000000100000101010100000100010101000000010100010001010100010000010100010001010" | |
| 760 "0001000100010100010001010000000101010100010000010100000100000101010100010000010100010001000001" | |
| 761 "1000001010001010100010000010001000100010100010100010000010001000101010100000101000001000101010" | |
| 762 "0101000001000101000100000001010001010101010001000001000000010001010100010101010000010100000001" | |
| 763 "0000100000001010100010101000000010001010001010000000101010001000101010001000101000100000100010" | |
| 764 "0000000100000100000101010101000000010101010001000100010001000101010001000100010000010100010101" | |
| 765 "0010101000001010001000101000000000101010001010000010101010000010001000100000001010101010001010" | |
| 766 "0100010001010100010000010100010001010100010000010001000100000100010101000101000100000101010001" | |
| 767 "1000001000100010101010101000000010001000001010000010101010000010101010000000100010001000101000" | |
| 768 "0000010000010101010000010101000000010101000001000101000100010001000101010001000100010000010100" | |
| 769 "1000001000101010000010001000001000101010100000100000001010001010101000000010001010101010001000" | |
| 770 "0100010001010001000100010000010100000100010100010100010001000001010100010101000100000101000101" | |
| 771 "1010000000101000100000001000101010100010000000101010101010000010101000000010100010001000100010" | |
| 772 "0100000101010000010100010001010100010000010101000100000100000101000001010100010000000101010001" | |
| 773 "1000001000001010001010001000101000001000101010000010101000100010100000101000100000001000101010" | |
| 774 "0101010100010001010101000000010101010000010100000100010100010001000100000100010001010100010100" | |
| 775 "1000100000101000000010100010101000001010100010100000100000101010000010101000100000001010000000" | |
| 776 "0001000001000101000101010000010001000100000101010001000100010100000101000101000100000101010001" | |
| 777 "0000000010001000101000100000100000101010101000000010101010001000100010001000101010001000100010" | |
| 778 "0101010100010000000100010101010001010100000001010101000001000001000001010100000101010001010101" | |
| 779 "1000100010101000100000101010001000101010000010001010001010001010000010100010100010000000100000" | |
| 780 "0000010101010000010101000000010101000001000101000100010001000101010001000100010000010100010000" | |
| 781 "1000101010000010001000001000101010100000100000001010001010101000000010001010101010001000000010" | |
| 782 "0100000101000001010001010000000100010100010100010001000001010100010101000100000101000101010000" | |
| 783 "0000001010001000100010100010000010101000100010001000101000001000100000101000100010100010001010" | |
| 784 "0101010000010100010000010100000101010100000101000001000000010101000101000101010000000101010101" | |
| 785 "1000001010001010001000101000001000101010000010101000100010100000101000100000001000101010100000" | |
| 786 "0001000101010100000001010101000001010000010001010001000100010000010001000101010001010001000001" | |
| 787 "0010001000001010101000000010101000101000001000001010100000101010001000000010100000001010101000" | |
| 788 }, | |
| 789 /* 32*/ { GS1_MODE, 50, -1, { 0, 0, "" }, "[17]070620[10]ABC123456", -1, 0, 7, 50, 1, 1, "GS1 Gen Spec Figure 5.1-8.", | |
| 790 "10000010101000100010101010001000000010100000100000" | |
| 791 "01000101000101010100000100010000010001000001010101" | |
| 792 "00001010001000101000101000100010001010100000000010" | |
| 793 "01000001000100000101010101010001000001000101000001" | |
| 794 "10001000001010100010001010100000100010100010000010" | |
| 795 "00010001010000000100010101000100010001010001000101" | |
| 796 "10001000001010101000001000100010100010100000101010" | |
| 797 }, | |
| 798 /* 33*/ { UNICODE_MODE, 200, -1, { 0, 0, "" }, "123456789012345678901234567890123456789012345678901234567890", -1, 0, 5, 200, 1, 1, "Max cols", | |
| 799 "10101000100010101010000010101000000010001000100000101010100010100000101000100010000000101000101010001010100000100000101010100000001000101000001010100010001010000010001010001010100000100010101000000010" | |
| 800 "00010101010000000101000100010001000101000101000100010001000001010001000001010100000001000101010000000101010100010101010000010001000101010001000001000001010000010100010001010101000001000001010100000001" | |
| 801 "10100010000000100010101000101010100000001010001000100000101000101000001000101010001000000010101010100010101000000010100010001000001010100000101000100000101010100010000000001000001010101000101010100000" | |
| 802 "00010001010001010000000101000100010001010000010000010100010100000100010101010001000101000000010100010001010100010000010100000101000100010100000101010000000101000001010100010100010001000101000001010001" | |
| 803 "10100010001010101000000010001000001010001010001000001010100010000000101010001010000010101010000000101000100010100010100000100010100010001010100000001010101000001010000000001000101000101010000010101010" | |
| 804 }, | |
| 805 /* 34*/ { UNICODE_MODE, 19, -1, { 0, 0, "" }, "4", -1, 0, 6, 19, 1, 1, "Mask 1 selected", | |
| 806 "1010100000101000101" | |
| 807 "0100000000010001010" | |
| 808 "0010101010000000000" | |
| 809 "0000010100000100000" | |
| 810 "1000100010001010001" | |
| 811 "0001010101010101010" | |
| 812 }, | |
| 813 /* 35*/ { UNICODE_MODE, 19, 3 << 8, { 0, 0, "" }, "4", -1, 0, 6, 19, 0, 1, "Mask 2 specified, unlit right edge mask; BWIPP automatically primes mask", | |
| 814 "1010101010000000100" | |
| 815 "0000000101000100010" | |
| 816 "1010100000001010100" | |
| 817 "0000010101010000000" | |
| 818 "1000001010100010100" | |
| 819 "0101000100010001010" | |
| 820 }, | |
| 821 /* 36*/ { UNICODE_MODE, 19, 7 << 8, { 0, 0, "" }, "4", -1, 0, 6, 19, 1, 1, "Mask 2' specified", | |
| 822 "1010101010000000101" | |
| 823 "0000000101000100010" | |
| 824 "1010100000001010100" | |
| 825 "0000010101010000000" | |
| 826 "1000001010100010101" | |
| 827 "0101000100010001010" | |
| 828 }, | |
| 829 /* 37*/ { GS1_MODE, -1, -1, { 0, 0, "" }, "[10]12[20]12", -1, 0, 12, 17, 1, 1, "Code Set C with FNC1", | |
| 830 "10100000001000001" | |
| 831 "00010100010101010" | |
| 832 "10001000100000001" | |
| 833 "01010100000101000" | |
| 834 "10000010000010001" | |
| 835 "01010001010100010" | |
| 836 "00001010100000001" | |
| 837 "00000101010001010" | |
| 838 "10101000001010001" | |
| 839 "01010101000101010" | |
| 840 "10000010100000101" | |
| 841 "01000100010101010" | |
| 842 }, | |
| 843 /* 38*/ { UNICODE_MODE, -1, -1, { 0, 0, "" }, "1234\011\034\035\036", -1, 0, 14, 21, 1, 1, "Code Set B HT FS GS RS", | |
| 844 "100010001000001010101" | |
| 845 "010001000001000001000" | |
| 846 "100010100010101010001" | |
| 847 "010100000000010100010" | |
| 848 "101000100010001000000" | |
| 849 "010000010000000001000" | |
| 850 "100000101010100000000" | |
| 851 "000101010101010000000" | |
| 852 "001000001010101010101" | |
| 853 "000000000100010001010" | |
| 854 "101010000000000000101" | |
| 855 "000101010101000101010" | |
| 856 "001010101000101010001" | |
| 857 "010101010001000101000" | |
| 858 }, | |
| 859 /* 39*/ { UNICODE_MODE, 17, -1, { 0, 0, "" }, "abcd\015\012", -1, 0, 14, 17, 1, 1, "Code Set B CRLF", | |
| 860 "00001000001000101" | |
| 861 "01000101010001000" | |
| 862 "10100000100010101" | |
| 863 "01000001010000010" | |
| 864 "00100010101000101" | |
| 865 "01010000010101000" | |
| 866 "10101010000010001" | |
| 867 "01000001000100010" | |
| 868 "00001010101010101" | |
| 869 "00000100010100010" | |
| 870 "00101010000000000" | |
| 871 "00010100010000000" | |
| 872 "10100000001010000" | |
| 873 "01010001000101000" | |
| 874 }, | |
| 875 /* 40*/ { DATA_MODE, -1, -1, { 0, 0, "" }, "\101\102\103\104\105\106\107\200\101\102\240\101", -1, 0, 18, 27, 1, 1, "Code Set B Upper Shift A Upper Shift B", | |
| 876 "101010100000101000101000001" | |
| 877 "010100010101000100010101000" | |
| 878 "000010001010100000101010101" | |
| 879 "010100010100000001010101000" | |
| 880 "001010000010001010101000101" | |
| 881 "000001000001010101000000010" | |
| 882 "101000101010100000001000001" | |
| 883 "000101000001010101010100010" | |
| 884 "001010101000101010100010101" | |
| 885 "000101010001000100010001010" | |
| 886 "000000001000100000000000001" | |
| 887 "010000000000010100000100010" | |
| 888 "101010101010101010101010101" | |
| 889 "000101010001000100010101010" | |
| 890 "100000000000100000000010101" | |
| 891 "000000010100010000000100010" | |
| 892 "100010101000000010001000001" | |
| 893 "010001000100000101000001010" | |
| 894 }, | |
| 895 /* 41*/ { UNICODE_MODE, -1, -1, { 0, 0, "" }, "ABCDEF\001G1234H", -1, 0, 16, 25, 1, 1, "Code Set A 4x Shift C", | |
| 896 "0010101010100000100000101" | |
| 897 "0000000100010101000001000" | |
| 898 "1000100000101000100000101" | |
| 899 "0101000001010100000101010" | |
| 900 "0000000000101010001010000" | |
| 901 "0100000000010101010100000" | |
| 902 "0010101010000000101010101" | |
| 903 "0100010101000000010100000" | |
| 904 "1010001000100010001000101" | |
| 905 "0101010001010000000001010" | |
| 906 "0000001010100010001010101" | |
| 907 "0001000000000001010001000" | |
| 908 "0010100000101010100000000" | |
| 909 "0101010100000100010100010" | |
| 910 "1010101010001000101000000" | |
| 911 "0000010100010101000101010" | |
| 912 }, | |
| 913 /* 42*/ { UNICODE_MODE, -1, -1, { 0, 0, "" }, "ABCDEF\001ab\011\034\035\036\001A", -1, 0, 19, 28, 1, 1, "Code Set A 6x Shift B HT FS GS RS", | |
| 914 "1000001010100010101010101010" | |
| 915 "0101000000010100010101010001" | |
| 916 "0010001010100000101000001010" | |
| 917 "0001000101000001010001010000" | |
| 918 "1000001010100000101010001000" | |
| 919 "0100010101010001000000010001" | |
| 920 "0000001010100010100010000010" | |
| 921 "0000010100000001010100010101" | |
| 922 "0000001010001010101000001010" | |
| 923 "0100010101010101000001010000" | |
| 924 "0010000000101000101000000010" | |
| 925 "0101000101000101000101000001" | |
| 926 "1000100000001010101000001000" | |
| 927 "0101000001010000010001010100" | |
| 928 "1010000000100010001010100010" | |
| 929 "0101010100000001000100010001" | |
| 930 "1010000010100000100000101000" | |
| 931 "0001010000010100000100010101" | |
| 932 "1010100010000000101010101010" | |
| 933 }, | |
| 934 /* 43*/ { UNICODE_MODE, -1, -1, { 0, 0, "" }, "ABCDEF\001abcdefgA", -1, 0, 19, 28, 1, 1, "Code Set A Latch B", | |
| 935 "1010001010100010101010101010" | |
| 936 "0100010101010000000100010001" | |
| 937 "1010000010100000100010101000" | |
| 938 "0001010001000001010100000001" | |
| 939 "0010001010100000000010101010" | |
| 940 "0101000000010100010101000001" | |
| 941 "0000101010100000001000001010" | |
| 942 "0000010101010000000100010101" | |
| 943 "0000101010100000101000001010" | |
| 944 "0001010100010001010000000101" | |
| 945 "1010000010100010100000001010" | |
| 946 "0101000101000000010001010001" | |
| 947 "1000100000001010101000001000" | |
| 948 "0101000001010000010100010001" | |
| 949 "1010000000100010001010100010" | |
| 950 "0101010100000001000100010001" | |
| 951 "1010000010100000100000101000" | |
| 952 "0001010000010100000100010101" | |
| 953 "1010100010000000101010101010" | |
| 954 }, | |
| 955 /* 44*/ { DATA_MODE, -1, -1, { 0, 0, "" }, "\200\200\200\200\061\062\063\064\065\066\067\070\071\060\061\062\063\064\065\066\200", -1, 0, 20, 29, 1, 1, "Binary Latch C", | |
| 956 "10101010000010100010101010001" | |
| 957 "01010001000101010001000000010" | |
| 958 "00001010101000101010001000001" | |
| 959 "00010100000001000101010100000" | |
| 960 "00100000101000100000000000101" | |
| 961 "00000001010101010100000101000" | |
| 962 "10101000001010000010101000100" | |
| 963 "01010100010000000101000000010" | |
| 964 "10101000101000001010100010100" | |
| 965 "00010101000101010001000101010" | |
| 966 "10000010101000100010101010001" | |
| 967 "01000001010100000001010001010" | |
| 968 "00001010101010101000000010001" | |
| 969 "00010100000000010000010101010" | |
| 970 "00101000100010001000101000001" | |
| 971 "00000100000101010101000000000" | |
| 972 "10000000000000001000000010101" | |
| 973 "01010001010001010000010101000" | |
| 974 "10000010100010000010001000101" | |
| 975 "01000100000100010001010101010" | |
| 976 }, | |
| 977 /* 45*/ { UNICODE_MODE, -1, -1, { 11, 24, "" }, "ABCDEFG", -1, 0, 16, 23, 1, 1, "Structured Append", | |
| 978 "10101000001000101000001" | |
| 979 "01010101000001010001010" | |
| 980 "10101010100010000000001" | |
| 981 "01000001010000010100010" | |
| 982 "10000000101010100010101" | |
| 983 "01010100010101010101000" | |
| 984 "10000010101010101000101" | |
| 985 "00010100010100000000010" | |
| 986 "00101000100000001010001" | |
| 987 "00010100000001000100000" | |
| 988 "00100010000000001010101" | |
| 989 "01010101010001010101000" | |
| 990 "10000000001010000000001" | |
| 991 "00000000010100010001010" | |
| 992 "10001010101000100010001" | |
| 993 "01000001000100010101010" | |
| 994 }, | |
| 995 /* 46*/ { UNICODE_MODE, -1, -1, { 0, 0, "" }, "1234", -1, 0, 10, 13, 1, 1, "", | |
| 996 "0010100000001" | |
| 997 "0000000001010" | |
| 998 "1000000010101" | |
| 999 "0101010101000" | |
| 1000 "1000101000000" | |
| 1001 "0100010100010" | |
| 1002 "1000000010100" | |
| 1003 "0101010000010" | |
| 1004 "1000101000001" | |
| 1005 "0101010101000" | |
| 1006 }, | |
| 1007 /* 47*/ { UNICODE_MODE, -1, -1, { 0, 0, "" }, "[)>\03605\035101\036\004", -1, 0, 12, 17, 1, 1, "Macro 05", | |
| 1008 "10000010001000101" | |
| 1009 "00000001000000010" | |
| 1010 "10001010100010001" | |
| 1011 "01010000010000000" | |
| 1012 "10001010000010001" | |
| 1013 "01000000010000010" | |
| 1014 "10100010101000001" | |
| 1015 "01010100000001010" | |
| 1016 "00001000101010101" | |
| 1017 "01010001000101000" | |
| 1018 "10101010101010101" | |
| 1019 "01010001010101010" | |
| 1020 }, | |
| 1021 /* 48*/ { UNICODE_MODE, -1, -1, { 0, 0, "" }, "[)>\03607Text\036\004", -1, 0, 14, 21, 1, 1, "Macro 07 (free form text)", | |
| 1022 "100010001000001000101" | |
| 1023 "010001000000010101010" | |
| 1024 "000010101000100000101" | |
| 1025 "010100000000010000000" | |
| 1026 "001000100000000000100" | |
| 1027 "010101010001010101010" | |
| 1028 "101010101010100010100" | |
| 1029 "010000010101000000000" | |
| 1030 "001010001000001010001" | |
| 1031 "000000000101010101010" | |
| 1032 "001000000010001000001" | |
| 1033 "000101000101000100000" | |
| 1034 "100010101010100010101" | |
| 1035 "000001010100010100000" | |
| 1036 }, | |
| 1037 /* 49*/ { UNICODE_MODE, -1, -1, { 0, 0, "" }, "[)>\03605\035Študentska št.\0352198390\036\004", -1, ZINT_WARN_USES_ECI, 23, 34, 1, 1, "Macro 05 with ECI", | |
| 1038 "1010101000100000101000001010000010" | |
| 1039 "0101000001000101010100000101000001" | |
| 1040 "1000101000101000100010100010001000" | |
| 1041 "0000010001010001000100010001010000" | |
| 1042 "0000101000100010000010001010101000" | |
| 1043 "0001010001000100010000010101010100" | |
| 1044 "0000100010100000101010001000001010" | |
| 1045 "0100010100010100010000010101000001" | |
| 1046 "1010101000100010000010000010001010" | |
| 1047 "0101000100000100010001010000010001" | |
| 1048 "0010101000100010001000001010101000" | |
| 1049 "0100010100010001000101010000010000" | |
| 1050 "0000101010100010000010100010100010" | |
| 1051 "0101000000000001010001010001000001" | |
| 1052 "0010100010000000101010100010100010" | |
| 1053 "0101000100010101000100000100010100" | |
| 1054 "0010100010000010101000101000001000" | |
| 1055 "0001000100000101000100010000010101" | |
| 1056 "1000100010100000100010001010100010" | |
| 1057 "0101010001000001000101000101000100" | |
| 1058 "0010000010001010100010001000001000" | |
| 1059 "0100000001000100010001010100010101" | |
| 1060 "1010001000001010101000000010101000" | |
| 1061 }, | |
| 1062 /* 50*/ { UNICODE_MODE, -1, -1, { 0, 0, "" }, "[)>\03607Τεχτ\036\004", -1, ZINT_WARN_USES_ECI, 17, 26, 1, 1, "Macro 07 with ECI", | |
| 1063 "10001010001000100000101000" | |
| 1064 "00010101000101000000010101" | |
| 1065 "00100010100000100010001000" | |
| 1066 "00010101000101010101000100" | |
| 1067 "10101000100010001010000000" | |
| 1068 "00000100010100010100000001" | |
| 1069 "00001010101000100000001010" | |
| 1070 "01010000010001010100010100" | |
| 1071 "00000010100010101010000010" | |
| 1072 "00010101000101000101000001" | |
| 1073 "00101000101000100010001000" | |
| 1074 "00010101000100000001010100" | |
| 1075 "10100010000010001010001000" | |
| 1076 "00010100010100010000010001" | |
| 1077 "10001000101000101010001000" | |
| 1078 "01000101010100000000000101" | |
| 1079 "10100010000010101010000010" | |
| 1080 }, | |
| 1081 }; | |
| 1082 const int data_size = ARRAY_SIZE(data); | |
| 1083 int i, length, ret; | |
| 1084 struct zint_symbol *symbol = NULL; | |
| 1085 | |
| 1086 char escaped[1024]; | |
| 1087 char cmp_buf[8192]; | |
| 1088 char cmp_msg[1024]; | |
| 1089 | |
| 1090 int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ | |
| 1091 int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ | |
| 1092 | |
| 1093 testStartSymbol("test_encode", &symbol); | |
| 1094 | |
| 1095 for (i = 0; i < data_size; i++) { | |
| 1096 | |
| 1097 if (testContinue(p_ctx, i)) continue; | |
| 1098 | |
| 1099 symbol = ZBarcode_Create(); | |
| 1100 assert_nonnull(symbol, "Symbol not created\n"); | |
| 1101 | |
| 1102 length = testUtilSetSymbol(symbol, BARCODE_DOTCODE, data[i].input_mode, -1 /*eci*/, -1, data[i].option_2, data[i].option_3, -1 /*output_options*/, data[i].data, data[i].length, debug); | |
| 1103 if (data[i].structapp.count) { | |
| 1104 symbol->structapp = data[i].structapp; | |
| 1105 } | |
| 1106 | |
| 1107 ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); | |
| 1108 assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); | |
| 1109 | |
| 1110 if (p_ctx->generate) { | |
| 1111 printf(" /*%3d*/ { %s, %d, %s, { %d, %d, \"%s\" }, \"%s\", %d, %s, %d, %d, %d, %d, \"%s\",\n", | |
| 1112 i, testUtilInputModeName(data[i].input_mode), data[i].option_2, | |
| 1113 testUtilOption3Name(BARCODE_DOTCODE, data[i].option_3), | |
| 1114 data[i].structapp.index, data[i].structapp.count, data[i].structapp.id, | |
| 1115 testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length, | |
| 1116 testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].zxingcpp_cmp, data[i].comment); | |
| 1117 testUtilModulesPrint(symbol, " ", "\n"); | |
| 1118 printf(" },\n"); | |
| 1119 } else { | |
| 1120 if (ret < ZINT_ERROR) { | |
| 1121 int width, row; | |
| 1122 | |
| 1123 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); | |
| 1124 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); | |
| 1125 | |
| 1126 ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row); | |
| 1127 assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data); | |
| 1128 | |
| 1129 if (do_bwipp && testUtilCanBwipp(i, symbol, -1, data[i].option_2, data[i].option_3, debug)) { | |
| 1130 if (!data[i].bwipp_cmp) { | |
| 1131 if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d %s not BWIPP compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), data[i].comment); | |
| 1132 } else { | |
| 1133 ret = testUtilBwipp(i, symbol, -1, data[i].option_2, data[i].option_3, data[i].data, length, NULL, cmp_buf, sizeof(cmp_buf), NULL); | |
| 1134 assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); | |
| 1135 | |
| 1136 ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, data[i].expected); | |
| 1137 assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n", | |
| 1138 i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, data[i].expected); | |
| 1139 } | |
| 1140 } | |
| 1141 if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) { | |
| 1142 if (!data[i].zxingcpp_cmp) { | |
| 1143 if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d %s not ZXing-C++ compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), data[i].comment); | |
| 1144 } else { | |
| 1145 int cmp_len, ret_len; | |
| 1146 char modules_dump[16384]; | |
| 1147 assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); | |
| 1148 ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); | |
| 1149 assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); | |
| 1150 | |
| 1151 ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len); | |
| 1152 assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", | |
| 1153 i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, escaped); | |
| 1154 } | |
| 1155 } | |
| 1156 } | |
| 1157 } | |
| 1158 | |
| 1159 ZBarcode_Delete(symbol); | |
| 1160 } | |
| 1161 | |
| 1162 testFinish(); | |
| 1163 } | |
| 1164 | |
| 1165 static void test_encode_segs(const testCtx *const p_ctx) { | |
| 1166 int debug = p_ctx->debug; | |
| 1167 | |
| 1168 struct item { | |
| 1169 int input_mode; | |
| 1170 int option_2; | |
| 1171 int option_3; | |
| 1172 struct zint_structapp structapp; | |
| 1173 struct zint_seg segs[3]; | |
| 1174 int ret; | |
| 1175 | |
| 1176 int expected_rows; | |
| 1177 int expected_width; | |
| 1178 int bwipp_cmp; | |
| 1179 int zxingcpp_cmp; | |
| 1180 char *comment; | |
| 1181 char *expected; | |
| 1182 }; | |
| 1183 /* ISS DotCode, Rev 4.0, DRAFT 0.15, TSC Pre-PR #5, MAY 28, 2019 */ | |
| 1184 static const struct item data[] = { | |
| 1185 /* 0*/ { UNICODE_MODE, 18, -1, { 0, 0, "" }, { { TU("¶"), -1, 0 }, { TU("Ж"), -1, 7 }, { TU(""), 0, 0 } }, 0, 13, 18, 1, 1, "ISS DotCode Rev 4.0 13.5 example **NOT SAME** different encodation", | |
| 1186 "100000001010101010" | |
| 1187 "000100000100010101" | |
| 1188 "001010000010101000" | |
| 1189 "010101010001010001" | |
| 1190 "100010100010000000" | |
| 1191 "010100010100000101" | |
| 1192 "001000101000000010" | |
| 1193 "000001010101000100" | |
| 1194 "100010100010000010" | |
| 1195 "000001000101000001" | |
| 1196 "101000101010100010" | |
| 1197 "010100000000010001" | |
| 1198 "100000101010000010" | |
| 1199 }, | |
| 1200 /* 1*/ { UNICODE_MODE, 18, -1, { 0, 0, "" }, { { TU("¶"), -1, 0 }, { TU("Ж"), -1, 0 }, { TU(""), 0, 0 } }, ZINT_WARN_USES_ECI, 13, 18, 1, 1, "ISS DotCode Rev 4.0 13.5 example auto-ECI", | |
| 1201 "100000001010101010" | |
| 1202 "000100000100010101" | |
| 1203 "001010000010101000" | |
| 1204 "010101010001010001" | |
| 1205 "100010100010000000" | |
| 1206 "010100010100000101" | |
| 1207 "001000101000000010" | |
| 1208 "000001010101000100" | |
| 1209 "100010100010000010" | |
| 1210 "000001000101000001" | |
| 1211 "101000101010100010" | |
| 1212 "010100000000010001" | |
| 1213 "100000101010000010" | |
| 1214 }, | |
| 1215 /* 2*/ { UNICODE_MODE, -1, -1, { 0, 0, "" }, { { TU("Ж"), -1, 7 }, { TU("¶"), -1, 0 }, { TU(""), 0, 0 } }, 0, 14, 21, 1, 1, "ISS DotCode Rev 4.0 13.5 example inverted", | |
| 1216 "100010001010101010000" | |
| 1217 "000100000101000001010" | |
| 1218 "101000101000001000101" | |
| 1219 "000001010100000101000" | |
| 1220 "001010101010100010001" | |
| 1221 "010001000001010101000" | |
| 1222 "101000101000101010100" | |
| 1223 "010101010001010001000" | |
| 1224 "100010001000000000100" | |
| 1225 "010100000001000100010" | |
| 1226 "001000100010000000101" | |
| 1227 "000000000100010100010" | |
| 1228 "100010001000100000001" | |
| 1229 "010101000100010001000" | |
| 1230 }, | |
| 1231 /* 3*/ { UNICODE_MODE, -1, -1, { 0, 0, "" }, { { TU("Ж"), -1, 0 }, { TU("¶"), -1, 0 }, { TU(""), 0, 0 } }, ZINT_WARN_USES_ECI, 14, 21, 1, 1, "ISS DotCode Rev 4.0 13.5 example inverted auto-ECI", | |
| 1232 "100010001010101010000" | |
| 1233 "000100000101000001010" | |
| 1234 "101000101000001000101" | |
| 1235 "000001010100000101000" | |
| 1236 "001010101010100010001" | |
| 1237 "010001000001010101000" | |
| 1238 "101000101000101010100" | |
| 1239 "010101010001010001000" | |
| 1240 "100010001000000000100" | |
| 1241 "010100000001000100010" | |
| 1242 "001000100010000000101" | |
| 1243 "000000000100010100010" | |
| 1244 "100010001000100000001" | |
| 1245 "010101000100010001000" | |
| 1246 }, | |
| 1247 /* 4*/ { UNICODE_MODE, 95, -1, { 0, 0, "" }, { { TU("product:Google Pixel 4a - 128 GB of Storage - Black;price:$439.97"), -1, 3 }, { TU("品名:Google 谷歌 Pixel 4a -128 GB的存储空间-黑色;零售价:¥3149.79"), -1, 29 }, { TU("Produkt:Google Pixel 4a - 128 GB Speicher - Schwarz;Preis:444,90 €"), -1, 17 } }, 0, 64, 95, 0, 1, "AIM ITS/04-023:2022 Annex A example; BWIPP different encodation", | |
| 1248 "10101000100000001010000000101000101010100010001010000010001000101000101000001000001000100010101" | |
| 1249 "00000101010001010000010101000000010100000001010101000101010100010101000101000100000100000100000" | |
| 1250 "10100010100010001000100000001010100000001000101000101010001010001010000000101000001000101000101" | |
| 1251 "01010001000100000000000001010000010100010101010100010001010001010000010000010000010100010000010" | |
| 1252 "10000010101000100000001010000010000000000000000000100010100010100000101010001000000010001000000" | |
| 1253 "00010100000101000001010100000101010101010000010001010100000100010101010001010101000101000000010" | |
| 1254 "10001010001010101010000010001010000010101000001000101000001000101000100010101010001000000010100" | |
| 1255 "00010100010100010101000000010001010101000101000101010001010101000000000101010001010100000101000" | |
| 1256 "10100000000000000000101000100010101010001000101010001010101010000000000010000000100010101010001" | |
| 1257 "01000100010001010001000000000000000001000100000100000001010100010100010001010001010101010100010" | |
| 1258 "00101000101010101000000010101000001010001010100010101000000000101010101000101010101010100000101" | |
| 1259 "00000101010101010100010001010101000101010000010001010001000001010101000100000100000001010001010" | |
| 1260 "00101010000010101000101000100000101000100010001000101000101010000010100010100000001000001010101" | |
| 1261 "01000000010001000101010100000100000000010101000100000100010000010000010100000101000100000001010" | |
| 1262 "00001010101000101000100000001000001010100010000010101010100000101010100010000000100010001000001" | |
| 1263 "01010101010101010100000000010100010000010101000101010100000101010000000000010000010100010101000" | |
| 1264 "10000000001010000010101000100010000010100000100000100010100010000000101010101010100010000000100" | |
| 1265 "00010000000000010001010101000101010101000000010100000100010001000101010101010001000001010101010" | |
| 1266 "10100000100000101010101010100000100010101010100010000010001010100010100010000010100000001010001" | |
| 1267 "01000001010000000101010001010001000001010100010000000100000000000001000100000100000101000101010" | |
| 1268 "10000010101010100010001010101010000000000010101000101010000000101000001000101010101010100000100" | |
| 1269 "00010101000100000100000101010000010100010001000001010100000100010101010001010101010001010001010" | |
| 1270 "00001010101000000010000010001010001000101000100000000000001010000000001000001010000000100010100" | |
| 1271 "01000001000101000101010000000101010101010101000001000001010101000101010100010001010000010000000" | |
| 1272 "10101010000010001000000000000000101010001010001010001000100000100010101010101000101010101010000" | |
| 1273 "01010100000101010000010101010001000101000100010101000100010001010001010101000000010101010101000" | |
| 1274 "00100010101000100010100010101000101000001000001010001010001010001010100000100010000010100010001" | |
| 1275 "00000000010100010001000000000100010000010000010101000001000001000101000101010100010100010100000" | |
| 1276 "10100000101010001000001000101010100000100000101000100010100000101000001000100000101000001010000" | |
| 1277 "00010101000101000101010101000101000001000001000000010001010100000100000100000101010000000101010" | |
| 1278 "00100000000010100010101010101010101000100010100010100010001010100010001000101010101000100010000" | |
| 1279 "01000100010000010000000101000101010100000100010100010101000101010001010001000100010100000000010" | |
| 1280 "10001000001000001010101010000000001010101000101010000000100010001010000010001000101010100000101" | |
| 1281 "01010101000001000100000001010000010100010100000101000000010100000000000000010101000001010001000" | |
| 1282 "00001010100000000000001000100010100010101010000000001000100000001010100010000010000000001010001" | |
| 1283 "01010101000101000001010100010000000001010100000100010101000101010101010001010000010101000100000" | |
| 1284 "00001010001000101000000000001010101010000010001000101010001000101000101010001000000010100010101" | |
| 1285 "00010001010000010100000000000101000001010001000101010101010001010101010101000101010100000101010" | |
| 1286 "10101000100010000000101010100010000000001010100010101010001010000010101000101010001010100010101" | |
| 1287 "01000100010000010101000101010000010101000101010001010001000001000000000000010101010101010001010" | |
| 1288 "10000010001000100010100010101000001010100010001010000000101000101010000010000010100010001000100" | |
| 1289 "01010000010101010101010100000001010100010000010000000000010100010100000100000000000001010000010" | |
| 1290 "00100000000010101010001000001010001010001000101010101010101010001000100010101000001000001000100" | |
| 1291 "00000100000101010001010101010100000001010101010000000100010100010001010001010101000001000101000" | |
| 1292 "00001010001010001010000000100000100000101000101000101000100010101010101000000010101000101000101" | |
| 1293 "01010101010001010100000000010001000001010001010101010101010100000001000000010101000101010100000" | |
| 1294 "10100010101000101010101010100010100000000010100000000010001000100010001010001000101010001010001" | |
| 1295 "01010001010000000001010101010101010100000101010001000100000001010000010100000000000101000001010" | |
| 1296 "00001010100010101000101010001000101000101010001010101010001000100000001010100000100000101010100" | |
| 1297 "00000001000101000101010001010001000001000001010101010101000000000101010101010000010000010000010" | |
| 1298 "10100000000010101000001000000000000010001010100010001000001010000000000000001000000010101000000" | |
| 1299 "00000100000100000100000000000100010100000100010000000000010000000101010001000001010101010101000" | |
| 1300 "00101000101000000010000000001000101010100000000010100010100010001010101010101010001010000000100" | |
| 1301 "01000101010000010000010100000001010100010001000001010101000101010100000101000101010100010100000" | |
| 1302 "10101010101010000010100010101010000000000010001000100000001000100000100000100010100010101000101" | |
| 1303 "01010000010001010001010100000101010001010001000101010001000101010000000101010001000000000101010" | |
| 1304 "10000000000010101000100010100010101010100000001000101000100010000000100000101010000010100010001" | |
| 1305 "00010101010100000001010101010000000101000100000100010001010001000100010000000101010100000001010" | |
| 1306 "10101010001010101010001000101010000010101010100010001000100000001000101000000000101000001000001" | |
| 1307 "01010100000101010100000000000100010101000101010100000000010101010001010000000100000001000100010" | |
| 1308 "10000010100000100000101010001000100000000000100000000010100010001010001010100010100010000010100" | |
| 1309 "00010000010101000101010101010101010000010100010000010001010000010100000101000100010000010000000" | |
| 1310 "10100000100000001010101010101010001010001010000010100010001010101010000010001010000000100010001" | |
| 1311 "01000001000100000101000101010100000000010001000100000101000100000100010101010101000101010100010" | |
| 1312 }, | |
| 1313 /* 5*/ { DATA_MODE, -1, -1, { 0, 0, "" }, { { TU("\266"), 1, 0 }, { TU("\266"), 1, 7 }, { TU("\266"), 1, 0 } }, 0, 15, 22, 1, 1, "Standard example + extra seg, data mode", | |
| 1314 "1000101010000000001000" | |
| 1315 "0100000101000101000001" | |
| 1316 "1000001000100010101000" | |
| 1317 "0000010001000001010101" | |
| 1318 "1000100000100010101010" | |
| 1319 "0001010000010000010001" | |
| 1320 "0010101000101010100010" | |
| 1321 "0000010101000101000000" | |
| 1322 "1000100010001010100000" | |
| 1323 "0101000101000100010100" | |
| 1324 "0010100000100000001010" | |
| 1325 "0001000101000001010100" | |
| 1326 "1010000010100010001010" | |
| 1327 "0000010000010000010101" | |
| 1328 "1010001010100000101010" | |
| 1329 }, | |
| 1330 /* 6*/ { UNICODE_MODE, 38, -1, { 0, 0, "" }, { { TU("1234567890β"), -1, 9 }, { TU("1234567890点"), -1, 20 }, { TU("1234567890"), -1, 0 } }, 0, 23, 38, 0, 1, "FNC2 ECI & BIN_LATCH ECI; BWIPP different encodation", | |
| 1331 "10000000001010100000101010100000100010" | |
| 1332 "00000001010001000001010001010101000100" | |
| 1333 "10001010100000101000001010001010101000" | |
| 1334 "01000101010001010001000100000000010101" | |
| 1335 "00001000100010001010100000101000100000" | |
| 1336 "01000101010000010101010001000000010101" | |
| 1337 "10001000101000101010000000100010000010" | |
| 1338 "01000100010001010001010000010100010001" | |
| 1339 "10101000000010001010000010101010000000" | |
| 1340 "01010100010000010100010000010000010101" | |
| 1341 "00000010100010001010000010000010100010" | |
| 1342 "01010000010001010001000101000001010101" | |
| 1343 "10000000000010001010101000101000000010" | |
| 1344 "00010001010001010100010000010101000101" | |
| 1345 "10000010101010101000000010001000100010" | |
| 1346 "00000101000101010100010000010100010000" | |
| 1347 "00001010101000000010100010001010000010" | |
| 1348 "01010001000100000100010001010000010101" | |
| 1349 "00001010001010001000000000101010100010" | |
| 1350 "01010101010000000100010101010000010100" | |
| 1351 "00101010100010000010100010000010000010" | |
| 1352 "01010000010100010001010000010000010101" | |
| 1353 "10000010100000001010100000100010001010" | |
| 1354 }, | |
| 1355 /* 7*/ { UNICODE_MODE, 29, -1, { 0, 0, "" }, { { TU("çèéêëì"), -1, 0 }, { TU("òóô"), -1, 899 }, { TU(""), 0, 0 } }, 0, 20, 29, 1, 0, "BIN_LATCH ECI > 0xFF; ZXing-C++ test can't handle binary", | |
| 1356 "10001010001010101000000010001" | |
| 1357 "01000001000100010100010101010" | |
| 1358 "10000000100000100000000010101" | |
| 1359 "00010100010001000101010000000" | |
| 1360 "10001000000000001010101010101" | |
| 1361 "00000100010100010000010101000" | |
| 1362 "10001000101000001000100000000" | |
| 1363 "01010101000101010101000101010" | |
| 1364 "10101010101010000010001010000" | |
| 1365 "00000001000001010101010001010" | |
| 1366 "10001000000010100000101010101" | |
| 1367 "01000001010100010101010100000" | |
| 1368 "00000010101000101000000000101" | |
| 1369 "01000101000001000100000000000" | |
| 1370 "00100010000010100010100000101" | |
| 1371 "01010000010101000101010100010" | |
| 1372 "10100000100010000010001000001" | |
| 1373 "01010101000000000100000001010" | |
| 1374 "10101000101010000010001010001" | |
| 1375 "01010101010100010001010001010" | |
| 1376 }, | |
| 1377 /* 8*/ { UNICODE_MODE, 29, -1, { 0, 0, "" }, { { TU("çèéêëì"), -1, 0 }, { TU("òóô"), -1, 65536 }, { TU(""), 0, 0 } }, 0, 22, 29, 1, 0, "BIN_LATCH ECI > 0xFFFF; ZXing-C++ test can't handle binary", | |
| 1378 "10101000100000101000001010001" | |
| 1379 "00010101000000000100010100000" | |
| 1380 "10100010001010000010101010100" | |
| 1381 "00010100010101000100010001010" | |
| 1382 "00001000001010101010101010101" | |
| 1383 "00010000000001000100010100010" | |
| 1384 "10001000001010000010000010001" | |
| 1385 "00000001010101010000000101010" | |
| 1386 "10101010101000001010100010101" | |
| 1387 "01000100000100010001010001000" | |
| 1388 "10000000000000101010100000001" | |
| 1389 "00010101000101000001000001000" | |
| 1390 "00101010101000100000001000101" | |
| 1391 "00010001010001000101000100010" | |
| 1392 "00000000100010100010000000001" | |
| 1393 "01000001000100000000010101010" | |
| 1394 "10100010100010001010001010101" | |
| 1395 "01000100010001010100010100000" | |
| 1396 "10101010001000100010100000101" | |
| 1397 "01000001000000010001000001000" | |
| 1398 "10001010101000101010000010001" | |
| 1399 "01010101010101010001010000010" | |
| 1400 }, | |
| 1401 /* 9*/ { UNICODE_MODE, -1, -1, { 0, 0, "" }, { { TU("[)>\03605\035"), -1, 0 }, { TU("A\036\004"), -1, 0 }, { TU(""), 0, 0 } }, 0, 10, 13, 1, 1, "Macro 05", | |
| 1402 "1010001010101" | |
| 1403 "0001000001010" | |
| 1404 "1010100010001" | |
| 1405 "0000000001000" | |
| 1406 "1000101000100" | |
| 1407 "0101010101000" | |
| 1408 "1000001000001" | |
| 1409 "0100010000010" | |
| 1410 "0000100000100" | |
| 1411 "0001010101010" | |
| 1412 }, | |
| 1413 /* 10*/ { UNICODE_MODE, -1, -1, { 0, 0, "" }, { { TU("[)>\03605\035"), -1, 0 }, { TU("Študentska št."), -1, 4 }, { TU("\0352198390\036\004"), -1, 0 } }, 0, 24, 35, 1, 1, "Macro 05 with ECI", | |
| 1414 "10101000000010101000000000101010001" | |
| 1415 "00010100000001000000000101010001010" | |
| 1416 "00000010001000000010100010001000101" | |
| 1417 "00000000010100010101000001010001010" | |
| 1418 "00000010101010000000101010100010000" | |
| 1419 "00010000000101000101010001000100000" | |
| 1420 "10001000000000001010100000001000101" | |
| 1421 "01000001010101010100000101010101010" | |
| 1422 "00100010000010100010001010101000000" | |
| 1423 "00010101010000000001010100010101000" | |
| 1424 "00101000100010001000001000100010101" | |
| 1425 "00010000010101010000010001010100000" | |
| 1426 "10100010101010101010000010000000001" | |
| 1427 "01010100000100010100000100000000010" | |
| 1428 "10001000100010100010101000001010101" | |
| 1429 "01010101010000000101000001000100010" | |
| 1430 "10001010101000001010101000001000100" | |
| 1431 "01000101010101000101010101010101000" | |
| 1432 "10101010101000100010100000000000000" | |
| 1433 "01000101010000000000010000000001000" | |
| 1434 "00100010001000101000100010101000100" | |
| 1435 "01000000000101010101010100000101010" | |
| 1436 "10001010000010100000001010000010001" | |
| 1437 "01010001000001010001010001010101010" | |
| 1438 }, | |
| 1439 /* 11*/ { UNICODE_MODE, -1, -1, { 35, 35, "" }, { { TU("Τεχτ"), -1, 9 }, { TU("กขฯ"), -1, 0 }, { TU(""), 0, 0 } }, ZINT_WARN_USES_ECI, 20, 29, 0, 1, "Structured Append with Terminate Latch A replaced", | |
| 1440 "10101000001010000000001000101" | |
| 1441 "01010101010101000000000100000" | |
| 1442 "00101010001010100010101010001" | |
| 1443 "01000100010000000101010100010" | |
| 1444 "10000010100010001000100000000" | |
| 1445 "00010000010101010100000101010" | |
| 1446 "10100010101010101010001000001" | |
| 1447 "00010101000000010101010001000" | |
| 1448 "10000000100000101000101000101" | |
| 1449 "01010000010001010001000100010" | |
| 1450 "00101000000000100010001010101" | |
| 1451 "01000001000101010001000001010" | |
| 1452 "00001010000000000000100010101" | |
| 1453 "00000101010101000100010001000" | |
| 1454 "00101000001010001000001010101" | |
| 1455 "01010101010100000100010001000" | |
| 1456 "10000000101000100010100010001" | |
| 1457 "00000000000000010001010101000" | |
| 1458 "10101010001010101010100000001" | |
| 1459 "01000101000001010100000100010" | |
| 1460 }, | |
| 1461 }; | |
| 1462 const int data_size = ARRAY_SIZE(data); | |
| 1463 int i, j, seg_count, ret; | |
| 1464 struct zint_symbol *symbol = NULL; | |
| 1465 | |
| 1466 char escaped[1024]; | |
| 1467 char cmp_buf[8192]; | |
| 1468 char cmp_msg[1024]; | |
| 1469 | |
| 1470 int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ | |
| 1471 int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ | |
| 1472 | |
| 1473 testStartSymbol("test_encode_segs", &symbol); | |
| 1474 | |
| 1475 for (i = 0; i < data_size; i++) { | |
| 1476 | |
| 1477 if (testContinue(p_ctx, i)) continue; | |
| 1478 | |
| 1479 symbol = ZBarcode_Create(); | |
| 1480 assert_nonnull(symbol, "Symbol not created\n"); | |
| 1481 | |
| 1482 testUtilSetSymbol(symbol, BARCODE_DOTCODE, data[i].input_mode, -1 /*eci*/, | |
| 1483 -1 /* option_1*/, data[i].option_2, data[i].option_3, -1 /*output_options*/, NULL, 0, debug); | |
| 1484 if (data[i].structapp.count) { | |
| 1485 symbol->structapp = data[i].structapp; | |
| 1486 } | |
| 1487 for (j = 0, seg_count = 0; j < 3 && data[i].segs[j].length; j++, seg_count++); | |
| 1488 | |
| 1489 ret = ZBarcode_Encode_Segs(symbol, data[i].segs, seg_count); | |
| 1490 assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode_Segs ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); | |
| 1491 | |
| 1492 if (p_ctx->generate) { | |
| 1493 char escaped1[4096]; | |
| 1494 char escaped2[4096]; | |
| 1495 int length = data[i].segs[0].length == -1 ? (int) ustrlen(data[i].segs[0].source) : data[i].segs[0].length; | |
| 1496 int length1 = data[i].segs[1].length == -1 ? (int) ustrlen(data[i].segs[1].source) : data[i].segs[1].length; | |
| 1497 int length2 = data[i].segs[2].length == -1 ? (int) ustrlen(data[i].segs[2].source) : data[i].segs[2].length; | |
| 1498 printf(" /*%3d*/ { %s, %d, %s, { %d, %d, \"%s\" }, { { TU(\"%s\"), %d, %d }, { TU(\"%s\"), %d, %d }, { TU(\"%s\"), %d, %d } }, %s, %d, %d, %d, %d, \"%s\",\n", | |
| 1499 i, testUtilInputModeName(data[i].input_mode), data[i].option_2, | |
| 1500 testUtilOption3Name(BARCODE_DOTCODE, data[i].option_3), | |
| 1501 data[i].structapp.index, data[i].structapp.count, data[i].structapp.id, | |
| 1502 testUtilEscape((const char *) data[i].segs[0].source, length, escaped, sizeof(escaped)), data[i].segs[0].length, data[i].segs[0].eci, | |
| 1503 testUtilEscape((const char *) data[i].segs[1].source, length1, escaped1, sizeof(escaped1)), data[i].segs[1].length, data[i].segs[1].eci, | |
| 1504 testUtilEscape((const char *) data[i].segs[2].source, length2, escaped2, sizeof(escaped2)), data[i].segs[2].length, data[i].segs[2].eci, | |
| 1505 testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].zxingcpp_cmp, data[i].comment); | |
| 1506 testUtilModulesPrint(symbol, " ", "\n"); | |
| 1507 printf(" },\n"); | |
| 1508 } else { | |
| 1509 if (ret < ZINT_ERROR) { | |
| 1510 int width, row; | |
| 1511 | |
| 1512 assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows); | |
| 1513 assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); | |
| 1514 | |
| 1515 ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row); | |
| 1516 assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d\n", i, ret, width, row); | |
| 1517 | |
| 1518 if (do_bwipp && testUtilCanBwipp(i, symbol, -1, data[i].option_2, data[i].option_3, debug)) { | |
| 1519 if (!data[i].bwipp_cmp) { | |
| 1520 if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d %s not BWIPP compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), data[i].comment); | |
| 1521 } else { | |
| 1522 ret = testUtilBwippSegs(i, symbol, -1, data[i].option_2, data[i].option_3, data[i].segs, seg_count, NULL, cmp_buf, sizeof(cmp_buf)); | |
| 1523 assert_zero(ret, "i:%d %s testUtilBwippSegs ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); | |
| 1524 | |
| 1525 ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, data[i].expected); | |
| 1526 assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n", | |
| 1527 i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, data[i].expected); | |
| 1528 } | |
| 1529 } | |
| 1530 if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, (const char *) data[i].segs[0].source, data[i].segs[0].length, debug)) { | |
| 1531 if (!data[i].zxingcpp_cmp) { | |
| 1532 if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d %s not ZXing-C++ compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), data[i].comment); | |
| 1533 } else if (data[i].input_mode == DATA_MODE) { | |
| 1534 if (debug & ZINT_DEBUG_TEST_PRINT) { | |
| 1535 printf("i:%d multiple segments in DATA_MODE not currently supported for ZXing-C++ testing (%s)\n", | |
| 1536 i, testUtilBarcodeName(symbol->symbology)); | |
| 1537 } | |
| 1538 } else { | |
| 1539 int cmp_len, ret_len; | |
| 1540 char modules_dump[16384]; | |
| 1541 assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); | |
| 1542 ret = testUtilZXingCPP(i, symbol, (const char *) data[i].segs[0].source, data[i].segs[0].length, | |
| 1543 modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); | |
| 1544 assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); | |
| 1545 | |
| 1546 ret = testUtilZXingCPPCmpSegs(symbol, cmp_msg, cmp_buf, cmp_len, data[i].segs, seg_count, | |
| 1547 NULL /*primary*/, escaped, &ret_len); | |
| 1548 assert_zero(ret, "i:%d %s testUtilZXingCPPCmpSegs %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", | |
| 1549 i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, escaped); | |
| 1550 } | |
| 1551 } | |
| 1552 } | |
| 1553 } | |
| 1554 | |
| 1555 ZBarcode_Delete(symbol); | |
| 1556 } | |
| 1557 | |
| 1558 testFinish(); | |
| 1559 } | |
| 1560 | |
| 1561 /* #181 Christian Hartlage / Nico Gunkel OSS-Fuzz */ | |
| 1562 static void test_fuzz(const testCtx *const p_ctx) { | |
| 1563 int debug = p_ctx->debug; | |
| 1564 | |
| 1565 struct item { | |
| 1566 int input_mode; | |
| 1567 char *data; | |
| 1568 int length; | |
| 1569 int ret; | |
| 1570 }; | |
| 1571 /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ | |
| 1572 static const struct item data[] = { | |
| 1573 /* 0*/ { DATA_MODE, "(\207'", -1, 0 }, /* 0x28,0x87,0x27 Note: should but doesn't trigger sanitize error if no length check, for some reason; UPDATE: use up-to-date gcc (9)! */ | |
| 1574 /* 1*/ { DATA_MODE, | |
| 1575 "\133\061\106\133\061\106\070\161\116\133\116\116\067\040\116\016\000\116\125\111\125\125\316\125\125\116\116\116\116\117\116\125" | |
| 1576 "\111\125\103\316\125\125\116\116\116\116\117\000\000\116\136\116\116\001\116\316\076\116\116\057\136\116\116\134\000\000\116\116" | |
| 1577 "\116\230\116\116\116\116\125\125\125\257\257\257\000\001\116\130\212\212\212\212\212\212\212\377\377\210\212\212\177\000\212\212" | |
| 1578 "\212\212\212\212\175\212\212\212\212\212\212\116\117\001\116\116\112\116\116\116\116\176\136\000\000\000\000\000\000\000\000\000" | |
| 1579 "\000\000\000\000\000\000\000\000\005\377\377\005\125\125\125\325\001\116\116\116\266\116\020\000\200\000\116\116\177\000\000\377" | |
| 1580 "\377\257\257\257\125\112\117\116\001\000\000\044\241\001\116\116\116\136\116\116\116\056\116\125\111\125\125\316\125\125\116\116" | |
| 1581 "\116\116\057\000\000\116\136\116\116\001\116\116\076\342\116\057\136\116\116\134\000\000\116\116\116\241\116\116\116\116\125\125" | |
| 1582 "\125\257\257\257\000\001\116\130\212\212\212\212\212\212\212\212\172\212\071\071\071\071\071\071\071\071\071\071\071\071\071\071" | |
| 1583 "\071\071\071\071\071\110\071\071\051\071\065\071\071\071\071\071\071\071\071\071\071\071\071\071\071\071\071\071\071\071\071\071" | |
| 1584 "\071\071\071\071\071\330\330\330\330\330\330\330\330\330\330\330\330\330\330\330\330\330\330\330\330\330\330\330\330\330\330\330" | |
| 1585 "\330\330\071\071\071\071\071\071\071\071\071\071\071\071\071\071\071\071\065\071\071\071\071\071\071\071\071\071\071\071\071\071" | |
| 1586 "\071\071\071\071\071\072\071\071\277\071\071\077\071\071\071\071\071\071\071\071\154\071\071\071\071\071\071\071\071\071\071\071" | |
| 1587 "\071\071\071\011\071\071\071\071\071\071\071\071\071\071\071\071\071\071\105\105\105\105\105\105\105\105\105\105\105\105\105\071" | |
| 1588 "\071\071\071\071\071", /* Original OSS-Fuzz triggering data for index out of bounds (encoding of HT/FS/GS/RS when shifting to code set B) */ | |
| 1589 421, 0 }, | |
| 1590 /* 2*/ { DATA_MODE, "\233:", -1, 0 }, /* Original OSS-Fuzz triggering data for codeword_array buffer overflow, L777 */ | |
| 1591 /* 3*/ { DATA_MODE, "\241\034", -1, 0 }, /* As above L793 */ | |
| 1592 /* 4*/ { DATA_MODE, "\270\036", -1, 0 }, /* As above L799 */ | |
| 1593 /* 5*/ { DATA_MODE, "\237\032", -1, 0 }, /* As above L904 */ | |
| 1594 /* 6*/ { DATA_MODE, "\237", -1, 0 }, /* As above L1090 */ | |
| 1595 }; | |
| 1596 const int data_size = ARRAY_SIZE(data); | |
| 1597 int i, length, ret; | |
| 1598 struct zint_symbol *symbol = NULL; | |
| 1599 | |
| 1600 testStartSymbol("test_fuzz", &symbol); | |
| 1601 | |
| 1602 for (i = 0; i < data_size; i++) { | |
| 1603 | |
| 1604 if (testContinue(p_ctx, i)) continue; | |
| 1605 | |
| 1606 symbol = ZBarcode_Create(); | |
| 1607 assert_nonnull(symbol, "Symbol not created\n"); | |
| 1608 | |
| 1609 length = testUtilSetSymbol(symbol, BARCODE_DOTCODE, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, data[i].length, debug); | |
| 1610 | |
| 1611 ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); | |
| 1612 assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); | |
| 1613 | |
| 1614 ZBarcode_Delete(symbol); | |
| 1615 } | |
| 1616 | |
| 1617 testFinish(); | |
| 1618 } | |
| 1619 | |
| 1620 #define GF 113 | |
| 1621 | |
| 1622 /* Dummy to generate pre-calculated coefficients for GF(113) of generator polys of degree 3 to 39 */ | |
| 1623 static void test_generate(const testCtx *const p_ctx) { | |
| 1624 | |
| 1625 /* roots (antilogs): root[0] = 1; for (i = 1; i < GF - 1; i++) root[i] = (PM * root[i - 1]) % GF; */ | |
| 1626 static const int root[GF - 1] = { | |
| 1627 1, 3, 9, 27, 81, 17, 51, 40, 7, 21, | |
| 1628 63, 76, 2, 6, 18, 54, 49, 34, 102, 80, | |
| 1629 14, 42, 13, 39, 4, 12, 36, 108, 98, 68, | |
| 1630 91, 47, 28, 84, 26, 78, 8, 24, 72, 103, | |
| 1631 83, 23, 69, 94, 56, 55, 52, 43, 16, 48, | |
| 1632 31, 93, 53, 46, 25, 75, 112, 110, 104, 86, | |
| 1633 32, 96, 62, 73, 106, 92, 50, 37, 111, 107, | |
| 1634 95, 59, 64, 79, 11, 33, 99, 71, 100, 74, | |
| 1635 109, 101, 77, 5, 15, 45, 22, 66, 85, 29, | |
| 1636 87, 35, 105, 89, 41, 10, 30, 90, 44, 19, | |
| 1637 57, 58, 61, 70, 97, 65, 82, 20, 60, 67, | |
| 1638 88, 38 | |
| 1639 }; | |
| 1640 int i, j, nc, cind, ci; | |
| 1641 | |
| 1642 /* Degree nc has nc + 1 terms */ | |
| 1643 char coefs[820 - 5] = {0}; /* 40*(41 + 1)/2 == 820 less 2 + 3 (degrees 1 and 2) */ | |
| 1644 int cinds[39 - 2] = {0}; | |
| 1645 | |
| 1646 if (!p_ctx->generate) { | |
| 1647 return; | |
| 1648 } | |
| 1649 | |
| 1650 printf(" static const char coefs[820 - 5] = { /* 40*(41 + 1)/2 == 820 less 2 + 3 (degrees 1 and 2) */\n"); | |
| 1651 for (nc = 3, cind = 0, ci = 0; nc <= 39; cind += nc + 1, ci++, nc++) { | |
| 1652 cinds[ci] = cind; | |
| 1653 | |
| 1654 coefs[cind] = 1; | |
| 1655 for (i = 1; i <= nc; i++) { | |
| 1656 for (j = nc; j >= 1; j--) { | |
| 1657 coefs[cind + j] = (GF + coefs[cind + j] - (root[i] * coefs[cind + j - 1]) % GF) % GF; | |
| 1658 } | |
| 1659 } | |
| 1660 printf(" "); | |
| 1661 for (i = 0; i <= nc; i++) { | |
| 1662 if (i == 22) printf("\n "); | |
| 1663 printf(" %3d,", coefs[cinds[ci] + i]); | |
| 1664 } | |
| 1665 printf("\n"); | |
| 1666 } | |
| 1667 printf(" };\n"); | |
| 1668 | |
| 1669 printf(" static const short cinds[39 - 2] = { /* Indexes into above coefs[] array */\n "); | |
| 1670 for (i = 0; i < ARRAY_SIZE(cinds); i++) { | |
| 1671 if (i == 22) printf("\n "); | |
| 1672 printf(" %3d,", cinds[i]); | |
| 1673 } | |
| 1674 printf("\n };\n"); | |
| 1675 } | |
| 1676 | |
| 1677 #include <time.h> | |
| 1678 | |
| 1679 #define TEST_PERF_ITERATIONS 1000 | |
| 1680 | |
| 1681 /* Not a real test, just performance indicator */ | |
| 1682 static void test_perf(const testCtx *const p_ctx) { | |
| 1683 int debug = p_ctx->debug; | |
| 1684 | |
| 1685 struct item { | |
| 1686 int symbology; | |
| 1687 int input_mode; | |
| 1688 int option_1; | |
| 1689 int option_2; | |
| 1690 char *data; | |
| 1691 int ret; | |
| 1692 | |
| 1693 int expected_rows; | |
| 1694 int expected_width; | |
| 1695 char *comment; | |
| 1696 }; | |
| 1697 static const struct item data[] = { | |
| 1698 /* 0*/ { BARCODE_DOTCODE, -1, -1, -1, | |
| 1699 "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz&,:#-.$/+%*=^ABCDEFGHIJKLMNOPQRSTUVWXYZ12345678901234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLM" | |
| 1700 "NOPQRSTUVWXYZ;<>@[]_`~!||()?{}'123456789012345678901234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJK" | |
| 1701 "LMNOPQRSTUVWXYZ12345678912345678912345678912345678900001234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFG" | |
| 1702 "HIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ12345678901234567" | |
| 1703 "890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcde" | |
| 1704 "fghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNO", | |
| 1705 0, 124, 185, "960 chars, text/numeric" }, | |
| 1706 }; | |
| 1707 const int data_size = ARRAY_SIZE(data); | |
| 1708 int i, length, ret; | |
| 1709 | |
| 1710 clock_t start, total_encode = 0, total_buffer = 0, diff_encode, diff_buffer; | |
| 1711 | |
| 1712 if (!(debug & ZINT_DEBUG_TEST_PERFORMANCE)) { /* -d 256 */ | |
| 1713 return; | |
| 1714 } | |
| 1715 | |
| 1716 for (i = 0; i < data_size; i++) { | |
| 1717 int j; | |
| 1718 | |
| 1719 if (testContinue(p_ctx, i)) continue; | |
| 1720 | |
| 1721 diff_encode = diff_buffer = 0; | |
| 1722 | |
| 1723 for (j = 0; j < TEST_PERF_ITERATIONS; j++) { | |
| 1724 struct zint_symbol *symbol = ZBarcode_Create(); | |
| 1725 assert_nonnull(symbol, "Symbol not created\n"); | |
| 1726 | |
| 1727 length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, data[i].option_1, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug); | |
| 1728 | |
| 1729 start = clock(); | |
| 1730 ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); | |
| 1731 diff_encode += clock() - start; | |
| 1732 assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); | |
| 1733 | |
| 1734 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); | |
| 1735 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); | |
| 1736 | |
| 1737 start = clock(); | |
| 1738 ret = ZBarcode_Buffer(symbol, 0 /*rotate_angle*/); | |
| 1739 diff_buffer += clock() - start; | |
| 1740 assert_zero(ret, "i:%d ZBarcode_Buffer ret %d != 0 (%s)\n", i, ret, symbol->errtxt); | |
| 1741 | |
| 1742 ZBarcode_Delete(symbol); | |
| 1743 } | |
| 1744 | |
| 1745 printf("%s: diff_encode %gms, diff_buffer %gms\n", data[i].comment, diff_encode * 1000.0 / CLOCKS_PER_SEC, diff_buffer * 1000.0 / CLOCKS_PER_SEC); | |
| 1746 | |
| 1747 total_encode += diff_encode; | |
| 1748 total_buffer += diff_buffer; | |
| 1749 } | |
| 1750 if (p_ctx->index != -1) { | |
| 1751 printf("totals: encode %gms, buffer %gms\n", total_encode * 1000.0 / CLOCKS_PER_SEC, total_buffer * 1000.0 / CLOCKS_PER_SEC); | |
| 1752 } | |
| 1753 } | |
| 1754 | |
| 1755 int main(int argc, char *argv[]) { | |
| 1756 | |
| 1757 testFunction funcs[] = { /* name, func */ | |
| 1758 { "test_large", test_large }, | |
| 1759 { "test_options", test_options }, | |
| 1760 { "test_input", test_input }, | |
| 1761 { "test_encode", test_encode }, | |
| 1762 { "test_encode_segs", test_encode_segs }, | |
| 1763 { "test_fuzz", test_fuzz }, | |
| 1764 { "test_generate", test_generate }, | |
| 1765 { "test_perf", test_perf }, | |
| 1766 }; | |
| 1767 | |
| 1768 testRun(argc, argv, funcs, ARRAY_SIZE(funcs)); | |
| 1769 | |
| 1770 testReport(); | |
| 1771 | |
| 1772 return 0; | |
| 1773 } | |
| 1774 | |
| 1775 /* vim: set ts=4 sw=4 et : */ |
