comparison mupdf-source/thirdparty/zint/backend/tests/test_telepen.c @ 2:b50eed0cc0ef upstream

ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4. The directory name has changed: no version number in the expanded directory now.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:43:07 +0200
parents
children
comparison
equal deleted inserted replaced
1:1d09e1dec1d9 2:b50eed0cc0ef
1 /*
2 libzint - the open source barcode library
3 Copyright (C) 2020-2024 Robin Stuart <rstuart114@gmail.com>
4
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions
7 are met:
8
9 1. Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
11 2. Redistributions in binary form must reproduce the above copyright
12 notice, this list of conditions and the following disclaimer in the
13 documentation and/or other materials provided with the distribution.
14 3. Neither the name of the project nor the names of its contributors
15 may be used to endorse or promote products derived from this software
16 without specific prior written permission.
17
18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
22 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 SUCH DAMAGE.
29 */
30 /* SPDX-License-Identifier: BSD-3-Clause */
31
32 #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 symbology;
39 char *pattern;
40 int length;
41 int ret;
42 int expected_rows;
43 int expected_width;
44 char *expected_errtxt;
45 };
46 /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
47 static const struct item data[] = {
48 /* 0*/ { BARCODE_TELEPEN, "\177", 69, 0, 1, 1152, "" },
49 /* 1*/ { BARCODE_TELEPEN, "\177", 70, ZINT_ERROR_TOO_LONG, -1, -1, "Error 390: Input length 70 too long (maximum 69)" },
50 /* 2*/ { BARCODE_TELEPEN_NUM, "1", 136, 0, 1, 1136, "" },
51 /* 3*/ { BARCODE_TELEPEN_NUM, "1", 137, ZINT_ERROR_TOO_LONG, -1, -1, "Error 392: Input length 137 too long (maximum 136)" },
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[256];
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 testUtilStrCpyRepeat(data_buf, data[i].pattern, data[i].length);
69 assert_equal(data[i].length, (int) strlen(data_buf), "i:%d length %d != strlen(data_buf) %d\n", i, data[i].length, (int) strlen(data_buf));
70
71 length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data_buf, data[i].length, debug);
72
73 ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
74 assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
75 assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
76 assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
77
78 if (ret < ZINT_ERROR) {
79 assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
80 assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
81 }
82
83 ZBarcode_Delete(symbol);
84 }
85
86 testFinish();
87 }
88
89 static void test_hrt(const testCtx *const p_ctx) {
90 int debug = p_ctx->debug;
91
92 struct item {
93 int symbology;
94 char *data;
95 int length;
96
97 char *expected;
98 };
99 /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
100 static const struct item data[] = {
101 /* 0*/ { BARCODE_TELEPEN, "ABC1234.;$", -1, "ABC1234.;$" },
102 /* 1*/ { BARCODE_TELEPEN, "abc1234.;$", -1, "abc1234.;$" },
103 /* 2*/ { BARCODE_TELEPEN, "ABC1234\001", -1, "ABC1234\001" },
104 /* 3*/ { BARCODE_TELEPEN, "ABC\0001234", 8, "ABC 1234" },
105 /* 4*/ { BARCODE_TELEPEN_NUM, "1234", -1, "1234" },
106 /* 5*/ { BARCODE_TELEPEN_NUM, "123X", -1, "123X" },
107 /* 6*/ { BARCODE_TELEPEN_NUM, "123x", -1, "123X" }, /* Converts to upper */
108 /* 7*/ { BARCODE_TELEPEN_NUM, "12345", -1, "012345" }, /* Adds leading zero if odd */
109 };
110 const int data_size = ARRAY_SIZE(data);
111 int i, length, ret;
112 struct zint_symbol *symbol = NULL;
113
114 testStartSymbol("test_hrt", &symbol);
115
116 for (i = 0; i < data_size; i++) {
117
118 if (testContinue(p_ctx, i)) continue;
119
120 symbol = ZBarcode_Create();
121 assert_nonnull(symbol, "Symbol not created\n");
122
123 length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
124
125 ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
126 assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
127
128 assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
129
130 ZBarcode_Delete(symbol);
131 }
132
133 testFinish();
134 }
135
136 static void test_input(const testCtx *const p_ctx) {
137 int debug = p_ctx->debug;
138
139 struct item {
140 int symbology;
141 char *data;
142 int length;
143 int ret;
144 int expected_rows;
145 int expected_width;
146 char *expected_errtxt;
147 };
148 /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
149 static const struct item data[] = {
150 /* 0*/ { BARCODE_TELEPEN, " !\"#$%&'()*+,-./0123456789:;<", -1, 0, 1, 512, "" },
151 /* 1*/ { BARCODE_TELEPEN, "AZaz\176\001", -1, 0, 1, 144, "" },
152 /* 2*/ { BARCODE_TELEPEN, "\000\177", 2, 0, 1, 80, "" },
153 /* 3*/ { BARCODE_TELEPEN, "é", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 391: Invalid character at position 1 in input, extended ASCII not allowed" },
154 /* 4*/ { BARCODE_TELEPEN_NUM, "1234567890", -1, 0, 1, 128, "" },
155 /* 5*/ { BARCODE_TELEPEN_NUM, "123456789A", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 393: Invalid character at position 10 in input (digits and \"X\" only)" },
156 /* 6*/ { BARCODE_TELEPEN_NUM, "123456789X", -1, 0, 1, 128, "" }, /* [0-9]X allowed */
157 /* 7*/ { BARCODE_TELEPEN_NUM, "12345678X9", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 394: Invalid odd position 9 of \"X\" in Telepen data" }, /* X[0-9] not allowed */
158 /* 8*/ { BARCODE_TELEPEN_NUM, "1X34567X9X", -1, 0, 1, 128, "" }, /* [0-9]X allowed multiple times */
159 };
160 const int data_size = ARRAY_SIZE(data);
161 int i, length, ret;
162 struct zint_symbol *symbol = NULL;
163
164 testStartSymbol("test_input", &symbol);
165
166 for (i = 0; i < data_size; i++) {
167
168 if (testContinue(p_ctx, i)) continue;
169
170 symbol = ZBarcode_Create();
171 assert_nonnull(symbol, "Symbol not created\n");
172
173 length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
174
175 ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
176 assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
177 assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
178 assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
179
180 if (ret < ZINT_ERROR) {
181 assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
182 assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
183 }
184
185 ZBarcode_Delete(symbol);
186 }
187
188 testFinish();
189 }
190
191 /* Telepen Barcode Symbology information and History (BSiH)
192 https://telepen.co.uk/wp-content/uploads/2018/10/Barcode-Symbology-information-and-History.pdf */
193 /* E2326U: SB Telepen Barcode Fonts Guide Issue 2 (Apr 2009)
194 https://telepen.co.uk/wp-content/uploads/2018/09/SB-Telepen-Barcode-Fonts-V2.pdf */
195 static void test_encode(const testCtx *const p_ctx) {
196 int debug = p_ctx->debug;
197
198 struct item {
199 int symbology;
200 char *data;
201 int length;
202 int ret;
203
204 int expected_rows;
205 int expected_width;
206 char *comment;
207 char *expected;
208 };
209 static const struct item data[] = {
210 /* 0*/ { BARCODE_TELEPEN, "1A", -1, 0, 1, 80, "Telepen BSiH Example, same",
211 "10101010101110001011101000100010101110111011100010100010001110101110001010101010"
212 },
213 /* 1*/ { BARCODE_TELEPEN, "ABC", -1, 0, 1, 96, "Telepen E2326U Example, same",
214 "101010101011100010111011101110001110001110111000101011101110101011101000101000101110001010101010"
215 },
216 /* 2*/ { BARCODE_TELEPEN, "RST", -1, 0, 1, 96, "Verified manually against tec-it",
217 "101010101011100011100011100010101010111010111000111010111000101010111000111011101110001010101010"
218 },
219 /* 3*/ { BARCODE_TELEPEN, "?@", -1, 0, 1, 80, "ASCII count 127, check 0; verified manually against tec-it",
220 "10101010101110001010101010101110111011101110101011101110111011101110001010101010"
221 },
222 /* 4*/ { BARCODE_TELEPEN, "\000", 1, 0, 1, 64, "Verified manually against tec-it",
223 "1010101010111000111011101110111011101110111011101110001010101010"
224 },
225 /* 5*/ { BARCODE_TELEPEN_NUM, "1234567890", -1, 0, 1, 128, "Verified manually against tec-it",
226 "10101010101110001010101110101110101000101010001010101110101110001011101010001000101110001010101010101011101010101110001010101010"
227 },
228 /* 6*/ { BARCODE_TELEPEN_NUM, "123456789", -1, 0, 1, 128, "Verified manually against tec-it (012345679)",
229 "10101010101110001110101010111010111000100010001011101110001110001000101010001010111010100010100010111000101110101110001010101010"
230 },
231 /* 7*/ { BARCODE_TELEPEN_NUM, "123X", -1, 0, 1, 80, "Verified manually against tec-it",
232 "10101010101110001010101110101110111010111000111011101011101110001110001010101010"
233 },
234 /* 8*/ { BARCODE_TELEPEN_NUM, "1X3X", -1, 0, 1, 80, "Verified manually against tec-it",
235 "10101010101110001110001110001110111010111000111010111010101110001110001010101010"
236 },
237 /* 9*/ { BARCODE_TELEPEN_NUM, "3637", -1, 0, 1, 80, "Glyph count 127, check 0; verified manually against tec-it",
238 "10101010101110001010101010101110111011101110101011101110111011101110001010101010"
239 },
240 };
241 const int data_size = ARRAY_SIZE(data);
242 int i, length, ret;
243 struct zint_symbol *symbol = NULL;
244
245 char escaped[1024];
246 char bwipp_buf[8192];
247 char bwipp_msg[1024];
248
249 int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
250
251 testStartSymbol("test_encode", &symbol);
252
253 for (i = 0; i < data_size; i++) {
254
255 if (testContinue(p_ctx, i)) continue;
256
257 symbol = ZBarcode_Create();
258 assert_nonnull(symbol, "Symbol not created\n");
259
260 length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
261
262 ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
263 assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
264
265 if (p_ctx->generate) {
266 printf(" /*%3d*/ { %s, \"%s\", %d, %s, %d, %d, \"%s\",\n",
267 i, testUtilBarcodeName(data[i].symbology), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length,
268 testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
269 testUtilModulesPrint(symbol, " ", "\n");
270 printf(" },\n");
271 } else {
272 if (ret < ZINT_ERROR) {
273 int width, row;
274
275 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);
276 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);
277
278 ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
279 assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data);
280
281 if (do_bwipp && testUtilCanBwipp(i, symbol, -1, -1, -1, debug)) {
282 ret = testUtilBwipp(i, symbol, -1, -1, -1, data[i].data, length, NULL, bwipp_buf, sizeof(bwipp_buf), NULL);
283 assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
284
285 ret = testUtilBwippCmp(symbol, bwipp_msg, bwipp_buf, data[i].expected);
286 assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n",
287 i, testUtilBarcodeName(symbol->symbology), ret, bwipp_msg, bwipp_buf, data[i].expected);
288 }
289 }
290 }
291
292 ZBarcode_Delete(symbol);
293 }
294
295 testFinish();
296 }
297
298 /* #181 Nico Gunkel OSS-Fuzz */
299 static void test_fuzz(const testCtx *const p_ctx) {
300 int debug = p_ctx->debug;
301
302 struct item {
303 int symbology;
304 char *data;
305 int length;
306 int ret;
307 };
308 /* Note NULs where using DELs code (16 binary characters wide) */
309 /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
310 static const struct item data[] = {
311 /* 0*/ { BARCODE_TELEPEN, "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 69, 0 },
312 /* 1*/ { BARCODE_TELEPEN, "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 70, ZINT_ERROR_TOO_LONG },
313 /* 2*/ { BARCODE_TELEPEN_NUM, "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 70, ZINT_ERROR_INVALID_DATA },
314 /* 3*/ { BARCODE_TELEPEN_NUM, "0404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404", 136, 0 },
315 /* 4*/ { BARCODE_TELEPEN_NUM, "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567", 137, ZINT_ERROR_TOO_LONG },
316 /* 5*/ { BARCODE_TELEPEN_NUM, "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000X", 136, 0 },
317 /* 6*/ { BARCODE_TELEPEN_NUM, "9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999", 136, 0 },
318 /* 7*/ { BARCODE_TELEPEN_NUM, "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", 4, 0 }, /* Length given, strlen > 137, so pseudo not NUL-terminated */
319 };
320 const int data_size = ARRAY_SIZE(data);
321 int i, length, ret;
322 struct zint_symbol *symbol = NULL;
323
324 testStartSymbol("test_fuzz", &symbol);
325
326 for (i = 0; i < data_size; i++) {
327
328 if (testContinue(p_ctx, i)) continue;
329
330 symbol = ZBarcode_Create();
331 assert_nonnull(symbol, "Symbol not created\n");
332
333 symbol->symbology = data[i].symbology;
334 symbol->debug |= debug;
335
336 length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length;
337
338 ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
339 assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
340
341 ZBarcode_Delete(symbol);
342 }
343
344 testFinish();
345 }
346
347 static const char TeleTable[128][16] = {
348 { "31313131" }, { "1131313111" }, { "33313111" }, { "1111313131" },
349 { "3111313111" }, { "11333131" }, { "13133131" }, { "111111313111" },
350 { "31333111" }, { "1131113131" }, { "33113131" }, { "1111333111" },
351 { "3111113131" }, { "1113133111" }, { "1311133111" }, { "111111113131" },
352 { "3131113111" }, { "11313331" }, { "333331" }, { "111131113111" },
353 { "31113331" }, { "1133113111" }, { "1313113111" }, { "1111113331" },
354 { "31131331" }, { "113111113111" }, { "3311113111" }, { "1111131331" },
355 { "311111113111" }, { "1113111331" }, { "1311111331" }, { "11111111113111" },
356 { "31313311" }, { "1131311131" }, { "33311131" }, { "1111313311" },
357 { "3111311131" }, { "11333311" }, { "13133311" }, { "111111311131" },
358 { "31331131" }, { "1131113311" }, { "33113311" }, { "1111331131" },
359 { "3111113311" }, { "1113131131" }, { "1311131131" }, { "111111113311" },
360 { "3131111131" }, { "1131131311" }, { "33131311" }, { "111131111131" },
361 { "3111131311" }, { "1133111131" }, { "1313111131" }, { "111111131311" },
362 { "3113111311" }, { "113111111131" }, { "3311111131" }, { "111113111311" },
363 { "311111111131" }, { "111311111311" }, { "131111111311" }, { "11111111111131" },
364 { "3131311111" }, { "11313133" }, { "333133" }, { "111131311111" },
365 { "31113133" }, { "1133311111" }, { "1313311111" }, { "1111113133" },
366 { "313333" }, { "113111311111" }, { "3311311111" }, { "11113333" },
367 { "311111311111" }, { "11131333" }, { "13111333" }, { "11111111311111" },
368 { "31311133" }, { "1131331111" }, { "33331111" }, { "1111311133" },
369 { "3111331111" }, { "11331133" }, { "13131133" }, { "111111331111" },
370 { "3113131111" }, { "1131111133" }, { "33111133" }, { "111113131111" },
371 { "3111111133" }, { "111311131111" }, { "131111131111" }, { "111111111133" },
372 { "31311313" }, { "113131111111" }, { "3331111111" }, { "1111311313" },
373 { "311131111111" }, { "11331313" }, { "13131313" }, { "11111131111111" },
374 { "3133111111" }, { "1131111313" }, { "33111313" }, { "111133111111" },
375 { "3111111313" }, { "111313111111" }, { "131113111111" }, { "111111111313" },
376 { "313111111111" }, { "1131131113" }, { "33131113" }, { "11113111111111" },
377 { "3111131113" }, { "113311111111" }, { "131311111111" }, { "111111131113" },
378 { "3113111113" }, { "11311111111111" }, { "331111111111" }, { "111113111113" },
379 { "31111111111111" }, { "111311111113" }, { "131111111113" },
380 {'1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1'},
381 };
382
383 /* Dummy to generate lengths table */
384 static void test_generate_lens(const testCtx *const p_ctx) {
385
386 int i;
387
388 if (!p_ctx->generate) {
389 return;
390 }
391
392 printf("static const char TeleLens[128] = {");
393 for (i = 0; i < 127; i++) {
394 if ((i % 16) == 0) {
395 printf("\n %2d,", (int) strlen(TeleTable[i]));
396 } else {
397 printf(" %2d,", (int) strlen(TeleTable[i]));
398 }
399 }
400 printf(" 16\n};\n");
401 }
402
403 int main(int argc, char *argv[]) {
404
405 testFunction funcs[] = { /* name, func */
406 { "test_large", test_large },
407 { "test_hrt", test_hrt },
408 { "test_input", test_input },
409 { "test_encode", test_encode },
410 { "test_fuzz", test_fuzz },
411 { "test_generate_lens", test_generate_lens },
412 };
413
414 testRun(argc, argv, funcs, ARRAY_SIZE(funcs));
415
416 testReport();
417
418 return 0;
419 }
420
421 /* vim: set ts=4 sw=4 et : */