Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/zint/backend/tests/test_mailmark.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_4s_input(const testCtx *const p_ctx) { | |
| 35 int debug = p_ctx->debug; | |
| 36 | |
| 37 struct item { | |
| 38 char *data; | |
| 39 int ret; | |
| 40 int expected_rows; | |
| 41 int expected_width; | |
| 42 }; | |
| 43 /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ | |
| 44 static const struct item data[] = { | |
| 45 /* 0*/ { "41038422416563762XY11 ", 0, 3, 155 }, | |
| 46 /* 1*/ { "41038422416563762XY11 ", ZINT_ERROR_TOO_LONG, -1, -1 }, | |
| 47 /* 2*/ { "4103842241656", ZINT_ERROR_TOO_LONG, -1, -1 }, /* Too short (< 14) */ | |
| 48 /* 3*/ { "41038422416563", ZINT_ERROR_INVALID_DATA, -1, -1 }, | |
| 49 /* 4*/ { "41038422416563762xy11 ", 0, 3, 155 }, /* Case insensitive */ | |
| 50 /* 5*/ { "41038422416563762xy11 .", ZINT_ERROR_INVALID_DATA, -1, -1 }, | |
| 51 /* 6*/ { "0100000000000AA000AA0A", 0, 3, 131, }, /* Length 22, Mailmark C (2 digit chain id) */ | |
| 52 /* 7*/ { "5100000000000AA000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* 1st char format 0-4 only */ | |
| 53 /* 8*/ { "0000000000000AA000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* 2nd char version id 1-4 only */ | |
| 54 /* 9*/ { "01F0000000000AA000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* 3rd char class 0-9A-E only */ | |
| 55 /* 10*/ { "0100A00000000AA000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* 4-5th chars chain id 2 digits */ | |
| 56 /* 11*/ { "010000000000AAA000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* 6-13th chars item id 8 digits */ | |
| 57 /* 12*/ { "0100000000000 A000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* Remaining chars post code */ | |
| 58 /* 13*/ { "0100000000000C1I2JQ3N ", 0, 3, 131, }, /* F N F N L L N L S */ | |
| 59 /* 14*/ { "010000000000091I2JQ3N ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N F N L L N L S bad 1st F */ | |
| 60 /* 15*/ { "0100000000000CAI2JQ3N ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N F N L L N L S bad 1st N */ | |
| 61 /* 16*/ { "0100000000000C1I2IQ3N ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N F N L L N L S bad 1st L */ | |
| 62 /* 17*/ { "0100000000000C1I2IQ3NA", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N F N L L N L S bad S */ | |
| 63 /* 18*/ { "0100000000000KM12JQ3N ", 0, 3, 131, }, /* F F N N L L N L S */ | |
| 64 /* 19*/ { "0100000000000K 12JQ3N ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N L L N L S bad 2nd F (non-numeric otherwise matches last pattern) */ | |
| 65 /* 20*/ { "0100000000000KM1AJQ3N ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N L L N L S bad 2nd N */ | |
| 66 /* 21*/ { "0100000000000KM12JO3N ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N L L N L S bad 2nd L */ | |
| 67 /* 22*/ { "0100000000000KM12JQ3NA", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N L L N L S bad S */ | |
| 68 /* 23*/ { "0100000000000OV123JQ4U", 0, 3, 131, }, /* F F N N N L L N L */ | |
| 69 /* 24*/ { "01000000000009V123JQ4U", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N N L L N L bad 1st F */ | |
| 70 /* 25*/ { "0100000000000OV12AJQ4U", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N N L L N L bad 3rd N */ | |
| 71 /* 26*/ { "0100000000000OV123JQ4V", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N N L L N L bad 3rd L */ | |
| 72 /* 27*/ { "0100000000000CI1K3JQ4U", 0, 3, 131, }, /* F F N F N L L N L */ | |
| 73 /* 28*/ { "0100000000000CI1 3JQ4U", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N F N L L N L bad 3rd F (non-numeric otherwise matches pattern above) */ | |
| 74 /* 29*/ { "0100000000000CIAK3JQ4U", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N F N L L N L bad 1st N */ | |
| 75 /* 30*/ { "0100000000000CI1K3CQ4U", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N F N L L N L bad 1st L */ | |
| 76 /* 31*/ { "0100000000000C12JQ3U ", 0, 3, 131, }, /* F N N L L N L S S */ | |
| 77 /* 32*/ { "0100000000000912JQ3U ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N L L N L S S bad F */ | |
| 78 /* 33*/ { "0100000000000C1AJQ3U ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N L L N L S S bad 2nd N */ | |
| 79 /* 34*/ { "0100000000000C12JO3U ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N L L N L S S bad 2nd L */ | |
| 80 /* 35*/ { "0100000000000C12JQ3UA ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N L L N L S S bad 1st S */ | |
| 81 /* 36*/ { "0100000000000C123JQ4U ", 0, 3, 131, }, /* F N N N L L N L S */ | |
| 82 /* 37*/ { "01000000000009123JQ4U ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N N L L N L S bad F */ | |
| 83 /* 38*/ { "0100000000000C12AJQ4U ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N N L L N L S bad 3rd N */ | |
| 84 /* 39*/ { "0100000000000C123JQ4V ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N N L L N L S bad 3rd L */ | |
| 85 /* 40*/ { "0100000000000C123JQ4U1", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N N L L N L S bad S */ | |
| 86 /* 41*/ { "01000000000000000AA000AA0A", 0, 3, 155, }, /* Length 26, Mailmark L (6 digit chain id) */ | |
| 87 /* 42*/ { "010A0000000000000AA000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* 4-9th chars chain id 6 digits */ | |
| 88 /* 43*/ { "010A0000000000000 A000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* Post code */ | |
| 89 /* 44*/ { "01000000000000000C1I2JQ3N ", 0, 3, 155, }, /* F N F N L L N L S */ | |
| 90 /* 45*/ { "01000000000000000C1 2JQ3N ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N F N L L N L S bad 2nd F */ | |
| 91 /* 46*/ { "01000000000000000KM12JQ3N ", 0, 3, 155, }, /* F F N N L L N L S */ | |
| 92 /* 47*/ { "01000000000000000KM12JQAN ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N L L N L S bad 3rd N */ | |
| 93 /* 48*/ { "01000000000000000OV123JQ4U", 0, 3, 155, }, /* F F N N N L L N L */ | |
| 94 /* 49*/ { "01000000000000000OV123IQ4U", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N N L L N L bad 1st L */ | |
| 95 /* 50*/ { "01000000000000000CI1K3JQ4U", 0, 3, 155, }, /* F F N F N L L N L */ | |
| 96 /* 51*/ { "010000000000000009I1K3JQ4U", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N F N L L N L bad 1st F */ | |
| 97 /* 52*/ { "01000000000000000C12JQ3U ", 0, 3, 155, }, /* F N N L L N L S S */ | |
| 98 /* 53*/ { "01000000000000000C12JQ3U A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N L L N L S S bad 2nd S */ | |
| 99 /* 54*/ { "01000000000000000C123JQ4U ", 0, 3, 155, }, /* F N N N L L N L S */ | |
| 100 /* 55*/ { "01000000000000000C 23JQ4U ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N N L L N L S bad 1st N (non-alpha otherwise matches 2nd pattern) */ | |
| 101 /* 56*/ { "41038422416563762XY1", ZINT_ERROR_INVALID_DATA, -1, -1 }, | |
| 102 }; | |
| 103 const int data_size = ARRAY_SIZE(data); | |
| 104 int i, length, ret; | |
| 105 struct zint_symbol *symbol = NULL; | |
| 106 | |
| 107 testStartSymbol("test_4s_input", &symbol); | |
| 108 | |
| 109 for (i = 0; i < data_size; i++) { | |
| 110 | |
| 111 if (testContinue(p_ctx, i)) continue; | |
| 112 | |
| 113 symbol = ZBarcode_Create(); | |
| 114 assert_nonnull(symbol, "Symbol not created\n"); | |
| 115 | |
| 116 length = testUtilSetSymbol(symbol, BARCODE_MAILMARK_4S, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug); | |
| 117 | |
| 118 ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); | |
| 119 assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); | |
| 120 | |
| 121 if (ret < ZINT_ERROR) { | |
| 122 assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows); | |
| 123 assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); | |
| 124 } | |
| 125 | |
| 126 ZBarcode_Delete(symbol); | |
| 127 } | |
| 128 | |
| 129 testFinish(); | |
| 130 } | |
| 131 | |
| 132 /* Royal Mail Mailmark barcode C encoding and decoding (Sep 2015) RMMBCED | |
| 133 https://www.royalmail.com/sites/default/files/Mailmark-4-state-barcode-C-encoding-and-decoding-instructions-Sept-2015.pdf | |
| 134 Royal Mail Mailmark barcode L encoding and decoding (Sep 2015) RMMBLED | |
| 135 https://www.royalmail.com/sites/default/files/Mailmark-4-state-barcode-L-encoding-and-decoding-instructions-Sept-2015.pdf | |
| 136 */ | |
| 137 static void test_4s_encode_vector(const testCtx *const p_ctx) { | |
| 138 int debug = p_ctx->debug; | |
| 139 | |
| 140 struct item { | |
| 141 char *data; | |
| 142 int ret_encode; | |
| 143 float w; | |
| 144 float h; | |
| 145 int ret_vector; | |
| 146 char *expected_daft; | |
| 147 }; | |
| 148 /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ | |
| 149 static const struct item data[] = { | |
| 150 /* 0*/ { "1100000000000XY11 ", 0, 100, 30, 0, "TTDTTATTDTAATTDTAATTDTAATTDTTDDAATAADDATAATDDFAFTDDTAADDDTAAFDFAFF" }, /* Example 1 from RMMBCED */ | |
| 151 /* 1*/ { "21B2254800659JW5O9QA6Y", 0, 100, 30, 0, "DAATATTTADTAATTFADDDDTTFTFDDDDFFDFDAFTADDTFFTDDATADTTFATTDAFDTFDDA" }, /* Example 2 from RMMBCED */ | |
| 152 /* 2*/ { "11000000000000000XY11 ", 0, 100, 30, 0, "TTDTTATDDTTATTDTAATTDTAATDDTTATTDTTDATFTAATDDTAATDDTATATFAADDAATAATDDTAADFTFTA" }, /* Example 1 from RMMBLED */ | |
| 153 /* 3*/ { "41038422416563762EF61AH8T", 0, 100, 30, 0, "DTTFATTDDTATTTATFTDFFFTFDFDAFTTTADTTFDTFDDDTDFDDFTFAADTFDTDTDTFAATAFDDTAATTDTT" }, /* Example 2 from RMMBLED */ | |
| 154 /* 4*/ { "0100000000000AA000AA0A", 0, 100, 30, 0, "TFATTADAAATAFAFADFTAFATDTTDTTAAFTTFFTTDFTTFFTTAFADFDFAAFTDDFDADDAA" }, | |
| 155 /* 5*/ { "0100000000009JA500AA0A", 0, 100, 30, 0, "TAFTTDADATTFDTFDFDFDTAATADADTTTATTFTDDDDTATDATDFTFFATAFFAFADAFFTDT" }, | |
| 156 /* 6*/ { "1234567890123C1I2JQ3N ", 0, 100, 30, 0, "TTDTDFTFDTAAFFDATAATFDDTATTTFDFTDTTFDFTTTFAAFFTDTADDATDDDTFFATFFAF" }, /* F N F N L L N L S */ | |
| 157 /* 7*/ { "2345678901234KM12JQ3N ", 0, 100, 30, 0, "TDTFAFADDATATATTAAFAFTFTDADFDTDAAADFFDTTDDTDDFATDDTFDATFDFTFFFDFTA" }, /* F F N N L L N L S */ | |
| 158 /* 8*/ { "34A6789012345OV123JQ4U", 0, 100, 30, 0, "TDTTATADDATDADADATTAFATDAADAFTTTAAFDATFAFDDFDATFDTADDTFFAAFDDTTAAD" }, /* F F N N N L L N L */ | |
| 159 /* 9*/ { "44E9999999999CI1K3JQ4U", 0, 100, 30, 0, "DADTFDATFAFAFFAADTDFTTAAFFAFFDFATFTFDDAAFDFDDFAFDTDTDDATTDATTAFDAD" }, /* F F N F N L L N L */ | |
| 160 /* 10*/ { "0418070504030C12JQ3U ", 0, 100, 30, 0, "FTAFFDAFTDDFTDTAFAADDDTADFTFAFFFATAAATFTDDDATFATFTTFTFFATADTDAAFTA" }, /* F N N L L N L S S */ | |
| 161 /* 11*/ { "02D7543219876C123JQ4U ", 0, 100, 30, 0, "AFTFAFATFDDFFDTTDDFAFDFDAFFTFAAFTTDATDFATATFTDFTFTTTFFTTATDATFDFTA" }, /* F N N N L L N L S */ | |
| 162 /* 12*/ { "01000000000000000AA000AA0A", 0, 100, 30, 0, "FDTTATTDDFFDATFAFDDTFFDDAATTTATTDTTADADDFDFTFAFAADTADDFDFTDTFTAFDDATDAFDFFATDT" }, | |
| 163 /* 13*/ { "01000000000000009JA500AA0A", 0, 100, 30, 0, "FDTDAADTDAAADDDAFADDDFDDAFAADDAADTTAAFFDDTFTTDDTDFDTTDDTTFFDTDTFAADTAFAAFFDFDF" }, | |
| 164 /* 14*/ { "01000000000000000C1I2JQ3N ", 0, 100, 30, 0, "TDTTDFTDDFDFFDTTAAATFFAADAFTTATTDTTAATFATDTTFAAFDFDAFTDADFTDFDFTFFFDADAFDDAATT" }, /* F N F N L L N L S */ | |
| 165 /* 15*/ { "01777777777777777KM12JQ3N ", 0, 100, 30, 0, "AFFADATDDTATDFFAFAAADDTATFFDADDDADDAFFAFDDTADTTFDFATAFDDAAFFTTAFADTAAFTTDTFFTA" }, /* F F N N L L N L S */ | |
| 166 /* 16*/ { "33C55555555555555OV123JQ4U", 0, 100, 30, 0, "FDTTFDDTDFFAAAADDFFDTFTFDDTADAAADATTFAFTTFDATTDDTDAFTAFTDDTTADDFFTAFDTDDTDTTAF" }, /* F F N N N L L N L */ | |
| 167 /* 17*/ { "42944444444444444CI1K3JQ4U", 0, 100, 30, 0, "FTDDTTTTFAFFTATFTTFTDTFTFAADADTAFDADDTFDFDAFDFTTAFATFDFDTTFATFDFDAAAFTFTDFFTAF" }, /* F F N F N L L N L */ | |
| 168 /* 18*/ { "31833333333333333C12JQ3U ", 0, 100, 30, 0, "DTTAFFDATATFAADAFDFATFFTFFTTTADTTTDTAAATDDTFFDDFTAADTTDTFFFDAFTFAADFDDAFDFTAFF" }, /* F N N L L N L S S */ | |
| 169 /* 19*/ { "22799999999999999C123JQ4U ", 0, 100, 30, 0, "DDATTDDATATTTAFDTAADATDDFFTFFDFFDTFAADDFAADFDFFTFFTFFDFDFTATATFDDFTFFFTFFTDDTF" }, /* F N N N L L N L S */ | |
| 170 }; | |
| 171 const int data_size = ARRAY_SIZE(data); | |
| 172 int i, length, ret; | |
| 173 struct zint_symbol *symbol = NULL; | |
| 174 | |
| 175 char actual_daft[80]; | |
| 176 | |
| 177 testStartSymbol("test_4s_encode_vector", &symbol); | |
| 178 | |
| 179 for (i = 0; i < data_size; i++) { | |
| 180 | |
| 181 if (testContinue(p_ctx, i)) continue; | |
| 182 | |
| 183 symbol = ZBarcode_Create(); | |
| 184 assert_nonnull(symbol, "Symbol not created\n"); | |
| 185 | |
| 186 length = testUtilSetSymbol(symbol, BARCODE_MAILMARK_4S, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug); | |
| 187 | |
| 188 ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); | |
| 189 assert_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret_encode, symbol->errtxt); | |
| 190 | |
| 191 assert_equal(symbol->rows, 3, "i:%d symbol->rows %d != 3\n", i, symbol->rows); | |
| 192 | |
| 193 ret = testUtilDAFTConvert(symbol, actual_daft, sizeof(actual_daft)); | |
| 194 assert_nonzero(ret, "i:%d testUtilDAFTConvert ret == 0", i); | |
| 195 assert_zero(strcmp(actual_daft, data[i].expected_daft), "i:%d\n actual %s\nexpected %s\n", i, actual_daft, data[i].expected_daft); | |
| 196 | |
| 197 ret = ZBarcode_Buffer_Vector(symbol, 0); | |
| 198 assert_equal(ret, data[i].ret_vector, "i:%d ZBarcode_Buffer_Vector ret %d != %d (%s)\n", i, ret, data[i].ret_vector, symbol->errtxt); | |
| 199 | |
| 200 ZBarcode_Delete(symbol); | |
| 201 } | |
| 202 | |
| 203 testFinish(); | |
| 204 } | |
| 205 | |
| 206 static void test_4s_encode(const testCtx *const p_ctx) { | |
| 207 int debug = p_ctx->debug; | |
| 208 | |
| 209 struct item { | |
| 210 char *data; | |
| 211 int ret; | |
| 212 | |
| 213 int expected_rows; | |
| 214 int expected_width; | |
| 215 char *comment; | |
| 216 char *expected; | |
| 217 }; | |
| 218 static const struct item data[] = { | |
| 219 /* 0*/ { "1100000000000XY11 ", 0, 3, 131, "Verified manually against TEC-IT", | |
| 220 "00000000001000000000101000000000101000000000101000000000000000101000101000001000101000000010101000000000101000000000101010001010101" | |
| 221 "10101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101" | |
| 222 "00001000000000001000000000001000000000001000000000001000001010000000000010100000000000101010001000101000000010101000000010101000101" | |
| 223 }, | |
| 224 }; | |
| 225 const int data_size = ARRAY_SIZE(data); | |
| 226 int i, length, ret; | |
| 227 struct zint_symbol *symbol = NULL; | |
| 228 | |
| 229 char escaped[1024]; | |
| 230 | |
| 231 testStartSymbol("test_4s_encode", &symbol); | |
| 232 | |
| 233 for (i = 0; i < data_size; i++) { | |
| 234 | |
| 235 if (testContinue(p_ctx, i)) continue; | |
| 236 | |
| 237 symbol = ZBarcode_Create(); | |
| 238 assert_nonnull(symbol, "Symbol not created\n"); | |
| 239 | |
| 240 length = testUtilSetSymbol(symbol, BARCODE_MAILMARK_4S, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug); | |
| 241 | |
| 242 ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); | |
| 243 assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); | |
| 244 | |
| 245 if (p_ctx->generate) { | |
| 246 printf(" /*%3d*/ { \"%s\", %s, %d, %d, \"%s\",\n", | |
| 247 i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), | |
| 248 testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment); | |
| 249 testUtilModulesPrint(symbol, " ", "\n"); | |
| 250 printf(" },\n"); | |
| 251 } else { | |
| 252 if (ret < ZINT_ERROR) { | |
| 253 int width, row; | |
| 254 | |
| 255 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); | |
| 256 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); | |
| 257 | |
| 258 ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row); | |
| 259 assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data); | |
| 260 } | |
| 261 } | |
| 262 | |
| 263 ZBarcode_Delete(symbol); | |
| 264 } | |
| 265 | |
| 266 testFinish(); | |
| 267 } | |
| 268 | |
| 269 static void test_2d_input(const testCtx *const p_ctx) { | |
| 270 int debug = p_ctx->debug; | |
| 271 | |
| 272 struct item { | |
| 273 int option_2; | |
| 274 char *data; | |
| 275 int ret; | |
| 276 int expected_rows; | |
| 277 int expected_width; | |
| 278 char *expected_errtxt; | |
| 279 }; | |
| 280 /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ | |
| 281 static const struct item data[] = { | |
| 282 /* 0*/ { -1, "012100123412345678AB19XY1A 0", 0, 24, 24, "" }, | |
| 283 /* 1*/ { -1, "012100123412345678ab19xy1a 0", 0, 24, 24, "" }, /* Converts to upper */ | |
| 284 /* 2*/ { -1, "jgb 012100123412345678ab19xy1a 0", 0, 24, 24, "" }, | |
| 285 /* 3*/ { -1, "012100123412345678AB19XY1A 0901234567890123456789012345678901234567890123456789012345678901", ZINT_ERROR_TOO_LONG, -1, -1, "Error 589: Input length 91 too long (maximum 90)" }, | |
| 286 /* 4*/ { -1, "012100123412345678AB19XY1A ", ZINT_ERROR_TOO_LONG, -1, -1, "Error 860: Input length 27 too short (minimum 28)" }, | |
| 287 /* 5*/ { -1, "012100123412345678AB19XY1A 090123456789012345678901234567890123456789012345678901234567", ZINT_ERROR_TOO_LONG, -1, -1, "Error 861: Input length 87 too long (maximum 86)" }, | |
| 288 /* 6*/ { -1, "JGB 012100123412345678AB19XY1A ", ZINT_ERROR_TOO_LONG, -1, -1, "Error 862: Input length 31 too short (minimum 32)" }, | |
| 289 /* 7*/ { 9, "JGB 012100123412345678AB19XY1A 0", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 863: Invalid Version '9' (8, 10 or 30 only)" }, | |
| 290 /* 8*/ { -1, "JGB 012100123412345678AB19XY1A 0 123456", 0, 24, 24, "" }, | |
| 291 /* 9*/ { 8, "JGB 012100123412345678AB19XY1A 0 1234567", ZINT_ERROR_TOO_LONG, -1, -1, "Error 864: Input length 52 too long for Version 8 (maximum 51)" }, | |
| 292 /* 10*/ { -1, "JGB 012100123412345678AB19XY1A 0 1234567890123456789012345", 0, 16, 48, "" }, | |
| 293 /* 11*/ { 30, "JGB 012100123412345678AB19XY1A 0 12345678901234567890123456", ZINT_ERROR_TOO_LONG, -1, -1, "Error 865: Input length 71 too long for Version 30 (maximum 70)" }, | |
| 294 /* 12*/ { -1, "JGB 012100123412345678AB19XY1A 0 123456789012345678901234567890123456789012345", 0, 32, 32, "" }, | |
| 295 /* 13*/ { -1, "JGB 012100123412345678AB19XY1A 0 1234567890123456789012345678901234567890123456", ZINT_ERROR_TOO_LONG, -1, -1, "Error 589: Input length 91 too long (maximum 90)" }, | |
| 296 /* 14*/ { -1, "JGB 012100123412345678AB19XY1A 0 .23456", 0, 24, 24, "" }, | |
| 297 /* 15*/ { -1, "JGB 012100123412345678AB19XY1A 0 . 23456", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 866: Invalid character at position 45 in input (alphanumerics and space only in first 45)" }, | |
| 298 /* 16*/ { -1, "JGB 12100123412345678AB19XY1A 0", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 867: Invalid Information Type ID (cannot be space)" }, | |
| 299 /* 17*/ { -1, " 12100123412345678AB19XY1A 0", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 867: Invalid Information Type ID (cannot be space)" }, | |
| 300 /* 18*/ { -1, "JGB 022100123412345678AB19XY1A 0", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 868: Invalid Version ID (\"1\" only)" }, | |
| 301 /* 19*/ { -1, "JGB 01 100123412345678AB19XY1A 0", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 869: Invalid Class (cannot be space)" }, | |
| 302 /* 20*/ { -1, "JGB 012100123A12345678AB19XY1A 0", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 870: Invalid Supply Chain ID (7 digits only)" }, | |
| 303 /* 21*/ { -1, "JGB 01210012341234567AAB19XY1A 0", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 871: Invalid Item ID (8 digits only)" }, | |
| 304 /* 22*/ { -1, "JGB 012100123412345678AB19VY1A 0", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 872: Invalid Destination Post Code plus DPS" }, | |
| 305 /* 22*/ { -1, "JGB 012100123412345678AB19XY11 0", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 872: Invalid Destination Post Code plus DPS" }, | |
| 306 /* 23*/ { -1, "JGB 012100123412345678AB19XY1A 7", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 873: Invalid Service Type (\"0\" to \"6\" only)" }, | |
| 307 /* 24*/ { -1, "JGB 012100123412345678AB19XY1A 0AB18XY", 0, 24, 24, "" }, | |
| 308 /* 25*/ { -1, "JGB 012100123412345678AB190XY1A0AB18XY", 0, 24, 24, "" }, | |
| 309 /* 26*/ { -1, "JGB 012100123412345678AB19XY1A 0AB18XI", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 874: Invalid Return to Sender Post Code" }, | |
| 310 /* 27*/ { -1, "JGB 012100123412345678AB19XY1A 0A18XY", 0, 24, 24, "" }, | |
| 311 /* 28*/ { -1, "JGB 012100123412345678AB19XY1A 0A18XC", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 874: Invalid Return to Sender Post Code" }, | |
| 312 /* 29*/ { -1, "JGB 012100123412345678AB19XY1A 0AB181XY", 0, 24, 24, "" }, | |
| 313 /* 30*/ { -1, "JGB 012100123412345678AB19XY1A 0AB181VY", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 874: Invalid Return to Sender Post Code" }, | |
| 314 /* 31*/ { -1, "JGB 012100123412345678AB19XY1A 0AB181XY ", 0, 24, 24, "" }, | |
| 315 /* 32*/ { -1, "JGB 012100123412345678AB19XY1A 0AB181XYA ", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 875: Invalid Reserved field (must be spaces only)" }, | |
| 316 }; | |
| 317 const int data_size = ARRAY_SIZE(data); | |
| 318 int i, length, ret; | |
| 319 struct zint_symbol *symbol = NULL; | |
| 320 | |
| 321 testStartSymbol("test_2d_input", &symbol); | |
| 322 | |
| 323 for (i = 0; i < data_size; i++) { | |
| 324 | |
| 325 if (testContinue(p_ctx, i)) continue; | |
| 326 | |
| 327 symbol = ZBarcode_Create(); | |
| 328 assert_nonnull(symbol, "Symbol not created\n"); | |
| 329 | |
| 330 length = testUtilSetSymbol(symbol, BARCODE_MAILMARK_2D, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug); | |
| 331 | |
| 332 ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); | |
| 333 assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); | |
| 334 | |
| 335 if (ret < ZINT_ERROR) { | |
| 336 assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows); | |
| 337 assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); | |
| 338 } | |
| 339 assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt); | |
| 340 | |
| 341 ZBarcode_Delete(symbol); | |
| 342 } | |
| 343 | |
| 344 testFinish(); | |
| 345 } | |
| 346 | |
| 347 static void test_2d_encode(const testCtx *const p_ctx) { | |
| 348 int debug = p_ctx->debug; | |
| 349 | |
| 350 struct item { | |
| 351 int option_2; | |
| 352 char *data; | |
| 353 int ret; | |
| 354 | |
| 355 int expected_rows; | |
| 356 int expected_width; | |
| 357 int bwipp_cmp; | |
| 358 char *comment; | |
| 359 char *expected; | |
| 360 }; | |
| 361 /* Mailmark Mailing Requirements for Letters and Large Letters 14th Nov 2019 (MMRLLL) | |
| 362 https://www.royalmailtechnical.com/rmt_docs/User_Guides_2020/Mailmark_Letters_and_Large_Letters_20200723.pdf */ | |
| 363 /* Mailmark Barcode Definition Document 15th Feb 2021 (MBDD) | |
| 364 https://www.royalmailtechnical.com/rmt_docs/User_Guides_2021/Mailmark_Barcode_definition_document_20210215.pdf */ | |
| 365 static const struct item data[] = { | |
| 366 /* 0*/ { 8, "JGB 01Z999999900000001EC1A1AA1A0SN35TQ ", 0, 24, 24, 1, "MMRLLL Section 2.4 Code Type Format 7 figure **NOT SAME**, figure switches from C40 to ASC to C40 to ASC contrary to spec", | |
| 367 "101010101010101010101010" | |
| 368 "110000010100011001100001" | |
| 369 "101001011100001011111010" | |
| 370 "101010000101100001100001" | |
| 371 "101111001100010111100010" | |
| 372 "101100100110000100001111" | |
| 373 "111010010000101000000100" | |
| 374 "110011011000001101111111" | |
| 375 "110010010011111011110110" | |
| 376 "101011110001001101110101" | |
| 377 "101001110010111010110110" | |
| 378 "111001111011110011011101" | |
| 379 "101000111000000010011010" | |
| 380 "111101110011110011010011" | |
| 381 "111100101110011011101010" | |
| 382 "111110101100111010011011" | |
| 383 "100100011000000001011100" | |
| 384 "110010100001110110011101" | |
| 385 "110110110111111011010000" | |
| 386 "100101010001111111010001" | |
| 387 "100110100000000011011110" | |
| 388 "111011110111100011100101" | |
| 389 "100111100000101110001010" | |
| 390 "111111111111111111111111" | |
| 391 }, | |
| 392 /* 1*/ { 10, "JGB 01Z999999900000001EC1A1AA1A0SN35TQ ", 0, 32, 32, 1, "MMRLLL Section 2.4 Code Type Format 9 figure **NOT SAME**, figure switches as above", | |
| 393 "10101010101010101010101010101010" | |
| 394 "11000001010001111001100100101111" | |
| 395 "10100101110000101011110000000000" | |
| 396 "10101000010110011001100111000101" | |
| 397 "10111100110001001111101111011110" | |
| 398 "10110010011000011100110000100101" | |
| 399 "11101001000010101001101010011110" | |
| 400 "11001101100000111100101100101111" | |
| 401 "11001001001111101110011100110100" | |
| 402 "10101111000100111001110000001111" | |
| 403 "10100111001001001101001011000110" | |
| 404 "11100111101111111011011000100101" | |
| 405 "10100011100000101001101010001010" | |
| 406 "11110111000101011111000110010001" | |
| 407 "11110010100011101101111000110100" | |
| 408 "11111111111111111111111111111111" | |
| 409 "10101010101010101010101010101010" | |
| 410 "11111010100000011011010000101011" | |
| 411 "10010000111100001001001100111010" | |
| 412 "11001011110010011011011101101011" | |
| 413 "11011111000101101001110001011100" | |
| 414 "10010101101110111000011000011001" | |
| 415 "10011001100100101100011101011100" | |
| 416 "11101010110101111001010110000001" | |
| 417 "10011011101011001000101001101000" | |
| 418 "10011101010100111110010101001011" | |
| 419 "11100011101000101010001110000000" | |
| 420 "10011001100101111101001111110001" | |
| 421 "11100101110010101100001100100100" | |
| 422 "10000111111010111001100111010101" | |
| 423 "11001101100011101011101000001000" | |
| 424 "11111111111111111111111111111111" | |
| 425 }, | |
| 426 /* 2*/ { 30, "JGB 01Z999999900000001EC1A1AA1A0SN35TQ ", 0, 16, 48, 1, "MMRLLL Section 2.4 Code Type Format 29 figure **NOT SAME**, figure switches as above", | |
| 427 "101010101010101010101010101010101010101010101010" | |
| 428 "110000010100011001101111111101100101100100011101" | |
| 429 "101001011100001011100010100100011001100010101100" | |
| 430 "101010000101100111000101100111101011001110100011" | |
| 431 "101111001100010010000110101000011010011110000110" | |
| 432 "101100100110011010111011100100001111010110011111" | |
| 433 "111010010000110011100110111001111011111101000100" | |
| 434 "110011011001001011111001110110000100111000101111" | |
| 435 "110010010011011011010000100011000011000101110100" | |
| 436 "101011110010010000101011110001011011000101110111" | |
| 437 "101001110000100010011100100101010111111011010110" | |
| 438 "111001101001001101000001101011100011010010111001" | |
| 439 "101000101100000110011100101011010001101010010110" | |
| 440 "111101100001100101011001110001000000010111101101" | |
| 441 "101101100011101110101010100001111111001010100010" | |
| 442 "111111111111111111111111111111111111111111111111" | |
| 443 }, | |
| 444 /* 3*/ { 30, "JGB 012100123412345678AB19XY1A 0 REFERENCE 12300AB", 0, 16, 48, 1, "MBDD Table 4 example", | |
| 445 "101010101010101010101010101010101010101010101010" | |
| 446 "110000010100010110001111111011100000001001111111" | |
| 447 "101001011100011001110010100100010100110011111100" | |
| 448 "101010000001001001000101100101000011100101110101" | |
| 449 "100011010001101010000110110110011101100110110110" | |
| 450 "101000011000000011111101110000010100101111011111" | |
| 451 "111100000000011111100000111000100011011111100110" | |
| 452 "101001101000010000000111110111110111001011110111" | |
| 453 "101101010010101010001000100011000101001111101100" | |
| 454 "111101101010111000101111110101011100111101000111" | |
| 455 "100111110100011000101100100001011000110111100100" | |
| 456 "111110100100110100110001111110101000010010001101" | |
| 457 "100111001001101101011100111010111100110110101110" | |
| 458 "100101101110100011011001111010111000111010100011" | |
| 459 "101111100001111111101010100010111101100101001100" | |
| 460 "111111111111111111111111111111111111111111111111" | |
| 461 }, | |
| 462 /* 4*/ { 10, "JGB 012100123412345678AB19XY1A 0 www.xyz.com", 0, 32, 32, 1, "MBDD Table 5 (& BWIPP) example", | |
| 463 "10101010101010101010101010101010" | |
| 464 "11000001010001011111111110001111" | |
| 465 "10100101110001101001111111000000" | |
| 466 "10101000000100111001100001000101" | |
| 467 "10001101000110101111001011011110" | |
| 468 "10100001100000011100001000100101" | |
| 469 "11110000000000101001000010011110" | |
| 470 "10100110100000111110101100101111" | |
| 471 "10110101001111101111011100110100" | |
| 472 "11110110100100111101110000001111" | |
| 473 "10011111001010001111000111001000" | |
| 474 "11111010001101111011010000000101" | |
| 475 "11011101110101001001000110101010" | |
| 476 "11010001000101011111100001000101" | |
| 477 "10111010110111101101010101000000" | |
| 478 "11111111111111111111111111111111" | |
| 479 "10101010101010101010101010101010" | |
| 480 "11000011011000011010010111011001" | |
| 481 "11111111101100101110011110110010" | |
| 482 "10010011110010111010110010110001" | |
| 483 "10100111000101001001001000011000" | |
| 484 "10111011101111111101000001101001" | |
| 485 "10101101100000101000111111011000" | |
| 486 "10000010111001111001111110111101" | |
| 487 "10001011111100101011101101110100" | |
| 488 "10011101110010111101110101101011" | |
| 489 "11100010111001101010010000101100" | |
| 490 "10011000111001011010011101001101" | |
| 491 "11101100101110101100110111001000" | |
| 492 "10001011110011111001100001110101" | |
| 493 "11000011100001101111110101011100" | |
| 494 "11111111111111111111111111111111" | |
| 495 }, | |
| 496 /* 5*/ { 10, "JGB 010100000700009001B707RH1A 0SN35XX ABCDEFGHIJ1234567890ABCDEFGHIJ1234567890A", 0, 32, 32, 1, "TEC-IT example, same", | |
| 497 "10101010101010101010101010101010" | |
| 498 "11000001010001111000100110110001" | |
| 499 "10100101110000101010110010100000" | |
| 500 "10101000010110011000011000100101" | |
| 501 "10001100111000101111101000001100" | |
| 502 "10011100011000011100000110100101" | |
| 503 "11001111001000101001000011011110" | |
| 504 "10100101011000111101111100101111" | |
| 505 "10101111010111101011101000110100" | |
| 506 "11001001100100011101000000010111" | |
| 507 "11001000001010001001111111010110" | |
| 508 "11010000001100111100101111011101" | |
| 509 "11001000010011101100011100100010" | |
| 510 "11010111001011011100001110100111" | |
| 511 "10111101001010001100100000100000" | |
| 512 "11111111111111111111111111111111" | |
| 513 "10101010101010101010101010101010" | |
| 514 "11011101001111111001100001001001" | |
| 515 "11110001010111001111011010111010" | |
| 516 "11001000011110111111000101111001" | |
| 517 "11010100000101101111101010001000" | |
| 518 "10010001000010011000000110011001" | |
| 519 "10011010001001101001100011100100" | |
| 520 "11010101100001011011100101000101" | |
| 521 "11001001100110101101010011000100" | |
| 522 "10101101001010111001100010011101" | |
| 523 "11111010111000101001011000000000" | |
| 524 "10101101110110111010110011100001" | |
| 525 "10100011100100101000101111010110" | |
| 526 "10100001111001011010010001100011" | |
| 527 "10111101100000001010110001010110" | |
| 528 "11111111111111111111111111111111" | |
| 529 }, | |
| 530 }; | |
| 531 const int data_size = ARRAY_SIZE(data); | |
| 532 int i, length, ret; | |
| 533 struct zint_symbol *symbol = NULL; | |
| 534 | |
| 535 char escaped[8192]; | |
| 536 char cmp_buf[32768]; | |
| 537 char cmp_msg[1024]; | |
| 538 | |
| 539 int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ | |
| 540 int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ | |
| 541 | |
| 542 testStartSymbol("test_2d_encode", &symbol); | |
| 543 | |
| 544 for (i = 0; i < data_size; i++) { | |
| 545 | |
| 546 if (testContinue(p_ctx, i)) continue; | |
| 547 | |
| 548 symbol = ZBarcode_Create(); | |
| 549 assert_nonnull(symbol, "Symbol not created\n"); | |
| 550 | |
| 551 length = testUtilSetSymbol(symbol, BARCODE_MAILMARK_2D, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug); | |
| 552 | |
| 553 ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); | |
| 554 assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); | |
| 555 | |
| 556 if (p_ctx->generate) { | |
| 557 printf(" /*%3d*/ { %d, \"%s\", %s, %d, %d, %d, \"%s\",\n", | |
| 558 i, data[i].option_2, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), | |
| 559 testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].comment); | |
| 560 testUtilModulesPrint(symbol, " ", "\n"); | |
| 561 printf(" },\n"); | |
| 562 } else { | |
| 563 if (ret < ZINT_ERROR) { | |
| 564 int width, row; | |
| 565 | |
| 566 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); | |
| 567 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); | |
| 568 | |
| 569 ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row); | |
| 570 assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data); | |
| 571 | |
| 572 if (do_bwipp && testUtilCanBwipp(i, symbol, -1, data[i].option_2, -1, debug)) { | |
| 573 if (!data[i].bwipp_cmp) { | |
| 574 if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d %s not BWIPP compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), data[i].comment); | |
| 575 } else { | |
| 576 ret = testUtilBwipp(i, symbol, -1, data[i].option_2, -1, data[i].data, length, NULL, cmp_buf, sizeof(cmp_buf), NULL); | |
| 577 assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); | |
| 578 | |
| 579 ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, data[i].expected); | |
| 580 assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n", | |
| 581 i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, data[i].expected); | |
| 582 } | |
| 583 } | |
| 584 if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) { | |
| 585 int cmp_len, ret_len; | |
| 586 char modules_dump[144 * 144 + 1]; | |
| 587 assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); | |
| 588 ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); | |
| 589 assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); | |
| 590 | |
| 591 ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len); | |
| 592 assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", | |
| 593 i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, escaped); | |
| 594 } | |
| 595 } | |
| 596 } | |
| 597 | |
| 598 ZBarcode_Delete(symbol); | |
| 599 } | |
| 600 | |
| 601 testFinish(); | |
| 602 } | |
| 603 | |
| 604 int main(int argc, char *argv[]) { | |
| 605 | |
| 606 testFunction funcs[] = { /* name, func */ | |
| 607 { "test_4s_input", test_4s_input }, | |
| 608 { "test_4s_encode_vector", test_4s_encode_vector }, | |
| 609 { "test_4s_encode", test_4s_encode }, | |
| 610 { "test_2d_input", test_2d_input }, | |
| 611 { "test_2d_encode", test_2d_encode }, | |
| 612 }; | |
| 613 | |
| 614 testRun(argc, argv, funcs, ARRAY_SIZE(funcs)); | |
| 615 | |
| 616 testReport(); | |
| 617 | |
| 618 return 0; | |
| 619 } | |
| 620 | |
| 621 /* vim: set ts=4 sw=4 et : */ |
