general: change BARCODE_RAW_TEXT to write to new zint_symbol

fields `raw_segs` and `raw_seg_count` instead of `text`, and to
  do so for all symbologies, using new common funcs `rt_cpy()` etc.
MICROPDF417: return ECC percentage in top byte of `option_1`
DBAR_EXP_STK: return `option_2`/`option_3` feedback
CLI: change warning text "ignoring" -> "**IGNORED**"
GUI: show feedback for DBAR_EXP_STK, MICROPDF417, UPNQR
ctest: fix recent inability to run tests via "ctest" on Windows
  (MSVC) by using cmake 3.22 feature `ENVIRONMENT_MODIFICATION`
manual: document feedback and RAW_TEXT in new "Feedback" section;
  rephrase some symbology descriptions
test suite: new general-use arg "-a"; add `func_name` to context;
  new "test_bwipp" test for testing BWIPP against ZXing-C++
This commit is contained in:
gitlost 2025-03-28 10:02:19 +00:00
parent d1bf02e156
commit a6c225447e
120 changed files with 10511 additions and 5620 deletions

View file

@ -1,8 +1,10 @@
Version 2.15.0.9 (dev) not released yet (2025-03-18) Version 2.15.0.9 (dev) not released yet (2025-03-28)
==================================================== ====================================================
**Incompatible changes** **Incompatible changes**
------------------------ ------------------------
- New `raw_segs` & `raw_seg_count` fields in `symbol` for use with new output
option `BARCODE_RAW_TEXT`
- Symbol structure members `option_1`, `option_2` and `option_3` now updated - Symbol structure members `option_1`, `option_2` and `option_3` now updated
after `ZBarcode_Encode()` and variants are called, and there are three new after `ZBarcode_Encode()` and variants are called, and there are three new
methods in the Qt Backend to access to them methods in the Qt Backend to access to them
@ -11,8 +13,8 @@ Version 2.15.0.9 (dev) not released yet (2025-03-18)
Changes Changes
------- -------
- Add new `BARCODE_RAW_TEXT` option for `output_options` and new warning - Add new `BARCODE_RAW_TEXT` option for `output_options` which sets new fields
`ZINT_WARN_HRT_RAW_TEXT` for when set when outputting HRT `raw_segs` and `raw_seg_count` with encoded data
- Add API funcs `ZBarcode_UTF8_To_ECI()` and `ZBarcode_Dest_Len_ECI()` - Add API funcs `ZBarcode_UTF8_To_ECI()` and `ZBarcode_Dest_Len_ECI()`
- Set `option_1`, `option_2`, `option_3` to values used in encodation, and add - Set `option_1`, `option_2`, `option_3` to values used in encodation, and add
new access methods `encodedOption1()` etc. to Qt Backend, and use in GUI to new access methods `encodedOption1()` etc. to Qt Backend, and use in GUI to

View file

@ -1,4 +1,4 @@
% README.linux 2025-02-19 % README.linux 2025-03-28
% Tested on Ubuntu 20.04.4 LTS, Ubuntu 22.04 LTS, Ubuntu 24.04 LTS and % Tested on Ubuntu 20.04.4 LTS, Ubuntu 22.04 LTS, Ubuntu 24.04 LTS and
% Fedora Linux 41 (Workstation Edition) % Fedora Linux 41 (Workstation Edition)
@ -126,7 +126,6 @@ ZINT_COVERAGE:BOOL=OFF # Set code coverage flags
ZINT_DEBUG:BOOL=OFF # Set debug compile flags ZINT_DEBUG:BOOL=OFF # Set debug compile flags
ZINT_FRONTEND:BOOL=ON # Build frontend ZINT_FRONTEND:BOOL=ON # Build frontend
ZINT_NOOPT:BOOL=OFF # Set no optimize compile flags ZINT_NOOPT:BOOL=OFF # Set no optimize compile flags
ZINT_SANITIZE:BOOL=OFF # Set sanitize compile/link flags
ZINT_SANITIZE:BOOL=OFF # Set sanitize address/undefined ZINT_SANITIZE:BOOL=OFF # Set sanitize address/undefined
ZINT_SANITIZEM:BOOL=OFF # Set sanitize memory (ignored if ZINT_SANITIZE) ZINT_SANITIZEM:BOOL=OFF # Set sanitize memory (ignored if ZINT_SANITIZE)
ZINT_SHARED:BOOL=ON # Build shared library ZINT_SHARED:BOOL=ON # Build shared library

View file

@ -105,11 +105,11 @@ static int c25_common(struct zint_symbol *symbol, const unsigned char source[],
expand(symbol, dest, d - dest); expand(symbol, dest, d - dest);
if (symbol->option_2 == 2 && !raw_text) { /* Exclude check digit from HRT if hidden */
/* Exclude check digit from HRT */ hrt_cpy_nochk(symbol, local_source, length - (symbol->option_2 == 2));
hrt_cpy_nochk(symbol, local_source, length - 1);
} else { if (raw_text && rt_cpy(symbol, local_source, length)) {
hrt_cpy_nochk(symbol, local_source, length); return ZINT_ERROR_MEMORY; /* `rt_cpy()` only fails with OOM */
} }
return 0; return 0;
@ -121,12 +121,6 @@ INTERNAL int c25standard(struct zint_symbol *symbol, unsigned char source[], int
return c25_common(symbol, source, length, 112, 1 /*is_matrix*/, C25MatrixStartStop, 6, 301); return c25_common(symbol, source, length, 112, 1 /*is_matrix*/, C25MatrixStartStop, 6, 301);
} }
/* Code 2 of 5 Industrial */
INTERNAL int c25ind(struct zint_symbol *symbol, unsigned char source[], int length) {
/* 10 + (79 + 1) * 14 + 9 = 1139 */
return c25_common(symbol, source, length, 79, 0 /*is_matrix*/, C25IndustStartStop, 6, 303);
}
/* Code 2 of 5 IATA */ /* Code 2 of 5 IATA */
INTERNAL int c25iata(struct zint_symbol *symbol, unsigned char source[], int length) { INTERNAL int c25iata(struct zint_symbol *symbol, unsigned char source[], int length) {
/* 4 + (80 + 1) * 14 + 5 = 1143 */ /* 4 + (80 + 1) * 14 + 5 = 1143 */
@ -139,4 +133,10 @@ INTERNAL int c25logic(struct zint_symbol *symbol, unsigned char source[], int le
return c25_common(symbol, source, length, 113, 1 /*is_matrix*/, C25IataLogicStartStop, 4, 307); return c25_common(symbol, source, length, 113, 1 /*is_matrix*/, C25IataLogicStartStop, 4, 307);
} }
/* Code 2 of 5 Industrial */
INTERNAL int c25ind(struct zint_symbol *symbol, unsigned char source[], int length) {
/* 10 + (79 + 1) * 14 + 9 = 1139 */
return c25_common(symbol, source, length, 79, 0 /*is_matrix*/, C25IndustStartStop, 6, 303);
}
/* vim: set ts=4 sw=4 et : */ /* vim: set ts=4 sw=4 et : */

View file

@ -117,11 +117,11 @@ INTERNAL int c25_inter_common(struct zint_symbol *symbol, unsigned char source[]
} }
} }
if (checkdigit_option == 2 && !raw_text) { /* Exclude check digit from HRT if hidden */
/* Exclude check digit from HRT */ hrt_cpy_nochk(symbol, local_source, length - (symbol->option_2 == 2));
hrt_cpy_nochk(symbol, local_source, length - 1);
} else { if (raw_text && rt_cpy(symbol, local_source, length)) {
hrt_cpy_nochk(symbol, local_source, length); return ZINT_ERROR_MEMORY; /* `rt_cpy()` only fails with OOM */
} }
return error_number; return error_number;

View file

@ -88,6 +88,8 @@ INTERNAL int itf14(struct zint_symbol *symbol, unsigned char source[], int lengt
hrt_cpy_nochk(symbol, local_source, 14); hrt_cpy_nochk(symbol, local_source, 14);
/* Use `raw_text` set by `c25_inter_common()` */
return error_number; return error_number;
} }
@ -106,7 +108,6 @@ INTERNAL int dpleit(struct zint_symbol *symbol, unsigned char source[], int leng
int factor; int factor;
unsigned char local_source[14]; unsigned char local_source[14];
int zeroes; int zeroes;
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT;
count = 0; count = 0;
if (length > 13) { if (length > 13) {
@ -134,14 +135,12 @@ INTERNAL int dpleit(struct zint_symbol *symbol, unsigned char source[], int leng
/* Based on eyeballing DIALOGPOST SCHWER, using 72X as default */ /* Based on eyeballing DIALOGPOST SCHWER, using 72X as default */
(void) set_height(symbol, 0.0f, 72.0f, 0.0f, 1 /*no_errtxt*/); (void) set_height(symbol, 0.0f, 72.0f, 0.0f, 1 /*no_errtxt*/);
if (raw_text) { /* HRT formatting as per DIALOGPOST SCHWER brochure but TEC-IT differs as do examples at
hrt_cpy_nochk(symbol, local_source, 14); https://www.philaseiten.de/cgi-bin/index.pl?ST=8615&CP=0&F=1#M147 */
} else { hrt_printf_nochk(symbol, "%.5s.%.3s.%.3s.%.3s", local_source, local_source + 5, local_source + 8,
/* HRT formatting as per DIALOGPOST SCHWER brochure but TEC-IT differs as do examples at local_source + 11);
https://www.philaseiten.de/cgi-bin/index.pl?ST=8615&CP=0&F=1#M147 */
hrt_printf_nochk(symbol, "%.5s.%.3s.%.3s.%.3s", local_source, local_source + 5, local_source + 8, /* Use `raw_text` set by `c25_inter_common()` */
local_source + 11);
}
return error_number; return error_number;
} }
@ -153,7 +152,6 @@ INTERNAL int dpident(struct zint_symbol *symbol, unsigned char source[], int len
unsigned int count; unsigned int count;
int factor; int factor;
unsigned char local_source[12]; unsigned char local_source[12];
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT;
count = 0; count = 0;
if (length > 11) { if (length > 11) {
@ -181,13 +179,11 @@ INTERNAL int dpident(struct zint_symbol *symbol, unsigned char source[], int len
/* Based on eyeballing DIALOGPOST SCHWER, using 72X as default */ /* Based on eyeballing DIALOGPOST SCHWER, using 72X as default */
(void) set_height(symbol, 0.0f, 72.0f, 0.0f, 1 /*no_errtxt*/); (void) set_height(symbol, 0.0f, 72.0f, 0.0f, 1 /*no_errtxt*/);
if (raw_text) { /* HRT formatting as per DIALOGPOST SCHWER brochure but TEC-IT differs as do other examples (see above) */
hrt_cpy_nochk(symbol, local_source, 12); hrt_printf_nochk(symbol, "%.2s.%.2s %c.%.3s.%.3s %c", local_source, local_source + 2, local_source[4],
} else { local_source + 5, local_source + 8, local_source[11]);
/* HRT formatting as per DIALOGPOST SCHWER brochure but TEC-IT differs as do other examples (see above) */
hrt_printf_nochk(symbol, "%.2s.%.2s %c.%.3s.%.3s %c", local_source, local_source + 2, local_source[4], /* Use `raw_text` set by `c25_inter_common()` */
local_source + 5, local_source + 8, local_source[11]);
}
return error_number; return error_number;
} }

View file

@ -277,9 +277,8 @@ INTERNAL int auspost(struct zint_symbol *symbol, unsigned char source[], int len
symbol->rows = 3; symbol->rows = 3;
symbol->width = writer - 1; symbol->width = writer - 1;
if (raw_text) { if (raw_text && rt_cpy_cat(symbol, fcc, 2, '\xFF' /*separator (none)*/, local_source, length)) {
hrt_cpy_nochk(symbol, fcc, 2); return ZINT_ERROR_MEMORY; /* `rt_cpy_cat()` only fails with OOM */
hrt_cat_nochk(symbol, local_source, length);
} }
return error_number; return error_number;

View file

@ -686,22 +686,30 @@ static int aztec_text_process(const unsigned char source[], int src_len, int bp,
} }
/* Call `aztec_text_process()` for each segment */ /* Call `aztec_text_process()` for each segment */
static int aztec_text_process_segs(struct zint_seg segs[], const int seg_count, int bp, char binary_string[], static int aztec_text_process_segs(struct zint_symbol *symbol, struct zint_seg segs[], const int seg_count, int bp,
const int gs1, const int gs1_bp, int *data_length, const int debug_print) { char binary_string[], const int gs1, const int gs1_bp, int *data_length, const int debug_print) {
int i; int i;
char current_mode = 'U'; char current_mode = 'U';
/* GS1 raw text dealt with by `ZBarcode_Encode_Segs()` */
const int raw_text = (symbol->input_mode & 0x07) != GS1_MODE && (symbol->output_options & BARCODE_RAW_TEXT);
if (raw_text && rt_init_segs(symbol, seg_count)) {
return ZINT_ERROR_MEMORY; /* `rt_init_segs()` only fails with OOM */
}
for (i = 0; i < seg_count; i++) { for (i = 0; i < seg_count; i++) {
if (!aztec_text_process(segs[i].source, segs[i].length, bp, binary_string, gs1, gs1_bp, segs[i].eci, if (!aztec_text_process(segs[i].source, segs[i].length, bp, binary_string, gs1, gs1_bp, segs[i].eci,
&current_mode, &bp, debug_print)) { &current_mode, &bp, debug_print)) {
return 0; return ZINT_ERROR_TOO_LONG; /* `aztec_text_process()` only fails with too long */
}
if (raw_text && rt_cpy_seg(symbol, i, &segs[i])) {
return ZINT_ERROR_MEMORY; /* `rt_cpy_seg()` only fails with OOM */
} }
} }
*data_length = bp; *data_length = bp;
return 1; return 0;
} }
/* Prevent data from obscuring reference grid */ /* Prevent data from obscuring reference grid */
@ -865,7 +873,7 @@ INTERNAL int aztec(struct zint_symbol *symbol, struct zint_seg segs[], const int
char adjusted_string[AZTEC_MAX_CAPACITY]; char adjusted_string[AZTEC_MAX_CAPACITY];
short AztecMap[AZTEC_MAP_SIZE]; short AztecMap[AZTEC_MAP_SIZE];
unsigned char desc_data[4], desc_ecc[6]; unsigned char desc_data[4], desc_ecc[6];
int error_number = 0; int error_number;
int compact, data_length, data_maxsize, codeword_size, adjusted_length; int compact, data_length, data_maxsize, codeword_size, adjusted_length;
int remainder, padbits, adjustment_size; int remainder, padbits, adjustment_size;
int bp = 0; int bp = 0;
@ -930,9 +938,14 @@ INTERNAL int aztec(struct zint_symbol *symbol, struct zint_seg segs[], const int
gs1_bp = bp; /* Initial FNC1 (FLG0) position */ gs1_bp = bp; /* Initial FNC1 (FLG0) position */
} }
if (!aztec_text_process_segs(segs, seg_count, bp, binary_string, gs1, gs1_bp, &data_length, debug_print)) { if ((error_number = aztec_text_process_segs(symbol, segs, seg_count, bp, binary_string, gs1, gs1_bp, &data_length,
return errtxt(ZINT_ERROR_TOO_LONG, symbol, 502, debug_print))) {
"Input too long, requires too many codewords (maximum " AZ_BIN_CAP_CWDS_S ")"); assert(error_number == ZINT_ERROR_TOO_LONG || error_number == ZINT_ERROR_MEMORY);
if (error_number == ZINT_ERROR_TOO_LONG) {
return errtxt(error_number, symbol, 502,
"Input too long, requires too many codewords (maximum " AZ_BIN_CAP_CWDS_S ")");
}
return error_number;
} }
assert(data_length > 0); /* Suppress clang-tidy warning: clang-analyzer-core.UndefinedBinaryOperatorResult */ assert(data_length > 0); /* Suppress clang-tidy warning: clang-analyzer-core.UndefinedBinaryOperatorResult */
@ -1121,6 +1134,8 @@ INTERNAL int aztec(struct zint_symbol *symbol, struct zint_seg segs[], const int
/* Feedback options: 0.165 = (.1 + .23) / 2 etc */ /* Feedback options: 0.165 = (.1 + .23) / 2 etc */
symbol->option_1 = ecc_ratio < 0.165f ? 1 : ecc_ratio < 0.295f ? 2 : ecc_ratio < 0.43f ? 3 : 4; symbol->option_1 = ecc_ratio < 0.165f ? 1 : ecc_ratio < 0.295f ? 2 : ecc_ratio < 0.43f ? 3 : 4;
} }
/* Feedback percentage in top byte */
symbol->option_1 |= ((int) (ecc_ratio * 100.0f)) << 8;
} }
if (debug_print) { if (debug_print) {
@ -1300,8 +1315,9 @@ INTERNAL int azrune(struct zint_symbol *symbol, unsigned char source[], int leng
char binary_string[28]; char binary_string[28];
unsigned char data_codewords[3], ecc_codewords[6]; unsigned char data_codewords[3], ecc_codewords[6];
int bp = 0; int bp = 0;
const int debug_print = symbol->debug & ZINT_DEBUG_PRINT;
rs_t rs; rs_t rs;
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT;
const int debug_print = symbol->debug & ZINT_DEBUG_PRINT;
input_value = 0; input_value = 0;
if (length > 3) { if (length > 3) {
@ -1363,6 +1379,10 @@ INTERNAL int azrune(struct zint_symbol *symbol, unsigned char source[], int leng
symbol->rows = 11; symbol->rows = 11;
symbol->width = 11; symbol->width = 11;
if (raw_text && rt_printf_256(symbol, "%03d", input_value)) {
return ZINT_ERROR_MEMORY; /* `rt_printf_256()` only fails with OOM */
}
return 0; return 0;
} }

View file

@ -72,6 +72,7 @@ INTERNAL int bc412(struct zint_symbol *symbol, unsigned char source[], int lengt
char dest[293]; /* 2 + (36 * 8) + 3 */ char dest[293]; /* 2 + (36 * 8) + 3 */
char *d = dest; char *d = dest;
int error_number = 0; int error_number = 0;
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT;
if (length > 18) { if (length > 18) {
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 790, "Input length %d too long (maximum 18)", length); return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 790, "Input length %d too long (maximum 18)", length);
@ -146,6 +147,10 @@ INTERNAL int bc412(struct zint_symbol *symbol, unsigned char source[], int lengt
hrt_cpy_nochk(symbol, padded_source, length + 1); hrt_cpy_nochk(symbol, padded_source, length + 1);
if (raw_text && rt_cpy(symbol, padded_source, length + 1)) {
return ZINT_ERROR_MEMORY; /* `rt_cpy()` only fails with OOM */
}
return error_number; return error_number;
} }

View file

@ -181,6 +181,7 @@ INTERNAL int channel(struct zint_symbol *symbol, unsigned char source[], int len
char *d = dest; char *d = dest;
int channels, i; int channels, i;
int error_number = 0, zeroes; int error_number = 0, zeroes;
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT;
if (length > 7) { if (length > 7) {
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 333, "Input length %d too long (maximum 7)", length); return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 333, "Input length %d too long (maximum 7)", length);
@ -250,13 +251,11 @@ INTERNAL int channel(struct zint_symbol *symbol, unsigned char source[], int len
} }
zeroes = channels - 1 - length; zeroes = channels - 1 - length;
if (zeroes > 0) { hrt_cpy_cat_nochk(symbol, zeroes_str, zeroes, '\xFF' /*separator (none)*/, source, length);
hrt_cpy_nochk(symbol, zeroes_str, zeroes);
hrt_cat_nochk(symbol, source, length);
} else {
hrt_cpy_nochk(symbol, source, length);
}
if (raw_text && rt_cpy_cat(symbol, zeroes_str, zeroes, '\xFF' /*separator (none)*/, source, length)) {
return ZINT_ERROR_MEMORY; /* `rt_cpy_cat()` only fails with OOM */
}
return error_number; return error_number;
} }

View file

@ -134,11 +134,13 @@ INTERNAL int codabar(struct zint_symbol *symbol, unsigned char source[], int len
(void) set_height(symbol, 0.0f, 50.0f, 0.0f, 1 /*no_errtxt*/); (void) set_height(symbol, 0.0f, 50.0f, 0.0f, 1 /*no_errtxt*/);
} }
if (symbol->option_2 == 2 || (raw_text && add_checksum)) { /* If visible check char, place before final A/B/C/D character (BS EN 798:1995 A.3) */
/* Place before final A/B/C/D character (BS EN 798:1995 A.3) */ hrt_cpy_cat_nochk(symbol, source, length - 1, symbol->option_2 == 2 ? CALCIUM[checksum] : '\xFF',
hrt_printf_nochk(symbol, "%.*s%c%c", length - 1, source, CALCIUM[checksum], source[length - 1]); source + length - 1, 1);
} else {
hrt_cpy_nochk(symbol, source, length); if (raw_text && rt_cpy_cat(symbol, source, length - 1,
add_checksum ? CALCIUM[checksum] : '\xFF', source + length - 1, 1)) {
return ZINT_ERROR_MEMORY; /* `rt_cpy_cat()` only fails with OOM */
} }
return error_number; return error_number;

View file

@ -547,6 +547,7 @@ INTERNAL int codablockf(struct zint_symbol *symbol, unsigned char source[], int
unsigned char *data; unsigned char *data;
int *pSet; int *pSet;
uchar *pOutput; uchar *pOutput;
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT;
/* Suppresses clang-analyzer-core.VLASize warning */ /* Suppresses clang-analyzer-core.VLASize warning */
assert(length > 0); assert(length > 0);
@ -562,6 +563,7 @@ INTERNAL int codablockf(struct zint_symbol *symbol, unsigned char source[], int
symbol->border_width = 1; /* AIM ISS-X-24 Section 4.6.1 b) (note change from previous default 2) */ symbol->border_width = 1; /* AIM ISS-X-24 Section 4.6.1 b) (note change from previous default 2) */
} }
hrt_cpy_nochk(symbol, (const unsigned char *) "", 0); /* Zap HRT for compatibility with CODABLOCKF */ hrt_cpy_nochk(symbol, (const unsigned char *) "", 0); /* Zap HRT for compatibility with CODABLOCKF */
/* Use `raw_text` from `code128()` */
if (symbol->output_options & COMPLIANT_HEIGHT) { if (symbol->output_options & COMPLIANT_HEIGHT) {
/* AIM ISS-X-24 Section 4.6.1 minimum row height 8X (for compatibility with CODABLOCKF, not specced /* AIM ISS-X-24 Section 4.6.1 minimum row height 8X (for compatibility with CODABLOCKF, not specced
for CODE128) */ for CODE128) */
@ -877,6 +879,10 @@ INTERNAL int codablockf(struct zint_symbol *symbol, unsigned char source[], int
symbol->border_width = 1; /* AIM ISS-X-24 Section 4.6.1 b) (note change from previous default 2) */ symbol->border_width = 1; /* AIM ISS-X-24 Section 4.6.1 b) (note change from previous default 2) */
} }
if (raw_text && rt_cpy(symbol, source, length)) {
return ZINT_ERROR_MEMORY; /* `rt_cpy()` only fails with OOM */
}
return error_number; return error_number;
} }

View file

@ -122,11 +122,11 @@ static const char C93Table[47][6] = {
INTERNAL int code39(struct zint_symbol *symbol, unsigned char source[], int length) { INTERNAL int code39(struct zint_symbol *symbol, unsigned char source[], int length) {
int i; int i;
int counter; int counter;
int error_number = 0;
int posns[86]; int posns[86];
char dest[890]; /* 10 (Start) + 86 * 10 + 10 (Check) + 9 (Stop) + 1 = 890 */ char dest[890]; /* 10 (Start) + 86 * 10 + 10 (Check) + 9 (Stop) + 1 = 890 */
char *d = dest; char *d = dest;
char check_digit = '\0'; char check_digit = '\0';
int error_number = 0;
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT; const int raw_text = symbol->output_options & BARCODE_RAW_TEXT;
if ((symbol->option_2 < 0) || (symbol->option_2 > 2)) { if ((symbol->option_2 < 0) || (symbol->option_2 > 2)) {
@ -212,10 +212,10 @@ INTERNAL int code39(struct zint_symbol *symbol, unsigned char source[], int leng
} }
/* Display a space check digit as _, otherwise it looks like an error */ /* Display a space check digit as _, otherwise it looks like an error */
if (symbol->option_2 == 1 && !raw_text && check_digit == ' ') { if (symbol->option_2 == 1 && check_digit == ' ') {
check_digit = '_'; check_digit = '_';
} }
if (symbol->symbology == BARCODE_CODE39 && !raw_text) { if (symbol->symbology == BARCODE_CODE39) {
hrt_cpy_chr(symbol, '*'); hrt_cpy_chr(symbol, '*');
hrt_cat_nochk(symbol, source, length); hrt_cat_nochk(symbol, source, length);
if (symbol->option_2 == 1) { /* Visible check digit */ if (symbol->option_2 == 1) { /* Visible check digit */
@ -223,29 +223,34 @@ INTERNAL int code39(struct zint_symbol *symbol, unsigned char source[], int leng
} }
hrt_cat_chr_nochk(symbol, '*'); hrt_cat_chr_nochk(symbol, '*');
} else { } else {
hrt_cpy_nochk(symbol, source, length); hrt_cpy_cat_nochk(symbol, source, length, symbol->option_2 == 1 ? check_digit : '\xFF', NULL /*cat*/, 0);
if (symbol->option_2 == 1 || (raw_text && check_digit)) { }
hrt_cat_chr_nochk(symbol, check_digit);
if (raw_text) {
if (rt_cpy_cat(symbol, source, length, check_digit ? check_digit == '_' ? ' ' : check_digit : '\xFF',
NULL /*cat*/, 0)) {
return ZINT_ERROR_MEMORY; /* `rt_cpy_cat()` only fails with OOM */
} }
} }
return error_number; return error_number;
} }
/* Extended Code 39 - ISO/IEC 16388:2007 Annex A */ /* Extended Code 39 - ISO/IEC 16388:2007 Annex A */
INTERNAL int excode39(struct zint_symbol *symbol, unsigned char source[], int length) { INTERNAL int excode39(struct zint_symbol *symbol, unsigned char source[], int length) {
int i;
unsigned char buffer[86 * 2 + 1] = {0}; unsigned char buffer[86 * 2 + 1] = {0};
unsigned char *b = buffer; unsigned char *b = buffer;
unsigned char check_digit = '\0'; unsigned char check_digit = '\0';
int i;
int error_number; int error_number;
const int saved_option_2 = symbol->option_2;
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT; const int raw_text = symbol->output_options & BARCODE_RAW_TEXT;
if (length > 86) { if (length > 86) {
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 328, "Input length %d too long (maximum 86)", length); return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 328, "Input length %d too long (maximum 86)", length);
} }
/* Creates a buffer string and places control characters into it */ /* Create a buffer string and place control characters into it */
for (i = 0; i < length; i++) { for (i = 0; i < length; i++) {
if (!z_isascii(source[i])) { if (!z_isascii(source[i])) {
/* Cannot encode extended ASCII */ /* Cannot encode extended ASCII */
@ -261,20 +266,41 @@ INTERNAL int excode39(struct zint_symbol *symbol, unsigned char source[], int le
} }
*b = '\0'; *b = '\0';
/* Then sends the buffer to the C39 function */ if (saved_option_2 == 2) {
error_number = code39(symbol, buffer, b - buffer); symbol->option_2 = 1; /* Make hidden check digit visible so returned in HRT */
}
if (raw_text) {
symbol->output_options &= ~BARCODE_RAW_TEXT; /* Don't use `code39()`'s `raw_text` */
}
/* Then send the buffer to the C39 function */
if ((error_number = code39(symbol, buffer, b - buffer)) >= ZINT_ERROR) {
return error_number;
}
if (saved_option_2 == 2) {
symbol->option_2 = 2; /* Restore */
}
if (raw_text) {
symbol->output_options |= BARCODE_RAW_TEXT; /* Restore */
}
/* Save visible (or BARCODE_RAW_TEXT) check digit */ /* Save visible (or BARCODE_RAW_TEXT) check digit */
if (symbol->option_2 == 1 || (raw_text && symbol->option_2 == 2)) { if (symbol->option_2 == 1 || (raw_text && symbol->option_2 == 2)) {
check_digit = symbol->text[symbol->text_length - 1]; check_digit = symbol->text[symbol->text_length - 1];
} }
/* Copy over source to HRT, subbing space for unprintables (unless BARCODE_RAW_TEXT) */ /* Copy over source to HRT, subbing space for unprintables */
(void) hrt_cpy_iso8859_1(symbol, source, length); /* Will fit (ASCII, length <= 86) */ (void) hrt_cpy_iso8859_1(symbol, source, length); /* Will fit (ASCII, length <= 86) */
if (check_digit) { if (symbol->option_2 == 1) {
hrt_cat_chr_nochk(symbol, check_digit); hrt_cat_chr_nochk(symbol, check_digit);
} }
if (raw_text && rt_cpy_cat(symbol, source, length, check_digit ? check_digit == '_' ? ' ' : check_digit : '\xFF',
NULL /*cat*/, 0)) {
return ZINT_ERROR_MEMORY; /* `rt_cpy_cat()` only fails with OOM */
}
return error_number; return error_number;
} }
@ -379,11 +405,15 @@ INTERNAL int code93(struct zint_symbol *symbol, unsigned char source[], int leng
} }
(void) hrt_cpy_iso8859_1(symbol, source, length); /* Will fit (ASCII, length <= 123) */ (void) hrt_cpy_iso8859_1(symbol, source, length); /* Will fit (ASCII, length <= 123) */
if (symbol->option_2 == 1 || raw_text) { if (symbol->option_2 == 1) {
hrt_cat_chr_nochk(symbol, SILVER[c]); hrt_cat_chr_nochk(symbol, SILVER[c]);
hrt_cat_chr_nochk(symbol, SILVER[k]); hrt_cat_chr_nochk(symbol, SILVER[k]);
} }
if (raw_text && rt_cpy_cat(symbol, source, length, SILVER[c], (const unsigned char *) SILVER + k, 1)) {
return ZINT_ERROR_MEMORY; /* `rt_cpy_cat()` only fails with OOM */
}
return error_number; return error_number;
} }
@ -473,11 +503,10 @@ INTERNAL int vin(struct zint_symbol *symbol, unsigned char source[], int length)
expand(symbol, dest, d - dest); expand(symbol, dest, d - dest);
if (raw_text && symbol->option_2 == 1) { hrt_cpy_nochk(symbol, source, length);
hrt_cpy_chr(symbol, 'I');
hrt_cat_nochk(symbol, source, length); if (raw_text && rt_cpy_cat(symbol, NULL /*source*/, 0, symbol->option_2 == 1 ? 'I' : '\xFF', source, length)) {
} else { return ZINT_ERROR_MEMORY; /* `rt_cpy_cat()` only fails with OOM */
hrt_cpy_nochk(symbol, source, length);
} }
/* Specification of dimensions/height for BARCODE_VIN unlikely */ /* Specification of dimensions/height for BARCODE_VIN unlikely */

View file

@ -978,15 +978,26 @@ static int c1_encode(struct zint_symbol *symbol, unsigned char source[], int len
/* Call `c1_encode()` for each segment */ /* Call `c1_encode()` for each segment */
static int c1_encode_segs(struct zint_symbol *symbol, struct zint_seg segs[], const int seg_count, const int gs1, static int c1_encode_segs(struct zint_symbol *symbol, struct zint_seg segs[], const int seg_count, const int gs1,
unsigned int target[], int *p_last_mode) { unsigned int target[], int *p_data_length, int *p_last_mode) {
int i; int i;
int tp = 0; int tp = 0;
/* GS1 raw text dealt with by `ZBarcode_Encode_Segs()` */
const int raw_text = !gs1 && (symbol->output_options & BARCODE_RAW_TEXT);
if (raw_text && rt_init_segs(symbol, seg_count)) {
return ZINT_ERROR_MEMORY; /* `rt_init_segs()` only fails with OOM */
}
for (i = 0; i < seg_count; i++) { for (i = 0; i < seg_count; i++) {
tp = c1_encode(symbol, segs[i].source, segs[i].length, segs[i].eci, seg_count, gs1, target, &tp, p_last_mode); tp = c1_encode(symbol, segs[i].source, segs[i].length, segs[i].eci, seg_count, gs1, target, &tp, p_last_mode);
if (raw_text && rt_cpy_seg(symbol, i, &segs[i])) {
return ZINT_ERROR_MEMORY; /* `rt_cpy_seg()` only fails with OOM */
}
} }
return tp; *p_data_length = tp;
return 0;
} }
/* Set symbol from datagrid */ /* Set symbol from datagrid */
@ -1061,6 +1072,7 @@ INTERNAL int codeone(struct zint_symbol *symbol, struct zint_seg segs[], const i
large_uint elreg; large_uint elreg;
unsigned int target[30], ecc[15]; unsigned int target[30], ecc[15];
int block_width; int block_width;
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT; /* GS1 mode ignored for Version S */
if (seg_count > 1) { if (seg_count > 1) {
return errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 715, "Multiple segments not supported for Version S"); return errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 715, "Multiple segments not supported for Version S");
@ -1096,6 +1108,10 @@ INTERNAL int codeone(struct zint_symbol *symbol, struct zint_seg segs[], const i
printf("Subversion: %d\n", sub_version); printf("Subversion: %d\n", sub_version);
} }
if (raw_text && rt_cpy(symbol, segs[0].source, segs[0].length)) {
return ZINT_ERROR_MEMORY; /* `rt_cpy()` only fails with OOM */
}
/* Convert value plus one to binary */ /* Convert value plus one to binary */
large_load_str_u64(&elreg, segs[0].source, segs[0].length); large_load_str_u64(&elreg, segs[0].source, segs[0].length);
large_add_u64(&elreg, 1); large_add_u64(&elreg, 1);
@ -1148,7 +1164,9 @@ INTERNAL int codeone(struct zint_symbol *symbol, struct zint_seg segs[], const i
i); i);
} }
data_length = c1_encode_segs(symbol, segs, seg_count, gs1, target, &last_mode); if (c1_encode_segs(symbol, segs, seg_count, gs1, target, &data_length, &last_mode)) {
return ZINT_ERROR_MEMORY; /* `c1_encode_segs()` only returns non-zero with OOM */
}
assert(data_length); /* Can't exceed C1_MAX_CWS as input <= 90 */ assert(data_length); /* Can't exceed C1_MAX_CWS as input <= 90 */
if (data_length > 38) { if (data_length > 38) {
@ -1231,7 +1249,9 @@ INTERNAL int codeone(struct zint_symbol *symbol, struct zint_seg segs[], const i
int blocks, data_blocks, ecc_blocks, ecc_length; int blocks, data_blocks, ecc_blocks, ecc_length;
int last_mode; int last_mode;
data_length = c1_encode_segs(symbol, segs, seg_count, gs1, target, &last_mode); if (c1_encode_segs(symbol, segs, seg_count, gs1, target, &data_length, &last_mode)) {
return ZINT_ERROR_MEMORY; /* `c1_encode_segs()` only returns non-zero with OOM */
}
if (data_length == 0) { if (data_length == 0) {
return errtxt(ZINT_ERROR_TOO_LONG, symbol, 517, return errtxt(ZINT_ERROR_TOO_LONG, symbol, 517,

View file

@ -47,16 +47,16 @@ static const char C11Table[11 + 1][6] = {
/* Code 11 */ /* Code 11 */
INTERNAL int code11(struct zint_symbol *symbol, unsigned char source[], int length) { INTERNAL int code11(struct zint_symbol *symbol, unsigned char source[], int length) {
static const unsigned char checkchrs[11] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-' };
int i; int i;
int h; int h;
int weight[141]; /* 140 + 1 extra for 1st check */ int weight[141]; /* 140 + 1 extra for 1st check */
char dest[864]; /* 6 + 140 * 6 + 2 * 6 + 5 + 1 = 864 */ char dest[864]; /* 6 + 140 * 6 + 2 * 6 + 5 + 1 = 864 */
int error_number = 0;
char *d = dest; char *d = dest;
int num_check_digits; int num_check_digits;
unsigned char checkstr[2]; unsigned char checkstr[2];
static const unsigned char checkchrs[11] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-' }; int error_number = 0;
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT;
/* Suppresses clang-tidy clang-analyzer-core.UndefinedBinaryOperatorResult warning */ /* Suppresses clang-tidy clang-analyzer-core.UndefinedBinaryOperatorResult warning */
assert(length > 0); assert(length > 0);
@ -150,6 +150,11 @@ INTERNAL int code11(struct zint_symbol *symbol, unsigned char source[], int leng
if (num_check_digits) { if (num_check_digits) {
hrt_cat_nochk(symbol, checkstr, num_check_digits); hrt_cat_nochk(symbol, checkstr, num_check_digits);
} }
if (raw_text && rt_cpy_cat(symbol, source, length, '\xFF' /*separator (none)*/, checkstr, num_check_digits)) {
return ZINT_ERROR_MEMORY; /* `rt_cpy_cat()` only fails with OOM */
}
return error_number; return error_number;
} }

View file

@ -381,6 +381,7 @@ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int len
unsigned char *src = source; unsigned char *src = source;
const int ab_only = symbol->symbology == BARCODE_CODE128AB; const int ab_only = symbol->symbology == BARCODE_CODE128AB;
const int start_idx = (symbol->output_options & READER_INIT) ? 2 : 0; const int start_idx = (symbol->output_options & READER_INIT) ? 2 : 0;
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT;
if (length > C128_MAX) { if (length > C128_MAX) {
/* This only blocks ridiculously long input - the actual length of the /* This only blocks ridiculously long input - the actual length of the
@ -491,7 +492,11 @@ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int len
} }
length = j; length = j;
} }
error_number = hrt_cpy_iso8859_1(symbol, src, length); error_number = hrt_cpy_iso8859_1(symbol, src, length); /* Returns warning only */
if (raw_text && rt_cpy(symbol, src, length)) {
return ZINT_ERROR_MEMORY; /* `rt_cpy()` only fails with OOM */
}
return error_number; return error_number;
} }
@ -634,14 +639,14 @@ INTERNAL int gs1_128_cc(struct zint_symbol *symbol, unsigned char source[], int
} }
/* Note won't overflow `text` buffer due to symbol character maximum restricted to C128_SYMBOL_MAX */ /* Note won't overflow `text` buffer due to symbol character maximum restricted to C128_SYMBOL_MAX */
if (raw_text) { if (symbol->input_mode & GS1PARENS_MODE) {
hrt_cpy_nochk(symbol, reduced, reduced_length); hrt_cpy_nochk(symbol, source, length);
} else { } else {
if (symbol->input_mode & GS1PARENS_MODE) { hrt_conv_gs1_brackets_nochk(symbol, source, length);
hrt_cpy_nochk(symbol, source, length); }
} else {
hrt_conv_gs1_brackets_nochk(symbol, source, length); if (raw_text && rt_cpy(symbol, reduced, reduced_length)) {
} return ZINT_ERROR_MEMORY; /* `rt_cpy()` only fails with OOM */
} }
return error_number; return error_number;

View file

@ -31,6 +31,7 @@
*/ */
/* SPDX-License-Identifier: BSD-3-Clause */ /* SPDX-License-Identifier: BSD-3-Clause */
#include <assert.h>
#include <stdio.h> #include <stdio.h>
#include "common.h" #include "common.h"
#include "code128.h" #include "code128.h"
@ -47,8 +48,8 @@ static int nve18_or_ean14(struct zint_symbol *symbol, unsigned char source[], co
{ "(00)", "[00]" }, /* NVE18 */ { "(00)", "[00]" }, /* NVE18 */
}; };
unsigned char ean128_equiv[23]; unsigned char ean128_equiv[23];
int error_number, zeroes; int i, zeroes;
int i; int error_number;
if (length > data_len) { if (length > data_len) {
return ZEXT errtxtf(ZINT_ERROR_TOO_LONG, symbol, 345, "Input length %1$d too long (maximum %2$d)", length, return ZEXT errtxtf(ZINT_ERROR_TOO_LONG, symbol, 345, "Input length %1$d too long (maximum %2$d)", length,
@ -71,6 +72,8 @@ static int nve18_or_ean14(struct zint_symbol *symbol, unsigned char source[], co
error_number = gs1_128(symbol, ean128_equiv, data_len + 5); error_number = gs1_128(symbol, ean128_equiv, data_len + 5);
/* Use `raw_text` set by `gs1_128()` */
return error_number; return error_number;
} }
@ -92,16 +95,15 @@ static const char KRSET[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
/* Specification at https://esolutions.dpd.com/dokumente/DPD_Parcel_Label_Specification_2.4.1_EN.pdf /* Specification at https://esolutions.dpd.com/dokumente/DPD_Parcel_Label_Specification_2.4.1_EN.pdf
* and identification tag info (Barcode ID) at https://esolutions.dpd.com/dokumente/DPD_Routing_Database_1.3_EN.pdf */ * and identification tag info (Barcode ID) at https://esolutions.dpd.com/dokumente/DPD_Routing_Database_1.3_EN.pdf */
INTERNAL int dpd(struct zint_symbol *symbol, unsigned char source[], int length) { INTERNAL int dpd(struct zint_symbol *symbol, unsigned char source[], int length) {
int error_number = 0;
int i, p; int i, p;
unsigned char ident_tag; unsigned char ident_tag;
unsigned char local_source_buf[29]; unsigned char local_source_buf[29];
unsigned char *local_source; unsigned char *local_source;
unsigned char hrt[37]; unsigned char hrt[37];
int cd; /* Check digit */
int error_number;
const int mod = 36; const int mod = 36;
const int relabel = symbol->option_2 == 1; /* A "relabel" has no identification tag */ const int relabel = symbol->option_2 == 1; /* A "relabel" has no identification tag */
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT;
int cd; /* Check digit */
if ((length != 27 && length != 28) || (length == 28 && relabel)) { if ((length != 27 && length != 28) || (length == 28 && relabel)) {
if (relabel) { if (relabel) {
@ -137,7 +139,10 @@ INTERNAL int dpd(struct zint_symbol *symbol, unsigned char source[], int length)
"Invalid DPD identification tag (first character), ASCII values 32 to 126 only"); "Invalid DPD identification tag (first character), ASCII values 32 to 126 only");
} }
(void) code128(symbol, local_source, length); /* Only error returned is for large text which can't happen */ if ((error_number = code128(symbol, local_source, length))) {
assert(error_number == ZINT_ERROR_MEMORY); /* Too long can't happen */
return error_number;
}
if (!(symbol->output_options & (BARCODE_BOX | BARCODE_BIND | BARCODE_BIND_TOP))) { if (!(symbol->output_options & (BARCODE_BOX | BARCODE_BIND | BARCODE_BIND_TOP))) {
/* If no option has been selected then uses default bind top option */ /* If no option has been selected then uses default bind top option */
@ -171,19 +176,17 @@ INTERNAL int dpd(struct zint_symbol *symbol, unsigned char source[], int length)
cd *= 2; cd *= 2;
if (cd >= (mod + 1)) cd -= mod + 1; if (cd >= (mod + 1)) cd -= mod + 1;
if (!raw_text) { switch (i + relabel) {
switch (i + relabel) { case 4:
case 4: case 7:
case 7: case 11:
case 11: case 15:
case 15: case 19:
case 19: case 21:
case 21: case 24:
case 24: case 27:
case 27: hrt[p++] = ' ';
hrt[p++] = ' '; break;
break;
}
} }
} }
@ -194,6 +197,8 @@ INTERNAL int dpd(struct zint_symbol *symbol, unsigned char source[], int length)
hrt_cpy_nochk(symbol, hrt, p + 1); hrt_cpy_nochk(symbol, hrt, p + 1);
/* Use `raw_text` from `code128()` */
/* Some compliance checks */ /* Some compliance checks */
if (not_sane(NEON_F, local_source + length - 16, 16)) { if (not_sane(NEON_F, local_source + length - 16, 16)) {
if (not_sane(NEON_F, local_source + length - 3, 3)) { /* 3-digit Country Code (ISO 3166-1) */ if (not_sane(NEON_F, local_source + length - 3, 3)) { /* 3-digit Country Code (ISO 3166-1) */
@ -214,13 +219,12 @@ INTERNAL int dpd(struct zint_symbol *symbol, unsigned char source[], int length)
/* https://www.upu.int/UPU/media/upu/files/postalSolutions/programmesAndServices/standards/S10-12.pdf */ /* https://www.upu.int/UPU/media/upu/files/postalSolutions/programmesAndServices/standards/S10-12.pdf */
INTERNAL int upu_s10(struct zint_symbol *symbol, unsigned char source[], int length) { INTERNAL int upu_s10(struct zint_symbol *symbol, unsigned char source[], int length) {
static const char weights[8] = { 8, 6, 4, 2, 3, 5, 9, 7 }; static const char weights[8] = { 8, 6, 4, 2, 3, 5, 9, 7 };
int i, j;
unsigned char local_source[13 + 1]; unsigned char local_source[13 + 1];
unsigned char have_check_digit = '\0'; unsigned char have_check_digit = '\0';
int check_digit;
int error_number = 0;
unsigned char hrt[18]; unsigned char hrt[18];
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT; int i, j;
int check_digit;
int error_number;
if (length != 12 && length != 13) { if (length != 12 && length != 13) {
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 834, "Input length %d wrong (12 or 13 characters required)", return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 834, "Input length %d wrong (12 or 13 characters required)",
@ -271,6 +275,11 @@ INTERNAL int upu_s10(struct zint_symbol *symbol, unsigned char source[], int len
local_source[10] = itoc(check_digit); local_source[10] = itoc(check_digit);
local_source[13] = '\0'; /* Terminating NUL required by `c128_cost()` */ local_source[13] = '\0'; /* Terminating NUL required by `c128_cost()` */
if ((error_number = code128(symbol, local_source, 13))) {
assert(error_number == ZINT_ERROR_MEMORY); /* Too long can't happen */
return error_number;
}
/* Do some checks on the Service Indicator (first char only) and Country Code */ /* Do some checks on the Service Indicator (first char only) and Country Code */
if (strchr("JKSTW", local_source[0]) != NULL) { /* These are reserved & cannot be assigned */ if (strchr("JKSTW", local_source[0]) != NULL) { /* These are reserved & cannot be assigned */
error_number = errtxtf(ZINT_WARN_NONCOMPLIANT, symbol, 839, error_number = errtxtf(ZINT_WARN_NONCOMPLIANT, symbol, 839,
@ -284,18 +293,16 @@ INTERNAL int upu_s10(struct zint_symbol *symbol, unsigned char source[], int len
"Country Code '%.2s' (last two characters) is not ISO 3166-1", local_source + 11); "Country Code '%.2s' (last two characters) is not ISO 3166-1", local_source + 11);
} }
(void) code128(symbol, local_source, 13); /* Only error returned is for large text which can't happen */
for (i = 0, j = 0; i < 13; i++) { for (i = 0, j = 0; i < 13; i++) {
if (!raw_text) { if (i == 2 || i == 5 || i == 8 || i == 11) {
if (i == 2 || i == 5 || i == 8 || i == 11) { hrt[j++] = ' ';
hrt[j++] = ' ';
}
} }
hrt[j++] = local_source[i]; hrt[j++] = local_source[i];
} }
hrt_cpy_nochk(symbol, hrt, j); hrt_cpy_nochk(symbol, hrt, j);
/* Use `raw_text` set by `code128()` */
if (symbol->output_options & COMPLIANT_HEIGHT) { if (symbol->output_options & COMPLIANT_HEIGHT) {
/* Universal Postal Union S10 Section 8, using max X 0.51mm & minimum height 12.5mm or 15% of width */ /* Universal Postal Union S10 Section 8, using max X 0.51mm & minimum height 12.5mm or 15% of width */
const float min_height_min = 24.5098038f; /* 12.5 / 0.51 */ const float min_height_min = 24.5098038f; /* 12.5 / 0.51 */

View file

@ -334,6 +334,8 @@ INTERNAL int code16k(struct zint_symbol *symbol, unsigned char source[], int len
int bar_characters; int bar_characters;
int error_number = 0, first_sum, second_sum; int error_number = 0, first_sum, second_sum;
const int gs1 = (symbol->input_mode & 0x07) == GS1_MODE; const int gs1 = (symbol->input_mode & 0x07) == GS1_MODE;
/* GS1 raw text dealt with by `ZBarcode_Encode_Segs()` */
const int raw_text = !gs1 && (symbol->output_options & BARCODE_RAW_TEXT);
const int debug_print = symbol->debug & ZINT_DEBUG_PRINT; const int debug_print = symbol->debug & ZINT_DEBUG_PRINT;
if (length > C128_MAX) { if (length > C128_MAX) {
@ -597,6 +599,10 @@ INTERNAL int code16k(struct zint_symbol *symbol, unsigned char source[], int len
symbol->border_width = 1; /* BS EN 12323:2005 Section 4.3.7 minimum (note change from previous default 2) */ symbol->border_width = 1; /* BS EN 12323:2005 Section 4.3.7 minimum (note change from previous default 2) */
} }
if (raw_text && rt_cpy(symbol, source, length)) {
return ZINT_ERROR_MEMORY; /* `rt_cpy()` only fails with OOM */
}
return error_number; return error_number;
} }

View file

@ -51,6 +51,7 @@ INTERNAL int code49(struct zint_symbol *symbol, unsigned char source[], int leng
int gs1; int gs1;
int h; int h;
int error_number = 0; int error_number = 0;
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT;
if (length > 81) { if (length > 81) {
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 430, "Input length %d too long (maximum 81)", length); return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 430, "Input length %d too long (maximum 81)", length);
@ -388,6 +389,10 @@ INTERNAL int code49(struct zint_symbol *symbol, unsigned char source[], int leng
symbol->border_width = 1; /* ANSI/AIM BC6-2000 Section 2.1 (note change from previous default 2) */ symbol->border_width = 1; /* ANSI/AIM BC6-2000 Section 2.1 (note change from previous default 2) */
} }
if (!gs1 && raw_text && rt_cpy(symbol, source, length)) { /* GS1 dealt with by `ZBarcode_Encode_Segs()` */
return ZINT_ERROR_MEMORY; /* `rt_cpy()` only fails with OOM */
}
return error_number; return error_number;
} }

View file

@ -447,7 +447,7 @@ INTERNAL int errtxtf(const int error_number, struct zint_symbol *symbol, const i
} else if (specs[i] == 'd') { } else if (specs[i] == 'd') {
if (dpads[i][0]) { if (dpads[i][0]) {
char dpad_fmt[30]; /* Make 30 to suppress gcc 14 "-Wformat-overflow=" false positive */ char dpad_fmt[30]; /* Make 30 to suppress gcc 14 "-Wformat-overflow=" false positive */
sprintf(dpad_fmt, "%%0%sd", dpads[i]); /* TODO: keep `dpads` separate else last mentioned trumps */ sprintf(dpad_fmt, "%%0%sd", dpads[i]);
sprintf(dfgs[i], dpad_fmt, va_arg(ap, int)); sprintf(dfgs[i], dpad_fmt, va_arg(ap, int));
} else { } else {
sprintf(dfgs[i], "%d", va_arg(ap, int)); sprintf(dfgs[i], "%d", va_arg(ap, int));
@ -455,14 +455,14 @@ INTERNAL int errtxtf(const int error_number, struct zint_symbol *symbol, const i
} else if (specs[i] == 'f' || specs[i] == 'g') { } else if (specs[i] == 'f' || specs[i] == 'g') {
if (fprecs[i]) { if (fprecs[i]) {
char fprec_fmt[5]; char fprec_fmt[5];
sprintf(fprec_fmt, "%%.%c%c", fprecs[i], specs[i]); /* TODO: keep `fprecs` separate else last mentioned trumps */ sprintf(fprec_fmt, "%%.%c%c", fprecs[i], specs[i]);
sprintf(dfgs[i], fprec_fmt, va_arg(ap, double)); sprintf(dfgs[i], fprec_fmt, va_arg(ap, double));
} else { } else {
sprintf(dfgs[i], specs[i] == 'f' ? "%f" : "%g", va_arg(ap, double)); sprintf(dfgs[i], specs[i] == 'f' ? "%f" : "%g", va_arg(ap, double));
} }
} else if (specs[i] == 's') { } else if (specs[i] == 's') {
if (have_slens[i] && slens[i] == -1) { if (have_slens[i] && slens[i] == -1) {
slens[i] = va_arg(ap, int); /* TODO: keep `slens` separate else last mentioned trumps */ slens[i] = va_arg(ap, int);
} }
ss[i] = va_arg(ap, char *); ss[i] = va_arg(ap, char *);
} }
@ -743,18 +743,16 @@ INTERNAL int utf8_to_unicode(struct zint_symbol *symbol, const unsigned char sou
} }
/* Treats source as ISO/IEC 8859-1 and copies into `symbol->text`, converting to UTF-8. Control chars (incl. DEL) and /* Treats source as ISO/IEC 8859-1 and copies into `symbol->text`, converting to UTF-8. Control chars (incl. DEL) and
non-ISO/IEC 8859-1 (0x80-9F) are replaced with spaces, unless BARCODE_RAW_TEXT set in `output_options`. non-ISO/IEC 8859-1 (0x80-9F) are replaced with spaces. Returns warning if truncated, else 0 */
Returns warning if truncated, else 0 */
INTERNAL int hrt_cpy_iso8859_1(struct zint_symbol *symbol, const unsigned char source[], const int length) { INTERNAL int hrt_cpy_iso8859_1(struct zint_symbol *symbol, const unsigned char source[], const int length) {
int i, j; int i, j;
int warn_number = 0; int warn_number = 0;
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT;
for (i = 0, j = 0; i < length && j < ARRAY_SIZE(symbol->text); i++) { for (i = 0, j = 0; i < length && j < ARRAY_SIZE(symbol->text); i++) {
if (z_isascii(source[i])) { if (z_isascii(source[i])) {
symbol->text[j++] = !raw_text && z_iscntrl(source[i]) ? ' ' : source[i]; symbol->text[j++] = z_iscntrl(source[i]) ? ' ' : source[i];
} else if (source[i] < 0xC0) { } else if (source[i] < 0xC0) {
if (!raw_text && source[i] < 0xA0) { /* 0x80-0x9F not valid ISO/IEC 8859-1 */ if (source[i] < 0xA0) { /* 0x80-0x9F not valid ISO/IEC 8859-1 */
symbol->text[j++] = ' '; symbol->text[j++] = ' ';
} else { } else {
if (j + 2 >= ARRAY_SIZE(symbol->text)) { if (j + 2 >= ARRAY_SIZE(symbol->text)) {
@ -790,11 +788,34 @@ INTERNAL int hrt_cpy_iso8859_1(struct zint_symbol *symbol, const unsigned char s
INTERNAL void hrt_cpy_nochk(struct zint_symbol *symbol, const unsigned char source[], const int length) { INTERNAL void hrt_cpy_nochk(struct zint_symbol *symbol, const unsigned char source[], const int length) {
assert(length < ARRAY_SIZE(symbol->text)); assert(length < ARRAY_SIZE(symbol->text));
memcpy(symbol->text, source, length); memcpy(symbol->text, source, (size_t) length);
symbol->text_length = length; symbol->text_length = length;
symbol->text[length] = '\0'; symbol->text[length] = '\0';
} }
/* No-check as-is copy of ASCII into `symbol->text`, appending `separator` (if ASCII - use `\xFF` for none) and then
`cat`, assuming total length fits */
INTERNAL void hrt_cpy_cat_nochk(struct zint_symbol *symbol, const unsigned char source[], const int length,
const char separator, const unsigned char cat[], const int cat_length) {
unsigned char *t = symbol->text;
const int total_length = (length > 0 ? length : 0) + z_isascii(separator) + (cat_length > 0 ? cat_length : 0);
assert(total_length < ARRAY_SIZE(symbol->text));
if (length > 0) {
memcpy(t, source, (size_t) length);
t += length;
}
if (z_isascii(separator)) {
*t++ = (unsigned char) separator;
}
if (cat_length > 0) {
memcpy(t, cat, (size_t) cat_length);
}
symbol->text_length = total_length;
symbol->text[total_length] = '\0';
}
/* Copy a single ASCII character into `symbol->text` (i.e. replaces content) */ /* Copy a single ASCII character into `symbol->text` (i.e. replaces content) */
INTERNAL void hrt_cpy_chr(struct zint_symbol *symbol, const char ch) { INTERNAL void hrt_cpy_chr(struct zint_symbol *symbol, const char ch) {
symbol->text[0] = ch; symbol->text[0] = ch;
@ -806,7 +827,7 @@ INTERNAL void hrt_cpy_chr(struct zint_symbol *symbol, const char ch) {
INTERNAL void hrt_cat_nochk(struct zint_symbol *symbol, const unsigned char source[], const int length) { INTERNAL void hrt_cat_nochk(struct zint_symbol *symbol, const unsigned char source[], const int length) {
assert(symbol->text_length + length < ARRAY_SIZE(symbol->text)); assert(symbol->text_length + length < ARRAY_SIZE(symbol->text));
memcpy(symbol->text + symbol->text_length, source, length); memcpy(symbol->text + symbol->text_length, source, (size_t) length);
symbol->text_length += length; symbol->text_length += length;
symbol->text[symbol->text_length] = '\0'; symbol->text[symbol->text_length] = '\0';
} }
@ -859,6 +880,149 @@ INTERNAL void hrt_conv_gs1_brackets_nochk(struct zint_symbol *symbol, const unsi
symbol->text[length] = '\0'; symbol->text[length] = '\0';
} }
/* Initialize `raw_segs` for `seg_count` segments. On error sets `errtxt`, returning BARCODE_ERROR_MEMORY */
INTERNAL int rt_init_segs(struct zint_symbol *symbol, const int seg_count) {
int i;
if (symbol->raw_segs) {
rt_free_segs(symbol);
}
if (!(symbol->raw_segs = (struct zint_seg *) calloc((size_t) seg_count, sizeof(struct zint_seg)))) {
return errtxt(ZINT_ERROR_MEMORY, symbol, 243, "Insufficient memory for raw segs buffer");
}
for (i = 0; i < seg_count; i++) {
symbol->raw_segs[i].source = NULL;
}
symbol->raw_seg_count = seg_count;
return 0;
}
/* Free `raw_segs` along with any `source` buffers */
INTERNAL void rt_free_segs(struct zint_symbol *symbol) {
if (symbol->raw_segs) {
int i;
assert(symbol->raw_seg_count);
for (i = 0; i < symbol->raw_seg_count; i++) {
if (symbol->raw_segs[i].source) {
free(symbol->raw_segs[i].source);
}
}
free(symbol->raw_segs);
symbol->raw_segs = NULL;
}
symbol->raw_seg_count = 0;
}
/* Helper to initialize `raw_segs[seg_idx]` to receive text of `length` */
static int rt_init_seg_source(struct zint_symbol *symbol, const int seg_idx, const int length) {
assert(symbol->raw_segs);
assert(seg_idx >= 0 && seg_idx < symbol->raw_seg_count);
assert(!symbol->raw_segs[seg_idx].source);
assert(length > 0);
if (!(symbol->raw_segs[seg_idx].source = (unsigned char *) malloc((size_t) length))) {
return errtxt(ZINT_ERROR_MEMORY, symbol, 245, "Insufficient memory for raw text source buffer");
}
return 0;
}
/* Copy `seg` to raw seg `seg_idx`. If `seg->eci` not set, raw seg eci set to 3. On error sets `errtxt`, returning
BARCODE_ERROR_MEMORY */
INTERNAL int rt_cpy_seg(struct zint_symbol *symbol, const int seg_idx, const struct zint_seg *seg) {
if (rt_init_seg_source(symbol, seg_idx, seg->length)) {
return ZINT_ERROR_MEMORY; /* `rt_init_seg_source()` only fails with OOM */
}
memcpy(symbol->raw_segs[seg_idx].source, seg->source, (size_t) seg->length);
symbol->raw_segs[seg_idx].length = seg->length;
symbol->raw_segs[seg_idx].eci = seg->eci ? seg->eci : 3;
return 0;
}
/* Copy `seg` to raw seg `seg_idx` using `ddata` converted to chars as source. If `eci` set, used instead of
`seg->eci`, and if neither set, sets raw seg eci to 3. On error sets `errtxt`, returning BARCODE_ERROR_MEMORY */
INTERNAL int rt_cpy_seg_ddata(struct zint_symbol *symbol, const int seg_idx, const struct zint_seg *seg,
const int eci, const unsigned int *ddata) {
unsigned char *s;
int i;
if (rt_init_seg_source(symbol, seg_idx, seg->length * 2)) {
return ZINT_ERROR_MEMORY; /* `rt_init_seg_source()` only fails with OOM */
}
for (i = 0, s = symbol->raw_segs[seg_idx].source; i < seg->length; i++) {
if (ddata[i] & 0xFF00) {
*s++ = (unsigned char) ((ddata[i] >> 8) & 0xFF);
}
*s++ = (unsigned char) (ddata[i] & 0xFF);
}
symbol->raw_segs[seg_idx].length = (int) (s - symbol->raw_segs[seg_idx].source);
symbol->raw_segs[seg_idx].eci = eci ? eci : seg->eci ? seg->eci : 3;
return 0;
}
/* Copy `source` to raw seg 0 buffer, setting raw seg ECI to 3. On error sets `errtxt`, returning
BARCODE_ERROR_MEMORY */
INTERNAL int rt_cpy(struct zint_symbol *symbol, const unsigned char source[], const int length) {
if (rt_init_segs(symbol, 1 /*seg_count*/) || rt_init_seg_source(symbol, 0 /*seg_idx*/, length)) {
return ZINT_ERROR_MEMORY; /* `rt_init_segs()` & `rt_init_seg_source()` only fail with OOM */
}
memcpy(symbol->raw_segs[0].source, source, (size_t) length);
symbol->raw_segs[0].length = length;
symbol->raw_segs[0].eci = 3;
return 0;
}
/* Copy `source` to raw seg 0 buffer, appending `separator` (if ASCII - use `\xFF` for none) and then `cat`, and
setting raw seg ECI to 3. On error sets `errtxt`, returning BARCODE_ERROR_MEMORY */
INTERNAL int rt_cpy_cat(struct zint_symbol *symbol, const unsigned char source[], const int length,
const char separator, const unsigned char cat[], const int cat_length) {
unsigned char *s;
const int total_length = (length > 0 ? length : 0) + z_isascii(separator) + (cat_length > 0 ? cat_length : 0);
if (rt_init_segs(symbol, 1 /*seg_count*/) || rt_init_seg_source(symbol, 0 /*seg_idx*/, total_length)) {
return ZINT_ERROR_MEMORY; /* `rt_init_segs()` & `rt_init_seg_source()` only fail with OOM */
}
s = symbol->raw_segs[0].source;
if (length > 0) {
memcpy(s, source, (size_t) length);
s += length;
}
if (z_isascii(separator)) {
*s++ = (unsigned char) separator;
}
if (cat_length > 0) {
memcpy(s, cat, (size_t) cat_length);
}
symbol->raw_segs[0].length = total_length;
symbol->raw_segs[0].eci = 3;
return 0;
}
/* `sprintf()` into raw seg 0 buffer, assuming formatted data less than 256 bytes. Sets raw seg ECI to 3. On error
sets `errtxt`, returning BARCODE_ERROR_MEMORY */
INTERNAL int rt_printf_256(struct zint_symbol *symbol, const char *fmt, ...) {
va_list ap;
int size;
if (rt_init_segs(symbol, 1 /*seg_count*/) || rt_init_seg_source(symbol, 0 /*seg_idx*/, 256)) {
return ZINT_ERROR_MEMORY; /* `rt_init_segs()` & `rt_init_seg_source()` only fail with OOM */
}
va_start(ap, fmt);
size = vsprintf((char *) symbol->raw_segs[0].source, fmt, ap);
assert(size >= 0);
assert(size < 256);
symbol->raw_segs[0].length = size;
symbol->raw_segs[0].eci = 3;
va_end(ap);
return 0;
}
/* Sets symbol height, returning a warning if not within minimum and/or maximum if given. /* Sets symbol height, returning a warning if not within minimum and/or maximum if given.
`default_height` does not include height of fixed-height rows (i.e. separators/composite data) */ `default_height` does not include height of fixed-height rows (i.e. separators/composite data) */
INTERNAL int set_height(struct zint_symbol *symbol, const float min_row_height, const float default_height, INTERNAL int set_height(struct zint_symbol *symbol, const float min_row_height, const float default_height,

View file

@ -301,13 +301,17 @@ INTERNAL int utf8_to_unicode(struct zint_symbol *symbol, const unsigned char sou
int *length, const int disallow_4byte); int *length, const int disallow_4byte);
/* Treats source as ISO/IEC 8859-1 and copies into `symbol->text`, converting to UTF-8. Control chars (incl. DEL) and /* Treats source as ISO/IEC 8859-1 and copies into `symbol->text`, converting to UTF-8. Control chars (incl. DEL) and
non-ISO/IEC 8859-1 (0x80-9F) are replaced with spaces, unless BARCODE_RAW_TEXT set in `output_options`. non-ISO/IEC 8859-1 (0x80-9F) are replaced with spaces. Returns warning if truncated, else 0 */
Returns warning if truncated, else 0 */
INTERNAL int hrt_cpy_iso8859_1(struct zint_symbol *symbol, const unsigned char source[], const int length); INTERNAL int hrt_cpy_iso8859_1(struct zint_symbol *symbol, const unsigned char source[], const int length);
/* No-check as-is copy of ASCII into `symbol->text`, assuming `length` fits */ /* No-check as-is copy of ASCII into `symbol->text`, assuming `length` fits */
INTERNAL void hrt_cpy_nochk(struct zint_symbol *symbol, const unsigned char source[], const int length); INTERNAL void hrt_cpy_nochk(struct zint_symbol *symbol, const unsigned char source[], const int length);
/* No-check as-is copy of ASCII into `symbol->text`, appending `separator` (if ASCII - use `\xFF` for none) and then
`cat`, assuming total length fits */
INTERNAL void hrt_cpy_cat_nochk(struct zint_symbol *symbol, const unsigned char source[], const int length,
const char separator, const unsigned char cat[], const int cat_length);
/* Copy a single ASCII character into `symbol->text` (i.e. replaces content) */ /* Copy a single ASCII character into `symbol->text` (i.e. replaces content) */
INTERNAL void hrt_cpy_chr(struct zint_symbol *symbol, const char ch); INTERNAL void hrt_cpy_chr(struct zint_symbol *symbol, const char ch);
@ -324,6 +328,35 @@ INTERNAL void hrt_printf_nochk(struct zint_symbol *symbol, const char *fmt, ...)
INTERNAL void hrt_conv_gs1_brackets_nochk(struct zint_symbol *symbol, const unsigned char source[], const int length); INTERNAL void hrt_conv_gs1_brackets_nochk(struct zint_symbol *symbol, const unsigned char source[], const int length);
/* Initialize `raw_segs` for `seg_count` segments. On error sets `errtxt`, returning BARCODE_ERROR_MEMORY */
INTERNAL int rt_init_segs(struct zint_symbol *symbol, const int seg_count);
/* Free `raw_segs` along with any `source` buffers */
INTERNAL void rt_free_segs(struct zint_symbol *symbol);
/* Copy `seg` to raw seg `seg_idx`. If `seg->eci` not set, raw seg eci set to 3. On error sets `errtxt`, returning
BARCODE_ERROR_MEMORY */
INTERNAL int rt_cpy_seg(struct zint_symbol *symbol, const int seg_idx, const struct zint_seg *seg);
/* Copy `seg` to raw seg `seg_idx` using `ddata` converted to chars as source. If `eci` set, used instead of
`seg->eci`, and if neither set, sets raw seg eci to 3. On error sets `errtxt`, returning BARCODE_ERROR_MEMORY */
INTERNAL int rt_cpy_seg_ddata(struct zint_symbol *symbol, const int seg_idx, const struct zint_seg *seg,
const int eci, const unsigned int *ddata);
/* Copy `source` to raw seg 0 buffer, setting raw seg ECI to 3. On error sets `errtxt`, returning
BARCODE_ERROR_MEMORY */
INTERNAL int rt_cpy(struct zint_symbol *symbol, const unsigned char source[], const int length);
/* Copy `source` to raw seg 0 buffer, appending `separator` (if ASCII - use `\xFF` for none) and then `cat`, and
setting raw seg ECI to 3. On error sets `errtxt`, returning BARCODE_ERROR_MEMORY */
INTERNAL int rt_cpy_cat(struct zint_symbol *symbol, const unsigned char source[], const int length,
const char separator, const unsigned char cat[], const int cat_length);
/* `sprintf()` into raw seg 0 buffer, assuming formatted data less than 256 bytes. Sets raw seg ECI to 3. On error
sets `errtxt`, returning BARCODE_ERROR_MEMORY */
INTERNAL int rt_printf_256(struct zint_symbol *symbol, const char *fmt, ...) ZINT_FORMAT_PRINTF(2, 3);
/* Sets symbol height, returning a warning if not within minimum and/or maximum if given. /* Sets symbol height, returning a warning if not within minimum and/or maximum if given.
`default_height` does not include height of fixed-height rows (i.e. separators/composite data) */ `default_height` does not include height of fixed-height rows (i.e. separators/composite data) */
INTERNAL int set_height(struct zint_symbol *symbol, const float min_row_height, const float default_height, INTERNAL int set_height(struct zint_symbol *symbol, const float min_row_height, const float default_height,

View file

@ -1242,6 +1242,7 @@ INTERNAL int composite(struct zint_symbol *symbol, unsigned char source[], int l
struct zint_symbol *linear; struct zint_symbol *linear;
int top_shift, bottom_shift; int top_shift, bottom_shift;
int linear_width = 0; int linear_width = 0;
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT;
const int debug_print = symbol->debug & ZINT_DEBUG_PRINT; const int debug_print = symbol->debug & ZINT_DEBUG_PRINT;
if (debug_print) printf("Reduced length: %d\n", length); if (debug_print) printf("Reduced length: %d\n", length);
@ -1589,6 +1590,15 @@ INTERNAL int composite(struct zint_symbol *symbol, unsigned char source[], int l
hrt_cpy_nochk(symbol, linear->text, linear->text_length); hrt_cpy_nochk(symbol, linear->text, linear->text_length);
if (raw_text) {
assert(linear->raw_segs && linear->raw_segs[0].source);
/* First linear, then pipe '|' separator (following BWIPP), then composite */
if (rt_cpy_cat(symbol, linear->raw_segs[0].source, linear->raw_segs[0].length, '|', source, length)) {
ZBarcode_Delete(linear);
return ZINT_ERROR_MEMORY; /* `rt_cpy_cat()` only fails with OOM */
}
}
ZBarcode_Delete(linear); ZBarcode_Delete(linear);
return error_number ? error_number : warn_number; return error_number ? error_number : warn_number;

View file

@ -1528,7 +1528,8 @@ static int dm_encode(struct zint_symbol *symbol, const unsigned char source[], c
error_number = dm_minimalenc(symbol, source, length, last_seg, &sp, target, &tp, process_buffer, &process_p, error_number = dm_minimalenc(symbol, source, length, last_seg, &sp, target, &tp, process_buffer, &process_p,
&b256_start, &current_mode, gs1, debug_print); &b256_start, &current_mode, gs1, debug_print);
} }
if (error_number != 0) { if (error_number) {
assert(error_number >= ZINT_ERROR);
return error_number; return error_number;
} }
@ -1685,6 +1686,8 @@ static int dm_encode_segs(struct zint_symbol *symbol, struct zint_seg segs[], co
int gs1; int gs1;
int in_macro = 0; int in_macro = 0;
const struct zint_seg *last_seg = &segs[seg_count - 1]; const struct zint_seg *last_seg = &segs[seg_count - 1];
/* GS1 raw text dealt with by `ZBarcode_Encode_Segs()` */
const int raw_text = (symbol->input_mode & 0x07) != GS1_MODE && (symbol->output_options & BARCODE_RAW_TEXT);
const int debug_print = symbol->debug & ZINT_DEBUG_PRINT; const int debug_print = symbol->debug & ZINT_DEBUG_PRINT;
if ((i = segs_length(segs, seg_count)) > 3116) { /* Max is 3166 digits */ if ((i = segs_length(segs, seg_count)) > 3116) { /* Max is 3166 digits */
@ -1798,6 +1801,10 @@ static int dm_encode_segs(struct zint_symbol *symbol, struct zint_seg segs[], co
in_macro = 1; in_macro = 1;
} }
if (raw_text && rt_init_segs(symbol, seg_count)) {
return ZINT_ERROR_MEMORY; /* `rt_init_segs()` only fails with OOM */
}
for (i = 0; i < seg_count; i++) { for (i = 0; i < seg_count; i++) {
int src_inc = 0, len_dec = 0; int src_inc = 0, len_dec = 0;
if (in_macro) { if (in_macro) {
@ -1808,11 +1815,14 @@ static int dm_encode_segs(struct zint_symbol *symbol, struct zint_seg segs[], co
len_dec += 2; /* Remove RS + EOT from end */ len_dec += 2; /* Remove RS + EOT from end */
} }
} }
error_number = dm_encode(symbol, segs[i].source + src_inc, segs[i].length - len_dec, segs[i].eci, if ((error_number = dm_encode(symbol, segs[i].source + src_inc, segs[i].length - len_dec, segs[i].eci,
i + 1 == seg_count, gs1, target, &tp); i + 1 == seg_count, gs1, target, &tp))) {
if (error_number != 0) { assert(error_number >= ZINT_ERROR);
return error_number; return error_number;
} }
if (raw_text && rt_cpy_seg(symbol, i, &segs[i])) { /* Note including macro header and RS + EOT */
return ZINT_ERROR_MEMORY; /* `rt_cpy_seg()` only fails with OOM */
}
} }
*p_binlen = tp; *p_binlen = tp;

View file

@ -1000,7 +1000,7 @@ static int dc_encode_message(struct zint_symbol *symbol, const unsigned char sou
/* Call `dc_encode_message()` for each segment */ /* Call `dc_encode_message()` for each segment */
static int dc_encode_message_segs(struct zint_symbol *symbol, const struct zint_seg segs[], const int seg_count, static int dc_encode_message_segs(struct zint_symbol *symbol, const struct zint_seg segs[], const int seg_count,
unsigned char *codeword_array, int *p_binary_finish, unsigned char structapp_array[], unsigned char *codeword_array, int *p_binary_finish, int *p_data_length, unsigned char structapp_array[],
int *p_structapp_size) { int *p_structapp_size) {
int i; int i;
@ -1011,6 +1011,8 @@ static int dc_encode_message_segs(struct zint_symbol *symbol, const struct zint_
int inside_macro = 0; int inside_macro = 0;
uint64_t bin_buf = 0; uint64_t bin_buf = 0;
int bin_buf_size = 0; int bin_buf_size = 0;
/* GS1 raw text dealt with by `ZBarcode_Encode_Segs()` */
const int raw_text = (symbol->input_mode & 0x07) != GS1_MODE && (symbol->output_options & BARCODE_RAW_TEXT);
const struct zint_seg *last_seg = &segs[seg_count - 1]; const struct zint_seg *last_seg = &segs[seg_count - 1];
@ -1019,15 +1021,23 @@ static int dc_encode_message_segs(struct zint_symbol *symbol, const struct zint_
last_RSEOT = last_seg->source[last_seg->length - 2] == 30; /* RS */ last_RSEOT = last_seg->source[last_seg->length - 2] == 30; /* RS */
} }
if (raw_text && rt_init_segs(symbol, seg_count)) {
return ZINT_ERROR_MEMORY; /* `rt_init_segs()` only fails with OOM */
}
for (i = 0; i < seg_count; i++) { for (i = 0; i < seg_count; i++) {
ap = dc_encode_message(symbol, segs[i].source, segs[i].length, segs[i].eci, i == seg_count - 1 /*last_seg*/, ap = dc_encode_message(symbol, segs[i].source, segs[i].length, segs[i].eci, i == seg_count - 1 /*last_seg*/,
last_EOT, last_RSEOT, ap, codeword_array, &encoding_mode, &inside_macro, &bin_buf, &bin_buf_size, last_EOT, last_RSEOT, ap, codeword_array, &encoding_mode, &inside_macro, &bin_buf, &bin_buf_size,
structapp_array, p_structapp_size); structapp_array, p_structapp_size);
if (raw_text && rt_cpy_seg(symbol, i, &segs[i])) { /* Note including macro header and RS + EOT */
return ZINT_ERROR_MEMORY; /* `rt_cpy_seg()` only fails with OOM */
}
} }
*p_binary_finish = encoding_mode == 'X'; *p_binary_finish = encoding_mode == 'X';
*p_data_length = ap + *p_structapp_size;
return ap + *p_structapp_size; return 0;
} }
/* Convert codewords to binary data stream */ /* Convert codewords to binary data stream */
@ -1269,8 +1279,10 @@ INTERNAL int dotcode(struct zint_symbol *symbol, struct zint_seg segs[], const i
} }
} }
data_length = dc_encode_message_segs(symbol, segs, seg_count, codeword_array, &binary_finish, structapp_array, if (dc_encode_message_segs(symbol, segs, seg_count, codeword_array, &binary_finish, &data_length,
&structapp_size); structapp_array, &structapp_size)) {
return ZINT_ERROR_MEMORY; /* `rt_cpy_seg()` etc. only fail with OOM */
}
/* Suppresses clang-tidy clang-analyzer-core.UndefinedBinaryOperatorResult/uninitialized.ArraySubscript /* Suppresses clang-tidy clang-analyzer-core.UndefinedBinaryOperatorResult/uninitialized.ArraySubscript
* warnings */ * warnings */

View file

@ -246,8 +246,8 @@ static int dx_parse_code(struct zint_symbol *symbol, const unsigned char *source
*output_length = bp; *output_length = bp;
if (raw_text) { if (raw_text && rt_printf_256(symbol, "%04d%s", (dx_code_1 << 4) | dx_code_2, frame_info)) {
hrt_printf_nochk(symbol, "%04d%s", (dx_code_1 << 4) | dx_code_2, frame_info); return ZINT_ERROR_MEMORY; /* `rt_printf_256()` only fails with OOM */
} }
return 0; return 0;

View file

@ -911,15 +911,20 @@ INTERNAL void sjis_cpy(const unsigned char source[], int *p_length, unsigned int
} }
/* Call `sjis_cpy()` for each segment */ /* Call `sjis_cpy()` for each segment */
INTERNAL void sjis_cpy_segs(struct zint_seg segs[], const int seg_count, unsigned int *ddata, INTERNAL int sjis_cpy_segs(struct zint_symbol *symbol, struct zint_seg segs[], const int seg_count,
const int full_multibyte) { unsigned int *ddata, const int full_multibyte) {
int i; int i;
unsigned int *dd = ddata; unsigned int *dd = ddata;
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT; /* Note only called for DATA_MODE */
for (i = 0; i < seg_count; i++) { for (i = 0; i < seg_count; i++) {
sjis_cpy(segs[i].source, &segs[i].length, dd, full_multibyte); sjis_cpy(segs[i].source, &segs[i].length, dd, full_multibyte);
if (raw_text && rt_cpy_seg_ddata(symbol, i, &segs[i], 0 /*eci*/, dd)) {
return ZINT_ERROR_MEMORY; /* `rt_cpy_seg_ddata()` only fails with OOM */
}
dd += segs[i].length; dd += segs[i].length;
} }
return 0;
} }
/* Convert UTF-8 string to ECI and place in array of ints using `sjis_cpy()` */ /* Convert UTF-8 string to ECI and place in array of ints using `sjis_cpy()` */
@ -1013,15 +1018,21 @@ INTERNAL void gb2312_cpy_test(const unsigned char source[], int *p_length, unsig
#endif #endif
/* Call `gb2312_cpy()` for each segment */ /* Call `gb2312_cpy()` for each segment */
INTERNAL void gb2312_cpy_segs(struct zint_seg segs[], const int seg_count, unsigned int *ddata, INTERNAL int gb2312_cpy_segs(struct zint_symbol *symbol, struct zint_seg segs[], const int seg_count,
const int full_multibyte) { unsigned int *ddata, const int full_multibyte) {
int i; int i;
unsigned int *dd = ddata; unsigned int *dd = ddata;
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT;
for (i = 0; i < seg_count; i++) { for (i = 0; i < seg_count; i++) {
const int eci = segs[i].eci ? segs[i].eci : 29; /* Need to set as `rt_cpy_seg_ddata()` defaults to 3 */
gb2312_cpy(segs[i].source, &segs[i].length, dd, full_multibyte); gb2312_cpy(segs[i].source, &segs[i].length, dd, full_multibyte);
if (raw_text && rt_cpy_seg_ddata(symbol, i, &segs[i], eci, dd)) {
return ZINT_ERROR_MEMORY; /* `rt_cpy_seg_ddata()` only fails with OOM */
}
dd += segs[i].length; dd += segs[i].length;
} }
return 0;
} }
/* Convert UTF-8 string to ECI and place in array of ints using `gb2312_cpy()` */ /* Convert UTF-8 string to ECI and place in array of ints using `gb2312_cpy()` */
@ -1132,15 +1143,20 @@ INTERNAL void gb18030_cpy_test(const unsigned char source[], int *p_length, unsi
#endif #endif
/* Call `gb18030_cpy()` for each segment */ /* Call `gb18030_cpy()` for each segment */
INTERNAL void gb18030_cpy_segs(struct zint_seg segs[], const int seg_count, unsigned int *ddata, INTERNAL int gb18030_cpy_segs(struct zint_symbol *symbol, struct zint_seg segs[], const int seg_count,
const int full_multibyte) { unsigned int *ddata, const int full_multibyte) {
int i; int i;
unsigned int *dd = ddata; unsigned int *dd = ddata;
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT;
for (i = 0; i < seg_count; i++) { for (i = 0; i < seg_count; i++) {
gb18030_cpy(segs[i].source, &segs[i].length, dd, full_multibyte); gb18030_cpy(segs[i].source, &segs[i].length, dd, full_multibyte);
if (raw_text && rt_cpy_seg_ddata(symbol, i, &segs[i], 0 /*eci*/, dd)) {
return ZINT_ERROR_MEMORY; /* `rt_cpy_seg_ddata()` only fails with OOM */
}
dd += segs[i].length; dd += segs[i].length;
} }
return 0;
} }
/* Convert UTF-8 string to ECI and place in array of ints using `gb18030_cpy()` */ /* Convert UTF-8 string to ECI and place in array of ints using `gb18030_cpy()` */

View file

@ -52,24 +52,24 @@ INTERNAL int get_best_eci_segs(struct zint_symbol *symbol, struct zint_seg segs[
INTERNAL int sjis_utf8(struct zint_symbol *symbol, const unsigned char source[], int *p_length, INTERNAL int sjis_utf8(struct zint_symbol *symbol, const unsigned char source[], int *p_length,
unsigned int *ddata); unsigned int *ddata);
INTERNAL void sjis_cpy(const unsigned char source[], int *p_length, unsigned int *ddata, const int full_multibyte); INTERNAL void sjis_cpy(const unsigned char source[], int *p_length, unsigned int *ddata, const int full_multibyte);
INTERNAL void sjis_cpy_segs(struct zint_seg segs[], const int seg_count, unsigned int *ddata, INTERNAL int sjis_cpy_segs(struct zint_symbol *symbol, struct zint_seg segs[], const int seg_count,
const int full_multibyte); unsigned int *ddata, const int full_multibyte);
INTERNAL int sjis_utf8_to_eci(const int eci, const unsigned char source[], int *p_length, unsigned int *ddata, INTERNAL int sjis_utf8_to_eci(const int eci, const unsigned char source[], int *p_length, unsigned int *ddata,
const int full_multibyte); const int full_multibyte);
/* GRIDMATRIX GB 2312 helpers */ /* GRIDMATRIX GB 2312 helpers */
INTERNAL int gb2312_utf8(struct zint_symbol *symbol, const unsigned char source[], int *p_length, INTERNAL int gb2312_utf8(struct zint_symbol *symbol, const unsigned char source[], int *p_length,
unsigned int *ddata); unsigned int *ddata);
INTERNAL void gb2312_cpy_segs(struct zint_seg segs[], const int seg_count, unsigned int *ddata, INTERNAL int gb2312_cpy_segs(struct zint_symbol *symbol, struct zint_seg segs[], const int seg_count,
const int full_multibyte); unsigned int *ddata, const int full_multibyte);
INTERNAL int gb2312_utf8_to_eci(const int eci, const unsigned char source[], int *p_length, unsigned int *ddata, INTERNAL int gb2312_utf8_to_eci(const int eci, const unsigned char source[], int *p_length, unsigned int *ddata,
const int full_multibyte); const int full_multibyte);
/* HANXIN GB 18030 helpers */ /* HANXIN GB 18030 helpers */
INTERNAL int gb18030_utf8(struct zint_symbol *symbol, const unsigned char source[], int *p_length, INTERNAL int gb18030_utf8(struct zint_symbol *symbol, const unsigned char source[], int *p_length,
unsigned int *ddata); unsigned int *ddata);
INTERNAL void gb18030_cpy_segs(struct zint_seg segs[], const int seg_count, unsigned int *ddata, INTERNAL int gb18030_cpy_segs(struct zint_symbol *symbol, struct zint_seg segs[], const int seg_count,
const int full_multibyte); unsigned int *ddata, const int full_multibyte);
INTERNAL int gb18030_utf8_to_eci(const int eci, const unsigned char source[], int *p_length, unsigned int *ddata, INTERNAL int gb18030_utf8_to_eci(const int eci, const unsigned char source[], int *p_length, unsigned int *ddata,
const int full_multibyte); const int full_multibyte);

View file

@ -1024,6 +1024,7 @@ INTERNAL int gridmatrix(struct zint_symbol *symbol, struct zint_seg segs[], cons
const struct zint_structapp *p_structapp = NULL; const struct zint_structapp *p_structapp = NULL;
int size_squared; int size_squared;
int bin_len; int bin_len;
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT;
const int debug_print = symbol->debug & ZINT_DEBUG_PRINT; const int debug_print = symbol->debug & ZINT_DEBUG_PRINT;
const int eci_length_segs = get_eci_length_segs(segs, seg_count); const int eci_length_segs = get_eci_length_segs(segs, seg_count);
struct zint_seg *local_segs = (struct zint_seg *) z_alloca(sizeof(struct zint_seg) * seg_count); struct zint_seg *local_segs = (struct zint_seg *) z_alloca(sizeof(struct zint_seg) * seg_count);
@ -1035,29 +1036,39 @@ INTERNAL int gridmatrix(struct zint_symbol *symbol, struct zint_seg segs[], cons
/* If ZINT_FULL_MULTIBYTE set use Hanzi mode in DATA_MODE or for non-GB 2312 in UNICODE_MODE */ /* If ZINT_FULL_MULTIBYTE set use Hanzi mode in DATA_MODE or for non-GB 2312 in UNICODE_MODE */
full_multibyte = (symbol->option_3 & 0xFF) == ZINT_FULL_MULTIBYTE; full_multibyte = (symbol->option_3 & 0xFF) == ZINT_FULL_MULTIBYTE;
if (raw_text && rt_init_segs(symbol, seg_count)) {
return ZINT_ERROR_MEMORY; /* `rt_init_segs()` only fails with OOM */
}
if ((symbol->input_mode & 0x07) == DATA_MODE) { if ((symbol->input_mode & 0x07) == DATA_MODE) {
gb2312_cpy_segs(local_segs, seg_count, ddata, full_multibyte); if (gb2312_cpy_segs(symbol, local_segs, seg_count, ddata, full_multibyte)) {
return ZINT_ERROR_MEMORY; /* `gb18030_cpy_segs()` only fails with OOM */
}
} else { } else {
unsigned int *dd = ddata; unsigned int *dd = ddata;
for (i = 0; i < seg_count; i++) { for (i = 0; i < seg_count; i++) {
int done = 0; int eci = 0;
if (local_segs[i].eci != 0 && local_segs[i].eci != 29) { /* Unless default or ECI 29 (GB 2312) */ if (local_segs[i].eci != 0 && local_segs[i].eci != 29) { /* Unless default or ECI 29 (GB 2312) */
/* Try other conversions */ /* Try other conversions */
error_number = gb2312_utf8_to_eci(local_segs[i].eci, local_segs[i].source, &local_segs[i].length, error_number = gb2312_utf8_to_eci(local_segs[i].eci, local_segs[i].source, &local_segs[i].length,
dd, full_multibyte); dd, full_multibyte);
if (error_number == 0) { if (error_number == 0) {
done = 1; eci = local_segs[i].eci;
} else { } else {
return errtxtf(error_number, symbol, 535, "Invalid character in input for ECI '%d'", return errtxtf(error_number, symbol, 535, "Invalid character in input for ECI '%d'",
local_segs[i].eci); local_segs[i].eci);
} }
} }
if (!done) { if (!eci) {
/* Try GB 2312 (EUC-CN) */ /* Try GB 2312 (EUC-CN) */
error_number = gb2312_utf8(symbol, local_segs[i].source, &local_segs[i].length, dd); error_number = gb2312_utf8(symbol, local_segs[i].source, &local_segs[i].length, dd);
if (error_number != 0) { if (error_number != 0) {
return error_number; return error_number;
} }
eci = 29;
}
if (raw_text && rt_cpy_seg_ddata(symbol, i, &local_segs[i], eci, dd)) {
return ZINT_ERROR_MEMORY; /* `rt_cpy_seg_ddata()` only fails with OOM */
} }
dd += local_segs[i].length; dd += local_segs[i].length;
} }

View file

@ -1488,6 +1488,7 @@ INTERNAL int hanxin(struct zint_symbol *symbol, struct zint_seg segs[], const in
int size_squared; int size_squared;
int codewords; int codewords;
int bin_len; int bin_len;
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT;
const int debug_print = symbol->debug & ZINT_DEBUG_PRINT; const int debug_print = symbol->debug & ZINT_DEBUG_PRINT;
const int eci_length_segs = get_eci_length_segs(segs, seg_count); const int eci_length_segs = get_eci_length_segs(segs, seg_count);
struct zint_seg *local_segs = (struct zint_seg *) z_alloca(sizeof(struct zint_seg) * seg_count); struct zint_seg *local_segs = (struct zint_seg *) z_alloca(sizeof(struct zint_seg) * seg_count);
@ -1508,12 +1509,18 @@ INTERNAL int hanxin(struct zint_symbol *symbol, struct zint_seg segs[], const in
user_mask = 0; /* Ignore */ user_mask = 0; /* Ignore */
} }
if (raw_text && rt_init_segs(symbol, seg_count)) {
return ZINT_ERROR_MEMORY; /* `rt_init_segs()` only fails with OOM */
}
if ((symbol->input_mode & 0x07) == DATA_MODE) { if ((symbol->input_mode & 0x07) == DATA_MODE) {
gb18030_cpy_segs(local_segs, seg_count, ddata, full_multibyte); if (gb18030_cpy_segs(symbol, local_segs, seg_count, ddata, full_multibyte)) {
return ZINT_ERROR_MEMORY; /* `gb18030_cpy_segs()` only fails with OOM */
}
} else { } else {
unsigned int *dd = ddata; unsigned int *dd = ddata;
for (i = 0; i < seg_count; i++) { for (i = 0; i < seg_count; i++) {
int done = 0; int done = 0, eci = local_segs[i].eci;
if (local_segs[i].eci != 32 || seg_count > 1) { /* Unless ECI 32 (GB 18030) or have multiple segments */ if (local_segs[i].eci != 32 || seg_count > 1) { /* Unless ECI 32 (GB 18030) or have multiple segments */
/* Try other conversions (ECI 0 defaults to ISO/IEC 8859-1) */ /* Try other conversions (ECI 0 defaults to ISO/IEC 8859-1) */
int error_number = gb18030_utf8_to_eci(local_segs[i].eci, local_segs[i].source, &local_segs[i].length, int error_number = gb18030_utf8_to_eci(local_segs[i].eci, local_segs[i].source, &local_segs[i].length,
@ -1535,6 +1542,10 @@ INTERNAL int hanxin(struct zint_symbol *symbol, struct zint_seg segs[], const in
warn_number = errtxt(ZINT_WARN_NONCOMPLIANT, symbol, 543, warn_number = errtxt(ZINT_WARN_NONCOMPLIANT, symbol, 543,
"Converted to GB 18030 but no ECI specified"); "Converted to GB 18030 but no ECI specified");
} }
eci = 32;
}
if (raw_text && rt_cpy_seg_ddata(symbol, i, &local_segs[i], eci, dd)) {
return ZINT_ERROR_MEMORY; /* `rt_cpy_seg_ddata()` only fails with OOM */
} }
dd += local_segs[i].length; dd += local_segs[i].length;
} }

View file

@ -449,8 +449,8 @@ INTERNAL int usps_imail(struct zint_symbol *symbol, unsigned char source[], int
symbol->rows = 3; symbol->rows = 3;
symbol->width = read - 1; symbol->width = read - 1;
if (raw_text) { if (raw_text && rt_cpy(symbol, source, length)) {
hrt_cpy_nochk(symbol, source, length); return ZINT_ERROR_MEMORY; /* `rt_cpy()` only fails with OOM */
} }
return error_number; return error_number;

View file

@ -76,6 +76,7 @@ static void set_symbol_defaults(struct zint_symbol *symbol) {
symbol->alphamap = NULL; symbol->alphamap = NULL;
symbol->vector = NULL; symbol->vector = NULL;
symbol->memfile = NULL; symbol->memfile = NULL;
symbol->raw_segs = NULL;
} }
/* Create and initialize a symbol structure */ /* Create and initialize a symbol structure */
@ -107,6 +108,7 @@ void ZBarcode_Clear(struct zint_symbol *symbol) {
memset(symbol->text, 0, sizeof(symbol->text)); memset(symbol->text, 0, sizeof(symbol->text));
symbol->text_length = 0; symbol->text_length = 0;
symbol->errtxt[0] = '\0'; symbol->errtxt[0] = '\0';
if (symbol->bitmap != NULL) { if (symbol->bitmap != NULL) {
free(symbol->bitmap); free(symbol->bitmap);
symbol->bitmap = NULL; symbol->bitmap = NULL;
@ -117,12 +119,15 @@ void ZBarcode_Clear(struct zint_symbol *symbol) {
} }
symbol->bitmap_width = 0; symbol->bitmap_width = 0;
symbol->bitmap_height = 0; symbol->bitmap_height = 0;
if (symbol->memfile != NULL) { if (symbol->memfile != NULL) {
free(symbol->memfile); free(symbol->memfile);
symbol->memfile = NULL; symbol->memfile = NULL;
} }
symbol->memfile_size = 0; symbol->memfile_size = 0;
rt_free_segs(symbol);
/* If there is a rendered version, ensure its memory is released */ /* If there is a rendered version, ensure its memory is released */
vector_free(symbol); vector_free(symbol);
} }
@ -138,6 +143,7 @@ void ZBarcode_Reset(struct zint_symbol *symbol) {
if (symbol->memfile != NULL) if (symbol->memfile != NULL)
free(symbol->memfile); free(symbol->memfile);
rt_free_segs(symbol);
vector_free(symbol); vector_free(symbol);
memset(symbol, 0, sizeof(*symbol)); memset(symbol, 0, sizeof(*symbol));
@ -155,6 +161,7 @@ void ZBarcode_Delete(struct zint_symbol *symbol) {
if (symbol->memfile != NULL) if (symbol->memfile != NULL)
free(symbol->memfile); free(symbol->memfile);
rt_free_segs(symbol);
vector_free(symbol); vector_free(symbol);
free(symbol); free(symbol);
@ -261,8 +268,6 @@ static int error_tag(int error_number, struct zint_symbol *symbol, const int err
error_number = ZINT_ERROR_INVALID_OPTION; error_number = ZINT_ERROR_INVALID_OPTION;
} else if (error_number == ZINT_WARN_HRT_TRUNCATED) { } else if (error_number == ZINT_WARN_HRT_TRUNCATED) {
error_number = ZINT_ERROR_HRT_TRUNCATED; error_number = ZINT_ERROR_HRT_TRUNCATED;
} else if (error_number == ZINT_WARN_HRT_RAW_TEXT) {
error_number = ZINT_ERROR_HRT_RAW_TEXT;
} else { /* Shouldn't happen */ } else { /* Shouldn't happen */
assert(0); /* Not reached */ assert(0); /* Not reached */
error_number = ZINT_ERROR_ENCODING_PROBLEM; error_number = ZINT_ERROR_ENCODING_PROBLEM;
@ -373,7 +378,6 @@ static int hibc(struct zint_symbol *symbol, struct zint_seg segs[], const int se
int counter, error_number = 0; int counter, error_number = 0;
char to_process[110 + 2 + 1]; char to_process[110 + 2 + 1];
int posns[110]; int posns[110];
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT;
/* without "+" and check: max 110 characters in HIBC 2.6 */ /* without "+" and check: max 110 characters in HIBC 2.6 */
if (length > 110) { if (length > 110) {
@ -402,27 +406,20 @@ static int hibc(struct zint_symbol *symbol, struct zint_seg segs[], const int se
if (symbol->debug & ZINT_DEBUG_PRINT) printf("HIBC processed source: %s\n", to_process); if (symbol->debug & ZINT_DEBUG_PRINT) printf("HIBC processed source: %s\n", to_process);
/* HIBC uses same `raw_text` as base symbologies */
switch (symbol->symbology) { switch (symbol->symbology) {
case BARCODE_HIBC_128: case BARCODE_HIBC_128:
error_number = code128(symbol, segs[0].source, segs[0].length); error_number = code128(symbol, segs[0].source, segs[0].length);
if (raw_text) { hrt_cpy_chr(symbol, '*');
hrt_cpy_nochk(symbol, segs[0].source, segs[0].length); hrt_cat_nochk(symbol, segs[0].source, segs[0].length);
} else { hrt_cat_chr_nochk(symbol, '*');
hrt_cpy_chr(symbol, '*');
hrt_cat_nochk(symbol, segs[0].source, segs[0].length);
hrt_cat_chr_nochk(symbol, '*');
}
break; break;
case BARCODE_HIBC_39: case BARCODE_HIBC_39:
symbol->option_2 = 0; symbol->option_2 = 0;
error_number = code39(symbol, segs[0].source, segs[0].length); error_number = code39(symbol, segs[0].source, segs[0].length);
if (raw_text) { hrt_cpy_chr(symbol, '*');
hrt_cpy_nochk(symbol, segs[0].source, segs[0].length); hrt_cat_nochk(symbol, segs[0].source, segs[0].length);
} else { hrt_cat_chr_nochk(symbol, '*');
hrt_cpy_chr(symbol, '*');
hrt_cat_nochk(symbol, segs[0].source, segs[0].length);
hrt_cat_chr_nochk(symbol, '*');
}
break; break;
case BARCODE_HIBC_DM: case BARCODE_HIBC_DM:
error_number = datamatrix(symbol, segs, seg_count); error_number = datamatrix(symbol, segs, seg_count);
@ -1222,16 +1219,19 @@ int ZBarcode_Encode_Segs(struct zint_symbol *symbol, const struct zint_seg segs[
strip_bom(local_segs[0].source, &local_segs[0].length); strip_bom(local_segs[0].source, &local_segs[0].length);
} }
if (((symbol->input_mode & 0x07) == GS1_MODE) || (check_force_gs1(symbol->symbology))) {
if ((symbol->input_mode & 0x07) == GS1_MODE || check_force_gs1(symbol->symbology)) {
if (gs1_compliant(symbol->symbology)) { if (gs1_compliant(symbol->symbology)) {
/* Reduce input for composite and non-forced symbologies, others (EAN128 and RSS_EXP based) will /* Reduce input for composite and non-forced symbologies, others (GS1_128 and DBAR_EXP based) will
handle it themselves */ handle it themselves */
if (is_composite(symbol->symbology) || !check_force_gs1(symbol->symbology)) { const int have_composite = is_composite(symbol->symbology);
if (have_composite || !check_force_gs1(symbol->symbology)) {
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT;
unsigned char *reduced = (unsigned char *) z_alloca(local_segs[0].length + 1); unsigned char *reduced = (unsigned char *) z_alloca(local_segs[0].length + 1);
error_number = gs1_verify(symbol, local_segs[0].source, local_segs[0].length, reduced, error_number = gs1_verify(symbol, local_segs[0].source, local_segs[0].length, reduced,
&local_segs[0].length); &local_segs[0].length);
if (error_number) { if (error_number) {
if (is_composite(symbol->symbology)) { if (have_composite) {
errtxt_adj(0, symbol, "%1$s%2$s", " (2D component)"); errtxt_adj(0, symbol, "%1$s%2$s", " (2D component)");
} }
error_number = error_tag(error_number, symbol, -1, NULL); error_number = error_tag(error_number, symbol, -1, NULL);
@ -1241,6 +1241,10 @@ int ZBarcode_Encode_Segs(struct zint_symbol *symbol, const struct zint_seg segs[
warn_number = error_number; /* Override any previous warning (errtxt has been overwritten) */ warn_number = error_number; /* Override any previous warning (errtxt has been overwritten) */
} }
memcpy(local_segs[0].source, reduced, local_segs[0].length + 1); /* Include terminating NUL */ memcpy(local_segs[0].source, reduced, local_segs[0].length + 1); /* Include terminating NUL */
/* Set raw text for non-composites (composites set their own raw text) */
if (!have_composite && raw_text && rt_cpy(symbol, reduced, local_segs[0].length)) {
return error_tag(ZINT_ERROR_MEMORY, symbol, -1, NULL); /* `rt_cpy()` only fails with OOM */
}
} }
} else { } else {
return error_tag(ZINT_ERROR_INVALID_OPTION, symbol, 210, "Selected symbology does not support GS1 mode"); return error_tag(ZINT_ERROR_INVALID_OPTION, symbol, 210, "Selected symbology does not support GS1 mode");
@ -1274,6 +1278,7 @@ int ZBarcode_Encode_Segs(struct zint_symbol *symbol, const struct zint_seg segs[
if (symbol->height < 0.5f) { /* Absolute minimum */ if (symbol->height < 0.5f) { /* Absolute minimum */
(void) set_height(symbol, 0.0f, 50.0f, 0.0f, 1 /*no_errtxt*/); (void) set_height(symbol, 0.0f, 50.0f, 0.0f, 1 /*no_errtxt*/);
} }
assert(!(symbol->output_options & BARCODE_RAW_TEXT) || (symbol->raw_segs && symbol->raw_seg_count));
} }
return error_number; return error_number;

View file

@ -170,7 +170,6 @@ INTERNAL int daft_set_height(struct zint_symbol *symbol, const float min_height,
/* Royal Mail 4-state Mailmark */ /* Royal Mail 4-state Mailmark */
INTERNAL int mailmark_4s(struct zint_symbol *symbol, unsigned char source[], int length) { INTERNAL int mailmark_4s(struct zint_symbol *symbol, unsigned char source[], int length) {
unsigned char local_source[28]; unsigned char local_source[28];
int format; int format;
int version_id; int version_id;
@ -500,8 +499,8 @@ INTERNAL int mailmark_4s(struct zint_symbol *symbol, unsigned char source[], int
symbol->rows = 3; symbol->rows = 3;
symbol->width = j - 1; symbol->width = j - 1;
if (raw_text) { if (raw_text && rt_cpy(symbol, local_source, length)) {
hrt_cpy_nochk(symbol, local_source, length); return ZINT_ERROR_MEMORY; /* `rt_cpy()` only fails with OOM */
} }
return error_number; return error_number;

View file

@ -555,6 +555,7 @@ INTERNAL int maxicode(struct zint_symbol *symbol, struct zint_seg segs[], const
unsigned char codewords[144]; unsigned char codewords[144];
int scm_vv = -1; int scm_vv = -1;
int structapp_cw = 0; int structapp_cw = 0;
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT;
const int debug_print = symbol->debug & ZINT_DEBUG_PRINT; const int debug_print = symbol->debug & ZINT_DEBUG_PRINT;
mode = symbol->option_1; mode = symbol->option_1;
@ -692,6 +693,17 @@ INTERNAL int maxicode(struct zint_symbol *symbol, struct zint_seg segs[], const
return errtxt(error_number, symbol, 553, "Input too long, requires too many codewords (maximum 144)"); return errtxt(error_number, symbol, 553, "Input too long, requires too many codewords (maximum 144)");
} }
if (raw_text) {
if (rt_init_segs(symbol, seg_count)) {
return ZINT_ERROR_MEMORY; /* `rt_init_segs()` only fails with OOM */
}
for (i = 0; i < seg_count; i++) {
if (rt_cpy_seg(symbol, i, &segs[i])) {
return ZINT_ERROR_MEMORY; /* `rt_cpy_seg()` only fails with OOM */
}
}
}
/* All the data is sorted - now do error correction */ /* All the data is sorted - now do error correction */
mx_do_primary_ecc(codewords); /* Always Enhanced ECC (EEC) 10 data + 10 error correction */ mx_do_primary_ecc(codewords); /* Always Enhanced ECC (EEC) 10 data + 10 error correction */

View file

@ -30,6 +30,7 @@
*/ */
/* SPDX-License-Identifier: BSD-3-Clause */ /* SPDX-License-Identifier: BSD-3-Clause */
#include <assert.h>
#include <stdio.h> #include <stdio.h>
#include "common.h" #include "common.h"
@ -98,8 +99,8 @@ INTERNAL int pharma(struct zint_symbol *symbol, unsigned char source[], int leng
(void) set_height(symbol, 0.0f, 50.0f, 0.0f, 1 /*no_errtxt*/); (void) set_height(symbol, 0.0f, 50.0f, 0.0f, 1 /*no_errtxt*/);
} }
if (raw_text) { if (raw_text && rt_cpy(symbol, source, length)) {
hrt_cpy_nochk(symbol, source, length); return ZINT_ERROR_MEMORY; /* `rt_cpy()` only fails with OOM */
} }
return error_number; return error_number;
@ -188,8 +189,8 @@ INTERNAL int pharma_two(struct zint_symbol *symbol, unsigned char source[], int
(void) set_height(symbol, 0.0f, 10.0f, 0.0f, 1 /*no_errtxt*/); (void) set_height(symbol, 0.0f, 10.0f, 0.0f, 1 /*no_errtxt*/);
} }
if (raw_text) { if (raw_text && rt_cpy(symbol, source, length)) {
hrt_cpy_nochk(symbol, source, length); return ZINT_ERROR_MEMORY; /* `rt_cpy()` only fails with OOM */
} }
return error_number; return error_number;
@ -198,12 +199,12 @@ INTERNAL int pharma_two(struct zint_symbol *symbol, unsigned char source[], int
/* Italian Pharmacode */ /* Italian Pharmacode */
INTERNAL int code32(struct zint_symbol *symbol, unsigned char source[], int length) { INTERNAL int code32(struct zint_symbol *symbol, unsigned char source[], int length) {
static const unsigned char TABELLA[] = "0123456789BCDFGHJKLMNPQRSTUVWXYZ"; static const unsigned char TABELLA[] = "0123456789BCDFGHJKLMNPQRSTUVWXYZ";
int i, zeroes, error_number = 0, checksum, checkpart, checkdigit; int i, zeroes, checksum, checkpart, checkdigit;
unsigned char local_source[10], risultante[7]; unsigned char local_source[10], risultante[7];
unsigned int pharmacode, devisor; unsigned int pharmacode, devisor;
int codeword[6]; int codeword[6];
int error_number;
const int saved_option_2 = symbol->option_2; const int saved_option_2 = symbol->option_2;
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT;
/* Validate the input */ /* Validate the input */
if (length > 8) { if (length > 8) {
@ -254,15 +255,19 @@ INTERNAL int code32(struct zint_symbol *symbol, unsigned char source[], int leng
risultante[5 - i] = TABELLA[codeword[i]]; risultante[5 - i] = TABELLA[codeword[i]];
} }
symbol->option_2 = 0; /* Need to overwrite this so `code39()` doesn't add a check digit itself */ if (symbol->option_2 == 1 || symbol->option_2 == 2) {
symbol->option_2 = 0; /* Need to overwrite this so `code39()` doesn't add a check digit itself */
/* Plot the barcode using Code 39 */
error_number = code39(symbol, risultante, 6);
if (error_number != 0) { /* Should never happen */
return error_number; /* Not reached */
} }
symbol->option_2 = saved_option_2; /* Restore */ /* Plot the barcode using Code 39 */
if ((error_number = code39(symbol, risultante, 6))) {
assert(error_number == ZINT_ERROR_MEMORY); /* Only error that can occur */
return error_number;
}
if (symbol->option_2 == 1 || symbol->option_2 == 2) {
symbol->option_2 = saved_option_2; /* Restore */
}
if (symbol->output_options & COMPLIANT_HEIGHT) { if (symbol->output_options & COMPLIANT_HEIGHT) {
/* Allegato A Caratteristiche tecniche del bollino farmaceutico /* Allegato A Caratteristiche tecniche del bollino farmaceutico
@ -276,11 +281,11 @@ INTERNAL int code32(struct zint_symbol *symbol, unsigned char source[], int leng
(void) set_height(symbol, 0.0f, 50.0f, 0.0f, 1 /*no_errtxt*/); (void) set_height(symbol, 0.0f, 50.0f, 0.0f, 1 /*no_errtxt*/);
} }
if (!raw_text) { /* Override the normal text output with the Pharmacode number */
/* Override the normal text output with the Pharmacode number */ hrt_cpy_chr(symbol, 'A');
hrt_cpy_chr(symbol, 'A'); hrt_cat_nochk(symbol, local_source, 9);
hrt_cat_nochk(symbol, local_source, 9);
} /* Use `raw_text` set by `code39()` */
return error_number; return error_number;
} }
@ -297,7 +302,6 @@ INTERNAL int pzn(struct zint_symbol *symbol, unsigned char source[], int length)
unsigned char local_source[1 + 8]; /* '-' prefix + 8 digits */ unsigned char local_source[1 + 8]; /* '-' prefix + 8 digits */
const int pzn7 = symbol->option_2 == 1; const int pzn7 = symbol->option_2 == 1;
const int saved_option_2 = symbol->option_2; const int saved_option_2 = symbol->option_2;
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT;
if (length > 8 - pzn7) { if (length > 8 - pzn7) {
return ZEXT errtxtf(ZINT_ERROR_TOO_LONG, symbol, 325, "Input length %1$d too long (maximum %2$d)", length, return ZEXT errtxtf(ZINT_ERROR_TOO_LONG, symbol, 325, "Input length %1$d too long (maximum %2$d)", length,
@ -339,11 +343,15 @@ INTERNAL int pzn(struct zint_symbol *symbol, unsigned char source[], int length)
local_source[8 - pzn7] = itoc(check_digit); local_source[8 - pzn7] = itoc(check_digit);
symbol->option_2 = 0; /* Need to overwrite this so `code39()` doesn't add a check digit itself */ if (symbol->option_2 == 1 || symbol->option_2 == 2) {
symbol->option_2 = 0; /* Need to overwrite this so `code39()` doesn't add a check digit itself */
}
error_number = code39(symbol, local_source, 9 - pzn7); error_number = code39(symbol, local_source, 9 - pzn7);
symbol->option_2 = saved_option_2; /* Restore */ if (symbol->option_2 == 1 || symbol->option_2 == 2) {
symbol->option_2 = saved_option_2; /* Restore */
}
if (symbol->output_options & COMPLIANT_HEIGHT) { if (symbol->output_options & COMPLIANT_HEIGHT) {
/* Technical Information regarding PZN Coding V 2.1 (25 Feb 2019) Code size /* Technical Information regarding PZN Coding V 2.1 (25 Feb 2019) Code size
@ -361,10 +369,10 @@ INTERNAL int pzn(struct zint_symbol *symbol, unsigned char source[], int length)
} }
} }
if (!raw_text) { hrt_cpy_nochk(symbol, (const unsigned char *) "PZN - ", 6); /* Note changed to put space after hyphen */
hrt_cpy_nochk(symbol, (const unsigned char *) "PZN - ", 6); /* Note changed to put space after hyphen */ hrt_cat_nochk(symbol, local_source + 1, 9 - pzn7 - 1);
hrt_cat_nochk(symbol, local_source + 1, 9 - pzn7 - 1);
} /* Use `raw_text` set by `code39()` */
return error_number; return error_number;
} }

View file

@ -90,7 +90,7 @@ static const char *pdf_mode_str(const int mode) {
original Visual Basic source code file pdf417.frm original Visual Basic source code file pdf417.frm
this code retains some original (French) procedure and variable names to ease conversion */ this code retains some original (French) procedure and variable names to ease conversion */
/* text mode processing tables */ /* Text mode processing tables */
/* TEX sub-mode assignments */ /* TEX sub-mode assignments */
static const char pdf_asciix[256] = { static const char pdf_asciix[256] = {
@ -229,7 +229,7 @@ static int pdf_text_num_length(short liste[3][PDF_MAX_LEN], const int indexliste
break; break;
len += liste[0][i]; len += liste[0][i];
if (len >= 5) /* we don't care if it's longer than 5 */ if (len >= 5) /* We don't care if it's longer than 5 */
break; break;
} }
@ -254,7 +254,7 @@ static int pdf_text_submode_length(const unsigned char chaine[], const int start
/* Obliged to change table */ /* Obliged to change table */
int newtable; int newtable;
if (j == (length - 1) || !(listet[j] & listet[j + 1])) { if (j == (length - 1) || !(listet[j] & listet[j + 1])) {
/* we change only one character - look for temporary switch */ /* We change only one character - look for temporary switch */
if ((listet[j] & T_ALPHA) && (curtable == T_LOWER)) { if ((listet[j] & T_ALPHA) && (curtable == T_LOWER)) {
wnet += 2; /* AS+char */ wnet += 2; /* AS+char */
continue; continue;
@ -330,7 +330,7 @@ static void pdf_appendix_d_encode(const unsigned char *chaine, short liste[3][PD
while (i < indexliste) { while (i < indexliste) {
if ((liste[1][i] == PDF_NUM) && pdf_num_stay(chaine, indexliste, liste, i)) { if ((liste[1][i] == PDF_NUM) && pdf_num_stay(chaine, indexliste, liste, i)) {
/* leave as numeric */ /* Leave as numeric */
liste[0][last] = liste[0][i]; liste[0][last] = liste[0][i];
liste[1][last] = PDF_NUM; liste[1][last] = PDF_NUM;
liste[2][last] = liste[2][i]; liste[2][last] = liste[2][i];
@ -339,7 +339,7 @@ static void pdf_appendix_d_encode(const unsigned char *chaine, short liste[3][PD
} else if (((liste[1][i] == PDF_TEX) || (liste[1][i] == PDF_NUM)) } else if (((liste[1][i] == PDF_TEX) || (liste[1][i] == PDF_NUM))
&& (stayintext || i == indexliste - 1 || (liste[0][i] >= 5) && (stayintext || i == indexliste - 1 || (liste[0][i] >= 5)
|| (pdf_text_num_length(liste, indexliste, i) >= 5))) { || (pdf_text_num_length(liste, indexliste, i) >= 5))) {
/* set to text and combine additional text/short numeric segments */ /* Set to text and combine additional text/short numeric segments */
liste[0][last] = liste[0][i]; liste[0][last] = liste[0][i];
liste[1][last] = PDF_TEX; liste[1][last] = PDF_TEX;
liste[2][last] = liste[2][i]; liste[2][last] = liste[2][i];
@ -361,7 +361,7 @@ static void pdf_appendix_d_encode(const unsigned char *chaine, short liste[3][PD
i = next; i = next;
continue; continue;
} else { } else {
/* build byte segment, including combining numeric/text segments that aren't long enough on their own */ /* Build byte segment, including combining numeric/text segments that aren't long enough on their own */
liste[0][last] = liste[0][i]; liste[0][last] = liste[0][i];
liste[1][last] = PDF_BYT; liste[1][last] = PDF_BYT;
liste[2][last] = liste[2][i]; liste[2][last] = liste[2][i];
@ -370,7 +370,7 @@ static void pdf_appendix_d_encode(const unsigned char *chaine, short liste[3][PD
next = i + 1; next = i + 1;
while (next < indexliste) { while (next < indexliste) {
if (liste[1][next] != PDF_BYT) { if (liste[1][next] != PDF_BYT) {
/* check for case of a single byte shift from text mode */ /* Check for case of a single byte shift from text mode */
if ((liste[0][last] == 1) && (last > 0) && (liste[1][last - 1] == PDF_TEX)) { if ((liste[0][last] == 1) && (last > 0) && (liste[1][last - 1] == PDF_TEX)) {
stayintext = 1; stayintext = 1;
break; break;
@ -393,7 +393,7 @@ static void pdf_appendix_d_encode(const unsigned char *chaine, short liste[3][PD
i++; i++;
} }
/* set the size of the list based on the last consolidated segment */ /* Set the size of the list based on the last consolidated segment */
*p_indexliste = last; *p_indexliste = last;
} }
@ -432,12 +432,12 @@ static void pdf_textprocess(short *chainemc, int *p_mclength, const unsigned cha
unsigned char chainet[PDF_MAX_STREAM_LEN]; unsigned char chainet[PDF_MAX_STREAM_LEN];
int wnet = 0; int wnet = 0;
/* add mode indicator if needed */ /* Add mode indicator if needed */
if (real_lastmode != PDF_TEX) { if (real_lastmode != PDF_TEX) {
chainemc[(*p_mclength)++] = 900; chainemc[(*p_mclength)++] = 900;
} }
/* listet will contain the table numbers and the value of each characters */ /* `listet` will contain the table numbers and the value of each characters */
for (indexlistet = 0; indexlistet < length; indexlistet++) { for (indexlistet = 0; indexlistet < length; indexlistet++) {
const int codeascii = chaine[start + indexlistet]; const int codeascii = chaine[start + indexlistet];
listet[0][indexlistet] = pdf_asciix[codeascii]; listet[0][indexlistet] = pdf_asciix[codeascii];
@ -454,7 +454,7 @@ static void pdf_textprocess(short *chainemc, int *p_mclength, const unsigned cha
/* Obliged to change table */ /* Obliged to change table */
int newtable; int newtable;
if (j == (length - 1) || !(listet[0][j] & listet[0][j + 1])) { if (j == (length - 1) || !(listet[0][j] & listet[0][j + 1])) {
/* we change only one character - look for temporary switch */ /* We change only one character - look for temporary switch */
if ((listet[0][j] & T_ALPHA) && (curtable == T_LOWER)) { if ((listet[0][j] & T_ALPHA) && (curtable == T_LOWER)) {
chainet[wnet++] = 27; /* AS */ chainet[wnet++] = 27; /* AS */
chainet[wnet++] = listet[1][j]; chainet[wnet++] = listet[1][j];
@ -503,7 +503,7 @@ static void pdf_textprocess_minimal(short *chainemc, int *p_mclength, const unsi
unsigned char chainet[PDF_MAX_STREAM_LEN]; unsigned char chainet[PDF_MAX_STREAM_LEN];
int wnet = 0; int wnet = 0;
/* add mode indicator if needed */ /* Add mode indicator if needed */
if (real_lastmode != PDF_TEX) { if (real_lastmode != PDF_TEX) {
chainemc[(*p_mclength)++] = 900; chainemc[(*p_mclength)++] = 900;
} }
@ -557,12 +557,12 @@ INTERNAL void pdf_byteprocess(short *chainemc, int *p_mclength, const unsigned c
const int real_lastmode = PDF_REAL_MODE(lastmode); const int real_lastmode = PDF_REAL_MODE(lastmode);
if (length == 1) { if (length == 1) {
/* shift or latch depending on previous mode */ /* Shift or latch depending on previous mode */
chainemc[(*p_mclength)++] = real_lastmode == PDF_TEX ? 913 : 901; chainemc[(*p_mclength)++] = real_lastmode == PDF_TEX ? 913 : 901;
chainemc[(*p_mclength)++] = chaine[start]; chainemc[(*p_mclength)++] = chaine[start];
} else { } else {
int len; int len;
/* select the switch for multiple of 6 bytes */ /* Select the switch for multiple of 6 bytes */
if (length % 6 == 0) { if (length % 6 == 0) {
chainemc[(*p_mclength)++] = 924; chainemc[(*p_mclength)++] = 924;
} else { } else {
@ -642,7 +642,7 @@ static void pdf_numbprocess(short *chainemc, int *p_mclength, const unsigned cha
nombre -= chainemod[p++] * 900; /* nombre % 900 */ nombre -= chainemod[p++] * 900; /* nombre % 900 */
} }
} }
/* return to 723 */ /* Return to 723 */
dummy[dumlength++] = nombre; dummy[dumlength++] = nombre;
len = p; len = p;
@ -997,8 +997,8 @@ static int pdf_initial(struct zint_symbol *symbol, const unsigned char chaine[],
int i, indexchaine = 0, indexliste = 0; int i, indexchaine = 0, indexliste = 0;
short liste[3][PDF_MAX_LEN] = {{0}}; short liste[3][PDF_MAX_LEN] = {{0}};
int mclength; int mclength;
const int debug_print = symbol->debug & ZINT_DEBUG_PRINT;
const int fast_encode = symbol->input_mode & FAST_MODE; const int fast_encode = symbol->input_mode & FAST_MODE;
const int debug_print = symbol->debug & ZINT_DEBUG_PRINT;
/* 456 */ /* 456 */
@ -1090,7 +1090,7 @@ static int pdf_initial(struct zint_symbol *symbol, const unsigned char chaine[],
break; break;
case PDF_BYT: /* 670 - octet stream mode */ case PDF_BYT: /* 670 - octet stream mode */
pdf_byteprocess(chainemc, &mclength, chaine, indexchaine, liste[0][i], *p_lastmode); pdf_byteprocess(chainemc, &mclength, chaine, indexchaine, liste[0][i], *p_lastmode);
/* don't switch mode on single byte shift from text mode */ /* Don't switch mode on single byte shift from text mode */
if (PDF_REAL_MODE(*p_lastmode) != PDF_TEX || liste[0][i] != 1) { if (PDF_REAL_MODE(*p_lastmode) != PDF_TEX || liste[0][i] != 1) {
*p_lastmode = PDF_BYT; *p_lastmode = PDF_BYT;
} else if (*p_curtable == T_PUNCT && *p_tex_padded) { /* If T_PUNCT and padded with AL */ } else if (*p_curtable == T_PUNCT && *p_tex_padded) { /* If T_PUNCT and padded with AL */
@ -1122,6 +1122,7 @@ static int pdf_initial_segs(struct zint_symbol *symbol, struct zint_seg segs[],
int lastmode; int lastmode;
int curtable; int curtable;
int tex_padded; int tex_padded;
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT;
*p_mclength = 0; *p_mclength = 0;
@ -1183,12 +1184,19 @@ static int pdf_initial_segs(struct zint_symbol *symbol, struct zint_seg segs[],
/* Start in upper alpha - tracked across calls to `pdf_textprocess()` to allow for interleaving byte shifts */ /* Start in upper alpha - tracked across calls to `pdf_textprocess()` to allow for interleaving byte shifts */
curtable = T_ALPHA; curtable = T_ALPHA;
if (raw_text && rt_init_segs(symbol, seg_count)) {
return ZINT_ERROR_MEMORY; /* `rt_init_segs()` only fails with OOM */
}
for (i = 0; i < seg_count; i++) { for (i = 0; i < seg_count; i++) {
error_number = pdf_initial(symbol, segs[i].source, segs[i].length, segs[i].eci, is_micro, i + 1 == seg_count, if ((error_number = pdf_initial(symbol, segs[i].source, segs[i].length, segs[i].eci, is_micro,
&lastmode, &curtable, &tex_padded, chainemc, p_mclength); i + 1 == seg_count, &lastmode, &curtable, &tex_padded, chainemc, p_mclength))) {
if (error_number) { /* Only errors >= ZINT_ERROR returned */ assert(error_number >= ZINT_ERROR);
return error_number; return error_number;
} }
if (raw_text && rt_cpy_seg(symbol, i, &segs[i])) {
return ZINT_ERROR_MEMORY; /* `rt_cpy_seg()` only fails with OOM */
}
} }
return error_number; return error_number;
@ -1207,15 +1215,14 @@ static int pdf_enc(struct zint_symbol *symbol, struct zint_seg segs[], const int
int structapp_cp = 0; int structapp_cp = 0;
int error_number; int error_number;
const int debug_print = symbol->debug & ZINT_DEBUG_PRINT; const int debug_print = symbol->debug & ZINT_DEBUG_PRINT;
static const short ecc_num_cws[] = { 2, 4, 8, 16, 32, 64, 128, 256, 512 };
if ((i = segs_length(segs, seg_count)) > PDF_MAX_LEN) { if ((i = segs_length(segs, seg_count)) > PDF_MAX_LEN) {
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 463, "Input length %d too long (maximum " PDF_MAX_LEN_S ")", i); return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 463, "Input length %d too long (maximum " PDF_MAX_LEN_S ")", i);
} }
error_number = pdf_initial_segs(symbol, segs, seg_count, 0 /*is_micro*/, chainemc, &mclength, structapp_cws, if ((error_number = pdf_initial_segs(symbol, segs, seg_count, 0 /*is_micro*/, chainemc, &mclength, structapp_cws,
&structapp_cp); &structapp_cp))) {
if (error_number) { /* Only errors return >= ZINT_ERROR */ assert(error_number >= ZINT_ERROR);
return error_number; return error_number;
} }
@ -1246,7 +1253,7 @@ static int pdf_enc(struct zint_symbol *symbol, struct zint_seg segs[], const int
ecc = 6; /* Not mentioned in Table E.1 */ ecc = 6; /* Not mentioned in Table E.1 */
} }
} }
ecc_cws = ecc_num_cws[ecc]; ecc_cws = 2 << ecc;
longueur = mclength + structapp_cp + ecc_cws; longueur = mclength + structapp_cp + ecc_cws;
@ -1366,7 +1373,7 @@ static int pdf_enc(struct zint_symbol *symbol, struct zint_seg segs[], const int
mccorrection[0] = (929 - (total * pdf_coefrs[offset]) % 929) % 929; mccorrection[0] = (929 - (total * pdf_coefrs[offset]) % 929) % 929;
} }
/* we add these codes to the string */ /* We add these codes to the string */
for (i = ecc_cws - 1; i >= 0; i--) { for (i = ecc_cws - 1; i >= 0; i--) {
chainemc[mclength++] = mccorrection[i] ? 929 - mccorrection[i] : 0; chainemc[mclength++] = mccorrection[i] ? 929 - mccorrection[i] : 0;
} }
@ -1391,7 +1398,7 @@ static int pdf_enc(struct zint_symbol *symbol, struct zint_seg segs[], const int
c2 = ecc * 3 + (rows - 1) % 3; c2 = ecc * 3 + (rows - 1) % 3;
c3 = cols - 1; c3 = cols - 1;
/* we now encode each row */ /* We now encode each row */
for (i = 0; i < rows; i++) { for (i = 0; i < rows; i++) {
const int k = (i / 3) * 30; const int k = (i / 3) * 30;
bp = 0; bp = 0;
@ -1493,9 +1500,10 @@ INTERNAL int pdf417(struct zint_symbol *symbol, struct zint_seg segs[], const in
return error_number; return error_number;
} }
/* like PDF417 only much smaller! */ /* Like PDF417 only much smaller! */
INTERNAL int micropdf417(struct zint_symbol *symbol, struct zint_seg segs[], const int seg_count) { INTERNAL int micropdf417(struct zint_symbol *symbol, struct zint_seg segs[], const int seg_count) {
int i, k, j, longueur, mccorrection[50] = {0}, offset; int i, k, j, longueur, mccorrection[50] = {0}, offset;
int ecc_cwds;
int total, mclength, error_number = 0; int total, mclength, error_number = 0;
short chainemc[PDF_MAX_STREAM_LEN]; short chainemc[PDF_MAX_STREAM_LEN];
char pattern[580]; char pattern[580];
@ -1518,9 +1526,9 @@ INTERNAL int micropdf417(struct zint_symbol *symbol, struct zint_seg segs[], con
/* Encoding starts out the same as PDF417, so use the same code */ /* Encoding starts out the same as PDF417, so use the same code */
error_number = pdf_initial_segs(symbol, segs, seg_count, 1 /*is_micro*/, chainemc, &mclength, structapp_cws, if ((error_number = pdf_initial_segs(symbol, segs, seg_count, 1 /*is_micro*/, chainemc, &mclength, structapp_cws,
&structapp_cp); &structapp_cp))) {
if (error_number) { /* Only errors return >= ZINT_ERROR */ assert(error_number >= ZINT_ERROR);
return error_number; return error_number;
} }
@ -1565,7 +1573,7 @@ INTERNAL int micropdf417(struct zint_symbol *symbol, struct zint_seg segs[], con
} }
if (symbol->option_2 == 1) { if (symbol->option_2 == 1) {
/* the user specified 1 column and the data does fit */ /* The user specified 1 column and the data does fit */
if (mclength + structapp_cp <= 4) { if (mclength + structapp_cp <= 4) {
variant = 1; variant = 1;
} else if (mclength + structapp_cp <= 7) { } else if (mclength + structapp_cp <= 7) {
@ -1580,7 +1588,7 @@ INTERNAL int micropdf417(struct zint_symbol *symbol, struct zint_seg segs[], con
variant = 6; variant = 6;
} }
} else if (symbol->option_2 == 2) { } else if (symbol->option_2 == 2) {
/* the user specified 2 columns and the data does fit */ /* The user specified 2 columns and the data does fit */
if (mclength + structapp_cp <= 8) { if (mclength + structapp_cp <= 8) {
variant = 7; variant = 7;
} else if (mclength + structapp_cp <= 13) { } else if (mclength + structapp_cp <= 13) {
@ -1597,7 +1605,7 @@ INTERNAL int micropdf417(struct zint_symbol *symbol, struct zint_seg segs[], con
variant = 13; variant = 13;
} }
} else if (symbol->option_2 == 3) { } else if (symbol->option_2 == 3) {
/* the user specified 3 columns and the data does fit */ /* The user specified 3 columns and the data does fit */
if (mclength + structapp_cp <= 6) { if (mclength + structapp_cp <= 6) {
variant = 14; variant = 14;
} else if (mclength + structapp_cp <= 10) { } else if (mclength + structapp_cp <= 10) {
@ -1620,7 +1628,7 @@ INTERNAL int micropdf417(struct zint_symbol *symbol, struct zint_seg segs[], con
variant = 23; variant = 23;
} }
} else if (symbol->option_2 == 4) { } else if (symbol->option_2 == 4) {
/* the user specified 4 columns and the data does fit */ /* The user specified 4 columns and the data does fit */
if (mclength + structapp_cp <= 8) { if (mclength + structapp_cp <= 8) {
variant = 24; variant = 24;
} else if (mclength + structapp_cp <= 12) { } else if (mclength + structapp_cp <= 12) {
@ -1659,24 +1667,27 @@ INTERNAL int micropdf417(struct zint_symbol *symbol, struct zint_seg segs[], con
/* Now we have the variant we can load the data */ /* Now we have the variant we can load the data */
variant--; variant--;
symbol->option_2 = pdf_MicroVariants[variant]; /* columns */ symbol->option_2 = pdf_MicroVariants[variant]; /* Columns */
symbol->rows = pdf_MicroVariants[variant + 34]; /* rows */ symbol->rows = pdf_MicroVariants[variant + 34]; /* Rows */
k = pdf_MicroVariants[variant + 68]; /* number of EC CWs */ ecc_cwds = pdf_MicroVariants[variant + 68]; /* Number of EC CWs */
longueur = (symbol->option_2 * symbol->rows) - k; /* number of non-EC CWs */ longueur = (symbol->option_2 * symbol->rows) - ecc_cwds; /* Number of non-EC CWs */
i = longueur - (mclength + structapp_cp); /* amount of padding required */ i = longueur - (mclength + structapp_cp); /* Amount of padding required */
offset = pdf_MicroVariants[variant + 102]; /* coefficient offset */ offset = pdf_MicroVariants[variant + 102]; /* Coefficient offset */
/* Feedback options */
/* Place in top byte, leaving bottom one for maybe future use - also compatible with AZTEC */
symbol->option_1 = ((int) roundf(ecc_cwds * 100.0f / (longueur + ecc_cwds))) << 8;
if (debug_print) { if (debug_print) {
fputs("\nChoose symbol size:\n", stdout); fputs("\nChoose symbol size:\n", stdout);
printf("%d columns x %d rows, variant %d\n", symbol->option_2, symbol->rows, variant + 1); printf("%d columns x %d rows, variant %d\n", symbol->option_2, symbol->rows, variant + 1);
printf("%d data codewords (including %d pads), %d ecc codewords\n", longueur, i, k); printf("%d data codewords (including %d pads), %d ecc codewords\n", longueur, i, ecc_cwds);
fputc('\n', stdout); fputc('\n', stdout);
} }
/* We add the padding */ /* We add the padding */
while (i > 0) { while (i-- > 0) {
chainemc[mclength++] = 900; chainemc[mclength++] = 900;
i--;
} }
/* We add the Structured Append Macro Control Block if any */ /* We add the Structured Append Macro Control Block if any */
@ -1689,8 +1700,8 @@ INTERNAL int micropdf417(struct zint_symbol *symbol, struct zint_seg segs[], con
/* Reed-Solomon error correction */ /* Reed-Solomon error correction */
longueur = mclength; longueur = mclength;
for (i = 0; i < longueur; i++) { for (i = 0; i < longueur; i++) {
total = (chainemc[i] + mccorrection[k - 1]) % 929; total = (chainemc[i] + mccorrection[ecc_cwds - 1]) % 929;
for (j = k - 1; j >= 0; j--) { for (j = ecc_cwds - 1; j >= 0; j--) {
if (j == 0) { if (j == 0) {
mccorrection[j] = (929 - (total * pdf_Microcoeffs[offset + j]) % 929) % 929; mccorrection[j] = (929 - (total * pdf_Microcoeffs[offset + j]) % 929) % 929;
} else { } else {
@ -1699,13 +1710,13 @@ INTERNAL int micropdf417(struct zint_symbol *symbol, struct zint_seg segs[], con
} }
} }
for (j = 0; j < k; j++) { for (j = 0; j < ecc_cwds; j++) {
if (mccorrection[j] != 0) { if (mccorrection[j] != 0) {
mccorrection[j] = 929 - mccorrection[j]; mccorrection[j] = 929 - mccorrection[j];
} }
} }
/* we add these codes to the string */ /* We add these codes to the string */
for (i = k - 1; i >= 0; i--) { for (i = ecc_cwds - 1; i >= 0; i--) {
chainemc[mclength++] = mccorrection[i]; chainemc[mclength++] = mccorrection[i];
} }
@ -1762,10 +1773,10 @@ INTERNAL int micropdf417(struct zint_symbol *symbol, struct zint_seg segs[], con
} }
} }
bp = bin_append_posn(pdf_rap_side[RightRAP - 1], 10, pattern, bp); bp = bin_append_posn(pdf_rap_side[RightRAP - 1], 10, pattern, bp);
pattern[bp++] = '1'; /* stop */ pattern[bp++] = '1'; /* Stop */
if (debug_print) printf("%.*s\n", bp, pattern); if (debug_print) printf("%.*s\n", bp, pattern);
/* so now pattern[] holds the string of '1's and '0's. - copy this to the symbol */ /* So now pattern[] holds the string of '1's and '0's. - copy this to the symbol */
for (loop = 0; loop < bp; loop++) { for (loop = 0; loop < bp; loop++) {
if (pattern[loop] == '1') { if (pattern[loop] == '1') {
set_module(symbol, i, loop); set_module(symbol, i, loop);

View file

@ -60,6 +60,7 @@ INTERNAL int plessey(struct zint_symbol *symbol, unsigned char source[], int len
char dest[570]; /* 8 + 67 * 8 + 2 * 8 + 9 + 1 = 570 */ char dest[570]; /* 8 + 67 * 8 + 2 * 8 + 9 + 1 = 570 */
char *d = dest; char *d = dest;
unsigned int check_digits = 0; unsigned int check_digits = 0;
char c1, c2;
int error_number = 0; int error_number = 0;
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT; const int raw_text = symbol->output_options & BARCODE_RAW_TEXT;
@ -116,12 +117,17 @@ INTERNAL int plessey(struct zint_symbol *symbol, unsigned char source[], int len
/* TODO: Find documentation on BARCODE_PLESSEY dimensions/height */ /* TODO: Find documentation on BARCODE_PLESSEY dimensions/height */
c1 = (char) xtoc(check_digits & 0xF);
c2 = (char) xtoc(check_digits >> 4);
hrt_cpy_nochk(symbol, source, length); hrt_cpy_nochk(symbol, source, length);
if (symbol->option_2 == 1 || raw_text) { if (symbol->option_2 == 1) {
const unsigned int c1 = check_digits & 0xF; hrt_cat_chr_nochk(symbol, c1);
const unsigned int c2 = check_digits >> 4; hrt_cat_chr_nochk(symbol, c2);
hrt_cat_chr_nochk(symbol, (char) xtoc(c1)); }
hrt_cat_chr_nochk(symbol, (char) xtoc(c2));
if (raw_text && rt_printf_256(symbol, "%.*s%c%c", length, source, c1, c2)) {
return ZINT_ERROR_MEMORY; /* `rt_printf_256()` only fails with OOM */
} }
return error_number; return error_number;
@ -164,7 +170,7 @@ static char msi_check_digit_mod11(const unsigned char source[], const int length
/* Plain MSI Plessey - does not calculate any check character */ /* Plain MSI Plessey - does not calculate any check character */
static char *msi_plessey_nomod(struct zint_symbol *symbol, const unsigned char source[], const int length, static char *msi_plessey_nomod(struct zint_symbol *symbol, const unsigned char source[], const int length,
char *d) { const int raw_text, char *d) {
int i; int i;
@ -174,12 +180,16 @@ static char *msi_plessey_nomod(struct zint_symbol *symbol, const unsigned char s
hrt_cpy_nochk(symbol, source, length); hrt_cpy_nochk(symbol, source, length);
if (raw_text && rt_cpy(symbol, source, length)) {
return NULL; /* `rt_cpy()` only fails with OOM */
}
return d; return d;
} }
/* MSI Plessey with Modulo 10 check digit */ /* MSI Plessey with Modulo 10 check digit */
static char *msi_plessey_mod10(struct zint_symbol *symbol, const unsigned char source[], const int length, static char *msi_plessey_mod10(struct zint_symbol *symbol, const unsigned char source[], const int length,
const int no_checktext, char *d) { const int no_checktext, const int raw_text, char *d) {
int i; int i;
char check_digit; char check_digit;
@ -200,13 +210,16 @@ static char *msi_plessey_mod10(struct zint_symbol *symbol, const unsigned char s
hrt_cat_chr_nochk(symbol, check_digit); hrt_cat_chr_nochk(symbol, check_digit);
} }
if (raw_text && rt_cpy_cat(symbol, source, length, check_digit, NULL /*cat*/, 0)) {
return NULL; /* `rt_cpy_cat()` only fails with OOM */
}
return d; return d;
} }
/* MSI Plessey with two Modulo 10 check digits */ /* MSI Plessey with two Modulo 10 check digits */
static char *msi_plessey_mod1010(struct zint_symbol *symbol, const unsigned char source[], const int length, static char *msi_plessey_mod1010(struct zint_symbol *symbol, const unsigned char source[], const int length,
const int no_checktext, char *d) { const int no_checktext, const int raw_text, char *d) {
int i; int i;
unsigned char local_source[92 + 2]; unsigned char local_source[92 + 2];
@ -226,48 +239,50 @@ static char *msi_plessey_mod1010(struct zint_symbol *symbol, const unsigned char
hrt_cpy_nochk(symbol, local_source, length + 2); hrt_cpy_nochk(symbol, local_source, length + 2);
} }
if (raw_text && rt_cpy(symbol, local_source, length + 2)) {
return NULL; /* `rt_cpy()` only fails with OOM */
}
return d; return d;
} }
/* MSI Plessey with Modulo 11 check digit */ /* MSI Plessey with Modulo 11 check digit */
static char *msi_plessey_mod11(struct zint_symbol *symbol, const unsigned char source[], const int length, static char *msi_plessey_mod11(struct zint_symbol *symbol, const unsigned char source[], const int length,
const int no_checktext, const int wrap, char *d) { const int no_checktext, const int wrap, const int raw_text, char *d) {
/* Uses the IBM weight system if wrap = 7, and the NCR system if wrap = 9 */ /* Uses the IBM weight system if wrap = 7, and the NCR system if wrap = 9 */
int i; int i;
char check_digit; unsigned char check_digits[2];
int check_digits_len = 1;
/* Draw data section */ /* Draw data section */
for (i = 0; i < length; i++, d += 8) { for (i = 0; i < length; i++, d += 8) {
memcpy(d, MSITable[source[i] - '0'], 8); memcpy(d, MSITable[source[i] - '0'], 8);
} }
/* Append check digit */ /* Append check digit(s) */
check_digit = msi_check_digit_mod11(source, length, wrap); check_digits[0] = msi_check_digit_mod11(source, length, wrap);
if (check_digit == ':') { if (check_digits[0] == ':') {
memcpy(d, MSITable[1], 8); check_digits[0] = '1';
d += 8; check_digits[1] = '0';
memcpy(d, MSITable[0], 8); check_digits_len++;
d += 8; }
} else { for (i = 0; i < check_digits_len; i++, d += 8) {
memcpy(d, MSITable[check_digit - '0'], 8); memcpy(d, MSITable[check_digits[i] - '0'], 8);
d += 8;
} }
hrt_cpy_nochk(symbol, source, length); hrt_cpy_nochk(symbol, source, length);
if (!no_checktext) { if (!no_checktext) {
if (check_digit == ':') { hrt_cat_nochk(symbol, check_digits, check_digits_len);
hrt_cat_nochk(symbol, (const unsigned char *) "10", 2);
} else {
hrt_cat_chr_nochk(symbol, check_digit);
}
} }
if (raw_text && rt_cpy_cat(symbol, source, length, '\xFF' /*separator (none)*/, check_digits, check_digits_len)) {
return NULL; /* `check_digits_len()` only fails with OOM */
}
return d; return d;
} }
/* MSI Plessey with Modulo 11 check digit and Modulo 10 check digit */ /* MSI Plessey with Modulo 11 check digit and Modulo 10 check digit */
static char *msi_plessey_mod1110(struct zint_symbol *symbol, const unsigned char source[], const int length, static char *msi_plessey_mod1110(struct zint_symbol *symbol, const unsigned char source[], const int length,
const int no_checktext, const int wrap, char *d) { const int no_checktext, const int wrap, const int raw_text, char *d) {
/* Uses the IBM weight system if wrap = 7, and the NCR system if wrap = 9 */ /* Uses the IBM weight system if wrap = 7, and the NCR system if wrap = 9 */
int i; int i;
char check_digit; char check_digit;
@ -300,6 +315,10 @@ static char *msi_plessey_mod1110(struct zint_symbol *symbol, const unsigned char
hrt_cpy_nochk(symbol, local_source, local_length); hrt_cpy_nochk(symbol, local_source, local_length);
} }
if (raw_text && rt_cpy(symbol, local_source, local_length)) {
return NULL; /* `rt_cpy()` only fails with OOM */
}
return d; return d;
} }
@ -322,7 +341,7 @@ INTERNAL int msi_plessey(struct zint_symbol *symbol, unsigned char source[], int
if (check_option >= 11 && check_option <= 16) { /* +10 means don't print check digits in HRT */ if (check_option >= 11 && check_option <= 16) { /* +10 means don't print check digits in HRT */
check_option -= 10; check_option -= 10;
no_checktext = !raw_text; no_checktext = 1;
} }
if ((check_option < 0) || (check_option > 6)) { if ((check_option < 0) || (check_option > 6)) {
check_option = 0; check_option = 0;
@ -333,22 +352,26 @@ INTERNAL int msi_plessey(struct zint_symbol *symbol, unsigned char source[], int
d += 2; d += 2;
switch (check_option) { switch (check_option) {
case 0: d = msi_plessey_nomod(symbol, source, length, d); case 0: d = msi_plessey_nomod(symbol, source, length, raw_text, d);
break; break;
case 1: d = msi_plessey_mod10(symbol, source, length, no_checktext, d); case 1: d = msi_plessey_mod10(symbol, source, length, no_checktext, raw_text, d);
break; break;
case 2: d = msi_plessey_mod1010(symbol, source, length, no_checktext, d); case 2: d = msi_plessey_mod1010(symbol, source, length, no_checktext, raw_text, d);
break; break;
case 3: d = msi_plessey_mod11(symbol, source, length, no_checktext, 7 /*IBM wrap*/, d); case 3: d = msi_plessey_mod11(symbol, source, length, no_checktext, 7 /*IBM wrap*/, raw_text, d);
break; break;
case 4: d = msi_plessey_mod1110(symbol, source, length, no_checktext, 7 /*IBM wrap*/, d); case 4: d = msi_plessey_mod1110(symbol, source, length, no_checktext, 7 /*IBM wrap*/, raw_text, d);
break; break;
case 5: d = msi_plessey_mod11(symbol, source, length, no_checktext, 9 /*NCR wrap*/, d); case 5: d = msi_plessey_mod11(symbol, source, length, no_checktext, 9 /*NCR wrap*/, raw_text, d);
break; break;
case 6: d = msi_plessey_mod1110(symbol, source, length, no_checktext, 9 /*NCR wrap*/, d); case 6: d = msi_plessey_mod1110(symbol, source, length, no_checktext, 9 /*NCR wrap*/, raw_text, d);
break; break;
} }
if (!d) {
return ZINT_ERROR_MEMORY; /* `rt_cpy()` etc. only fail with OOM */
}
/* Stop character */ /* Stop character */
memcpy(d, "121", 3); memcpy(d, "121", 3);
d += 3; d += 3;

View file

@ -182,9 +182,8 @@ static int postnet_enc(struct zint_symbol *symbol, const unsigned char source[],
/* Stop character */ /* Stop character */
memcpy(d, "L", 2); /* Include terminating NUL */ memcpy(d, "L", 2); /* Include terminating NUL */
if (raw_text) { if (raw_text && rt_cpy_cat(symbol, source, length, itoc(check_digit), NULL /*cat*/, 0)) {
hrt_cpy_nochk(symbol, source, length); return ZINT_ERROR_MEMORY; /* `rt_cpy_cat()` only fails with OOM */
hrt_cat_chr_nochk(symbol, (char) itoc(check_digit));
} }
return error_number; return error_number;
@ -256,9 +255,8 @@ static int planet_enc(struct zint_symbol *symbol, const unsigned char source[],
/* Stop character */ /* Stop character */
memcpy(d, "L", 2); /* Include terminating NUL */ memcpy(d, "L", 2); /* Include terminating NUL */
if (raw_text) { if (raw_text && rt_cpy_cat(symbol, source, length, itoc(check_digit), NULL /*cat*/, 0)) {
hrt_cpy_nochk(symbol, source, length); return ZINT_ERROR_MEMORY; /* `rt_cpy_cat()` only fails with OOM */
hrt_cat_chr_nochk(symbol, (char) itoc(check_digit));
} }
return error_number; return error_number;
@ -300,6 +298,7 @@ INTERNAL int koreapost(struct zint_symbol *symbol, unsigned char source[], int l
char dest[80]; char dest[80];
char *d = dest; char *d = dest;
int posns[6]; int posns[6];
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT;
if (length > 6) { if (length > 6) {
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 484, "Input length %d too long (maximum 6)", length); return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 484, "Input length %d too long (maximum 6)", length);
@ -337,6 +336,10 @@ INTERNAL int koreapost(struct zint_symbol *symbol, unsigned char source[], int l
hrt_cpy_nochk(symbol, local_source, 7); hrt_cpy_nochk(symbol, local_source, 7);
if (raw_text && rt_cpy(symbol, local_source, 7)) {
return ZINT_ERROR_MEMORY; /* `rt_cpy()` only fails with OOM */
}
return error_number; return error_number;
} }
@ -350,24 +353,21 @@ INTERNAL int fim(struct zint_symbol *symbol, unsigned char source[], int length)
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 486, "Input length %d too long (maximum 1)", length); return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 486, "Input length %d too long (maximum 1)", length);
} }
to_upper(source, length);
switch ((char) source[0]) { switch ((char) source[0]) {
case 'a':
case 'A': case 'A':
expand(symbol, "111515111", 9); expand(symbol, "111515111", 9);
break; break;
case 'b':
case 'B': case 'B':
expand(symbol, "13111311131", 11); expand(symbol, "13111311131", 11);
break; break;
case 'c':
case 'C': case 'C':
expand(symbol, "11131313111", 11); expand(symbol, "11131313111", 11);
break; break;
case 'd':
case 'D': case 'D':
expand(symbol, "1111131311111", 13); expand(symbol, "1111131311111", 13);
break; break;
case 'e':
case 'E': case 'E':
expand(symbol, "1317131", 7); expand(symbol, "1317131", 7);
break; break;
@ -377,10 +377,6 @@ INTERNAL int fim(struct zint_symbol *symbol, unsigned char source[], int length)
break; break;
} }
if (raw_text) {
hrt_cpy_chr(symbol, (const char) (z_islower(source[0]) ? source[0] & 0x5F : source[0]));
}
if (symbol->output_options & COMPLIANT_HEIGHT) { if (symbol->output_options & COMPLIANT_HEIGHT) {
/* USPS Domestic Mail Manual (USPS DMM 300) Jan 8, 2006 (updated 2011) 708.9.3 /* USPS Domestic Mail Manual (USPS DMM 300) Jan 8, 2006 (updated 2011) 708.9.3
X 0.03125" (1/32) +- 0.008" so X max 0.03925", height 0.625" (5/8) +- 0.125" (1/8) */ X 0.03125" (1/32) +- 0.008" so X max 0.03925", height 0.625" (5/8) +- 0.125" (1/8) */
@ -392,6 +388,10 @@ INTERNAL int fim(struct zint_symbol *symbol, unsigned char source[], int length)
(void) set_height(symbol, 0.0f, 50.0f, 0.0f, 1 /*no_errtxt*/); (void) set_height(symbol, 0.0f, 50.0f, 0.0f, 1 /*no_errtxt*/);
} }
if (raw_text && rt_cpy(symbol, source, length)) {
return ZINT_ERROR_MEMORY; /* `rt_cpy()` only fails with OOM */
}
return error_number; return error_number;
} }
@ -428,11 +428,10 @@ INTERNAL int daft_set_height(struct zint_symbol *symbol, const float min_height,
return error_number; return error_number;
} }
/* Handles the 4 State barcodes used in the UK by Royal Mail */ /* Handles the 4 State barcodes used in the UK by Royal Mail. Returns check_character */
static void rm4scc_enc(struct zint_symbol *symbol, const int *posns, char *d, const int length) { static int rm4scc_enc(struct zint_symbol *symbol, const int *posns, char *d, const int length) {
int i; int i;
int top, bottom, row, column, check_digit; int top, bottom, row, column, check_digit;
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT;
top = 0; top = 0;
bottom = 0; bottom = 0;
@ -465,9 +464,7 @@ static void rm4scc_enc(struct zint_symbol *symbol, const int *posns, char *d, co
/* Stop character */ /* Stop character */
memcpy(d, "0", 2); /* Include terminating NUL */ memcpy(d, "0", 2); /* Include terminating NUL */
if (raw_text) { return KRSET[check_digit];
hrt_cat_chr_nochk(symbol, KRSET[check_digit]);
}
} }
/* Puts RM4SCC into the data matrix */ /* Puts RM4SCC into the data matrix */
@ -477,6 +474,7 @@ INTERNAL int rm4scc(struct zint_symbol *symbol, unsigned char source[], int leng
int posns[50]; int posns[50];
int loopey, h; int loopey, h;
int writer; int writer;
char check_digit;
int error_number = 0; int error_number = 0;
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT; const int raw_text = symbol->output_options & BARCODE_RAW_TEXT;
@ -488,10 +486,8 @@ INTERNAL int rm4scc(struct zint_symbol *symbol, unsigned char source[], int leng
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 489, return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 489,
"Invalid character at position %d in input (alphanumerics only)", i); "Invalid character at position %d in input (alphanumerics only)", i);
} }
if (raw_text) {
hrt_cpy_nochk(symbol, source, length); check_digit = rm4scc_enc(symbol, posns, height_pattern, length);
}
rm4scc_enc(symbol, posns, height_pattern, length);
writer = 0; writer = 0;
h = (int) strlen(height_pattern); h = (int) strlen(height_pattern);
@ -527,6 +523,10 @@ INTERNAL int rm4scc(struct zint_symbol *symbol, unsigned char source[], int leng
symbol->rows = 3; symbol->rows = 3;
symbol->width = writer - 1; symbol->width = writer - 1;
if (raw_text && rt_cpy_cat(symbol, source, length, check_digit, NULL /*cat*/, 0)) {
return ZINT_ERROR_MEMORY; /* `rt_cpy_cat()` only fails with OOM */
}
return error_number; return error_number;
} }
@ -585,8 +585,8 @@ INTERNAL int kix(struct zint_symbol *symbol, unsigned char source[], int length)
symbol->rows = 3; symbol->rows = 3;
symbol->width = writer - 1; symbol->width = writer - 1;
if (raw_text) { if (raw_text && rt_cpy(symbol, source, length)) {
hrt_cpy_nochk(symbol, source, length); return ZINT_ERROR_MEMORY; /* `rt_cpy()` only fails with OOM */
} }
return error_number; return error_number;
@ -640,8 +640,8 @@ INTERNAL int daft(struct zint_symbol *symbol, unsigned char source[], int length
symbol->rows = 3; symbol->rows = 3;
symbol->width = writer - 1; symbol->width = writer - 1;
if (raw_text) { if (raw_text && rt_cpy(symbol, source, length)) {
hrt_cpy_nochk(symbol, source, length); return ZINT_ERROR_MEMORY; /* `rt_cpy()` only fails with OOM */
} }
return 0; return 0;
@ -672,8 +672,8 @@ INTERNAL int flat(struct zint_symbol *symbol, unsigned char source[], int length
/* TODO: Find documentation on BARCODE_FLAT dimensions/height */ /* TODO: Find documentation on BARCODE_FLAT dimensions/height */
if (raw_text) { if (raw_text && rt_cpy(symbol, source, length)) {
hrt_cpy_nochk(symbol, source, length); return ZINT_ERROR_MEMORY; /* `rt_cpy()` only fails with OOM */
} }
return error_number; return error_number;
@ -791,9 +791,9 @@ INTERNAL int japanpost(struct zint_symbol *symbol, unsigned char source[], int l
(void) daft_set_height(symbol, 0.0f, 0.0f); (void) daft_set_height(symbol, 0.0f, 0.0f);
} }
if (raw_text) { /* Note: check char is in KASUTSET and not truly representable in raw text's SHKASUTSET_F */
hrt_cpy_nochk(symbol, source, length); if (raw_text && rt_cpy(symbol, source, length)) {
/* Note: check char is in KASUTSET and not truly representable in HRT's SHKASUTSET_F */ return ZINT_ERROR_MEMORY; /* `rt_cpy()` only fails with OOM */
} }
return error_number; return error_number;

View file

@ -1599,13 +1599,19 @@ static int qr_prep_data(struct zint_symbol *symbol, struct zint_seg segs[], cons
int i; int i;
/* If ZINT_FULL_MULTIBYTE use Kanji mode in DATA_MODE or for non-Shift JIS in UNICODE_MODE */ /* If ZINT_FULL_MULTIBYTE use Kanji mode in DATA_MODE or for non-Shift JIS in UNICODE_MODE */
const int full_multibyte = (symbol->option_3 & 0xFF) == ZINT_FULL_MULTIBYTE; const int full_multibyte = (symbol->option_3 & 0xFF) == ZINT_FULL_MULTIBYTE;
/* GS1 raw text dealt with by `ZBarcode_Encode_Segs()` */
const int raw_text = (symbol->input_mode & 0x07) != GS1_MODE && (symbol->output_options & BARCODE_RAW_TEXT);
if (raw_text && rt_init_segs(symbol, seg_count)) {
return ZINT_ERROR_MEMORY; /* `rt_init_segs()` only fails with OOM */
}
if ((symbol->input_mode & 0x07) == DATA_MODE) { if ((symbol->input_mode & 0x07) == DATA_MODE) {
sjis_cpy_segs(segs, seg_count, ddata, full_multibyte); warn_number = sjis_cpy_segs(symbol, segs, seg_count, ddata, full_multibyte);
} else { } else {
unsigned int *dd = ddata; unsigned int *dd = ddata;
for (i = 0; i < seg_count; i++) { for (i = 0; i < seg_count; i++) {
int done = 0; int done = 0, eci = segs[i].eci;
if (segs[i].eci != 20 || seg_count > 1) { /* Unless ECI 20 (Shift JIS) or have multiple segments */ if (segs[i].eci != 20 || seg_count > 1) { /* Unless ECI 20 (Shift JIS) or have multiple segments */
/* Try other encodings (ECI 0 defaults to ISO/IEC 8859-1) */ /* Try other encodings (ECI 0 defaults to ISO/IEC 8859-1) */
int error_number = sjis_utf8_to_eci(segs[i].eci, segs[i].source, &segs[i].length, dd, full_multibyte); int error_number = sjis_utf8_to_eci(segs[i].eci, segs[i].source, &segs[i].length, dd, full_multibyte);
@ -1625,6 +1631,10 @@ static int qr_prep_data(struct zint_symbol *symbol, struct zint_seg segs[], cons
warn_number = errtxt(ZINT_WARN_NONCOMPLIANT, symbol, 760, warn_number = errtxt(ZINT_WARN_NONCOMPLIANT, symbol, 760,
"Converted to Shift JIS but no ECI specified"); "Converted to Shift JIS but no ECI specified");
} }
eci = 20;
}
if (raw_text && rt_cpy_seg_ddata(symbol, i, &segs[i], eci, dd)) {
return ZINT_ERROR_MEMORY; /* `rt_cpy_seg_ddata()` only fails with OOM */
} }
dd += segs[i].length; dd += segs[i].length;
} }
@ -2174,15 +2184,17 @@ INTERNAL int microqr(struct zint_symbol *symbol, unsigned char source[], int len
unsigned int ddata[40]; unsigned int ddata[40];
char mode[40]; char mode[40];
int alpha_used = 0, byte_or_kanji_used = 0; int alpha_used = 0, byte_or_kanji_used = 0;
int eci = 0;
int version_valid[4]; int version_valid[4];
int binary_count[4]; int binary_count[4];
int ecc_level, version; int ecc_level, version;
int bitmask, format, format_full; int bitmask, format, format_full;
int size_squared; int size_squared;
unsigned char *grid;
struct zint_seg segs[1]; struct zint_seg segs[1];
const int seg_count = 1; const int seg_count = 1;
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT;
const int debug_print = symbol->debug & ZINT_DEBUG_PRINT; const int debug_print = symbol->debug & ZINT_DEBUG_PRINT;
unsigned char *grid;
if (length > 35) { if (length > 35) {
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 562, "Input length %d too long (maximum 35)", length); return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 562, "Input length %d too long (maximum 35)", length);
@ -2224,6 +2236,7 @@ INTERNAL int microqr(struct zint_symbol *symbol, unsigned char source[], int len
if (error_number != 0) { if (error_number != 0) {
return error_number; return error_number;
} }
eci = 20;
} }
} }
@ -2263,6 +2276,10 @@ INTERNAL int microqr(struct zint_symbol *symbol, unsigned char source[], int len
segs[0].length = length; segs[0].length = length;
segs[0].eci = 0; segs[0].eci = 0;
if (raw_text && (rt_init_segs(symbol, seg_count) || rt_cpy_seg_ddata(symbol, 0, &segs[0], eci, ddata))) {
return ZINT_ERROR_MEMORY; /* `rt_init_segs()` & `rt_cpy_seg_ddata()` only fail with OOM */
}
/* Determine length of binary data */ /* Determine length of binary data */
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
if (version_valid[i]) { if (version_valid[i]) {
@ -2392,6 +2409,7 @@ INTERNAL int upnqr(struct zint_symbol *symbol, unsigned char source[], int lengt
struct zint_seg segs[1]; struct zint_seg segs[1];
const int seg_count = 1; const int seg_count = 1;
const int fast_encode = symbol->input_mode & FAST_MODE; const int fast_encode = symbol->input_mode & FAST_MODE;
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT;
const int debug_print = symbol->debug & ZINT_DEBUG_PRINT; const int debug_print = symbol->debug & ZINT_DEBUG_PRINT;
unsigned char *datastream; unsigned char *datastream;
unsigned char *fullstream; unsigned char *fullstream;
@ -2435,6 +2453,10 @@ INTERNAL int upnqr(struct zint_symbol *symbol, unsigned char source[], int lengt
segs[0].length = length; segs[0].length = length;
segs[0].eci = 4; segs[0].eci = 4;
if (raw_text && (rt_init_segs(symbol, seg_count) || rt_cpy_seg_ddata(symbol, 0, &segs[0], 0 /*eci*/, ddata))) {
return ZINT_ERROR_MEMORY; /* `rt_init_segs()` & `rt_cpy_seg_ddata()` only fail with OOM */
}
est_binlen = qr_calc_binlen_segs(15, mode, ddata, segs, seg_count, NULL /*p_structapp*/, 1 /*mode_preset*/, est_binlen = qr_calc_binlen_segs(15, mode, ddata, segs, seg_count, NULL /*p_structapp*/, 1 /*mode_preset*/,
0 /*gs1*/, debug_print); 0 /*gs1*/, debug_print);

View file

@ -1006,9 +1006,6 @@ static int plot_raster_default(struct zint_symbol *symbol, const int rotate_angl
} }
hide_text = !symbol->show_hrt || symbol->text_length == 0 || scaler < 1.0f; hide_text = !symbol->show_hrt || symbol->text_length == 0 || scaler < 1.0f;
if (!hide_text && (symbol->output_options & BARCODE_RAW_TEXT)) {
warn_number = errtxt(ZINT_WARN_HRT_RAW_TEXT, symbol, 665, "HRT outputted as raw text");
}
out_set_whitespace_offsets(symbol, hide_text, comp_xoffset, &xoffset, &yoffset, &roffset, &boffset, out_set_whitespace_offsets(symbol, hide_text, comp_xoffset, &xoffset, &yoffset, &roffset, &boffset,
NULL /*qz_right*/, si, &xoffset_si, &yoffset_si, &roffset_si, &boffset_si, &qz_right_si); NULL /*qz_right*/, si, &xoffset_si, &yoffset_si, &roffset_si, &boffset_si, &qz_right_si);

View file

@ -62,6 +62,7 @@
* RSS Expanded Stacked > GS1 DataBar Expanded Stacked Omnidirectional * RSS Expanded Stacked > GS1 DataBar Expanded Stacked Omnidirectional
*/ */
#include <assert.h>
#include <stdio.h> #include <stdio.h>
#include "common.h" #include "common.h"
#include "large.h" #include "large.h"
@ -153,19 +154,24 @@ static void getRSSwidths(int widths[], int val, int n, const int elements, const
return; return;
} }
/* Helper to construct zero-padded GTIN14 with check digit, returning `buf` for convenience */
static unsigned char *dbar_gtin14(const unsigned char *source, const int length, unsigned char buf[14]) {
const int zeroes = 13 - length;
assert(zeroes >= 0);
memset(buf, '0', zeroes);
memcpy(buf + zeroes, source, length);
buf[zeroes + length] = gs1_check_digit(buf, 13);
return buf;
}
/* Set GTIN-14 human readable text */ /* Set GTIN-14 human readable text */
static void dbar_set_gtin14_hrt(struct zint_symbol *symbol, const unsigned char *source, const int length) { static void dbar_set_gtin14_hrt(struct zint_symbol *symbol, const unsigned char *source, const int length) {
static const unsigned char zeroes_str[] = "0000000000000"; /* 13 zeroes */ unsigned char buf[14];
const int zeroes = 13 - length;
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT;
if (raw_text) { hrt_cpy_nochk(symbol, (const unsigned char *) "(01)", 4);
hrt_printf_nochk(symbol, "01%.*s%.*s", zeroes, zeroes_str, length, source); hrt_cat_nochk(symbol, dbar_gtin14(source, length, buf), 14);
hrt_cat_chr_nochk(symbol, gs1_check_digit(symbol->text + 2, 13));
} else {
hrt_printf_nochk(symbol, "(01)%.*s%.*s", zeroes, zeroes_str, length, source);
hrt_cat_chr_nochk(symbol, gs1_check_digit(symbol->text + 4, 13));
}
} }
/* Expand from a width pattern to a bit pattern */ /* Expand from a width pattern to a bit pattern */
@ -548,10 +554,6 @@ INTERNAL int dbar_omn_cc(struct zint_symbol *symbol, unsigned char source[], int
symbol->width = 50; symbol->width = 50;
} }
if (raw_text) {
dbar_set_gtin14_hrt(symbol, source, length);
}
if (symbol->symbology != BARCODE_DBAR_STK_CC) { /* Composite calls dbar_omnstk_set_height() itself */ if (symbol->symbology != BARCODE_DBAR_STK_CC) { /* Composite calls dbar_omnstk_set_height() itself */
error_number = dbar_omnstk_set_height(symbol, 0 /*first_row*/); error_number = dbar_omnstk_set_height(symbol, 0 /*first_row*/);
} }
@ -600,10 +602,6 @@ INTERNAL int dbar_omn_cc(struct zint_symbol *symbol, unsigned char source[], int
} }
symbol->rows = symbol->rows + 1; symbol->rows = symbol->rows + 1;
if (raw_text) {
dbar_set_gtin14_hrt(symbol, source, length);
}
/* ISO/IEC 24724:2011 5.3.2.2 minimum 33X height per row */ /* ISO/IEC 24724:2011 5.3.2.2 minimum 33X height per row */
if (symbol->symbology == BARCODE_DBAR_OMNSTK_CC) { if (symbol->symbology == BARCODE_DBAR_OMNSTK_CC) {
symbol->height = symbol->height ? 33.0f : 66.0f; /* Pass back min row or default height */ symbol->height = symbol->height ? 33.0f : 66.0f; /* Pass back min row or default height */
@ -616,6 +614,13 @@ INTERNAL int dbar_omn_cc(struct zint_symbol *symbol, unsigned char source[], int
} }
} }
if (raw_text) {
unsigned char buf[14];
if (rt_cpy(symbol, dbar_gtin14(source, length, buf), 14)) {
return ZINT_ERROR_MEMORY; /* `rt_cpy()` only fails with OOM */
}
}
return error_number; return error_number;
} }
@ -635,6 +640,7 @@ INTERNAL int dbar_ltd_cc(struct zint_symbol *symbol, unsigned char source[], int
int latch; int latch;
int separator_row; int separator_row;
int widths[7]; int widths[7];
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT;
separator_row = 0; separator_row = 0;
@ -793,6 +799,13 @@ INTERNAL int dbar_ltd_cc(struct zint_symbol *symbol, unsigned char source[], int
/* Set human readable text */ /* Set human readable text */
dbar_set_gtin14_hrt(symbol, source, length); dbar_set_gtin14_hrt(symbol, source, length);
if (raw_text) {
unsigned char buf[14];
if (rt_cpy(symbol, dbar_gtin14(source, length, buf), 14)) {
return ZINT_ERROR_MEMORY; /* `rt_cpy()` only fails with OOM */
}
}
/* ISO/IEC 24724:2011 6.2 10X minimum height, use as default also */ /* ISO/IEC 24724:2011 6.2 10X minimum height, use as default also */
if (symbol->symbology == BARCODE_DBAR_LTD_CC) { if (symbol->symbology == BARCODE_DBAR_LTD_CC) {
symbol->height = 10.0f; /* Pass back min row == default height */ symbol->height = 10.0f; /* Pass back min row == default height */
@ -1332,6 +1345,12 @@ INTERNAL int dbar_exp_cc(struct zint_symbol *symbol, unsigned char source[], int
return error_number; return error_number;
} }
if ((symbol->symbology == BARCODE_DBAR_EXPSTK) || (symbol->symbology == BARCODE_DBAR_EXPSTK_CC)) {
/* Feedback options */
symbol->option_2 = cols_per_row;
symbol->option_3 = max_rows;
}
data_chars = bp / 12; data_chars = bp / 12;
if (debug_print) fputs("Data:", stdout); if (debug_print) fputs("Data:", stdout);
@ -1470,10 +1489,10 @@ INTERNAL int dbar_exp_cc(struct zint_symbol *symbol, unsigned char source[], int
} }
symbol->rows = symbol->rows + 1; symbol->rows = symbol->rows + 1;
if (raw_text) { dbar_exp_hrt(symbol, source, length);
hrt_cpy_nochk(symbol, reduced, reduced_length);
} else { if (raw_text && rt_cpy(symbol, reduced, reduced_length)) {
dbar_exp_hrt(symbol, source, length); return ZINT_ERROR_MEMORY; /* `rt_cpy()` only fails with OOM */
} }
} else { } else {
@ -1593,8 +1612,8 @@ INTERNAL int dbar_exp_cc(struct zint_symbol *symbol, unsigned char source[], int
} }
symbol->rows = symbol->rows - 3; symbol->rows = symbol->rows - 3;
if (raw_text) { if (raw_text && rt_cpy(symbol, reduced, reduced_length)) {
hrt_cpy_nochk(symbol, reduced, reduced_length); return ZINT_ERROR_MEMORY; /* `rt_cpy()` only fails with OOM */
} }
} }

View file

@ -139,8 +139,9 @@ INTERNAL int telepen(struct zint_symbol *symbol, unsigned char source[], int len
} }
hrt_cpy_iso8859_1(symbol, source, length); hrt_cpy_iso8859_1(symbol, source, length);
if (raw_text) {
hrt_cat_chr_nochk(symbol, (char) check_digit); if (raw_text && rt_cpy_cat(symbol, source, length, check_digit, NULL /*cat*/, 0)) {
return ZINT_ERROR_MEMORY; /* `rt_cpy_cat()` only fails with OOM */
} }
return error_number; return error_number;
@ -218,8 +219,9 @@ INTERNAL int telepen_num(struct zint_symbol *symbol, unsigned char source[], int
} }
hrt_cpy_nochk(symbol, local_source, length); hrt_cpy_nochk(symbol, local_source, length);
if (raw_text) {
hrt_cat_chr_nochk(symbol, (char) check_digit); if (raw_text && rt_cpy_cat(symbol, local_source, length, check_digit, NULL /*cat*/, 0)) {
return ZINT_ERROR_MEMORY; /* `rt_cpy_cat()` only fails with OOM */
} }
return error_number; return error_number;

View file

@ -45,6 +45,7 @@ zint_add_test(aztec test_aztec)
zint_add_test(bc412 test_bc412) zint_add_test(bc412 test_bc412)
zint_add_test(big5 test_big5) zint_add_test(big5 test_big5)
zint_add_test(bmp test_bmp) zint_add_test(bmp test_bmp)
zint_add_test(bwipp test_bwipp)
zint_add_test(channel test_channel) zint_add_test(channel test_channel)
zint_add_test(codabar test_codabar) zint_add_test(codabar test_codabar)
zint_add_test(codablock test_codablock) zint_add_test(codablock test_codablock)

View file

@ -79,7 +79,7 @@ static void test_large(const testCtx *const p_ctx) {
char data_buf[4096] = {0}; /* Suppress clang -fsanitize=memory false positive */ char data_buf[4096] = {0}; /* Suppress clang -fsanitize=memory false positive */
testStartSymbol("test_large", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -118,64 +118,65 @@ static void test_hrt(const testCtx *const p_ctx) {
int output_options; int output_options;
const char *data; const char *data;
const char *expected; const char *expected;
const char *expected_raw;
}; };
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = { static const struct item data[] = {
/* 0*/ { BARCODE_C25STANDARD, -1, -1, "123456789", "123456789" }, /* 0*/ { BARCODE_C25STANDARD, -1, -1, "123456789", "123456789", "" },
/* 1*/ { BARCODE_C25STANDARD, -1, BARCODE_RAW_TEXT, "123456789", "123456789" }, /* 1*/ { BARCODE_C25STANDARD, -1, BARCODE_RAW_TEXT, "123456789", "123456789", "123456789" },
/* 2*/ { BARCODE_C25STANDARD, 1, -1, "123456789", "1234567895" }, /* 2*/ { BARCODE_C25STANDARD, 1, -1, "123456789", "1234567895", "" },
/* 3*/ { BARCODE_C25STANDARD, 1, BARCODE_RAW_TEXT, "123456789", "1234567895" }, /* 3*/ { BARCODE_C25STANDARD, 1, BARCODE_RAW_TEXT, "123456789", "1234567895", "1234567895" },
/* 4*/ { BARCODE_C25STANDARD, 2, -1, "123456789", "123456789" }, /* Suppresses printing of check digit */ /* 4*/ { BARCODE_C25STANDARD, 2, -1, "123456789", "123456789", "" }, /* Suppresses printing of check digit */
/* 5*/ { BARCODE_C25STANDARD, 2, BARCODE_RAW_TEXT, "123456789", "1234567895" }, /* Unless plain HRT */ /* 5*/ { BARCODE_C25STANDARD, 2, BARCODE_RAW_TEXT, "123456789", "123456789", "1234567895" }, /* Not in raw text */
/* 6*/ { BARCODE_C25INTER, -1, -1, "123456789", "0123456789" }, /* Adds leading zero if odd */ /* 6*/ { BARCODE_C25INTER, -1, -1, "123456789", "0123456789", "" }, /* Adds leading zero if odd */
/* 7*/ { BARCODE_C25INTER, -1, BARCODE_RAW_TEXT, "123456789", "0123456789" }, /* 7*/ { BARCODE_C25INTER, -1, BARCODE_RAW_TEXT, "123456789", "0123456789", "0123456789" },
/* 8*/ { BARCODE_C25INTER, 1, -1, "123456789", "1234567895" }, /* Unless check digit added when it becomes even */ /* 8*/ { BARCODE_C25INTER, 1, -1, "123456789", "1234567895", "" }, /* Unless check digit added when it becomes even */
/* 9*/ { BARCODE_C25INTER, 1, BARCODE_RAW_TEXT, "123456789", "1234567895" }, /* 9*/ { BARCODE_C25INTER, 1, BARCODE_RAW_TEXT, "123456789", "1234567895", "1234567895" },
/* 10*/ { BARCODE_C25INTER, 2, -1, "123456789", "123456789" }, /* 10*/ { BARCODE_C25INTER, 2, -1, "123456789", "123456789", "" },
/* 11*/ { BARCODE_C25INTER, 2, BARCODE_RAW_TEXT, "123456789", "1234567895" }, /* 11*/ { BARCODE_C25INTER, 2, BARCODE_RAW_TEXT, "123456789", "123456789", "1234567895" },
/* 12*/ { BARCODE_C25INTER, -1, -1, "1234567890", "1234567890" }, /* No leading zero if even */ /* 12*/ { BARCODE_C25INTER, -1, -1, "1234567890", "1234567890", "" }, /* No leading zero if even */
/* 13*/ { BARCODE_C25INTER, -1, BARCODE_RAW_TEXT, "1234567890", "1234567890" }, /* 13*/ { BARCODE_C25INTER, -1, BARCODE_RAW_TEXT, "1234567890", "1234567890", "1234567890" },
/* 14*/ { BARCODE_C25INTER, 1, -1, "1234567890", "012345678905" }, /* Unless check digit added when it becomes odd */ /* 14*/ { BARCODE_C25INTER, 1, -1, "1234567890", "012345678905", "" }, /* Unless check digit added when it becomes odd */
/* 15*/ { BARCODE_C25INTER, 1, BARCODE_RAW_TEXT, "1234567890", "012345678905" }, /* 15*/ { BARCODE_C25INTER, 1, BARCODE_RAW_TEXT, "1234567890", "012345678905", "012345678905" },
/* 16*/ { BARCODE_C25INTER, 2, -1, "1234567890", "01234567890" }, /* 16*/ { BARCODE_C25INTER, 2, -1, "1234567890", "01234567890", "" },
/* 17*/ { BARCODE_C25INTER, 2, BARCODE_RAW_TEXT, "1234567890", "012345678905" }, /* 17*/ { BARCODE_C25INTER, 2, BARCODE_RAW_TEXT, "1234567890", "01234567890", "012345678905" },
/* 18*/ { BARCODE_C25IATA, -1, -1, "123456789", "123456789" }, /* 18*/ { BARCODE_C25IATA, -1, -1, "123456789", "123456789", "" },
/* 19*/ { BARCODE_C25IATA, -1, BARCODE_RAW_TEXT, "123456789", "123456789" }, /* 19*/ { BARCODE_C25IATA, -1, BARCODE_RAW_TEXT, "123456789", "123456789", "123456789" },
/* 20*/ { BARCODE_C25IATA, 1, -1, "123456789", "1234567895" }, /* 20*/ { BARCODE_C25IATA, 1, -1, "123456789", "1234567895", "" },
/* 21*/ { BARCODE_C25IATA, 1, BARCODE_RAW_TEXT, "123456789", "1234567895" }, /* 21*/ { BARCODE_C25IATA, 1, BARCODE_RAW_TEXT, "123456789", "1234567895", "1234567895" },
/* 22*/ { BARCODE_C25IATA, 2, -1, "123456789", "123456789" }, /* 22*/ { BARCODE_C25IATA, 2, -1, "123456789", "123456789", "" },
/* 23*/ { BARCODE_C25IATA, 2, BARCODE_RAW_TEXT, "123456789", "1234567895" }, /* 23*/ { BARCODE_C25IATA, 2, BARCODE_RAW_TEXT, "123456789", "123456789", "1234567895" },
/* 24*/ { BARCODE_C25LOGIC, -1, -1, "123456789", "123456789" }, /* 24*/ { BARCODE_C25LOGIC, -1, -1, "123456789", "123456789", "" },
/* 25*/ { BARCODE_C25LOGIC, -1, BARCODE_RAW_TEXT, "123456789", "123456789" }, /* 25*/ { BARCODE_C25LOGIC, -1, BARCODE_RAW_TEXT, "123456789", "123456789", "123456789" },
/* 26*/ { BARCODE_C25LOGIC, 1, -1, "123456789", "1234567895" }, /* 26*/ { BARCODE_C25LOGIC, 1, -1, "123456789", "1234567895", "" },
/* 27*/ { BARCODE_C25LOGIC, 1, BARCODE_RAW_TEXT, "123456789", "1234567895" }, /* 27*/ { BARCODE_C25LOGIC, 1, BARCODE_RAW_TEXT, "123456789", "1234567895", "1234567895" },
/* 28*/ { BARCODE_C25LOGIC, 2, -1, "123456789", "123456789" }, /* 28*/ { BARCODE_C25LOGIC, 2, -1, "123456789", "123456789", "" },
/* 29*/ { BARCODE_C25LOGIC, 2, BARCODE_RAW_TEXT, "123456789", "1234567895" }, /* 29*/ { BARCODE_C25LOGIC, 2, BARCODE_RAW_TEXT, "123456789", "123456789", "1234567895" },
/* 30*/ { BARCODE_C25IND, -1, -1, "123456789", "123456789" }, /* 30*/ { BARCODE_C25IND, -1, -1, "123456789", "123456789", "" },
/* 31*/ { BARCODE_C25IND, -1, BARCODE_RAW_TEXT, "123456789", "123456789" }, /* 31*/ { BARCODE_C25IND, -1, BARCODE_RAW_TEXT, "123456789", "123456789", "123456789" },
/* 32*/ { BARCODE_C25IND, 1, -1, "123456789", "1234567895" }, /* 32*/ { BARCODE_C25IND, 1, -1, "123456789", "1234567895", "" },
/* 33*/ { BARCODE_C25IND, 1, BARCODE_RAW_TEXT, "123456789", "1234567895" }, /* 33*/ { BARCODE_C25IND, 1, BARCODE_RAW_TEXT, "123456789", "1234567895", "1234567895" },
/* 34*/ { BARCODE_C25IND, 2, -1, "123456789", "123456789" }, /* 34*/ { BARCODE_C25IND, 2, -1, "123456789", "123456789", "" },
/* 35*/ { BARCODE_C25IND, 2, BARCODE_RAW_TEXT, "123456789", "1234567895" }, /* 35*/ { BARCODE_C25IND, 2, BARCODE_RAW_TEXT, "123456789", "123456789", "1234567895" },
/* 36*/ { BARCODE_DPLEIT, -1, -1, "123456789", "00001.234.567.890" }, /* Leading zeroes added to make 13 + appended checksum */ /* 36*/ { BARCODE_DPLEIT, -1, -1, "123456789", "00001.234.567.890", "" }, /* Leading zeroes added to make 13 + appended checksum */
/* 37*/ { BARCODE_DPLEIT, -1, BARCODE_RAW_TEXT, "123456789", "00001234567890" }, /* 37*/ { BARCODE_DPLEIT, -1, BARCODE_RAW_TEXT, "123456789", "00001.234.567.890", "00001234567890" },
/* 38*/ { BARCODE_DPLEIT, -1, -1, "1234567890123", "12345.678.901.236" }, /* 38*/ { BARCODE_DPLEIT, -1, -1, "1234567890123", "12345.678.901.236", "" },
/* 39*/ { BARCODE_DPLEIT, -1, BARCODE_RAW_TEXT, "1234567890123", "12345678901236" }, /* 39*/ { BARCODE_DPLEIT, -1, BARCODE_RAW_TEXT, "1234567890123", "12345.678.901.236", "12345678901236" },
/* 40*/ { BARCODE_DPIDENT, -1, -1, "123456789", "00.12 3.456.789 0" }, /* Leading zeroes added to make 11 + appended checksum */ /* 40*/ { BARCODE_DPIDENT, -1, -1, "123456789", "00.12 3.456.789 0", "" }, /* Leading zeroes added to make 11 + appended checksum */
/* 41*/ { BARCODE_DPIDENT, -1, BARCODE_RAW_TEXT, "123456789", "001234567890" }, /* 41*/ { BARCODE_DPIDENT, -1, BARCODE_RAW_TEXT, "123456789", "00.12 3.456.789 0", "001234567890" },
/* 42*/ { BARCODE_DPIDENT, -1, -1, "12345678901", "12.34 5.678.901 6" }, /* 42*/ { BARCODE_DPIDENT, -1, -1, "12345678901", "12.34 5.678.901 6", "" },
/* 43*/ { BARCODE_DPIDENT, -1, BARCODE_RAW_TEXT, "12345678901", "123456789016" }, /* 43*/ { BARCODE_DPIDENT, -1, BARCODE_RAW_TEXT, "12345678901", "12.34 5.678.901 6", "123456789016" },
/* 44*/ { BARCODE_ITF14, -1, -1, "123456789", "00001234567895" }, /* Leading zeroes added to make 13 + appended checksum */ /* 44*/ { BARCODE_ITF14, -1, -1, "123456789", "00001234567895", "" }, /* Leading zeroes added to make 13 + appended checksum */
/* 45*/ { BARCODE_ITF14, -1, BARCODE_RAW_TEXT, "123456789", "00001234567895" }, /* 45*/ { BARCODE_ITF14, -1, BARCODE_RAW_TEXT, "123456789", "00001234567895", "00001234567895" },
/* 46*/ { BARCODE_ITF14, -1, -1, "1234567890123", "12345678901231" }, /* 46*/ { BARCODE_ITF14, -1, -1, "1234567890123", "12345678901231", "" },
/* 47*/ { BARCODE_ITF14, -1, BARCODE_RAW_TEXT, "1234567890123", "12345678901231" }, /* 47*/ { BARCODE_ITF14, -1, BARCODE_RAW_TEXT, "1234567890123", "12345678901231", "12345678901231" },
}; };
const int data_size = ARRAY_SIZE(data); const int data_size = ARRAY_SIZE(data);
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
int expected_length; int expected_length, expected_raw_length;
testStartSymbol("test_hrt", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -188,6 +189,7 @@ static void test_hrt(const testCtx *const p_ctx) {
-1 /*option_1*/, data[i].option_2, -1 /*option_3*/, data[i].output_options, -1 /*option_1*/, data[i].option_2, -1 /*option_3*/, data[i].output_options,
data[i].data, -1, debug); data[i].data, -1, debug);
expected_length = (int) strlen(data[i].expected); expected_length = (int) strlen(data[i].expected);
expected_raw_length = (int) strlen(data[i].expected_raw);
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt); assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
@ -196,6 +198,18 @@ static void test_hrt(const testCtx *const p_ctx) {
i, symbol->text_length, expected_length); i, symbol->text_length, expected_length);
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
i, symbol->text, data[i].expected); i, symbol->text, data[i].expected);
if (symbol->output_options & BARCODE_RAW_TEXT) {
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
assert_nonnull(symbol->raw_segs[0].source, "i:%d raw_segs[0].source NULL\n", i);
assert_equal(symbol->raw_segs[0].length, expected_raw_length,
"i:%d raw_segs[0].length %d != expected_raw_length %d\n",
i, symbol->raw_segs[0].length, expected_raw_length);
assert_zero(memcmp(symbol->raw_segs[0].source, data[i].expected_raw, expected_raw_length),
"i:%d memcmp(%s, %s, %d) != 0\n",
i, symbol->raw_segs[0].source, data[i].expected_raw, expected_raw_length);
} else {
assert_null(symbol->raw_segs, "i:%d raw_segs not NULL\n", i);
}
ZBarcode_Delete(symbol); ZBarcode_Delete(symbol);
} }
@ -233,7 +247,7 @@ static void test_input(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_input", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -369,10 +383,11 @@ static void test_encode(const testCtx *const p_ctx) {
char cmp_buf[4096]; char cmp_buf[4096];
char cmp_msg[1024]; char cmp_msg[1024];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ /* Only do BWIPP/ZXing-C++ tests if asked, too slow otherwise */
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript();
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder();
testStartSymbol("test_encode", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -381,14 +396,18 @@ static void test_encode(const testCtx *const p_ctx) {
symbol = ZBarcode_Create(); symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n"); assert_nonnull(symbol, "Symbol not created\n");
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug); length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/,
-1 /*option_1*/, data[i].option_2, -1 /*option_3*/, -1 /*output_options*/,
data[i].data, -1, debug);
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n",
i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) { if (p_ctx->generate) {
printf(" /*%3d*/ { %s, %d, \"%s\", %s, %d, %d, \"%s\",\n", printf(" /*%3d*/ { %s, %d, \"%s\", %s, %d, %d, \"%s\",\n",
i, testUtilBarcodeName(data[i].symbology), data[i].option_2, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), i, testUtilBarcodeName(data[i].symbology), data[i].option_2,
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment); testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
testUtilModulesPrint(symbol, " ", "\n"); testUtilModulesPrint(symbol, " ", "\n");
printf(" },\n"); printf(" },\n");
@ -396,30 +415,40 @@ static void test_encode(const testCtx *const p_ctx) {
if (ret < ZINT_ERROR) { if (ret < ZINT_ERROR) {
int width, row; int width, row;
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data); assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n",
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); i, symbol->rows, data[i].expected_rows, data[i].data);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n",
i, symbol->width, data[i].expected_width, data[i].data);
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row); ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data); assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n",
i, ret, width, row, data[i].data);
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, data[i].option_2, -1, debug)) { if (do_bwipp && testUtilCanBwipp(i, symbol, -1, data[i].option_2, -1, debug)) {
ret = testUtilBwipp(i, symbol, -1, data[i].option_2, -1, data[i].data, length, NULL, cmp_buf, sizeof(cmp_buf), NULL); ret = testUtilBwipp(i, symbol, -1, data[i].option_2, -1, data[i].data, length, NULL,
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); cmp_buf, sizeof(cmp_buf), NULL);
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n",
i, testUtilBarcodeName(symbol->symbology), ret);
ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, data[i].expected); ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, data[i].expected);
assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n", assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n",
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, data[i].expected); i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, data[i].expected);
} }
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) { if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) {
int cmp_len, ret_len; int cmp_len, ret_len;
char modules_dump[8192 + 1]; char modules_dump[8192 + 1];
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1,
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); "i:%d testUtilModulesDump == -1\n", i);
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, 1 /*zxingcpp_cmp*/, cmp_buf,
sizeof(cmp_buf), &cmp_len);
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n",
i, testUtilBarcodeName(symbol->symbology), ret);
ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len); ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length,
NULL /*primary*/, escaped, &ret_len);
assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n",
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, escaped); i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len,
escaped);
} }
} }
} }

View file

@ -67,7 +67,7 @@ static void test_large(const testCtx *const p_ctx) {
char data_buf[64]; char data_buf[64];
testStartSymbol("test_large", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -104,40 +104,41 @@ static void test_hrt(const testCtx *const p_ctx) {
const char *data; const char *data;
const char *expected; const char *expected;
const char *expected_raw;
}; };
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = { static const struct item data[] = {
/* 0*/ { BARCODE_AUSPOST, -1, "12345678", "" }, /* None */ /* 0*/ { BARCODE_AUSPOST, -1, "12345678", "", "" }, /* None */
/* 1*/ { BARCODE_AUSPOST, BARCODE_RAW_TEXT, "12345678", "1112345678" }, /* 1*/ { BARCODE_AUSPOST, BARCODE_RAW_TEXT, "12345678", "", "1112345678" },
/* 2*/ { BARCODE_AUSPOST, -1, "1234567890123", "" }, /* None */ /* 2*/ { BARCODE_AUSPOST, -1, "1234567890123", "", "" }, /* None */
/* 3*/ { BARCODE_AUSPOST, BARCODE_RAW_TEXT, "1234567890123", "591234567890123" }, /* 3*/ { BARCODE_AUSPOST, BARCODE_RAW_TEXT, "1234567890123", "", "591234567890123" },
/* 4*/ { BARCODE_AUSPOST, -1, "1234567890123456", "" }, /* None */ /* 4*/ { BARCODE_AUSPOST, -1, "1234567890123456", "", "" }, /* None */
/* 5*/ { BARCODE_AUSPOST, BARCODE_RAW_TEXT, "1234567890123456", "591234567890123456" }, /* 5*/ { BARCODE_AUSPOST, BARCODE_RAW_TEXT, "1234567890123456", "", "591234567890123456" },
/* 6*/ { BARCODE_AUSPOST, -1, "123456789012345678", "" }, /* None */ /* 6*/ { BARCODE_AUSPOST, -1, "123456789012345678", "", "" }, /* None */
/* 7*/ { BARCODE_AUSPOST, BARCODE_RAW_TEXT, "123456789012345678", "62123456789012345678" }, /* 7*/ { BARCODE_AUSPOST, BARCODE_RAW_TEXT, "123456789012345678", "", "62123456789012345678" },
/* 8*/ { BARCODE_AUSPOST, -1, "12345678901234567890123", "" }, /* None */ /* 8*/ { BARCODE_AUSPOST, -1, "12345678901234567890123", "", "" }, /* None */
/* 9*/ { BARCODE_AUSPOST, BARCODE_RAW_TEXT, "12345678901234567890123", "6212345678901234567890123" }, /* 9*/ { BARCODE_AUSPOST, BARCODE_RAW_TEXT, "12345678901234567890123", "", "6212345678901234567890123" },
/* 10*/ { BARCODE_AUSREPLY, -1, "1234567", "" }, /* None */ /* 10*/ { BARCODE_AUSREPLY, -1, "1234567", "", "" }, /* None */
/* 11*/ { BARCODE_AUSREPLY, BARCODE_RAW_TEXT, "1234567", "4501234567" }, /* 11*/ { BARCODE_AUSREPLY, BARCODE_RAW_TEXT, "1234567", "", "4501234567" },
/* 12*/ { BARCODE_AUSREPLY, -1, "12345678", "" }, /* None */ /* 12*/ { BARCODE_AUSREPLY, -1, "12345678", "", "" }, /* None */
/* 13*/ { BARCODE_AUSREPLY, BARCODE_RAW_TEXT, "12345678", "4512345678" }, /* 13*/ { BARCODE_AUSREPLY, BARCODE_RAW_TEXT, "12345678", "", "4512345678" },
/* 14*/ { BARCODE_AUSROUTE, -1, "123456", "" }, /* None */ /* 14*/ { BARCODE_AUSROUTE, -1, "123456", "", "" }, /* None */
/* 15*/ { BARCODE_AUSROUTE, BARCODE_RAW_TEXT, "123456", "8700123456" }, /* 15*/ { BARCODE_AUSROUTE, BARCODE_RAW_TEXT, "123456", "", "8700123456" },
/* 16*/ { BARCODE_AUSROUTE, -1, "12345678", "" }, /* None */ /* 16*/ { BARCODE_AUSROUTE, -1, "12345678", "", "" }, /* None */
/* 17*/ { BARCODE_AUSROUTE, BARCODE_RAW_TEXT, "12345678", "8712345678" }, /* 17*/ { BARCODE_AUSROUTE, BARCODE_RAW_TEXT, "12345678", "", "8712345678" },
/* 18*/ { BARCODE_AUSROUTE, -1, "12345", "" }, /* None */ /* 18*/ { BARCODE_AUSROUTE, -1, "12345", "", "" }, /* None */
/* 19*/ { BARCODE_AUSROUTE, BARCODE_RAW_TEXT, "12345", "8700012345" }, /* 19*/ { BARCODE_AUSROUTE, BARCODE_RAW_TEXT, "12345", "", "8700012345" },
/* 20*/ { BARCODE_AUSREDIRECT, -1, "12345678", "" }, /* None */ /* 20*/ { BARCODE_AUSREDIRECT, -1, "12345678", "", "" }, /* None */
/* 21*/ { BARCODE_AUSREDIRECT, BARCODE_RAW_TEXT, "12345678", "9212345678" }, /* 21*/ { BARCODE_AUSREDIRECT, BARCODE_RAW_TEXT, "12345678", "", "9212345678" },
/* 22*/ { BARCODE_AUSREDIRECT, -1, "1234", "" }, /* None */ /* 22*/ { BARCODE_AUSREDIRECT, -1, "1234", "", "" }, /* None */
/* 23*/ { BARCODE_AUSREDIRECT, BARCODE_RAW_TEXT, "1234", "9200001234" }, /* 23*/ { BARCODE_AUSREDIRECT, BARCODE_RAW_TEXT, "1234", "", "9200001234" },
}; };
const int data_size = ARRAY_SIZE(data); const int data_size = ARRAY_SIZE(data);
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
int expected_length; int expected_length, expected_raw_length;
testStartSymbol("test_hrt", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -150,6 +151,7 @@ static void test_hrt(const testCtx *const p_ctx) {
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options, -1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options,
data[i].data, -1, debug); data[i].data, -1, debug);
expected_length = (int) strlen(data[i].expected); expected_length = (int) strlen(data[i].expected);
expected_raw_length = (int) strlen(data[i].expected_raw);
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt); assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
@ -158,6 +160,18 @@ static void test_hrt(const testCtx *const p_ctx) {
i, symbol->text_length, expected_length); i, symbol->text_length, expected_length);
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
i, symbol->text, data[i].expected); i, symbol->text, data[i].expected);
if (symbol->output_options & BARCODE_RAW_TEXT) {
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
assert_nonnull(symbol->raw_segs[0].source, "i:%d raw_segs[0].source NULL\n", i);
assert_equal(symbol->raw_segs[0].length, expected_raw_length,
"i:%d raw_segs[0].length %d != expected_raw_length %d\n",
i, symbol->raw_segs[0].length, expected_raw_length);
assert_zero(memcmp(symbol->raw_segs[0].source, data[i].expected_raw, expected_raw_length),
"i:%d memcmp(%s, %s, %d) != 0\n",
i, symbol->raw_segs[0].source, data[i].expected_raw, expected_raw_length);
} else {
assert_null(symbol->raw_segs, "i:%d raw_segs not NULL\n", i);
}
ZBarcode_Delete(symbol); ZBarcode_Delete(symbol);
} }
@ -209,7 +223,7 @@ static void test_input(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
testStartSymbol("test_input", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -352,7 +366,7 @@ static void test_encode(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
testStartSymbol("test_encode", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -422,7 +436,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_fuzz", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {

File diff suppressed because it is too large Load diff

View file

@ -43,50 +43,55 @@ static void test_input(const testCtx *const p_ctx) {
int expected_rows; int expected_rows;
int expected_width; int expected_width;
const char *expected; const char *expected;
const char *expected_raw;
const char *comment; const char *comment;
}; };
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = { static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, "123456", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 792: Input length 6 too short (minimum 7)", "" }, /* 0*/ { UNICODE_MODE, -1, "123456", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 792: Input length 6 too short (minimum 7)", "", "" },
/* 1*/ { UNICODE_MODE, -1, "1234567890123456789", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 790: Input length 19 too long (maximum 18)", "" }, /* 1*/ { UNICODE_MODE, -1, "1234567890123456789", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 790: Input length 19 too long (maximum 18)", "", "" },
/* 2*/ { UNICODE_MODE, -1, "1234567", -1, 0, 1, 102, "1U234567", "" }, /* 2*/ { UNICODE_MODE, -1, "1234567", -1, 0, 1, 102, "1U234567", "", "" },
/* 3*/ { UNICODE_MODE, BARCODE_RAW_TEXT, "1234567", -1, 0, 1, 102, "1U234567", "" }, /* No difference */ /* 3*/ { UNICODE_MODE, BARCODE_RAW_TEXT, "1234567", -1, 0, 1, 102, "1U234567", "1U234567", "No difference" },
/* 4*/ { UNICODE_MODE, -1, "1234567 ", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 791: Invalid character at position 8 in input (alphanumerics only, excluding \"O\")", "" }, /* 4*/ { UNICODE_MODE, -1, "1234567 ", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 791: Invalid character at position 8 in input (alphanumerics only, excluding \"O\")", "", "" },
/* 5*/ { UNICODE_MODE, -1, "ABCDEFGHIJKLMNOPQR", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 791: Invalid character at position 15 in input (alphanumerics only, excluding \"O\")", "" }, /* 5*/ { UNICODE_MODE, -1, "ABCDEFGHIJKLMNOPQR", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 791: Invalid character at position 15 in input (alphanumerics only, excluding \"O\")", "", "" },
/* 6*/ { UNICODE_MODE, -1, "ABCDEFGHIJKLMNPQRS", -1, 0, 1, 234, "AQBCDEFGHIJKLMNPQRS", "" }, /* 6*/ { UNICODE_MODE, -1, "ABCDEFGHIJKLMNPQRS", -1, 0, 1, 234, "AQBCDEFGHIJKLMNPQRS", "", "" },
/* 7*/ { UNICODE_MODE, BARCODE_RAW_TEXT, "ABCDEFGHIJKLMNPQRS", -1, 0, 1, 234, "AQBCDEFGHIJKLMNPQRS", "" }, /* No difference */ /* 7*/ { UNICODE_MODE, BARCODE_RAW_TEXT, "ABCDEFGHIJKLMNPQRS", -1, 0, 1, 234, "AQBCDEFGHIJKLMNPQRS", "AQBCDEFGHIJKLMNPQRS", "No difference" },
/* 8*/ { UNICODE_MODE, -1, "STUVWXYZ1234567890", -1, 0, 1, 234, "SCTUVWXYZ1234567890", "" }, /* 8*/ { UNICODE_MODE, -1, "STUVWXYZ1234567890", -1, 0, 1, 234, "SCTUVWXYZ1234567890", "", "" },
/* 9*/ { UNICODE_MODE, -1, "abcdefghijklmnpqrs", -1, 0, 1, 234, "AQBCDEFGHIJKLMNPQRS", "" }, /* 9*/ { UNICODE_MODE, -1, "abcdefghijklmnpqrs", -1, 0, 1, 234, "AQBCDEFGHIJKLMNPQRS", "", "" },
/* 10*/ { UNICODE_MODE, BARCODE_RAW_TEXT, "abcdefghijklmnpqrs", -1, 0, 1, 234, "AQBCDEFGHIJKLMNPQRS", "" }, /* No difference */ /* 10*/ { UNICODE_MODE, BARCODE_RAW_TEXT, "abcdefghijklmnpqrs", -1, 0, 1, 234, "AQBCDEFGHIJKLMNPQRS", "AQBCDEFGHIJKLMNPQRS", "No difference" },
/* 11*/ { UNICODE_MODE, -1, "123456789012345678", -1, 0, 1, 234, "1223456789012345678", "" }, /* 11*/ { UNICODE_MODE, -1, "123456789012345678", -1, 0, 1, 234, "1223456789012345678", "", "" },
/* 12*/ { UNICODE_MODE, -1, "MMMMMMMMMMMMMMMMMM", -1, 0, 1, 234, "MTMMMMMMMMMMMMMMMMM", "" }, /* 12*/ { UNICODE_MODE, BARCODE_RAW_TEXT, "123456789012345678", -1, 0, 1, 234, "1223456789012345678", "1223456789012345678", "No difference" },
/* 13*/ { UNICODE_MODE, -1, "00000000", -1, 0, 1, 114, "000000000", "" }, /* 13*/ { UNICODE_MODE, -1, "MMMMMMMMMMMMMMMMMM", -1, 0, 1, 234, "MTMMMMMMMMMMMMMMMMM", "", "" },
/* 14*/ { UNICODE_MODE, BARCODE_RAW_TEXT, "00000000", -1, 0, 1, 114, "000000000", "" }, /* No difference */ /* 14*/ { UNICODE_MODE, -1, "00000000", -1, 0, 1, 114, "000000000", "", "" },
/* 15*/ { UNICODE_MODE, -1, "000000000", -1, 0, 1, 126, "0000000000", "" }, /* 15*/ { UNICODE_MODE, BARCODE_RAW_TEXT, "00000000", -1, 0, 1, 114, "000000000", "000000000", "" },
/* 16*/ { UNICODE_MODE, BARCODE_RAW_TEXT, "000000000", -1, 0, 1, 126, "0000000000", "" }, /* No difference */ /* 16*/ { UNICODE_MODE, -1, "000000000", -1, 0, 1, 126, "0000000000", "", "" },
/* 17*/ { UNICODE_MODE, -1, "000S0S000S", -1, 0, 1, 138, "0S00S0S000S", "" }, /* 17*/ { UNICODE_MODE, BARCODE_RAW_TEXT, "000000000", -1, 0, 1, 126, "0000000000", "0000000000", "" },
/* 18*/ { UNICODE_MODE, -1, "ZYXWVUTSRQP", -1, 0, 1, 150, "Z0YXWVUTSRQP", "" }, /* 18*/ { UNICODE_MODE, -1, "000S0S000S", -1, 0, 1, 138, "0S00S0S000S", "", "" },
/* 19*/ { UNICODE_MODE, -1, "0R9GLVHA8EZ4", -1, 0, 1, 162, "0DR9GLVHA8EZ4", "" }, /* 19*/ { UNICODE_MODE, BARCODE_RAW_TEXT, "000S0S000S", -1, 0, 1, 138, "0S00S0S000S", "0S00S0S000S", "" },
/* 20*/ { UNICODE_MODE, -1, "NTS1J2Q6C7DYK", -1, 0, 1, 174, "NRTS1J2Q6C7DYK", "" }, /* 20*/ { UNICODE_MODE, -1, "ZYXWVUTSRQP", -1, 0, 1, 150, "Z0YXWVUTSRQP", "", "" },
/* 21*/ { UNICODE_MODE, -1, "TS1J2Q6C7DYKBU", -1, 0, 1, 186, "TWS1J2Q6C7DYKBU", "" }, /* 21*/ { UNICODE_MODE, -1, "0R9GLVHA8EZ4", -1, 0, 1, 162, "0DR9GLVHA8EZ4", "", "" },
/* 22*/ { UNICODE_MODE, -1, "IX3FWP5M0R9GLVH", -1, 0, 1, 198, "IBX3FWP5M0R9GLVH", "" }, /* 22*/ { UNICODE_MODE, -1, "NTS1J2Q6C7DYK", -1, 0, 1, 174, "NRTS1J2Q6C7DYK", "", "" },
/* 23*/ { UNICODE_MODE, -1, "R9GLVHA8EZ4NTS1J", -1, 0, 1, 210, "RY9GLVHA8EZ4NTS1J", "" }, /* 23*/ { UNICODE_MODE, -1, "TS1J2Q6C7DYKBU", -1, 0, 1, 186, "TWS1J2Q6C7DYKBU", "", "" },
/* 24*/ { UNICODE_MODE, -1, "M5PWF3XIUBKYD7C6Q", -1, 0, 1, 222, "M35PWF3XIUBKYD7C6Q", "" }, /* 24*/ { UNICODE_MODE, BARCODE_RAW_TEXT, "TS1J2Q6C7DYKBU", -1, 0, 1, 186, "TWS1J2Q6C7DYKBU", "TWS1J2Q6C7DYKBU", "" },
/* 25*/ { UNICODE_MODE, -1, "2J1STN4ZE8AHVLG90R", -1, 0, 1, 234, "2PJ1STN4ZE8AHVLG90R", "" }, /* 25*/ { UNICODE_MODE, -1, "IX3FWP5M0R9GLVH", -1, 0, 1, 198, "IBX3FWP5M0R9GLVH", "", "" },
/* 26*/ { UNICODE_MODE, -1, "JJJJJJJJJJJJJJJJJJ", -1, 0, 1, 234, "J9JJJJJJJJJJJJJJJJJ", "" }, /* 26*/ { UNICODE_MODE, -1, "R9GLVHA8EZ4NTS1J", -1, 0, 1, 210, "RY9GLVHA8EZ4NTS1J", "", "" },
/* 27*/ { UNICODE_MODE, BARCODE_RAW_TEXT, "JJJJJJJJJJJJJJJJJJ", -1, 0, 1, 234, "J9JJJJJJJJJJJJJJJJJ", "" }, /* No difference */ /* 27*/ { UNICODE_MODE, -1, "M5PWF3XIUBKYD7C6Q", -1, 0, 1, 222, "M35PWF3XIUBKYD7C6Q", "", "" },
/* 28*/ { UNICODE_MODE, -1, "2J1STN4ZE8AHVLG90R", -1, 0, 1, 234, "2PJ1STN4ZE8AHVLG90R", "", "" },
/* 29*/ { UNICODE_MODE, BARCODE_RAW_TEXT, "2J1STN4ZE8AHVLG90R", -1, 0, 1, 234, "2PJ1STN4ZE8AHVLG90R", "2PJ1STN4ZE8AHVLG90R", "" },
/* 30*/ { UNICODE_MODE, -1, "JJJJJJJJJJJJJJJJJJ", -1, 0, 1, 234, "J9JJJJJJJJJJJJJJJJJ", "", "" },
/* 31*/ { UNICODE_MODE, BARCODE_RAW_TEXT, "JJJJJJJJJJJJJJJJJJ", -1, 0, 1, 234, "J9JJJJJJJJJJJJJJJJJ", "J9JJJJJJJJJJJJJJJJJ", "" },
}; };
const int data_size = ARRAY_SIZE(data); const int data_size = ARRAY_SIZE(data);
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
int expected_length; int expected_length, expected_raw_length;
char bwipp_buf[8192]; char bwipp_buf[8192];
char bwipp_msg[1024]; char bwipp_msg[1024];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
testStartSymbol("test_input", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -99,6 +104,7 @@ static void test_input(const testCtx *const p_ctx) {
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options, -1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options,
data[i].data, data[i].length, debug); data[i].data, data[i].length, debug);
expected_length = (int) strlen(data[i].expected); expected_length = (int) strlen(data[i].expected);
expected_raw_length = (int) strlen(data[i].expected_raw);
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
@ -112,6 +118,18 @@ static void test_input(const testCtx *const p_ctx) {
i, symbol->text_length, expected_length); i, symbol->text_length, expected_length);
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
i, symbol->text, data[i].expected); i, symbol->text, data[i].expected);
if (symbol->output_options & BARCODE_RAW_TEXT) {
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
assert_nonnull(symbol->raw_segs[0].source, "i:%d raw_segs[0].source NULL\n", i);
assert_equal(symbol->raw_segs[0].length, expected_raw_length,
"i:%d raw_segs[0].length %d != expected_raw_length %d\n",
i, symbol->raw_segs[0].length, expected_raw_length);
assert_zero(memcmp(symbol->raw_segs[0].source, data[i].expected_raw, expected_raw_length),
"i:%d memcmp(%s, %s, %d) != 0\n",
i, symbol->raw_segs[0].source, data[i].expected_raw, expected_raw_length);
} else {
assert_null(symbol->raw_segs, "i:%d raw_segs not NULL\n", i);
}
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, -1, -1, debug)) { if (do_bwipp && testUtilCanBwipp(i, symbol, -1, -1, -1, debug)) {
char modules_dump[8192 + 1]; char modules_dump[8192 + 1];
@ -165,7 +183,7 @@ static void test_encode(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
testStartSymbol("test_encode", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {

View file

@ -95,7 +95,7 @@ static void test_u_big5_int(const testCtx *const p_ctx) {
(void)debug; (void)debug;
#endif #endif
testStart("test_u_big5_int"); testStart(p_ctx->func_name);
#ifdef TEST_JUST_SAY_GNO #ifdef TEST_JUST_SAY_GNO
if ((debug & ZINT_DEBUG_TEST_PERFORMANCE)) { /* -d 256 */ if ((debug & ZINT_DEBUG_TEST_PERFORMANCE)) { /* -d 256 */
@ -199,7 +199,7 @@ static void test_big5_utf8(const testCtx *const p_ctx) {
struct zint_symbol symbol = {0}; struct zint_symbol symbol = {0};
unsigned int b5data[20]; unsigned int b5data[20];
testStart("test_big5_utf8"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int ret_length; int ret_length;

View file

@ -67,7 +67,7 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
const char *const have_identify = testUtilHaveIdentify(); const char *const have_identify = testUtilHaveIdentify();
testStart("test_pixel_plot"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int size; int size;
@ -160,7 +160,7 @@ static void test_print(const testCtx *const p_ctx) {
const char *const have_identify = testUtilHaveIdentify(); const char *const have_identify = testUtilHaveIdentify();
testStart("test_print"); testStart(p_ctx->func_name);
if (p_ctx->generate) { if (p_ctx->generate) {
char data_dir_path[1024]; char data_dir_path[1024];
@ -255,7 +255,7 @@ static void test_outfile(const testCtx *const p_ctx) {
(void)p_ctx; (void)p_ctx;
testStart("test_outfile"); testStart(p_ctx->func_name);
symbol.symbology = BARCODE_CODE128; symbol.symbology = BARCODE_CODE128;
symbol.bitmap = data; symbol.bitmap = data;

321
backend/tests/test_bwipp.c Normal file
View file

@ -0,0 +1,321 @@
/*
libzint - the open source barcode library
Copyright (C) 2025 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* SPDX-License-Identifier: BSD-3-Clause */
#include "testcommon.h"
static int aztec_width(const int bwipp_len) {
static const int width_lens[33] = {
15 * 15, 19 * 19, 23 * 23, 27 * 27, 31 * 31, 37 * 37, 41 * 41, 45 * 45, 49 * 49, 53 * 53,
57 * 57, 61 * 61, 67 * 67, 71 * 71, 75 * 75, 79 * 79, 83 * 83, 87 * 87, 91 * 91, 95 * 95,
101 * 101, 105 * 105, 109 * 109, 113 * 113, 117 * 117, 121 * 121, 125 * 125, 131 * 131, 135 * 135, 139 * 139,
143 * 143, 147 * 147, 151 * 151,
};
static const int widths[33] = {
15, 19, 23, 27, 31, 37, 41, 45, 49, 53,
57, 61, 67, 71, 75, 79, 83, 87, 91, 95,
101, 105, 109, 113, 117, 121, 125, 131, 135, 139,
143, 147, 151,
};
int i;
for (i = ARRAY_SIZE(width_lens) - 1; i >= 0 && width_lens[i] != bwipp_len; i--);
return i >= 0 ? widths[i] : 0;
}
static int cnv_hex_data(const char *hex, char *buf, const int buf_size) {
const char *h = hex;
const char *const he = hex + strlen(hex);
char *str_end;
int i;
for (i = 0; i < buf_size && h < he; i++) {
buf[i] = (char) strtol(h, &str_end, 16);
if (str_end == h) {
return -1;
}
h = str_end + 1;
}
if (i < buf_size) buf[i] = '\0';
return i == buf_size ? -1 : i;
}
static void test_aztec_random(const testCtx *const p_ctx) {
#ifndef _WIN32
int debug = p_ctx->debug;
int i, length, ret;
#endif
struct zint_symbol *symbol = NULL;
#ifndef _WIN32
int symbology = BARCODE_AZTEC;
int input_mode = DATA_MODE;
int eci = 899;
int option_1 = 1;
int option_2 = -1;
int option_3 = -1;
int output_options = -1;
char data_buf[4096];
char bwipp_buf[32768];
char escaped[8192];
char escaped2[8192];
char cmp_buf[8192];
char cmp_msg[8192];
char ret_buf[8192] = {0}; /* Suppress clang -fsanitize=memory false positive */
const int iterations = p_ctx->arg ? p_ctx->arg : 10000; /* Use "-a N" to set iterations */
/* Requires to be run with "-d 1024" (see ZINT_DEBUG_TEST_BWIPP_ZXINGCPP in "testcommon.h") */
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP_ZXINGCPP) && testUtilHaveGhostscript();
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_BWIPP_ZXINGCPP) && testUtilHaveZXingCPPDecoder();
#endif
testStartSymbol(p_ctx->func_name, &symbol);
#ifdef _WIN32
testSkip("Test not implemented on Windows");
#else
if (!do_bwipp || !do_zxingcpp) {
testSkip("Test requires BWIPP and ZXing-C++");
return;
}
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
printf(" iterations %d\n", iterations);
for (i = 0; i < iterations; i++) {
int bwipp_len, cmp_len, ret_len;
length = arc4random_uniform(1800) + 1;
arc4random_buf(data_buf, length);
testUtilSetSymbol(symbol, symbology, input_mode, eci, option_1, option_2, option_3,
output_options, data_buf, length, debug);
assert_nonzero(testUtilCanBwipp(i, symbol, option_1, option_2, option_3, debug),
"i:%d testUtilCanBwipp != 0\n", i);
assert_nonzero(testUtilCanZXingCPP(i, symbol, data_buf, length, debug), "i:%d testUtilCanZXingCPP != 0\n", i);
symbol->rows = 0;
ret = testUtilBwipp(i, symbol, option_1, option_2, option_3, data_buf, length, NULL, bwipp_buf,
sizeof(bwipp_buf), NULL);
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
bwipp_len = strlen(bwipp_buf);
assert_nonzero(bwipp_len, "i:%d bwipp_len %d = 0\n", i, bwipp_len);
symbol->width = aztec_width(bwipp_len);
assert_equal(symbol->width * symbol->width, bwipp_len,
"i:%d symbol->width^2 %d != bwipp_len %d (symbol->width %d)\n",
i, symbol->width * symbol->width, bwipp_len, symbol->width);
ret = testUtilZXingCPP(i, symbol, data_buf, length, bwipp_buf, 1 /*zxingcpp_cmp*/, cmp_buf, sizeof(cmp_buf),
&cmp_len);
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
/*fprintf(stderr, "cmp_len %d\n", cmp_len);*/
ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data_buf, length, NULL /*primary*/,
ret_buf, &ret_len);
assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %s\nexpected: %s\n",
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg,
testUtilEscape(cmp_buf, cmp_len, escaped, sizeof(escaped)),
testUtilEscape(ret_buf, ret_len, escaped2, sizeof(escaped2)));
}
ZBarcode_Delete(symbol);
testFinish();
#endif /* _WIN32 */
}
static void test_aztec_bwipjs_354(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
const char *data;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 0*/ { "08 77 00 81 A2 2E 20 47 C3 92 B8 F1 AD" },
/* 1*/ { "86 A0 B3 0D 0A 41 86 66 8E FD 43" },
/* 2*/ { "AE 45 C1 84 90 0D 0A 59 8C 4D DB 33 44" },
/* 3*/ { "38 15 AC B3 FA 3A 20 56 0A 94 66 A7 D7" },
/* 4*/ { "7D 82 BC 46 6A 0D 0A 4A CA 89 B3 D4 66" },
/* 5*/ { "BD 9C 7F 2C 20 F2 99 D0 66 49 7F 3E F2 44 CD 10 EC 1B 38 3E 27 07 2C 58 5E 42 A3 B4 D3 D9 98 61 F1 B6 E6 0F 82 3A FE FB 05 09 A2 22 8C E6 56 33 49 66 00 3B 5D 0B 5F 81 51 72 BA 6A B0 8C D2 68 2D FA 71 F6 C1 1A FC 1A 85 18 30 89 0F BC FD 44 CB D5 B3 84 5D FE 25 4E 70 86 12 D9 65 D7 6F 3D CD 97 27 07 31 46 F3 85 9A 0A 87 D4 02 B8 98 56 44 56 17 00 7F 21 81 C8 5F 37 81 C0 CC 98 87 2C 2D C5 8D 53 7D 46 8D 6E 8C 20 8A 9B 79 4E 33 C6 55 07 A2 05 C8 82 D0 EF CF 86 F1 79 00 0A 6F 4E 18 52 D8 64 51 0F 0A C5 9A CD 6B BD C0 A0 AB 24 F5 1D 2F E3 4D CF B7 92 7F 9C 24 48 6C D5 CD 21 AD 3C FE 65 5B 19 51 F5 8C 72 01 5D 51 CC 9C 50 7C 95 12 D5 32 E4 17 6F 39 EB 91 37 36 C2 D5 5B 30 DE F6 F1 FF 83 8F 80 75 24 E4 2A EF AA AD C5 A3 5B F0 B3 94 73 9C C9 00 D0 52 DF 1A 8A 2D DE E7 F4 45 FA FE EA 50 4D 12 DF 51 D5 5E D1 97 74 95 48 D6 C5 CB 7D E0 23 91 67 4B F3 DD 07 19 61 05 CC 91 52 D8 33 BB B8 B6 87 16 1C C5 28 72 6C 31 A8 04 7E 90 E8 23 94 4F C6 37 E7 5F 38 01 81 42 08 44 45 56 44 56 11 04 21" },
/* 6*/ { "CF 03 28 05 68 3A 20 4A DF 7B 82 61 24" },
/* 7*/ { "AD F2 EF 17 99 3A 20 53 94 9F C3 1D 87" },
/* 8*/ { "63 F4 F5 FE 28 0D 0A 4C 05 02 DA DA 3F" },
/* 9*/ { "C5 8C 5F D5 DF 2C 20 56 F3 25 91 57 A0" },
/* 10*/ { "CC A4 68 67 8D 3A 20 51 38 90 71 50 D8" },
/* 11*/ { "A9 CE F9 ED 9E 2E 20 53 42 BC 8E 12 57" },
/* 12*/ { "2D CD 5A 50 8A 0D 0A 46 A4 84 6B B0 6F" },
/* 13*/ { "C1 30 C4 53 C2 2E 20 4A DF 14 48 94 B1" },
/* 14*/ { "06 CF 01 7A 73 3A 20 59 76 E0 B2 A4 52" },
/* 15*/ { "63 D3 1A A2 86 2C 20 1F 2E 20 F4 F9 BB 72 D6 40 15 47 29 4B 7F 18 E2 E6 FF C7 B5 70 8B 0C 66 4D EF 68 9A 05 56 44 56 17 00 7F 21 81 C8 5F 37 81 C0 CC 98 87 2C 2D C5 8D 53 7D 46 8D 6E 8C 20 8A 9B 79 4E 33 C6 55 07 A2 05 C8 82 D0 EF CF 86 F1 79 00 0A 6F 4E 18 52 D8 64 51 0F 0A C5 9A CD 6B BD C0 A0 AB 24 F5 1D 2F E3 4D CF B7 92 7F 9C 24 48 6C D5 CD 21 AD 3C FE 65 5B 19 51 F5 8C 72 01 5D 51 CC 9C 50 7C 95 12 D5 32 E4 17 6F 39 EB 91 37 36 C2 D5 5B 30 DE F6 F1 FF 83 8F 80 75 24 E4 2A EF AA AD C5 A3 5B F0 B3 94 73 9C C9 00 D0 52 DF 1A 8A 2D DE E7 F4 45 FA FE EA 50 4D 12 DF 51 D5 5E D1 97 74 95 48 D6 C5 CB 7D E0 23 91 67 4B F3 DD 07 19 61 05 CC 91 52 D8 33 BB B8 B6 87 16 1C C5 28 72 6C 31 A8 04 7E 90 E8 23 94 4F C6 37 E7 5F 38 01 81 42 08 44 45 56 44 56 11 04 21" },
/* 16*/ { "D4 E0 65 86 30 3A 20 49 0B F7 A3 2B 84" },
/* 17*/ { "14 76 23 3A 20 44 7E 4B E9 D5 2C" },
/* 18*/ { "D1 45 B1 02 EF 0D 0A 34 C6 33 27 FF B5 80 3F EB 3D 06 CD 34 17 FA 73 7F 23 31 83 F9 03 F8 47 60 03 BD 4B 13 58 15 E4 B8 A7 BD CA 0E 1C 6D BC D0 92 18 73 4B A9 EB 50 07 73 2A 59 F0 0F 8B 27 A3 1D 0E 7B CB FB 9C B3 10 38 03 0D 2D C4 5D B0 3F 61 FE FF BA 3B 45 8F 11 83 A6 74 2B 72 BB D3 A0 B8 10 1F D8 6A 42 BC 3F EA 57 9A 05 56 44 56 17 00 7F 21 81 C8 5F 37 81 C0 CC 98 87 2C 2D C5 8D 53 7D 46 8D 6E 8C 20 8A 9B 79 4E 33 C6 55 07 A2 05 C8 82 D0 EF CF 86 F1 79 00 0A 6F 4E 18 52 D8 64 51 0F 0A C5 9A CD 6B BD C0 A0 AB 24 F5 1D 2F E3 4D CF B7 92 7F 9C 24 48 6C D5 CD 21 AD 3C FE 65 5B 19 51 F5 8C 72 01 5D 51 CC 9C 50 7C 95 12 D5 32 E4 17 6F 39 EB 91 37 36 C2 D5 5B 30 DE F6 F1 FF 83 8F 80 75 24 E4 2A EF AA AD C5 A3 5B F0 B3 94 73 9C C9 00 D0 52 DF 1A 8A 2D DE E7 F4 45 FA FE EA 50 4D 12 DF 51 D5 5E D1 97 74 95 48 D6 C5 CB 7D E0 23 91 67 4B F3 DD 07 19 61 05 CC 91 52 D8 33 BB B8 B6 87 16 1C C5 28 72 6C 31 A8 04 7E 90 E8 23 94 4F C6 37 E7 5F 38 01 81 42 08 44 45 56 44 56 11 04 21" },
/* 19*/ { "E8 F4 51 3F F4 3A 20 0D 84 DA 14 44 E8" },
/* 20*/ { "2B F2 AB 75 3D 2C 20 3B 50 49 03 2B CD" },
/* 21*/ { "D8 31 62 57 6E 0D 0A 49 04 10 D2 6A E8" },
/* 22*/ { "81 80 2E 66 91 2C 20 59 35 4D C5 79 89" },
/* 23*/ { "37 5D 72 EB DD 2C 20 DB 6C 8C B8 34 46 FE 45 86 14 92 33 B0 AC 87 59 29 3B AF EE 45 ED 99 3A EA FB F5 A5 B4 14 61 5A 09 CB C9 29 F5 83 E7 9B C2 0B F6 E6 5B D6 4A 7F 37 EE 76 8E 03 FB 04 2D E2 20 5D 5D C4 79 F6 64 03 C9 D4 1E C1 3C CA 36 C3 DA 5D 79 90 2F 88 BD 8E FE 60 AA DF 77 28 5E 73 59 69 21 44 71 01 F2 AA 99 3A 9A 05 56 44 56 17 00 7F 21 81 C8 5F 37 81 C0 48 CA D1 84 F0 E7 DC 2E 97 1E 24 29 57 8B 24 01 45 78 F3 05 68 57 89 72 14 BB 01 D7 FA 34 D6 A6 DE 23 52 B9 1E 70 AA 27 C0 3C 84 56 05 24 8B 97 0A A6 27 D9 47 35 07 60 F5 92 B4 B9 C2 9C 8A 40 F7 FE 53 7C 60 8E 89 77 BB B6 07 DF 3F FC DA 11 56 13 51 52 A7 68 57 D7 60 45 22 C5 06 7B D6 1F 70 D6 A5 4B 7F F2 C9 2E B4 54 C4 5E 06 8D 6E 76 A2 C3 2F 22 8A 04 45 E4 C1 5D 82 3C CC 88 22 16 68 77 DB 3F E0 61 01 1C B3 83 4B 6B 54 44 24 03 AF DE 4F E4 10 38 86 E4 D3 BE 18 E9 8E AC AC 9F 38 DD F5 6A 4F AB AF E5 87 47 9B 9A A6 0F 66 B2 A1 B2 EE 71 7A AB EE 48 16 DE 51 B0 53 EB 3C 06 5F 38 01 81 42 08 44 45 56 44 56 11 04 21" },
/* 24*/ { "C7 C6 DA A1 0D 0A 20 03 CF 8F 2E 8E" },
/* 25*/ { "D1 A5 72 92 8D 0D 0A 4B 86 38 C8 92 A2" },
/* 26*/ { "4D 62 77 F8 E6 3A 20 47 AB 2C 1A 17 74" },
/* 27*/ { "A0 6D 63 A3 92 2C 20 58 F5 4B F4 4B 37" },
/* 28*/ { "1D 14 1A D3 98 2C 20 20 70 7D D0 E9 23" },
/* 29*/ { "7A 60 61 0F EE 2E 20 53 B0 82 59 52 2E" },
/* 30*/ { "27 CB FE 95 25 2C 20 46 20 8A AB B1 4E" },
/* 31*/ { "D5 CD 8C 8E B2 2C 20 52 13 16 8B C9 69" },
/* 32*/ { "22 BA 6C 8B A6 0D 0A B7 22 F8 FC F8 40 7C 47 26 F6 0E F1 1D 9A 51 B9 A8 E0 09 C8 B6 A9 27 C9 A9 EB F1 8F D8 82 CA 6B BA 27 B6 72 44 12 D9 EC C5 CF 6B BD 94 1F F9 9C C7 4C 1B 1C 77 40 8A 21 74 22 4C DC E6 38 D1 9D 41 9E 95 48 87 35 85 D1 32 D4 9E F6 20 D2 38 5E B5 77 E9 07 DF F4 84 44 8B DB 9D 09 80 78 9E 2C DA 7B 1B 9A 05 56 44 56 17 00 7F 21 81 C8 5F 37 81 C0 CC 98 87 2C 2D C5 8D 53 7D 46 8D 6E 8C 20 8A 9B 79 4E 33 C6 55 07 A2 05 C8 82 D0 EF CF 86 F1 79 00 0A 6F 4E 18 52 D8 64 51 0F 0A C5 9A CD 6B BD C0 A0 AB 24 F5 1D 2F E3 4D CF B7 92 7F 9C 24 48 6C D5 CD 21 AD 3C FE 65 5B 19 51 F5 8C 72 01 5D 51 CC 9C 50 7C 95 12 D5 32 E4 17 6F 39 EB 91 37 36 C2 D5 5B 30 DE F6 F1 FF 83 8F 80 75 24 E4 2A EF AA AD C5 A3 5B F0 B3 94 73 9C C9 00 D0 52 DF 1A 8A 2D DE E7 F4 45 FA FE EA 50 4D 12 DF 51 D5 5E D1 97 74 95 48 D6 C5 CB 7D E0 23 91 67 4B F3 DD 07 19 61 05 CC 91 52 D8 33 BB B8 B6 87 16 1C C5 28 72 6C 31 A8 04 7E 90 E8 23 94 4F C6 37 E7 5F 38 01 81 42 08 44 45 56 44 56 11 04 21" },
/* 33*/ { "3A 3B A3 B0 3D 2E 20 4C 12 7A 39 06 CB" },
/* 34*/ { "4E C6 3E B8 DD 3A 20 6E 72 67 2B BE 56 92 DB" },
/* 35*/ { "C5 48 67 EA FB 3A 20 07 1F 01 F3 EF 82 85 F0 18 1C 86 E4 E7 70 AD 9A 2A 68 73 4A 82 8A 09 33 16 9C CC 83 61 2D 36 E0 EF 57 96 DB 64 08 90 1B 69 23 77 E9 97 9D 4B 2A 2B F8 09 D8 85 86 BC 80 F7 D0 5E B9 8E 5E D3 33 4E C1 13 58 0D 6A 68 77 CE 6C B0 49 C4 9F 58 86 D3 95 F7 CE A6 DD F0 6E 9A 05 56 44 56 17 00 7F 21 81 C8 5F 37 81 C0 CC 98 87 2C 2D C5 8D 53 7D 46 8D 6E 8C 20 8A 9B 79 4E 33 C6 55 07 A2 05 C8 82 D0 EF CF 86 F1 79 00 0A 6F 4E 18 52 D8 64 51 0F 0A C5 9A CD 6B BD C0 A0 AB 24 F5 1D 2F E3 4D CF B7 92 7F 9C 24 48 6C D5 CD 21 AD 3C FE 65 5B 19 51 F5 8C 72 01 5D 51 CC 9C 50 7C 95 12 D5 32 E4 17 6F 39 EB 91 37 36 C2 D5 5B 30 DE F6 F1 FF 83 8F 80 75 24 E4 2A EF AA AD C5 A3 5B F0 B3 94 73 9C C9 00 D0 52 DF 1A 8A 2D DE E7 F4 45 FA FE EA 50 4D 12 DF 51 D5 5E D1 97 74 95 48 D6 C5 CB 7D E0 23 91 67 4B F3 DD 07 19 61 05 CC 91 52 D8 33 BB B8 B6 87 16 1C C5 28 72 6C 31 A8 04 7E 90 E8 23 94 4F C6 37 E7 5F 38 01 81 42 08 44 45 56 44 56 11 04 21" },
/* 36*/ { "24 47 8C DF B9 2C 20 4A 72 4D 7A 46 BF" },
/* 37*/ { "D4 2A 1D CE A4 2E 20 44 04 BD 19 7D A4" },
/* 38*/ { "1F AB 7C 69 B4 3A 20 4B FE 23 7D 5B CD" },
/* 39*/ { "2B 2F 40 94 6D 2E 20 55 69 DE 3D 15 74" },
/* 40*/ { "17 CC A0 F7 7D 2C 20 5A 2B 13 72 7F 7B" },
/* 41*/ { "E6 48 F3 56 A9 3A 20 58 F5 77 45 B8 71" },
/* 42*/ { "0D 0A 4C FA D8 67 95 EA" },
/* 43*/ { "52 38 A1 5F F9 2E 20 41 A0 6E 06 6D CD" },
/* 44*/ { "D6 FD C4 7D 2D 0D 0A 52 A0 CA 01 A0 A8" },
/* 45*/ { "DB 89 AD 70 F3 2E 20 4A 53 5E 00 DB E1" },
/* 46*/ { "8C A1 D2 FB F2 3A 20 71 7A 35 97 55 31 3C" },
/* 47*/ { "81 80 25 A8 BE 2C 20 49 EE C0 B9 81 7F" },
/* 48*/ { "2E 20 20 27 37 7E AA E4" },
/* 49*/ { "76 60 3D D7 32 2C 20 48 39 D9 86 CA 93" },
};
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
int symbology = BARCODE_AZTEC;
int input_mode = DATA_MODE;
int eci = 899;
int option_1 = 1;
int option_2 = -1;
int option_3 = -1;
int output_options = -1;
char data_buf[4096];
char bwipp_buf[32768];
char escaped[8192];
char escaped2[8192];
char cmp_buf[8192];
char cmp_msg[8192];
char ret_buf[8192] = {0}; /* Suppress clang -fsanitize=memory false positive */
/* Requires to be run with "-d 1024" (see ZINT_DEBUG_TEST_BWIPP_ZXINGCPP in "testcommon.h") */
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP_ZXINGCPP) && testUtilHaveGhostscript();
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_BWIPP_ZXINGCPP) && testUtilHaveZXingCPPDecoder();
testStartSymbol(p_ctx->func_name, &symbol);
if (!do_bwipp || !do_zxingcpp) {
testSkip("Test requires BWIPP and ZXing-C++");
return;
}
for (i = 0; i < data_size; i++) {
int bwipp_len, cmp_len, ret_len;
if (testContinue(p_ctx, i)) continue;
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
length = cnv_hex_data(data[i].data, data_buf, ARRAY_SIZE(data_buf));
assert_nonzero(length, "i:%d cnv_hex_data length zero\n", i);
#if 0
debug_print_escape(TCU(data_buf), length, NULL);
printf("\n");
#endif
testUtilSetSymbol(symbol, symbology, input_mode, eci, option_1, option_2, option_3,
output_options, data_buf, length, debug);
assert_nonzero(testUtilCanBwipp(i, symbol, option_1, option_2, option_3, debug),
"i:%d testUtilCanBwipp != 0\n", i);
assert_nonzero(testUtilCanZXingCPP(i, symbol, data_buf, length, debug), "i:%d testUtilCanZXingCPP != 0\n", i);
symbol->rows = 0;
ret = testUtilBwipp(i, symbol, option_1, option_2, option_3, data_buf, length, NULL, bwipp_buf,
sizeof(bwipp_buf), NULL);
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
bwipp_len = strlen(bwipp_buf);
assert_nonzero(bwipp_len, "i:%d bwipp_len %d = 0\n", i, bwipp_len);
symbol->width = aztec_width(bwipp_len);
assert_equal(symbol->width * symbol->width, bwipp_len,
"i:%d symbol->width^2 %d != bwipp_len %d (symbol->width %d)\n",
i, symbol->width * symbol->width, bwipp_len, symbol->width);
ret = testUtilZXingCPP(i, symbol, data_buf, length, bwipp_buf, 1 /*zxingcpp_cmp*/, cmp_buf, sizeof(cmp_buf),
&cmp_len);
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
/*fprintf(stderr, "cmp_len %d\n", cmp_len);*/
ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data_buf, length, NULL /*primary*/,
ret_buf, &ret_len);
assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %s\nexpected: %s\n",
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg,
testUtilEscape(cmp_buf, cmp_len, escaped, sizeof(escaped)),
testUtilEscape(ret_buf, ret_len, escaped2, sizeof(escaped2)));
ZBarcode_Delete(symbol);
}
testFinish();
}
int main(int argc, char *argv[]) {
testFunction funcs[] = { /* name, func */
{ "test_aztec_random", test_aztec_random },
{ "test_aztec_bwipjs_354", test_aztec_bwipjs_354 },
};
testRun(argc, argv, funcs, ARRAY_SIZE(funcs));
testReport();
return 0;
}
/* vim: set ts=4 sw=4 et : */

View file

@ -57,32 +57,42 @@ static void test_hrt(const testCtx *const p_ctx) {
/* 10*/ { 5, -1, "12", -1, "0012" }, /* 10*/ { 5, -1, "12", -1, "0012" },
/* 11*/ { 5, BARCODE_RAW_TEXT, "12", -1, "0012" }, /* 11*/ { 5, BARCODE_RAW_TEXT, "12", -1, "0012" },
/* 12*/ { 5, -1, "1", -1, "0001" }, /* 12*/ { 5, -1, "1", -1, "0001" },
/* 13*/ { 5, -1, "1234", -1, "1234" }, /* 13*/ { 5, BARCODE_RAW_TEXT, "1", -1, "0001" },
/* 14*/ { 6, -1, "1234", -1, "01234" }, /* 14*/ { 5, -1, "1234", -1, "1234" },
/* 15*/ { 6, -1, "123", -1, "00123" }, /* 15*/ { 5, BARCODE_RAW_TEXT, "1234", -1, "1234" },
/* 16*/ { 6, -1, "12", -1, "00012" }, /* 16*/ { 6, -1, "1234", -1, "01234" },
/* 17*/ { 6, -1, "1", -1, "00001" }, /* 17*/ { 6, BARCODE_RAW_TEXT, "1234", -1, "01234" },
/* 18*/ { 7, -1, "1234", -1, "001234" }, /* 18*/ { 6, -1, "123", -1, "00123" },
/* 19*/ { 7, -1, "12345", -1, "012345" }, /* 19*/ { 6, BARCODE_RAW_TEXT, "123", -1, "00123" },
/* 20*/ { 7, -1, "123456", -1, "123456" }, /* 20*/ { 6, -1, "12", -1, "00012" },
/* 21*/ { 7, -1, "1", -1, "000001" }, /* 21*/ { 6, BARCODE_RAW_TEXT, "12", -1, "00012" },
/* 22*/ { 8, -1, "12345", -1, "0012345" }, /* 22*/ { 6, -1, "1", -1, "00001" },
/* 23*/ { 8, BARCODE_RAW_TEXT, "12345", -1, "0012345" }, /* 23*/ { 6, BARCODE_RAW_TEXT, "1", -1, "00001" },
/* 24*/ { 8, -1, "123456", -1, "0123456" }, /* 24*/ { 7, -1, "1234", -1, "001234" },
/* 25*/ { 8, BARCODE_RAW_TEXT, "123456", -1, "0123456" }, /* 25*/ { 7, BARCODE_RAW_TEXT, "1234", -1, "001234" },
/* 26*/ { 8, -1, "1234567", -1, "1234567" }, /* 26*/ { 7, -1, "12345", -1, "012345" },
/* 27*/ { 8, BARCODE_RAW_TEXT, "1234567", -1, "1234567" }, /* 27*/ { 7, BARCODE_RAW_TEXT, "12345", -1, "012345" },
/* 28*/ { 8, -1, "12", -1, "0000012" }, /* 28*/ { 7, -1, "123456", -1, "123456" },
/* 29*/ { 8, BARCODE_RAW_TEXT, "12", -1, "0000012" }, /* 29*/ { 7, BARCODE_RAW_TEXT, "123456", -1, "123456" },
/* 30*/ { 8, -1, "1", -1, "0000001" }, /* 30*/ { 7, -1, "1", -1, "000001" },
/* 31*/ { 8, BARCODE_RAW_TEXT, "1", -1, "0000001" }, /* 31*/ { 7, BARCODE_RAW_TEXT, "1", -1, "000001" },
/* 32*/ { 8, -1, "12345", -1, "0012345" },
/* 33*/ { 8, BARCODE_RAW_TEXT, "12345", -1, "0012345" },
/* 34*/ { 8, -1, "123456", -1, "0123456" },
/* 35*/ { 8, BARCODE_RAW_TEXT, "123456", -1, "0123456" },
/* 36*/ { 8, -1, "1234567", -1, "1234567" },
/* 37*/ { 8, BARCODE_RAW_TEXT, "1234567", -1, "1234567" },
/* 38*/ { 8, -1, "12", -1, "0000012" },
/* 39*/ { 8, BARCODE_RAW_TEXT, "12", -1, "0000012" },
/* 40*/ { 8, -1, "1", -1, "0000001" },
/* 41*/ { 8, BARCODE_RAW_TEXT, "1", -1, "0000001" },
}; };
const int data_size = ARRAY_SIZE(data); const int data_size = ARRAY_SIZE(data);
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
int expected_length; int expected_length;
testStartSymbol("test_hrt", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -103,6 +113,18 @@ static void test_hrt(const testCtx *const p_ctx) {
i, symbol->text_length, expected_length); i, symbol->text_length, expected_length);
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
i, symbol->text, data[i].expected); i, symbol->text, data[i].expected);
if (symbol->output_options & BARCODE_RAW_TEXT) {
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
assert_nonnull(symbol->raw_segs[0].source, "i:%d raw_segs[0].source NULL\n", i);
assert_equal(symbol->raw_segs[0].length, expected_length,
"i:%d raw_segs[0].length %d != expected_length %d\n",
i, symbol->raw_segs[0].length, expected_length);
assert_zero(memcmp(symbol->raw_segs[0].source, data[i].expected, expected_length),
"i:%d memcmp(%s, %s, %d) != 0\n",
i, symbol->raw_segs[0].source, data[i].expected, expected_length);
} else {
assert_null(symbol->raw_segs, "i:%d raw_segs not NULL\n", i);
}
ZBarcode_Delete(symbol); ZBarcode_Delete(symbol);
} }
@ -183,7 +205,7 @@ static void test_input(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_input", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -447,7 +469,7 @@ static void test_encode(const testCtx *const p_ctx) {
char bwipp_buf[8192]; char bwipp_buf[8192];
char bwipp_msg[1024]; char bwipp_msg[1024];
testStartSymbol("test_encode", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {

View file

@ -58,7 +58,7 @@ static void test_large(const testCtx *const p_ctx) {
char data_buf[128]; char data_buf[128];
testStartSymbol("test_large", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -96,28 +96,29 @@ static void test_hrt(const testCtx *const p_ctx) {
const char *data; const char *data;
const char *expected; const char *expected;
const char *expected_raw;
}; };
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = { static const struct item data[] = {
/* 0*/ { BARCODE_CODABAR, -1, -1, "A1234B", "A1234B" }, /* 0*/ { BARCODE_CODABAR, -1, -1, "A1234B", "A1234B", "" },
/* 1*/ { BARCODE_CODABAR, -1, BARCODE_RAW_TEXT, "A1234B", "A1234B" }, /* 1*/ { BARCODE_CODABAR, -1, BARCODE_RAW_TEXT, "A1234B", "A1234B", "A1234B" },
/* 2*/ { BARCODE_CODABAR, -1, -1, "a1234c", "A1234C" }, /* Converts to upper */ /* 2*/ { BARCODE_CODABAR, -1, -1, "a1234c", "A1234C", "" }, /* Converts to upper */
/* 3*/ { BARCODE_CODABAR, -1, BARCODE_RAW_TEXT, "a1234c", "A1234C" }, /* 3*/ { BARCODE_CODABAR, -1, BARCODE_RAW_TEXT, "a1234c", "A1234C", "A1234C" },
/* 4*/ { BARCODE_CODABAR, 1, -1, "A1234B", "A1234B" }, /* Check not included */ /* 4*/ { BARCODE_CODABAR, 1, -1, "A1234B", "A1234B", "" }, /* Check not included */
/* 5*/ { BARCODE_CODABAR, 1, BARCODE_RAW_TEXT, "A1234B", "A12345B" }, /* 5*/ { BARCODE_CODABAR, 1, BARCODE_RAW_TEXT, "A1234B", "A1234B", "A12345B" },
/* 6*/ { BARCODE_CODABAR, 2, -1, "A1234B", "A12345B" }, /* Check included */ /* 6*/ { BARCODE_CODABAR, 2, -1, "A1234B", "A12345B", "" }, /* Check included */
/* 7*/ { BARCODE_CODABAR, 2, BARCODE_RAW_TEXT, "A1234B", "A12345B" }, /* 7*/ { BARCODE_CODABAR, 2, BARCODE_RAW_TEXT, "A1234B", "A12345B", "A12345B" },
/* 8*/ { BARCODE_CODABAR, 1, -1, "A123456A", "A123456A" }, /* Check not included */ /* 8*/ { BARCODE_CODABAR, 1, -1, "A123456A", "A123456A", "" }, /* Check not included */
/* 9*/ { BARCODE_CODABAR, 1, BARCODE_RAW_TEXT, "A123456A", "A123456$A" }, /* 9*/ { BARCODE_CODABAR, 1, BARCODE_RAW_TEXT, "A123456A", "A123456A", "A123456$A" },
/* 10*/ { BARCODE_CODABAR, 2, -1, "A123456A", "A123456$A" }, /* Check included */ /* 10*/ { BARCODE_CODABAR, 2, -1, "A123456A", "A123456$A", "" }, /* Check included */
/* 11*/ { BARCODE_CODABAR, 2, BARCODE_RAW_TEXT, "A123456A", "A123456$A" }, /* 11*/ { BARCODE_CODABAR, 2, BARCODE_RAW_TEXT, "A123456A", "A123456$A", "A123456$A" },
}; };
const int data_size = ARRAY_SIZE(data); const int data_size = ARRAY_SIZE(data);
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
int expected_length; int expected_length, expected_raw_length;
testStartSymbol("test_hrt", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -130,6 +131,7 @@ static void test_hrt(const testCtx *const p_ctx) {
-1 /*option_1*/, data[i].option_2, -1 /*option_3*/, data[i].output_options, -1 /*option_1*/, data[i].option_2, -1 /*option_3*/, data[i].output_options,
data[i].data, -1, debug); data[i].data, -1, debug);
expected_length = (int) strlen(data[i].expected); expected_length = (int) strlen(data[i].expected);
expected_raw_length = (int) strlen(data[i].expected_raw);
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt); assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
@ -138,6 +140,18 @@ static void test_hrt(const testCtx *const p_ctx) {
i, symbol->text_length, expected_length); i, symbol->text_length, expected_length);
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
i, symbol->text, data[i].expected); i, symbol->text, data[i].expected);
if (symbol->output_options & BARCODE_RAW_TEXT) {
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
assert_nonnull(symbol->raw_segs[0].source, "i:%d raw_segs[0].source NULL\n", i);
assert_equal(symbol->raw_segs[0].length, expected_raw_length,
"i:%d raw_segs[0].length %d != expected_raw_length %d\n",
i, symbol->raw_segs[0].length, expected_raw_length);
assert_zero(memcmp(symbol->raw_segs[0].source, data[i].expected_raw, expected_raw_length),
"i:%d memcmp(%s, %s, %d) != 0\n",
i, symbol->raw_segs[0].source, data[i].expected_raw, expected_raw_length);
} else {
assert_null(symbol->raw_segs, "i:%d raw_segs not NULL\n", i);
}
ZBarcode_Delete(symbol); ZBarcode_Delete(symbol);
} }
@ -180,7 +194,7 @@ static void test_input(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
testStartSymbol("test_input", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -263,7 +277,7 @@ static void test_encode(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */
testStartSymbol("test_encode", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -304,13 +318,18 @@ static void test_encode(const testCtx *const p_ctx) {
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) { if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) {
int cmp_len, ret_len; int cmp_len, ret_len;
char modules_dump[8192 + 1]; char modules_dump[8192 + 1];
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1,
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); "i:%d testUtilModulesDump == -1\n", i);
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, 1 /*zxingcpp_cmp*/, cmp_buf,
sizeof(cmp_buf), &cmp_len);
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n",
i, testUtilBarcodeName(symbol->symbology), ret);
ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len); ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length,
NULL /*primary*/, escaped, &ret_len);
assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n",
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, escaped); i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len,
escaped);
} }
} }
} }

View file

@ -92,7 +92,7 @@ static void test_large(const testCtx *const p_ctx) {
char data_buf[ZINT_MAX_DATA_LEN + 2]; char data_buf[ZINT_MAX_DATA_LEN + 2];
testStartSymbol("test_large", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -169,7 +169,7 @@ static void test_options(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_options", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -227,7 +227,7 @@ static void test_reader_init(const testCtx *const p_ctx) {
char escaped[1024]; char escaped[1024];
testStartSymbol("test_reader_init", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -267,26 +267,42 @@ static void test_hrt(const testCtx *const p_ctx) {
struct item { struct item {
int symbology; int symbology;
int input_mode;
int option_1; int option_1;
int option_2; int option_2;
int output_options; int output_options;
const char *data; const char *data;
int length;
const char *expected; const char *expected;
const char *expected_raw;
int expected_raw_length;
}; };
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = { static const struct item data[] = {
/* 0*/ { BARCODE_CODABLOCKF, -1, -1, -1, "12345623456", "" }, /* None */ /* 0*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, -1, "12345623456", -1, "", "", -1 }, /* None */
/* 1*/ { BARCODE_CODABLOCKF, -1, -1, BARCODE_RAW_TEXT, "12345623456", "" }, /* No difference */ /* 1*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, BARCODE_RAW_TEXT, "12345623456", -1, "", "12345623456", -1 },
/* 2*/ { BARCODE_CODABLOCKF, 1, -1, -1, "12345623456", "" }, /* None (CODE128) */ /* 2*/ { BARCODE_CODABLOCKF, UNICODE_MODE, 1, -1, -1, "12345623456", -1, "", "", -1 }, /* None (CODE128) */
/* 3*/ { BARCODE_CODABLOCKF, 1, -1, BARCODE_RAW_TEXT, "12345623456", "" }, /* No difference */ /* 3*/ { BARCODE_CODABLOCKF, UNICODE_MODE, 1, -1, BARCODE_RAW_TEXT, "12345623456", -1, "", "12345623456", -1 },
/* 4*/ { BARCODE_CODABLOCKF, UNICODE_MODE, 1, -1, -1, "12345623456\012é", -1, "", "", -1 }, /* None (CODE128) */
/* 5*/ { BARCODE_CODABLOCKF, UNICODE_MODE, 1, -1, BARCODE_RAW_TEXT, "12345623456\012é", -1, "", "12345623456\012\351", -1 },
/* 6*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, -1, "12345623456\012é", -1, "", "", -1 }, /* None */
/* 7*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, BARCODE_RAW_TEXT, "12345623456\012é", -1, "", "12345623456\012\351", -1 },
/* 8*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, -1, "12345623456\000\012é", -1, "", "", -1 }, /* None */
/* 9*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, BARCODE_RAW_TEXT, "12345623456\000\012é", 15, "", "12345623456\000\012\351", 14 },
/* 10*/ { BARCODE_CODABLOCKF, DATA_MODE, -1, -1, -1, "12345623456\000\012é", 15, "", "", -1 }, /* None */
/* 11*/ { BARCODE_CODABLOCKF, DATA_MODE, -1, -1, BARCODE_RAW_TEXT, "12345623456\000\012é", 15, "", "12345623456\000\012é", 15 },
/* 12*/ { BARCODE_CODABLOCKF, DATA_MODE, -1, -1, -1, "12345623456\000\012\351", 14, "", "", -1 }, /* None */
/* 13*/ { BARCODE_CODABLOCKF, DATA_MODE, -1, -1, BARCODE_RAW_TEXT, "12345623456\000\012\351", 14, "", "12345623456\000\012\351", 14 },
/* 14*/ { BARCODE_HIBC_BLOCKF, UNICODE_MODE, -1, -1, -1, "H123ABC01234567890", -1, "", "", -1 }, /* None */
/* 15*/ { BARCODE_HIBC_BLOCKF, UNICODE_MODE, -1, -1, BARCODE_RAW_TEXT, "H123ABC01234567890", -1, "", "+H123ABC01234567890D", -1 },
}; };
const int data_size = ARRAY_SIZE(data); const int data_size = ARRAY_SIZE(data);
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
int expected_length; int expected_length, expected_raw_length;
testStartSymbol("test_hrt", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -295,10 +311,11 @@ static void test_hrt(const testCtx *const p_ctx) {
symbol = ZBarcode_Create(); symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n"); assert_nonnull(symbol, "Symbol not created\n");
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/,
data[i].option_1, data[i].option_2, -1 /*option_3*/, data[i].output_options, data[i].option_1, data[i].option_2, -1 /*option_3*/, data[i].output_options,
data[i].data, -1, debug); data[i].data, data[i].length, debug);
expected_length = (int) strlen(data[i].expected); expected_length = (int) strlen(data[i].expected);
expected_raw_length = data[i].expected_raw_length == -1 ? (int) strlen(data[i].expected_raw) : data[i].expected_raw_length;
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt); assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
@ -307,6 +324,19 @@ static void test_hrt(const testCtx *const p_ctx) {
i, symbol->text_length, expected_length); i, symbol->text_length, expected_length);
assert_zero(memcmp(symbol->text, data[i].expected, expected_length), "i:%d memcmp(%s, %s, %d) != 0\n", assert_zero(memcmp(symbol->text, data[i].expected, expected_length), "i:%d memcmp(%s, %s, %d) != 0\n",
i, symbol->text, data[i].expected, expected_length); i, symbol->text, data[i].expected, expected_length);
if (symbol->output_options & BARCODE_RAW_TEXT) {
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
assert_nonnull(symbol->raw_segs[0].source, "i:%d raw_segs[0].source NULL\n", i);
assert_equal(symbol->raw_segs[0].length, expected_raw_length,
"i:%d raw_segs[0].length %d != expected_raw_length %d\n",
i, symbol->raw_segs[0].length, expected_raw_length);
assert_zero(memcmp(symbol->raw_segs[0].source, data[i].expected_raw, expected_raw_length),
"i:%d memcmp(%.*s, %.*s, %d) != 0\n",
i, symbol->raw_segs[0].length, symbol->raw_segs[0].source, expected_raw_length,
data[i].expected_raw, expected_raw_length);
} else {
assert_null(symbol->raw_segs, "i:%d raw_segs not NULL\n", i);
}
ZBarcode_Delete(symbol); ZBarcode_Delete(symbol);
} }
@ -328,6 +358,7 @@ static void test_input(const testCtx *const p_ctx) {
int expected_rows; int expected_rows;
int expected_width; int expected_width;
int bwipp_cmp; int bwipp_cmp;
int zxingcpp_cmp;
const char *expected; const char *expected;
const char *comment; const char *comment;
}; };
@ -347,59 +378,59 @@ static void test_input(const testCtx *const p_ctx) {
ÿ U+00FF (\377, 255), UTF-8 C3BF, CodeB-only extended ASCII ÿ U+00FF (\377, 255), UTF-8 C3BF, CodeB-only extended ASCII
*/ */
static const struct item data[] = { static const struct item data[] = {
/* 0*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "A", -1, 0, 2, 101, 1, "67 64 40 21 63 64 63 42 6A 67 64 0B 63 64 2B 40 4F 6A", "Fillings 5" }, /* 0*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "A", -1, 0, 2, 101, 1, 1, "67 64 40 21 63 64 63 42 6A 67 64 0B 63 64 2B 40 4F 6A", "Fillings 5" },
/* 1*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "AAA", -1, 0, 2, 101, 1, "67 64 40 21 21 21 63 55 6A 67 64 0B 63 64 0E 57 48 6A", "Fillings 3" }, /* 1*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "AAA", -1, 0, 2, 101, 1, 1, "67 64 40 21 21 21 63 55 6A 67 64 0B 63 64 0E 57 48 6A", "Fillings 3" },
/* 2*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "AAAA", -1, 0, 2, 101, 1, "67 64 40 21 21 21 21 65 6A 67 64 0B 63 64 1A 0E 03 6A", "Fillings 2" }, /* 2*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "AAAA", -1, 0, 2, 101, 1, 1, "67 64 40 21 21 21 21 65 6A 67 64 0B 63 64 1A 0E 03 6A", "Fillings 2" },
/* 3*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "AAAAA", -1, 0, 2, 101, 1, "67 64 40 21 21 21 21 65 6A 67 64 0B 21 63 1D 30 14 6A", "Fillings 1" }, /* 3*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "AAAAA", -1, 0, 2, 101, 1, 1, "67 64 40 21 21 21 21 65 6A 67 64 0B 21 63 1D 30 14 6A", "Fillings 1" },
/* 4*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "AAAAAA", -1, 0, 2, 101, 1, "67 64 40 21 21 21 21 65 6A 67 64 0B 21 21 35 5D 2B 6A", "Fillings 0" }, /* 4*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "AAAAAA", -1, 0, 2, 101, 1, 1, "67 64 40 21 21 21 21 65 6A 67 64 0B 21 21 35 5D 2B 6A", "Fillings 0" },
/* 5*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "1234", -1, 0, 2, 101, 1, "67 63 00 0C 22 64 63 1A 6A 67 64 0B 63 64 3A 1C 29 6A", "Fillings 4" }, /* 5*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "1234", -1, 0, 2, 101, 1, 1, "67 63 00 0C 22 64 63 1A 6A 67 64 0B 63 64 3A 1C 29 6A", "Fillings 4" },
/* 6*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "12345", -1, 0, 2, 101, 1, "67 63 00 0C 22 64 15 49 6A 67 64 0B 63 64 41 44 07 6A", "Fillings 2 (not counting CodeB at end of 1st line)" }, /* 6*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "12345", -1, 0, 2, 101, 1, 1, "67 63 00 0C 22 64 15 49 6A 67 64 0B 63 64 41 44 07 6A", "Fillings 2 (not counting CodeB at end of 1st line)" },
/* 7*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "123456", -1, 0, 2, 101, 1, "67 63 00 0C 22 38 64 12 6A 67 64 0B 63 64 2D 50 52 6A", "Fillings 3" }, /* 7*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "123456", -1, 0, 2, 101, 1, 1, "67 63 00 0C 22 38 64 12 6A 67 64 0B 63 64 2D 50 52 6A", "Fillings 3" },
/* 8*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "1234567", -1, 0, 2, 101, 1, "67 63 00 0C 22 38 64 12 6A 67 64 0B 17 63 16 02 5B 6A", "Fillings 1 (not counting CodeB at end of 1st line)" }, /* 8*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "1234567", -1, 0, 2, 101, 1, 1, "67 63 00 0C 22 38 64 12 6A 67 64 0B 17 63 16 02 5B 6A", "Fillings 1 (not counting CodeB at end of 1st line)" },
/* 9*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "12345678", -1, 0, 2, 101, 1, "67 63 00 0C 22 38 4E 5C 6A 67 64 0B 63 64 08 1C 64 6A", "Fillings 2" }, /* 9*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "12345678", -1, 0, 2, 101, 1, 1, "67 63 00 0C 22 38 4E 5C 6A 67 64 0B 63 64 08 1C 64 6A", "Fillings 2" },
/* 10*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "123456789", -1, 0, 2, 101, 1, "67 63 00 0C 22 38 4E 5C 6A 67 64 0B 19 63 25 4C 65 6A", "Fillings 1" }, /* 10*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "123456789", -1, 0, 2, 101, 1, 1, "67 63 00 0C 22 38 4E 5C 6A 67 64 0B 19 63 25 4C 65 6A", "Fillings 1" },
/* 11*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "1234567890", -1, 0, 2, 101, 0, "67 63 00 0C 22 38 4E 5C 6A 67 64 0B 19 10 41 38 62 6A", "Fillings 0; BWIPP different encodation (CodeB 9 0 instead of CodeC 90" }, /* 11*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "1234567890", -1, 0, 2, 101, 0, 1, "67 63 00 0C 22 38 4E 5C 6A 67 64 0B 19 10 41 38 62 6A", "Fillings 0; BWIPP different encodation (CodeB 9 0 instead of CodeC 90" },
/* 12*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "A123ñ", -1, 0, 2, 101, 1, "67 64 40 21 11 12 13 54 6A 67 64 0B 64 51 42 28 50 6A", "K1/K2 example in Annex F" }, /* 12*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "A123ñ", -1, 0, 2, 101, 1, 1, "67 64 40 21 11 12 13 54 6A 67 64 0B 64 51 42 28 50 6A", "K1/K2 example in Annex F" },
/* 13*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "", -1, 0, 2, 101, 1, "67 64 40 41 64 3F 63 54 6A 67 64 0B 63 64 5B 1D 06 6A", "CodeB a FNC4 ß fits 1st line" }, /* 13*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "", -1, 0, 2, 101, 1, 1, "67 64 40 41 64 3F 63 54 6A 67 64 0B 63 64 5B 1D 06 6A", "CodeB a FNC4 ß fits 1st line" },
/* 14*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "\037ß", -1, 0, 2, 101, 1, "67 62 40 5F 65 3F 63 49 6A 67 64 0B 63 64 0F 1D 26 6A", "CodeA US FNC4 ß fits 1st line" }, /* 14*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "\037ß", -1, 0, 2, 101, 1, 1, "67 62 40 5F 65 3F 63 49 6A 67 64 0B 63 64 0F 1D 26 6A", "CodeA US FNC4 ß fits 1st line" },
/* 15*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "aaß", -1, 0, 2, 101, 1, "67 64 40 41 41 64 3F 10 6A 67 64 0B 63 64 4E 5B 04 6A", "CodeB a a FNC4 ß fits 1st line" }, /* 15*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "aaß", -1, 0, 2, 101, 1, 1, "67 64 40 41 41 64 3F 10 6A 67 64 0B 63 64 4E 5B 04 6A", "CodeB a a FNC4 ß fits 1st line" },
/* 16*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "\037\037ß", -1, 0, 2, 101, 1, "67 62 40 5F 5F 65 3F 17 6A 67 64 0B 63 64 34 0F 24 6A", "CodeA US US FNC4 ß fits 1st line" }, /* 16*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "\037\037ß", -1, 0, 2, 101, 1, 1, "67 62 40 5F 5F 65 3F 17 6A 67 64 0B 63 64 34 0F 24 6A", "CodeA US US FNC4 ß fits 1st line" },
/* 17*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "aaaß", -1, 0, 2, 101, 1, "67 64 40 41 41 41 63 39 6A 67 64 0B 64 3F 4C 4E 50 6A", "CodeB a (3) / CodeB FNC4 ß fully on next line" }, /* 17*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "aaaß", -1, 0, 2, 101, 1, 1, "67 64 40 41 41 41 63 39 6A 67 64 0B 64 3F 4C 4E 50 6A", "CodeB a (3) / CodeB FNC4 ß fully on next line" },
/* 18*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "\037\037\037ß", -1, 0, 2, 101, 1, "67 62 40 5F 5F 5F 63 03 6A 67 64 0B 64 3F 0E 34 1A 6A", "CodeA US (3) / CodeB FNC4 ß fully on next line" }, /* 18*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "\037\037\037ß", -1, 0, 2, 101, 1, 1, "67 62 40 5F 5F 5F 63 03 6A 67 64 0B 64 3F 0E 34 1A 6A", "CodeA US (3) / CodeB FNC4 ß fully on next line" },
/* 19*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "", -1, 0, 2, 101, 1, "67 64 40 41 64 40 63 59 6A 67 64 0B 63 64 5D 1E 16 6A", "CodeB a FNC4 à fits 1st line" }, /* 19*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "", -1, 0, 2, 101, 1, 1, "67 64 40 41 64 40 63 59 6A 67 64 0B 63 64 5D 1E 16 6A", "CodeB a FNC4 à fits 1st line" },
/* 20*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "\037à", -1, 0, 2, 101, 0, "67 62 40 5F 65 62 40 26 6A 67 64 0B 63 64 1B 1E 01 6A", "CodeA US FNC4 Shift à fits 1st line; BWIPP different encodation (CodeB instead of Shift)" }, /* 20*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "\037à", -1, 0, 2, 101, 0, 1, "67 62 40 5F 65 62 40 26 6A 67 64 0B 63 64 1B 1E 01 6A", "CodeA US FNC4 Shift à fits 1st line; BWIPP different encodation (CodeB instead of Shift)" },
/* 21*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "\037àa", -1, 0, 2, 101, 0, "67 62 40 5F 64 64 40 2C 6A 67 64 0B 41 63 52 4A 16 6A", "CodeA US LatchB FNC4 à fits 1st line / Code B a; BWIPP diffent encodation (as above)" }, /* 21*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "\037àa", -1, 0, 2, 101, 0, 1, "67 62 40 5F 64 64 40 2C 6A 67 64 0B 41 63 52 4A 16 6A", "CodeA US LatchB FNC4 à fits 1st line / Code B a; BWIPP diffent encodation (as above)" },
/* 22*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "aaà", -1, 0, 2, 101, 1, "67 64 40 41 41 64 40 16 6A 67 64 0B 63 64 51 5D 1F 6A", "CodeB a a FNC4 à fits 1st line" }, /* 22*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "aaà", -1, 0, 2, 101, 1, 1, "67 64 40 41 41 64 40 16 6A 67 64 0B 63 64 51 5D 1F 6A", "CodeB a a FNC4 à fits 1st line" },
/* 23*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "\037\037à", -1, 0, 2, 101, 1, "67 62 40 5F 5F 63 64 1D 6A 67 64 0B 64 40 37 1B 55 6A", "CodeA US US / Code B FNC4 à fully on next line" }, /* 23*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "\037\037à", -1, 0, 2, 101, 1, 1, "67 62 40 5F 5F 63 64 1D 6A 67 64 0B 64 40 37 1B 55 6A", "CodeA US US / Code B FNC4 à fully on next line" },
/* 24*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "aaaà", -1, 0, 2, 101, 1, "67 64 40 41 41 41 63 39 6A 67 64 0B 64 40 50 51 13 6A", "CodeB a (3) / Code B FNC4 à fully on next line" }, /* 24*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "aaaà", -1, 0, 2, 101, 1, 1, "67 64 40 41 41 41 63 39 6A 67 64 0B 64 40 50 51 13 6A", "CodeB a (3) / Code B FNC4 à fully on next line" },
/* 25*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "\037\037\037à", -1, 0, 2, 101, 1, "67 62 40 5F 5F 5F 63 03 6A 67 64 0B 64 40 1C 37 0F 6A", "CodeA US (3) / CodeB FNC4 à fully on next line" }, /* 25*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "\037\037\037à", -1, 0, 2, 101, 1, 1, "67 62 40 5F 5F 5F 63 03 6A 67 64 0B 64 40 1C 37 0F 6A", "CodeA US (3) / CodeB FNC4 à fully on next line" },
/* 26*/ { BARCODE_CODABLOCKF, DATA_MODE, -1, -1, "\037\200", -1, 0, 2, 101, 1, "67 62 40 5F 65 40 63 4E 6A 67 64 0B 63 64 5D 0A 05 6A", "CodeA US FNC4 PAD fits 1st line" }, /* 26*/ { BARCODE_CODABLOCKF, DATA_MODE, -1, -1, "\037\200", -1, 0, 2, 101, 1, 899, "67 62 40 5F 65 40 63 4E 6A 67 64 0B 63 64 5D 0A 05 6A", "CodeA US FNC4 PAD fits 1st line" },
/* 27*/ { BARCODE_CODABLOCKF, DATA_MODE, -1, -1, "\141\200", -1, 0, 2, 101, 0, "67 64 40 41 64 62 40 31 6A 67 64 0B 63 64 49 0A 08 6A", "CodeB a FNC4 Shift PAD fits 1st line; BWIPP different encodation (CodeA instead of Shift)" }, /* 27*/ { BARCODE_CODABLOCKF, DATA_MODE, -1, -1, "\141\200", -1, 0, 2, 101, 0, 899, "67 64 40 41 64 62 40 31 6A 67 64 0B 63 64 49 0A 08 6A", "CodeB a FNC4 Shift PAD fits 1st line; BWIPP different encodation (CodeA instead of Shift)" },
/* 28*/ { BARCODE_CODABLOCKF, DATA_MODE, -1, -1, "\141\200\037", -1, 0, 2, 101, 0, "67 64 40 41 65 65 40 44 6A 67 62 0B 5F 63 10 12 3E 6A", "CodeB a LatchA FNC4 PAD fits 1st line / CodeA US; BWIPP diffent encodation (as above)" }, /* 28*/ { BARCODE_CODABLOCKF, DATA_MODE, -1, -1, "\141\200\037", -1, 0, 2, 101, 0, 899, "67 64 40 41 65 65 40 44 6A 67 62 0B 5F 63 10 12 3E 6A", "CodeB a LatchA FNC4 PAD fits 1st line / CodeA US; BWIPP diffent encodation (as above)" },
/* 29*/ { BARCODE_CODABLOCKF, DATA_MODE, -1, -1, "\037\037\200", -1, 0, 2, 101, 1, "67 62 40 5F 5F 65 40 1D 6A 67 64 0B 63 64 0F 5D 0A 6A", "CodeA US US FNC4 PAD fits 1st line" }, /* 29*/ { BARCODE_CODABLOCKF, DATA_MODE, -1, -1, "\037\037\200", -1, 0, 2, 101, 1, 899, "67 62 40 5F 5F 65 40 1D 6A 67 64 0B 63 64 0F 5D 0A 6A", "CodeA US US FNC4 PAD fits 1st line" },
/* 30*/ { BARCODE_CODABLOCKF, DATA_MODE, -1, -1, "\141\141\200", -1, 0, 2, 101, 1, "67 64 40 41 41 63 64 1B 6A 67 62 0B 65 40 33 49 21 6A", "CodeB a a / CodeA FNC4 PAD fully on next line" }, /* 30*/ { BARCODE_CODABLOCKF, DATA_MODE, -1, -1, "\141\141\200", -1, 0, 2, 101, 1, 899, "67 64 40 41 41 63 64 1B 6A 67 62 0B 65 40 33 49 21 6A", "CodeB a a / CodeA FNC4 PAD fully on next line" },
/* 31*/ { BARCODE_CODABLOCKF, DATA_MODE, -1, -1, "\037\037\037\200", -1, 0, 2, 101, 1, "67 62 40 5F 5F 5F 63 03 6A 67 62 0B 65 40 4A 0F 06 6A", "CodeA US (3) / CodeA FNC4 PAD fully on next line" }, /* 31*/ { BARCODE_CODABLOCKF, DATA_MODE, -1, -1, "\037\037\037\200", -1, 0, 2, 101, 1, 899, "67 62 40 5F 5F 5F 63 03 6A 67 62 0B 65 40 4A 0F 06 6A", "CodeA US (3) / CodeA FNC4 PAD fully on next line" },
/* 32*/ { BARCODE_CODABLOCKF, DATA_MODE, -1, -1, "\141\141\141\200", -1, 0, 2, 101, 1, "67 64 40 41 41 41 63 39 6A 67 62 0B 65 40 28 33 34 6A", "CodeB a (3) / CodeA FNC4 PAD fully on next line" }, /* 32*/ { BARCODE_CODABLOCKF, DATA_MODE, -1, -1, "\141\141\141\200", -1, 0, 2, 101, 1, 899, "67 64 40 41 41 41 63 39 6A 67 62 0B 65 40 28 33 34 6A", "CodeB a (3) / CodeA FNC4 PAD fully on next line" },
/* 33*/ { BARCODE_CODABLOCKF, DATA_MODE, -1, 10, "\200\240\237\340\337\341\377", -1, 0, 4, 112, 0, "(40) 67 62 42 65 40 65 00 63 1E 6A 67 62 0B 65 5F 64 64 40 55 6A 67 64 0C 64 3F 64 41 63", "BWIPP different encodation (CodeB before FNC4 instead of after)" }, /* 33*/ { BARCODE_CODABLOCKF, DATA_MODE, -1, 10, "\200\240\237\340\337\341\377", -1, 0, 4, 112, 0, 899, "(40) 67 62 42 65 40 65 00 63 1E 6A 67 62 0B 65 5F 64 64 40 55 6A 67 64 0C 64 3F 64 41 63", "BWIPP different encodation (CodeB before FNC4 instead of after)" },
/* 34*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "\000a\037\177}12", 7, 0, 3, 101, 1, "67 62 41 40 62 41 5F 3B 6A 67 64 0B 5F 5D 11 12 2D 6A 67 64 0C 63 64 40 05 26 6A", "" }, /* 34*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "\000a\037\177}12", 7, 0, 3, 101, 1, 1, "67 62 41 40 62 41 5F 3B 6A 67 64 0B 5F 5D 11 12 2D 6A 67 64 0C 63 64 40 05 26 6A", "" },
/* 35*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "abcdéf", -1, 0, 3, 101, 1, "67 64 41 41 42 43 44 5D 6A 67 64 0B 64 49 46 63 0A 6A 67 64 0C 63 64 4F 26 02 6A", "" }, /* 35*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "abcdéf", -1, 0, 3, 101, 1, 1, "67 64 41 41 42 43 44 5D 6A 67 64 0B 64 49 46 63 0A 6A 67 64 0C 63 64 4F 26 02 6A", "" },
/* 36*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "a12é\000", 6, 0, 3, 101, 0, "67 64 41 41 11 12 63 2C 6A 67 64 0B 64 49 62 40 2B 6A 67 64 0C 63 64 33 34 31 6A", "BWIPP different encodation (CodeA instead of Shift)" }, /* 36*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "a12é\000", 6, 0, 3, 101, 0, 1, "67 64 41 41 11 12 63 2C 6A 67 64 0B 64 49 62 40 2B 6A 67 64 0C 63 64 33 34 31 6A", "BWIPP different encodation (CodeA instead of Shift)" },
/* 37*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, 11, "1234\001", -1, 0, 2, 123, 1, "67 63 00 0C 22 65 41 63 64 54 6A 67 64 0B 63 64 63 64 3F 20 24 6A", "" }, /* 37*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, 11, "1234\001", -1, 0, 2, 123, 1, 1, "67 63 00 0C 22 65 41 63 64 54 6A 67 64 0B 63 64 63 64 3F 20 24 6A", "" },
/* 38*/ { BARCODE_CODABLOCKF, UNICODE_MODE, 3, -1, "ÁÁÁÁÁÁ99999999999999ÁÁÁÁÁÁÁ99999999999999Á", -1, 0, 3, 244, 1, "(66) 67 64 41 64 21 64 21 64 21 64 21 64 21 64 21 63 63 63 63 63 56 6A 67 63 2B 63 63 63", "Latching to extended ASCII not used by `codablockf()` (see test_code128 Okapi)" }, /* 38*/ { BARCODE_CODABLOCKF, UNICODE_MODE, 3, -1, "ÁÁÁÁÁÁ99999999999999ÁÁÁÁÁÁÁ99999999999999Á", -1, 0, 3, 244, 1, 1, "(66) 67 64 41 64 21 64 21 64 21 64 21 64 21 64 21 63 63 63 63 63 56 6A 67 63 2B 63 63 63", "Latching to extended ASCII not used by `codablockf()` (see test_code128 Okapi)" },
/* 39*/ { BARCODE_CODABLOCKF, DATA_MODE, 2, -1, "@g(\302\302\302\302\3025555\302\302\302\302\302\302\302\302", -1, 0, 2, 255, 1, "(46) 67 64 40 20 47 08 64 22 64 22 64 22 64 22 64 22 63 37 37 64 63 4B 6A 67 64 0B 64 22", "Must allow for FNC4 when testing if enough room when switching from CodeC" }, /* 39*/ { BARCODE_CODABLOCKF, DATA_MODE, 2, -1, "@g(\302\302\302\302\3025555\302\302\302\302\302\302\302\302", -1, 0, 2, 255, 1, 899, "(46) 67 64 40 20 47 08 64 22 64 22 64 22 64 22 64 22 63 37 37 64 63 4B 6A 67 64 0B 64 22", "Must allow for FNC4 when testing if enough room when switching from CodeC" },
/* 40*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "ÿ\012àa\0121\012àAà", -1, 0, 5, 101, 0, "(45) 67 64 43 64 5F 65 4A 09 6A 67 64 0B 64 40 41 63 34 6A 67 62 0C 4A 11 4A 63 25 6A 67", "BWIPP different encoding (Shift instead of CodeA)" }, /* 40*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "ÿ\012àa\0121\012àAà", -1, 0, 5, 101, 0, 1, "(45) 67 64 43 64 5F 65 4A 09 6A 67 64 0B 64 40 41 63 34 6A 67 62 0C 4A 11 4A 63 25 6A 67", "BWIPP different encoding (Shift instead of CodeA)" },
/* 41*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "ÿy1234\012àa\0121\0127890àAàDà\012à", -1, 0, 7, 112, 0, "(70) 67 64 45 64 5F 59 11 12 2E 6A 67 62 0B 13 14 4A 63 64 43 6A 67 64 0C 64 40 41 65 4A", "BWIPP different encoding (Shift instead of CodeA)" }, /* 41*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "ÿy1234\012àa\0121\0127890àAàDà\012à", -1, 0, 7, 112, 0, 1, "(70) 67 64 45 64 5F 59 11 12 2E 6A 67 62 0B 13 14 4A 63 64 43 6A 67 64 0C 64 40 41 65 4A", "BWIPP different encoding (Shift instead of CodeA)" },
/* 42*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "ÿ12345678\012à12345678abcdef\0121\01223456\012\0127890àAàBCDEFà\012\012à", -1, 0, 8, 134, 0, "(96) 67 64 46 64 5F 63 0C 22 38 4E 5E 6A 67 62 0B 4A 64 64 40 63 0C 22 2B 6A 67 63 2C 38", "BWIPP different encoding (CodeB before FNC4 instead of after)" }, /* 42*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "ÿ12345678\012à12345678abcdef\0121\01223456\012\0127890àAàBCDEFà\012\012à", -1, 0, 8, 134, 0, 1, "(96) 67 64 46 64 5F 63 0C 22 38 4E 5E 6A 67 62 0B 4A 64 64 40 63 0C 22 2B 6A 67 63 2C 38", "BWIPP different encoding (CodeB before FNC4 instead of after)" },
/* 43*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "123456789012345ABCDEFGHI\012123456ÿ12345678\012à12345678abcdef\012\012123456\012\0127890àABCDEFà\012\012ààGHIJKàLMNOPQabc\012defà1234567ghijk\012\012à901234\012\012\012\012567890àààààààABCDEFGààà\012\012\012HIJK\012\012\012\012à\012à\012à\01212345à\012à\012à67890ààÄ9012ÄÄ56789Ä12Ä3\0124\0125\0126A\012a\012A\012A\012a\012a\012BCD1A2B3C4a5b6c7d8e9\0120\0121\0122\0123Ä4Ä5Ä6A7a8A9a0\012Ä12345678ÄÄÄÄÄÄÄÄÄÄÄ2ÄÄÄÄÄÄÄÄ4ÄÄÄÄÄÄAÄÄÄÄÄÄaÄÄÄÄÄÄé1é2é34é56Ä78é9éAéBéCéééééaébécé123456789012345ABCDEFGHI\012123456ÿ12345678\012à12345678abcdef\012\012123456\012\0127890àABCDEFà\012\012ààGHIJKàLMNOPQabc\012defà1234567ghijk\012\012à901234\012\012\012\012567890àààààààABCDEFGààà\012\012\012HIJK\012\012\012\012à\012à\012à\01212345à\012à\012à67890ààÄ9012ÄÄ56789Ä12Ä3\0124\0125\0126A\012a\012A\012A\012a\012a\012BCD1A2B3C4a5b6c7d8e9\0120\0121\0122\0123Ä4Ä5Ä6A7a8A9a0\012Ä12345678ÄÄÄÄÄÄÄÄÄÄÄ2ÄÄÄÄÄÄÄÄ4ÄÄÄÄÄÄAÄÄÄÄÄÄaÄÄÄÄÄÄé1é2é34é56Ä78é9éAéBéCéééééaébécé12345123456789012345ABCDEFGHI\012123456ÿ12345678\012à12345678abcdef\012\012123456\012\0127890àABCDEFà\012\012ààGHIJKàLMNOPQabc\012defà1234567ghijk\012\012à901234\012\012\012\012567890àààààààABCDEFGààà\012\012\012HIJK\012\012\012\012à\012à\012à\01212345à\012à\012à67890ààÄ9012ÄÄ56789Ä12Ä3\0124\0125\0126A\012a\012A\012A\012a\012a\012BCD1A2B3C4a5b6c7d8e9\0120\0121\0122\0123Ä4Ä5Ä6A7a8A9a0\012Ä12345678ÄÄÄÄÄÄÄÄÄÄÄ2ÄÄÄÄÄÄÄÄ4ÄÄÄÄÄÄAÄÄÄÄÄÄaÄÄÄÄÄÄé1é2é34é56Ä78é9éAéBéCéééééaébécé123456789012345ABCDEFGHI\012123456ÿ12345678\012à12345678abcdef\012\012123456\012\0127890àABCDEFà\012\012ààGHIJKàLMNOPQabc\012defà1234567ghijk\012\012à901234\012\012\012\012567890àààààààABCDEFGààà\012\012\012HIJK\012\012\012\012à\012à\012à\01212345à\012à\012à67890ààÄ9012ÄÄ56789Ä12Ä3\0124\0125\0126A\012a\012A\012A\012a\012a\012BCD1A2" "B3C4a5b6c7d8e9\0120\0121\0122\0123Ä4Ä5Ä6A7a8A9a0\012Ä12345678ÄÄÄÄÄÄÄÄÄÄÄ2ÄÄÄÄÄÄÄÄ4ÄÄÄÄÄÄAÄÄÄÄÄÄaÄÄÄÄÄÄé1é2é34é56Ä78é9éAéBéCéééééaébécé6789012345ABCDEFGHI\012123456ÿ12345678\012à12345678abcdef\012\012123456\012\0127890àABCDEFà\012\012ààGHIJKàLMNOPQabc\012defà1234567ghijk\012\012à901234\012\012\012\012567890àààààààABCDEFGààà\012\012\012HIJK\012\012\012\012à\012à\012à\01212345à\012à\012à67890ààÄ9012ÄÄ56789Ä12Ä3\0124\0125\0126A\012a\012A\012A\012a\012a\012BCD1A2B3C4a5b6c7d8e9\0120\0121\0122\0123Ä4Ä5Ä6A7a8A9a0\012Ä12345678ÄÄÄÄÄÄÄÄÄÄÄ2ÄÄÄÄÄÄÄÄ4ÄÄÄÄÄÄAÄÄÄÄÄÄaÄÄÄÄÄÄé1é2é34é56Ä78é9éAéBéCéééééaébécé123456789012345ABCDEFGHI\012123456ÿ12345678\012à12345678abcdef\012\012123456\012\0127890àABCDEFà\012\012ààGHIJKàLMNOPQabc\012defà1234567ghijk\012\012à901234\012\012\012\012567890àààààààABCDEFGààà\012\012\012HIJK\012\012\012\012à\012à\012à\012123456à\012à\012à\0123Ä4Ä5Ä6AÄ56789Ä12Ä3\0124\0125\0126A\012a\012A\012A\012a\012a\012BCD1A2B3C4a5b6c7d8e9\0120\0121\0122\0123Ä4Ä5Ä6A7a8A9a0\012Ä12345678ÄÄÄÄÄé1é2é34é56Ä78é9éAéBéCéééééaébécéÄÄÄÄÄÄ2ÄÄÄÄÄÄÄÄ4ÄÄÄé1é2é34é56Ä78é9éAéBéCéééééaébécéÄÄÄAÄÄÄÄÄÄaÄÄÄÄÄÄé1é2é34é56Ä78é9éAéBéCéééééaébécé", -1, 0, 44, 739, 0, "(2948) 67 63 2A 0C 22 38 4E 5A 0C 22 65 15 21 22 23 24 25 26 27 28 29 4A 63 0C 22 38 64", "BWIPP gs command too long" }, /* 43*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "123456789012345ABCDEFGHI\012123456ÿ12345678\012à12345678abcdef\012\012123456\012\0127890àABCDEFà\012\012ààGHIJKàLMNOPQabc\012defà1234567ghijk\012\012à901234\012\012\012\012567890àààààààABCDEFGààà\012\012\012HIJK\012\012\012\012à\012à\012à\01212345à\012à\012à67890ààÄ9012ÄÄ56789Ä12Ä3\0124\0125\0126A\012a\012A\012A\012a\012a\012BCD1A2B3C4a5b6c7d8e9\0120\0121\0122\0123Ä4Ä5Ä6A7a8A9a0\012Ä12345678ÄÄÄÄÄÄÄÄÄÄÄ2ÄÄÄÄÄÄÄÄ4ÄÄÄÄÄÄAÄÄÄÄÄÄaÄÄÄÄÄÄé1é2é34é56Ä78é9éAéBéCéééééaébécé123456789012345ABCDEFGHI\012123456ÿ12345678\012à12345678abcdef\012\012123456\012\0127890àABCDEFà\012\012ààGHIJKàLMNOPQabc\012defà1234567ghijk\012\012à901234\012\012\012\012567890àààààààABCDEFGààà\012\012\012HIJK\012\012\012\012à\012à\012à\01212345à\012à\012à67890ààÄ9012ÄÄ56789Ä12Ä3\0124\0125\0126A\012a\012A\012A\012a\012a\012BCD1A2B3C4a5b6c7d8e9\0120\0121\0122\0123Ä4Ä5Ä6A7a8A9a0\012Ä12345678ÄÄÄÄÄÄÄÄÄÄÄ2ÄÄÄÄÄÄÄÄ4ÄÄÄÄÄÄAÄÄÄÄÄÄaÄÄÄÄÄÄé1é2é34é56Ä78é9éAéBéCéééééaébécé12345123456789012345ABCDEFGHI\012123456ÿ12345678\012à12345678abcdef\012\012123456\012\0127890àABCDEFà\012\012ààGHIJKàLMNOPQabc\012defà1234567ghijk\012\012à901234\012\012\012\012567890àààààààABCDEFGààà\012\012\012HIJK\012\012\012\012à\012à\012à\01212345à\012à\012à67890ààÄ9012ÄÄ56789Ä12Ä3\0124\0125\0126A\012a\012A\012A\012a\012a\012BCD1A2B3C4a5b6c7d8e9\0120\0121\0122\0123Ä4Ä5Ä6A7a8A9a0\012Ä12345678ÄÄÄÄÄÄÄÄÄÄÄ2ÄÄÄÄÄÄÄÄ4ÄÄÄÄÄÄAÄÄÄÄÄÄaÄÄÄÄÄÄé1é2é34é56Ä78é9éAéBéCéééééaébécé123456789012345ABCDEFGHI\012123456ÿ12345678\012à12345678abcdef\012\012123456\012\0127890àABCDEFà\012\012ààGHIJKàLMNOPQabc\012defà1234567ghijk\012\012à901234\012\012\012\012567890àààààààABCDEFGààà\012\012\012HIJK\012\012\012\012à\012à\012à\01212345à\012à\012à67890ààÄ9012ÄÄ56789Ä12Ä3\0124\0125\0126A\012a\012A\012A\012a\012a\012BCD1A2" "B3C4a5b6c7d8e9\0120\0121\0122\0123Ä4Ä5Ä6A7a8A9a0\012Ä12345678ÄÄÄÄÄÄÄÄÄÄÄ2ÄÄÄÄÄÄÄÄ4ÄÄÄÄÄÄAÄÄÄÄÄÄaÄÄÄÄÄÄé1é2é34é56Ä78é9éAéBéCéééééaébécé6789012345ABCDEFGHI\012123456ÿ12345678\012à12345678abcdef\012\012123456\012\0127890àABCDEFà\012\012ààGHIJKàLMNOPQabc\012defà1234567ghijk\012\012à901234\012\012\012\012567890àààààààABCDEFGààà\012\012\012HIJK\012\012\012\012à\012à\012à\01212345à\012à\012à67890ààÄ9012ÄÄ56789Ä12Ä3\0124\0125\0126A\012a\012A\012A\012a\012a\012BCD1A2B3C4a5b6c7d8e9\0120\0121\0122\0123Ä4Ä5Ä6A7a8A9a0\012Ä12345678ÄÄÄÄÄÄÄÄÄÄÄ2ÄÄÄÄÄÄÄÄ4ÄÄÄÄÄÄAÄÄÄÄÄÄaÄÄÄÄÄÄé1é2é34é56Ä78é9éAéBéCéééééaébécé123456789012345ABCDEFGHI\012123456ÿ12345678\012à12345678abcdef\012\012123456\012\0127890àABCDEFà\012\012ààGHIJKàLMNOPQabc\012defà1234567ghijk\012\012à901234\012\012\012\012567890àààààààABCDEFGààà\012\012\012HIJK\012\012\012\012à\012à\012à\012123456à\012à\012à\0123Ä4Ä5Ä6AÄ56789Ä12Ä3\0124\0125\0126A\012a\012A\012A\012a\012a\012BCD1A2B3C4a5b6c7d8e9\0120\0121\0122\0123Ä4Ä5Ä6A7a8A9a0\012Ä12345678ÄÄÄÄÄé1é2é34é56Ä78é9éAéBéCéééééaébécéÄÄÄÄÄÄ2ÄÄÄÄÄÄÄÄ4ÄÄÄé1é2é34é56Ä78é9éAéBéCéééééaébécéÄÄÄAÄÄÄÄÄÄaÄÄÄÄÄÄé1é2é34é56Ä78é9éAéBéCéééééaébécé", -1, 0, 44, 739, 0, 1, "(2948) 67 63 2A 0C 22 38 4E 5A 0C 22 65 15 21 22 23 24 25 26 27 28 29 4A 63 0C 22 38 64", "BWIPP gs command too long" },
/* 44*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "ÿ12345678\012à12345678abcdef\012\012123456\012\0127890àABCDEFà\012\012ààGHIJKàLMNOPQabc\012defà1234567ghijk\012\012à901234\012\012\012\012567890ààààABCDEFGààà\012\012\012HIJK\012\012\012\012à\012à\012à\01212345à\012à\012à67890ààÄ9012ÄÄ56789Ä12Ä3\0124\0125\0126A\012a\012A\012A\012a\012a\012BCD1A2B3C4a5b6c7d8e9\0120\0121\0122\0123Ä4Ä5Ä6A7a8A9a0\012Ä12345678ÄÄÄÄÄÄ2ÄÄÄÄÄÄ4ÄÄÄÄÄÄaÄÄÄÄé1é2é34é56Ä78é9éAéBéCéééééaébécé123456789012345ABCDEFGHI\012123456ÿ12345678\012à12345678abcdef\012123456\012\0127890àABCDEFà\012\012ààGHIJKàLMNOPQabc\012defà1234567ghijk\012\012à901234\0122567890àààààABCDEFGààà\012\012\012HIJK\012\012\012\012à\012à\01212345à\012à\012à67890ààÄ9012ÄÄ56789Ä12Ä3\0124\0125\0126A\012a\012A\012A\012a\012a\012BCD1A2B3C4a5b6c7d8e9\0120\0121\0122\0123Ä4Ä5Ä6A7a8A9a0\012Ä12345678ÄÄ2Ä4ÄaÄé1é2é34é56Ä78é9éAéBéCééaébécé123456789012345ABCDEF\012123456ÿ123456\012à12345678abcdef\012\0121234\012\0127890àABCDà\012\012ààGHIJKàLMabc\012defà1234567ghijk\012\012à901234\012\012\012\012567890ààABCDEFGààà\012\012\012HIJK\012\012\012\012à\012à\012à\01212345à\012à\012à67890ààÄ9012ÄÄ56789Ä12Ä3\0124\0125\0126A\012a\012A\012A\012a\012a\012BCD1A2", -1, 0, 33, 387, 0, "(1155) 67 64 5F 64 5F 63 0C 22 38 4E 65 4A 64 64 40 63 0C 22 38 4E 64 41 42 43 44 45 46", "BWIPP different encodation" }, /* 44*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "ÿ12345678\012à12345678abcdef\012\012123456\012\0127890àABCDEFà\012\012ààGHIJKàLMNOPQabc\012defà1234567ghijk\012\012à901234\012\012\012\012567890ààààABCDEFGààà\012\012\012HIJK\012\012\012\012à\012à\012à\01212345à\012à\012à67890ààÄ9012ÄÄ56789Ä12Ä3\0124\0125\0126A\012a\012A\012A\012a\012a\012BCD1A2B3C4a5b6c7d8e9\0120\0121\0122\0123Ä4Ä5Ä6A7a8A9a0\012Ä12345678ÄÄÄÄÄÄ2ÄÄÄÄÄÄ4ÄÄÄÄÄÄaÄÄÄÄé1é2é34é56Ä78é9éAéBéCéééééaébécé123456789012345ABCDEFGHI\012123456ÿ12345678\012à12345678abcdef\012123456\012\0127890àABCDEFà\012\012ààGHIJKàLMNOPQabc\012defà1234567ghijk\012\012à901234\0122567890àààààABCDEFGààà\012\012\012HIJK\012\012\012\012à\012à\01212345à\012à\012à67890ààÄ9012ÄÄ56789Ä12Ä3\0124\0125\0126A\012a\012A\012A\012a\012a\012BCD1A2B3C4a5b6c7d8e9\0120\0121\0122\0123Ä4Ä5Ä6A7a8A9a0\012Ä12345678ÄÄ2Ä4ÄaÄé1é2é34é56Ä78é9éAéBéCééaébécé123456789012345ABCDEF\012123456ÿ123456\012à12345678abcdef\012\0121234\012\0127890àABCDà\012\012ààGHIJKàLMabc\012defà1234567ghijk\012\012à901234\012\012\012\012567890ààABCDEFGààà\012\012\012HIJK\012\012\012\012à\012à\012à\01212345à\012à\012à67890ààÄ9012ÄÄ56789Ä12Ä3\0124\0125\0126A\012a\012A\012A\012a\012a\012BCD1A2", -1, 0, 33, 387, 0, 1, "(1155) 67 64 5F 64 5F 63 0C 22 38 4E 65 4A 64 64 40 63 0C 22 38 4E 64 41 42 43 44 45 46", "BWIPP different encodation" },
/* 45*/ { BARCODE_CODABLOCKF, DATA_MODE | ESCAPE_MODE, -1, -1, "\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\x09", -1, 0, 3, 101, 1, "67 62 41 41 42 43 44 5B 6A 67 62 0B 45 46 47 48 37 6A 67 62 0C 49 63 1B 44 2C 6A", "Okapi control-chars-1.png" }, /* 45*/ { BARCODE_CODABLOCKF, DATA_MODE | ESCAPE_MODE, -1, -1, "\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\x09", -1, 0, 3, 101, 1, 1, "67 62 41 41 42 43 44 5B 6A 67 62 0B 45 46 47 48 37 6A 67 62 0C 49 63 1B 44 2C 6A", "Okapi control-chars-1.png" },
/* 46*/ { BARCODE_CODABLOCKF, DATA_MODE | ESCAPE_MODE, 4, -1, "\\x80\\x81\\x82\\x83\\x9E\\x9F\\xA0", -1, 0, 4, 101, 1, "(36) 67 62 42 65 40 65 41 24 6A 67 62 0B 65 42 65 43 31 6A 67 62 0C 65 5E 65 5F 16 6A 67", "Okapi control-chars-2.png" }, /* 46*/ { BARCODE_CODABLOCKF, DATA_MODE | ESCAPE_MODE, 4, -1, "\\x80\\x81\\x82\\x83\\x9E\\x9F\\xA0", -1, 0, 4, 101, 1, 899, "(36) 67 62 42 65 40 65 41 24 6A 67 62 0B 65 42 65 43 31 6A 67 62 0C 65 5E 65 5F 16 6A 67", "Okapi control-chars-2.png" },
/* 47*/ { BARCODE_CODABLOCKF, DATA_MODE | ESCAPE_MODE, -1, -1, "\\x00z", -1, 0, 2, 101, 0, "67 62 40 40 62 5A 63 00 6A 67 64 0B 63 64 32 04 3F 6A", "Okapi data-null-z.png; BWIPP different encodation" }, /* 47*/ { BARCODE_CODABLOCKF, DATA_MODE | ESCAPE_MODE, -1, -1, "\\x00z", -1, 0, 2, 101, 0, 1, "67 62 40 40 62 5A 63 00 6A 67 64 0B 63 64 32 04 3F 6A", "Okapi data-null-z.png; BWIPP different encodation" },
/* 48*/ { BARCODE_CODABLOCKF, UNICODE_MODE | ESCAPE_MODE, -1, -1, "2610\\u00F2", -1, 0, 2, 101, 1, "67 63 00 1A 0A 64 63 4B 6A 67 64 0B 64 52 33 26 64 6A", "Okapi data-fuzz-19.png" }, /* 48*/ { BARCODE_CODABLOCKF, UNICODE_MODE | ESCAPE_MODE, -1, -1, "2610\\u00F2", -1, 0, 2, 101, 1, 1, "67 63 00 1A 0A 64 63 4B 6A 67 64 0B 64 52 33 26 64 6A", "Okapi data-fuzz-19.png" },
/* 49*/ { BARCODE_CODABLOCKF, DATA_MODE | ESCAPE_MODE, 7, -1, "*\\r\\xF2\\x82\\x82(\\x982\\x82\\x82*\\r\\xF2\\x82\\xA8\\x82\\x82\\x82\\x82", -1, 0, 7, 123, 0, "(77) 67 62 45 0A 4D 64 64 52 63 35 6A 67 62 0B 65 42 65 42 08 63 43 6A 67 62 0C 65 58 12", "Okapi data-fuzz-20.png; BWIPP different encodation" }, /* 49*/ { BARCODE_CODABLOCKF, DATA_MODE | ESCAPE_MODE, 7, -1, "*\\r\\xF2\\x82\\x82(\\x982\\x82\\x82*\\r\\xF2\\x82\\xA8\\x82\\x82\\x82\\x82", -1, 0, 7, 123, 0, 899, "(77) 67 62 45 0A 4D 64 64 52 63 35 6A 67 62 0B 65 42 65 42 08 63 43 6A 67 62 0C 65 58 12", "Okapi data-fuzz-20.png; BWIPP different encodation" },
/* 50*/ { BARCODE_CODABLOCKF, UNICODE_MODE | ESCAPE_MODE, -1, -1, "\\u0018\\u00F2", -1, 0, 2, 101, 0, "67 62 40 58 65 62 52 16 6A 67 64 0B 63 64 38 30 30 6A", "Okapi data-fuzz-21.png; BWIPP different encodation" }, /* 50*/ { BARCODE_CODABLOCKF, UNICODE_MODE | ESCAPE_MODE, -1, -1, "\\u0018\\u00F2", -1, 0, 2, 101, 0, 1, "67 62 40 58 65 62 52 16 6A 67 64 0B 63 64 38 30 30 6A", "Okapi data-fuzz-21.png; BWIPP different encodation" },
/* 51*/ { BARCODE_HIBC_BLOCKF, UNICODE_MODE, -1, -1, "A99912345/$$52001510X3", -1, 0, 6, 101, 1, "(54) 67 64 44 0B 21 19 19 3A 6A 67 63 2B 5B 17 2D 64 24 6A 67 64 0C 0F 04 04 15 16 6A 67", "" }, /* 51*/ { BARCODE_HIBC_BLOCKF, UNICODE_MODE, -1, -1, "A99912345/$$52001510X3", -1, 0, 6, 101, 1, 1, "(54) 67 64 44 0B 21 19 19 3A 6A 67 63 2B 5B 17 2D 64 24 6A 67 64 0C 0F 04 04 15 16 6A 67", "" },
/* 52*/ { BARCODE_HIBC_BLOCKF, UNICODE_MODE, -1, -1, "A99912345/$$520:1510X3", -1, ZINT_ERROR_INVALID_DATA, -1, -1, 1, "Error 203: Invalid character at position 16 in input (alphanumerics, space and \"-.$/+%\" only)", "" }, /* 52*/ { BARCODE_HIBC_BLOCKF, UNICODE_MODE, -1, -1, "A99912345/$$520:1510X3", -1, ZINT_ERROR_INVALID_DATA, -1, -1, 1, 1, "Error 203: Invalid character at position 16 in input (alphanumerics, space and \"-.$/+%\" only)", "" },
}; };
const int data_size = ARRAY_SIZE(data); const int data_size = ARRAY_SIZE(data);
int i, length, ret; int i, length, ret;
@ -409,10 +440,11 @@ static void test_input(const testCtx *const p_ctx) {
char cmp_buf[32768]; char cmp_buf[32768];
char cmp_msg[32768]; char cmp_msg[32768];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ /* Only do BWIPP/ZXing-C++ tests if asked, too slow otherwise */
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript();
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder();
testStartSymbol("test_input", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -423,16 +455,20 @@ static void test_input(const testCtx *const p_ctx) {
symbol->debug = ZINT_DEBUG_TEST; /* Needed to get codeword dump in errtxt */ symbol->debug = ZINT_DEBUG_TEST; /* Needed to get codeword dump in errtxt */
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, data[i].length, debug); length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/,
data[i].option_1, data[i].option_2, -1 /*option_3*/, -1 /*output_options*/,
data[i].data, data[i].length, debug);
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) { if (p_ctx->generate) {
printf(" /*%3d*/ { %s, %s, %d, %d, \"%s\", %d, %s, %d, %d, %d, \"%s\", \"%s\" },\n", printf(" /*%3d*/ { %s, %s, %d, %d, \"%s\", %d, %s, %d, %d, %d, %d, \"%s\", \"%s\" },\n",
i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), data[i].option_1, data[i].option_2, i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode),
data[i].option_1, data[i].option_2,
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length,
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp, symbol->errtxt, data[i].comment); testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp,
data[i].zxingcpp_cmp, symbol->errtxt, data[i].comment);
} else { } else {
assert_zero(strcmp((char *) symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); assert_zero(strcmp((char *) symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
if (ret < ZINT_ERROR) { if (ret < ZINT_ERROR) {
@ -456,13 +492,19 @@ static void test_input(const testCtx *const p_ctx) {
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) { if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) {
int cmp_len, ret_len; int cmp_len, ret_len;
char modules_dump[32768]; char modules_dump[32768];
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); assert_nonzero(data[i].zxingcpp_cmp, "i:%d data[i].zxingcpp_cmp == 0", i);
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1,
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); "i:%d testUtilModulesDump == -1\n", i);
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, data[i].zxingcpp_cmp,
cmp_buf, sizeof(cmp_buf), &cmp_len);
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n",
i, testUtilBarcodeName(symbol->symbology), ret);
ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len); ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length,
NULL /*primary*/, escaped, &ret_len);
assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n",
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, escaped); i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len,
escaped);
} }
} }
} }
@ -585,10 +627,11 @@ static void test_encode(const testCtx *const p_ctx) {
char cmp_buf[8192]; char cmp_buf[8192];
char cmp_msg[1024]; char cmp_msg[1024];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ /* Only do BWIPP/ZXing-C++ tests if asked, too slow otherwise */
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript();
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder();
testStartSymbol("test_encode", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -597,14 +640,18 @@ static void test_encode(const testCtx *const p_ctx) {
symbol = ZBarcode_Create(); symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n"); assert_nonnull(symbol, "Symbol not created\n");
length = testUtilSetSymbol(symbol, data[i].symbology, UNICODE_MODE, -1 /*eci*/, data[i].option_1, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug); length = testUtilSetSymbol(symbol, data[i].symbology, UNICODE_MODE, -1 /*eci*/,
data[i].option_1, data[i].option_2, -1 /*option_3*/, -1 /*output_options*/,
data[i].data, -1, debug);
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n",
i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) { if (p_ctx->generate) {
printf(" /*%3d*/ { %s, %d, %d, \"%s\", %s, %d, %d, %d, \"%s\",\n", printf(" /*%3d*/ { %s, %d, %d, \"%s\", %s, %d, %d, %d, \"%s\",\n",
i, testUtilBarcodeName(data[i].symbology), data[i].option_1, data[i].option_2, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), i, testUtilBarcodeName(data[i].symbology), data[i].option_1, data[i].option_2,
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].comment); testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].comment);
testUtilModulesPrint(symbol, " ", "\n"); testUtilModulesPrint(symbol, " ", "\n");
printf(" },\n"); printf(" },\n");
@ -612,34 +659,48 @@ static void test_encode(const testCtx *const p_ctx) {
if (ret < ZINT_ERROR) { if (ret < ZINT_ERROR) {
int width, row; int width, row;
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data); assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n",
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); i, symbol->rows, data[i].expected_rows, data[i].data);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n",
i, symbol->width, data[i].expected_width, data[i].data);
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row); ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data); assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row,
data[i].data);
if (do_bwipp && testUtilCanBwipp(i, symbol, data[i].option_1, data[i].option_2, -1, debug)) { if (do_bwipp && testUtilCanBwipp(i, symbol, data[i].option_1, data[i].option_2, -1, debug)) {
if (!data[i].bwipp_cmp) { if (!data[i].bwipp_cmp) {
if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d %s not BWIPP compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), data[i].comment); if (debug & ZINT_DEBUG_TEST_PRINT) {
printf("i:%d %s not BWIPP compatible (%s)\n",
i, testUtilBarcodeName(symbol->symbology), data[i].comment);
}
} else { } else {
ret = testUtilBwipp(i, symbol, data[i].option_1, data[i].option_2, -1, data[i].data, length, NULL, cmp_buf, sizeof(cmp_buf), NULL); ret = testUtilBwipp(i, symbol, data[i].option_1, data[i].option_2, -1, data[i].data, length,
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); NULL, cmp_buf, sizeof(cmp_buf), NULL);
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i,
testUtilBarcodeName(symbol->symbology), ret);
ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, data[i].expected); ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, data[i].expected);
assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n", assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n",
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, data[i].expected); i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf,
data[i].expected);
} }
} }
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) { if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) {
int cmp_len, ret_len; int cmp_len, ret_len;
char modules_dump[4096]; char modules_dump[4096];
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1,
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); "i:%d testUtilModulesDump == -1\n", i);
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, 1 /*zxingcpp_cmp*/, cmp_buf,
sizeof(cmp_buf), &cmp_len);
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n",
i, testUtilBarcodeName(symbol->symbology), ret);
ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len); ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length,
NULL /*primary*/, escaped, &ret_len);
assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n",
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, escaped); i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf,
ret_len, escaped);
} }
} }
} }
@ -661,10 +722,11 @@ static void test_fuzz(const testCtx *const p_ctx) {
int length; int length;
int ret; int ret;
int bwipp_cmp; int bwipp_cmp;
int zxingcpp_cmp;
const char *comment; const char *comment;
}; };
static const struct item data[] = { static const struct item data[] = {
/* 0*/ { -1, -1, "\034\034I", 3, 0, 1, "" }, /* 0*/ { -1, -1, "\034\034I", 3, 0, 1, 1, "" },
/* 1*/ { 6, -2147483647 - 1 /*Suppress MSVC warning C4146*/, /* 1*/ { 6, -2147483647 - 1 /*Suppress MSVC warning C4146*/,
"\134\000\377\153\143\163\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061" "\134\000\377\153\143\163\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061"
"\071\065\062\000\000\000\000\061\061\061\061\061\061\366\366\366\366\366\366\366\366\366\366\007\366\366\366\366\366\366\366\061\061\061\061\061\061\061\061\061" "\071\065\062\000\000\000\000\061\061\061\061\061\061\366\366\366\366\366\366\366\366\366\366\007\366\366\366\366\366\366\366\061\061\061\061\061\061\061\061\061"
@ -672,7 +734,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
"\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\312\061\061\061\061\061\061\061" "\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\312\061\061\061\061\061\061\061"
"\061\366\366\366\366\366\366\366\366\366\366\007\366\366\366\366\366\366\366\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\323\323\323\323\000" "\061\366\366\366\366\366\366\366\366\366\366\007\366\366\366\366\366\366\366\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\323\323\323\323\000"
"\200\135\000\362\362\362\362\000\167\027\000\000\000\000\000\000\000\000\000\167\167\167\167\000\000\000\154\000\043\000\000\000\000\000\000\000\000\153", "\200\135\000\362\362\362\362\000\167\027\000\000\000\000\000\000\000\000\000\167\167\167\167\000\000\000\154\000\043\000\000\000\000\000\000\000\000\153",
238, 0, 0, "BWIPP different (better) encodation" 238, 0, 0, 899, "BWIPP different (better) encodation"
}, /* #300 (#9) Andre Maute */ }, /* #300 (#9) Andre Maute */
}; };
const int data_size = ARRAY_SIZE(data); const int data_size = ARRAY_SIZE(data);
@ -683,10 +745,11 @@ static void test_fuzz(const testCtx *const p_ctx) {
char cmp_buf[32768]; char cmp_buf[32768];
char cmp_msg[32768]; char cmp_msg[32768];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ /* Only do BWIPP/ZXing-C++ tests if asked, too slow otherwise */
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript();
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder();
testStartSymbol("test_fuzz", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -719,13 +782,19 @@ static void test_fuzz(const testCtx *const p_ctx) {
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) { if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) {
int cmp_len, ret_len; int cmp_len, ret_len;
char modules_dump[32768]; char modules_dump[32768];
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); assert_nonzero(data[i].zxingcpp_cmp, "i:%d data[i].zxingcpp_cmp == 0", i);
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1,
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); "i:%d testUtilModulesDump == -1\n", i);
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, data[i].zxingcpp_cmp, cmp_buf,
sizeof(cmp_buf), &cmp_len);
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n",
i, testUtilBarcodeName(symbol->symbology), ret);
ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len); ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/,
escaped, &ret_len);
assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n",
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, escaped); i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len,
escaped);
} }
} }

View file

@ -75,7 +75,7 @@ static void test_large(const testCtx *const p_ctx) {
char data_buf[4096]; char data_buf[4096];
testStartSymbol("test_large", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -117,80 +117,82 @@ static void test_hrt(const testCtx *const p_ctx) {
const char *expected; const char *expected;
int expected_length; int expected_length;
const char *expected_raw;
int expected_raw_length;
}; };
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = { static const struct item data[] = {
/* 0*/ { BARCODE_CODE39, -1, -1, "ABC1234", -1, "*ABC1234*", -1 }, /* 0*/ { BARCODE_CODE39, -1, -1, "ABC1234", -1, "*ABC1234*", -1, "", -1 },
/* 1*/ { BARCODE_CODE39, -1, BARCODE_RAW_TEXT, "ABC1234", -1, "ABC1234", -1 }, /* 1*/ { BARCODE_CODE39, -1, BARCODE_RAW_TEXT, "ABC1234", -1, "*ABC1234*", -1, "ABC1234", -1 },
/* 2*/ { BARCODE_CODE39, 1, -1, "ABC1234", -1, "*ABC12340*", -1 }, /* With visible check digit */ /* 2*/ { BARCODE_CODE39, 1, -1, "ABC1234", -1, "*ABC12340*", -1, "", -1 }, /* With visible check digit */
/* 3*/ { BARCODE_CODE39, 1, BARCODE_RAW_TEXT, "ABC1234", -1, "ABC12340", -1 }, /* 3*/ { BARCODE_CODE39, 1, BARCODE_RAW_TEXT, "ABC1234", -1, "*ABC12340*", -1, "ABC12340", -1 },
/* 4*/ { BARCODE_CODE39, -1, -1, "abc1234", -1, "*ABC1234*", -1 }, /* Converts to upper */ /* 4*/ { BARCODE_CODE39, -1, -1, "abc1234", -1, "*ABC1234*", -1, "", -1 }, /* Converts to upper */
/* 5*/ { BARCODE_CODE39, -1, BARCODE_RAW_TEXT, "abc1234", -1, "ABC1234", -1 }, /* 5*/ { BARCODE_CODE39, -1, BARCODE_RAW_TEXT, "abc1234", -1, "*ABC1234*", -1, "ABC1234", -1 },
/* 6*/ { BARCODE_CODE39, 1, -1, "abc1234", -1, "*ABC12340*", -1 }, /* Converts to upper */ /* 6*/ { BARCODE_CODE39, 1, -1, "abc1234", -1, "*ABC12340*", -1, "", -1 }, /* Converts to upper */
/* 7*/ { BARCODE_CODE39, 1, BARCODE_RAW_TEXT, "abc1234", -1, "ABC12340", -1 }, /* 7*/ { BARCODE_CODE39, 1, BARCODE_RAW_TEXT, "abc1234", -1, "*ABC12340*", -1, "ABC12340", -1 },
/* 8*/ { BARCODE_CODE39, 1, -1, "ab", -1, "*ABL*", -1 }, /* Converts to upper */ /* 8*/ { BARCODE_CODE39, 1, -1, "ab", -1, "*ABL*", -1, "", -1 }, /* Converts to upper */
/* 9*/ { BARCODE_CODE39, 1, BARCODE_RAW_TEXT, "ab", -1, "ABL", -1 }, /* 9*/ { BARCODE_CODE39, 1, BARCODE_RAW_TEXT, "ab", -1, "*ABL*", -1, "ABL", -1 },
/* 10*/ { BARCODE_CODE39, -1, -1, "123456789", -1, "*123456789*", -1 }, /* 10*/ { BARCODE_CODE39, -1, -1, "123456789", -1, "*123456789*", -1, "", -1 },
/* 11*/ { BARCODE_CODE39, -1, BARCODE_RAW_TEXT, "123456789", -1, "123456789", -1 }, /* 11*/ { BARCODE_CODE39, -1, BARCODE_RAW_TEXT, "123456789", -1, "*123456789*", -1, "123456789", -1 },
/* 12*/ { BARCODE_CODE39, 1, -1, "123456789", -1, "*1234567892*", -1 }, /* With visible check digit */ /* 12*/ { BARCODE_CODE39, 1, -1, "123456789", -1, "*1234567892*", -1, "", -1 }, /* With visible check digit */
/* 13*/ { BARCODE_CODE39, 1, BARCODE_RAW_TEXT, "123456789", -1, "1234567892", -1 }, /* 13*/ { BARCODE_CODE39, 1, BARCODE_RAW_TEXT, "123456789", -1, "*1234567892*", -1, "1234567892", -1 },
/* 14*/ { BARCODE_CODE39, 2, -1, "123456789", -1, "*123456789*", -1 }, /* With hidden check digit */ /* 14*/ { BARCODE_CODE39, 2, -1, "123456789", -1, "*123456789*", -1, "", -1 }, /* With hidden check digit */
/* 15*/ { BARCODE_CODE39, 2, BARCODE_RAW_TEXT, "123456789", -1, "1234567892", -1 }, /* Includes check digit */ /* 15*/ { BARCODE_CODE39, 2, BARCODE_RAW_TEXT, "123456789", -1, "*123456789*", -1, "1234567892", -1 }, /* Includes check digit */
/* 16*/ { BARCODE_EXCODE39, -1, -1, "ABC1234", -1, "ABC1234", -1 }, /* 16*/ { BARCODE_EXCODE39, -1, -1, "ABC1234", -1, "ABC1234", -1, "", -1 },
/* 17*/ { BARCODE_EXCODE39, -1, BARCODE_RAW_TEXT, "ABC1234", -1, "ABC1234", -1 }, /* 17*/ { BARCODE_EXCODE39, -1, BARCODE_RAW_TEXT, "ABC1234", -1, "ABC1234", -1, "ABC1234", -1 },
/* 18*/ { BARCODE_EXCODE39, 1, -1, "ABC1234", -1, "ABC12340", -1 }, /* With visible check digit */ /* 18*/ { BARCODE_EXCODE39, 1, -1, "ABC1234", -1, "ABC12340", -1, "", -1 }, /* With visible check digit */
/* 19*/ { BARCODE_EXCODE39, 1, BARCODE_RAW_TEXT, "ABC1234", -1, "ABC12340", -1 }, /* 19*/ { BARCODE_EXCODE39, 1, BARCODE_RAW_TEXT, "ABC1234", -1, "ABC12340", -1, "ABC12340", -1 },
/* 20*/ { BARCODE_EXCODE39, -1, -1, "abc1234", -1, "abc1234", -1 }, /* 20*/ { BARCODE_EXCODE39, -1, -1, "abc1234", -1, "abc1234", -1, "", -1 },
/* 21*/ { BARCODE_EXCODE39, -1, BARCODE_RAW_TEXT, "abc1234", -1, "abc1234", -1 }, /* 21*/ { BARCODE_EXCODE39, -1, BARCODE_RAW_TEXT, "abc1234", -1, "abc1234", -1, "abc1234", -1 },
/* 22*/ { BARCODE_EXCODE39, 1, -1, "abc1234", -1, "abc1234.", -1 }, /* With visible check digit (previously was hidden) */ /* 22*/ { BARCODE_EXCODE39, 1, -1, "abc1234", -1, "abc1234.", -1, "", -1 }, /* With visible check digit (previously was hidden) */
/* 23*/ { BARCODE_EXCODE39, 1, BARCODE_RAW_TEXT, "abc1234", -1, "abc1234.", -1 }, /* 23*/ { BARCODE_EXCODE39, 1, BARCODE_RAW_TEXT, "abc1234", -1, "abc1234.", -1, "abc1234.", -1 },
/* 24*/ { BARCODE_EXCODE39, 2, -1, "abc1234", -1, "abc1234", -1 }, /* With hidden check digit */ /* 24*/ { BARCODE_EXCODE39, 2, -1, "abc1234", -1, "abc1234", -1, "", -1 }, /* With hidden check digit */
/* 25*/ { BARCODE_EXCODE39, 2, BARCODE_RAW_TEXT, "abc1234", -1, "abc1234.", -1 }, /* Includes check digit */ /* 25*/ { BARCODE_EXCODE39, 2, BARCODE_RAW_TEXT, "abc1234", -1, "abc1234", -1, "abc1234.", -1 }, /* Includes check digit */
/* 26*/ { BARCODE_EXCODE39, -1, -1, "a%\000\001$\177z\033\037!+/\\@A~", 16, "a% $ z !+/\\@A~", -1 }, /* NUL, ctrls and DEL replaced with spaces */ /* 26*/ { BARCODE_EXCODE39, -1, -1, "a%\000\001$\177z\033\037!+/\\@A~", 16, "a% $ z !+/\\@A~", -1, "", -1 }, /* NUL, ctrls and DEL replaced with spaces */
/* 27*/ { BARCODE_EXCODE39, -1, BARCODE_RAW_TEXT, "a%\000\001$\177z\033\037!+/\\@A~", 16, "a%\000\001$\177z\033\037!+/\\@A~", 16 }, /* No replacements */ /* 27*/ { BARCODE_EXCODE39, -1, BARCODE_RAW_TEXT, "a%\000\001$\177z\033\037!+/\\@A~", 16, "a% $ z !+/\\@A~", -1, "a%\000\001$\177z\033\037!+/\\@A~", 16 }, /* No replacements */
/* 28*/ { BARCODE_EXCODE39, 1, -1, "a%\000\001$\177z\033\037!+/\\@A~", 16, "a% $ z !+/\\@A~L", -1 }, /* With visible check digit */ /* 28*/ { BARCODE_EXCODE39, 1, -1, "a%\000\001$\177z\033\037!+/\\@A~", 16, "a% $ z !+/\\@A~L", -1, "", -1 }, /* With visible check digit */
/* 29*/ { BARCODE_EXCODE39, 1, BARCODE_RAW_TEXT, "a%\000\001$\177z\033\037!+/\\@A~", 16, "a%\000\001$\177z\033\037!+/\\@A~L", 17 }, /* 29*/ { BARCODE_EXCODE39, 1, BARCODE_RAW_TEXT, "a%\000\001$\177z\033\037!+/\\@A~", 16, "a% $ z !+/\\@A~L", -1, "a%\000\001$\177z\033\037!+/\\@A~L", 17 },
/* 30*/ { BARCODE_EXCODE39, 2, -1, "a%\000\001$\177z\033\037!+/\\@A~", 16, "a% $ z !+/\\@A~", -1 }, /* With hidden check digit */ /* 30*/ { BARCODE_EXCODE39, 2, -1, "a%\000\001$\177z\033\037!+/\\@A~", 16, "a% $ z !+/\\@A~", -1, "", -1 }, /* With hidden check digit */
/* 31*/ { BARCODE_EXCODE39, 2, BARCODE_RAW_TEXT, "a%\000\001$\177z\033\037!+/\\@A~", 16, "a%\000\001$\177z\033\037!+/\\@A~L", 17 }, /* Includes check digit */ /* 31*/ { BARCODE_EXCODE39, 2, BARCODE_RAW_TEXT, "a%\000\001$\177z\033\037!+/\\@A~", 16, "a% $ z !+/\\@A~", -1, "a%\000\001$\177z\033\037!+/\\@A~L", 17 }, /* Includes check digit */
/* 32*/ { BARCODE_LOGMARS, -1, -1, "ABC1234", -1, "ABC1234", -1 }, /* 32*/ { BARCODE_LOGMARS, -1, -1, "ABC1234", -1, "ABC1234", -1, "", -1 },
/* 33*/ { BARCODE_LOGMARS, -1, BARCODE_RAW_TEXT, "ABC1234", -1, "ABC1234", -1 }, /* 33*/ { BARCODE_LOGMARS, -1, BARCODE_RAW_TEXT, "ABC1234", -1, "ABC1234", -1, "ABC1234", -1 },
/* 34*/ { BARCODE_LOGMARS, -1, -1, "abc1234", -1, "ABC1234", -1 }, /* Converts to upper */ /* 34*/ { BARCODE_LOGMARS, -1, -1, "abc1234", -1, "ABC1234", -1, "", -1 }, /* Converts to upper */
/* 35*/ { BARCODE_LOGMARS, -1, BARCODE_RAW_TEXT, "abc1234", -1, "ABC1234", -1 }, /* 35*/ { BARCODE_LOGMARS, -1, BARCODE_RAW_TEXT, "abc1234", -1, "ABC1234", -1, "ABC1234", -1 },
/* 36*/ { BARCODE_LOGMARS, 1, -1, "abc1234", -1, "ABC12340", -1 }, /* With check digit */ /* 36*/ { BARCODE_LOGMARS, 1, -1, "abc1234", -1, "ABC12340", -1, "", -1 }, /* With check digit */
/* 37*/ { BARCODE_LOGMARS, 1, BARCODE_RAW_TEXT, "abc1234", -1, "ABC12340", -1 }, /* 37*/ { BARCODE_LOGMARS, 1, BARCODE_RAW_TEXT, "abc1234", -1, "ABC12340", -1, "ABC12340", -1 },
/* 38*/ { BARCODE_LOGMARS, 1, -1, "12345/ABCDE", -1, "12345/ABCDET", -1 }, /* With visible check digit */ /* 38*/ { BARCODE_LOGMARS, 1, -1, "12345/ABCDE", -1, "12345/ABCDET", -1, "", -1 }, /* With visible check digit */
/* 39*/ { BARCODE_LOGMARS, 1, BARCODE_RAW_TEXT, "12345/ABCDE", -1, "12345/ABCDET", -1 }, /* 39*/ { BARCODE_LOGMARS, 1, BARCODE_RAW_TEXT, "12345/ABCDE", -1, "12345/ABCDET", -1, "12345/ABCDET", -1 },
/* 40*/ { BARCODE_LOGMARS, 2, -1, "12345/ABCDE", -1, "12345/ABCDE", -1 }, /* With hidden check digit */ /* 40*/ { BARCODE_LOGMARS, 2, -1, "12345/ABCDE", -1, "12345/ABCDE", -1, "", -1 }, /* With hidden check digit */
/* 41*/ { BARCODE_LOGMARS, 2, BARCODE_RAW_TEXT, "12345/ABCDE", -1, "12345/ABCDET", -1 }, /* Includes check digit */ /* 41*/ { BARCODE_LOGMARS, 2, BARCODE_RAW_TEXT, "12345/ABCDE", -1, "12345/ABCDE", -1, "12345/ABCDET", -1 }, /* Includes check digit */
/* 42*/ { BARCODE_CODE93, -1, -1, "ABC1234", -1, "ABC1234", -1 }, /* No longer shows 2 check chars added (same as BWIPP and TEC-IT) */ /* 42*/ { BARCODE_CODE93, -1, -1, "ABC1234", -1, "ABC1234", -1, "", -1 }, /* No longer shows 2 check chars added (same as BWIPP and TEC-IT) */
/* 43*/ { BARCODE_CODE93, -1, BARCODE_RAW_TEXT, "ABC1234", -1, "ABC1234S5", -1 }, /* Unless BARCODE_RAW_TEXT */ /* 43*/ { BARCODE_CODE93, -1, BARCODE_RAW_TEXT, "ABC1234", -1, "ABC1234", -1, "ABC1234S5", -1 }, /* Unless BARCODE_RAW_TEXT */
/* 44*/ { BARCODE_CODE93, 1, -1, "ABC1234", -1, "ABC1234S5", -1 }, /* Unless requested */ /* 44*/ { BARCODE_CODE93, 1, -1, "ABC1234", -1, "ABC1234S5", -1, "", -1 }, /* Unless requested */
/* 45*/ { BARCODE_CODE93, 1, BARCODE_RAW_TEXT, "ABC1234", -1, "ABC1234S5", -1 }, /* 45*/ { BARCODE_CODE93, 1, BARCODE_RAW_TEXT, "ABC1234", -1, "ABC1234S5", -1, "ABC1234S5", -1 },
/* 46*/ { BARCODE_CODE93, -1, -1, "abc1234", -1, "abc1234", -1 }, /* 46*/ { BARCODE_CODE93, -1, -1, "abc1234", -1, "abc1234", -1, "", -1 },
/* 47*/ { BARCODE_CODE93, -1, BARCODE_RAW_TEXT, "abc1234", -1, "abc1234ZG", -1 }, /* 47*/ { BARCODE_CODE93, -1, BARCODE_RAW_TEXT, "abc1234", -1, "abc1234", -1, "abc1234ZG", -1 },
/* 48*/ { BARCODE_CODE93, 1, -1, "abc1234", -1, "abc1234ZG", -1 }, /* 48*/ { BARCODE_CODE93, 1, -1, "abc1234", -1, "abc1234ZG", -1, "", -1 },
/* 49*/ { BARCODE_CODE93, 1, BARCODE_RAW_TEXT, "abc1234", -1, "abc1234ZG", -1 }, /* 49*/ { BARCODE_CODE93, 1, BARCODE_RAW_TEXT, "abc1234", -1, "abc1234ZG", -1, "abc1234ZG", -1 },
/* 50*/ { BARCODE_CODE93, -1, -1, "A\001a\000b\177d\037e", 9, "A a b d e", -1 }, /* NUL, ctrls and DEL replaced with spaces */ /* 50*/ { BARCODE_CODE93, -1, -1, "A\001a\000b\177d\037e", 9, "A a b d e", -1, "", -1 }, /* NUL, ctrls and DEL replaced with spaces */
/* 51*/ { BARCODE_CODE93, -1, BARCODE_RAW_TEXT, "A\001a\000b\177d\037e", 9, "A\001a\000b\177d\037e1R", 11 }, /* No replacements */ /* 51*/ { BARCODE_CODE93, -1, BARCODE_RAW_TEXT, "A\001a\000b\177d\037e", 9, "A a b d e", -1, "A\001a\000b\177d\037e1R", 11 }, /* No replacements */
/* 52*/ { BARCODE_CODE93, 1, -1, "A\001a\000b\177d\037e", 9, "A a b d e1R", -1 }, /* 52*/ { BARCODE_CODE93, 1, -1, "A\001a\000b\177d\037e", 9, "A a b d e1R", -1, "", -1 },
/* 53*/ { BARCODE_CODE93, 1, BARCODE_RAW_TEXT, "A\001a\000b\177d\037e", 9, "A\001a\000b\177d\037e1R", 11 }, /* 53*/ { BARCODE_CODE93, 1, BARCODE_RAW_TEXT, "A\001a\000b\177d\037e", 9, "A a b d e1R", -1, "A\001a\000b\177d\037e1R", 11 },
/* 54*/ { BARCODE_VIN, -1, -1, "1FTCR10UXTPA78180", -1, "1FTCR10UXTPA78180", -1 }, /* 54*/ { BARCODE_VIN, -1, -1, "1FTCR10UXTPA78180", -1, "1FTCR10UXTPA78180", -1, "", -1 },
/* 55*/ { BARCODE_VIN, -1, BARCODE_RAW_TEXT, "1FTCR10UXTPA78180", -1, "1FTCR10UXTPA78180", -1 }, /* 55*/ { BARCODE_VIN, -1, BARCODE_RAW_TEXT, "1FTCR10UXTPA78180", -1, "1FTCR10UXTPA78180", -1, "1FTCR10UXTPA78180", -1 },
/* 56*/ { BARCODE_VIN, 1, -1, "2FTPX28L0XCA15511", -1, "2FTPX28L0XCA15511", -1 }, /* Include Import char - no change */ /* 56*/ { BARCODE_VIN, 1, -1, "2FTPX28L0XCA15511", -1, "2FTPX28L0XCA15511", -1, "", -1 }, /* Include Import char - no change in HRT */
/* 57*/ { BARCODE_VIN, 1, BARCODE_RAW_TEXT, "2FTPX28L0XCA15511", -1, "I2FTPX28L0XCA15511", -1 }, /* Unless BARCODE_RAW_TEXT */ /* 57*/ { BARCODE_VIN, 1, BARCODE_RAW_TEXT, "2FTPX28L0XCA15511", -1, "2FTPX28L0XCA15511", -1, "I2FTPX28L0XCA15511", -1 }, /* Included in BARCODE_RAW_TEXT */
/* 58*/ { BARCODE_HIBC_39, -1, -1, "ABC1234", -1, "*+ABC1234+*", -1 }, /* 58*/ { BARCODE_HIBC_39, -1, -1, "ABC1234", -1, "*+ABC1234+*", -1, "", -1 },
/* 59*/ { BARCODE_HIBC_39, -1, BARCODE_RAW_TEXT, "ABC1234", -1, "+ABC1234+", -1 }, /* 59*/ { BARCODE_HIBC_39, -1, BARCODE_RAW_TEXT, "ABC1234", -1, "*+ABC1234+*", -1, "+ABC1234+", -1 },
/* 60*/ { BARCODE_HIBC_39, -1, -1, "abc1234", -1, "*+ABC1234+*", -1 }, /* Converts to upper */ /* 60*/ { BARCODE_HIBC_39, -1, -1, "abc1234", -1, "*+ABC1234+*", -1, "", -1 }, /* Converts to upper */
/* 61*/ { BARCODE_HIBC_39, -1, BARCODE_RAW_TEXT, "abc1234", -1, "+ABC1234+", -1 }, /* 61*/ { BARCODE_HIBC_39, -1, BARCODE_RAW_TEXT, "abc1234", -1, "*+ABC1234+*", -1, "+ABC1234+", -1 },
/* 62*/ { BARCODE_HIBC_39, -1, -1, "123456789", -1, "*+1234567890*", -1 }, /* 62*/ { BARCODE_HIBC_39, -1, -1, "123456789", -1, "*+1234567890*", -1, "", -1 },
/* 63*/ { BARCODE_HIBC_39, -1, BARCODE_RAW_TEXT, "123456789", -1, "+1234567890", -1 }, /* 63*/ { BARCODE_HIBC_39, -1, BARCODE_RAW_TEXT, "123456789", -1, "*+1234567890*", -1, "+1234567890", -1 },
}; };
const int data_size = ARRAY_SIZE(data); const int data_size = ARRAY_SIZE(data);
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
int expected_length; int expected_length, expected_raw_length;
testStartSymbol("test_hrt", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -203,6 +205,7 @@ static void test_hrt(const testCtx *const p_ctx) {
-1 /*option_1*/, data[i].option_2, -1 /*option_3*/, data[i].output_options, -1 /*option_1*/, data[i].option_2, -1 /*option_3*/, data[i].output_options,
data[i].data, data[i].length, debug); data[i].data, data[i].length, debug);
expected_length = data[i].expected_length == -1 ? (int) strlen(data[i].expected) : data[i].expected_length; expected_length = data[i].expected_length == -1 ? (int) strlen(data[i].expected) : data[i].expected_length;
expected_raw_length = data[i].expected_raw_length == -1 ? (int) strlen(data[i].expected_raw) : data[i].expected_raw_length;
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt); assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
@ -211,6 +214,19 @@ static void test_hrt(const testCtx *const p_ctx) {
i, symbol->text_length, expected_length); i, symbol->text_length, expected_length);
assert_zero(memcmp(symbol->text, data[i].expected, expected_length), "i:%d memcmp(%s, %s, %d) != 0\n", assert_zero(memcmp(symbol->text, data[i].expected, expected_length), "i:%d memcmp(%s, %s, %d) != 0\n",
i, symbol->text, data[i].expected, expected_length); i, symbol->text, data[i].expected, expected_length);
if (symbol->output_options & BARCODE_RAW_TEXT) {
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
assert_nonnull(symbol->raw_segs[0].source, "i:%d raw_segs[0].source NULL\n", i);
assert_equal(symbol->raw_segs[0].length, expected_raw_length,
"i:%d raw_segs[0].length %d != expected_raw_length %d\n",
i, symbol->raw_segs[0].length, expected_raw_length);
assert_zero(memcmp(symbol->raw_segs[0].source, data[i].expected_raw, expected_raw_length),
"i:%d memcmp(%.*s, %.*s, %d) != 0\n",
i, symbol->raw_segs[0].length, symbol->raw_segs[0].source, expected_raw_length,
data[i].expected_raw, expected_raw_length);
} else {
assert_null(symbol->raw_segs, "i:%d raw_segs not NULL\n", i);
}
ZBarcode_Delete(symbol); ZBarcode_Delete(symbol);
} }
@ -293,7 +309,7 @@ static void test_input(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_input", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -453,10 +469,11 @@ static void test_encode(const testCtx *const p_ctx) {
char cmp_buf[8192]; char cmp_buf[8192];
char cmp_msg[1024]; char cmp_msg[1024];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ /* Only do BWIPP/ZXing-C++ tests if asked, too slow otherwise */
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript();
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder();
testStartSymbol("test_encode", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -497,13 +514,18 @@ static void test_encode(const testCtx *const p_ctx) {
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) { if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) {
int cmp_len, ret_len; int cmp_len, ret_len;
char modules_dump[8192 + 1]; char modules_dump[8192 + 1];
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1,
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); "i:%d testUtilModulesDump == -1\n", i);
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, 1 /*zxingcpp_cmp*/, cmp_buf,
sizeof(cmp_buf), &cmp_len);
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n",
i, testUtilBarcodeName(symbol->symbology), ret);
ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len); ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length,
NULL /*primary*/, escaped, &ret_len);
assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n",
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, escaped); i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len,
escaped);
} }
} }
} }

View file

@ -200,7 +200,7 @@ static void test_large(const testCtx *const p_ctx) {
char data_buf[4096]; char data_buf[4096];
testStartSymbol("test_large", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -294,7 +294,7 @@ static void test_input(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_input", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -2901,7 +2901,7 @@ static void test_encode(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
testStartSymbol("test_encode", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -3290,7 +3290,7 @@ static void test_encode_segs(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
testStartSymbol("test_encode_segs", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -3363,6 +3363,183 @@ static void test_encode_segs(const testCtx *const p_ctx) {
testFinish(); testFinish();
} }
static void test_rt(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
int input_mode;
int eci;
int option_2;
int output_options;
const char *data;
int length;
int ret;
int expected_eci;
const char *expected;
int expected_length;
int expected_raw_eci;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, -1, -1, "é", -1, 0, 0, "", -1, 0 },
/* 1*/ { UNICODE_MODE, -1, -1, BARCODE_RAW_TEXT, "é", -1, 0, 0, "\351", -1, 3 },
/* 2*/ { UNICODE_MODE, -1, -1, -1, "", -1, ZINT_WARN_USES_ECI, 13, "", -1, 0 },
/* 3*/ { UNICODE_MODE, -1, -1, BARCODE_RAW_TEXT, "", -1, ZINT_WARN_USES_ECI, 13, "\241", -1, 13 },
/* 4*/ { DATA_MODE, -1, -1, -1, "\351", -1, 0, 0, "", -1, 0 },
/* 5*/ { DATA_MODE, -1, -1, BARCODE_RAW_TEXT, "\351", -1, 0, 0, "\351", -1, 3 },
/* 6*/ { UNICODE_MODE, 26, -1, -1, "é", -1, 0, 26, "", -1, 0 },
/* 7*/ { UNICODE_MODE, 26, -1, BARCODE_RAW_TEXT, "é", -1, 0, 26, "é", -1, 26 },
/* 8*/ { UNICODE_MODE, 899, -1, -1, "é", -1, 0, 899, "", -1, 0 },
/* 9*/ { UNICODE_MODE, 899, -1, BARCODE_RAW_TEXT, "é", -1, 0, 899, "é", -1, 899 },
/* 10*/ { GS1_MODE, -1, -1, -1, "[01]04912345123459[15]970331[30]128[10]ABC123", -1, 0, 0, "", -1, 0 },
/* 11*/ { GS1_MODE, -1, -1, BARCODE_RAW_TEXT, "[01]04912345123459[15]970331[30]128[10]ABC123", -1, 0, 0, "01049123451234591597033130128\03510ABC123", -1, 3 },
/* 12*/ { UNICODE_MODE, -1, 9, -1, "12345", -1, 0, 0, "", -1, 0 }, /* Version S */
/* 13*/ { UNICODE_MODE, -1, 9, BARCODE_RAW_TEXT, "12345", -1, 0, 0, "12345", -1, 3 },
};
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
int expected_length;
char escaped[4096];
char escaped2[4096];
testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) {
if (testContinue(p_ctx, i)) continue;
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
length = testUtilSetSymbol(symbol, BARCODE_CODEONE, data[i].input_mode, data[i].eci,
-1 /*option_1*/, data[i].option_2, -1 /*option_3*/, data[i].output_options,
data[i].data, data[i].length, debug);
expected_length = data[i].expected_length == -1 ? (int) strlen(data[i].expected) : data[i].expected_length;
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n",
i, ret, data[i].ret, symbol->errtxt);
if (ret < ZINT_ERROR) {
assert_equal(symbol->eci, data[i].expected_eci, "i:%d eci %d != %d\n",
i, symbol->eci, data[i].expected_eci);
if (symbol->output_options & BARCODE_RAW_TEXT) {
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
assert_nonnull(symbol->raw_segs[0].source, "i:%d raw_segs[0].source NULL\n", i);
assert_equal(symbol->raw_segs[0].length, expected_length,
"i:%d raw_segs[0].length %d != expected_length %d\n",
i, symbol->raw_segs[0].length, expected_length);
assert_zero(memcmp(symbol->raw_segs[0].source, data[i].expected, expected_length),
"i:%d raw_segs[0].source memcmp(%s, %s, %d) != 0\n", i,
testUtilEscape((const char *) symbol->raw_segs[0].source, symbol->raw_segs[0].length,
escaped, sizeof(escaped)),
testUtilEscape(data[i].expected, expected_length, escaped2, sizeof(escaped2)),
expected_length);
assert_equal(symbol->raw_segs[0].eci, data[i].expected_raw_eci,
"i:%d raw_segs[0].eci %d != expected_raw_eci %d\n",
i, symbol->raw_segs[0].eci, data[i].expected_raw_eci);
} else {
assert_null(symbol->raw_segs, "i:%d raw_segs not NULL\n", i);
}
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_rt_segs(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
int input_mode;
int output_options;
struct zint_seg segs[3];
int ret;
int expected_rows;
int expected_width;
struct zint_seg expected_raw_segs[3];
int expected_raw_seg_count;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, { { TU(""), -1, 0 }, { TU("Ж"), -1, 7 }, {0} }, 0, 16, 18, {{0}}, 0 },
/* 1*/ { UNICODE_MODE, BARCODE_RAW_TEXT, { { TU(""), -1, 0 }, { TU("Ж"), -1, 7 }, { TU(""), 0, 0 } }, 0, 16, 18, { { TU("\266"), 1, 3 }, { TU("\266"), 1, 7 }, {0} }, 2 },
/* 2*/ { UNICODE_MODE, -1, { { TU("éé"), -1, 0 }, { TU("กขฯ"), -1, 0 }, { TU("βββ"), -1, 0 } }, ZINT_WARN_USES_ECI, 28, 32, {{0}}, 0 },
/* 3*/ { UNICODE_MODE, BARCODE_RAW_TEXT, { { TU("éé"), -1, 0 }, { TU("กขฯ"), -1, 0 }, { TU("βββ"), -1, 0 } }, ZINT_WARN_USES_ECI, 28, 32, { { TU("\351\351"), 2, 3 }, { TU("\241\242\317"), 3, 13 }, { TU("\342\342\342"), 3, 9 } }, 3 },
/* 4*/ { DATA_MODE, -1, { { TU(""), -1, 26 }, { TU("Ж"), -1, 0 }, { TU("\223\137"), -1, 20 } }, 0, 28, 32, {{0}}, 0 },
/* 5*/ { DATA_MODE, BARCODE_RAW_TEXT, { { TU(""), -1, 26 }, { TU("Ж"), -1, 0 }, { TU("\223\137"), -1, 20 } }, 0, 28, 32, { { TU(""), 2, 26 }, { TU("\320\226"), 2, 3 }, { TU("\223\137"), 2, 20 } }, 3 },
};
const int data_size = ARRAY_SIZE(data);
int i, j, seg_count, ret;
struct zint_symbol *symbol = NULL;
int expected_length;
char escaped[4096];
char escaped2[4096];
testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) {
if (testContinue(p_ctx, i)) continue;
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
testUtilSetSymbol(symbol, BARCODE_CODEONE, data[i].input_mode, -1 /*eci*/,
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options,
NULL, 0, debug);
for (j = 0, seg_count = 0; j < 3 && data[i].segs[j].length; j++, seg_count++);
ret = ZBarcode_Encode_Segs(symbol, data[i].segs, seg_count);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode_Segs ret %d != %d (%s)\n",
i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (width %d)\n",
i, symbol->rows, data[i].expected_rows, symbol->width);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n",
i, symbol->width, data[i].expected_width);
assert_equal(symbol->raw_seg_count, data[i].expected_raw_seg_count, "i:%d symbol->raw_seg_count %d != %d\n",
i, symbol->raw_seg_count, data[i].expected_raw_seg_count);
if (symbol->output_options & BARCODE_RAW_TEXT) {
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
for (j = 0; j < symbol->raw_seg_count; j++) {
assert_nonnull(symbol->raw_segs[j].source, "i:%d raw_segs[%d].source NULL\n", i, j);
expected_length = data[i].expected_raw_segs[j].length;
assert_equal(symbol->raw_segs[j].length, expected_length,
"i:%d raw_segs[%d].length %d != expected_length %d\n",
i, j, symbol->raw_segs[j].length, expected_length);
assert_zero(memcmp(symbol->raw_segs[j].source, data[i].expected_raw_segs[j].source, expected_length),
"i:%d raw_segs[%d].source memcmp(%s, %s, %d) != 0\n", i, j,
testUtilEscape((const char *) symbol->raw_segs[j].source, expected_length, escaped,
sizeof(escaped)),
testUtilEscape((const char *) data[i].expected_raw_segs[j].source, expected_length,
escaped2, sizeof(escaped2)),
expected_length);
assert_equal(symbol->raw_segs[j].eci, data[i].expected_raw_segs[j].eci,
"i:%d raw_segs[%d].eci %d != expected_raw_segs.eci %d\n",
i, j, symbol->raw_segs[j].eci, data[i].expected_raw_segs[j].eci);
}
} else {
assert_null(symbol->raw_segs, "i:%d raw_segs not NULL\n", i);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_fuzz(const testCtx *const p_ctx) { static void test_fuzz(const testCtx *const p_ctx) {
int debug = p_ctx->debug; int debug = p_ctx->debug;
@ -3392,7 +3569,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
testStartSymbol("test_fuzz", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -3436,6 +3613,8 @@ int main(int argc, char *argv[]) {
{ "test_input", test_input }, { "test_input", test_input },
{ "test_encode", test_encode }, { "test_encode", test_encode },
{ "test_encode_segs", test_encode_segs }, { "test_encode_segs", test_encode_segs },
{ "test_rt", test_rt },
{ "test_rt_segs", test_rt_segs },
{ "test_fuzz", test_fuzz }, { "test_fuzz", test_fuzz },
}; };

View file

@ -57,7 +57,7 @@ static void test_large(const testCtx *const p_ctx) {
char data_buf[4096] = {0}; /* Suppress clang -fsanitize=memory false positive */ char data_buf[4096] = {0}; /* Suppress clang -fsanitize=memory false positive */
testStartSymbol("test_large", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -115,7 +115,7 @@ static void test_hrt(const testCtx *const p_ctx) {
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
int expected_length; int expected_length;
testStartSymbol("test_hrt", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -136,6 +136,18 @@ static void test_hrt(const testCtx *const p_ctx) {
i, symbol->text_length, expected_length); i, symbol->text_length, expected_length);
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
i, symbol->text, data[i].expected); i, symbol->text, data[i].expected);
if (symbol->output_options & BARCODE_RAW_TEXT) {
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
assert_nonnull(symbol->raw_segs[0].source, "i:%d raw_segs[0].source NULL\n", i);
assert_equal(symbol->raw_segs[0].length, expected_length,
"i:%d raw_segs[0].length %d != expected_length %d\n",
i, symbol->raw_segs[0].length, expected_length);
assert_zero(memcmp(symbol->raw_segs[0].source, data[i].expected, expected_length),
"i:%d memcmp(%s, %s, %d) != 0\n",
i, symbol->raw_segs[0].source, data[i].expected, expected_length);
} else {
assert_null(symbol->raw_segs, "i:%d raw_segs not NULL\n", i);
}
ZBarcode_Delete(symbol); ZBarcode_Delete(symbol);
} }
@ -173,7 +185,7 @@ static void test_input(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_input", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -243,10 +255,11 @@ static void test_encode(const testCtx *const p_ctx) {
char cmp_buf[8192]; char cmp_buf[8192];
char cmp_msg[1024]; char cmp_msg[1024];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ /* Only do BWIPP/ZXing-C++ tests if asked, too slow otherwise */
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript();
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder();
testStartSymbol("test_encode", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -288,12 +301,15 @@ static void test_encode(const testCtx *const p_ctx) {
int cmp_len, ret_len; int cmp_len, ret_len;
char modules_dump[8192 + 1]; char modules_dump[8192 + 1];
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i);
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, 1 /*zxingcpp_cmp*/, cmp_buf,
sizeof(cmp_buf), &cmp_len);
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len); ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length,
NULL /*primary*/, escaped, &ret_len);
assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n",
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, escaped); i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len,
escaped);
} }
} }
} }

File diff suppressed because it is too large Load diff

View file

@ -62,7 +62,7 @@ static void test_large(const testCtx *const p_ctx) {
char data_buf[4096]; char data_buf[4096];
testStartSymbol("test_large", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -117,7 +117,7 @@ static void test_reader_init(const testCtx *const p_ctx) {
char escaped[1024]; char escaped[1024];
testStartSymbol("test_reader_init", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -166,6 +166,7 @@ static void test_input(const testCtx *const p_ctx) {
int expected_rows; int expected_rows;
int expected_width; int expected_width;
int bwipp_cmp; int bwipp_cmp;
int zxingcpp_cmp;
const char *expected; const char *expected;
int expected_option_1; int expected_option_1;
int expected_option_3; int expected_option_3;
@ -181,53 +182,53 @@ static void test_input(const testCtx *const p_ctx) {
é U+00E9 (\351, 233), UTF-8 C3A9, CodeB-only extended ASCII é U+00E9 (\351, 233), UTF-8 C3A9, CodeB-only extended ASCII
*/ */
static const struct item data[] = { static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, -1, 0, "\037", -1, 0, 2, 70, 1, "(10) 0 95 103 103 103 103 103 103 22 42", 2, 0, "ModeA US Pad (6)" }, /* 0*/ { UNICODE_MODE, -1, -1, 0, "\037", -1, 0, 2, 70, 1, 1, "(10) 0 95 103 103 103 103 103 103 22 42", 2, 0, "ModeA US Pad (6)" },
/* 1*/ { UNICODE_MODE, -1, -1, 0, "A", -1, 0, 2, 70, 1, "(10) 1 33 103 103 103 103 103 103 52 82", 2, 0, "ModeB A Pad (6)" }, /* 1*/ { UNICODE_MODE, -1, -1, 0, "A", -1, 0, 2, 70, 1, 1, "(10) 1 33 103 103 103 103 103 103 52 82", 2, 0, "ModeB A Pad (6)" },
/* 2*/ { UNICODE_MODE, -1, -1, 0, "12", -1, 0, 2, 70, 1, "(10) 2 12 103 103 103 103 103 103 98 27", 2, 0, "ModeC 12 Pad (6)" }, /* 2*/ { UNICODE_MODE, -1, -1, 0, "12", -1, 0, 2, 70, 1, 1, "(10) 2 12 103 103 103 103 103 103 98 27", 2, 0, "ModeC 12 Pad (6)" },
/* 3*/ { GS1_MODE, -1, -1, 0, "[90]A", -1, 0, 2, 70, 1, "(10) 3 25 16 33 103 103 103 103 83 20", 2, 0, "ModeBFNC1 9 0 A Pad (4)" }, /* 3*/ { GS1_MODE, -1, -1, 0, "[90]A", -1, 0, 2, 70, 1, 1, "(10) 3 25 16 33 103 103 103 103 83 20", 2, 0, "ModeBFNC1 9 0 A Pad (4)" },
/* 4*/ { GS1_MODE, -1, -1, 0, "[90]12", -1, 0, 2, 70, 1, "(10) 4 90 12 103 103 103 103 103 79 62", 2, 0, "ModeCFNC1 90 12 Pad (5)" }, /* 4*/ { GS1_MODE, -1, -1, 0, "[90]12", -1, 0, 2, 70, 1, 1, "(10) 4 90 12 103 103 103 103 103 79 62", 2, 0, "ModeCFNC1 90 12 Pad (5)" },
/* 5*/ { GS1_MODE, -1, -1, 0, "[90]12[20]12", -1, 0, 2, 70, 1, "(10) 4 90 12 102 20 12 103 103 9 72", 2, 0, "ModeCFNC1 90 12 FNC1 20 12 Pad (2)" }, /* 5*/ { GS1_MODE, -1, -1, 0, "[90]12[20]12", -1, 0, 2, 70, 1, 1, "(10) 4 90 12 102 20 12 103 103 9 72", 2, 0, "ModeCFNC1 90 12 FNC1 20 12 Pad (2)" },
/* 6*/ { GS1_MODE, -1, -1, 0, "[90]123[20]12", -1, 0, 3, 70, 1, "(15) 11 90 12 100 19 99 102 20 12 103 103 103 103 102 11", 3, 0, "ModeCFNC1 90 CodeB 3 CodeC FNC1 20 12 Pad (4)" }, /* 6*/ { GS1_MODE, -1, -1, 0, "[90]123[20]12", -1, 0, 3, 70, 1, 1, "(15) 11 90 12 100 19 99 102 20 12 103 103 103 103 102 11", 3, 0, "ModeCFNC1 90 CodeB 3 CodeC FNC1 20 12 Pad (4)" },
/* 7*/ { GS1_MODE, -1, -1, 0, "[90]123[91]1A3[20]12", -1, 0, 4, 70, 1, "(20) 18 90 12 100 19 102 25 99 11 100 33 19 99 102 20 12 103 103 0 3", 4, 0, "ModeCFNC1 90 12 CodeB 3 FNC1 9 CodeC 11 CodeB A 3 CodeC FNC1 20 12 Pad (2)" }, /* 7*/ { GS1_MODE, -1, -1, 0, "[90]123[91]1A3[20]12", -1, 0, 4, 70, 1, 1, "(20) 18 90 12 100 19 102 25 99 11 100 33 19 99 102 20 12 103 103 0 3", 4, 0, "ModeCFNC1 90 12 CodeB 3 FNC1 9 CodeC 11 CodeB A 3 CodeC FNC1 20 12 Pad (2)" },
/* 8*/ { GS1_MODE, -1, -1, 0, "[90]123A[91]123", -1, 0, 3, 70, 1, "(15) 11 90 12 100 19 33 102 25 99 11 23 103 103 81 56", 3, 0, "ModeCFNC1 90 12 CodeB 3 A FNC1 9 CodeC 11 23 Pad (2)" }, /* 8*/ { GS1_MODE, -1, -1, 0, "[90]123A[91]123", -1, 0, 3, 70, 1, 1, "(15) 11 90 12 100 19 33 102 25 99 11 23 103 103 81 56", 3, 0, "ModeCFNC1 90 12 CodeB 3 A FNC1 9 CodeC 11 23 Pad (2)" },
/* 9*/ { GS1_MODE | GS1PARENS_MODE, -1, -1, 0, "(90)12", -1, 0, 2, 70, 1, "(10) 4 90 12 103 103 103 103 103 79 62", 2, 0, "ModeCFNC1 90 12 Pad (5)" }, /* 9*/ { GS1_MODE | GS1PARENS_MODE, -1, -1, 0, "(90)12", -1, 0, 2, 70, 1, 1, "(10) 4 90 12 103 103 103 103 103 79 62", 2, 0, "ModeCFNC1 90 12 Pad (5)" },
/* 10*/ { UNICODE_MODE, -1, -1, 0, "a0123456789", -1, 0, 2, 70, 1, "(10) 5 65 1 23 45 67 89 103 27 86", 2, 0, "ModeC1SB a 01 23 45 67 89 Pad" }, /* 10*/ { UNICODE_MODE, -1, -1, 0, "a0123456789", -1, 0, 2, 70, 1, 1, "(10) 5 65 1 23 45 67 89 103 27 86", 2, 0, "ModeC1SB a 01 23 45 67 89 Pad" },
/* 11*/ { UNICODE_MODE, -1, -1, 0, "ab0123456789", -1, 0, 2, 70, 1, "(10) 6 65 66 1 23 45 67 89 19 42", 2, 0, "ModeC2SB a b 01 23 45 67 89" }, /* 11*/ { UNICODE_MODE, -1, -1, 0, "ab0123456789", -1, 0, 2, 70, 1, 1, "(10) 6 65 66 1 23 45 67 89 19 42", 2, 0, "ModeC2SB a b 01 23 45 67 89" },
/* 12*/ { UNICODE_MODE, -1, -1, 0, "1234\037a", -1, 0, 2, 70, 0, "(10) 2 12 34 101 95 98 65 103 67 53", 2, 0, "ModeC 12 34 CodeA US 1SB a Pad; BWIPP different encodation, CodeB instead of 1SB" }, /* 12*/ { UNICODE_MODE, -1, -1, 0, "1234\037a", -1, 0, 2, 70, 0, 1, "(10) 2 12 34 101 95 98 65 103 67 53", 2, 0, "ModeC 12 34 CodeA US 1SB a Pad; BWIPP different encodation, CodeB instead of 1SB" },
/* 13*/ { UNICODE_MODE, -1, -1, 0, "\000\037ß", 4, 0, 2, 70, 1, "(10) 0 64 95 101 63 103 103 103 75 11", 2, 0, "ModeA NUL US FNC4 ß Pad (3)" }, /* 13*/ { UNICODE_MODE, -1, -1, 0, "\000\037ß", 4, 0, 2, 70, 1, 1, "(10) 0 64 95 101 63 103 103 103 75 11", 2, 0, "ModeA NUL US FNC4 ß Pad (3)" },
/* 14*/ { UNICODE_MODE, -1, -1, 0, "\000\037é", 4, 0, 2, 70, 0, "(10) 0 64 95 101 98 73 103 103 75 6", 2, 0, "ModeA NUL US FNC4 1SB é Pad (2); BWIPP different encodation, CodeB instead of 1SB" }, /* 14*/ { UNICODE_MODE, -1, -1, 0, "\000\037é", 4, 0, 2, 70, 0, 1, "(10) 0 64 95 101 98 73 103 103 75 6", 2, 0, "ModeA NUL US FNC4 1SB é Pad (2); BWIPP different encodation, CodeB instead of 1SB" },
/* 15*/ { UNICODE_MODE, -1, -1, 0, "\000\037éa", 5, 0, 2, 70, 0, "(10) 0 64 95 100 100 73 65 103 99 69", 2, 0, "ModeA NUL US CodeB FNC4 é a Pad; BWIPP different encodation, FNC4 before CodeB" }, /* 15*/ { UNICODE_MODE, -1, -1, 0, "\000\037éa", 5, 0, 2, 70, 0, 1, "(10) 0 64 95 100 100 73 65 103 99 69", 2, 0, "ModeA NUL US CodeB FNC4 é a Pad; BWIPP different encodation, FNC4 before CodeB" },
/* 16*/ { UNICODE_MODE, -1, -1, 0, "abß", -1, 0, 2, 70, 1, "(10) 1 65 66 100 63 103 103 103 66 56", 2, 0, "ModeB a b FNC4 ß Pad (3)" }, /* 16*/ { UNICODE_MODE, -1, -1, 0, "abß", -1, 0, 2, 70, 1, 1, "(10) 1 65 66 100 63 103 103 103 66 56", 2, 0, "ModeB a b FNC4 ß Pad (3)" },
/* 17*/ { DATA_MODE, -1, -1, 0, "\141\142\237", -1, 0, 2, 70, 0, "(10) 1 65 66 100 98 95 103 103 6 71", 2, 0, "ModeB a b FNC4 1SA APC Pad (2); BWIPP different encodation, CodeA instead of 1SA" }, /* 17*/ { DATA_MODE, -1, -1, 0, "\141\142\237", -1, 0, 2, 70, 0, 899, "(10) 1 65 66 100 98 95 103 103 6 71", 2, 0, "ModeB a b FNC4 1SA APC Pad (2); BWIPP different encodation, CodeA instead of 1SA" },
/* 18*/ { DATA_MODE, -1, -1, 0, "\141\142\237\037", -1, 0, 2, 70, 0, "(10) 1 65 66 101 101 95 95 103 72 93", 2, 0, "ModeB a b CodeA FNC4 APC US Pad; BWIPP different encodation, FNC4 before CodeA" }, /* 18*/ { DATA_MODE, -1, -1, 0, "\141\142\237\037", -1, 0, 2, 70, 0, 899, "(10) 1 65 66 101 101 95 95 103 72 93", 2, 0, "ModeB a b CodeA FNC4 APC US Pad; BWIPP different encodation, FNC4 before CodeA" },
/* 19*/ { UNICODE_MODE, -1, -1, 0, "ééé", -1, 0, 2, 70, 0, "(10) 1 100 73 100 73 100 73 103 105 106", 2, 0, "ModeB FNC4 é FNC4 é FNC4 é Pad; BWIPP different encodation, uses double FNC4 latch" }, /* 19*/ { UNICODE_MODE, -1, -1, 0, "ééé", -1, 0, 2, 70, 0, 1, "(10) 1 100 73 100 73 100 73 103 105 106", 2, 0, "ModeB FNC4 é FNC4 é FNC4 é Pad; BWIPP different encodation, uses double FNC4 latch" },
/* 20*/ { UNICODE_MODE, -1, -1, 0, "aééééb", -1, 0, 3, 70, 1, "(15) 8 65 100 73 100 73 100 73 100 73 66 103 103 39 83", 3, 0, "ModeB a FNC4 é (4) b Pad (2)" }, /* 20*/ { UNICODE_MODE, -1, -1, 0, "aééééb", -1, 0, 3, 70, 1, 1, "(15) 8 65 100 73 100 73 100 73 100 73 66 103 103 39 83", 3, 0, "ModeB a FNC4 é (4) b Pad (2)" },
/* 21*/ { UNICODE_MODE, -1, -1, 0, "aéééééb", -1, 0, 3, 70, 0, "(15) 8 65 100 73 100 73 100 73 100 73 100 73 66 74 106", 3, 0, "ModeB a FNC4 é (5) b; BWIPP different encodation, uses double FNC4 latch" }, /* 21*/ { UNICODE_MODE, -1, -1, 0, "aéééééb", -1, 0, 3, 70, 0, 1, "(15) 8 65 100 73 100 73 100 73 100 73 100 73 66 74 106", 3, 0, "ModeB a FNC4 é (5) b; BWIPP different encodation, uses double FNC4 latch" },
/* 22*/ { UNICODE_MODE, -1, -1, 0, "aééééébcdeé", -1, 0, 4, 70, 0, "(20) 15 65 100 73 100 73 100 73 100 73 100 73 66 67 68 69 100 73 14 69", 4, 0, "ModeB a FNC4 é (5) b c d e FNC4 é; BWIPP different encodation, uses double FNC4 latch then FNC4 escapes" }, /* 22*/ { UNICODE_MODE, -1, -1, 0, "aééééébcdeé", -1, 0, 4, 70, 0, 1, "(20) 15 65 100 73 100 73 100 73 100 73 100 73 66 67 68 69 100 73 14 69", 4, 0, "ModeB a FNC4 é (5) b c d e FNC4 é; BWIPP different encodation, uses double FNC4 latch then FNC4 escapes" },
/* 23*/ { UNICODE_MODE, -1, -1, 0, "123456789012345678901234", -1, 0, 3, 70, 1, "(15) 9 12 34 56 78 90 12 34 56 78 90 12 34 71 42", 3, 0, "3 rows" }, /* 23*/ { UNICODE_MODE, -1, -1, 0, "123456789012345678901234", -1, 0, 3, 70, 1, 1, "(15) 9 12 34 56 78 90 12 34 56 78 90 12 34 71 42", 3, 0, "3 rows" },
/* 24*/ { UNICODE_MODE, -1, 2, 0, "123456789012345678901234", -1, 0, 3, 70, 0, "(15) 9 12 34 56 78 90 12 34 56 78 90 12 34 71 42", 3, 0, "Min 2 rows (no change); BWIPP doesn't support min rows < required" }, /* 24*/ { UNICODE_MODE, -1, 2, 0, "123456789012345678901234", -1, 0, 3, 70, 0, 1, "(15) 9 12 34 56 78 90 12 34 56 78 90 12 34 71 42", 3, 0, "Min 2 rows (no change); BWIPP doesn't support min rows < required" },
/* 25*/ { UNICODE_MODE, -1, 3, 0, "123456789012345678901234", -1, 0, 3, 70, 1, "(15) 9 12 34 56 78 90 12 34 56 78 90 12 34 71 42", 3, 0, "Min 3 rows (no change)" }, /* 25*/ { UNICODE_MODE, -1, 3, 0, "123456789012345678901234", -1, 0, 3, 70, 1, 1, "(15) 9 12 34 56 78 90 12 34 56 78 90 12 34 71 42", 3, 0, "Min 3 rows (no change)" },
/* 26*/ { UNICODE_MODE, -1, 4, 0, "123456789012345678901234", -1, 0, 4, 70, 1, "(20) 16 12 34 56 78 90 12 34 56 78 90 12 34 103 103 103 103 103 66 96", 4, 0, "Min 4 rows" }, /* 26*/ { UNICODE_MODE, -1, 4, 0, "123456789012345678901234", -1, 0, 4, 70, 1, 1, "(20) 16 12 34 56 78 90 12 34 56 78 90 12 34 103 103 103 103 103 66 96", 4, 0, "Min 4 rows" },
/* 27*/ { UNICODE_MODE, -1, 5, 0, "123456789012345678901234", -1, 0, 5, 70, 1, "(25) 23 12 34 56 78 90 12 34 56 78 90 12 34 103 103 103 103 103 103 103 103 103 103 68 61", 5, 0, "Min 5 rows" }, /* 27*/ { UNICODE_MODE, -1, 5, 0, "123456789012345678901234", -1, 0, 5, 70, 1, 1, "(25) 23 12 34 56 78 90 12 34 56 78 90 12 34 103 103 103 103 103 103 103 103 103 103 68 61", 5, 0, "Min 5 rows" },
/* 28*/ { UNICODE_MODE, -1, 16, 0, "123456789012345678901234", -1, 0, 16, 70, 1, "(80) 100 12 34 56 78 90 12 34 56 78 90 12 34 103 103 103 103 103 103 103 103 103 103 103", 16, 0, "Min 16 rows" }, /* 28*/ { UNICODE_MODE, -1, 16, 0, "123456789012345678901234", -1, 0, 16, 70, 1, 1, "(80) 100 12 34 56 78 90 12 34 56 78 90 12 34 103 103 103 103 103 103 103 103 103 103 103", 16, 0, "Min 16 rows" },
/* 29*/ { UNICODE_MODE, -1, 1, 0, "123456789012345678901234", -1, ZINT_ERROR_INVALID_OPTION, -1, -1, 1, "Error 424: Minimum number of rows '1' out of range (2 to 16)", 1, 0, "" }, /* 29*/ { UNICODE_MODE, -1, 1, 0, "123456789012345678901234", -1, ZINT_ERROR_INVALID_OPTION, -1, -1, 1, 1, "Error 424: Minimum number of rows '1' out of range (2 to 16)", 1, 0, "" },
/* 30*/ { UNICODE_MODE, -1, 17, 0, "123456789012345678901234", -1, ZINT_ERROR_INVALID_OPTION, -1, -1, 1, "Error 424: Minimum number of rows '17' out of range (2 to 16)", 17, 0, "" }, /* 30*/ { UNICODE_MODE, -1, 17, 0, "123456789012345678901234", -1, ZINT_ERROR_INVALID_OPTION, -1, -1, 1, 1, "Error 424: Minimum number of rows '17' out of range (2 to 16)", 17, 0, "" },
/* 31*/ { UNICODE_MODE, -1, -1, 0, "ÁÁÁÁÁÁ99999999999999Á", -1, 0, 6, 70, 0, "(30) 29 100 33 100 33 100 33 100 33 100 33 100 33 99 99 99 99 99 99 99 99 100 100 33 103", 6, 0, "BWIPP different encodation, uses double FNC4 latch" }, /* 31*/ { UNICODE_MODE, -1, -1, 0, "ÁÁÁÁÁÁ99999999999999Á", -1, 0, 6, 70, 0, 1, "(30) 29 100 33 100 33 100 33 100 33 100 33 100 33 99 99 99 99 99 99 99 99 100 100 33 103", 6, 0, "BWIPP different encodation, uses double FNC4 latch" },
/* 32*/ { UNICODE_MODE, -1, -1, 0, "ÿ\012àa\0121\012àAà", -1, 0, 4, 70, 0, "(20) 15 100 95 98 74 100 64 65 98 74 17 98 74 100 64 33 100 64 47 35", 4, 0, "BWIPP different encodation, uses CodeA instead of 1SA" }, /* 32*/ { UNICODE_MODE, -1, -1, 0, "ÿ\012àa\0121\012àAà", -1, 0, 4, 70, 0, 1, "(20) 15 100 95 98 74 100 64 65 98 74 17 98 74 100 64 33 100 64 47 35", 4, 0, "BWIPP different encodation, uses CodeA instead of 1SA" },
/* 33*/ { UNICODE_MODE, -1, -1, 0, "ÿ\012àa\0121\012àAà\012à", -1, 0, 5, 70, 0, "(25) 22 100 95 98 74 100 64 65 98 74 17 98 74 100 64 33 100 64 98 74 100 64 103 89 18", 5, 0, "BWIPP different encodation, uses CodeA instead of 1SA" }, /* 33*/ { UNICODE_MODE, -1, -1, 0, "ÿ\012àa\0121\012àAà\012à", -1, 0, 5, 70, 0, 1, "(25) 22 100 95 98 74 100 64 65 98 74 17 98 74 100 64 33 100 64 98 74 100 64 103 89 18", 5, 0, "BWIPP different encodation, uses CodeA instead of 1SA" },
/* 34*/ { UNICODE_MODE, -1, -1, 0, "y1234\012àa\0121\0127890àAàDà\012à", -1, 0, 7, 70, 0, "(35) 40 89 12 34 101 74 100 100 64 65 98 74 17 98 74 99 78 90 100 100 64 33 100 64 36 100", 7, 0, "BWIPP different encodation, uses Sh2B + other differences" }, /* 34*/ { UNICODE_MODE, -1, -1, 0, "y1234\012àa\0121\0127890àAàDà\012à", -1, 0, 7, 70, 0, 1, "(35) 40 89 12 34 101 74 100 100 64 65 98 74 17 98 74 99 78 90 100 100 64 33 100 64 36 100", 7, 0, "BWIPP different encodation, uses Sh2B + other differences" },
/* 35*/ { UNICODE_MODE, -1, -1, 0, "ÿ1234\012àa\0121\0127890àAàDà\012à", -1, 0, 7, 70, 0, "(35) 41 100 95 12 34 101 74 100 100 64 65 98 74 17 98 74 99 78 90 100 100 64 33 100 64 36", 7, 0, "BWIPP different encodation" }, /* 35*/ { UNICODE_MODE, -1, -1, 0, "ÿ1234\012àa\0121\0127890àAàDà\012à", -1, 0, 7, 70, 0, 1, "(35) 41 100 95 12 34 101 74 100 100 64 65 98 74 17 98 74 99 78 90 100 100 64 33 100 64 36", 7, 0, "BWIPP different encodation" },
/* 36*/ { UNICODE_MODE, -1, -1, 0, "yÿ1234\012àa\0121\0127890àAàDà\012à", -1, 0, 8, 70, 0, "(40) 43 89 100 95 99 12 34 101 74 100 100 64 65 98 74 17 98 74 99 78 90 100 100 64 33 100", 8, 0, "BWIPP different encodation (and fits in 7 rows)" }, /* 36*/ { UNICODE_MODE, -1, -1, 0, "yÿ1234\012àa\0121\0127890àAàDà\012à", -1, 0, 8, 70, 0, 1, "(40) 43 89 100 95 99 12 34 101 74 100 100 64 65 98 74 17 98 74 99 78 90 100 100 64 33 100", 8, 0, "BWIPP different encodation (and fits in 7 rows)" },
/* 37*/ { UNICODE_MODE, -1, -1, 0, "ÿy1234\012àa\0121\0127890àAàDà\012à", -1, 0, 8, 70, 0, "(40) 43 100 95 89 99 12 34 101 74 100 100 64 65 98 74 17 98 74 99 78 90 100 100 64 33 100", 8, 0, "BWIPP different encodation (and fits in 7 rows)" }, /* 37*/ { UNICODE_MODE, -1, -1, 0, "ÿy1234\012àa\0121\0127890àAàDà\012à", -1, 0, 8, 70, 0, 1, "(40) 43 100 95 89 99 12 34 101 74 100 100 64 65 98 74 17 98 74 99 78 90 100 100 64 33 100", 8, 0, "BWIPP different encodation (and fits in 7 rows)" },
/* 38*/ { UNICODE_MODE, -1, -1, 0, "ÿÿ1234\012àa\0121\0127890àAàDà\012à", -1, 0, 8, 70, 0, "(40) 43 100 95 100 95 99 12 34 101 74 100 100 64 65 98 74 17 98 74 99 78 90 100 100 64 33", 8, 0, "BWIPP different encodation (and fits in 7 rows)" }, /* 38*/ { UNICODE_MODE, -1, -1, 0, "ÿÿ1234\012àa\0121\0127890àAàDà\012à", -1, 0, 8, 70, 0, 1, "(40) 43 100 95 100 95 99 12 34 101 74 100 100 64 65 98 74 17 98 74 99 78 90 100 100 64 33", 8, 0, "BWIPP different encodation (and fits in 7 rows)" },
/* 39*/ { UNICODE_MODE, -1, -1, 0, "ÿ1234\012àa\0121\01223456\0127890àAàDà\012à", -1, 0, 8, 70, 0, "(40) 48 100 95 12 34 101 74 100 100 64 65 98 74 17 98 74 18 99 34 56 101 74 99 78 90 100", 8, 0, "BWIPP different encodation, uses Sh2B + other differences" }, /* 39*/ { UNICODE_MODE, -1, -1, 0, "ÿ1234\012àa\0121\01223456\0127890àAàDà\012à", -1, 0, 8, 70, 0, 1, "(40) 48 100 95 12 34 101 74 100 100 64 65 98 74 17 98 74 18 99 34 56 101 74 99 78 90 100", 8, 0, "BWIPP different encodation, uses Sh2B + other differences" },
/* 40*/ { UNICODE_MODE, -1, -1, 0, "ÿ1234\012à1234a\0121\01223456\0127890àAàDà\012à", -1, 0, 9, 70, 0, "(45) 55 100 95 12 34 101 74 101 98 64 99 12 34 100 65 98 74 17 98 74 18 99 34 56 101 74 99", 9, 0, "BWIPP different encodation, uses Sh2C + other differences" }, /* 40*/ { UNICODE_MODE, -1, -1, 0, "ÿ1234\012à1234a\0121\01223456\0127890àAàDà\012à", -1, 0, 9, 70, 0, 1, "(45) 55 100 95 12 34 101 74 101 98 64 99 12 34 100 65 98 74 17 98 74 18 99 34 56 101 74 99", 9, 0, "BWIPP different encodation, uses Sh2C + other differences" },
/* 41*/ { UNICODE_MODE, -1, -1, 0, "ÿ1234\012à1234ab\0121\01223456\012\0127890àAàBCDà\012\012à", -1, 0, 10, 70, 0, "(50) 62 100 95 12 34 101 74 101 98 64 99 12 34 100 65 66 98 74 17 98 74 18 99 34 56 101 74", 10, 0, "BWIPP different encodation, uses Sh2C + other differences" }, /* 41*/ { UNICODE_MODE, -1, -1, 0, "ÿ1234\012à1234ab\0121\01223456\012\0127890àAàBCDà\012\012à", -1, 0, 10, 70, 0, 1, "(50) 62 100 95 12 34 101 74 101 98 64 99 12 34 100 65 66 98 74 17 98 74 18 99 34 56 101 74", 10, 0, "BWIPP different encodation, uses Sh2C + other differences" },
/* 42*/ { UNICODE_MODE, -1, -1, 0, "ÿ123456\012à123456abcd\0121\01223456\012\0127890àAàBCDEà\012\012à", -1, 0, 11, 70, 0, "(55) 69 100 95 12 34 56 101 74 101 98 64 99 12 34 56 100 65 66 67 68 98 74 17 98 74 18 99", 11, 0, "BWIPP different encodation, uses Sh3C + other differences" }, /* 42*/ { UNICODE_MODE, -1, -1, 0, "ÿ123456\012à123456abcd\0121\01223456\012\0127890àAàBCDEà\012\012à", -1, 0, 11, 70, 0, 1, "(55) 69 100 95 12 34 56 101 74 101 98 64 99 12 34 56 100 65 66 67 68 98 74 17 98 74 18 99", 11, 0, "BWIPP different encodation, uses Sh3C + other differences" },
/* 43*/ { UNICODE_MODE, -1, -1, 0, "ÿ12345678\012à12345678abcdef\0121\01223456\012\0127890àAàBCDEFà\012\012à", -1, 0, 12, 70, 0, "(60) 76 100 95 12 34 56 78 101 74 101 98 64 99 12 34 56 78 100 65 66 67 68 69 70 98 74 17", 12, 0, "BWIPP different encodation, uses Sh2C + other differences" }, /* 43*/ { UNICODE_MODE, -1, -1, 0, "ÿ12345678\012à12345678abcdef\0121\01223456\012\0127890àAàBCDEFà\012\012à", -1, 0, 12, 70, 0, 1, "(60) 76 100 95 12 34 56 78 101 74 101 98 64 99 12 34 56 78 100 65 66 67 68 69 70 98 74 17", 12, 0, "BWIPP different encodation, uses Sh2C + other differences" },
/* 44*/ { UNICODE_MODE, COMPLIANT_HEIGHT, -1, 4, "A", -1, 0, 2, 70, 1, "(10) 1 33 103 103 103 103 103 103 52 82", 2, 4, "option_3 separator" }, /* 44*/ { UNICODE_MODE, COMPLIANT_HEIGHT, -1, 4, "A", -1, 0, 2, 70, 1, 1, "(10) 1 33 103 103 103 103 103 103 52 82", 2, 4, "option_3 separator" },
/* 45*/ { UNICODE_MODE, COMPLIANT_HEIGHT, -1, 5, "A", -1, 0, 2, 70, 1, "(10) 1 33 103 103 103 103 103 103 52 82", 2, 1, "option_3 invalid 5 -> 1" }, /* 45*/ { UNICODE_MODE, COMPLIANT_HEIGHT, -1, 5, "A", -1, 0, 2, 70, 1, 1, "(10) 1 33 103 103 103 103 103 103 52 82", 2, 1, "option_3 invalid 5 -> 1" },
/* 46*/ { UNICODE_MODE, -1, -1, 5, "A", -1, 0, 2, 70, 1, "(10) 1 33 103 103 103 103 103 103 52 82", 2, 5, "option_3 invalid 5 ignored unless COMPLIANT_HEIGHT" }, /* 46*/ { UNICODE_MODE, -1, -1, 5, "A", -1, 0, 2, 70, 1, 1, "(10) 1 33 103 103 103 103 103 103 52 82", 2, 5, "option_3 invalid 5 ignored unless COMPLIANT_HEIGHT" },
}; };
const int data_size = ARRAY_SIZE(data); const int data_size = ARRAY_SIZE(data);
int i, length, ret; int i, length, ret;
@ -237,10 +238,11 @@ static void test_input(const testCtx *const p_ctx) {
char cmp_buf[8192]; char cmp_buf[8192];
char cmp_msg[1024]; char cmp_msg[1024];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ /* Only do BWIPP/ZXing-C++ tests if asked, too slow otherwise */
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript();
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder();
testStartSymbol("test_input", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -259,12 +261,12 @@ static void test_input(const testCtx *const p_ctx) {
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) { if (p_ctx->generate) {
printf(" /*%3d*/ { %s, %s, %d, %d, \"%s\", %d, %s, %d, %d, %d, \"%s\", %d, %d, \"%s\" },\n", printf(" /*%3d*/ { %s, %s, %d, %d, \"%s\", %d, %s, %d, %d, %d, %d, \"%s\", %d, %d, \"%s\" },\n",
i, testUtilInputModeName(data[i].input_mode), testUtilOutputOptionsName(data[i].output_options), i, testUtilInputModeName(data[i].input_mode), testUtilOutputOptionsName(data[i].output_options),
data[i].option_1, data[i].option_3, data[i].option_1, data[i].option_3,
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length,
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp, testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp,
symbol->errtxt, symbol->option_1, symbol->option_3, data[i].comment); data[i].zxingcpp_cmp, symbol->errtxt, symbol->option_1, symbol->option_3, data[i].comment);
} else { } else {
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
if (ret < ZINT_ERROR) { if (ret < ZINT_ERROR) {
@ -288,13 +290,19 @@ static void test_input(const testCtx *const p_ctx) {
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) { if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) {
int cmp_len, ret_len; int cmp_len, ret_len;
char modules_dump[4096]; char modules_dump[4096];
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); assert_nonzero(data[i].zxingcpp_cmp, "i:%d data[i].zxingcpp_cmp == 0", i);
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1,
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); "i:%d testUtilModulesDump == -1\n", i);
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, data[i].zxingcpp_cmp,
cmp_buf, sizeof(cmp_buf), &cmp_len);
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n",
i, testUtilBarcodeName(symbol->symbology), ret);
ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len); ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length,
NULL /*primary*/, escaped, &ret_len);
assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n",
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, escaped); i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len,
escaped);
} }
} }
assert_equal(symbol->option_1, data[i].expected_option_1, "i:%d symbol->option_1 %d != %d\n", assert_equal(symbol->option_1, data[i].expected_option_1, "i:%d symbol->option_1 %d != %d\n",
@ -375,10 +383,11 @@ static void test_encode(const testCtx *const p_ctx) {
char cmp_buf[8192]; char cmp_buf[8192];
char cmp_msg[1024]; char cmp_msg[1024];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ /* Only do BWIPP/ZXing-C++ tests if asked, too slow otherwise */
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript();
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder();
testStartSymbol("test_encode", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -420,13 +429,18 @@ static void test_encode(const testCtx *const p_ctx) {
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) { if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) {
int cmp_len, ret_len; int cmp_len, ret_len;
char modules_dump[4096]; char modules_dump[4096];
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1,
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); "i:%d testUtilModulesDump == -1\n", i);
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, 1 /*zxingcpp_cmp*/, cmp_buf,
sizeof(cmp_buf), &cmp_len);
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n",
i, testUtilBarcodeName(symbol->symbology), ret);
ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len); ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length,
NULL /*primary*/, escaped, &ret_len);
assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n",
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, escaped); i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len,
escaped);
} }
} }
} }
@ -437,6 +451,84 @@ static void test_encode(const testCtx *const p_ctx) {
testFinish(); testFinish();
} }
static void test_rt(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
int input_mode;
int output_options;
const char *data;
int length;
int ret;
int expected_eci;
const char *expected;
int expected_length;
int expected_raw_eci;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, "é", -1, 0, 0, "", -1, 0 },
/* 1*/ { UNICODE_MODE, BARCODE_RAW_TEXT, "é", -1, 0, 0, "\351", -1, 3 },
/* 2*/ { DATA_MODE, -1, "\351", -1, 0, 0, "", -1, 0 },
/* 3*/ { DATA_MODE, BARCODE_RAW_TEXT, "\351", -1, 0, 0, "\351", -1, 3 },
/* 4*/ { GS1_MODE, -1, "[01]04912345123459[15]970331[30]128[10]ABC123", -1, 0, 0, "", -1, 0 },
/* 5*/ { GS1_MODE, BARCODE_RAW_TEXT, "[01]04912345123459[15]970331[30]128[10]ABC123", -1, 0, 0, "01049123451234591597033130128\03510ABC123", -1, 3 },
};
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
int expected_length;
char escaped[4096];
char escaped2[4096];
testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) {
if (testContinue(p_ctx, i)) continue;
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
length = testUtilSetSymbol(symbol, BARCODE_CODE16K, data[i].input_mode, -1 /*eci*/,
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options,
data[i].data, data[i].length, debug);
expected_length = data[i].expected_length == -1 ? (int) strlen(data[i].expected) : data[i].expected_length;
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < ZINT_ERROR) {
assert_equal(symbol->eci, data[i].expected_eci, "i:%d eci %d != %d\n",
i, symbol->eci, data[i].expected_eci);
if (symbol->output_options & BARCODE_RAW_TEXT) {
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
assert_nonnull(symbol->raw_segs[0].source, "i:%d raw_segs[0].source NULL\n", i);
assert_equal(symbol->raw_segs[0].length, expected_length,
"i:%d raw_segs[0].length %d != expected_length %d\n",
i, symbol->raw_segs[0].length, expected_length);
assert_zero(memcmp(symbol->raw_segs[0].source, data[i].expected, expected_length),
"i:%d raw_segs[0].source memcmp(%s, %s, %d) != 0\n", i,
testUtilEscape((const char *) symbol->raw_segs[0].source, symbol->raw_segs[0].length,
escaped, sizeof(escaped)),
testUtilEscape(data[i].expected, expected_length, escaped2, sizeof(escaped2)),
expected_length);
assert_equal(symbol->raw_segs[0].eci, data[i].expected_raw_eci,
"i:%d raw_segs[0].eci %d != expected_raw_eci %d\n",
i, symbol->raw_segs[0].eci, data[i].expected_raw_eci);
} else {
assert_null(symbol->raw_segs, "i:%d raw_segs not NULL\n", i);
}
}
ZBarcode_Delete(symbol);
}
testFinish();
}
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
testFunction funcs[] = { /* name, func */ testFunction funcs[] = { /* name, func */
@ -444,6 +536,7 @@ int main(int argc, char *argv[]) {
{ "test_reader_init", test_reader_init }, { "test_reader_init", test_reader_init },
{ "test_input", test_input }, { "test_input", test_input },
{ "test_encode", test_encode }, { "test_encode", test_encode },
{ "test_rt", test_rt },
}; };
testRun(argc, argv, funcs, ARRAY_SIZE(funcs)); testRun(argc, argv, funcs, ARRAY_SIZE(funcs));

View file

@ -55,7 +55,7 @@ static void test_large(const testCtx *const p_ctx) {
char data_buf[4096]; char data_buf[4096];
testStartSymbol("test_large", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -149,7 +149,7 @@ static void test_input(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
testStartSymbol("test_input", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -256,7 +256,7 @@ static void test_encode(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
testStartSymbol("test_encode", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -304,12 +304,91 @@ static void test_encode(const testCtx *const p_ctx) {
testFinish(); testFinish();
} }
static void test_rt(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
int input_mode;
int output_options;
const char *data;
int length;
int ret;
int expected_eci;
const char *expected;
int expected_length;
int expected_raw_eci;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, "AB\000123", 6, 0, 0, "", -1, 0 },
/* 1*/ { UNICODE_MODE, BARCODE_RAW_TEXT, "AB\000123", 6, 0, 0, "AB\000123", 6, 3 },
/* 2*/ { DATA_MODE, -1, "AB\000123", 6, 0, 0, "", -1, 0 },
/* 3*/ { DATA_MODE, BARCODE_RAW_TEXT, "AB\000123", 6, 0, 0, "AB\000123", 6, 3 },
/* 4*/ { GS1_MODE, -1, "[01]04912345123459[15]970331[30]128[10]ABC123", -1, 0, 0, "", -1, 0 },
/* 5*/ { GS1_MODE, BARCODE_RAW_TEXT, "[01]04912345123459[15]970331[30]128[10]ABC123", -1, 0, 0, "01049123451234591597033130128\03510ABC123", -1, 3 },
};
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
int expected_length;
char escaped[4096];
char escaped2[4096];
testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) {
if (testContinue(p_ctx, i)) continue;
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
length = testUtilSetSymbol(symbol, BARCODE_CODE49, data[i].input_mode, -1 /*eci*/,
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options,
data[i].data, data[i].length, debug);
expected_length = data[i].expected_length == -1 ? (int) strlen(data[i].expected) : data[i].expected_length;
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < ZINT_ERROR) {
assert_equal(symbol->eci, data[i].expected_eci, "i:%d eci %d != %d\n",
i, symbol->eci, data[i].expected_eci);
if (symbol->output_options & BARCODE_RAW_TEXT) {
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
assert_nonnull(symbol->raw_segs[0].source, "i:%d raw_segs[0].source NULL\n", i);
assert_equal(symbol->raw_segs[0].length, expected_length,
"i:%d raw_segs[0].length %d != expected_length %d\n",
i, symbol->raw_segs[0].length, expected_length);
assert_zero(memcmp(symbol->raw_segs[0].source, data[i].expected, expected_length),
"i:%d raw_segs[0].source memcmp(%s, %s, %d) != 0\n", i,
testUtilEscape((const char *) symbol->raw_segs[0].source, symbol->raw_segs[0].length,
escaped, sizeof(escaped)),
testUtilEscape(data[i].expected, expected_length, escaped2, sizeof(escaped2)),
expected_length);
assert_equal(symbol->raw_segs[0].eci, data[i].expected_raw_eci,
"i:%d raw_segs[0].eci %d != expected_raw_eci %d\n",
i, symbol->raw_segs[0].eci, data[i].expected_raw_eci);
} else {
assert_null(symbol->raw_segs, "i:%d raw_segs not NULL\n", i);
}
}
ZBarcode_Delete(symbol);
}
testFinish();
}
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
testFunction funcs[] = { /* name, func */ testFunction funcs[] = { /* name, func */
{ "test_large", test_large }, { "test_large", test_large },
{ "test_input", test_input }, { "test_input", test_input },
{ "test_encode", test_encode }, { "test_encode", test_encode },
{ "test_rt", test_rt },
}; };
testRun(argc, argv, funcs, ARRAY_SIZE(funcs)); testRun(argc, argv, funcs, ARRAY_SIZE(funcs));

View file

@ -70,7 +70,7 @@ static void test_to_int(const testCtx *const p_ctx) {
const int data_size = ARRAY_SIZE(data); const int data_size = ARRAY_SIZE(data);
int i, length, ret; int i, length, ret;
testStart("test_to_int"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -104,7 +104,7 @@ static void test_to_upper(const testCtx *const p_ctx) {
unsigned char buf[512]; unsigned char buf[512];
testStart("test_to_upper"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -140,7 +140,7 @@ static void test_chr_cnt(const testCtx *const p_ctx) {
const int data_size = ARRAY_SIZE(data); const int data_size = ARRAY_SIZE(data);
int i, length, ret; int i, length, ret;
testStart("test_chr_cnt"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -176,7 +176,7 @@ static void test_is_chr(const testCtx *const p_ctx) {
const int data_size = ARRAY_SIZE(data); const int data_size = ARRAY_SIZE(data);
int i, ret; int i, ret;
testStart("test_is_chr"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -290,7 +290,7 @@ static void test_not_sane(const testCtx *const p_ctx) {
const int data_size = ARRAY_SIZE(data); const int data_size = ARRAY_SIZE(data);
int i, j, length, ret; int i, j, length, ret;
testStart("test_not_sane"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -344,7 +344,7 @@ static void test_not_sane_lookup(const testCtx *const p_ctx) {
int test_length; int test_length;
int posns[32] = {0}; /* Suppress clang -fsanitize=memory false positive */ int posns[32] = {0}; /* Suppress clang -fsanitize=memory false positive */
testStart("test_not_sane_lookup"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -396,7 +396,7 @@ static void test_errtxt(const testCtx *const p_ctx) {
struct zint_symbol s_symbol; struct zint_symbol s_symbol;
struct zint_symbol *symbol = &s_symbol; struct zint_symbol *symbol = &s_symbol;
testStart("test_errtxt"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -529,7 +529,7 @@ static void test_errtxtf(const testCtx *const p_ctx) {
struct zint_symbol s_symbol; struct zint_symbol s_symbol;
struct zint_symbol *symbol = &s_symbol; struct zint_symbol *symbol = &s_symbol;
testStart("test_errtxtf"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -600,7 +600,7 @@ static void test_cnt_digits(const testCtx *const p_ctx) {
const int data_size = ARRAY_SIZE(data); const int data_size = ARRAY_SIZE(data);
int i, length, ret; int i, length, ret;
testStart("test_cnt_digits"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -639,7 +639,7 @@ static void test_is_valid_utf8(const testCtx *const p_ctx) {
const int data_size = ARRAY_SIZE(data); const int data_size = ARRAY_SIZE(data);
int i, length, ret; int i, length, ret;
testStart("test_is_valid_utf8"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -682,7 +682,7 @@ static void test_utf8_to_unicode(const testCtx *const p_ctx) {
struct zint_symbol s_symbol; struct zint_symbol s_symbol;
struct zint_symbol *symbol = &s_symbol; struct zint_symbol *symbol = &s_symbol;
testStart("test_utf8_to_unicode"); testStart(p_ctx->func_name);
symbol->debug = debug; symbol->debug = debug;
@ -721,8 +721,6 @@ static void test_hrt_cpy_iso8859_1(const testCtx *const p_ctx) {
int length; int length;
int ret; int ret;
const char *expected; const char *expected;
const char *expected_plain;
int expected_plain_length;
const char *comment; const char *comment;
}; };
/* /*
@ -732,28 +730,28 @@ static void test_hrt_cpy_iso8859_1(const testCtx *const p_ctx) {
*/ */
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = { static const struct item data[] = {
/* 0*/ { "", -1, 0, "", NULL, -1, "" }, /* 0*/ { "", -1, 0, "", "" },
/* 1*/ { "abc", -1, 0, "abc", NULL, -1, "" }, /* 1*/ { "abc", -1, 0, "abc", "" },
/* 2*/ { "\000A\001B\002\036\037C ~\177", 11, 0, " A B C ~ ", "\000A\001B\002\036\037C ~\177", 11, "" }, /* 2*/ { "\000A\001B\002\036\037C ~\177", 11, 0, " A B C ~ ", "" },
/* 3*/ { "~\177\200\201\237\240", -1, 0, "~ \302\240", "~\177\302\200\302\201\302\237\302\240", -1, "" }, /* 3*/ { "~\177\200\201\237\240", -1, 0, "~ \302\240", "" },
/* 4*/ { "\241\242\243\244\257\260", -1, 0, "¡¢£¤¯°", NULL, -1, "" }, /* 4*/ { "\241\242\243\244\257\260", -1, 0, "¡¢£¤¯°", "" },
/* 5*/ { "\276\277\300\337\377", -1, 0, "¾¿Àßÿ", NULL, -1, "" }, /* 5*/ { "\276\277\300\337\377", -1, 0, "¾¿Àßÿ", "" },
/* 6*/ { "\351", -1, 0, "é", NULL, -1, "" }, /* 6*/ { "\351", -1, 0, "é", "" },
/* 7*/ { "\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241", -1, 0, "¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", NULL, -1, "127 \241" }, /* 7*/ { "\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241", -1, 0, "¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", "127 \241" },
/* 8*/ { "a\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241", -1, 0, "a¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", NULL, -1, "a + 127 \241" }, /* 8*/ { "a\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241", -1, 0, "a¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", "a + 127 \241" },
/* 9*/ { "\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241a", -1, 0, "¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡a", NULL, -1, "127 \241 + a" }, /* 9*/ { "\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241a", -1, 0, "¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡a", "127 \241 + a" },
/* 10*/ { "\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241", -1, 1, "¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", NULL, -1, "128 \241 (truncated)" }, /* 10*/ { "\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241", -1, 1, "¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", "128 \241 (truncated)" },
/* 11*/ { "a\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241", -1, 1, "a¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", NULL, -1, "a + 128 \241 (truncated)" }, /* 11*/ { "a\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241", -1, 1, "a¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", "a + 128 \241 (truncated)" },
/* 12*/ { "\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241a", -1, 1, "¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", NULL, -1, "128 \241 + a (truncated)" }, /* 12*/ { "\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241a", -1, 1, "¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", "128 \241 + a (truncated)" },
/* 13*/ { "\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241", -1, 1, "¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", NULL, -1, "129 \241 (truncated)" }, /* 13*/ { "\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241", -1, 1, "¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", "129 \241 (truncated)" },
/* 14*/ { "\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351", -1, 0, "ééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", NULL, -1, "127 \351" }, /* 14*/ { "\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351", -1, 0, "ééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", "127 \351" },
/* 15*/ { "a\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351", -1, 0, "aééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", NULL, -1, "a + 127 \351" }, /* 15*/ { "a\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351", -1, 0, "aééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", "a + 127 \351" },
/* 16*/ { "\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351a", -1, 0, "éééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééa", NULL, -1, "127 \351 + a" }, /* 16*/ { "\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351a", -1, 0, "éééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééa", "127 \351 + a" },
/* 17*/ { "\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351", -1, 1, "ééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", NULL, -1, "128 \351 (truncated)" }, /* 17*/ { "\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351", -1, 1, "ééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", "128 \351 (truncated)" },
/* 18*/ { "a\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351", -1, 1, "aééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", NULL, -1, "a + 128 \351 (truncated)" }, /* 18*/ { "a\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351", -1, 1, "aééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", "a + 128 \351 (truncated)" },
/* 19*/ { "\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351a", -1, 1, "ééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", NULL, -1, "128 \351 + a (truncated)" }, /* 19*/ { "\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351a", -1, 1, "ééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", "128 \351 + a (truncated)" },
/* 20*/ { "\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351", -1, 1, "ééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", NULL, -1, "129 \351 (truncated)" }, /* 20*/ { "\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351", -1, 1, "ééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", "129 \351 (truncated)" },
/* 21*/ { "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", -1, 1, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", NULL, -1, "256 A (truncated)" }, /* 21*/ { "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", -1, 1, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "256 A (truncated)" },
}; };
const int data_size = ARRAY_SIZE(data); const int data_size = ARRAY_SIZE(data);
int i, length, ret; int i, length, ret;
@ -761,9 +759,8 @@ static void test_hrt_cpy_iso8859_1(const testCtx *const p_ctx) {
struct zint_symbol s_symbol; struct zint_symbol s_symbol;
struct zint_symbol *symbol = &s_symbol; struct zint_symbol *symbol = &s_symbol;
int expected_length; int expected_length;
const char *expected;
testStart("test_hrt_cpy_iso8859_1"); testStart(p_ctx->func_name);
symbol->debug = debug; symbol->debug = debug;
@ -784,31 +781,12 @@ static void test_hrt_cpy_iso8859_1(const testCtx *const p_ctx) {
} }
} }
assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret); assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret);
assert_nonzero(testUtilIsValidUTF8(symbol->text, symbol->text_length), "i:%d testUtilIsValidUTF8(%s) != 1\n", assert_nonzero(testUtilIsValidUTF8(symbol->text, (int) ustrlen(symbol->text)),
i, symbol->text); "i:%d testUtilIsValidUTF8(%s) != 1\n", i, symbol->text);
assert_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d\n", assert_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d\n",
i, symbol->text_length, expected_length); i, symbol->text_length, expected_length);
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d symbol->text (%s) != expected (%s)\n", assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d symbol->text (%s) != expected (%s)\n",
i, symbol->text, data[i].expected); i, symbol->text, data[i].expected);
memset(symbol, 0, sizeof(*symbol));
symbol->output_options = BARCODE_RAW_TEXT;
if (data[i].expected_plain == NULL) {
expected = data[i].expected;
expected_length = (int) strlen(expected);
} else {
expected = data[i].expected_plain;
expected_length = data[i].expected_plain_length == -1 ? (int) strlen(expected) : data[i].expected_plain_length;
}
ret = hrt_cpy_iso8859_1(symbol, (unsigned char *) data[i].data, length);
assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret);
assert_nonzero(testUtilIsValidUTF8(symbol->text, symbol->text_length), "i:%d testUtilIsValidUTF8(%s) != 1\n",
i, symbol->text);
assert_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d\n",
i, symbol->text_length, expected_length);
assert_zero(memcmp(symbol->text, expected, symbol->text_length), "i:%d symbol->text (%s) != expected (%s)\n", i, symbol->text, expected);
} }
testFinish(); testFinish();
@ -853,7 +831,7 @@ static void test_hrt_cpy_nochk(const testCtx *const p_ctx) {
struct zint_symbol *symbol = &s_symbol; struct zint_symbol *symbol = &s_symbol;
int expected_length; int expected_length;
testStart("test_hrt_cpy_nochk"); testStart(p_ctx->func_name);
symbol->debug = debug; symbol->debug = debug;
@ -896,6 +874,71 @@ static void test_hrt_cpy_nochk(const testCtx *const p_ctx) {
testFinish(); testFinish();
} }
static void test_hrt_cpy_cat_nochk(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
const char *source;
int length;
char separator;
const char *cat;
int cat_length;
const char *expected;
int expected_length;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 0*/ { NULL, -1, '\xFF', NULL, -1, "", -1 },
/* 1*/ { "", 0, '\xFF', NULL, -1, "", -1 },
/* 2*/ { "", 0, '\xFF', "", 0, "", -1 },
/* 3*/ { NULL, 0, '\xFF', "", 0, "", -1 },
/* 4*/ { "ABC", 3, ':', "DEF", 3, "ABC:DEF", -1 },
/* 5*/ { "", 0, ':', "DEF", 3, ":DEF", -1 },
/* 6*/ { "", 0, '\xFF', "DEF", 3, "DEF", -1 },
/* 7*/ { "ABC", 3, ':', "", 0, "ABC:", -1 },
/* 8*/ { "ABC", 3, '\xFF', "", 0, "ABC", -1 },
/* 9*/ { "", 0, ':', "", 0, ":", -1 },
};
const int data_size = ARRAY_SIZE(data);
int i;
struct zint_symbol s_symbol;
struct zint_symbol *symbol = &s_symbol;
int expected_length;
testStart(p_ctx->func_name);
symbol->debug = debug;
for (i = 0; i < data_size; i++) {
int j;
if (testContinue(p_ctx, i)) continue;
memset(symbol, 0, sizeof(*symbol));
expected_length = data[i].expected_length == -1 ? (int) strlen(data[i].expected) : data[i].expected_length;
hrt_cpy_cat_nochk(symbol, TCU(data[i].source), data[i].length, data[i].separator, TCU(data[i].cat), data[i].cat_length);
if (p_ctx->index != -1 && (debug & ZINT_DEBUG_TEST_PRINT)) {
for (j = 0; j < symbol->text_length; j++) {
fprintf(stderr, "symbol->text[%d] %2X\n", j, symbol->text[j]);
}
}
assert_nonzero(testUtilIsValidUTF8(symbol->text, (int) ustrlen(symbol->text)),
"i:%d testUtilIsValidUTF8(%s) != 1\n", i, symbol->text);
assert_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d\n",
i, symbol->text_length, expected_length);
assert_zero(memcmp(symbol->text, data[i].expected, expected_length), "i:%d memcmp(%s, %s, %d) != 0\n",
i, symbol->text, data[i].expected, expected_length);
}
testFinish();
}
static void test_hrt_printf_nochk(const testCtx *const p_ctx) { static void test_hrt_printf_nochk(const testCtx *const p_ctx) {
int debug = p_ctx->debug; int debug = p_ctx->debug;
@ -919,7 +962,7 @@ static void test_hrt_printf_nochk(const testCtx *const p_ctx) {
struct zint_symbol s_symbol; struct zint_symbol s_symbol;
struct zint_symbol *symbol = &s_symbol; struct zint_symbol *symbol = &s_symbol;
testStart("test_hrt_printf_nochk"); testStart(p_ctx->func_name);
symbol->debug = debug; symbol->debug = debug;
@ -974,7 +1017,7 @@ static void test_hrt_conv_gs1_brackets_nochk(const testCtx *const p_ctx) {
struct zint_symbol s_symbol; struct zint_symbol s_symbol;
struct zint_symbol *symbol = &s_symbol; struct zint_symbol *symbol = &s_symbol;
testStart("test_hrt_conv_gs1_brackets_nochk"); testStart(p_ctx->func_name);
symbol->debug = debug; symbol->debug = debug;
@ -995,6 +1038,236 @@ static void test_hrt_conv_gs1_brackets_nochk(const testCtx *const p_ctx) {
testFinish(); testFinish();
} }
static void test_rt_cpy_seg(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
int seg_count;
int seg_idx;
struct zint_seg seg;
unsigned int ddata[8];
int ddata_size;
int ddata_eci;
const char *expected;
int expected_length;
int expected_eci;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 0*/ { 1, 0, { TU("A"), 1, 0 }, {0}, 0, 0, "A", -1, 3 },
/* 1*/ { 1, 0, { TU("A"), 1, 900 }, {0}, 0, 0, "A", -1, 900 },
/* 2*/ { 2, 1, { TU("A"), 1, 0 }, {0}, 0, 0, "A", -1, 3 },
/* 3*/ { 1, 0, { TU("ABCDE"), 5, 0 }, { 'B', 0xFF, 'C', 0xFF00, 'D' }, 5, 0, "B\377C\377\000D", 6, 3 },
};
const int data_size = ARRAY_SIZE(data);
int i, ret;
struct zint_symbol s_symbol;
struct zint_symbol *symbol = &s_symbol;
int expected_length;
char escaped[4096];
char escaped2[4096];
testStart(p_ctx->func_name);
symbol->debug = debug;
for (i = 0; i < data_size; i++) {
int seg_idx;
if (testContinue(p_ctx, i)) continue;
expected_length = data[i].expected_length == -1 ? (int) strlen(data[i].expected) : data[i].expected_length;
assert_nonzero(data[i].seg_count, "i:%d seg_count zero\n", i);
ret = rt_init_segs(symbol, data[i].seg_count);
assert_zero(ret, "i:%d rt_init_segs(%d) %d != 0\n", i, data[i].seg_count, ret);
seg_idx = data[i].seg_idx;
assert_nonzero(seg_idx >= 0, "i:%d seg_idx %d < 0\n", i, seg_idx);
assert_nonzero(seg_idx < data[i].seg_count, "i:%d seg_idx %d >= seg_count 0%d\n",
i, seg_idx, data[i].seg_count);
if (data[i].ddata_size > 0) {
assert_equal(data[i].seg.length, data[i].ddata_size, "i:%d seg_length %d != ddata_size %d\n",
i, data[i].seg.length, data[i].ddata_size);
ret = rt_cpy_seg_ddata(symbol, seg_idx, &data[i].seg, data[i].ddata_eci, data[i].ddata);
assert_zero(ret, "i:%d rt_cpy_seg_ddata %d != 0\n", i, ret);
} else {
ret = rt_cpy_seg(symbol, seg_idx, &data[i].seg);
assert_zero(ret, "i:%d rt_cpy_segs %d != 0\n", i, ret);
}
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
assert_nonnull(symbol->raw_segs[seg_idx].source, "i:%d raw_segs[%d].source NULL\n", i, seg_idx);
assert_equal(symbol->raw_segs[seg_idx].length, expected_length,
"i:%d raw_segs[%d].length %d != expected_length %d\n",
i, seg_idx, symbol->raw_segs[seg_idx].length, expected_length);
assert_zero(memcmp(symbol->raw_segs[seg_idx].source, data[i].expected, expected_length),
"i:%d raw_segs[%d].source memcmp(%s, %s, %d) != 0\n", i, seg_idx,
testUtilEscape((const char *) symbol->raw_segs[seg_idx].source, symbol->raw_segs[seg_idx].length,
escaped, sizeof(escaped)),
testUtilEscape(data[i].expected, expected_length, escaped2, sizeof(escaped2)),
expected_length);
assert_equal(symbol->raw_segs[seg_idx].eci, data[i].expected_eci,
"i:%d raw_segs[%d].eci %d != expected_eci %d\n",
i, seg_idx, symbol->raw_segs[seg_idx].eci, data[i].expected_eci);
ZBarcode_Clear(symbol);
}
testFinish();
}
static void test_rt_cpy(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
int seg_count;
int seg_idx;
const char *source;
int length;
char separator;
const char *cat;
int cat_length;
const char *expected;
int expected_length;
int expected_eci;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 0*/ { 1, 0, "A", -1, '\0', "", -1, "A", -1, 3 },
/* 1*/ { 1, 0, "A", -1, ':', "B", -1, "A:B", -1, 3 },
/* 2*/ { 1, 0, "A", -1, '\xFF', "B", -1, "AB", -1, 3 },
/* 3*/ { 1, 0, "A", -1, '\0', "B", -1, "A\000B", 3, 3 },
};
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol s_symbol;
struct zint_symbol *symbol = &s_symbol;
int expected_length;
char escaped[4096];
char escaped2[4096];
testStart(p_ctx->func_name);
symbol->debug = debug;
for (i = 0; i < data_size; i++) {
int cat_length;
if (testContinue(p_ctx, i)) continue;
expected_length = data[i].expected_length == -1 ? (int) strlen(data[i].expected) : data[i].expected_length;
ret = rt_init_segs(symbol, 1);
assert_zero(ret, "i:%d rt_init_segs %d != 0\n", i, ret);
length = data[i].length == -1 ? (int) strlen(data[i].source) : data[i].length;
if ((cat_length = data[i].cat_length == -1 ? (int) strlen(data[i].cat) : data[i].cat_length)) {
ret = rt_cpy_cat(symbol, TCU(data[i].source), length, data[i].separator, TCU(data[i].cat), cat_length);
assert_zero(ret, "i:%d rt_cpy_cat %d != 0\n", i, ret);
} else {
ret = rt_cpy(symbol, TCU(data[i].source), length);
assert_zero(ret, "i:%d rt_cpy %d != 0\n", i, ret);
}
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
assert_nonnull(symbol->raw_segs[0].source, "i:%d raw_segs[0].source NULL\n", i);
assert_equal(symbol->raw_segs[0].length, expected_length,
"i:%d raw_segs[0].length %d != expected_length %d\n",
i, symbol->raw_segs[0].length, expected_length);
assert_zero(memcmp(symbol->raw_segs[0].source, data[i].expected, expected_length),
"i:%d raw_segs[0].source memcmp(%s, %s, %d) != 0\n", i,
testUtilEscape((const char *) symbol->raw_segs[0].source, symbol->raw_segs[0].length,
escaped, sizeof(escaped)),
testUtilEscape(data[i].expected, expected_length, escaped2, sizeof(escaped2)),
expected_length);
assert_equal(symbol->raw_segs[0].eci, data[i].expected_eci,
"i:%d raw_segs[0].eci %d != expected_eci %d\n",
i, symbol->raw_segs[0].eci, data[i].expected_eci);
ZBarcode_Clear(symbol);
}
testFinish();
}
static void test_rt_printf_256(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
const char *fmt;
int num_args;
const char *data1;
const char *data2;
const char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 0*/ { "", 1, "", "", "" },
/* 1*/ { "*%s*", 1, "gosh", "", "*gosh*" },
/* 2*/ { "%.1s.%.2s", 2, "gosh", "wow", "g.wo" },
/* 3*/ { "ABCDEFGHIJKLMNOPQRST%sABCDEFGHIJKLMNOPQRST%sABCDEFGHIJKLMNO", 2, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", "ABCDEFGHIJKLMNOPQRST1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890ABCDEFGHIJKLMNOPQRST1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890ABCDEFGHIJKLMNO" }, /* Max 255 - 1 more and overflow */
};
const int data_size = ARRAY_SIZE(data);
int i, ret;
struct zint_symbol s_symbol;
struct zint_symbol *symbol = &s_symbol;
int expected_length;
char escaped[4096];
char escaped2[4096];
testStart(p_ctx->func_name);
symbol->debug = debug;
for (i = 0; i < data_size; i++) {
if (testContinue(p_ctx, i)) continue;
expected_length = (int) strlen(data[i].expected);
ret = rt_init_segs(symbol, 1);
assert_zero(ret, "i:%d rt_init_segs %d != 0\n", i, ret);
if (data[i].num_args == 1) {
ret = rt_printf_256(symbol, data[i].fmt, data[i].data1);
} else if (data[i].num_args == 2) {
ret = rt_printf_256(symbol, data[i].fmt, data[i].data1, data[i].data2);
} else {
assert_zero(1, "i:%d, bad num_args\n", i);
}
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
assert_nonnull(symbol->raw_segs[0].source, "i:%d raw_segs[0].source NULL\n", i);
assert_equal(symbol->raw_segs[0].length, expected_length,
"i:%d raw_segs[0].length %d != expected_length %d\n",
i, symbol->raw_segs[0].length, expected_length);
assert_zero(memcmp(symbol->raw_segs[0].source, data[i].expected, expected_length),
"i:%d raw_segs[0].source memcmp(%s, %s, %d) != 0\n", i,
testUtilEscape((const char *) symbol->raw_segs[0].source, symbol->raw_segs[0].length,
escaped, sizeof(escaped)),
testUtilEscape(data[i].expected, expected_length, escaped2, sizeof(escaped2)),
expected_length);
assert_equal(symbol->raw_segs[0].eci, 3, "i:%d raw_segs[0].eci %d != 3\n", i, symbol->raw_segs[0].eci);
ZBarcode_Clear(symbol);
}
testFinish();
}
static void test_set_height(const testCtx *const p_ctx) { static void test_set_height(const testCtx *const p_ctx) {
int debug = p_ctx->debug; int debug = p_ctx->debug;
@ -1034,7 +1307,7 @@ static void test_set_height(const testCtx *const p_ctx) {
struct zint_symbol s_symbol; struct zint_symbol s_symbol;
struct zint_symbol *symbol = &s_symbol; struct zint_symbol *symbol = &s_symbol;
testStart("set_height"); testStart(p_ctx->func_name);
symbol->debug = debug; symbol->debug = debug;
@ -1080,7 +1353,7 @@ static void test_debug_test_codeword_dump_int(const testCtx *const p_ctx) {
struct zint_symbol s_symbol; struct zint_symbol s_symbol;
struct zint_symbol *symbol = &s_symbol; struct zint_symbol *symbol = &s_symbol;
testStart("test_debug_test_codeword_dump_int"); testStart(p_ctx->func_name);
symbol->debug = debug; symbol->debug = debug;
@ -1112,8 +1385,12 @@ int main(int argc, char *argv[]) {
{ "test_utf8_to_unicode", test_utf8_to_unicode }, { "test_utf8_to_unicode", test_utf8_to_unicode },
{ "test_hrt_cpy_iso8859_1", test_hrt_cpy_iso8859_1 }, { "test_hrt_cpy_iso8859_1", test_hrt_cpy_iso8859_1 },
{ "test_hrt_cpy_nochk", test_hrt_cpy_nochk }, { "test_hrt_cpy_nochk", test_hrt_cpy_nochk },
{ "test_hrt_cpy_cat_nochk", test_hrt_cpy_cat_nochk },
{ "test_hrt_printf_nochk", test_hrt_printf_nochk }, { "test_hrt_printf_nochk", test_hrt_printf_nochk },
{ "test_hrt_conv_gs1_brackets_nochk", test_hrt_conv_gs1_brackets_nochk }, { "test_hrt_conv_gs1_brackets_nochk", test_hrt_conv_gs1_brackets_nochk },
{ "test_rt_cpy_seg", test_rt_cpy_seg },
{ "test_rt_cpy", test_rt_cpy },
{ "test_rt_printf_256", test_rt_printf_256 },
{ "test_set_height", test_set_height }, { "test_set_height", test_set_height },
{ "test_debug_test_codeword_dump_int", test_debug_test_codeword_dump_int }, { "test_debug_test_codeword_dump_int", test_debug_test_codeword_dump_int },
}; };

View file

@ -77,7 +77,7 @@ static void test_eanx_leading_zeroes(const testCtx *const p_ctx) {
int i, length, composite_length, ret; int i, length, composite_length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_eanx_leading_zeroes", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -1539,7 +1539,7 @@ static void test_examples(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
testStartSymbol("test_examples", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -1712,7 +1712,7 @@ static void test_odd_numbered_numeric(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
testStartSymbol("test_odd_numbered_numeric", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -1841,7 +1841,7 @@ static void test_ean128_cc_shift(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
testStartSymbol("test_ean128_cc_shift", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -1922,7 +1922,7 @@ static void test_ean128_cc_width(const testCtx *const p_ctx) {
int i, length, composite_length, ret; int i, length, composite_length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_ean128_cc_width", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -2389,7 +2389,7 @@ static void test_encodation_0(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
testStartSymbol("test_encodation_0", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -2527,7 +2527,7 @@ static void test_encodation_10(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
testStartSymbol("test_encodation_10", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -2943,7 +2943,7 @@ static void test_encodation_11(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
testStartSymbol("test_encodation_11", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -3096,7 +3096,7 @@ static void test_addongap(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
testStartSymbol("test_addongap", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -3187,7 +3187,7 @@ static void test_gs1parens(const testCtx *const p_ctx) {
int i, length, composite_length, ret; int i, length, composite_length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_gs1parens", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -3226,65 +3226,68 @@ static void test_hrt(const testCtx *const p_ctx) {
int ret; int ret;
const char *expected; const char *expected;
const char *expected_raw;
}; };
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = { static const struct item data[] = {
/* 0*/ { BARCODE_EANX_CC, -1, -1, "1234567", "[20]12", 0, "12345670" }, /* EAN-8 */ /* 0*/ { BARCODE_EANX_CC, -1, -1, "1234567", "[20]12", 0, "12345670", "" }, /* EAN-8 */
/* 1*/ { BARCODE_EANX_CC, -1, BARCODE_RAW_TEXT, "1234567", "[20]12", 0, "12345670" }, /* EAN-8 */ /* 1*/ { BARCODE_EANX_CC, -1, BARCODE_RAW_TEXT, "1234567", "[20]12", 0, "12345670", "12345670|2012" }, /* EAN-8 */
/* 2*/ { BARCODE_EANX_CC, -1, -1, "123456789012", "[20]12", 0, "1234567890128" }, /* EAN-13 */ /* 2*/ { BARCODE_EANX_CC, -1, -1, "123456789012", "[20]12", 0, "1234567890128", "" }, /* EAN-13 */
/* 3*/ { BARCODE_EANX_CC, -1, BARCODE_RAW_TEXT, "123456789012", "[20]12", 0, "1234567890128" }, /* EAN-13 */ /* 3*/ { BARCODE_EANX_CC, -1, BARCODE_RAW_TEXT, "123456789012", "[20]12", 0, "1234567890128", "1234567890128|2012" }, /* EAN-13 */
/* 4*/ { BARCODE_EANX_CC, -1, -1, "1234567890128", "[20]12", 0, "1234567890128" }, /* 4*/ { BARCODE_EANX_CC, -1, -1, "123456789012", "[10]LOT123[20]12", 0, "1234567890128", "" }, /* EAN-13 */
/* 5*/ { BARCODE_EANX_CC, -1, -1, "1234567890123", "[20]12", ZINT_ERROR_INVALID_CHECK, "" }, /* 5*/ { BARCODE_EANX_CC, -1, BARCODE_RAW_TEXT, "123456789012", "[10]LOT123[20]12", 0, "1234567890128", "1234567890128|10LOT123\0352012" }, /* EAN-13 */
/* 6*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, -1, "1234567890123", "[20]12", ZINT_ERROR_INVALID_CHECK, "" }, /* Still checked */ /* 6*/ { BARCODE_EANX_CC, -1, -1, "1234567890128", "[20]12", 0, "1234567890128", "" },
/* 7*/ { BARCODE_EANX_CC, -1, -1, "1234567890128", "[20]1A", ZINT_WARN_NONCOMPLIANT, "1234567890128" }, /* AI (20) should be 2 nos. */ /* 7*/ { BARCODE_EANX_CC, -1, -1, "1234567890123", "[20]12", ZINT_ERROR_INVALID_CHECK, "", "" },
/* 8*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, -1, "1234567890128", "[20]1A", 0, "1234567890128" }, /* 8*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, -1, "1234567890123", "[20]12", ZINT_ERROR_INVALID_CHECK, "", "" }, /* Still checked */
/* 9*/ { BARCODE_EANX_CC, -1, -1, "1234567890128+12", "[20]12", 0, "1234567890128+12" }, /* 9*/ { BARCODE_EANX_CC, -1, -1, "1234567890128", "[20]1A", ZINT_WARN_NONCOMPLIANT, "1234567890128", "" }, /* AI (20) should be 2 nos. */
/* 10*/ { BARCODE_EANX_CC, -1, BARCODE_RAW_TEXT, "1234567890128+12", "[20]12", 0, "1234567890128+12" }, /* 10*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, -1, "1234567890128", "[20]1A", 0, "1234567890128", "" },
/* 11*/ { BARCODE_DBAR_OMN_CC, -1, -1, "1234567890123", "[20]12", 0, "(01)12345678901231" }, /* 11*/ { BARCODE_EANX_CC, -1, -1, "1234567890128+12", "[20]12", 0, "1234567890128+12", "" },
/* 12*/ { BARCODE_DBAR_OMN_CC, -1, BARCODE_RAW_TEXT, "1234567890123", "[20]12", 0, "0112345678901231" }, /* 12*/ { BARCODE_EANX_CC, -1, BARCODE_RAW_TEXT, "1234567890128+12", "[20]12", 0, "1234567890128+12", "1234567890128+12|2012" },
/* 13*/ { BARCODE_DBAR_OMN_CC, -1, -1, "12345678901231", "[20]12", 0, "(01)12345678901231" }, /* 13*/ { BARCODE_DBAR_OMN_CC, -1, -1, "1234567890123", "[20]12", 0, "(01)12345678901231", "" },
/* 14*/ { BARCODE_DBAR_OMN_CC, -1, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, "" }, /* 14*/ { BARCODE_DBAR_OMN_CC, -1, BARCODE_RAW_TEXT, "1234567890123", "[20]12", 0, "(01)12345678901231", "12345678901231|2012" },
/* 15*/ { BARCODE_DBAR_OMN_CC, GS1NOCHECK_MODE, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, "" }, /* Still checked */ /* 15*/ { BARCODE_DBAR_OMN_CC, -1, -1, "12345678901231", "[20]12", 0, "(01)12345678901231", "" },
/* 16*/ { BARCODE_DBAR_OMN_CC, -1, -1, "12345678901231", "[20]1A", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231" }, /* AI (20) should be 2 nos. */ /* 16*/ { BARCODE_DBAR_OMN_CC, -1, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, "", "" },
/* 17*/ { BARCODE_DBAR_OMN_CC, GS1NOCHECK_MODE, -1, "12345678901231", "[20]1A", 0, "(01)12345678901231" }, /* 17*/ { BARCODE_DBAR_OMN_CC, GS1NOCHECK_MODE, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, "", "" }, /* Still checked */
/* 18*/ { BARCODE_DBAR_LTD_CC, -1, -1, "1234567890123", "[20]12", 0, "(01)12345678901231" }, /* 18*/ { BARCODE_DBAR_OMN_CC, -1, -1, "12345678901231", "[20]1A", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231", "" }, /* AI (20) should be 2 nos. */
/* 19*/ { BARCODE_DBAR_LTD_CC, -1, BARCODE_RAW_TEXT, "1234567890123", "[20]12", 0, "0112345678901231" }, /* 19*/ { BARCODE_DBAR_OMN_CC, GS1NOCHECK_MODE, -1, "12345678901231", "[20]1A", 0, "(01)12345678901231", "" },
/* 20*/ { BARCODE_DBAR_LTD_CC, -1, -1, "12345678901231", "[20]12", 0, "(01)12345678901231" }, /* 20*/ { BARCODE_DBAR_LTD_CC, -1, -1, "1234567890123", "[20]12", 0, "(01)12345678901231", "" },
/* 21*/ { BARCODE_DBAR_LTD_CC, -1, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, "" }, /* 21*/ { BARCODE_DBAR_LTD_CC, -1, BARCODE_RAW_TEXT, "1234567890123", "[20]12", 0, "(01)12345678901231", "12345678901231|2012" },
/* 22*/ { BARCODE_DBAR_LTD_CC, GS1NOCHECK_MODE, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, "" }, /* Still checked */ /* 22*/ { BARCODE_DBAR_LTD_CC, -1, -1, "12345678901231", "[20]12", 0, "(01)12345678901231", "" },
/* 23*/ { BARCODE_DBAR_LTD_CC, -1, -1, "12345678901231", "[20]1A", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231" }, /* AI (20) should be 2 nos. */ /* 23*/ { BARCODE_DBAR_LTD_CC, -1, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, "", "" },
/* 24*/ { BARCODE_DBAR_LTD_CC, GS1NOCHECK_MODE, -1, "12345678901231", "[20]1A", 0, "(01)12345678901231" }, /* 24*/ { BARCODE_DBAR_LTD_CC, GS1NOCHECK_MODE, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, "", "" }, /* Still checked */
/* 25*/ { BARCODE_UPCA_CC, -1, -1, "12345678901", "[20]12", 0, "123456789012" }, /* 25*/ { BARCODE_DBAR_LTD_CC, -1, -1, "12345678901231", "[20]1A", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231", "" }, /* AI (20) should be 2 nos. */
/* 26*/ { BARCODE_UPCA_CC, -1, BARCODE_RAW_TEXT, "12345678901", "[20]12", 0, "123456789012" }, /* 26*/ { BARCODE_DBAR_LTD_CC, GS1NOCHECK_MODE, -1, "12345678901231", "[20]1A", 0, "(01)12345678901231", "" },
/* 27*/ { BARCODE_UPCA_CC, -1, -1, "123456789012", "[20]12", 0, "123456789012" }, /* 27*/ { BARCODE_UPCA_CC, -1, -1, "12345678901", "[20]12", 0, "123456789012", "" },
/* 28*/ { BARCODE_UPCA_CC, -1, -1, "123456789013", "[20]12", ZINT_ERROR_INVALID_CHECK, "" }, /* 28*/ { BARCODE_UPCA_CC, -1, BARCODE_RAW_TEXT, "12345678901", "[20]12", 0, "123456789012", "123456789012|2012" },
/* 29*/ { BARCODE_UPCA_CC, GS1NOCHECK_MODE, -1, "123456789013", "[20]12", ZINT_ERROR_INVALID_CHECK, "" }, /* Still checked */ /* 29*/ { BARCODE_UPCA_CC, -1, -1, "123456789012", "[20]12", 0, "123456789012", "" },
/* 30*/ { BARCODE_UPCA_CC, -1, -1, "123456789012", "[20]1A", ZINT_WARN_NONCOMPLIANT, "123456789012" }, /* AI (20) should be 2 nos. */ /* 30*/ { BARCODE_UPCA_CC, -1, -1, "123456789013", "[20]12", ZINT_ERROR_INVALID_CHECK, "", "" },
/* 31*/ { BARCODE_UPCA_CC, GS1NOCHECK_MODE, -1, "123456789012", "[20]1A", 0, "123456789012" }, /* 31*/ { BARCODE_UPCA_CC, GS1NOCHECK_MODE, -1, "123456789013", "[20]12", ZINT_ERROR_INVALID_CHECK, "", "" }, /* Still checked */
/* 32*/ { BARCODE_UPCA_CC, -1, -1, "123456789012+123", "[20]12", 0, "123456789012+00123" }, /* 32*/ { BARCODE_UPCA_CC, -1, -1, "123456789012", "[20]1A", ZINT_WARN_NONCOMPLIANT, "123456789012", "" }, /* AI (20) should be 2 nos. */
/* 33*/ { BARCODE_UPCA_CC, -1, BARCODE_RAW_TEXT, "123456789012+123", "[20]12", 0, "123456789012+00123" }, /* 33*/ { BARCODE_UPCA_CC, GS1NOCHECK_MODE, -1, "123456789012", "[20]1A", 0, "123456789012", "" },
/* 34*/ { BARCODE_UPCE_CC, -1, -1, "123456", "[20]12", 0, "01234565" }, /* 34*/ { BARCODE_UPCA_CC, -1, -1, "123456789012+123", "[20]12", 0, "123456789012+00123", "" },
/* 35*/ { BARCODE_UPCE_CC, -1, BARCODE_RAW_TEXT, "123456", "[20]12", 0, "01234565" }, /* 35*/ { BARCODE_UPCA_CC, -1, BARCODE_RAW_TEXT, "123456789012+123", "[20]12", 0, "123456789012+00123", "123456789012+00123|2012" },
/* 36*/ { BARCODE_UPCE_CC, -1, -1, "1234567", "[20]12", 0, "12345670" }, /* 36*/ { BARCODE_UPCE_CC, -1, -1, "123456", "[20]12", 0, "01234565", "" },
/* 37*/ { BARCODE_UPCE_CC, -1, -1, "12345670", "[20]12", 0, "12345670" }, /* 37*/ { BARCODE_UPCE_CC, -1, BARCODE_RAW_TEXT, "123456", "[20]12", 0, "01234565", "01234565|2012" },
/* 38*/ { BARCODE_UPCE_CC, -1, -1, "12345671", "[20]12", ZINT_ERROR_INVALID_CHECK, "" }, /* 38*/ { BARCODE_UPCE_CC, -1, -1, "1234567", "[20]12", 0, "12345670", "" },
/* 39*/ { BARCODE_UPCE_CC, GS1NOCHECK_MODE, -1, "12345671", "[20]12", ZINT_ERROR_INVALID_CHECK, "" }, /* Still checked */ /* 39*/ { BARCODE_UPCE_CC, -1, -1, "12345670", "[20]12", 0, "12345670", "" },
/* 40*/ { BARCODE_UPCE_CC, -1, -1, "12345670", "[20]12", 0, "12345670" }, /* Check digit can now be given for UPCE_CC, like UPCA_CC */ /* 40*/ { BARCODE_UPCE_CC, -1, -1, "12345671", "[20]12", ZINT_ERROR_INVALID_CHECK, "", "" },
/* 41*/ { BARCODE_UPCE_CC, -1, -1, "1234567", "[20]1A", ZINT_WARN_NONCOMPLIANT, "12345670" }, /* AI (20) should be 2 nos. */ /* 41*/ { BARCODE_UPCE_CC, GS1NOCHECK_MODE, -1, "12345671", "[20]12", ZINT_ERROR_INVALID_CHECK, "", "" }, /* Still checked */
/* 42*/ { BARCODE_UPCE_CC, GS1NOCHECK_MODE, -1, "1234567", "[20]1A", 0, "12345670" }, /* 42*/ { BARCODE_UPCE_CC, -1, -1, "12345670", "[20]12", 0, "12345670", "" }, /* Check digit can now be given for UPCE_CC, like UPCA_CC */
/* 43*/ { BARCODE_UPCE_CC, -1, -1, "1234567+2", "[20]12", 0, "12345670+02" }, /* 43*/ { BARCODE_UPCE_CC, -1, -1, "1234567", "[20]1A", ZINT_WARN_NONCOMPLIANT, "12345670", "" }, /* AI (20) should be 2 nos. */
/* 44*/ { BARCODE_UPCE_CC, -1, BARCODE_RAW_TEXT, "1234567+2", "[20]12", 0, "12345670+02" }, /* 44*/ { BARCODE_UPCE_CC, GS1NOCHECK_MODE, -1, "1234567", "[20]1A", 0, "12345670", "" },
/* 45*/ { BARCODE_DBAR_STK_CC, -1, -1, "12345678901231", "[20]12", 0, "" }, /* No HRT for stacked symbologies */ /* 45*/ { BARCODE_UPCE_CC, -1, -1, "1234567+2", "[20]12", 0, "12345670+02", "" },
/* 46*/ { BARCODE_DBAR_STK_CC, -1, BARCODE_RAW_TEXT, "12345678901231", "[20]12", 0, "0112345678901231" }, /* Unless RAW_TEXT */ /* 46*/ { BARCODE_UPCE_CC, -1, BARCODE_RAW_TEXT, "1234567+2", "[20]12", 0, "12345670+02", "12345670+02|2012" },
/* 47*/ { BARCODE_DBAR_OMNSTK_CC, -1, -1, "12345678901231", "[20]12", 0, "" }, /* 47*/ { BARCODE_DBAR_STK_CC, -1, -1, "12345678901231", "[20]12", 0, "", "" }, /* No HRT for stacked symbologies */
/* 48*/ { BARCODE_DBAR_OMNSTK_CC, -1, BARCODE_RAW_TEXT, "12345678901231", "[20]12", 0, "0112345678901231" }, /* 48*/ { BARCODE_DBAR_STK_CC, -1, BARCODE_RAW_TEXT, "12345678901231", "[20]12", 0, "", "12345678901231|2012" }, /* But have RAW_TEXT */
/* 49*/ { BARCODE_DBAR_OMNSTK_CC, -1, -1, "12345678901231", "[20]12", 0, "", "" },
/* 50*/ { BARCODE_DBAR_OMNSTK_CC, -1, BARCODE_RAW_TEXT, "12345678901231", "[20]12", 0, "", "12345678901231|2012" },
}; };
const int data_size = ARRAY_SIZE(data); const int data_size = ARRAY_SIZE(data);
int i, length, composite_length, ret; int i, length, composite_length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
int expected_length; int expected_length, expected_raw_length;
testStartSymbol("test_hrt", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -3300,6 +3303,7 @@ static void test_hrt(const testCtx *const p_ctx) {
strcpy(symbol->primary, data[i].data); strcpy(symbol->primary, data[i].data);
expected_length = (int) strlen(data[i].expected); expected_length = (int) strlen(data[i].expected);
expected_raw_length = (int) strlen(data[i].expected_raw);
composite_length = (int) strlen(data[i].composite); composite_length = (int) strlen(data[i].composite);
@ -3308,7 +3312,20 @@ static void test_hrt(const testCtx *const p_ctx) {
assert_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d\n", assert_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d\n",
i, symbol->text_length, expected_length); i, symbol->text_length, expected_length);
assert_zero(strcmp((const char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected); assert_zero(strcmp((const char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
i, symbol->text, data[i].expected);
if (symbol->output_options & BARCODE_RAW_TEXT) {
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
assert_nonnull(symbol->raw_segs[0].source, "i:%d raw_segs[0].source NULL\n", i);
assert_equal(symbol->raw_segs[0].length, expected_raw_length,
"i:%d raw_segs[0].length %d != expected_raw_length %d\n",
i, symbol->raw_segs[0].length, expected_raw_length);
assert_zero(memcmp(symbol->raw_segs[0].source, data[i].expected_raw, expected_raw_length),
"i:%d memcmp(%s, %s, %d) != 0\n",
i, symbol->raw_segs[0].source, data[i].expected_raw, expected_raw_length);
} else {
assert_null(symbol->raw_segs, "i:%d raw_segs not NULL\n", i);
}
ZBarcode_Delete(symbol); ZBarcode_Delete(symbol);
} }
@ -3463,7 +3480,7 @@ static void test_input(const testCtx *const p_ctx) {
int i, length, composite_length, ret; int i, length, composite_length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_input", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -3539,7 +3556,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
testStartSymbol("test_fuzz", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {

File diff suppressed because it is too large Load diff

View file

@ -56,7 +56,7 @@ static void test_large(const testCtx *const p_ctx) {
char data_buf[4096]; char data_buf[4096];
testStartSymbol("test_large", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -128,7 +128,7 @@ static void test_options(const testCtx *const p_ctx) {
char option_3_buf[64]; char option_3_buf[64];
testStartSymbol("test_options", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -177,51 +177,52 @@ static void test_input(const testCtx *const p_ctx) {
int ret; int ret;
const char *expected; const char *expected;
int bwipp_cmp; int bwipp_cmp;
int zxingcpp_cmp;
const char *comment; const char *comment;
}; };
static const struct item data[] = { static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, 13, -1, { 0, 0, "" }, "A", -1, 0, "66 21 6A", 1, "" }, /* 0*/ { UNICODE_MODE, -1, 13, -1, { 0, 0, "" }, "A", -1, 0, "66 21 6A", 1, 1, "" },
/* 1*/ { UNICODE_MODE, 3, -1, -1, { 0, 0, "" }, "A", -1, 0, "6C 03 66 21", 1, "" }, /* 1*/ { UNICODE_MODE, 3, -1, -1, { 0, 0, "" }, "A", -1, 0, "6C 03 66 21", 1, 1, "" },
/* 2*/ { UNICODE_MODE, 40, 18, -1, { 0, 0, "" }, "A", -1, 0, "6C 28 00 00 66 21", 1, "" }, /* 2*/ { UNICODE_MODE, 40, 18, -1, { 0, 0, "" }, "A", -1, 0, "6C 28 00 00 66 21", 1, 1, "" },
/* 3*/ { UNICODE_MODE, 113, 18, -1, { 0, 0, "" }, "A", -1, 0, "6C 28 00 49 66 21", 1, "" }, /* 3*/ { UNICODE_MODE, 113, 18, -1, { 0, 0, "" }, "A", -1, 0, "6C 28 00 49 66 21", 1, 1, "" },
/* 4*/ { UNICODE_MODE, 899, 18, -1, { 0, 0, "" }, "A", -1, 0, "6C 28 07 44 66 21", 1, "" }, /* 4*/ { UNICODE_MODE, 899, 18, -1, { 0, 0, "" }, "A", -1, 0, "6C 28 07 44 66 21", 1, 1, "" },
/* 5*/ { UNICODE_MODE, 12769, 18, 8 << 8, { 0, 0, "" }, "A", -1, 0, "6C 28 70 49 66 21", 1, "" }, /* 5*/ { UNICODE_MODE, 12769, 18, 8 << 8, { 0, 0, "" }, "A", -1, 0, "6C 28 70 49 66 21", 1, 1, "" },
/* 6*/ { UNICODE_MODE, 811799, 18, -1, { 0, 0, "" }, "A", -1, 0, "6C 67 40 50 66 21", 1, "" }, /* 6*/ { UNICODE_MODE, 811799, 18, -1, { 0, 0, "" }, "A", -1, 0, "6C 67 40 50 66 21", 1, 1, "" },
/* 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, "" }, /* 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, 1, "" },
/* 8*/ { UNICODE_MODE, -1, 13, -1, { 0, 0, "" }, "\000", 1, 0, "65 40 6A", 1, "LatchA (0x65) NUL PAD" }, /* 8*/ { UNICODE_MODE, -1, 13, -1, { 0, 0, "" }, "\000", 1, 0, "65 40 6A", 1, 1, "LatchA (0x65) NUL PAD" },
/* 9*/ { UNICODE_MODE, -1, 13, -1, { 0, 0, "" }, "\010", -1, 0, "65 48 6A", 1, "LatchA (0x65) BS PAD" }, /* 9*/ { UNICODE_MODE, -1, 13, -1, { 0, 0, "" }, "\010", -1, 0, "65 48 6A", 1, 1, "LatchA (0x65) BS PAD" },
/* 10*/ { UNICODE_MODE, -1, 13, -1, { 0, 0, "" }, "\011", -1, 0, "65 49 6A", 1, "Lead special; LatchA (0x65) HT PAD" }, /* 10*/ { UNICODE_MODE, -1, 13, -1, { 0, 0, "" }, "\011", -1, 0, "65 49 6A", 1, 1, "Lead special; LatchA (0x65) HT PAD" },
/* 11*/ { UNICODE_MODE, -1, 13, -1, { 0, 0, "" }, "\034", -1, 0, "65 5C 6A", 1, "Lead special; LatchA (0x65) FS PAD" }, /* 11*/ { UNICODE_MODE, -1, 13, -1, { 0, 0, "" }, "\034", -1, 0, "65 5C 6A", 1, 1, "Lead special; LatchA (0x65) FS PAD" },
/* 12*/ { UNICODE_MODE, -1, 13, -1, { 0, 0, "" }, "\035", -1, 0, "65 5D 6A", 1, "Lead special; LatchA (0x65) GS PAD" }, /* 12*/ { UNICODE_MODE, -1, 13, -1, { 0, 0, "" }, "\035", -1, 0, "65 5D 6A", 1, 1, "Lead special; LatchA (0x65) GS PAD" },
/* 13*/ { UNICODE_MODE, -1, 13, -1, { 0, 0, "" }, "\036", -1, 0, "65 5E 6A", 1, "Lead special; LatchA (0x65) RS PAD" }, /* 13*/ { UNICODE_MODE, -1, 13, -1, { 0, 0, "" }, "\036", -1, 0, "65 5E 6A", 1, 1, "Lead special; LatchA (0x65) RS PAD" },
/* 14*/ { UNICODE_MODE, -1, 13, -1, { 0, 0, "" }, "\037", -1, 0, "65 5F 6A", 1, "LatchA (0x65) US PAD" }, /* 14*/ { UNICODE_MODE, -1, 13, -1, { 0, 0, "" }, "\037", -1, 0, "65 5F 6A", 1, 1, "LatchA (0x65) US PAD" },
/* 15*/ { UNICODE_MODE, -1, 13, -1, { 0, 0, "" }, "\177", -1, 0, "66 5F 6A", 1, "ShiftB (0x66) DEL PAD" }, /* 15*/ { UNICODE_MODE, -1, 13, -1, { 0, 0, "" }, "\177", -1, 0, "66 5F 6A", 1, 1, "ShiftB (0x66) DEL PAD" },
/* 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" }, /* 16*/ { UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "[)>\03605\035A\036\004", -1, 0, "6A 61 21", 1, 1, "[)>RS 05 GS A RS EOT; LatchB (0x6A) Macro97 (0x61) A" },
/* 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" }, /* 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, 1, "[)>RS 06 GS HT FS GS RS RS EOT; LatchB (0x6A) Macro98 (0x62) HT FS GS RS PAD" },
/* 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" }, /* 18*/ { UNICODE_MODE, -1, 17, -1, { 0, 0, "" }, "[)>\03612\03512345\036\004", -1, 0, "6A 63 11 67 17 2D 6A", 1, 1, "[)>RS 12 GS A RS EOT; LatchB (0x6A) Macro99 (0x63) 1 2xShiftC (0x67) 23 45 PAD" },
/* 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" }, /* 19*/ { UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "[)>\03601Blah\004", -1, 0, "6A 64 10 11 22 4C 41 48 6A", 1, 1, "[)>RS 01 Blah EOT; LatchB (0x6A) Macro100 (0x64) 0 1 B l a h PAD" },
/* 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" }, /* 20*/ { UNICODE_MODE, -1, 22, -1, { 0, 0, "" }, "[)>\03605\035A\004", -1, 0, "65 3B 09 1E 5E 10 15 5D 21 44", 1, 1, "NOTE: no longer using Macro for malformed 05/06/12" },
/* 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" }, /* 21*/ { UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "[)>\03606A\004", -1, 0, "65 3B 09 1E 5E 10 16 21 44", 1, 1, "NOTE: no longer using Macro for malformed 05/06/12" },
/* 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" }, /* 22*/ { UNICODE_MODE, -1, 13, -1, { 0, 0, "" }, "[)>\036991\036\004", -1, 0, "6A 64 19 19 11 64", 1, 1, "[)>RS 99 1 RS EOT; LatchB (0x6A) Macro100 (0x64) 9 9 1 RS" },
/* 23*/ { UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "1712345610", -1, 0, "6B 64 0C 22 38", 1, "FNC1 (0x6B) 17..10 12 34 56" }, /* 23*/ { UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "1712345610", -1, 0, "6B 64 0C 22 38", 1, 1, "FNC1 (0x6B) 17..10 12 34 56" },
/* 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" }, /* 24*/ { GS1_MODE, -1, -1, -1, { 0, 0, "" }, "[17]123456[10]123", -1, ZINT_WARN_NONCOMPLIANT, "64 0C 22 38 0C 66 13", 0, 1, "17..10 12 34 56 12 ShiftB (0x66) 3; BWIPP does not allow bad month" },
/* 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" }, /* 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, 1, "90 LatchB (0x6A) A B C FNC1 (0x6B) 9 0 a b c FNC1 (0x6B) 9 2xShitfC (0x67) 01 23 PAD" },
/* 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" }, /* 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, 1, "90 LatchB (0x6A) A B C FNC1 (0x6B) 9 0 a b c FNC1 (0x6B) 9 2xShitfC (0x67) 01 23 PAD" },
/* 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" }, /* 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, 1, "FNC1 (0x6B) 99 LatchB (0x6A) a A [ { 0 0 ShiftA (0x65) NUL" },
/* 28*/ { UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "\015\012", -1, 0, "66 60", 0, "ShiftB (0x66) CR/LF; BWIPP different encodation" }, /* 28*/ { UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "\015\012", -1, 0, "66 60", 0, 1, "ShiftB (0x66) CR/LF; BWIPP different encodation" },
/* 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" }, /* 29*/ { UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "A\015\012", -1, 0, "67 21 60", 0, 1, "2xShiftB (0x67) A CR/LF; BWIPP different encodation" },
/* 30*/ { UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "\015\015\012", -1, 0, "65 4D 4D 4A", 1, "LatchA (0x65) CR CR LF" }, /* 30*/ { UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "\015\015\012", -1, 0, "65 4D 4D 4A", 1, 1, "LatchA (0x65) CR CR LF" },
/* 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" }, /* 31*/ { UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "ABCDE12345678", -1, 0, "6A 21 22 23 24 25 69 0C 22 38 4E", 1, 1, "LatchB (0x6A) A B C D 4xShiftC 12 34 56 78" },
/* 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" }, /* 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, 1, "LatchA (0x65) NULL A B C D LatchC (0x6A) 12 34 56 78 90 PAD" },
/* 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" }, /* 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, 899, "LatchB (0x6A) a b c d e BinaryLatch (0x70) 0x80 0x81 0x82 0x83 0x84 0xFF" },
/* 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" }, /* 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, 899, "UpperShiftA (0x6E) NUL 12 UpperShiftB (0x6F) SP 34 BinaryLatch (0x70) 0x81 0x82 TermB (0x6E) 5 6" },
/* 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" }, /* 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, 899, "BinaryLatch (0x70) 0x80 0x81 0x82 0x83 Intr2xShiftC (0x67) 12 3" },
/* 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" }, /* 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, 899, "LatchA (0x65) SOH BinaryLatch (0x70) 0x80 0x81 0x82 0x83 0x80 0x81 0x82 0x83" },
/* 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" }, /* 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, 1, "LatchA (0x65) SOH 6xShiftB (0x65) a b c HT CR/LF RS" },
/* 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" }, /* 38*/ { UNICODE_MODE, -1, -1, -1, { 35, 35, "" }, "ABCDE", -1, 0, "6A 21 22 23 24 25 3A 3A 6C", 1, 1, "LatchB (0x6A) A B C D E Z Z FNC2" },
/* 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" }, /* 39*/ { UNICODE_MODE, -1, -1, -1, { 9, 10, "" }, "1234567890", -1, 0, "6B 0C 22 38 4E 5A 65 19 21 6C", 1, 1, "FNC1 (0x6B) 12 34 56 78 90 LatchA (0x65) 9 A FNC2" },
/* 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" }, /* 40*/ { UNICODE_MODE, -1, -1, -1, { 2, 3, "" }, "\001\002\003\004", -1, 0, "65 41 42 43 44 6A 12 13 6C", 1, 1, "LatchA (0x65) <SOH> <STX> <ETX> <EOT> PAD 2 3 FNC2" },
/* 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" }, /* 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, 899, "BinaryLatch (0x70) (...) TermA (0x6D) 1 Y FNC2" },
}; };
const int data_size = ARRAY_SIZE(data); const int data_size = ARRAY_SIZE(data);
int i, length, ret; int i, length, ret;
@ -231,10 +232,11 @@ static void test_input(const testCtx *const p_ctx) {
char cmp_buf[32768]; char cmp_buf[32768];
char cmp_msg[1024]; char cmp_msg[1024];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ /* Only do BWIPP/ZXing-C++ tests if asked, too slow otherwise */
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript();
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder();
testStartSymbol("test_input", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -256,11 +258,12 @@ static void test_input(const testCtx *const p_ctx) {
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) { if (p_ctx->generate) {
printf(" /*%3d*/ { %s, %d, %d, %d, { %d, %d, \"%s\" }, \"%s\", %d, %s, \"%s\", %d, \"%s\" },\n", printf(" /*%3d*/ { %s, %d, %d, %d, { %d, %d, \"%s\" }, \"%s\", %d, %s, \"%s\", %d, %d, \"%s\" },\n",
i, testUtilInputModeName(data[i].input_mode), data[i].eci, data[i].option_2, data[i].option_3, i, testUtilInputModeName(data[i].input_mode), data[i].eci, data[i].option_2, data[i].option_3,
data[i].structapp.index, data[i].structapp.count, data[i].structapp.id, data[i].structapp.index, data[i].structapp.count, data[i].structapp.id,
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
data[i].length, testUtilErrorName(data[i].ret), symbol->errtxt, data[i].bwipp_cmp, data[i].comment); data[i].length, testUtilErrorName(data[i].ret), symbol->errtxt, data[i].bwipp_cmp,
data[i].zxingcpp_cmp, data[i].comment);
} else { } else {
assert_zero(strcmp((char *) symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); assert_zero(strcmp((char *) symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
@ -276,19 +279,25 @@ static void test_input(const testCtx *const p_ctx) {
ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, modules_dump); ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, modules_dump);
assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n", assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n",
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, modules_dump); i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, modules_dump);
} }
} }
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) { if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) {
int cmp_len, ret_len; int cmp_len, ret_len;
char modules_dump[200 * 200 + 1]; char modules_dump[200 * 200 + 1];
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); assert_nonzero(data[i].zxingcpp_cmp, "i:%d data[i].zxingcpp_cmp == 0", i);
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1,
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); "i:%d testUtilModulesDump == -1\n", i);
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, data[i].zxingcpp_cmp,
cmp_buf, sizeof(cmp_buf), &cmp_len);
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n",
i, testUtilBarcodeName(symbol->symbology), ret);
ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len); ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length,
NULL /*primary*/, escaped, &ret_len);
assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n",
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, escaped); i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len,
escaped);
} }
} }
} }
@ -883,7 +892,7 @@ static void test_encode(const testCtx *const p_ctx) {
"10100000001010000" "10100000001010000"
"01010001000101000" "01010001000101000"
}, },
/* 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", /* 40*/ { DATA_MODE, -1, -1, { 0, 0, "" }, "\101\102\103\104\105\106\107\200\101\102\240\101", -1, 0, 18, 27, 1, 899, "Code Set B Upper Shift A Upper Shift B",
"101010100000101000101000001" "101010100000101000101000001"
"010100010101000100010101000" "010100010101000100010101000"
"000010001010100000101010101" "000010001010100000101010101"
@ -963,7 +972,7 @@ static void test_encode(const testCtx *const p_ctx) {
"0001010000010100000100010101" "0001010000010100000100010101"
"1010100010000000101010101010" "1010100010000000101010101010"
}, },
/* 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", /* 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, 899, "Binary Latch C",
"10101010000010100010101010001" "10101010000010100010101010001"
"01010001000101010001000000010" "01010001000101010001000000010"
"00001010101000101010001000001" "00001010101000101010001000001"
@ -1098,10 +1107,11 @@ static void test_encode(const testCtx *const p_ctx) {
char cmp_buf[8192]; char cmp_buf[8192];
char cmp_msg[1024]; char cmp_msg[1024];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ /* Only do BWIPP/ZXing-C++ tests if asked, too slow otherwise */
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript();
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder();
testStartSymbol("test_encode", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -1155,13 +1165,18 @@ static void test_encode(const testCtx *const p_ctx) {
} else { } else {
int cmp_len, ret_len; int cmp_len, ret_len;
char modules_dump[16384]; char modules_dump[16384];
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1,
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); "i:%d testUtilModulesDump == -1\n", i);
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, data[i].zxingcpp_cmp,
cmp_buf, sizeof(cmp_buf), &cmp_len);
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n",
i, testUtilBarcodeName(symbol->symbology), ret);
ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len); ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length,
NULL /*primary*/, escaped, &ret_len);
assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n",
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, escaped); i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf,
ret_len, escaped);
} }
} }
} }
@ -1321,7 +1336,7 @@ static void test_encode_segs(const testCtx *const p_ctx) {
"10100000100000001010101010101010001010001010000010100010001010101010000010001010000000100010001" "10100000100000001010101010101010001010001010000010100010001010101010000010001010000000100010001"
"01000001000100000101000101010100000000010001000100000101000100000100010101010101000101010100010" "01000001000100000101000101010100000000010001000100000101000100000100010101010101000101010100010"
}, },
/* 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", /* 5*/ { DATA_MODE, -1, -1, { 0, 0, "" }, { { TU("\266"), 1, 0 }, { TU("\266"), 1, 7 }, { TU("\266"), 1, 0 } }, 0, 15, 22, 1, 0, "Standard example + extra seg, data mode",
"1000101010000000001000" "1000101010000000001000"
"0100000101000101000001" "0100000101000101000001"
"1000001000100010101000" "1000001000100010101000"
@ -1363,7 +1378,7 @@ static void test_encode_segs(const testCtx *const p_ctx) {
"01010000010100010001010000010000010101" "01010000010100010001010000010000010101"
"10000010100000001010100000100010001010" "10000010100000001010100000100010001010"
}, },
/* 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", /* 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 UTF-8 binary",
"10001010001010101000000010001" "10001010001010101000000010001"
"01000001000100010100010101010" "01000001000100010100010101010"
"10000000100000100000000010101" "10000000100000100000000010101"
@ -1385,7 +1400,7 @@ static void test_encode_segs(const testCtx *const p_ctx) {
"10101000101010000010001010001" "10101000101010000010001010001"
"01010101010100010001010001010" "01010101010100010001010001010"
}, },
/* 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", /* 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 UTF-8 binary",
"10101000100000101000001010001" "10101000100000101000001010001"
"00010101000000000100010100000" "00010101000000000100010100000"
"10100010001010000010101010100" "10100010001010000010101010100"
@ -1481,7 +1496,7 @@ static void test_encode_segs(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */
testStartSymbol("test_encode_segs", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -1543,21 +1558,25 @@ static void test_encode_segs(const testCtx *const p_ctx) {
if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d %s not ZXing-C++ compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), data[i].comment); if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d %s not ZXing-C++ compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), data[i].comment);
} else if (data[i].input_mode == DATA_MODE) { } else if (data[i].input_mode == DATA_MODE) {
if (debug & ZINT_DEBUG_TEST_PRINT) { if (debug & ZINT_DEBUG_TEST_PRINT) {
printf("i:%d multiple segments in DATA_MODE not currently supported for ZXing-C++ testing (%s)\n", printf("i:%d %s multiple segments in DATA_MODE not currently supported for ZXing-C++ testing\n",
i, testUtilBarcodeName(symbol->symbology)); i, testUtilBarcodeName(symbol->symbology));
} }
} else { } else {
int cmp_len, ret_len; int cmp_len, ret_len;
char modules_dump[16384]; char modules_dump[16384];
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1,
ret = testUtilZXingCPP(i, symbol, (const char *) data[i].segs[0].source, data[i].segs[0].length, "i:%d testUtilModulesDump == -1\n", i);
modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); ret = testUtilZXingCPP(i, symbol, (const char *) data[i].segs[0].source,
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); data[i].segs[0].length, modules_dump, data[i].zxingcpp_cmp, cmp_buf,
sizeof(cmp_buf), &cmp_len);
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n",
i, testUtilBarcodeName(symbol->symbology), ret);
ret = testUtilZXingCPPCmpSegs(symbol, cmp_msg, cmp_buf, cmp_len, data[i].segs, seg_count, ret = testUtilZXingCPPCmpSegs(symbol, cmp_msg, cmp_buf, cmp_len, data[i].segs, seg_count,
NULL /*primary*/, escaped, &ret_len); NULL /*primary*/, escaped, &ret_len);
assert_zero(ret, "i:%d %s testUtilZXingCPPCmpSegs %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", assert_zero(ret, "i:%d %s testUtilZXingCPPCmpSegs %d != 0 %s\n actual: %.*s\nexpected: %.*s\n",
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, escaped); i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf,
ret_len, escaped);
} }
} }
} }
@ -1569,6 +1588,181 @@ static void test_encode_segs(const testCtx *const p_ctx) {
testFinish(); testFinish();
} }
static void test_rt(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
int input_mode;
int eci;
int output_options;
const char *data;
int length;
int ret;
int expected_eci;
const char *expected;
int expected_length;
int expected_raw_eci;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, -1, "é", -1, 0, 0, "", -1, 0 },
/* 1*/ { UNICODE_MODE, -1, BARCODE_RAW_TEXT, "é", -1, 0, 0, "\351", -1, 3 },
/* 2*/ { UNICODE_MODE, -1, -1, "", -1, ZINT_WARN_USES_ECI, 13, "", -1, 0 },
/* 3*/ { UNICODE_MODE, -1, BARCODE_RAW_TEXT, "", -1, ZINT_WARN_USES_ECI, 13, "\241", -1, 13 },
/* 4*/ { UNICODE_MODE | ESCAPE_MODE, -1, -1, "[)>\\R05\\GA\\R\\E", -1, 0, 0, "", -1, 0 },
/* 5*/ { UNICODE_MODE | ESCAPE_MODE, -1, BARCODE_RAW_TEXT, "[)>\\R05\\GA\\R\\E", -1, 0, 0, "[)>\03605\035A\036\004", -1, 3 },
/* 6*/ { DATA_MODE, -1, -1, "\351", -1, 0, 0, "", -1, 0 },
/* 7*/ { DATA_MODE, -1, BARCODE_RAW_TEXT, "\351", -1, 0, 0, "\351", -1, 3 },
/* 8*/ { UNICODE_MODE, 26, -1, "é", -1, 0, 26, "", -1, 0 },
/* 9*/ { UNICODE_MODE, 26, BARCODE_RAW_TEXT, "é", -1, 0, 26, "é", -1, 26 },
/* 10*/ { UNICODE_MODE, 899, -1, "é", -1, 0, 899, "", -1, 0 },
/* 11*/ { UNICODE_MODE, 899, BARCODE_RAW_TEXT, "é", -1, 0, 899, "é", -1, 899 },
/* 12*/ { GS1_MODE, -1, -1, "[01]04912345123459[15]970331[30]128[10]ABC123", -1, 0, 0, "", -1, 0 },
/* 13*/ { GS1_MODE, -1, BARCODE_RAW_TEXT, "[01]04912345123459[15]970331[30]128[10]ABC123", -1, 0, 0, "01049123451234591597033130128\03510ABC123", -1, 3 },
};
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
int expected_length;
char escaped[4096];
char escaped2[4096];
testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) {
if (testContinue(p_ctx, i)) continue;
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
length = testUtilSetSymbol(symbol, BARCODE_DOTCODE, data[i].input_mode, data[i].eci,
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options,
data[i].data, data[i].length, debug);
expected_length = data[i].expected_length == -1 ? (int) strlen(data[i].expected) : data[i].expected_length;
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < ZINT_ERROR) {
assert_equal(symbol->eci, data[i].expected_eci, "i:%d eci %d != %d\n",
i, symbol->eci, data[i].expected_eci);
if (symbol->output_options & BARCODE_RAW_TEXT) {
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
assert_nonnull(symbol->raw_segs[0].source, "i:%d raw_segs[0].source NULL\n", i);
assert_equal(symbol->raw_segs[0].length, expected_length,
"i:%d raw_segs[0].length %d != expected_length %d\n",
i, symbol->raw_segs[0].length, expected_length);
assert_zero(memcmp(symbol->raw_segs[0].source, data[i].expected, expected_length),
"i:%d raw_segs[0].source memcmp(%s, %s, %d) != 0\n", i,
testUtilEscape((const char *) symbol->raw_segs[0].source, symbol->raw_segs[0].length,
escaped, sizeof(escaped)),
testUtilEscape(data[i].expected, expected_length, escaped2, sizeof(escaped2)),
expected_length);
assert_equal(symbol->raw_segs[0].eci, data[i].expected_raw_eci,
"i:%d raw_segs[0].eci %d != expected_raw_eci %d\n",
i, symbol->raw_segs[0].eci, data[i].expected_raw_eci);
} else {
assert_null(symbol->raw_segs, "i:%d raw_segs not NULL\n", i);
}
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_rt_segs(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
int input_mode;
int output_options;
struct zint_seg segs[3];
int ret;
int expected_rows;
int expected_width;
struct zint_seg expected_raw_segs[3];
int expected_raw_seg_count;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, { { TU(""), -1, 0 }, { TU("Ж"), -1, 7 }, {0} }, 0, 12, 19, {{0}}, 0 },
/* 1*/ { UNICODE_MODE, BARCODE_RAW_TEXT, { { TU(""), -1, 0 }, { TU("Ж"), -1, 7 }, { TU(""), 0, 0 } }, 0, 12, 19, { { TU("\266"), 1, 3 }, { TU("\266"), 1, 7 }, {0} }, 2 },
/* 2*/ { UNICODE_MODE, -1, { { TU("éé"), -1, 0 }, { TU("กขฯ"), -1, 0 }, { TU("βββ"), -1, 0 } }, ZINT_WARN_USES_ECI, 19, 28, {{0}}, 0 },
/* 3*/ { UNICODE_MODE, BARCODE_RAW_TEXT, { { TU("éé"), -1, 0 }, { TU("กขฯ"), -1, 0 }, { TU("βββ"), -1, 0 } }, ZINT_WARN_USES_ECI, 19, 28, { { TU("\351\351"), 2, 3 }, { TU("\241\242\317"), 3, 13 }, { TU("\342\342\342"), 3, 9 } }, 3 },
/* 4*/ { DATA_MODE, -1, { { TU(""), -1, 26 }, { TU("Ж"), -1, 0 }, { TU("\223\137"), -1, 20 } }, 0, 19, 28, {{0}}, 0 },
/* 5*/ { DATA_MODE, BARCODE_RAW_TEXT, { { TU(""), -1, 26 }, { TU("Ж"), -1, 0 }, { TU("\223\137"), -1, 20 } }, 0, 19, 28, { { TU(""), 2, 26 }, { TU("\320\226"), 2, 3 }, { TU("\223\137"), 2, 20 } }, 3 },
};
const int data_size = ARRAY_SIZE(data);
int i, j, seg_count, ret;
struct zint_symbol *symbol = NULL;
int expected_length;
char escaped[4096];
char escaped2[4096];
testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) {
if (testContinue(p_ctx, i)) continue;
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
testUtilSetSymbol(symbol, BARCODE_DOTCODE, data[i].input_mode, -1 /*eci*/,
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options,
NULL, 0, debug);
for (j = 0, seg_count = 0; j < 3 && data[i].segs[j].length; j++, seg_count++);
ret = ZBarcode_Encode_Segs(symbol, data[i].segs, seg_count);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode_Segs ret %d != %d (%s)\n",
i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (width %d)\n",
i, symbol->rows, data[i].expected_rows, symbol->width);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n",
i, symbol->width, data[i].expected_width);
assert_equal(symbol->raw_seg_count, data[i].expected_raw_seg_count, "i:%d symbol->raw_seg_count %d != %d\n",
i, symbol->raw_seg_count, data[i].expected_raw_seg_count);
if (symbol->output_options & BARCODE_RAW_TEXT) {
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
for (j = 0; j < symbol->raw_seg_count; j++) {
assert_nonnull(symbol->raw_segs[j].source, "i:%d raw_segs[%d].source NULL\n", i, j);
expected_length = data[i].expected_raw_segs[j].length;
assert_equal(symbol->raw_segs[j].length, expected_length,
"i:%d raw_segs[%d].length %d != expected_length %d\n",
i, j, symbol->raw_segs[j].length, expected_length);
assert_zero(memcmp(symbol->raw_segs[j].source, data[i].expected_raw_segs[j].source, expected_length),
"i:%d raw_segs[%d].source memcmp(%s, %s, %d) != 0\n", i, j,
testUtilEscape((const char *) symbol->raw_segs[j].source, expected_length, escaped,
sizeof(escaped)),
testUtilEscape((const char *) data[i].expected_raw_segs[j].source, expected_length,
escaped2, sizeof(escaped2)),
expected_length);
assert_equal(symbol->raw_segs[j].eci, data[i].expected_raw_segs[j].eci,
"i:%d raw_segs[%d].eci %d != expected_raw_segs.eci %d\n",
i, j, symbol->raw_segs[j].eci, data[i].expected_raw_segs[j].eci);
}
} else {
assert_null(symbol->raw_segs, "i:%d raw_segs not NULL\n", i);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
/* #181 Christian Hartlage / Nico Gunkel OSS-Fuzz */ /* #181 Christian Hartlage / Nico Gunkel OSS-Fuzz */
static void test_fuzz(const testCtx *const p_ctx) { static void test_fuzz(const testCtx *const p_ctx) {
int debug = p_ctx->debug; int debug = p_ctx->debug;
@ -1608,7 +1802,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_fuzz", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -1771,6 +1965,8 @@ int main(int argc, char *argv[]) {
{ "test_input", test_input }, { "test_input", test_input },
{ "test_encode", test_encode }, { "test_encode", test_encode },
{ "test_encode_segs", test_encode_segs }, { "test_encode_segs", test_encode_segs },
{ "test_rt", test_rt },
{ "test_rt_segs", test_rt_segs },
{ "test_fuzz", test_fuzz }, { "test_fuzz", test_fuzz },
{ "test_generate", test_generate }, { "test_generate", test_generate },
{ "test_perf", test_perf }, { "test_perf", test_perf },

View file

@ -39,30 +39,31 @@ static void test_hrt(const testCtx *const p_ctx) {
const char *data; const char *data;
const char *expected; const char *expected;
const char *expected_raw;
}; };
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = { static const struct item data[] = {
/* 0*/ { -1, "79-7", "" }, /* None */ /* 0*/ { -1, "79-7", "", "" }, /* None */
/* 1*/ { BARCODE_RAW_TEXT, "79-7", "1271" }, /* 1*/ { BARCODE_RAW_TEXT, "79-7", "", "1271" },
/* 2*/ { -1, "1271", "" }, /* None */ /* 2*/ { -1, "1271", "", "" }, /* None */
/* 3*/ { BARCODE_RAW_TEXT, "1271", "1271" }, /* 3*/ { BARCODE_RAW_TEXT, "1271", "", "1271" },
/* 4*/ { -1, "012710", "" }, /* None */ /* 4*/ { -1, "012710", "", "" }, /* None */
/* 5*/ { BARCODE_RAW_TEXT, "012710", "1271" }, /* 5*/ { BARCODE_RAW_TEXT, "012710", "", "1271" },
/* 6*/ { -1, "1-0", "" }, /* None */ /* 6*/ { -1, "1-0", "", "" }, /* None */
/* 7*/ { BARCODE_RAW_TEXT, "1-0", "0016" }, /* 7*/ { BARCODE_RAW_TEXT, "1-0", "", "0016" },
/* 8*/ { -1, "2047/63A", "" }, /* None */ /* 8*/ { -1, "2047/63A", "", "" }, /* None */
/* 9*/ { BARCODE_RAW_TEXT, "2047/63A", "204763A" }, /* 9*/ { BARCODE_RAW_TEXT, "2047/63A", "", "204763A" },
/* 10*/ { -1, "79-7/1", "" }, /* None */ /* 10*/ { -1, "79-7/1", "", "" }, /* None */
/* 11*/ { BARCODE_RAW_TEXT, "79-7/1", "12711" }, /* 11*/ { BARCODE_RAW_TEXT, "79-7/1", "", "12711" },
/* 12*/ { -1, "79-7/sa", "" }, /* None */ /* 12*/ { -1, "79-7/sa", "", "" }, /* None */
/* 13*/ { BARCODE_RAW_TEXT, "79-7/sa", "127162A" }, /* 13*/ { BARCODE_RAW_TEXT, "79-7/sa", "", "127162A" },
}; };
const int data_size = ARRAY_SIZE(data); const int data_size = ARRAY_SIZE(data);
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
int expected_length; int expected_length, expected_raw_length;
testStartSymbol("test_hrt", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -75,6 +76,7 @@ static void test_hrt(const testCtx *const p_ctx) {
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options, -1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options,
data[i].data, -1, debug); data[i].data, -1, debug);
expected_length = (int) strlen(data[i].expected); expected_length = (int) strlen(data[i].expected);
expected_raw_length = (int) strlen(data[i].expected_raw);
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt); assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
@ -83,6 +85,18 @@ static void test_hrt(const testCtx *const p_ctx) {
i, symbol->text_length, expected_length, symbol->text); i, symbol->text_length, expected_length, symbol->text);
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
i, symbol->text, data[i].expected); i, symbol->text, data[i].expected);
if (symbol->output_options & BARCODE_RAW_TEXT) {
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
assert_nonnull(symbol->raw_segs[0].source, "i:%d raw_segs[0].source NULL\n", i);
assert_equal(symbol->raw_segs[0].length, expected_raw_length,
"i:%d raw_segs[0].length %d != expected_raw_length %d\n",
i, symbol->raw_segs[0].length, expected_raw_length);
assert_zero(memcmp(symbol->raw_segs[0].source, data[i].expected_raw, expected_raw_length),
"i:%d memcmp(%s, %s, %d) != 0\n",
i, symbol->raw_segs[0].source, data[i].expected_raw, expected_raw_length);
} else {
assert_null(symbol->raw_segs, "i:%d raw_segs not NULL\n", i);
}
ZBarcode_Delete(symbol); ZBarcode_Delete(symbol);
} }
@ -133,7 +147,7 @@ static void test_input(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_input", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -283,9 +297,10 @@ static void test_encode(const testCtx *const p_ctx) {
char cmp_buf[4096]; char cmp_buf[4096];
char cmp_msg[1024]; char cmp_msg[1024];
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ /* Only do ZXing-C++ test if asked, too slow otherwise */
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder();
testStartSymbol("test_encode", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -318,13 +333,18 @@ static void test_encode(const testCtx *const p_ctx) {
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) { if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) {
int cmp_len, ret_len; int cmp_len, ret_len;
char modules_dump[8192 + 1]; char modules_dump[8192 + 1];
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1,
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); "i:%d testUtilModulesDump == -1\n", i);
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, 1 /*zxingcpp_cmp*/, cmp_buf,
sizeof(cmp_buf), &cmp_len);
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n",
i, testUtilBarcodeName(symbol->symbology), ret);
ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len); ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length,
NULL /*primary*/, escaped, &ret_len);
assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n",
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, escaped); i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len,
escaped);
} }
} }
} }

View file

@ -65,7 +65,7 @@ static void test_bom(const testCtx *const p_ctx) {
int width, height; int width, height;
testStart("test_bom"); testStart(p_ctx->func_name);
symbol = ZBarcode_Create(); symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n"); assert_nonnull(symbol, "Symbol not created\n");
@ -98,7 +98,7 @@ static void test_iso_8859_16(const testCtx *const p_ctx) {
int length, ret; int length, ret;
struct zint_symbol *symbol; struct zint_symbol *symbol;
testStart("test_iso_8859_16"); testStart(p_ctx->func_name);
symbol = ZBarcode_Create(); symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n"); assert_nonnull(symbol, "Symbol not created\n");
@ -385,7 +385,7 @@ static void test_reduced_charset_input(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol; struct zint_symbol *symbol;
testStart("test_reduced_charset_input"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -695,7 +695,7 @@ static void test_utf8_to_eci_sb(const testCtx *const p_ctx) {
unsigned char source[5]; unsigned char source[5];
unsigned char dest[2] = {0}; unsigned char dest[2] = {0};
testStart("test_utf8_to_eci_sb"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int j; int j;
@ -774,7 +774,7 @@ static void test_utf8_to_eci_ascii(const testCtx *const p_ctx) {
char dest[128] = {0}; /* Suppress clang -fsanitize=memory false positive */ char dest[128] = {0}; /* Suppress clang -fsanitize=memory false positive */
testStart("test_utf8_to_eci_ascii"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int out_length; int out_length;
@ -825,7 +825,7 @@ static void test_utf8_to_eci_utf16be(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
const int eci = 25; const int eci = 25;
testStart("test_utf8_to_eci_utf16be"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int out_length, eci_length; int out_length, eci_length;
@ -890,7 +890,7 @@ static void test_utf8_to_eci_utf16le(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
const int eci = 33; const int eci = 33;
testStart("test_utf8_to_eci_utf16le"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int out_length, eci_length; int out_length, eci_length;
@ -952,7 +952,7 @@ static void test_utf8_to_eci_utf32be(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
const int eci = 34; const int eci = 34;
testStart("test_utf8_to_eci_utf32be"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int out_length, eci_length; int out_length, eci_length;
@ -1016,7 +1016,7 @@ static void test_utf8_to_eci_utf32le(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
const int eci = 35; const int eci = 35;
testStart("test_utf8_to_eci_utf32le"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int out_length, eci_length; int out_length, eci_length;
@ -1084,7 +1084,7 @@ static void test_utf8_to_eci_sjis(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
const int eci = 20; const int eci = 20;
testStart("test_utf8_to_eci_sjis"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int out_length, eci_length; int out_length, eci_length;
@ -1130,7 +1130,7 @@ static void test_utf8_to_eci_big5(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
const int eci = 28; const int eci = 28;
testStart("test_utf8_to_eci_big5"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int out_length, eci_length; int out_length, eci_length;
@ -1176,7 +1176,7 @@ static void test_utf8_to_eci_gb2312(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
const int eci = 29; const int eci = 29;
testStart("test_utf8_to_eci_gb2312"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int out_length, eci_length; int out_length, eci_length;
@ -1222,7 +1222,7 @@ static void test_utf8_to_eci_euc_kr(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
const int eci = 30; const int eci = 30;
testStart("test_utf8_to_eci_euc_kr"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int out_length, eci_length; int out_length, eci_length;
@ -1268,7 +1268,7 @@ static void test_utf8_to_eci_gbk(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
const int eci = 31; const int eci = 31;
testStart("test_utf8_to_eci_gbk"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int out_length, eci_length; int out_length, eci_length;
@ -1314,7 +1314,7 @@ static void test_utf8_to_eci_gb18030(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
const int eci = 32; const int eci = 32;
testStart("test_utf8_to_eci_gb18030"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int out_length, eci_length; int out_length, eci_length;
@ -1366,7 +1366,7 @@ static void test_is_eci_convertible_segs(const testCtx *const p_ctx) {
int convertible[3]; int convertible[3];
testStart("test_is_eci_convertible_segs"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -1405,7 +1405,7 @@ static void test_get_best_eci(const testCtx *const p_ctx) {
int data_size = ARRAY_SIZE(data); int data_size = ARRAY_SIZE(data);
int i, length, ret; int i, length, ret;
testStart("test_get_best_eci"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -1443,7 +1443,7 @@ static void test_get_best_eci_segs(const testCtx *const p_ctx) {
int i, j, seg_count, ret; int i, j, seg_count, ret;
struct zint_symbol *symbol; struct zint_symbol *symbol;
testStart("test_get_best_eci_segs"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {

View file

@ -112,7 +112,7 @@ static void test_print(const testCtx *const p_ctx) {
have_libreoffice = testUtilHaveLibreOffice(); have_libreoffice = testUtilHaveLibreOffice();
} }
testStartSymbol("test_print", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
if (p_ctx->generate) { if (p_ctx->generate) {
char data_dir_path[1024]; char data_dir_path[1024];
@ -219,7 +219,7 @@ static void test_outfile(const testCtx *const p_ctx) {
(void)p_ctx; (void)p_ctx;
testStart("test_outfile"); testStart(p_ctx->func_name);
symbol.symbology = BARCODE_CODE128; symbol.symbology = BARCODE_CODE128;
symbol.vector = &vector; symbol.vector = &vector;

View file

@ -73,7 +73,7 @@ static void test_svg(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_svg", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -154,7 +154,7 @@ static void test_putsf(const testCtx *const p_ctx) {
char buf[512] = {0}; /* Suppress clang-16/17 run-time exception MemorySanitizer: use-of-uninitialized-value */ char buf[512] = {0}; /* Suppress clang-16/17 run-time exception MemorySanitizer: use-of-uninitialized-value */
#endif #endif
testStart("test_putsf"); testStart(p_ctx->func_name);
for (j = 0; j < 2; j++) { /* 1st `memfile`, then file */ for (j = 0; j < 2; j++) { /* 1st `memfile`, then file */
#ifdef ZINT_TEST_NO_FMEMOPEN #ifdef ZINT_TEST_NO_FMEMOPEN
@ -247,7 +247,7 @@ static void test_printf(const testCtx *const p_ctx) {
(void)debug; (void)debug;
testStart("test_printf"); testStart(p_ctx->func_name);
for (j = 0; j < 2; j++) { /* 1st memfile, then file */ for (j = 0; j < 2; j++) { /* 1st memfile, then file */
ZBarcode_Reset(symbol); ZBarcode_Reset(symbol);
@ -344,7 +344,7 @@ static void test_seek(const testCtx *const p_ctx) {
(void)debug; (void)debug;
testStart("test_seek"); testStart(p_ctx->func_name);
for (j = 0; j < 2; j++) { /* 1st memfile, then file */ for (j = 0; j < 2; j++) { /* 1st memfile, then file */
ZBarcode_Reset(symbol); ZBarcode_Reset(symbol);
@ -434,7 +434,7 @@ static void test_large(const testCtx *const p_ctx) {
(void)debug; (void)debug;
testStart("test_large"); testStart(p_ctx->func_name);
symbol = ZBarcode_Create(); symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n"); assert_nonnull(symbol, "Symbol not created\n");

View file

@ -173,7 +173,7 @@ static void test_u_gb18030_int(const testCtx *const p_ctx) {
(void)debug; (void)debug;
#endif #endif
testStart("test_u_gb18030_int"); testStart(p_ctx->func_name);
#ifdef TEST_JUST_SAY_GNO #ifdef TEST_JUST_SAY_GNO
if ((debug & ZINT_DEBUG_TEST_PERFORMANCE)) { /* -d 256 */ if ((debug & ZINT_DEBUG_TEST_PERFORMANCE)) { /* -d 256 */
@ -284,7 +284,7 @@ static void test_gb18030_utf8(const testCtx *const p_ctx) {
struct zint_symbol symbol = {0}; struct zint_symbol symbol = {0};
unsigned int gbdata[30] = {0}; /* Suppress clang -fsanitize=memory false positive */ unsigned int gbdata[30] = {0}; /* Suppress clang -fsanitize=memory false positive */
testStart("test_gb18030_utf8"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int ret_length; int ret_length;
@ -401,7 +401,7 @@ static void test_gb18030_utf8_to_eci(const testCtx *const p_ctx) {
unsigned int gbdata[30] = {0}; /* Suppress clang -fsanitize=memory false positive */ unsigned int gbdata[30] = {0}; /* Suppress clang -fsanitize=memory false positive */
testStart("test_gb18030_utf8_to_eci"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int ret_length; int ret_length;
@ -457,7 +457,7 @@ static void test_gb18030_cpy(const testCtx *const p_ctx) {
unsigned int gbdata[30] = {0}; /* Suppress clang -fsanitize=memory false positive */ unsigned int gbdata[30] = {0}; /* Suppress clang -fsanitize=memory false positive */
testStart("test_gb18030_cpy"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int ret_length; int ret_length;
@ -508,7 +508,7 @@ static void test_u_gbk_int(const testCtx *const p_ctx) {
unsigned int val, val2; unsigned int val, val2;
unsigned int i; unsigned int i;
testStart("test_u_gbk_int"); testStart(p_ctx->func_name);
for (i = 0; i < 0xFFFE; i++) { for (i = 0; i < 0xFFFE; i++) {
if (i >= 0xD800 && i <= 0xDFFF) { /* UTF-16 surrogates */ if (i >= 0xD800 && i <= 0xDFFF) { /* UTF-16 surrogates */

View file

@ -92,7 +92,7 @@ static void test_u_gb2312_int(const testCtx *const p_ctx) {
(void)debug; (void)debug;
#endif #endif
testStart("test_u_gb2312_int"); testStart(p_ctx->func_name);
#ifdef TEST_JUST_SAY_GNO #ifdef TEST_JUST_SAY_GNO
if ((debug & ZINT_DEBUG_TEST_PERFORMANCE)) { /* -d 256 */ if ((debug & ZINT_DEBUG_TEST_PERFORMANCE)) { /* -d 256 */
@ -190,7 +190,7 @@ static void test_gb2312_utf8(const testCtx *const p_ctx) {
struct zint_symbol symbol = {0}; struct zint_symbol symbol = {0};
unsigned int gbdata[20] = {0}; /* Suppress clang -fsanitize=memory false positive */ unsigned int gbdata[20] = {0}; /* Suppress clang -fsanitize=memory false positive */
testStart("test_gb2312_utf8"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int ret_length; int ret_length;
@ -292,7 +292,7 @@ static void test_gb2312_utf8_to_eci(const testCtx *const p_ctx) {
unsigned int gbdata[20] = {0}; /* Suppress clang -fsanitize=memory false positive */ unsigned int gbdata[20] = {0}; /* Suppress clang -fsanitize=memory false positive */
testStart("test_gb2312_utf8_to_eci"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int ret_length; int ret_length;
@ -348,7 +348,7 @@ static void test_gb2312_cpy(const testCtx *const p_ctx) {
unsigned int gbdata[20] = {0}; /* Suppress clang -fsanitize=memory false positive */ unsigned int gbdata[20] = {0}; /* Suppress clang -fsanitize=memory false positive */
testStart("test_gb2312_cpy"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int ret_length; int ret_length;

View file

@ -68,7 +68,7 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
const char *const have_identify = testUtilHaveIdentify(); const char *const have_identify = testUtilHaveIdentify();
testStart("test_pixel_plot"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int size; int size;
@ -196,7 +196,7 @@ static void test_print(const testCtx *const p_ctx) {
const char *const have_identify = testUtilHaveIdentify(); const char *const have_identify = testUtilHaveIdentify();
testStartSymbol("test_print", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
if (p_ctx->generate) { if (p_ctx->generate) {
char data_dir_path[1024]; char data_dir_path[1024];
@ -303,7 +303,7 @@ static void test_outfile(const testCtx *const p_ctx) {
(void)p_ctx; (void)p_ctx;
testStart("test_outfile"); testStart(p_ctx->func_name);
symbol.symbology = BARCODE_CODE128; symbol.symbology = BARCODE_CODE128;
symbol.bitmap = data; symbol.bitmap = data;
@ -341,7 +341,7 @@ static void test_large_scale(const testCtx *const p_ctx) {
struct zint_symbol symbol = {0}; struct zint_symbol symbol = {0};
char data[] = "1"; char data[] = "1";
testStart("test_large_scale"); testStart(p_ctx->func_name);
length = (int) strlen(data); length = (int) strlen(data);
@ -373,7 +373,7 @@ static void test_too_big(const testCtx *const p_ctx) {
(void)debug; (void)debug;
testStart("test_too_big"); testStart(p_ctx->func_name);
length = (int) strlen(data); length = (int) strlen(data);

View file

@ -95,7 +95,7 @@ static void test_large(const testCtx *const p_ctx) {
char data_buf[2800 + 1]; char data_buf[2800 + 1];
testStartSymbol("test_large", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -173,7 +173,7 @@ static void test_options(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_options", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -364,7 +364,7 @@ static void test_input(const testCtx *const p_ctx) {
char escaped[1024]; char escaped[1024];
testStartSymbol("test_input", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -520,7 +520,7 @@ static void test_encode(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_encode", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -857,7 +857,7 @@ static void test_encode_segs(const testCtx *const p_ctx) {
char escaped[8192]; char escaped[8192];
testStartSymbol("test_encode_segs", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -907,6 +907,190 @@ static void test_encode_segs(const testCtx *const p_ctx) {
testFinish(); testFinish();
} }
static void test_rt(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
int input_mode;
int eci;
int option_3;
int output_options;
const char *data;
int length;
int ret;
int expected_eci;
const char *expected;
int expected_length;
int expected_raw_eci;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, -1, -1, "é", -1, 0, 0, "", -1, 0 },
/* 1*/ { UNICODE_MODE, -1, -1, BARCODE_RAW_TEXT, "é", -1, 0, 0, "\250\246", -1, 29 },
/* 2*/ { UNICODE_MODE, -1, -1, -1, "", -1, ZINT_WARN_USES_ECI, 13, "", -1, 0 },
/* 3*/ { UNICODE_MODE, -1, -1, BARCODE_RAW_TEXT, "", -1, ZINT_WARN_USES_ECI, 13, "\241", -1, 13 },
/* 4*/ { UNICODE_MODE, -1, -1, -1, "", -1, 0, 0, "", -1, 0 },
/* 5*/ { UNICODE_MODE, -1, -1, BARCODE_RAW_TEXT, "", -1, 0, 0, "\265\347", -1, 29 },
/* 6*/ { DATA_MODE, -1, -1, -1, "\351", -1, 0, 0, "", -1, 0 },
/* 7*/ { DATA_MODE, -1, -1, BARCODE_RAW_TEXT, "\351", -1, 0, 0, "\351", -1, 29 },
/* 8*/ { DATA_MODE, -1, ZINT_FULL_MULTIBYTE, -1, "\351", -1, 0, 0, "", -1, 0 },
/* 9*/ { DATA_MODE, -1, ZINT_FULL_MULTIBYTE, BARCODE_RAW_TEXT, "\351", -1, 0, 0, "\351", -1, 29 },
/* 10*/ { DATA_MODE, -1, ZINT_FULL_MULTIBYTE, -1, "\265\347", -1, 0, 0, "", -1, 0 },
/* 11*/ { DATA_MODE, -1, ZINT_FULL_MULTIBYTE, BARCODE_RAW_TEXT, "\265\347", -1, 0, 0, "\265\347", -1, 29 },
/* 12*/ { UNICODE_MODE, 26, -1, -1, "é", -1, 0, 26, "", -1, 0 },
/* 13*/ { UNICODE_MODE, 26, -1, BARCODE_RAW_TEXT, "é", -1, 0, 26, "é", -1, 26 },
/* 14*/ { UNICODE_MODE, 899, -1, -1, "é", -1, 0, 899, "", -1, 0 },
/* 15*/ { UNICODE_MODE, 899, -1, BARCODE_RAW_TEXT, "é", -1, 0, 899, "é", -1, 899 },
};
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
int expected_length;
char escaped[4096];
char escaped2[4096];
testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) {
if (testContinue(p_ctx, i)) continue;
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
length = testUtilSetSymbol(symbol, BARCODE_GRIDMATRIX, data[i].input_mode, data[i].eci,
-1 /*option_1*/, -1 /*option_2*/, data[i].option_3, data[i].output_options,
data[i].data, data[i].length, debug);
expected_length = data[i].expected_length == -1 ? (int) strlen(data[i].expected) : data[i].expected_length;
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < ZINT_ERROR) {
assert_equal(symbol->eci, data[i].expected_eci, "i:%d eci %d != %d\n",
i, symbol->eci, data[i].expected_eci);
if (symbol->output_options & BARCODE_RAW_TEXT) {
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
assert_nonnull(symbol->raw_segs[0].source, "i:%d raw_segs[0].source NULL\n", i);
assert_equal(symbol->raw_segs[0].length, expected_length,
"i:%d raw_segs[0].length %d != expected_length %d\n",
i, symbol->raw_segs[0].length, expected_length);
assert_zero(memcmp(symbol->raw_segs[0].source, data[i].expected, expected_length),
"i:%d raw_segs[0].source memcmp(%s, %s, %d) != 0\n", i,
testUtilEscape((const char *) symbol->raw_segs[0].source, symbol->raw_segs[0].length,
escaped, sizeof(escaped)),
testUtilEscape(data[i].expected, expected_length, escaped2, sizeof(escaped2)),
expected_length);
assert_equal(symbol->raw_segs[0].eci, data[i].expected_raw_eci,
"i:%d raw_segs[0].eci %d != expected_raw_eci %d\n",
i, symbol->raw_segs[0].eci, data[i].expected_raw_eci);
} else {
assert_null(symbol->raw_segs, "i:%d raw_segs not NULL\n", i);
}
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_rt_segs(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
int input_mode;
int output_options;
struct zint_seg segs[3];
int ret;
int expected_rows;
int expected_width;
struct zint_seg expected_raw_segs[3];
int expected_raw_seg_count;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, { { TU(""), -1, 0 }, { TU("Ж"), -1, 7 }, {0} }, ZINT_WARN_USES_ECI, 30, 30, {{0}}, 0 },
/* 1*/ { UNICODE_MODE, BARCODE_RAW_TEXT, { { TU(""), -1, 0 }, { TU("Ж"), -1, 7 }, { TU(""), 0, 0 } }, ZINT_WARN_USES_ECI, 30, 30, { { TU("\266"), 1, 3 }, { TU("\266"), 1, 7 }, {0} }, 2 },
/* 2*/ { UNICODE_MODE, -1, { { TU(""), -1, 0 }, { TU("Ж"), -1, 7 }, {0} }, ZINT_WARN_USES_ECI, 30, 30, {{0}}, 0 },
/* 3*/ { UNICODE_MODE, BARCODE_RAW_TEXT, { { TU(""), -1, 0 }, { TU("Ж"), -1, 7 }, { TU(""), 0, 0 } }, ZINT_WARN_USES_ECI, 30, 30, { { TU("\241"), 1, 13 }, { TU("\266"), 1, 7 }, {0} }, 2 },
/* 4*/ { UNICODE_MODE, -1, { { TU(""), -1, 0 }, { TU("Ж"), -1, 7 }, {0} }, 0, 30, 30, {{0}}, 0 },
/* 5*/ { UNICODE_MODE, BARCODE_RAW_TEXT, { { TU(""), -1, 0 }, { TU("Ж"), -1, 7 }, { TU(""), 0, 0 } }, 0, 30, 30, { { TU("\265\347"), 2, 29 }, { TU("\266"), 1, 7 }, {0} }, 2 },
/* 6*/ { UNICODE_MODE, -1, { { TU("电电"), -1, 0 }, { TU("กขฯ"), -1, 13 }, { TU("βββ"), -1, 9 } }, 0, 30, 30, {{0}}, 0 },
/* 7*/ { UNICODE_MODE, BARCODE_RAW_TEXT, { { TU("电电"), -1, 0 }, { TU("กขฯ"), -1, 13 }, { TU("βββ"), -1, 9 } }, 0, 30, 30, { { TU("\265\347\265\347"), 4, 29 }, { TU("\241\242\317"), 3, 13 }, { TU("\342\342\342"), 3, 9 } }, 3 },
/* 8*/ { UNICODE_MODE, -1, { { TU(""), -1, 26 }, { TU("Ж"), -1, 0 }, { TU(""), -1, 20 } }, 0, 30, 30, {{0}}, 0 },
/* 9*/ { UNICODE_MODE, BARCODE_RAW_TEXT, { { TU(""), -1, 26 }, { TU("Ж"), -1, 0 }, { TU(""), -1, 20 } }, 0, 30, 30, { { TU(""), 2, 26 }, { TU("\247\250"), 2, 29 }, { TU("\223\137"), 2, 20 } }, 3 },
/* 10*/ { DATA_MODE, -1, { { TU(""), -1, 26 }, { TU("Ж"), -1, 0 }, { TU("\223\137"), -1, 20 } }, 0, 30, 30, {{0}}, 0 },
/* 11*/ { DATA_MODE, BARCODE_RAW_TEXT, { { TU(""), -1, 26 }, { TU("Ж"), -1, 0 }, { TU("\223\137"), -1, 20 } }, 0, 30, 30, { { TU(""), 2, 26 }, { TU("\320\226"), 2, 29 }, { TU("\223\137"), 2, 20 } }, 3 },
};
const int data_size = ARRAY_SIZE(data);
int i, j, seg_count, ret;
struct zint_symbol *symbol = NULL;
int expected_length;
char escaped[4096];
char escaped2[4096];
testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) {
if (testContinue(p_ctx, i)) continue;
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
testUtilSetSymbol(symbol, BARCODE_GRIDMATRIX, data[i].input_mode, -1 /*eci*/,
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options,
NULL, 0, debug);
for (j = 0, seg_count = 0; j < 3 && data[i].segs[j].length; j++, seg_count++);
ret = ZBarcode_Encode_Segs(symbol, data[i].segs, seg_count);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode_Segs ret %d != %d (%s)\n",
i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (width %d)\n",
i, symbol->rows, data[i].expected_rows, symbol->width);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n",
i, symbol->width, data[i].expected_width);
assert_equal(symbol->raw_seg_count, data[i].expected_raw_seg_count, "i:%d symbol->raw_seg_count %d != %d\n",
i, symbol->raw_seg_count, data[i].expected_raw_seg_count);
if (symbol->output_options & BARCODE_RAW_TEXT) {
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
for (j = 0; j < symbol->raw_seg_count; j++) {
assert_nonnull(symbol->raw_segs[j].source, "i:%d raw_segs[%d].source NULL\n", i, j);
expected_length = data[i].expected_raw_segs[j].length;
assert_equal(symbol->raw_segs[j].length, expected_length,
"i:%d raw_segs[%d].length %d != expected_length %d\n",
i, j, symbol->raw_segs[j].length, expected_length);
assert_zero(memcmp(symbol->raw_segs[j].source, data[i].expected_raw_segs[j].source, expected_length),
"i:%d raw_segs[%d].source memcmp(%s, %s, %d) != 0\n", i, j,
testUtilEscape((const char *) symbol->raw_segs[j].source, expected_length, escaped,
sizeof(escaped)),
testUtilEscape((const char *) data[i].expected_raw_segs[j].source, expected_length,
escaped2, sizeof(escaped2)),
expected_length);
assert_equal(symbol->raw_segs[j].eci, data[i].expected_raw_segs[j].eci,
"i:%d raw_segs[%d].eci %d != expected_raw_segs.eci %d\n",
i, j, symbol->raw_segs[j].eci, data[i].expected_raw_segs[j].eci);
}
} else {
assert_null(symbol->raw_segs, "i:%d raw_segs not NULL\n", i);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
#include <time.h> #include <time.h>
#define TEST_PERF_ITERATIONS 1000 #define TEST_PERF_ITERATIONS 1000
@ -1001,6 +1185,8 @@ int main(int argc, char *argv[]) {
{ "test_input", test_input }, { "test_input", test_input },
{ "test_encode", test_encode }, { "test_encode", test_encode },
{ "test_encode_segs", test_encode_segs }, { "test_encode_segs", test_encode_segs },
{ "test_rt", test_rt },
{ "test_rt_segs", test_rt_segs },
{ "test_perf", test_perf }, { "test_perf", test_perf },
}; };

View file

@ -201,7 +201,7 @@ static void test_gs1_reduce(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
testStartSymbol("test_gs1_reduce", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -271,107 +271,108 @@ static void test_hrt(const testCtx *const p_ctx) {
int ret; int ret;
const char *expected; const char *expected;
const char *expected_raw;
}; };
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = { static const struct item data[] = {
/* 0*/ { BARCODE_GS1_128, -1, -1, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234(20)12" }, /* Incorrect check digit */ /* 0*/ { BARCODE_GS1_128, -1, -1, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234(20)12", "" }, /* Incorrect check digit */
/* 1*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, "[01]12345678901234[20]12", "", 0, "(01)12345678901234(20)12" }, /* 1*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, "[01]12345678901234[20]12", "", 0, "(01)12345678901234(20)12", "" },
/* 2*/ { BARCODE_GS1_128, -1, BARCODE_RAW_TEXT, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "01123456789012342012" }, /* 2*/ { BARCODE_GS1_128, -1, BARCODE_RAW_TEXT, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234(20)12", "01123456789012342012" },
/* 3*/ { BARCODE_GS1_128, -1, -1, "[01]12345678901231[20]12", "", 0, "(01)12345678901231(20)12" }, /* 3*/ { BARCODE_GS1_128, -1, -1, "[01]12345678901231[20]12", "", 0, "(01)12345678901231(20)12", "" },
/* 4*/ { BARCODE_GS1_128, -1, -1, "[01]12345678901231[10]12[20]AB", "", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231(10)12(20)AB" }, /* AI (20) should be 2 nos. */ /* 4*/ { BARCODE_GS1_128, -1, -1, "[01]12345678901231[10]12[20]AB", "", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231(10)12(20)AB", "" }, /* AI (20) should be 2 nos. */
/* 5*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, "[01]12345678901231[10]10[20]AB", "", 0, "(01)12345678901231(10)10(20)AB" }, /* 5*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, "[01]12345678901231[10]10[20]AB", "", 0, "(01)12345678901231(10)10(20)AB", "" },
/* 6*/ { BARCODE_GS1_128, -1, -1, "[01]12345678901231[10]AB[20]12", "", 0, "(01)12345678901231(10)AB(20)12" }, /* 6*/ { BARCODE_GS1_128, -1, -1, "[01]12345678901231[10]AB[20]12", "", 0, "(01)12345678901231(10)AB(20)12", "" },
/* 7*/ { BARCODE_GS1_128, -1, -1, "[91]ABCDEF]GH", "", ZINT_WARN_NONCOMPLIANT, "(91)ABCDEF]GH" }, /* Invalid CSET 82 character */ /* 7*/ { BARCODE_GS1_128, -1, -1, "[91]ABCDEF]GH", "", ZINT_WARN_NONCOMPLIANT, "(91)ABCDEF]GH", "" }, /* Invalid CSET 82 character */
/* 8*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, "[91]ABCDEF]GH", "", 0, "(91)ABCDEF]GH" }, /* 8*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, "[91]ABCDEF]GH", "", 0, "(91)ABCDEF]GH", "" },
/* 9*/ { BARCODE_GS1_128, -1, BARCODE_RAW_TEXT, "[91]ABCDEF]GH", "", ZINT_WARN_NONCOMPLIANT, "91ABCDEF]GH" }, /* 9*/ { BARCODE_GS1_128, -1, BARCODE_RAW_TEXT, "[91]ABCDEF]GH", "", ZINT_WARN_NONCOMPLIANT, "(91)ABCDEF]GH", "91ABCDEF]GH" },
/* 10*/ { BARCODE_GS1_128, -1, -1, "[91]ABCDEF)GH", "", 0, "(91)ABCDEF)GH" }, /* 10*/ { BARCODE_GS1_128, -1, -1, "[91]ABCDEF)GH", "", 0, "(91)ABCDEF)GH", "" },
/* 11*/ { BARCODE_GS1_128, -1, BARCODE_RAW_TEXT, "[91]ABCDEF)GH", "", 0, "91ABCDEF)GH" }, /* 11*/ { BARCODE_GS1_128, -1, BARCODE_RAW_TEXT, "[91]ABCDEF)GH", "", 0, "(91)ABCDEF)GH", "91ABCDEF)GH" },
/* 12*/ { BARCODE_GS1_128, -1, -1, "[91]ABCDEF(GH", "", 0, "(91)ABCDEF(GH" }, /* 12*/ { BARCODE_GS1_128, -1, -1, "[91]ABCDEF(GH", "", 0, "(91)ABCDEF(GH", "" },
/* 13*/ { BARCODE_GS1_128, -1, BARCODE_RAW_TEXT, "[91]ABCDEF(GH", "", 0, "91ABCDEF(GH" }, /* 13*/ { BARCODE_GS1_128, -1, BARCODE_RAW_TEXT, "[91]ABCDEF(GH", "", 0, "(91)ABCDEF(GH", "91ABCDEF(GH" },
/* 14*/ { BARCODE_GS1_128, -1, -1, "[91]ABCDE(20)12", "", 0, "(91)ABCDE(20)12" }, /* 14*/ { BARCODE_GS1_128, -1, -1, "[91]ABCDE(20)12", "", 0, "(91)ABCDE(20)12", "" },
/* 15*/ { BARCODE_GS1_128, -1, BARCODE_RAW_TEXT, "[91]ABCDE(20)12", "", 0, "91ABCDE(20)12" }, /* 15*/ { BARCODE_GS1_128, -1, BARCODE_RAW_TEXT, "[91]ABCDE(20)12", "", 0, "(91)ABCDE(20)12", "91ABCDE(20)12" },
/* 16*/ { BARCODE_GS1_128, -1, -1, "[90]1234[91]ABCDE(20)12", "", 0, "(90)1234(91)ABCDE(20)12" }, /* 16*/ { BARCODE_GS1_128, -1, -1, "[90]1234[91]ABCDE(20)12", "", 0, "(90)1234(91)ABCDE(20)12", "" },
/* 17*/ { BARCODE_GS1_128, -1, BARCODE_RAW_TEXT, "[90]1234[91]ABCDE(20)12", "", 0, "901234\03591ABCDE(20)12" }, /* 17*/ { BARCODE_GS1_128, -1, BARCODE_RAW_TEXT, "[90]1234[91]ABCDE(20)12", "", 0, "(90)1234(91)ABCDE(20)12", "901234\03591ABCDE(20)12" },
/* 18*/ { BARCODE_GS1_128, -1, -1, "[90]1234[91]ABCDE(20)12[20]12", "", 0, "(90)1234(91)ABCDE(20)12(20)12" }, /* 18*/ { BARCODE_GS1_128, -1, -1, "[90]1234[91]ABCDE(20)12[20]12", "", 0, "(90)1234(91)ABCDE(20)12(20)12", "" },
/* 19*/ { BARCODE_GS1_128, -1, BARCODE_RAW_TEXT, "[90]1234[91]ABCDE(20)12[20]12", "", 0, "901234\03591ABCDE(20)12\0352012" }, /* 19*/ { BARCODE_GS1_128, -1, BARCODE_RAW_TEXT, "[90]1234[91]ABCDE(20)12[20]12", "", 0, "(90)1234(91)ABCDE(20)12(20)12", "901234\03591ABCDE(20)12\0352012" },
/* 20*/ { BARCODE_GS1_128, GS1PARENS_MODE, -1, "(91)ABCDEF]GH", "", ZINT_WARN_NONCOMPLIANT, "(91)ABCDEF]GH" }, /* Invalid CSET 82 character */ /* 20*/ { BARCODE_GS1_128, GS1PARENS_MODE, -1, "(91)ABCDEF]GH", "", ZINT_WARN_NONCOMPLIANT, "(91)ABCDEF]GH", "" }, /* Invalid CSET 82 character */
/* 21*/ { BARCODE_GS1_128, GS1PARENS_MODE | GS1NOCHECK_MODE, -1, "(91)ABCDEF]GH", "", 0, "(91)ABCDEF]GH" }, /* 21*/ { BARCODE_GS1_128, GS1PARENS_MODE | GS1NOCHECK_MODE, -1, "(91)ABCDEF]GH", "", 0, "(91)ABCDEF]GH", "" },
/* 22*/ { BARCODE_GS1_128, GS1PARENS_MODE, BARCODE_RAW_TEXT, "(91)ABCDEF]GH", "", ZINT_WARN_NONCOMPLIANT, "91ABCDEF]GH" }, /* 22*/ { BARCODE_GS1_128, GS1PARENS_MODE, BARCODE_RAW_TEXT, "(91)ABCDEF]GH", "", ZINT_WARN_NONCOMPLIANT, "(91)ABCDEF]GH", "91ABCDEF]GH" },
/* 23*/ { BARCODE_GS1_128, GS1PARENS_MODE, -1, "(91)ABCDEF)GH", "", 0, "(91)ABCDEF)GH" }, /* 23*/ { BARCODE_GS1_128, GS1PARENS_MODE, -1, "(91)ABCDEF)GH", "", 0, "(91)ABCDEF)GH", "" },
/* 24*/ { BARCODE_GS1_128, GS1PARENS_MODE, BARCODE_RAW_TEXT, "(91)ABCDEF)GH", "", 0, "91ABCDEF)GH" }, /* 24*/ { BARCODE_GS1_128, GS1PARENS_MODE, BARCODE_RAW_TEXT, "(91)ABCDEF)GH", "", 0, "(91)ABCDEF)GH", "91ABCDEF)GH" },
/* 25*/ { BARCODE_GS1_128, GS1PARENS_MODE, -1, "(91)ABCDE[FGH", "", ZINT_WARN_NONCOMPLIANT, "(91)ABCDE[FGH" }, /* Invalid CSET 82 character */ /* 25*/ { BARCODE_GS1_128, GS1PARENS_MODE, -1, "(91)ABCDE[FGH", "", ZINT_WARN_NONCOMPLIANT, "(91)ABCDE[FGH", "" }, /* Invalid CSET 82 character */
/* 26*/ { BARCODE_GS1_128, GS1PARENS_MODE | GS1NOCHECK_MODE, -1, "(91)ABCDE[FGH", "", 0, "(91)ABCDE[FGH" }, /* 26*/ { BARCODE_GS1_128, GS1PARENS_MODE | GS1NOCHECK_MODE, -1, "(91)ABCDE[FGH", "", 0, "(91)ABCDE[FGH", "" },
/* 27*/ { BARCODE_GS1_128, GS1PARENS_MODE, BARCODE_RAW_TEXT, "(91)ABCDE[FGH", "", ZINT_WARN_NONCOMPLIANT, "91ABCDE[FGH" }, /* 27*/ { BARCODE_GS1_128, GS1PARENS_MODE, BARCODE_RAW_TEXT, "(91)ABCDE[FGH", "", ZINT_WARN_NONCOMPLIANT, "(91)ABCDE[FGH", "91ABCDE[FGH" },
/* 28*/ { BARCODE_GS1_128, GS1PARENS_MODE, -1, "(91)ABCDE[92]GH", "", ZINT_WARN_NONCOMPLIANT, "(91)ABCDE[92]GH" }, /* Invalid CSET 82 character */ /* 28*/ { BARCODE_GS1_128, GS1PARENS_MODE, -1, "(91)ABCDE[92]GH", "", ZINT_WARN_NONCOMPLIANT, "(91)ABCDE[92]GH", "" }, /* Invalid CSET 82 character */
/* 29*/ { BARCODE_GS1_128, GS1PARENS_MODE | GS1NOCHECK_MODE, -1, "(91)ABCDE[92]GH", "", 0, "(91)ABCDE[92]GH" }, /* 29*/ { BARCODE_GS1_128, GS1PARENS_MODE | GS1NOCHECK_MODE, -1, "(91)ABCDE[92]GH", "", 0, "(91)ABCDE[92]GH", "" },
/* 30*/ { BARCODE_GS1_128, GS1PARENS_MODE, BARCODE_RAW_TEXT, "(91)ABCDE[92]GH", "", ZINT_WARN_NONCOMPLIANT, "91ABCDE[92]GH" }, /* 30*/ { BARCODE_GS1_128, GS1PARENS_MODE, BARCODE_RAW_TEXT, "(91)ABCDE[92]GH", "", ZINT_WARN_NONCOMPLIANT, "(91)ABCDE[92]GH", "91ABCDE[92]GH" },
/* 31*/ { BARCODE_GS1_128_CC, -1, -1, "[01]12345678901234[20]12", "[21]12345", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234(20)12" }, /* Incorrect check digit */ /* 31*/ { BARCODE_GS1_128_CC, -1, -1, "[01]12345678901234[20]12", "[21]12345", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234(20)12", "" }, /* Incorrect check digit */
/* 32*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, "[01]12345678901234[20]12", "[21]12345", 0, "(01)12345678901234(20)12" }, /* 32*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, "[01]12345678901234[20]12", "[21]12345", 0, "(01)12345678901234(20)12", "" },
/* 33*/ { BARCODE_GS1_128_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901234[20]12", "[21]12345", ZINT_WARN_NONCOMPLIANT, "01123456789012342012" }, /* 33*/ { BARCODE_GS1_128_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901234[20]12", "[21]12345", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234(20)12", "01123456789012342012|2112345" },
/* 34*/ { BARCODE_GS1_128_CC, -1, -1, "[01]12345678901231[20]12", "[21]12345", 0, "(01)12345678901231(20)12" }, /* 34*/ { BARCODE_GS1_128_CC, -1, -1, "[01]12345678901231[20]12", "[21]12345", 0, "(01)12345678901231(20)12", "" },
/* 35*/ { BARCODE_GS1_128_CC, -1, -1, "[01]12345678901231[10]12[20]AB", "[21]12345", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231(10)12(20)AB" }, /* AI (20) should be 2 nos. */ /* 35*/ { BARCODE_GS1_128_CC, -1, -1, "[01]12345678901231[10]12[20]AB", "[21]12345", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231(10)12(20)AB", "" }, /* AI (20) should be 2 nos. */
/* 36*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, "[01]12345678901231[10]12[20]AB", "[21]12345", 0, "(01)12345678901231(10)12(20)AB" }, /* 36*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, "[01]12345678901231[10]12[20]AB", "[21]12345", 0, "(01)12345678901231(10)12(20)AB", "" },
/* 37*/ { BARCODE_GS1_128_CC, -1, -1, "[01]12345678901231[10]AB[20]12", "[21]12345", 0, "(01)12345678901231(10)AB(20)12" }, /* 37*/ { BARCODE_GS1_128_CC, -1, -1, "[01]12345678901231[10]AB[20]12", "[21]12345", 0, "(01)12345678901231(10)AB(20)12", "" },
/* 38*/ { BARCODE_GS1_128_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12", "[21]12345", 0, "011234567890123110AB\0352012" }, /* 38*/ { BARCODE_GS1_128_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12", "[21]12345", 0, "(01)12345678901231(10)AB(20)12", "011234567890123110AB\0352012|2112345" },
/* 39*/ { BARCODE_GS1_128_CC, -1, -1, "[01]12345678901231[10]AB[20]12", "[30]1234567A", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231(10)AB(20)12" }, /* 39*/ { BARCODE_GS1_128_CC, -1, -1, "[01]12345678901231[10]AB[20]12", "[30]1234567A", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231(10)AB(20)12", "" },
/* 40*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, "[01]12345678901231[10]AB[20]12", "[30]1234567A", 0, "(01)12345678901231(10)AB(20)12" }, /* 40*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, "[01]12345678901231[10]AB[20]12", "[30]1234567A", 0, "(01)12345678901231(10)AB(20)12", "" },
/* 41*/ { BARCODE_EAN14, -1, -1, "1234567890123", "", 0, "(01)12345678901231" }, /* 41*/ { BARCODE_EAN14, -1, -1, "1234567890123", "", 0, "(01)12345678901231", "" },
/* 42*/ { BARCODE_EAN14, -1, BARCODE_RAW_TEXT, "1234567890123", "", 0, "0112345678901231" }, /* 42*/ { BARCODE_EAN14, -1, BARCODE_RAW_TEXT, "1234567890123", "", 0, "(01)12345678901231", "0112345678901231" },
/* 43*/ { BARCODE_EAN14, -1, -1, "1234", "", 0, "(01)00000000012348" }, /* 43*/ { BARCODE_EAN14, -1, -1, "1234", "", 0, "(01)00000000012348", "" },
/* 44*/ { BARCODE_EAN14, -1, BARCODE_RAW_TEXT, "1234", "", 0, "0100000000012348" }, /* 44*/ { BARCODE_EAN14, -1, BARCODE_RAW_TEXT, "1234", "", 0, "(01)00000000012348", "0100000000012348" },
/* 45*/ { BARCODE_EAN14, -1, -1, "12345", "", 0, "(01)00000000123457" }, /* 45*/ { BARCODE_EAN14, -1, -1, "12345", "", 0, "(01)00000000123457", "" },
/* 46*/ { BARCODE_EAN14, -1, -1, "12340", "", 0, "(01)00000000123402" }, /* 46*/ { BARCODE_EAN14, -1, -1, "12340", "", 0, "(01)00000000123402", "" },
/* 47*/ { BARCODE_NVE18, -1, -1, "12345678901234567", "", 0, "(00)123456789012345675" }, /* 47*/ { BARCODE_NVE18, -1, -1, "12345678901234567", "", 0, "(00)123456789012345675", "" },
/* 48*/ { BARCODE_NVE18, -1, BARCODE_RAW_TEXT, "12345678901234567", "", 0, "00123456789012345675" }, /* 48*/ { BARCODE_NVE18, -1, BARCODE_RAW_TEXT, "12345678901234567", "", 0, "(00)123456789012345675", "00123456789012345675" },
/* 49*/ { BARCODE_NVE18, -1, -1, "1234", "", 0, "(00)000000000000012348" }, /* 49*/ { BARCODE_NVE18, -1, -1, "1234", "", 0, "(00)000000000000012348", "" },
/* 50*/ { BARCODE_NVE18, -1, BARCODE_RAW_TEXT, "1234", "", 0, "00000000000000012348" }, /* 50*/ { BARCODE_NVE18, -1, BARCODE_RAW_TEXT, "1234", "", 0, "(00)000000000000012348", "00000000000000012348" },
/* 51*/ { BARCODE_NVE18, -1, -1, "12345", "", 0, "(00)000000000000123457" }, /* 51*/ { BARCODE_NVE18, -1, -1, "12345", "", 0, "(00)000000000000123457", "" },
/* 52*/ { BARCODE_NVE18, -1, -1, "12340", "", 0, "(00)000000000000123402" }, /* 52*/ { BARCODE_NVE18, -1, -1, "12340", "", 0, "(00)000000000000123402", "" },
/* 53*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234(20)12" }, /* Incorrect check digit */ /* 53*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234(20)12", "" }, /* Incorrect check digit */
/* 54*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, "[01]12345678901234[20]12", "", 0, "(01)12345678901234(20)12" }, /* 54*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, "[01]12345678901234[20]12", "", 0, "(01)12345678901234(20)12", "" },
/* 55*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "01123456789012342012" }, /* 55*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234(20)12", "01123456789012342012" },
/* 56*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[20]12", "", 0, "(01)12345678901231(20)12" }, /* 56*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[20]12", "", 0, "(01)12345678901231(20)12", "" },
/* 57*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[20]12", "", 0, "01123456789012312012" }, /* 57*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[20]12", "", 0, "(01)12345678901231(20)12", "01123456789012312012" },
/* 58*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]12[20]AB", "", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231(10)12(20)AB" }, /* AI (20) should be 2 nos. */ /* 58*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]12[20]AB", "", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231(10)12(20)AB", "" }, /* AI (20) should be 2 nos. */
/* 59*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, "[01]12345678901231[10]12[20]AB", "", 0, "(01)12345678901231(10)12(20)AB" }, /* 59*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, "[01]12345678901231[10]12[20]AB", "", 0, "(01)12345678901231(10)12(20)AB", "" },
/* 60*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]12[20]AB", "", ZINT_WARN_NONCOMPLIANT, "01123456789012311012\03520AB" }, /* 60*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]12[20]AB", "", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231(10)12(20)AB", "01123456789012311012\03520AB" },
/* 61*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]AB[20]12", "", 0, "(01)12345678901231(10)AB(20)12" }, /* 61*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]AB[20]12", "", 0, "(01)12345678901231(10)AB(20)12", "" },
/* 62*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12", "", 0, "011234567890123110AB\0352012" }, /* 62*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12", "", 0, "(01)12345678901231(10)AB(20)12", "011234567890123110AB\0352012" },
/* 63*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC(2012", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC(2012" }, /* 63*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC(2012", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC(2012", "" },
/* 64*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12[90]ABC(2012", "", 0, "011234567890123110AB\035201290ABC(2012" }, /* 64*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12[90]ABC(2012", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC(2012", "011234567890123110AB\035201290ABC(2012" },
/* 65*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC20)12" }, /* 65*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC20)12", "" },
/* 66*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "", 0, "011234567890123110AB\035201290ABC20)12" }, /* 66*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC20)12", "011234567890123110AB\035201290ABC20)12" },
/* 67*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC(20)12", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC(20)12" }, /* 67*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC(20)12", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC(20)12", "" },
/* 68*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12[90]ABC(20)12", "", 0, "011234567890123110AB\035201290ABC(20)12" }, /* 68*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12[90]ABC(20)12", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC(20)12", "011234567890123110AB\035201290ABC(20)12" },
/* 69*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC(20)12[91]12(", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC(20)12(91)12(" }, /* 69*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC(20)12[91]12(", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC(20)12(91)12(" , ""},
/* 70*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12[90]ABC(20)12[91]12(", "", 0, "011234567890123110AB\035201290ABC(20)12\0359112(" }, /* 70*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12[90]ABC(20)12[91]12(", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC(20)12(91)12(" , "011234567890123110AB\035201290ABC(20)12\0359112(" },
/* 71*/ { BARCODE_DBAR_EXP_CC, -1, -1, "[01]12345678901234", "[21]12345", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234" }, /* 71*/ { BARCODE_DBAR_EXP_CC, -1, -1, "[01]12345678901234", "[21]12345", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234", "" },
/* 72*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, -1, "[01]12345678901234", "[21]12345", 0, "(01)12345678901234" }, /* 72*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, -1, "[01]12345678901234", "[21]12345", 0, "(01)12345678901234", "" },
/* 73*/ { BARCODE_DBAR_EXP_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901234", "[21]12345", ZINT_WARN_NONCOMPLIANT, "0112345678901234" }, /* 73*/ { BARCODE_DBAR_EXP_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901234", "[21]12345", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234", "0112345678901234|2112345" },
/* 74*/ { BARCODE_DBAR_EXP_CC, -1, -1, "[01]12345678901231", "[21]12345", 0, "(01)12345678901231" }, /* 74*/ { BARCODE_DBAR_EXP_CC, -1, -1, "[01]12345678901231", "[21]12345", 0, "(01)12345678901231", "" },
/* 75*/ { BARCODE_DBAR_EXP_CC, -1, -1, "[01]12345678901231[20]12[21]12345", "[21]12345", 0, "(01)12345678901231(20)12(21)12345" }, /* 75*/ { BARCODE_DBAR_EXP_CC, -1, -1, "[01]12345678901231[20]12[21]12345", "[21]12345", 0, "(01)12345678901231(20)12(21)12345", "" },
/* 76*/ { BARCODE_DBAR_EXP_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901231[20]12[21]12345", "[21]12345", 0, "011234567890123120122112345" }, /* 76*/ { BARCODE_DBAR_EXP_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901231[20]12[21]12345", "[21]12345", 0, "(01)12345678901231(20)12(21)12345", "011234567890123120122112345|2112345" },
/* 77*/ { BARCODE_DBAR_EXPSTK, -1, -1, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "" }, /* 77*/ { BARCODE_DBAR_EXPSTK, -1, -1, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "", "" },
/* 78*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, -1, "[01]12345678901234[20]12", "", 0, "" }, /* 78*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, -1, "[01]12345678901234[20]12", "", 0, "", "" },
/* 79*/ { BARCODE_DBAR_EXPSTK, -1, BARCODE_RAW_TEXT, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "01123456789012342012" }, /* 79*/ { BARCODE_DBAR_EXPSTK, -1, BARCODE_RAW_TEXT, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "", "01123456789012342012" },
/* 80*/ { BARCODE_DBAR_EXPSTK, -1, -1, "[01]12345678901231[20]12", "", 0, "" }, /* 80*/ { BARCODE_DBAR_EXPSTK, -1, -1, "[01]12345678901231[20]12", "", 0, "", "" },
/* 81*/ { BARCODE_DBAR_EXPSTK, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "", 0, "" }, /* 81*/ { BARCODE_DBAR_EXPSTK, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "", 0, "", "" },
/* 82*/ { BARCODE_DBAR_EXPSTK, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "", 0, "011234567890123110AB\035201290ABC20)12" }, /* 82*/ { BARCODE_DBAR_EXPSTK, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "", 0, "", "011234567890123110AB\035201290ABC20)12" },
/* 83*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, "[01]12345678901234[20]12", "[21]12345", ZINT_WARN_NONCOMPLIANT, "" }, /* 83*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, "[01]12345678901234[20]12", "[21]12345", ZINT_WARN_NONCOMPLIANT, "" , ""},
/* 84*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, -1, "[01]12345678901234[20]12", "[21]12345", 0, "" }, /* 84*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, -1, "[01]12345678901234[20]12", "[21]12345", 0, "", "" },
/* 85*/ { BARCODE_DBAR_EXPSTK_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901234[20]12", "[21]12345", ZINT_WARN_NONCOMPLIANT, "01123456789012342012" }, /* 85*/ { BARCODE_DBAR_EXPSTK_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901234[20]12", "[21]12345", ZINT_WARN_NONCOMPLIANT, "", "01123456789012342012|2112345" },
/* 86*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, "[01]12345678901231[20]12", "[21]12345", 0, "" }, /* 86*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, "[01]12345678901231[20]12", "[21]12345", 0, "", "" },
/* 87*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "[21]12345", 0, "" }, /* 87*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "[21]12345", 0, "", "" },
/* 88*/ { BARCODE_DBAR_EXPSTK_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "[21]12345", 0, "011234567890123110AB\035201290ABC20)12" }, /* 88*/ { BARCODE_DBAR_EXPSTK_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "[21]12345", 0, "", "011234567890123110AB\035201290ABC20)12|2112345" },
}; };
const int data_size = ARRAY_SIZE(data); const int data_size = ARRAY_SIZE(data);
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
int expected_length; int expected_length, expected_raw_length;
const char *text; const char *text;
testStartSymbol("test_hrt", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -390,6 +391,7 @@ static void test_hrt(const testCtx *const p_ctx) {
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options, -1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options,
text, -1, debug); text, -1, debug);
expected_length = (int) strlen(data[i].expected); expected_length = (int) strlen(data[i].expected);
expected_raw_length = (int) strlen(data[i].expected_raw);
ret = ZBarcode_Encode(symbol, TCU(text), length); ret = ZBarcode_Encode(symbol, TCU(text), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, data[i].ret, ret, symbol->errtxt); assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, data[i].ret, ret, symbol->errtxt);
@ -398,6 +400,16 @@ static void test_hrt(const testCtx *const p_ctx) {
i, symbol->text_length, expected_length); i, symbol->text_length, expected_length);
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
i, symbol->text, data[i].expected); i, symbol->text, data[i].expected);
if (symbol->output_options & BARCODE_RAW_TEXT) {
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
assert_nonnull(symbol->raw_segs[0].source, "i:%d raw_segs[0].source NULL\n", i);
assert_equal(symbol->raw_segs[0].length, expected_raw_length, "i:%d raw_segs[0].length %d != expected_raw_length %d\n",
i, symbol->raw_segs[0].length, expected_raw_length);
assert_zero(memcmp(symbol->raw_segs[0].source, data[i].expected_raw, expected_raw_length), "i:%d memcmp(%s, %s, %d) != 0\n",
i, symbol->raw_segs[0].source, data[i].expected_raw, expected_raw_length);
} else {
assert_null(symbol->raw_segs, "i:%d raw_segs not NULL\n", i);
}
ZBarcode_Delete(symbol); ZBarcode_Delete(symbol);
} }
@ -1455,7 +1467,7 @@ static void test_gs1_verify(const testCtx *const p_ctx) {
char reduced[1024] = {0}; /* Suppress clang -fsanitize=memory false positive */ char reduced[1024] = {0}; /* Suppress clang -fsanitize=memory false positive */
char escaped[1024]; char escaped[1024];
testStartSymbol("test_gs1_verify", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -2165,7 +2177,7 @@ static void test_gs1_lint(const testCtx *const p_ctx) {
char escaped[1024]; char escaped[1024];
char escaped2[1024]; char escaped2[1024];
testStartSymbol("test_gs1_lint", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -2336,7 +2348,7 @@ static void test_input_mode(const testCtx *const p_ctx) {
struct zint_symbol previous_symbol; struct zint_symbol previous_symbol;
testStartSymbol("test_input_mode", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -2566,7 +2578,7 @@ static void test_gs1nocheck_mode(const testCtx *const p_ctx) {
const char *text; const char *text;
testStartSymbol("test_gs1nocheck_mode", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {

File diff suppressed because it is too large Load diff

View file

@ -70,7 +70,7 @@ static void test_csv(const testCtx *const p_ctx) {
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_csv", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
if (test_performance) { if (test_performance) {
printf("test_csv perf iterations: %d\n", perf_iterations); printf("test_csv perf iterations: %d\n", perf_iterations);
@ -170,18 +170,19 @@ static void test_hrt(const testCtx *const p_ctx) {
int output_options; int output_options;
const char *data; const char *data;
const char *expected; const char *expected;
const char *expected_raw;
}; };
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = { static const struct item data[] = {
/* 0*/ { -1, "53379777234994544928-51135759461", "" }, /* None */ /* 0*/ { -1, "53379777234994544928-51135759461", "", "" }, /* None */
/* 1*/ { BARCODE_RAW_TEXT, "53379777234994544928-51135759461", "53379777234994544928-51135759461" }, /* 1*/ { BARCODE_RAW_TEXT, "53379777234994544928-51135759461", "", "53379777234994544928-51135759461" },
}; };
const int data_size = ARRAY_SIZE(data); const int data_size = ARRAY_SIZE(data);
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
int expected_length; int expected_length, expected_raw_length;
testStartSymbol("test_hrt", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -194,6 +195,7 @@ static void test_hrt(const testCtx *const p_ctx) {
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options, -1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options,
data[i].data, -1, debug); data[i].data, -1, debug);
expected_length = (int) strlen(data[i].expected); expected_length = (int) strlen(data[i].expected);
expected_raw_length = (int) strlen(data[i].expected_raw);
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt); assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
@ -202,6 +204,18 @@ static void test_hrt(const testCtx *const p_ctx) {
i, symbol->text_length, expected_length); i, symbol->text_length, expected_length);
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
i, symbol->text, data[i].expected); i, symbol->text, data[i].expected);
if (symbol->output_options & BARCODE_RAW_TEXT) {
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
assert_nonnull(symbol->raw_segs[0].source, "i:%d raw_segs[0].source NULL\n", i);
assert_equal(symbol->raw_segs[0].length, expected_raw_length,
"i:%d raw_segs[0].length %d != expected_raw_length %d\n",
i, symbol->raw_segs[0].length, expected_raw_length);
assert_zero(memcmp(symbol->raw_segs[0].source, data[i].expected_raw, expected_raw_length),
"i:%d memcmp(%s, %s, %d) != 0\n",
i, symbol->raw_segs[0].source, data[i].expected_raw, expected_raw_length);
} else {
assert_null(symbol->raw_segs, "i:%d raw_segs not NULL\n", i);
}
ZBarcode_Delete(symbol); ZBarcode_Delete(symbol);
} }
@ -244,7 +258,7 @@ static void test_input(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
testStartSymbol("test_input", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -310,7 +324,7 @@ static void test_encode(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
testStartSymbol("test_encode", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {

View file

@ -377,7 +377,7 @@ static void test_numeric(const testCtx *const p_ctx) {
int data_size = ARRAY_SIZE(data); int data_size = ARRAY_SIZE(data);
int i, ret; int i, ret;
testStart("test_numeric"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -440,7 +440,7 @@ static void test_numeric_bc(const testCtx *const p_ctx) {
int i, ret, bc_ret; int i, ret, bc_ret;
testStart("test_numeric_bc"); testStart(p_ctx->func_name);
for (i = 0; i < 1001; i++) { for (i = 0; i < 1001; i++) {
if (testContinue(p_ctx, i)) continue; if (testContinue(p_ctx, i)) continue;
@ -679,7 +679,7 @@ static void test_alpha2(const testCtx *const p_ctx) {
int data_size = ARRAY_SIZE(data); int data_size = ARRAY_SIZE(data);
int i, ret; int i, ret;
testStart("test_alpha2"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -746,7 +746,7 @@ static void test_alpha2_bc(const testCtx *const p_ctx) {
(void)p_ctx; (void)p_ctx;
testStart("test_alpha2_bc"); testStart(p_ctx->func_name);
for (i = 0; i < 128; i++) { for (i = 0; i < 128; i++) {
int j; int j;

View file

@ -1047,7 +1047,7 @@ static void test_numeric(const testCtx *const p_ctx) {
int data_size = ARRAY_SIZE(data); int data_size = ARRAY_SIZE(data);
int i, ret; int i, ret;
testStart("test_numeric"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -1103,7 +1103,7 @@ static void test_numeric_bc(const testCtx *const p_ctx) {
int i, ret, bc_ret; int i, ret, bc_ret;
testStart("test_numeric_bc"); testStart(p_ctx->func_name);
for (i = 0; i < 1001; i++) { for (i = 0; i < 1001; i++) {
if (testContinue(p_ctx, i)) continue; if (testContinue(p_ctx, i)) continue;

View file

@ -111,7 +111,7 @@ static void test_u_ksx1001_int(const testCtx *const p_ctx) {
(void)debug; (void)debug;
#endif #endif
testStart("test_u_ksx1001_int"); testStart(p_ctx->func_name);
#ifdef TEST_JUST_SAY_GNO #ifdef TEST_JUST_SAY_GNO
if ((debug & ZINT_DEBUG_TEST_PERFORMANCE)) { /* -d 256 */ if ((debug & ZINT_DEBUG_TEST_PERFORMANCE)) { /* -d 256 */

View file

@ -196,7 +196,7 @@ static void test_clz_u64(const testCtx *const p_ctx) {
int data_size = ARRAY_SIZE(data); int data_size = ARRAY_SIZE(data);
int i, ret; int i, ret;
testStart("test_clz_u64"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -229,7 +229,7 @@ static void test_load(const testCtx *const p_ctx) {
char t_dump[35]; char t_dump[35];
char expected_dump[35]; char expected_dump[35];
testStart("test_load"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -270,7 +270,7 @@ static void test_load_str_u64(const testCtx *const p_ctx) {
char t_dump[35]; char t_dump[35];
char expected_dump[35]; char expected_dump[35];
testStart("test_load_str_u64"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -314,7 +314,7 @@ static void test_add_u64(const testCtx *const p_ctx) {
char t_dump[35]; char t_dump[35];
char expected_dump[35]; char expected_dump[35];
testStart("test_add_u64"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -358,7 +358,7 @@ static void test_sub_u64(const testCtx *const p_ctx) {
char t_dump[35]; char t_dump[35];
char expected_dump[35]; char expected_dump[35];
testStart("test_sub_u64"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -415,7 +415,7 @@ static void test_mul_u64(const testCtx *const p_ctx) {
char t_dump[35]; char t_dump[35];
char expected_dump[35]; char expected_dump[35];
testStart("test_mul_u64"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -540,7 +540,7 @@ static void test_div_u64(const testCtx *const p_ctx) {
char t_dump[35]; char t_dump[35];
char expected_dump[35]; char expected_dump[35];
testStart("test_div_u64"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -706,7 +706,7 @@ static void test_unset_bit(const testCtx *const p_ctx) {
char t_dump[35]; char t_dump[35];
char expected_dump[35]; char expected_dump[35];
testStart("test_unset_bit"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -780,7 +780,7 @@ static void test_uint_array(const testCtx *const p_ctx) {
unsigned char uchar_array[130]; unsigned char uchar_array[130];
unsigned char uchar_expected_array[130]; unsigned char uchar_expected_array[130];
testStart("test_uint_array"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -871,7 +871,7 @@ static void test_dump(const testCtx *const p_ctx) {
char dump[35]; char dump[35];
testStart("test_dump"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {

View file

@ -220,7 +220,7 @@ static void test_checks(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_checks", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -313,7 +313,7 @@ static void test_checks_segs(const testCtx *const p_ctx) {
int i, ret; int i, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_checks_segs", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -368,7 +368,7 @@ static void test_input_data(const testCtx *const p_ctx) {
const char *text; const char *text;
testStartSymbol("test_input_data", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -521,7 +521,7 @@ static void test_symbologies(const testCtx *const p_ctx) {
struct zint_symbol s_symbol = {0}; struct zint_symbol s_symbol = {0};
struct zint_symbol *symbol = &s_symbol; struct zint_symbol *symbol = &s_symbol;
testStart("test_symbologies"); testStart(p_ctx->func_name);
for (i = -1; i < 148; i++) { for (i = -1; i < 148; i++) {
if (testContinue(p_ctx, i)) continue; if (testContinue(p_ctx, i)) continue;
@ -576,7 +576,7 @@ static void test_input_mode(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_input_mode", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -711,7 +711,7 @@ static void test_escape_char_process(const testCtx *const p_ctx) {
const char *text; const char *text;
testStartSymbol("test_escape_char_process", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -812,7 +812,7 @@ static void test_escape_char_process_test(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
testStart("test_escape_char_process_test"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -869,7 +869,7 @@ static void test_cap(const testCtx *const p_ctx) {
int i; int i;
unsigned int uret; unsigned int uret;
testStart("test_cap"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -886,7 +886,7 @@ static void test_cap_compliant_height(const testCtx *const p_ctx) {
int symbol_id; int symbol_id;
unsigned int uret; unsigned int uret;
testStart("test_cap_compliant_height"); testStart(p_ctx->func_name);
for (symbol_id = 1; symbol_id <= BARCODE_LAST; symbol_id++) { for (symbol_id = 1; symbol_id <= BARCODE_LAST; symbol_id++) {
if (!ZBarcode_ValidID(symbol_id)) continue; if (!ZBarcode_ValidID(symbol_id)) continue;
@ -986,7 +986,7 @@ static void test_encode_file_empty(const testCtx *const p_ctx) {
(void)p_ctx; (void)p_ctx;
testStartSymbol("test_encode_file_empty", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
symbol = ZBarcode_Create(); symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n"); assert_nonnull(symbol, "Symbol not created\n");
@ -1018,7 +1018,7 @@ static void test_encode_file_too_large(const testCtx *const p_ctx) {
(void)p_ctx; (void)p_ctx;
testStartSymbol("test_encode_file_too_large", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
symbol = ZBarcode_Create(); symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n"); assert_nonnull(symbol, "Symbol not created\n");
@ -1056,7 +1056,7 @@ static void test_encode_file_unreadable(const testCtx *const p_ctx) {
(void)p_ctx; (void)p_ctx;
testStartSymbol("test_encode_file_unreadable", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
#ifdef _WIN32 #ifdef _WIN32
testSkip("Test not implemented on Windows"); testSkip("Test not implemented on Windows");
@ -1097,7 +1097,7 @@ static void test_encode_file_directory(const testCtx *const p_ctx) {
(void)p_ctx; (void)p_ctx;
testStartSymbol("test_encode_file_directory", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
#if defined(__NetBSD__) || defined(_AIX) #if defined(__NetBSD__) || defined(_AIX)
/* Reading a directory works on NetBSD, and get `code128()` ZINT_ERROR_TOO_LONG instead */ /* Reading a directory works on NetBSD, and get `code128()` ZINT_ERROR_TOO_LONG instead */
@ -1133,7 +1133,7 @@ static void test_encode_file(const testCtx *const p_ctx) {
(void)p_ctx; (void)p_ctx;
testStartSymbol("test_encode_file", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
(void) testUtilRemove(filename); /* In case junk hanging around */ (void) testUtilRemove(filename); /* In case junk hanging around */
(void) testUtilRemove(outfile); /* In case junk hanging around */ (void) testUtilRemove(outfile); /* In case junk hanging around */
@ -1196,7 +1196,7 @@ static void test_encode_print_outfile_directory(const testCtx *const p_ctx) {
(void)p_ctx; (void)p_ctx;
testStartSymbol("test_encode_print_outfile_directory", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
symbol = ZBarcode_Create(); symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n"); assert_nonnull(symbol, "Symbol not created\n");
@ -1241,7 +1241,7 @@ static void test_bad_args(const testCtx *const p_ctx) {
(void)p_ctx; (void)p_ctx;
testStartSymbol("test_bad_args", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
/* These just return, no error */ /* These just return, no error */
ZBarcode_Clear(NULL); ZBarcode_Clear(NULL);
@ -1380,7 +1380,7 @@ static void test_valid_id(const testCtx *const p_ctx) {
(void)p_ctx; (void)p_ctx;
testStart("test_valid_id"); testStart(p_ctx->func_name);
for (symbol_id = -1; symbol_id < 160; symbol_id++) { for (symbol_id = -1; symbol_id < 160; symbol_id++) {
ret = ZBarcode_ValidID(symbol_id); ret = ZBarcode_ValidID(symbol_id);
@ -1582,7 +1582,7 @@ static void test_barcode_name(const testCtx *const p_ctx) {
(void)p_ctx; (void)p_ctx;
testStart("test_barcode_name"); testStart(p_ctx->func_name);
for (symbol_id = -1; symbol_id < 160; symbol_id++) { for (symbol_id = -1; symbol_id < 160; symbol_id++) {
int prev_ret; int prev_ret;
@ -1625,25 +1625,23 @@ static void test_error_tag(const testCtx *const p_ctx) {
/* 5*/ { 0, ZINT_WARN_NONCOMPLIANT, WARN_FAIL_ALL, "", ZINT_ERROR_NONCOMPLIANT, "Error " }, /* 5*/ { 0, ZINT_WARN_NONCOMPLIANT, WARN_FAIL_ALL, "", ZINT_ERROR_NONCOMPLIANT, "Error " },
/* 6*/ { 0, ZINT_WARN_HRT_TRUNCATED, -1, "", ZINT_WARN_HRT_TRUNCATED, "Warning " }, /* 6*/ { 0, ZINT_WARN_HRT_TRUNCATED, -1, "", ZINT_WARN_HRT_TRUNCATED, "Warning " },
/* 7*/ { 0, ZINT_WARN_HRT_TRUNCATED, WARN_FAIL_ALL, "", ZINT_ERROR_HRT_TRUNCATED, "Error " }, /* 7*/ { 0, ZINT_WARN_HRT_TRUNCATED, WARN_FAIL_ALL, "", ZINT_ERROR_HRT_TRUNCATED, "Error " },
/* 8*/ { 0, ZINT_WARN_HRT_RAW_TEXT, -1, "", ZINT_WARN_HRT_RAW_TEXT, "Warning " }, /* 8*/ { 0, ZINT_ERROR_TOO_LONG, WARN_DEFAULT, "", ZINT_ERROR_TOO_LONG, "Error " },
/* 9*/ { 0, ZINT_WARN_HRT_RAW_TEXT, WARN_FAIL_ALL, "", ZINT_ERROR_HRT_RAW_TEXT, "Error " }, /* 9*/ { 0, ZINT_ERROR_TOO_LONG, WARN_FAIL_ALL, "", ZINT_ERROR_TOO_LONG, "Error " },
/* 10*/ { 0, ZINT_ERROR_TOO_LONG, WARN_DEFAULT, "", ZINT_ERROR_TOO_LONG, "Error " }, /* 10*/ { 0, ZINT_WARN_USES_ECI, -1, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901", ZINT_WARN_USES_ECI, "Warning 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901" },
/* 11*/ { 0, ZINT_ERROR_TOO_LONG, WARN_FAIL_ALL, "", ZINT_ERROR_TOO_LONG, "Error " }, /* 11*/ { 1, ZINT_WARN_USES_ECI, -1, "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012", ZINT_WARN_USES_ECI, "Warning 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901" },
/* 12*/ { 0, ZINT_WARN_USES_ECI, -1, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901", ZINT_WARN_USES_ECI, "Warning 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901" }, /* 12*/ { 0, ZINT_WARN_USES_ECI, WARN_FAIL_ALL, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123", ZINT_ERROR_USES_ECI, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" },
/* 13*/ { 1, ZINT_WARN_USES_ECI, -1, "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012", ZINT_WARN_USES_ECI, "Warning 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901" }, /* 13*/ { 1, ZINT_WARN_USES_ECI, WARN_FAIL_ALL, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", ZINT_ERROR_USES_ECI, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" },
/* 14*/ { 0, ZINT_WARN_USES_ECI, WARN_FAIL_ALL, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123", ZINT_ERROR_USES_ECI, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" }, /* 14*/ { 0, ZINT_ERROR_INVALID_DATA, -1, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123", ZINT_ERROR_INVALID_DATA, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" },
/* 15*/ { 1, ZINT_WARN_USES_ECI, WARN_FAIL_ALL, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", ZINT_ERROR_USES_ECI, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" }, /* 15*/ { 1, ZINT_ERROR_INVALID_DATA, -1, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", ZINT_ERROR_INVALID_DATA, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" },
/* 16*/ { 0, ZINT_ERROR_INVALID_DATA, -1, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123", ZINT_ERROR_INVALID_DATA, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" }, /* 16*/ { 1, ZINT_ERROR_INVALID_DATA, WARN_FAIL_ALL, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", ZINT_ERROR_INVALID_DATA, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" },
/* 17*/ { 1, ZINT_ERROR_INVALID_DATA, -1, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", ZINT_ERROR_INVALID_DATA, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" }, /* 17*/ { 1, ZINT_WARN_USES_ECI, -1, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", ZINT_WARN_USES_ECI, "Warning 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901" },
/* 18*/ { 1, ZINT_ERROR_INVALID_DATA, WARN_FAIL_ALL, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", ZINT_ERROR_INVALID_DATA, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" }, /* 18*/ { 1, ZINT_WARN_USES_ECI, WARN_FAIL_ALL, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", ZINT_ERROR_USES_ECI, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" },
/* 19*/ { 1, ZINT_WARN_USES_ECI, -1, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", ZINT_WARN_USES_ECI, "Warning 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901" }, /* 19*/ { 1, ZINT_ERROR_INVALID_DATA, -1, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", ZINT_ERROR_INVALID_DATA, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" },
/* 20*/ { 1, ZINT_WARN_USES_ECI, WARN_FAIL_ALL, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", ZINT_ERROR_USES_ECI, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" },
/* 21*/ { 1, ZINT_ERROR_INVALID_DATA, -1, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", ZINT_ERROR_INVALID_DATA, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" },
}; };
const int data_size = ARRAY_SIZE(data); const int data_size = ARRAY_SIZE(data);
int i, ret; int i, ret;
testStart("test_error_tag"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
struct zint_symbol s_symbol = {0}; struct zint_symbol s_symbol = {0};
@ -1680,7 +1678,7 @@ static void test_strip_bom(const testCtx *const p_ctx) {
(void)p_ctx; (void)p_ctx;
testStart("test_strip_bom"); testStart(p_ctx->func_name);
strcpy(buf, data); strcpy(buf, data);
length = (int) strlen(buf); length = (int) strlen(buf);
@ -1708,7 +1706,7 @@ static void test_zero_outfile(const testCtx *const p_ctx) {
(void)p_ctx; (void)p_ctx;
testStartSymbol("test_zero_outfile", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
symbol = ZBarcode_Create(); symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n"); assert_nonnull(symbol, "Symbol not created\n");
@ -1741,7 +1739,7 @@ static void test_clear(const testCtx *const p_ctx) {
(void)p_ctx; (void)p_ctx;
testStartSymbol("test_clear", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
symbol = ZBarcode_Create(); symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n"); assert_nonnull(symbol, "Symbol not created\n");
@ -1861,7 +1859,7 @@ static void test_reset(const testCtx *const p_ctx) {
(void)p_ctx; (void)p_ctx;
testStart("test_reset"); testStart(p_ctx->func_name);
symbol_def = ZBarcode_Create(); symbol_def = ZBarcode_Create();
assert_nonnull(symbol_def, "Default symbol not created\n"); assert_nonnull(symbol_def, "Default symbol not created\n");
@ -2082,7 +2080,7 @@ static void test_scale_from_xdimdp(const testCtx *const p_ctx) {
float x_dim_from_scale; float x_dim_from_scale;
float dpmm_from_dpi; float dpmm_from_dpi;
testStart("test_scale_from_xdimdp"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -2156,7 +2154,7 @@ static void test_xdimdp_from_scale(const testCtx *const p_ctx) {
float ret; float ret;
float dpmm_from_dpi; float dpmm_from_dpi;
testStart("test_xdimdp_from_scale"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -2247,7 +2245,7 @@ static void test_utf8_to_eci(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
int expected_length; int expected_length;
testStart("test_utf8_to_eci"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int ret_dest; int ret_dest;
@ -2287,6 +2285,177 @@ static void test_utf8_to_eci(const testCtx *const p_ctx) {
testFinish(); testFinish();
} }
static void test_raw_text(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
int symbology;
int input_mode;
const char *data;
const char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 0*/ { BARCODE_CODE11, -1, "1234567890", "123456789019" },
/* 1*/ { BARCODE_C25STANDARD, -1, "1234567890", "" },
/* 2*/ { BARCODE_C25INTER, -1, "1234567890", "" },
/* 3*/ { BARCODE_C25IATA, -1, "1234567890", "" },
/* 4*/ { BARCODE_C25LOGIC, -1, "1234567890", "" },
/* 5*/ { BARCODE_C25IND, -1, "1234567890", "" },
/* 6*/ { BARCODE_CODE39, -1, "1234567890", "" },
/* 7*/ { BARCODE_EXCODE39, -1, "1234567890", "" },
/* 8*/ { BARCODE_EANX, -1, "123456789012", "1234567890128" },
/* 9*/ { BARCODE_EANX_CHK, -1, "1234567890128", "" },
/* 10*/ { BARCODE_GS1_128, -1, "[01]12345678901231", "0112345678901231" },
/* 11*/ { BARCODE_CODABAR, -1, "A00000000B", "" },
/* 12*/ { BARCODE_CODE128, -1, "1234567890", "" },
/* 13*/ { BARCODE_DPLEIT, -1, "1234567890123", "12345678901236" },
/* 14*/ { BARCODE_DPIDENT, -1, "12345678901", "123456789016" },
/* 15*/ { BARCODE_CODE16K, -1, "1234567890", "" },
/* 16*/ { BARCODE_CODE16K, GS1_MODE, "[01]12345678901231", "0112345678901231" },
/* 17*/ { BARCODE_CODE49, -1, "1234567890", "" },
/* 18*/ { BARCODE_CODE49, GS1_MODE, "[01]12345678901231", "0112345678901231" },
/* 19*/ { BARCODE_CODE93, -1, "1234567890", "1234567890M%" },
/* 20*/ { BARCODE_FLAT, -1, "1234567890", "" },
/* 21*/ { BARCODE_DBAR_OMN, -1, "1234567890123", "12345678901231" },
/* 22*/ { BARCODE_DBAR_LTD, -1, "1234567890123", "12345678901231" },
/* 23*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231", "0112345678901231" },
/* 24*/ { BARCODE_TELEPEN, -1, "1234567890", "1234567890n" },
/* 25*/ { BARCODE_UPCA, -1, "12345678901", "123456789012" },
/* 26*/ { BARCODE_UPCA_CHK, -1, "123456789012", "123456789012" },
/* 27*/ { BARCODE_UPCE, -1, "1234567", "12345670" },
/* 28*/ { BARCODE_UPCE_CHK, -1, "12345670", "" },
/* 29*/ { BARCODE_POSTNET, -1, "12345678901", "123456789014" },
/* 30*/ { BARCODE_MSI_PLESSEY, -1, "1234567890", "" },
/* 31*/ { BARCODE_FIM, -1, "A", "" },
/* 32*/ { BARCODE_LOGMARS, -1, "1234567890", "" },
/* 33*/ { BARCODE_PHARMA, -1, "123456", "" },
/* 34*/ { BARCODE_PZN, -1, "123456", "-01234562" },
/* 35*/ { BARCODE_PHARMA_TWO, -1, "12345678", "" },
/* 36*/ { BARCODE_CEPNET, -1, "12345678", "123456784" },
/* 37*/ { BARCODE_PDF417, -1, "1234567890", "" },
/* 38*/ { BARCODE_PDF417COMP, -1, "1234567890", "" },
/* 39*/ { BARCODE_MAXICODE, -1, "1234567890", "" },
/* 40*/ { BARCODE_QRCODE, -1, "1234567890", "" },
/* 41*/ { BARCODE_QRCODE, UNICODE_MODE, "1234567890", "" },
/* 42*/ { BARCODE_QRCODE, GS1_MODE, "[01]12345678901231", "0112345678901231" },
/* 43*/ { BARCODE_CODE128AB, -1, "1234567890", "" },
/* 44*/ { BARCODE_AUSPOST, -1, "12345678901234567890123", "6212345678901234567890123" },
/* 45*/ { BARCODE_AUSREPLY, -1, "12345678", "4512345678" },
/* 46*/ { BARCODE_AUSROUTE, -1, "12345678", "8712345678" },
/* 47*/ { BARCODE_AUSREDIRECT, -1, "12345678", "9212345678" },
/* 48*/ { BARCODE_ISBNX, -1, "123456789", "9780123456786" },
/* 49*/ { BARCODE_RM4SCC, -1, "1234567890", "12345678906" },
/* 50*/ { BARCODE_DATAMATRIX, -1, "ABC", "" },
/* 51*/ { BARCODE_DATAMATRIX, GS1_MODE, "[01]12345678901231", "0112345678901231" },
/* 52*/ { BARCODE_EAN14, -1, "1234567890123", "0112345678901231" },
/* 53*/ { BARCODE_VIN, -1, "12345678701234567", "" },
/* 54*/ { BARCODE_CODABLOCKF, -1, "1234567890", "" },
/* 55*/ { BARCODE_NVE18, -1, "12345678901234567", "00123456789012345675" },
/* 56*/ { BARCODE_JAPANPOST, -1, "1234567890", "" },
/* 57*/ { BARCODE_KOREAPOST, -1, "123456", "1234569" },
/* 58*/ { BARCODE_DBAR_STK, -1, "1234567890123", "12345678901231" },
/* 59*/ { BARCODE_DBAR_OMNSTK, -1, "1234567890123", "12345678901231" },
/* 60*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231", "0112345678901231" },
/* 61*/ { BARCODE_PLANET, -1, "12345678901", "123456789014" },
/* 62*/ { BARCODE_MICROPDF417, -1, "1234567890", "" },
/* 63*/ { BARCODE_USPS_IMAIL, -1, "12345678901234567890", "" },
/* 64*/ { BARCODE_PLESSEY, -1, "1234567890", "12345678906E" },
/* 65*/ { BARCODE_TELEPEN_NUM, -1, "1234567890", "1234567890g" },
/* 66*/ { BARCODE_ITF14, -1, "1234567890", "00012345678905" },
/* 67*/ { BARCODE_KIX, -1, "123456ABCDE", "" },
/* 68*/ { BARCODE_AZTEC, -1, "1234567890AB", "" },
/* 69*/ { BARCODE_DAFT, -1, "DAFTDAFTDAFTDAFT", "" },
/* 70*/ { BARCODE_DPD, -1, "0123456789012345678901234567", "" },
/* 71*/ { BARCODE_MICROQR, -1, "12345", "" },
/* 72*/ { BARCODE_MICROQR, UNICODE_MODE, "12345", "" },
/* 73*/ { BARCODE_HIBC_128, -1, "1234567890", "+12345678900" },
/* 74*/ { BARCODE_HIBC_39, -1, "1234567890", "+12345678900" },
/* 75*/ { BARCODE_HIBC_DM, -1, "ABC", "+ABCV" },
/* 76*/ { BARCODE_HIBC_QR, -1, "1234567890AB", "+1234567890ABL" },
/* 77*/ { BARCODE_HIBC_PDF, -1, "1234567890", "+12345678900" },
/* 78*/ { BARCODE_HIBC_MICPDF, -1, "1234567890", "+12345678900" },
/* 79*/ { BARCODE_HIBC_BLOCKF, -1, "1234567890", "+12345678900" },
/* 80*/ { BARCODE_HIBC_AZTEC, -1, "1234567890AB", "+1234567890ABL" },
/* 81*/ { BARCODE_DOTCODE, -1, "ABC", "" },
/* 82*/ { BARCODE_HANXIN, -1, "1234567890AB", "" },
/* 83*/ { BARCODE_HANXIN, UNICODE_MODE, "1234567890AB", "" },
/* 84*/ { BARCODE_MAILMARK_2D, -1, "012100123412345678AB19XY1A 0", "JGB 012100123412345678AB19XY1A 0 " },
/* 85*/ { BARCODE_UPU_S10, -1, "EE876543216CA", "" },
/* 86*/ { BARCODE_MAILMARK_4S, -1, "01000000000000000AA00AA0A", "01000000000000000AA00AA0A " },
/* 87*/ { BARCODE_AZRUNE, -1, "255", "" },
/* 88*/ { BARCODE_CODE32, -1, "12345678", "3PRM8N" },
/* 89*/ { BARCODE_EANX_CC, -1, "123456789012", "1234567890128|2001" },
/* 90*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901231", "0112345678901231|2001" },
/* 91*/ { BARCODE_DBAR_OMN_CC, -1, "1234567890123", "12345678901231|2001" },
/* 92*/ { BARCODE_DBAR_LTD_CC, -1, "1234567890123", "12345678901231|2001" },
/* 93*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231", "0112345678901231|2001" },
/* 94*/ { BARCODE_UPCA_CC, -1, "12345678901", "123456789012|2001" },
/* 95*/ { BARCODE_UPCE_CC, -1, "1234567", "12345670|2001" },
/* 96*/ { BARCODE_DBAR_STK_CC, -1, "1234567890123", "12345678901231|2001" },
/* 97*/ { BARCODE_DBAR_OMNSTK_CC, -1, "1234567890123", "12345678901231|2001" },
/* 98*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231", "0112345678901231|2001" },
/* 99*/ { BARCODE_CHANNEL, -1, "01", "" },
/*100*/ { BARCODE_CODEONE, -1, "12345678901234567890", "" },
/*101*/ { BARCODE_CODEONE, GS1_MODE, "[01]12345678901231", "0112345678901231" },
/*102*/ { BARCODE_GRIDMATRIX, -1, "ABC", "" },
/*103*/ { BARCODE_GRIDMATRIX, UNICODE_MODE, "ABC", "" },
/*104*/ { BARCODE_UPNQR, -1, "1234567890AB", "" },
/*105*/ { BARCODE_ULTRA, -1, "1234567890", "" },
/*106*/ { BARCODE_ULTRA, GS1_MODE, "[01]12345678901231", "0112345678901231" },
/*107*/ { BARCODE_RMQR, -1, "12345", "" },
/*108*/ { BARCODE_RMQR, UNICODE_MODE, "12345", "" },
/*109*/ { BARCODE_RMQR, GS1_MODE, "[01]12345678901231", "0112345678901231" },
/*110*/ { BARCODE_BC412, -1, "1234567", "1U234567" },
};
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
const char *expected;
int expected_length;
const char *text;
testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) {
if (testContinue(p_ctx, i)) continue;
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
if (is_composite(data[i].symbology)) {
text = "[20]01";
strcpy(symbol->primary, data[i].data);
} else {
text = data[i].data;
}
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/,
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, BARCODE_RAW_TEXT,
text, -1, debug);
expected = data[i].expected[0] ? data[i].expected : data[i].data;
expected_length = (int) strlen(expected);
ret = ZBarcode_Encode(symbol, TCU(text), length);
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
assert_nonnull(symbol->raw_segs[0].source, "i:%d raw_segs[0].source NULL\n", i);
assert_equal(symbol->raw_segs[0].length, expected_length,
"i:%d raw_segs[0].length %d (%.*s) != expected_length %d (%s)\n",
i, symbol->raw_segs[0].length, symbol->raw_segs[0].length, symbol->raw_segs[0].source,
expected_length, expected);
assert_zero(memcmp(symbol->raw_segs[0].source, expected, expected_length),
"i:%d memcmp(%.*s, %.*s, %d) != 0\n",
i, expected_length, symbol->raw_segs[0].source, expected_length, expected, expected_length);
ZBarcode_Delete(symbol);
}
testFinish();
}
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
testFunction funcs[] = { /* name, func */ testFunction funcs[] = { /* name, func */
@ -2316,6 +2485,7 @@ int main(int argc, char *argv[]) {
{ "test_scale_from_xdimdp", test_scale_from_xdimdp }, { "test_scale_from_xdimdp", test_scale_from_xdimdp },
{ "test_xdimdp_from_scale", test_xdimdp_from_scale }, { "test_xdimdp_from_scale", test_xdimdp_from_scale },
{ "test_utf8_to_eci", test_utf8_to_eci }, { "test_utf8_to_eci", test_utf8_to_eci },
{ "test_raw_text", test_raw_text },
}; };
testRun(argc, argv, funcs, ARRAY_SIZE(funcs)); testRun(argc, argv, funcs, ARRAY_SIZE(funcs));

View file

@ -39,26 +39,27 @@ static void test_4s_hrt(const testCtx *const p_ctx) {
const char *data; const char *data;
const char *expected; const char *expected;
const char *expected_raw;
}; };
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = { static const struct item data[] = {
/* 0*/ { -1, "1100000000000XY11", "" }, /* None */ /* 0*/ { -1, "1100000000000XY11", "", "" }, /* None */
/* 1*/ { BARCODE_RAW_TEXT, "1100000000000XY11", "1100000000000XY11 " }, /* 1*/ { BARCODE_RAW_TEXT, "1100000000000XY11", "", "1100000000000XY11 " },
/* 2*/ { -1, "1100000000000XY11 ", "" }, /* None */ /* 2*/ { -1, "1100000000000XY11 ", "", "" }, /* None */
/* 3*/ { BARCODE_RAW_TEXT, "1100000000000XY11 ", "1100000000000XY11 " }, /* 3*/ { BARCODE_RAW_TEXT, "1100000000000XY11 ", "", "1100000000000XY11 " },
/* 4*/ { -1, "0100000000000A00AA0A", "" }, /* None */ /* 4*/ { -1, "0100000000000A00AA0A", "", "" }, /* None */
/* 5*/ { BARCODE_RAW_TEXT, "0100000000000A00AA0A", "0100000000000A00AA0A " }, /* None */ /* 5*/ { BARCODE_RAW_TEXT, "0100000000000A00AA0A", "", "0100000000000A00AA0A " }, /* None */
/* 6*/ { -1, "41038422416563762XY11 ", "" }, /* None */ /* 6*/ { -1, "41038422416563762XY11 ", "", "" }, /* None */
/* 7*/ { BARCODE_RAW_TEXT, "41038422416563762XY11 ", "41038422416563762XY11 " }, /* 7*/ { BARCODE_RAW_TEXT, "41038422416563762XY11 ", "", "41038422416563762XY11 " },
/* 8*/ { -1, "01000000000000000AA000AA0A", "" }, /* None */ /* 8*/ { -1, "01000000000000000AA000AA0A", "", "" }, /* None */
/* 9*/ { BARCODE_RAW_TEXT, "01000000000000000AA000AA0A", "01000000000000000AA000AA0A" }, /* 9*/ { BARCODE_RAW_TEXT, "01000000000000000AA000AA0A", "", "01000000000000000AA000AA0A" },
}; };
const int data_size = ARRAY_SIZE(data); const int data_size = ARRAY_SIZE(data);
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
int expected_length; int expected_length, expected_raw_length;
testStartSymbol("test_4s_hrt", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -71,6 +72,7 @@ static void test_4s_hrt(const testCtx *const p_ctx) {
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options, -1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options,
data[i].data, -1, debug); data[i].data, -1, debug);
expected_length = (int) strlen(data[i].expected); expected_length = (int) strlen(data[i].expected);
expected_raw_length = (int) strlen(data[i].expected_raw);
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt); assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
@ -79,6 +81,18 @@ static void test_4s_hrt(const testCtx *const p_ctx) {
i, symbol->text_length, expected_length, symbol->text); i, symbol->text_length, expected_length, symbol->text);
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
i, symbol->text, data[i].expected); i, symbol->text, data[i].expected);
if (symbol->output_options & BARCODE_RAW_TEXT) {
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
assert_nonnull(symbol->raw_segs[0].source, "i:%d raw_segs[0].source NULL\n", i);
assert_equal(symbol->raw_segs[0].length, expected_raw_length,
"i:%d raw_segs[0].length %d != expected_raw_length %d\n",
i, symbol->raw_segs[0].length, expected_raw_length);
assert_zero(memcmp(symbol->raw_segs[0].source, data[i].expected_raw, expected_raw_length),
"i:%d memcmp(%s, %s, %d) != 0\n",
i, symbol->raw_segs[0].source, data[i].expected_raw, expected_raw_length);
} else {
assert_null(symbol->raw_segs, "i:%d raw_segs not NULL\n", i);
}
ZBarcode_Delete(symbol); ZBarcode_Delete(symbol);
} }
@ -159,7 +173,7 @@ static void test_4s_input(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_4s_input", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -229,7 +243,7 @@ static void test_4s_encode_vector(const testCtx *const p_ctx) {
char actual_daft[80]; char actual_daft[80];
testStartSymbol("test_4s_encode_vector", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -283,7 +297,7 @@ static void test_4s_encode(const testCtx *const p_ctx) {
char escaped[1024]; char escaped[1024];
testStartSymbol("test_4s_encode", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -374,7 +388,7 @@ static void test_2d_input(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_2d_input", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -597,10 +611,11 @@ static void test_2d_encode(const testCtx *const p_ctx) {
char cmp_buf[32768]; char cmp_buf[32768];
char cmp_msg[1024]; char cmp_msg[1024];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ /* Only do BWIPP/ZXing-C++ tests if asked, too slow otherwise */
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript();
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder();
testStartSymbol("test_2d_encode", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -646,12 +661,14 @@ static void test_2d_encode(const testCtx *const p_ctx) {
int cmp_len, ret_len; int cmp_len, ret_len;
char modules_dump[144 * 144 + 1]; char modules_dump[144 * 144 + 1];
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i);
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, 1 /*zxingcpp_cmp*/, cmp_buf, sizeof(cmp_buf), &cmp_len);
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len); ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length,
NULL /*primary*/, escaped, &ret_len);
assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n",
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, escaped); i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len,
escaped);
} }
} }
} }
@ -662,6 +679,81 @@ static void test_2d_encode(const testCtx *const p_ctx) {
testFinish(); testFinish();
} }
static void test_2d_rt(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
int input_mode;
int output_options;
const char *data;
int length;
int ret;
int expected_eci;
const char *expected;
int expected_length;
int expected_raw_eci;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, "jgb 012100123412345678ab19xy1a 0", -1, 0, 0, "", -1, 0 },
/* 1*/ { UNICODE_MODE, BARCODE_RAW_TEXT, "jgb 012100123412345678ab19xy1a 0", -1, 0, 0, "JGB 012100123412345678AB19XY1A 0 ", -1, 3 },
};
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
int expected_length;
char escaped[4096];
char escaped2[4096];
testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) {
if (testContinue(p_ctx, i)) continue;
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
length = testUtilSetSymbol(symbol, BARCODE_MAILMARK_2D, data[i].input_mode, -1 /*eci*/,
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options,
data[i].data, data[i].length, debug);
expected_length = data[i].expected_length == -1 ? (int) strlen(data[i].expected) : data[i].expected_length;
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n",
i, ret, data[i].ret, symbol->errtxt);
if (ret < ZINT_ERROR) {
assert_equal(symbol->eci, data[i].expected_eci, "i:%d eci %d != %d\n",
i, symbol->eci, data[i].expected_eci);
if (symbol->output_options & BARCODE_RAW_TEXT) {
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
assert_nonnull(symbol->raw_segs[0].source, "i:%d raw_segs[0].source NULL\n", i);
assert_equal(symbol->raw_segs[0].length, expected_length,
"i:%d raw_segs[0].length %d != expected_length %d\n",
i, symbol->raw_segs[0].length, expected_length);
assert_zero(memcmp(symbol->raw_segs[0].source, data[i].expected, expected_length),
"i:%d raw_segs[0].source memcmp(%s, %s, %d) != 0\n", i,
testUtilEscape((const char *) symbol->raw_segs[0].source, symbol->raw_segs[0].length,
escaped, sizeof(escaped)),
testUtilEscape(data[i].expected, expected_length, escaped2, sizeof(escaped2)),
expected_length);
assert_equal(symbol->raw_segs[0].eci, data[i].expected_raw_eci,
"i:%d raw_segs[0].eci %d != expected_raw_eci %d\n",
i, symbol->raw_segs[0].eci, data[i].expected_raw_eci);
} else {
assert_null(symbol->raw_segs, "i:%d raw_segs not NULL\n", i);
}
}
ZBarcode_Delete(symbol);
}
testFinish();
}
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
testFunction funcs[] = { /* name, func */ testFunction funcs[] = { /* name, func */
@ -671,6 +763,7 @@ int main(int argc, char *argv[]) {
{ "test_4s_encode", test_4s_encode }, { "test_4s_encode", test_4s_encode },
{ "test_2d_input", test_2d_input }, { "test_2d_input", test_2d_input },
{ "test_2d_encode", test_2d_encode }, { "test_2d_encode", test_2d_encode },
{ "test_2d_rt", test_2d_rt },
}; };
testRun(argc, argv, funcs, ARRAY_SIZE(funcs)); testRun(argc, argv, funcs, ARRAY_SIZE(funcs));

View file

@ -44,45 +44,46 @@ static void test_large(const testCtx *const p_ctx) {
int expected_rows; int expected_rows;
int expected_width; int expected_width;
int bwipp_cmp; int bwipp_cmp;
int zxingcpp_cmp;
const char *comment; const char *comment;
}; };
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = { static const struct item data[] = {
/* 0*/ { -1, -1, "1", 138, "", 0, 33, 30, 1, "Mode 4 (138 agrees with ISO/IEC 16023:2000)" }, /* 0*/ { -1, -1, "1", 138, "", 0, 33, 30, 1, 1, "Mode 4 (138 agrees with ISO/IEC 16023:2000)" },
/* 1*/ { -1, -1, "1", 139, "", ZINT_ERROR_TOO_LONG, -1, -1, 1, "" }, /* 1*/ { -1, -1, "1", 139, "", ZINT_ERROR_TOO_LONG, -1, -1, 1, 1, "" },
/* 2*/ { -1, -1, "1", 144, "", ZINT_ERROR_TOO_LONG, -1, -1, 1, "" }, /* 2*/ { -1, -1, "1", 144, "", ZINT_ERROR_TOO_LONG, -1, -1, 1, 1, "" },
/* 3*/ { -1, -1, "1", 145, "", ZINT_ERROR_TOO_LONG, -1, -1, 1, "Absolute max" }, /* 3*/ { -1, -1, "1", 145, "", ZINT_ERROR_TOO_LONG, -1, -1, 1, 1, "Absolute max" },
/* 4*/ { -1, -1, "A", 93, "", 0, 33, 30, 1, "" }, /* 4*/ { -1, -1, "A", 93, "", 0, 33, 30, 1, 1, "" },
/* 5*/ { -1, -1, "A", 94, "", ZINT_ERROR_TOO_LONG, -1, -1, 1, "" }, /* 5*/ { -1, -1, "A", 94, "", ZINT_ERROR_TOO_LONG, -1, -1, 1, 1, "" },
/* 6*/ { -1, -1, "\001", 91, "", 0, 33, 30, 1, "" }, /* 6*/ { -1, -1, "\001", 91, "", 0, 33, 30, 1, 1, "" },
/* 7*/ { -1, -1, "\001", 92, "", ZINT_ERROR_TOO_LONG, -1, -1, 1, "" }, /* 7*/ { -1, -1, "\001", 92, "", ZINT_ERROR_TOO_LONG, -1, -1, 1, 1, "" },
/* 8*/ { -1, -1, "\200", 91, "", 0, 33, 30, 1, "" }, /* 8*/ { -1, -1, "\200", 91, "", 0, 33, 30, 1, 899, "" },
/* 9*/ { -1, -1, "\200", 92, "", ZINT_ERROR_TOO_LONG, -1, -1, 1, "" }, /* 9*/ { -1, -1, "\200", 92, "", ZINT_ERROR_TOO_LONG, -1, -1, 1, 899, "" },
/* 10*/ { 2, -1, "1", 126, "123456789123123", 0, 33, 30, 1, "" }, /* 10*/ { 2, -1, "1", 126, "123456789123123", 0, 33, 30, 1, 1, "" },
/* 11*/ { 2, -1, "1", 127, "123456789123123", ZINT_ERROR_TOO_LONG, -1, -1, 1, "" }, /* 11*/ { 2, -1, "1", 127, "123456789123123", ZINT_ERROR_TOO_LONG, -1, -1, 1, 1, "" },
/* 12*/ { 2, -1, "A", 84, "123456789123123", 0, 33, 30, 1, "" }, /* 12*/ { 2, -1, "A", 84, "123456789123123", 0, 33, 30, 1, 1, "" },
/* 13*/ { 2, -1, "A", 85, "123456789123123", ZINT_ERROR_TOO_LONG, -1, -1, 1, "" }, /* 13*/ { 2, -1, "A", 85, "123456789123123", ZINT_ERROR_TOO_LONG, -1, -1, 1, 1, "" },
/* 14*/ { 2, 96 + 1, "1", 109, "123456789123123", 0, 33, 30, 1, "" }, /* 14*/ { 2, 96 + 1, "1", 109, "123456789123123", 0, 33, 30, 1, 1, "" },
/* 15*/ { 2, 96 + 1, "1", 110, "123456789123123", ZINT_ERROR_TOO_LONG, -1, -1, 1, "" }, /* 15*/ { 2, 96 + 1, "1", 110, "123456789123123", ZINT_ERROR_TOO_LONG, -1, -1, 1, 1, "" },
/* 16*/ { 2, 96 + 1, "1", 136, "123456789123123", ZINT_ERROR_TOO_LONG, -1, -1, 1, "Absolute max with SCM vv" }, /* 16*/ { 2, 96 + 1, "1", 136, "123456789123123", ZINT_ERROR_TOO_LONG, -1, -1, 1, 1, "Absolute max with SCM vv" },
/* 17*/ { 3, -1, "1", 126, "ABCDEF123123", 0, 33, 30, 1, "" }, /* 17*/ { 3, -1, "1", 126, "ABCDEF123123", 0, 33, 30, 1, 1, "" },
/* 18*/ { 3, -1, "1", 127, "ABCDEF123123", ZINT_ERROR_TOO_LONG, -1, -1, 1, "" }, /* 18*/ { 3, -1, "1", 127, "ABCDEF123123", ZINT_ERROR_TOO_LONG, -1, -1, 1, 1, "" },
/* 19*/ { 3, -1, "A", 84, "ABCDEF123123", 0, 33, 30, 1, "" }, /* 19*/ { 3, -1, "A", 84, "ABCDEF123123", 0, 33, 30, 1, 1, "" },
/* 20*/ { 3, -1, "A", 85, "ABCDEF123123", ZINT_ERROR_TOO_LONG, -1, -1, 1, "" }, /* 20*/ { 3, -1, "A", 85, "ABCDEF123123", ZINT_ERROR_TOO_LONG, -1, -1, 1, 1, "" },
/* 21*/ { 3, 96 + 1, "1", 109, "ABCDEF123123", 0, 33, 30, 1, "" }, /* 21*/ { 3, 96 + 1, "1", 109, "ABCDEF123123", 0, 33, 30, 1, 1, "" },
/* 22*/ { 3, 96 + 1, "1", 110, "ABCDEF123123", ZINT_ERROR_TOO_LONG, -1, -1, 1, "" }, /* 22*/ { 3, 96 + 1, "1", 110, "ABCDEF123123", ZINT_ERROR_TOO_LONG, -1, -1, 1, 1, "" },
/* 23*/ { 0, -1, "1", 126, "123456789123123", 0, 33, 30, 1, "Mode 2" }, /* 23*/ { 0, -1, "1", 126, "123456789123123", 0, 33, 30, 1, 1, "Mode 2" },
/* 24*/ { 0, -1, "1", 127, "123456789123123", ZINT_ERROR_TOO_LONG, -1, -1, 1, "" }, /* 24*/ { 0, -1, "1", 127, "123456789123123", ZINT_ERROR_TOO_LONG, -1, -1, 1, 1, "" },
/* 25*/ { 0, -1, "1", 126, "ABCDEF123123", 0, 33, 30, 1, "Mode 3" }, /* 25*/ { 0, -1, "1", 126, "ABCDEF123123", 0, 33, 30, 1, 1, "Mode 3" },
/* 26*/ { 0, -1, "1", 127, "ABCDEF123123", ZINT_ERROR_TOO_LONG, -1, -1, 1, "" }, /* 26*/ { 0, -1, "1", 127, "ABCDEF123123", ZINT_ERROR_TOO_LONG, -1, -1, 1, 1, "" },
/* 27*/ { 5, -1, "1", 113, "", 0, 33, 30, 1, "Extra EEC" }, /* 27*/ { 5, -1, "1", 113, "", 0, 33, 30, 1, 1, "Extra EEC" },
/* 28*/ { 5, -1, "1", 114, "", ZINT_ERROR_TOO_LONG, -1, -1, 1, "" }, /* 28*/ { 5, -1, "1", 114, "", ZINT_ERROR_TOO_LONG, -1, -1, 1, 1, "" },
/* 29*/ { 5, -1, "A", 77, "", 0, 33, 30, 1, "" }, /* 29*/ { 5, -1, "A", 77, "", 0, 33, 30, 1, 1, "" },
/* 30*/ { 5, -1, "A", 78, "", ZINT_ERROR_TOO_LONG, -1, -1, 1, "" }, /* 30*/ { 5, -1, "A", 78, "", ZINT_ERROR_TOO_LONG, -1, -1, 1, 1, "" },
/* 31*/ { 6, -1, "1", 138, "", 0, 33, 30, 1, "" }, /* 31*/ { 6, -1, "1", 138, "", 0, 33, 30, 1, 1, "" },
/* 32*/ { 6, -1, "1", 139, "", ZINT_ERROR_TOO_LONG, -1, -1, 1, "" }, /* 32*/ { 6, -1, "1", 139, "", ZINT_ERROR_TOO_LONG, -1, -1, 1, 1, "" },
/* 33*/ { 6, -1, "A", 93, "", 0, 33, 30, 1, "" }, /* 33*/ { 6, -1, "A", 93, "", 0, 33, 30, 1, 1, "" },
/* 34*/ { 6, -1, "A", 94, "", ZINT_ERROR_TOO_LONG, -1, -1, 1, "" }, /* 34*/ { 6, -1, "A", 94, "", ZINT_ERROR_TOO_LONG, -1, -1, 1, 1, "" },
}; };
const int data_size = ARRAY_SIZE(data); const int data_size = ARRAY_SIZE(data);
int i, length, ret; int i, length, ret;
@ -94,10 +95,11 @@ static void test_large(const testCtx *const p_ctx) {
char cmp_msg[1024]; char cmp_msg[1024];
const char expected_errtxt[] = "Error 553: Input too long, requires too many codewords (maximum 144)"; const char expected_errtxt[] = "Error 553: Input too long, requires too many codewords (maximum 144)";
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ /* Only do BWIPP/ZXing-C++ tests if asked, too slow otherwise */
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript();
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder();
testStartSymbol("test_large", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -141,13 +143,18 @@ static void test_large(const testCtx *const p_ctx) {
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data_buf, length, debug)) { if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data_buf, length, debug)) {
int cmp_len, ret_len; int cmp_len, ret_len;
char modules_dump[33 * 33 + 1]; char modules_dump[33 * 33 + 1];
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1,
ret = testUtilZXingCPP(i, symbol, data_buf, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); "i:%d testUtilModulesDump == -1\n", i);
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); ret = testUtilZXingCPP(i, symbol, data_buf, length, modules_dump, data[i].zxingcpp_cmp, cmp_buf,
sizeof(cmp_buf), &cmp_len);
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n",
i, testUtilBarcodeName(symbol->symbology), ret);
ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data_buf, length, symbol->primary, escaped, &ret_len); ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data_buf, length, symbol->primary,
escaped, &ret_len);
assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n",
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, escaped); i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len,
escaped);
} }
} }
@ -247,9 +254,9 @@ static void test_input(const testCtx *const p_ctx) {
/* 64*/ { UNICODE_MODE, -1, -1, -1, { 1, 2, "A" }, "A", -1, "", ZINT_ERROR_INVALID_OPTION, 0, "Error 549: Structured Append ID not available for MaxiCode", 4, 0, 1, 1, "" }, /* 64*/ { UNICODE_MODE, -1, -1, -1, { 1, 2, "A" }, "A", -1, "", ZINT_ERROR_INVALID_OPTION, 0, "Error 549: Structured Append ID not available for MaxiCode", 4, 0, 1, 1, "" },
/* 65*/ { UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "b..A", -1, "", 0, 30, "(144) 04 3B 02 2E 2E 01 21 21 21 21 11 1C 30 14 2D 3E 16 0E 0C 31 21 21 21 21 21 21 21 21", 4, 0, 1, 1, "" }, /* 65*/ { UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "b..A", -1, "", 0, 30, "(144) 04 3B 02 2E 2E 01 21 21 21 21 11 1C 30 14 2D 3E 16 0E 0C 31 21 21 21 21 21 21 21 21", 4, 0, 1, 1, "" },
/* 66*/ { UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "A123456789b123456789bbbA", -1, "", 0, 30, "(144) 04 01 1F 07 16 3C 34 15 3F 02 10 1B 28 22 20 32 37 0C 0B 2A 1F 07 16 3C 34 15 02 02", 4, 0, 1, 1, "" }, /* 66*/ { UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "A123456789b123456789bbbA", -1, "", 0, 30, "(144) 04 01 1F 07 16 3C 34 15 3F 02 10 1B 28 22 20 32 37 0C 0B 2A 1F 07 16 3C 34 15 02 02", 4, 0, 1, 1, "" },
/* 67*/ { ESCAPE_MODE, -1, -1, -1, { 0, 0, "" }, "\\d192\\d224\\d224\\d224\\d192\\d224\\d224\\d224\\d192\\d224\\d224\\d224\\d192\\d224\\d224\\d224\\d192\\d224\\d224\\d224\\d192", -1, "", 0, 30, "(144) 04 3C 00 3D 3D 00 00 00 3C 00 34 39 0E 35 1D 25 00 1B 28 03 00 00 00 3C 00 00 00 00", 4, 0, 1, 1, "BWIPP PR #279" }, /* 67*/ { ESCAPE_MODE, -1, -1, -1, { 0, 0, "" }, "\\d192\\d224\\d224\\d224\\d192\\d224\\d224\\d224\\d192\\d224\\d224\\d224\\d192\\d224\\d224\\d224\\d192\\d224\\d224\\d224\\d192", -1, "", 0, 30, "(144) 04 3C 00 3D 3D 00 00 00 3C 00 34 39 0E 35 1D 25 00 1B 28 03 00 00 00 3C 00 00 00 00", 4, 0, 1, 899, "BWIPP PR #279" },
/* 68*/ { ESCAPE_MODE, -1, 2, -1, { 0, 0, "" }, "1Z34567890\\GUPSN\\G102562\\G034\\G\\G1/1\\G\\GY\\G2201 Second St\\GFt Myers\\GFL\\R\\E", -1, "339010000840001", 0, 30, "(144) 02 34 21 13 03 15 02 12 07 00 0C 03 00 38 24 04 0B 1F 2F 21 31 1A 33 34 35 36 37 38", 2, 0, 1, 1, "" }, /* 68*/ { ESCAPE_MODE, -1, 2, -1, { 0, 0, "" }, "1Z34567890\\GUPSN\\G102562\\G034\\G\\G1/1\\G\\GY\\G2201 Second St\\GFt Myers\\GFL\\R\\E", -1, "339010000840001", 0, 30, "(144) 02 34 21 13 03 15 02 12 07 00 0C 03 00 38 24 04 0B 1F 2F 21 31 1A 33 34 35 36 37 38", 2, 0, 1, 1, "" },
/* 69*/ { ESCAPE_MODE, -1, -1, -1, { 0, 0, "" }, "ABabcdeAabcdABCabcdABabc\\d192\\d192 \\d192\\d224\\d224\\d028\\d224\\d001\\d001\\d001\\d029\\d00112345678a123456789aABCDa\\d192\\d224\\d001\\d192\\d001\\d224\\d030\\d004", -1, "", 0, 30, "(144) 04 01 02 3F 01 02 03 04 05 3B 25 28 3F 32 0D 10 0D 0F 35 11 01 01 02 03 04 39 01 02", 4, 0, 1, 1, "Exercises all latches & no. of shifts" }, /* 69*/ { ESCAPE_MODE, -1, -1, -1, { 0, 0, "" }, "ABabcdeAabcdABCabcdABabc\\d192\\d192 \\d192\\d224\\d224\\d028\\d224\\d001\\d001\\d001\\d029\\d00112345678a123456789aABCDa\\d192\\d224\\d001\\d192\\d001\\d224\\d030\\d004", -1, "", 0, 30, "(144) 04 01 02 3F 01 02 03 04 05 3B 25 28 3F 32 0D 10 0D 0F 35 11 01 01 02 03 04 39 01 02", 4, 0, 1, 899, "Exercises all latches & no. of shifts" },
/* 70*/ { UNICODE_MODE, 1023, 3, 96 + 1, { 2, 3, "" }, "A", -1, "P144275001", 0, 30, "(144) 03 08 08 0D 1D 0C 34 04 05 00 13 29 0C 17 0F 15 2E 38 00 0B 21 0A 3B 2A 29 3B 28 1E", 3, 97, 1, 1, "ECI, Structured Append, SCM" }, /* 70*/ { UNICODE_MODE, 1023, 3, 96 + 1, { 2, 3, "" }, "A", -1, "P144275001", 0, 30, "(144) 03 08 08 0D 1D 0C 34 04 05 00 13 29 0C 17 0F 15 2E 38 00 0B 21 0A 3B 2A 29 3B 28 1E", 3, 97, 1, 1, "ECI, Structured Append, SCM" },
/* 71*/ { UNICODE_MODE, -1, 5, -1, { 0, 0, "" }, "A", -1, "", 0, 30, "(144) 05 01 21 21 21 21 21 21 21 21 1F 2E 09 22 19 05 31 13 2B 28 21 21 21 21 21 21 21 21", 5, 0, 1, 1, "" }, /* 71*/ { UNICODE_MODE, -1, 5, -1, { 0, 0, "" }, "A", -1, "", 0, 30, "(144) 05 01 21 21 21 21 21 21 21 21 1F 2E 09 22 19 05 31 13 2B 28 21 21 21 21 21 21 21 21", 5, 0, 1, 1, "" },
/* 72*/ { UNICODE_MODE, -1, 6, -1, { 0, 0, "" }, "A", -1, "", 0, 30, "(144) 06 01 21 21 21 21 21 21 21 21 26 0D 39 39 11 1E 0E 2C 00 37 21 21 21 21 21 21 21 21", 6, 0, 1, 1, "" }, /* 72*/ { UNICODE_MODE, -1, 6, -1, { 0, 0, "" }, "A", -1, "", 0, 30, "(144) 06 01 21 21 21 21 21 21 21 21 26 0D 39 39 11 1E 0E 2C 00 37 21 21 21 21 21 21 21 21", 6, 0, 1, 1, "" },
@ -263,10 +270,11 @@ static void test_input(const testCtx *const p_ctx) {
char cmp_buf[32768] = {0}; /* Suppress clang -fsanitize=memory false positive */ char cmp_buf[32768] = {0}; /* Suppress clang -fsanitize=memory false positive */
char cmp_msg[1024]; char cmp_msg[1024];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ /* Only do BWIPP/ZXing-C++ tests if asked, too slow otherwise */
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript();
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder();
testStartSymbol("test_input", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -277,14 +285,17 @@ static void test_input(const testCtx *const p_ctx) {
symbol->debug = ZINT_DEBUG_TEST; /* Needed to get codeword dump in errtxt */ symbol->debug = ZINT_DEBUG_TEST; /* Needed to get codeword dump in errtxt */
length = testUtilSetSymbol(symbol, BARCODE_MAXICODE, data[i].input_mode, data[i].eci, data[i].option_1, data[i].option_2, -1, -1 /*output_options*/, data[i].data, data[i].length, debug); length = testUtilSetSymbol(symbol, BARCODE_MAXICODE, data[i].input_mode, data[i].eci,
data[i].option_1, data[i].option_2, -1 /*option_3*/, -1 /*output_options*/,
data[i].data, data[i].length, debug);
if (data[i].structapp.count) { if (data[i].structapp.count) {
symbol->structapp = data[i].structapp; symbol->structapp = data[i].structapp;
} }
strcpy(symbol->primary, data[i].primary); strcpy(symbol->primary, data[i].primary);
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n",
i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) { if (p_ctx->generate) {
printf(" /*%3d*/ { %s, %d, %d, %d, { %d, %d, \"%s\" }, \"%s\", %d, \"%s\", %s, %d, \"%s\", %d, %d, %d, %d, \"%s\" },\n", printf(" /*%3d*/ { %s, %d, %d, %d, { %d, %d, \"%s\" }, \"%s\", %d, \"%s\", %s, %d, \"%s\", %d, %d, %d, %d, \"%s\" },\n",
@ -297,9 +308,11 @@ static void test_input(const testCtx *const p_ctx) {
data[i].bwipp_cmp, data[i].zxingcpp_cmp, data[i].comment); data[i].bwipp_cmp, data[i].zxingcpp_cmp, data[i].comment);
} else { } else {
if (ret < ZINT_ERROR) { if (ret < ZINT_ERROR) {
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); 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);
} }
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
i, symbol->errtxt, data[i].expected);
assert_equal(symbol->option_1, data[i].expected_option_1, "i:%d symbol->option_1 %d != %d (option_2 %d)\n", assert_equal(symbol->option_1, data[i].expected_option_1, "i:%d symbol->option_1 %d != %d (option_2 %d)\n",
i, symbol->option_1, data[i].expected_option_1, symbol->option_2); i, symbol->option_1, data[i].expected_option_1, symbol->option_2);
assert_equal(symbol->option_2, data[i].expected_option_2, "i:%d symbol->option_2 %d != %d\n", assert_equal(symbol->option_2, data[i].expected_option_2, "i:%d symbol->option_2 %d != %d\n",
@ -309,31 +322,45 @@ static void test_input(const testCtx *const p_ctx) {
if (ret < ZINT_ERROR) { if (ret < ZINT_ERROR) {
if (do_bwipp && testUtilCanBwipp(i, symbol, data[i].option_1, data[i].option_2, -1, debug)) { if (do_bwipp && testUtilCanBwipp(i, symbol, data[i].option_1, data[i].option_2, -1, debug)) {
if (!data[i].bwipp_cmp) { if (!data[i].bwipp_cmp) {
if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d %s not BWIPP compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), data[i].comment); if (debug & ZINT_DEBUG_TEST_PRINT) {
printf("i:%d %s not BWIPP compatible (%s)\n",
i, testUtilBarcodeName(symbol->symbology), data[i].comment);
}
} else { } else {
char modules_dump[33 * 33 + 1]; char modules_dump[33 * 33 + 1];
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1,
ret = testUtilBwipp(i, symbol, data[i].option_1, data[i].option_2, -1, data[i].data, length, symbol->primary, cmp_buf, sizeof(cmp_buf), NULL); "i:%d testUtilModulesDump == -1\n", i);
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); ret = testUtilBwipp(i, symbol, data[i].option_1, data[i].option_2, -1, data[i].data, length,
symbol->primary, cmp_buf, sizeof(cmp_buf), NULL);
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n",
i, testUtilBarcodeName(symbol->symbology), ret);
ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, modules_dump); ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, modules_dump);
assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n", assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n",
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, modules_dump); i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, modules_dump);
} }
} }
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) { if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) {
if (!data[i].zxingcpp_cmp) { if (!data[i].zxingcpp_cmp) {
if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d %s not ZXing-C++ compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), data[i].comment); if (debug & ZINT_DEBUG_TEST_PRINT) {
printf("i:%d %s not ZXing-C++ compatible (%s)\n",
i, testUtilBarcodeName(symbol->symbology), data[i].comment);
}
} else { } else {
int cmp_len, ret_len; int cmp_len, ret_len;
char modules_dump[33 * 33 + 1]; char modules_dump[33 * 33 + 1];
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1,
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); "i:%d testUtilModulesDump == -1\n", i);
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, data[i].zxingcpp_cmp,
cmp_buf, sizeof(cmp_buf), &cmp_len);
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n",
i, testUtilBarcodeName(symbol->symbology), ret);
ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, symbol->primary, escaped, &ret_len); ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length,
symbol->primary, escaped, &ret_len);
assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n",
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, escaped); i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf,
ret_len, escaped);
} }
} }
} }
@ -361,11 +388,12 @@ static void test_encode(const testCtx *const p_ctx) {
int expected_rows; int expected_rows;
int expected_width; int expected_width;
int bwipp_cmp; int bwipp_cmp;
int zxingcpp_cmp;
const char *comment; const char *comment;
const char *expected; const char *expected;
}; };
static const struct item data[] = { static const struct item data[] = {
/* 0*/ { -1, -1, -1, { 0, 0, "" }, "THIS IS A 93 CHARACTER CODE SET A MESSAGE THAT FILLS A MODE 4, UNAPPENDED, MAXICODE SYMBOL...", -1, "", 0, 33, 30, 1, "ISO/IEC 16023:2000 Figure 2 (and L1), same", /* 0*/ { -1, -1, -1, { 0, 0, "" }, "THIS IS A 93 CHARACTER CODE SET A MESSAGE THAT FILLS A MODE 4, UNAPPENDED, MAXICODE SYMBOL...", -1, "", 0, 33, 30, 1, 1, "ISO/IEC 16023:2000 Figure 2 (and L1), same",
"011111010000001000001000100111" "011111010000001000001000100111"
"000100000001000000001010000000" "000100000001000000001010000000"
"001011001100100110110010010010" "001011001100100110110010010010"
@ -400,7 +428,7 @@ static void test_encode(const testCtx *const p_ctx) {
"001001101111101101101010011100" "001001101111101101101010011100"
"001011000000111101100100001000" "001011000000111101100100001000"
}, },
/* 1*/ { -1, 4, -1, { 0, 0, "" }, "MaxiCode (19 chars)", -1, "", 0, 33, 30, 1, "ISO/IEC 16023:2000 Figure H1 **NOT SAME** different encodation (figure uses '3 Shift A' among other differences)", /* 1*/ { -1, 4, -1, { 0, 0, "" }, "MaxiCode (19 chars)", -1, "", 0, 33, 30, 1, 1, "ISO/IEC 16023:2000 Figure H1 **NOT SAME** different encodation (figure uses '3 Shift A' among other differences)",
"000111011111010000001010110111" "000111011111010000001010110111"
"101101010001110001000000110110" "101101010001110001000000110110"
"101110001010111100100111111011" "101110001010111100100111111011"
@ -435,7 +463,7 @@ static void test_encode(const testCtx *const p_ctx) {
"100000101101100000001000111110" "100000101101100000001000111110"
"011101000100000001001111101001" "011101000100000001001111101001"
}, },
/* 2*/ { ESCAPE_MODE, 2, 96 + 1, { 0, 0, "" }, "1Z00004951\\GUPSN\\G06X610\\G159\\G1234567\\G1/1\\G\\GY\\G634 ALPHA DR\\GPITTSBURGH\\GPA\\R\\E", -1, "152382802840001", 0, 33, 30, 1, "ISO/IEC 16023:2000 Figure B2 **NOT SAME** uses different encodation (figure precedes PAD chars with Latch B)", /* 2*/ { ESCAPE_MODE, 2, 96 + 1, { 0, 0, "" }, "1Z00004951\\GUPSN\\G06X610\\G159\\G1234567\\G1/1\\G\\GY\\G634 ALPHA DR\\GPITTSBURGH\\GPA\\R\\E", -1, "152382802840001", 0, 33, 30, 1, 1, "ISO/IEC 16023:2000 Figure B2 **NOT SAME** uses different encodation (figure precedes PAD chars with Latch B)",
"110101110110111110111111101111" "110101110110111110111111101111"
"010101010111000011011000010010" "010101010111000011011000010010"
"110110110001001010100110010001" "110110110001001010100110010001"
@ -470,7 +498,7 @@ static void test_encode(const testCtx *const p_ctx) {
"000111101001100001111000010110" "000111101001100001111000010110"
"000100101000110000000111110011" "000100101000110000000111110011"
}, },
/* 3*/ { ESCAPE_MODE, 2, 96 + 1, { 0, 0, "" }, "1Z00004951\\GUPSN\\G06X610\\G159\\G1234567\\G1/1\\G\\GY\\G634 ALPHA DR\\GPITTSBURGH\\GPA\\R\\E", -1, "15238840001", 0, 33, 30, 1, "OkapiBarcode zero-pad postcode lacking +4 (US 840 only), ISO/IEC 16023:2000 Annex B.1.4a", /* 3*/ { ESCAPE_MODE, 2, 96 + 1, { 0, 0, "" }, "1Z00004951\\GUPSN\\G06X610\\G159\\G1234567\\G1/1\\G\\GY\\G634 ALPHA DR\\GPITTSBURGH\\GPA\\R\\E", -1, "15238840001", 0, 33, 30, 1, 1, "OkapiBarcode zero-pad postcode lacking +4 (US 840 only), ISO/IEC 16023:2000 Annex B.1.4a",
"110101110110111110111111101111" "110101110110111110111111101111"
"010101010111000011011000010010" "010101010111000011011000010010"
"110110110001001010100110010001" "110110110001001010100110010001"
@ -505,7 +533,7 @@ static void test_encode(const testCtx *const p_ctx) {
"000111101001100001111000010110" "000111101001100001111000010110"
"000100101000110000000111110011" "000100101000110000000111110011"
}, },
/* 4*/ { -1, 3, -1, { 0, 0, "" }, "CEN", -1, "B1050056999", 0, 33, 30, 1, "ISO/IEC 16023:2000 B.1 Example (primary only given, data arbitrary); verified manually against tec-it", /* 4*/ { -1, 3, -1, { 0, 0, "" }, "CEN", -1, "B1050056999", 0, 33, 30, 1, 1, "ISO/IEC 16023:2000 B.1 Example (primary only given, data arbitrary); verified manually against tec-it",
"000000010101010101010101010111" "000000010101010101010101010111"
"001011000000000000000000000010" "001011000000000000000000000010"
"111001101010101010101010101000" "111001101010101010101010101000"
@ -540,7 +568,7 @@ static void test_encode(const testCtx *const p_ctx) {
"010010001001110010000101000010" "010010001001110010000101000010"
"010001011010000011010010011100" "010001011010000011010010011100"
}, },
/* 5*/ { UNICODE_MODE | ESCAPE_MODE, -1, -1, { 0, 0, "" }, "Comité Européen de Normalisation\034rue de Stassart 36\034B-1050 BRUXELLES\034TEL +3225196811", -1, "", 0, 33, 30, 1, "ISO/IEC 16023:2000 Example F.5 **NOT SAME** uses different encodation (2 Shift A among other things)", /* 5*/ { UNICODE_MODE | ESCAPE_MODE, -1, -1, { 0, 0, "" }, "Comité Européen de Normalisation\034rue de Stassart 36\034B-1050 BRUXELLES\034TEL +3225196811", -1, "", 0, 33, 30, 1, 1, "ISO/IEC 16023:2000 Example F.5 **NOT SAME** uses different encodation (2 Shift A among other things)",
"110010100010110000000100000111" "110010100010110000000100000111"
"011010001100110110111110101100" "011010001100110110111110101100"
"111010011100101010011100101101" "111010011100101010011100101101"
@ -575,7 +603,7 @@ static void test_encode(const testCtx *const p_ctx) {
"001111010001110000011001100110" "001111010001110000011001100110"
"000100001011101000111010000010" "000100001011101000111010000010"
}, },
/* 6*/ { -1, -1, -1, { 0, 0, "" }, "999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999", -1, "", 0, 33, 30, 1, "Numeric compaction, verified manually against TEC-IT", /* 6*/ { -1, -1, -1, { 0, 0, "" }, "999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999", -1, "", 0, 33, 30, 1, 1, "Numeric compaction, verified manually against TEC-IT",
"101101010111101101010111101111" "101101010111101101010111101111"
"110110111011110110111011110100" "110110111011110110111011110100"
"111101001111111101001111111100" "111101001111111101001111111100"
@ -610,7 +638,7 @@ static void test_encode(const testCtx *const p_ctx) {
"101111000100011110110011011100" "101111000100011110110011011100"
"011111000110100011001101000000" "011111000110100011001101000000"
}, },
/* 7*/ { -1, 5, -1, { 0, 0, "" }, "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\037\237\240\242\243\244\245\246\247\251\255\256\266\225\226\227\230\231\232\233\234\235\236", 51, "", 0, 33, 30, 1, "Mode 5 set E", /* 7*/ { -1, 5, -1, { 0, 0, "" }, "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\037\237\240\242\243\244\245\246\247\251\255\256\266\225\226\227\230\231\232\233\234\235\236", 51, "", 0, 33, 30, 1, 899, "Mode 5 set E",
"000000000000000000101010101011" "000000000000000000101010101011"
"100101010111111111000000001000" "100101010111111111000000001000"
"110010011100100111001001110011" "110010011100100111001001110011"
@ -645,7 +673,7 @@ static void test_encode(const testCtx *const p_ctx) {
"011111011011101100100101001010" "011111011011101100100101001010"
"000011101111000101100100011101" "000011101111000101100100011101"
}, },
/* 8*/ { -1, 6, -1, { 0, 0, "" }, "\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377\241\250\253\257\260\264\267\270\273\277\212\213\214\215\216\217\220\221\222\223\224", -1, "", 0, 33, 30, 1, "Mode 6 set D", /* 8*/ { -1, 6, -1, { 0, 0, "" }, "\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377\241\250\253\257\260\264\267\270\273\277\212\213\214\215\216\217\220\221\222\223\224", -1, "", 0, 33, 30, 1, 899, "Mode 6 set D",
"000000000000000000101010101011" "000000000000000000101010101011"
"100101010111111111000000001010" "100101010111111111000000001010"
"110010011100100111001001110001" "110010011100100111001001110001"
@ -680,7 +708,7 @@ static void test_encode(const testCtx *const p_ctx) {
"011111001010000101000011000110" "011111001010000101000011000110"
"101111010010011100100011110010" "101111010010011100100011110010"
}, },
/* 9*/ { -1, 6, -1, { 0, 0, "" }, "\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\252\254\261\262\263\265\271\272\274\275\276\200\201\202\203\204\205\206\207\210\211", -1, "", 0, 33, 30, 1, "Mode 6 set C", /* 9*/ { -1, 6, -1, { 0, 0, "" }, "\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\252\254\261\262\263\265\271\272\274\275\276\200\201\202\203\204\205\206\207\210\211", -1, "", 0, 33, 30, 1, 899, "Mode 6 set C",
"000000000000000000101010101011" "000000000000000000101010101011"
"100101010111111111000000001010" "100101010111111111000000001010"
"110010011100100111001001110001" "110010011100100111001001110001"
@ -715,7 +743,7 @@ static void test_encode(const testCtx *const p_ctx) {
"011111001010000101000011000110" "011111001010000101000011000110"
"101111010010011100100011110010" "101111010010011100100011110010"
}, },
/* 10*/ { UNICODE_MODE | ESCAPE_MODE, 4, -1, { 0, 0, "" }, "`abcdefghijklmnopqrstuvwxyz\034\\G\\R{}~\177;<=>?[\\\\]^_ ,./:@!|", -1, "", 0, 33, 30, 1, "Mode 4 Set B", /* 10*/ { UNICODE_MODE | ESCAPE_MODE, 4, -1, { 0, 0, "" }, "`abcdefghijklmnopqrstuvwxyz\034\\G\\R{}~\177;<=>?[\\\\]^_ ,./:@!|", -1, "", 0, 33, 30, 1, 1, "Mode 4 Set B",
"000000000000000010101010101011" "000000000000000010101010101011"
"010101011111111100000000101010" "010101011111111100000000101010"
"001001110010011100100111001000" "001001110010011100100111001000"
@ -750,7 +778,7 @@ static void test_encode(const testCtx *const p_ctx) {
"100100110011010101001011100100" "100100110011010101001011100100"
"001000101111010000111000010101" "001000101111010000111000010101"
}, },
/* 11*/ { UNICODE_MODE | ESCAPE_MODE, 4, -1, { 0, 0, "" }, "\\rABCDEFGHIJKLMNOPQRSTUVWXYZ\034\\G\\R \"#$%&'()*+,-./0123456789:", -1, "", 0, 33, 30, 1, "Mode 4 Set A", /* 11*/ { UNICODE_MODE | ESCAPE_MODE, 4, -1, { 0, 0, "" }, "\\rABCDEFGHIJKLMNOPQRSTUVWXYZ\034\\G\\R \"#$%&'()*+,-./0123456789:", -1, "", 0, 33, 30, 1, 1, "Mode 4 Set A",
"000000000000001010101010101011" "000000000000001010101010101011"
"010101111111110000000010101010" "010101111111110000000010101010"
"100111001001110010011100100101" "100111001001110010011100100101"
@ -785,7 +813,7 @@ static void test_encode(const testCtx *const p_ctx) {
"010010011001101010010001111100" "010010011001101010010001111100"
"100111100111001110011000011011" "100111100111001110011000011011"
}, },
/* 12*/ { UNICODE_MODE, 4, -1, { 0, 0, "" }, "ABCDabcdAabcABabcABCabcABCDaABCabABCabcABCéa", -1, "", 0, 33, 30, 1, "Mode 4 LCHB SHA 2SHA 3SHA LCHA SHB LCHB 3SHA 3SHA SHD", /* 12*/ { UNICODE_MODE, 4, -1, { 0, 0, "" }, "ABCDabcdAabcABabcABCabcABCDaABCabABCabcABCéa", -1, "", 0, 33, 30, 1, 1, "Mode 4 LCHB SHA 2SHA 3SHA LCHA SHB LCHB 3SHA 3SHA SHD",
"110000000011000000000011000011" "110000000011000000000011000011"
"010000000001000000000001000000" "010000000001000000000001000000"
"111010011100100110011110100101" "111010011100100110011110100101"
@ -820,7 +848,7 @@ static void test_encode(const testCtx *const p_ctx) {
"110001000010011110111101111000" "110001000010011110111101111000"
"011010011011111110001000000010" "011010011011111110001000000010"
}, },
/* 13*/ { UNICODE_MODE, 4, -1, { 0, 0, "" }, "ÀÁÂÃ1", -1, "", 0, 33, 30, 1, "Mode 4 LCKC LCHA", /* 13*/ { UNICODE_MODE, 4, -1, { 0, 0, "" }, "ÀÁÂÃ1", -1, "", 0, 33, 30, 1, 1, "Mode 4 LCKC LCHA",
"010101010101010101010101010111" "010101010101010101010101010111"
"000000000000000000000000000000" "000000000000000000000000000000"
"101010101010101010101010101010" "101010101010101010101010101010"
@ -855,7 +883,7 @@ static void test_encode(const testCtx *const p_ctx) {
"010110101111010110101010111100" "010110101111010110101010111100"
"010100000000010110101010010100" "010100000000010110101010010100"
}, },
/* 14*/ { UNICODE_MODE, 4, -1, { 0, 0, "" }, "ÀÁÂÃ123456789", -1, "", 0, 33, 30, 1, "Mode 4 LCKC NS", /* 14*/ { UNICODE_MODE, 4, -1, { 0, 0, "" }, "ÀÁÂÃ123456789", -1, "", 0, 33, 30, 1, 1, "Mode 4 LCKC NS",
"111110110101010101010101010111" "111110110101010101010101010111"
"111010010000000000000000000000" "111010010000000000000000000000"
"000010011010101010101010101000" "000010011010101010101010101000"
@ -890,7 +918,7 @@ static void test_encode(const testCtx *const p_ctx) {
"000000111100011110100001110000" "000000111100011110100001110000"
"101000000010100111001011110101" "101000000010100111001011110101"
}, },
/* 15*/ { UNICODE_MODE, 4, -1, { 0, 0, "" }, "àáâã1", -1, "", 0, 33, 30, 1, "Mode 4 LCKD LCHA", /* 15*/ { UNICODE_MODE, 4, -1, { 0, 0, "" }, "àáâã1", -1, "", 0, 33, 30, 1, 1, "Mode 4 LCKD LCHA",
"010101010101010101010101010111" "010101010101010101010101010111"
"000000000000000000000000000000" "000000000000000000000000000000"
"101010101010101010101010101010" "101010101010101010101010101010"
@ -925,7 +953,7 @@ static void test_encode(const testCtx *const p_ctx) {
"010110101111010110101010111100" "010110101111010110101010111100"
"010100000000010110101010010100" "010100000000010110101010010100"
}, },
/* 16*/ { UNICODE_MODE, 4, -1, { 0, 0, "" }, "¢£¤¥1", -1, "", 0, 33, 30, 1, "Mode 4 LCKE LCHA", /* 16*/ { UNICODE_MODE, 4, -1, { 0, 0, "" }, "¢£¤¥1", -1, "", 0, 33, 30, 1, 1, "Mode 4 LCKE LCHA",
"010101010101010101010101010111" "010101010101010101010101010111"
"000000000000000000000000000000" "000000000000000000000000000000"
"101010101010101010101010101010" "101010101010101010101010101010"
@ -960,7 +988,7 @@ static void test_encode(const testCtx *const p_ctx) {
"010110101111010110101010111100" "010110101111010110101010111100"
"010100000000010110101010010100" "010100000000010110101010010100"
}, },
/* 17*/ { UNICODE_MODE, 4, -1, { 0, 0, "" }, "¢£¤¥123456789", -1, "", 0, 33, 30, 1, "Mode 4 LCKE NS", /* 17*/ { UNICODE_MODE, 4, -1, { 0, 0, "" }, "¢£¤¥123456789", -1, "", 0, 33, 30, 1, 1, "Mode 4 LCKE NS",
"111110101010101010101010101011" "111110101010101010101010101011"
"111010111111111111111111111100" "111010111111111111111111111100"
"000010000000000000000000000011" "000010000000000000000000000011"
@ -995,7 +1023,7 @@ static void test_encode(const testCtx *const p_ctx) {
"011100101001010011011100111100" "011100101001010011011100111100"
"101101110111011101011010011101" "101101110111011101011010011101"
}, },
/* 18*/ { UNICODE_MODE, 4, -1, { 0, 0, "" }, "ABCDE12abcde1ÀÁÂ⣤¥1àáâãabcde123A123456789àáâ㢣¤¥abc", -1, "", 0, 33, 30, 1, "Mode 4 mixed sets", /* 18*/ { UNICODE_MODE, 4, -1, { 0, 0, "" }, "ABCDE12abcde1ÀÁÂ⣤¥1àáâãabcde123A123456789àáâ㢣¤¥abc", -1, "", 0, 33, 30, 1, 1, "Mode 4 mixed sets",
"000000001111111100000000111111" "000000001111111100000000111111"
"000010101100111100000000111100" "000010101100111100000000111100"
"011100101110000000100111010111" "011100101110000000100111010111"
@ -1030,7 +1058,7 @@ static void test_encode(const testCtx *const p_ctx) {
"100010001001110010101010111000" "100010001001110010101010111000"
"111010110110001100101000010001" "111010110110001100101000010001"
}, },
/* 19*/ { UNICODE_MODE, 4, -1, { 0, 0, "" }, "A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789MNO123456789", -1, "", 0, 33, 30, 1, "Mode 4 spaced NSs", /* 19*/ { UNICODE_MODE, 4, -1, { 0, 0, "" }, "A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789MNO123456789", -1, "", 0, 33, 30, 1, 1, "Mode 4 spaced NSs",
"001011111000100010111110001011" "001011111000100010111110001011"
"101011101000111010111010101100" "101011101000111010111010101100"
"110100001011111101000010001101" "110100001011111101000010001101"
@ -1065,7 +1093,7 @@ static void test_encode(const testCtx *const p_ctx) {
"011101000011011001001111111000" "011101000011011001001111111000"
"111010010011100000100100111111" "111010010011100000100100111111"
}, },
/* 20*/ { UNICODE_MODE, 4, -1, { 3, 7, "" }, "THIS IS A 91 CHARACTER CODE SET A MESSAGE THAT FILLS A MODE 4, APPENDED, MAXICODE SYMBOL...", -1, "", 0, 33, 30, 1, "Mode 4 Structured Append", /* 20*/ { UNICODE_MODE, 4, -1, { 3, 7, "" }, "THIS IS A 91 CHARACTER CODE SET A MESSAGE THAT FILLS A MODE 4, APPENDED, MAXICODE SYMBOL...", -1, "", 0, 33, 30, 1, 1, "Mode 4 Structured Append",
"010001111101000000100000100011" "010001111101000000100000100011"
"000000010000000100000000101000" "000000010000000100000000101000"
"001000101000110010011011001000" "001000101000110010011011001000"
@ -1100,7 +1128,7 @@ static void test_encode(const testCtx *const p_ctx) {
"010101011101100110111011100100" "010101011101100110111011100100"
"011001000011110011011110111010" "011001000011110011011110111010"
}, },
/* 21*/ { UNICODE_MODE, 3, -1, { 1, 8, "" }, "COMMISSION FOR EUROPEAN NORMALIZATION, RUE DE STASSART 36, B-1050 BRUXELLES", -1, "B1050056999", 0, 33, 30, 1, "Mode 3 Structured Append", /* 21*/ { UNICODE_MODE, 3, -1, { 1, 8, "" }, "COMMISSION FOR EUROPEAN NORMALIZATION, RUE DE STASSART 36, B-1050 BRUXELLES", -1, "B1050056999", 0, 33, 30, 1, 1, "Mode 3 Structured Append",
"010000000000001010000000010011" "010000000000001010000000010011"
"001000111111010000011111001000" "001000111111010000011111001000"
"101111111010101111101101000101" "101111111010101111101101000101"
@ -1135,7 +1163,7 @@ static void test_encode(const testCtx *const p_ctx) {
"011111110000111010001010001100" "011111110000111010001010001100"
"110010001001001011011111100111" "110010001001001011011111100111"
}, },
/* 22*/ { UNICODE_MODE, -1, -1, { 0, 0, "" }, "am.//ab,\034TA# z\015!", -1, "", 0, 33, 30, 1, "Was test_best_supported_set", /* 22*/ { UNICODE_MODE, -1, -1, { 0, 0, "" }, "am.//ab,\034TA# z\015!", -1, "", 0, 33, 30, 1, 1, "Was test_best_supported_set",
"101110000101101100110101010111" "101110000101101100110101010111"
"110110000011010100100000000010" "110110000011010100100000000010"
"001000101111011100101010101010" "001000101111011100101010101010"
@ -1179,10 +1207,11 @@ static void test_encode(const testCtx *const p_ctx) {
char cmp_buf[8192]; char cmp_buf[8192];
char cmp_msg[1024]; char cmp_msg[1024];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ /* Only do BWIPP/ZXing-C++ tests if asked, too slow otherwise */
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript();
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder();
testStartSymbol("test_encode", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -1201,11 +1230,12 @@ static void test_encode(const testCtx *const p_ctx) {
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) { if (p_ctx->generate) {
printf(" /*%3d*/ { %s, %d, %d, { %d, %d, \"%s\" }, \"%s\", %d, \"%s\", %s, %d, %d, %d, \"%s\",\n", printf(" /*%3d*/ { %s, %d, %d, { %d, %d, \"%s\" }, \"%s\", %d, \"%s\", %s, %d, %d, %d, %d, \"%s\",\n",
i, testUtilInputModeName(data[i].input_mode), data[i].option_1, data[i].option_2, i, testUtilInputModeName(data[i].input_mode), data[i].option_1, data[i].option_2,
data[i].structapp.index, data[i].structapp.count, data[i].structapp.id, data[i].structapp.index, data[i].structapp.count, data[i].structapp.id,
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length,
data[i].primary, testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].comment); data[i].primary, testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp,
data[i].zxingcpp_cmp, data[i].comment);
testUtilModulesPrint(symbol, " ", "\n"); testUtilModulesPrint(symbol, " ", "\n");
printf(" },\n"); printf(" },\n");
} else { } else {
@ -1233,13 +1263,19 @@ static void test_encode(const testCtx *const p_ctx) {
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) { if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) {
int cmp_len, ret_len; int cmp_len, ret_len;
char modules_dump[17984 + 1]; char modules_dump[17984 + 1];
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1,
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); "i:%d testUtilModulesDump == -1\n", i);
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); assert_nonzero(data[i].zxingcpp_cmp, "i:%d data[i].zxingcpp_cmp == 0", i);
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, data[i].zxingcpp_cmp,
cmp_buf, sizeof(cmp_buf), &cmp_len);
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n",
i, testUtilBarcodeName(symbol->symbology), ret);
ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, data[i].primary, escaped, &ret_len); ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length,
data[i].primary, escaped, &ret_len);
assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n",
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, escaped); i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len,
escaped);
} }
} }
} }
@ -1768,10 +1804,11 @@ static void test_encode_segs(const testCtx *const p_ctx) {
char cmp_buf[8192]; char cmp_buf[8192];
char cmp_msg[1024]; char cmp_msg[1024];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ /* Only do BWIPP/ZXing-C++ tests if asked, too slow otherwise */
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript();
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder();
testStartSymbol("test_encode_segs", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -1800,52 +1837,69 @@ static void test_encode_segs(const testCtx *const p_ctx) {
printf(" /*%3d*/ { %s, %d, %d, { %d, %d, \"%s\" }, { { TU(\"%s\"), %d, %d }, { TU(\"%s\"), %d, %d }, { TU(\"%s\"), %d, %d } }, \"%s\", %s, %d, %d, %d, \"%s\",\n", printf(" /*%3d*/ { %s, %d, %d, { %d, %d, \"%s\" }, { { TU(\"%s\"), %d, %d }, { TU(\"%s\"), %d, %d }, { TU(\"%s\"), %d, %d } }, \"%s\", %s, %d, %d, %d, \"%s\",\n",
i, testUtilInputModeName(data[i].input_mode), data[i].option_1, data[i].option_2, i, testUtilInputModeName(data[i].input_mode), data[i].option_1, data[i].option_2,
data[i].structapp.index, data[i].structapp.count, data[i].structapp.id, data[i].structapp.index, data[i].structapp.count, data[i].structapp.id,
testUtilEscape((const char *) data[i].segs[0].source, length, escaped, sizeof(escaped)), data[i].segs[0].length, data[i].segs[0].eci, testUtilEscape((const char *) data[i].segs[0].source, length, escaped, sizeof(escaped)),
testUtilEscape((const char *) data[i].segs[1].source, length1, escaped1, sizeof(escaped1)), data[i].segs[1].length, data[i].segs[1].eci, data[i].segs[0].length, data[i].segs[0].eci,
testUtilEscape((const char *) data[i].segs[2].source, length2, escaped2, sizeof(escaped2)), data[i].segs[2].length, data[i].segs[2].eci, testUtilEscape((const char *) data[i].segs[1].source, length1, escaped1, sizeof(escaped1)),
data[i].primary, testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].comment); data[i].segs[1].length, data[i].segs[1].eci,
testUtilEscape((const char *) data[i].segs[2].source, length2, escaped2, sizeof(escaped2)),
data[i].segs[2].length, data[i].segs[2].eci,
data[i].primary, testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp,
data[i].comment);
testUtilModulesPrint(symbol, " ", "\n"); testUtilModulesPrint(symbol, " ", "\n");
printf(" },\n"); printf(" },\n");
} else { } else {
if (ret < ZINT_ERROR) { if (ret < ZINT_ERROR) {
int width, row; int width, row;
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows); assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n",
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); i, symbol->rows, data[i].expected_rows);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n",
i, symbol->width, data[i].expected_width);
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row); ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d\n", i, ret, width, row); assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d\n", i, ret, width, row);
if (do_bwipp && testUtilCanBwipp(i, symbol, data[i].option_1, data[i].option_2, -1, debug)) { if (do_bwipp && testUtilCanBwipp(i, symbol, data[i].option_1, data[i].option_2, -1, debug)) {
if (!data[i].bwipp_cmp) { if (!data[i].bwipp_cmp) {
if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d %s not BWIPP compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), data[i].comment); if (debug & ZINT_DEBUG_TEST_PRINT) {
printf("i:%d %s not BWIPP compatible (%s)\n",
i, testUtilBarcodeName(symbol->symbology), data[i].comment);
}
} else { } else {
ret = testUtilBwippSegs(i, symbol, data[i].option_1, data[i].option_2, -1, data[i].segs, seg_count, data[i].primary, cmp_buf, sizeof(cmp_buf)); ret = testUtilBwippSegs(i, symbol, data[i].option_1, data[i].option_2, -1, data[i].segs,
assert_zero(ret, "i:%d %s testUtilBwippSegs ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); seg_count, data[i].primary, cmp_buf, sizeof(cmp_buf));
assert_zero(ret, "i:%d %s testUtilBwippSegs ret %d != 0\n",
i, testUtilBarcodeName(symbol->symbology), ret);
ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, data[i].expected); ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, data[i].expected);
assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n", assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n",
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, data[i].expected); i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf,
data[i].expected);
} }
} }
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, (const char *) data[i].segs[0].source, data[i].segs[0].length, debug)) { if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, (const char *) data[i].segs[0].source,
data[i].segs[0].length, debug)) {
if (data[i].input_mode == DATA_MODE) { if (data[i].input_mode == DATA_MODE) {
if (debug & ZINT_DEBUG_TEST_PRINT) { if (debug & ZINT_DEBUG_TEST_PRINT) {
printf("i:%d multiple segments in DATA_MODE not currently supported for ZXing-C++ testing (%s)\n", printf("i:%d %s multiple segments in DATA_MODE not currently supported for ZXing-C++ testing\n",
i, testUtilBarcodeName(symbol->symbology)); i, testUtilBarcodeName(symbol->symbology));
} }
} else { } else {
int cmp_len, ret_len; int cmp_len, ret_len;
char modules_dump[17984 + 1]; char modules_dump[17984 + 1];
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1,
ret = testUtilZXingCPP(i, symbol, (const char *) data[i].segs[0].source, data[i].segs[0].length, "i:%d testUtilModulesDump == -1\n", i);
modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); ret = testUtilZXingCPP(i, symbol, (const char *) data[i].segs[0].source,
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); data[i].segs[0].length, modules_dump, 1 /*zxingcpp_cmp*/, cmp_buf,
sizeof(cmp_buf), &cmp_len);
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n",
i, testUtilBarcodeName(symbol->symbology), ret);
ret = testUtilZXingCPPCmpSegs(symbol, cmp_msg, cmp_buf, cmp_len, data[i].segs, seg_count, ret = testUtilZXingCPPCmpSegs(symbol, cmp_msg, cmp_buf, cmp_len, data[i].segs, seg_count,
data[i].primary, escaped, &ret_len); data[i].primary, escaped, &ret_len);
assert_zero(ret, "i:%d %s testUtilZXingCPPCmpSegs %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", assert_zero(ret, "i:%d %s testUtilZXingCPPCmpSegs %d != 0 %s\n actual: %.*s\nexpected: %.*s\n",
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, escaped); i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf,
ret_len, escaped);
} }
} }
} }
@ -1857,6 +1911,178 @@ static void test_encode_segs(const testCtx *const p_ctx) {
testFinish(); testFinish();
} }
static void test_rt(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
int input_mode;
int eci;
int output_options;
const char *data;
int length;
int ret;
int expected_eci;
const char *expected;
int expected_length;
int expected_raw_eci;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, -1, "é", -1, 0, 0, "", -1, 0 },
/* 1*/ { UNICODE_MODE, -1, BARCODE_RAW_TEXT, "é", -1, 0, 0, "\351", -1, 3 },
/* 2*/ { UNICODE_MODE, -1, -1, "", -1, ZINT_WARN_USES_ECI, 13, "", -1, 0 },
/* 3*/ { UNICODE_MODE, -1, BARCODE_RAW_TEXT, "", -1, ZINT_WARN_USES_ECI, 13, "\241", -1, 13 },
/* 4*/ { DATA_MODE, -1, -1, "\351", -1, 0, 0, "", -1, 0 },
/* 5*/ { DATA_MODE, -1, BARCODE_RAW_TEXT, "\351", -1, 0, 0, "\351", -1, 3 },
/* 6*/ { UNICODE_MODE, 26, -1, "é", -1, 0, 26, "", -1, 0 },
/* 7*/ { UNICODE_MODE, 26, BARCODE_RAW_TEXT, "é", -1, 0, 26, "é", -1, 26 },
/* 8*/ { UNICODE_MODE, 899, -1, "é", -1, 0, 899, "", -1, 0 },
/* 9*/ { UNICODE_MODE, 899, BARCODE_RAW_TEXT, "é", -1, 0, 899, "é", -1, 899 },
};
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
int expected_length;
char escaped[4096];
char escaped2[4096];
testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) {
if (testContinue(p_ctx, i)) continue;
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
length = testUtilSetSymbol(symbol, BARCODE_MAXICODE, data[i].input_mode, data[i].eci,
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options,
data[i].data, data[i].length, debug);
expected_length = data[i].expected_length == -1 ? (int) strlen(data[i].expected) : data[i].expected_length;
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n",
i, ret, data[i].ret, symbol->errtxt);
if (ret < ZINT_ERROR) {
assert_equal(symbol->eci, data[i].expected_eci, "i:%d eci %d != %d\n",
i, symbol->eci, data[i].expected_eci);
if (symbol->output_options & BARCODE_RAW_TEXT) {
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
assert_nonnull(symbol->raw_segs[0].source, "i:%d raw_segs[0].source NULL\n", i);
assert_equal(symbol->raw_segs[0].length, expected_length,
"i:%d raw_segs[0].length %d != expected_length %d\n",
i, symbol->raw_segs[0].length, expected_length);
assert_zero(memcmp(symbol->raw_segs[0].source, data[i].expected, expected_length),
"i:%d raw_segs[0].source memcmp(%s, %s, %d) != 0\n", i,
testUtilEscape((const char *) symbol->raw_segs[0].source, symbol->raw_segs[0].length,
escaped, sizeof(escaped)),
testUtilEscape(data[i].expected, expected_length, escaped2, sizeof(escaped2)),
expected_length);
assert_equal(symbol->raw_segs[0].eci, data[i].expected_raw_eci,
"i:%d raw_segs[0].eci %d != expected_raw_eci %d\n",
i, symbol->raw_segs[0].eci, data[i].expected_raw_eci);
} else {
assert_null(symbol->raw_segs, "i:%d raw_segs not NULL\n", i);
}
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_rt_segs(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
int input_mode;
int output_options;
struct zint_seg segs[3];
int ret;
int expected_rows;
int expected_width;
struct zint_seg expected_raw_segs[3];
int expected_raw_seg_count;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, { { TU(""), -1, 0 }, { TU("Ж"), -1, 7 }, {0} }, 0, 33, 30, {{0}}, 0 },
/* 1*/ { UNICODE_MODE, BARCODE_RAW_TEXT, { { TU(""), -1, 0 }, { TU("Ж"), -1, 7 }, { TU(""), 0, 0 } }, 0, 33, 30, { { TU("\266"), 1, 3 }, { TU("\266"), 1, 7 }, {0} }, 2 },
/* 2*/ { UNICODE_MODE, -1, { { TU("éé"), -1, 0 }, { TU("กขฯ"), -1, 0 }, { TU("βββ"), -1, 0 } }, ZINT_WARN_USES_ECI, 33, 30, {{0}}, 0 },
/* 3*/ { UNICODE_MODE, BARCODE_RAW_TEXT, { { TU("éé"), -1, 0 }, { TU("กขฯ"), -1, 0 }, { TU("βββ"), -1, 0 } }, ZINT_WARN_USES_ECI, 33, 30, { { TU("\351\351"), 2, 3 }, { TU("\241\242\317"), 3, 13 }, { TU("\342\342\342"), 3, 9 } }, 3 },
/* 4*/ { DATA_MODE, -1, { { TU(""), -1, 26 }, { TU("Ж"), -1, 0 }, { TU("\223\137"), -1, 20 } }, 0, 33, 30, {{0}}, 0 },
/* 5*/ { DATA_MODE, BARCODE_RAW_TEXT, { { TU(""), -1, 26 }, { TU("Ж"), -1, 0 }, { TU("\223\137"), -1, 20 } }, 0, 33, 30, { { TU(""), 2, 26 }, { TU("\320\226"), 2, 3 }, { TU("\223\137"), 2, 20 } }, 3 },
};
const int data_size = ARRAY_SIZE(data);
int i, j, seg_count, ret;
struct zint_symbol *symbol = NULL;
int expected_length;
char escaped[4096];
char escaped2[4096];
testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) {
if (testContinue(p_ctx, i)) continue;
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
testUtilSetSymbol(symbol, BARCODE_MAXICODE, data[i].input_mode, -1 /*eci*/,
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options,
NULL, 0, debug);
for (j = 0, seg_count = 0; j < 3 && data[i].segs[j].length; j++, seg_count++);
ret = ZBarcode_Encode_Segs(symbol, data[i].segs, seg_count);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode_Segs ret %d != %d (%s)\n",
i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (width %d)\n",
i, symbol->rows, data[i].expected_rows, symbol->width);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n",
i, symbol->width, data[i].expected_width);
assert_equal(symbol->raw_seg_count, data[i].expected_raw_seg_count, "i:%d symbol->raw_seg_count %d != %d\n",
i, symbol->raw_seg_count, data[i].expected_raw_seg_count);
if (symbol->output_options & BARCODE_RAW_TEXT) {
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
for (j = 0; j < symbol->raw_seg_count; j++) {
assert_nonnull(symbol->raw_segs[j].source, "i:%d raw_segs[%d].source NULL\n", i, j);
expected_length = data[i].expected_raw_segs[j].length;
assert_equal(symbol->raw_segs[j].length, expected_length,
"i:%d raw_segs[%d].length %d != expected_length %d\n",
i, j, symbol->raw_segs[j].length, expected_length);
assert_zero(memcmp(symbol->raw_segs[j].source, data[i].expected_raw_segs[j].source, expected_length),
"i:%d raw_segs[%d].source memcmp(%s, %s, %d) != 0\n", i, j,
testUtilEscape((const char *) symbol->raw_segs[j].source, expected_length, escaped,
sizeof(escaped)),
testUtilEscape((const char *) data[i].expected_raw_segs[j].source, expected_length,
escaped2, sizeof(escaped2)),
expected_length);
assert_equal(symbol->raw_segs[j].eci, data[i].expected_raw_segs[j].eci,
"i:%d raw_segs[%d].eci %d != expected_raw_segs.eci %d\n",
i, j, symbol->raw_segs[j].eci, data[i].expected_raw_segs[j].eci);
}
} else {
assert_null(symbol->raw_segs, "i:%d raw_segs not NULL\n", i);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
/* #181 Nico Gunkel OSS-Fuzz */ /* #181 Nico Gunkel OSS-Fuzz */
static void test_fuzz(const testCtx *const p_ctx) { static void test_fuzz(const testCtx *const p_ctx) {
int debug = p_ctx->debug; int debug = p_ctx->debug;
@ -1880,7 +2106,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_fuzz", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -2009,6 +2235,8 @@ int main(int argc, char *argv[]) {
{ "test_input", test_input }, { "test_input", test_input },
{ "test_encode", test_encode }, { "test_encode", test_encode },
{ "test_encode_segs", test_encode_segs }, { "test_encode_segs", test_encode_segs },
{ "test_rt", test_rt },
{ "test_rt_segs", test_rt_segs },
{ "test_fuzz", test_fuzz }, { "test_fuzz", test_fuzz },
{ "test_perf", test_perf }, { "test_perf", test_perf },
}; };

View file

@ -63,7 +63,7 @@ static void test_large(const testCtx *const p_ctx) {
char data_buf[128]; char data_buf[128];
testStartSymbol("test_large", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -103,46 +103,47 @@ static void test_hrt(const testCtx *const p_ctx) {
const char *data; const char *data;
const char *expected; const char *expected;
const char *expected_raw;
}; };
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = { static const struct item data[] = {
/* 0*/ { BARCODE_PHARMA, -1, -1, "123456", "" }, /* None */ /* 0*/ { BARCODE_PHARMA, -1, -1, "123456", "", "" }, /* None */
/* 1*/ { BARCODE_PHARMA, -1, BARCODE_RAW_TEXT, "123456", "123456" }, /* 1*/ { BARCODE_PHARMA, -1, BARCODE_RAW_TEXT, "123456", "", "123456" },
/* 2*/ { BARCODE_PHARMA_TWO, -1, -1, "123456", "" }, /* None */ /* 2*/ { BARCODE_PHARMA_TWO, -1, -1, "123456", "", "" }, /* None */
/* 3*/ { BARCODE_PHARMA_TWO, -1, BARCODE_RAW_TEXT, "123456", "123456" }, /* 3*/ { BARCODE_PHARMA_TWO, -1, BARCODE_RAW_TEXT, "123456", "", "123456" },
/* 4*/ { BARCODE_CODE32, -1, -1, "123456", "A001234564" }, /* 4*/ { BARCODE_CODE32, -1, -1, "123456", "A001234564", "" },
/* 5*/ { BARCODE_CODE32, -1, BARCODE_RAW_TEXT, "123456", "015PN4" }, /* Actual encoded CODE39 value */ /* 5*/ { BARCODE_CODE32, -1, BARCODE_RAW_TEXT, "123456", "A001234564", "015PN4" }, /* Actual encoded CODE39 value */
/* 6*/ { BARCODE_CODE32, -1, -1, "12345678", "A123456788" }, /* 6*/ { BARCODE_CODE32, -1, -1, "12345678", "A123456788", "" },
/* 7*/ { BARCODE_CODE32, -1, BARCODE_RAW_TEXT, "12345678", "3PRM8N" }, /* 7*/ { BARCODE_CODE32, -1, BARCODE_RAW_TEXT, "12345678", "A123456788", "3PRM8N" },
/* 8*/ { BARCODE_CODE32, 1, -1, "12345678", "A123456788" }, /* Ignore option_2 re check digits */ /* 8*/ { BARCODE_CODE32, 1, -1, "12345678", "A123456788", "" }, /* Ignore option_2 re check digits */
/* 9*/ { BARCODE_CODE32, 1, BARCODE_RAW_TEXT, "12345678", "3PRM8N" }, /* 9*/ { BARCODE_CODE32, 1, BARCODE_RAW_TEXT, "12345678", "A123456788", "3PRM8N" },
/* 10*/ { BARCODE_CODE32, 2, -1, "12345678", "A123456788" }, /* Ignore option_2 re check digits */ /* 10*/ { BARCODE_CODE32, 2, -1, "12345678", "A123456788", "" }, /* Ignore option_2 re check digits */
/* 11*/ { BARCODE_CODE32, 2, BARCODE_RAW_TEXT, "12345678", "3PRM8N" }, /* 11*/ { BARCODE_CODE32, 2, BARCODE_RAW_TEXT, "12345678", "A123456788", "3PRM8N" },
/* 12*/ { BARCODE_PZN, -1, -1, "12345", "PZN - 00123458" }, /* Pads with zeroes if length < 7 */ /* 12*/ { BARCODE_PZN, -1, -1, "12345", "PZN - 00123458", "" }, /* Pads with zeroes if length < 7 */
/* 13*/ { BARCODE_PZN, -1, BARCODE_RAW_TEXT, "12345", "-00123458" }, /* Actual encoded CODE39 value */ /* 13*/ { BARCODE_PZN, -1, BARCODE_RAW_TEXT, "12345", "PZN - 00123458", "-00123458" }, /* Actual encoded CODE39 value */
/* 14*/ { BARCODE_PZN, -1, -1, "123456", "PZN - 01234562" }, /* 14*/ { BARCODE_PZN, -1, -1, "123456", "PZN - 01234562", "" },
/* 15*/ { BARCODE_PZN, -1, BARCODE_RAW_TEXT, "123456", "-01234562" }, /* 15*/ { BARCODE_PZN, -1, BARCODE_RAW_TEXT, "123456", "PZN - 01234562", "-01234562" },
/* 16*/ { BARCODE_PZN, -1, -1, "1234567", "PZN - 12345678" }, /* 16*/ { BARCODE_PZN, -1, -1, "1234567", "PZN - 12345678", "" },
/* 17*/ { BARCODE_PZN, -1, BARCODE_RAW_TEXT, "1234567", "-12345678" }, /* 17*/ { BARCODE_PZN, -1, BARCODE_RAW_TEXT, "1234567", "PZN - 12345678", "-12345678" },
/* 18*/ { BARCODE_PZN, -1, -1, "12345678", "PZN - 12345678" }, /* 18*/ { BARCODE_PZN, -1, -1, "12345678", "PZN - 12345678", "" },
/* 19*/ { BARCODE_PZN, -1, BARCODE_RAW_TEXT, "12345678", "-12345678" }, /* 19*/ { BARCODE_PZN, -1, BARCODE_RAW_TEXT, "12345678", "PZN - 12345678", "-12345678" },
/* 20*/ { BARCODE_PZN, 1, -1, "1234", "PZN - 0012345" }, /* PZN7, pads with zeroes if length < 6 */ /* 20*/ { BARCODE_PZN, 1, -1, "1234", "PZN - 0012345", "" }, /* PZN7, pads with zeroes if length < 6 */
/* 21*/ { BARCODE_PZN, 1, BARCODE_RAW_TEXT, "1234", "-0012345" }, /* 21*/ { BARCODE_PZN, 1, BARCODE_RAW_TEXT, "1234", "PZN - 0012345", "-0012345" },
/* 22*/ { BARCODE_PZN, 1, -1, "12345", "PZN - 0123458" }, /* 22*/ { BARCODE_PZN, 1, -1, "12345", "PZN - 0123458", "" },
/* 23*/ { BARCODE_PZN, 1, BARCODE_RAW_TEXT, "12345", "-0123458" }, /* 23*/ { BARCODE_PZN, 1, BARCODE_RAW_TEXT, "12345", "PZN - 0123458", "-0123458" },
/* 24*/ { BARCODE_PZN, 1, -1, "123456", "PZN - 1234562" }, /* 24*/ { BARCODE_PZN, 1, -1, "123456", "PZN - 1234562", "" },
/* 25*/ { BARCODE_PZN, 1, BARCODE_RAW_TEXT, "123456", "-1234562" }, /* 25*/ { BARCODE_PZN, 1, BARCODE_RAW_TEXT, "123456", "PZN - 1234562", "-1234562" },
/* 26*/ { BARCODE_PZN, 1, -1, "1234562", "PZN - 1234562" }, /* 26*/ { BARCODE_PZN, 1, -1, "1234562", "PZN - 1234562", "" },
/* 27*/ { BARCODE_PZN, 1, BARCODE_RAW_TEXT, "1234562", "-1234562" }, /* 27*/ { BARCODE_PZN, 1, BARCODE_RAW_TEXT, "1234562", "PZN - 1234562", "-1234562" },
/* 28*/ { BARCODE_PZN, 2, -1, "12345", "PZN - 00123458" }, /* Ignore option_2 re check digits */ /* 28*/ { BARCODE_PZN, 2, -1, "12345", "PZN - 00123458", "" }, /* Ignore option_2 re check digits */
/* 29*/ { BARCODE_PZN, 2, BARCODE_RAW_TEXT, "12345", "-00123458" }, /* 29*/ { BARCODE_PZN, 2, BARCODE_RAW_TEXT, "12345", "PZN - 00123458", "-00123458" },
}; };
const int data_size = ARRAY_SIZE(data); const int data_size = ARRAY_SIZE(data);
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
int expected_length; int expected_length, expected_raw_length;
testStartSymbol("test_hrt", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -155,6 +156,7 @@ static void test_hrt(const testCtx *const p_ctx) {
-1 /*option_1*/, data[i].option_2, -1 /*option_3*/, data[i].output_options, -1 /*option_1*/, data[i].option_2, -1 /*option_3*/, data[i].output_options,
data[i].data, -1, debug); data[i].data, -1, debug);
expected_length = (int) strlen(data[i].expected); expected_length = (int) strlen(data[i].expected);
expected_raw_length = (int) strlen(data[i].expected_raw);
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt); assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
@ -163,6 +165,18 @@ static void test_hrt(const testCtx *const p_ctx) {
i, symbol->text_length, expected_length, symbol->text); i, symbol->text_length, expected_length, symbol->text);
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
i, symbol->text, data[i].expected); i, symbol->text, data[i].expected);
if (symbol->output_options & BARCODE_RAW_TEXT) {
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
assert_nonnull(symbol->raw_segs[0].source, "i:%d raw_segs[0].source NULL\n", i);
assert_equal(symbol->raw_segs[0].length, expected_raw_length,
"i:%d raw_segs[0].length %d != expected_raw_length %d\n",
i, symbol->raw_segs[0].length, expected_raw_length);
assert_zero(memcmp(symbol->raw_segs[0].source, data[i].expected_raw, expected_raw_length),
"i:%d memcmp(%s, %s, %d) != 0\n",
i, symbol->raw_segs[0].source, data[i].expected_raw, expected_raw_length);
} else {
assert_null(symbol->raw_segs, "i:%d raw_segs not NULL\n", i);
}
ZBarcode_Delete(symbol); ZBarcode_Delete(symbol);
} }
@ -223,7 +237,7 @@ static void test_input(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
testStartSymbol("test_input", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -323,10 +337,11 @@ static void test_encode(const testCtx *const p_ctx) {
char cmp_buf[8192]; char cmp_buf[8192];
char cmp_msg[1024]; char cmp_msg[1024];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ /* Only do BWIPP/ZXing-C++ tests if asked, too slow otherwise */
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript();
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder();
testStartSymbol("test_encode", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -367,13 +382,18 @@ static void test_encode(const testCtx *const p_ctx) {
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) { if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) {
int cmp_len, ret_len; int cmp_len, ret_len;
char modules_dump[8192 + 1]; char modules_dump[8192 + 1];
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1,
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); "i:%d testUtilModulesDump == -1\n", i);
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, 1 /*zxingcpp_cmp*/, cmp_buf,
sizeof(cmp_buf), &cmp_len);
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n",
i, testUtilBarcodeName(symbol->symbology), ret);
ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len); ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length,
NULL /*primary*/, escaped, &ret_len);
assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n",
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, escaped); i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len,
escaped);
} }
} }
} }

View file

@ -70,7 +70,7 @@ static void test_check_colour_options(const testCtx *const p_ctx) {
int i, ret; int i, ret;
struct zint_symbol symbol = {0}; /* Suppress clang -fsanitize=memory false positive */ struct zint_symbol symbol = {0}; /* Suppress clang -fsanitize=memory false positive */
testStart("test_check_colour_options"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -116,7 +116,7 @@ static void test_colour_get_rgb(const testCtx *const p_ctx) {
const int data_size = ARRAY_SIZE(data); const int data_size = ARRAY_SIZE(data);
int i, ret; int i, ret;
testStart("test_colour_get_rgb"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
/* Suppress clang-16 run-time exception MemorySanitizer: use-of-uninitialized-value (fixed in clang-17) */ /* Suppress clang-16 run-time exception MemorySanitizer: use-of-uninitialized-value (fixed in clang-17) */
@ -176,7 +176,7 @@ static void test_colour_get_cmyk(const testCtx *const p_ctx) {
const int data_size = ARRAY_SIZE(data); const int data_size = ARRAY_SIZE(data);
int i, ret; int i, ret;
testStart("test_colour_get_cmyk"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
/* Suppress clang -fsanitize=memory false positives */ /* Suppress clang -fsanitize=memory false positives */
@ -214,7 +214,7 @@ static void test_quiet_zones(const testCtx *const p_ctx) {
int comp_xoffset = 0; int comp_xoffset = 0;
float left, right, top, bottom; float left, right, top, bottom;
testStart("test_quiet_zones"); testStart(p_ctx->func_name);
for (i = 1; i <= BARCODE_LAST; i++) { for (i = 1; i <= BARCODE_LAST; i++) {
if (!ZBarcode_ValidID(i)) continue; if (!ZBarcode_ValidID(i)) continue;
@ -270,7 +270,7 @@ static void test_set_whitespace_offsets(const testCtx *const p_ctx) {
float xoffset, yoffset, roffset, boffset, qz_right; float xoffset, yoffset, roffset, boffset, qz_right;
int xoffset_si, yoffset_si, roffset_si, boffset_si, qz_right_si; int xoffset_si, yoffset_si, roffset_si, boffset_si, qz_right_si;
testStart("test_set_whitespace_offsets"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
if (testContinue(p_ctx, i)) continue; if (testContinue(p_ctx, i)) continue;
@ -361,7 +361,7 @@ static void test_fopen(const testCtx *const p_ctx) {
char subdirname[1024 + 256]; char subdirname[1024 + 256];
int dir_exists, subdir_exists; int dir_exists, subdir_exists;
testStart("test_fopen"); testStart(p_ctx->func_name);
assert_nonnull(getcwd(cwdbuf, sizeof(cwdbuf)), "getcwd NULL (%d, %s)\n", errno, strerror(errno)); assert_nonnull(getcwd(cwdbuf, sizeof(cwdbuf)), "getcwd NULL (%d, %s)\n", errno, strerror(errno));

View file

@ -70,7 +70,7 @@ static void test_print(const testCtx *const p_ctx) {
const char *const have_identify = testUtilHaveIdentify(); const char *const have_identify = testUtilHaveIdentify();
testStart("test_pcx"); testStart(p_ctx->func_name);
if (p_ctx->generate) { if (p_ctx->generate) {
char data_dir_path[1024]; char data_dir_path[1024];
@ -171,7 +171,7 @@ static void test_outfile(const testCtx *const p_ctx) {
(void)p_ctx; (void)p_ctx;
testStart("test_outfile"); testStart(p_ctx->func_name);
symbol.symbology = BARCODE_CODE128; symbol.symbology = BARCODE_CODE128;
symbol.bitmap = data; symbol.bitmap = data;

File diff suppressed because it is too large Load diff

View file

@ -73,7 +73,7 @@ static void test_large(const testCtx *const p_ctx) {
char data_buf[4096] = {0}; /* Suppress clang -fsanitize=memory false positive */ char data_buf[4096] = {0}; /* Suppress clang -fsanitize=memory false positive */
testStartSymbol("test_large", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -113,91 +113,93 @@ static void test_hrt(const testCtx *const p_ctx) {
const char *data; const char *data;
const char *expected; const char *expected;
const char *expected_raw;
}; };
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = { static const struct item data[] = {
/* 0*/ { BARCODE_MSI_PLESSEY, -1, -1, "1234567", "1234567" }, /* 0*/ { BARCODE_MSI_PLESSEY, -1, -1, "1234567", "1234567", "" },
/* 1*/ { BARCODE_MSI_PLESSEY, -1, BARCODE_RAW_TEXT, "1234567", "1234567" }, /* 1*/ { BARCODE_MSI_PLESSEY, -1, BARCODE_RAW_TEXT, "1234567", "1234567", "1234567" },
/* 2*/ { BARCODE_MSI_PLESSEY, 0, -1, "1234567", "1234567" }, /* 2*/ { BARCODE_MSI_PLESSEY, 0, -1, "1234567", "1234567", "" },
/* 3*/ { BARCODE_MSI_PLESSEY, 0, BARCODE_RAW_TEXT, "1234567", "1234567" }, /* 3*/ { BARCODE_MSI_PLESSEY, 0, BARCODE_RAW_TEXT, "1234567", "1234567", "1234567" },
/* 4*/ { BARCODE_MSI_PLESSEY, 1, -1, "1234567", "12345674" }, /* 4*/ { BARCODE_MSI_PLESSEY, 1, -1, "1234567", "12345674", "" },
/* 5*/ { BARCODE_MSI_PLESSEY, 1, BARCODE_RAW_TEXT, "1234567", "12345674" }, /* 5*/ { BARCODE_MSI_PLESSEY, 1, BARCODE_RAW_TEXT, "1234567", "12345674", "12345674" },
/* 6*/ { BARCODE_MSI_PLESSEY, 1 + 10, -1, "1234567", "1234567" }, /* 6*/ { BARCODE_MSI_PLESSEY, 1 + 10, -1, "1234567", "1234567", "" },
/* 7*/ { BARCODE_MSI_PLESSEY, 1 + 10, BARCODE_RAW_TEXT, "1234567", "12345674" }, /* 7*/ { BARCODE_MSI_PLESSEY, 1 + 10, BARCODE_RAW_TEXT, "1234567", "1234567", "12345674" },
/* 8*/ { BARCODE_MSI_PLESSEY, 1, -1, "9999999999", "99999999990" }, /* 8*/ { BARCODE_MSI_PLESSEY, 1, -1, "9999999999", "99999999990", "" },
/* 9*/ { BARCODE_MSI_PLESSEY, 1, BARCODE_RAW_TEXT, "9999999999", "99999999990" }, /* 9*/ { BARCODE_MSI_PLESSEY, 1, BARCODE_RAW_TEXT, "9999999999", "99999999990", "99999999990" },
/* 10*/ { BARCODE_MSI_PLESSEY, 2, -1, "1234567", "123456741" }, /* 10*/ { BARCODE_MSI_PLESSEY, 2, -1, "1234567", "123456741", "" },
/* 11*/ { BARCODE_MSI_PLESSEY, 2, BARCODE_RAW_TEXT, "1234567", "123456741" }, /* 11*/ { BARCODE_MSI_PLESSEY, 2, BARCODE_RAW_TEXT, "1234567", "123456741", "123456741" },
/* 12*/ { BARCODE_MSI_PLESSEY, 2 + 10, -1, "1234567", "1234567" }, /* 12*/ { BARCODE_MSI_PLESSEY, 2 + 10, -1, "1234567", "1234567", "" },
/* 13*/ { BARCODE_MSI_PLESSEY, 2 + 10, BARCODE_RAW_TEXT, "1234567", "123456741" }, /* 13*/ { BARCODE_MSI_PLESSEY, 2 + 10, BARCODE_RAW_TEXT, "1234567", "1234567", "123456741" },
/* 14*/ { BARCODE_MSI_PLESSEY, 2, -1, "9999999999", "999999999900" }, /* 14*/ { BARCODE_MSI_PLESSEY, 2, -1, "9999999999", "999999999900", "" },
/* 15*/ { BARCODE_MSI_PLESSEY, 2, BARCODE_RAW_TEXT, "9999999999", "999999999900" }, /* 15*/ { BARCODE_MSI_PLESSEY, 2, BARCODE_RAW_TEXT, "9999999999", "999999999900", "999999999900" },
/* 16*/ { BARCODE_MSI_PLESSEY, 3, -1, "1234567", "12345674" }, /* 16*/ { BARCODE_MSI_PLESSEY, 3, -1, "1234567", "12345674", "" },
/* 17*/ { BARCODE_MSI_PLESSEY, 3, BARCODE_RAW_TEXT, "1234567", "12345674" }, /* 17*/ { BARCODE_MSI_PLESSEY, 3, BARCODE_RAW_TEXT, "1234567", "12345674", "12345674" },
/* 18*/ { BARCODE_MSI_PLESSEY, 3 + 10, -1, "1234567", "1234567" }, /* 18*/ { BARCODE_MSI_PLESSEY, 3 + 10, -1, "1234567", "1234567", "" },
/* 19*/ { BARCODE_MSI_PLESSEY, 3 + 10, BARCODE_RAW_TEXT, "1234567", "12345674" }, /* 19*/ { BARCODE_MSI_PLESSEY, 3 + 10, BARCODE_RAW_TEXT, "1234567", "1234567", "12345674" },
/* 20*/ { BARCODE_MSI_PLESSEY, 3, -1, "9999999999", "99999999995" }, /* 20*/ { BARCODE_MSI_PLESSEY, 3, -1, "9999999999", "99999999995", "" },
/* 21*/ { BARCODE_MSI_PLESSEY, 3, BARCODE_RAW_TEXT, "9999999999", "99999999995" }, /* 21*/ { BARCODE_MSI_PLESSEY, 3, BARCODE_RAW_TEXT, "9999999999", "99999999995", "99999999995" },
/* 22*/ { BARCODE_MSI_PLESSEY, 4, -1, "1234567", "123456741" }, /* 22*/ { BARCODE_MSI_PLESSEY, 4, -1, "1234567", "123456741", "" },
/* 23*/ { BARCODE_MSI_PLESSEY, 4, BARCODE_RAW_TEXT, "1234567", "123456741" }, /* 23*/ { BARCODE_MSI_PLESSEY, 4, BARCODE_RAW_TEXT, "1234567", "123456741", "123456741" },
/* 24*/ { BARCODE_MSI_PLESSEY, 4 + 10, -1, "1234567", "1234567" }, /* 24*/ { BARCODE_MSI_PLESSEY, 4 + 10, -1, "1234567", "1234567", "" },
/* 25*/ { BARCODE_MSI_PLESSEY, 4 + 10, BARCODE_RAW_TEXT, "1234567", "123456741" }, /* 25*/ { BARCODE_MSI_PLESSEY, 4 + 10, BARCODE_RAW_TEXT, "1234567", "1234567", "123456741" },
/* 26*/ { BARCODE_MSI_PLESSEY, 4, -1, "9999999999", "999999999959" }, /* 26*/ { BARCODE_MSI_PLESSEY, 4, -1, "9999999999", "999999999959", "" },
/* 27*/ { BARCODE_MSI_PLESSEY, 4, BARCODE_RAW_TEXT, "9999999999", "999999999959" }, /* 27*/ { BARCODE_MSI_PLESSEY, 4, BARCODE_RAW_TEXT, "9999999999", "999999999959", "999999999959" },
/* 28*/ { BARCODE_MSI_PLESSEY, 5, -1, "1234567", "12345679" }, /* 28*/ { BARCODE_MSI_PLESSEY, 5, -1, "1234567", "12345679", "" },
/* 29*/ { BARCODE_MSI_PLESSEY, 5, BARCODE_RAW_TEXT, "1234567", "12345679" }, /* 29*/ { BARCODE_MSI_PLESSEY, 5, BARCODE_RAW_TEXT, "1234567", "12345679", "12345679" },
/* 30*/ { BARCODE_MSI_PLESSEY, 5 + 10, -1, "1234567", "1234567" }, /* 30*/ { BARCODE_MSI_PLESSEY, 5 + 10, -1, "1234567", "1234567", "" },
/* 31*/ { BARCODE_MSI_PLESSEY, 5 + 10, BARCODE_RAW_TEXT, "1234567", "12345679" }, /* 31*/ { BARCODE_MSI_PLESSEY, 5 + 10, BARCODE_RAW_TEXT, "1234567", "1234567", "12345679" },
/* 32*/ { BARCODE_MSI_PLESSEY, 5, -1, "9999999999", "999999999910" }, /* 32*/ { BARCODE_MSI_PLESSEY, 5, -1, "9999999999", "999999999910", "" },
/* 33*/ { BARCODE_MSI_PLESSEY, 5, BARCODE_RAW_TEXT, "9999999999", "999999999910" }, /* 33*/ { BARCODE_MSI_PLESSEY, 5, BARCODE_RAW_TEXT, "9999999999", "999999999910", "999999999910" },
/* 34*/ { BARCODE_MSI_PLESSEY, 6, -1, "1234567", "123456790" }, /* 34*/ { BARCODE_MSI_PLESSEY, 6, -1, "1234567", "123456790", "" },
/* 35*/ { BARCODE_MSI_PLESSEY, 6, BARCODE_RAW_TEXT, "1234567", "123456790" }, /* 35*/ { BARCODE_MSI_PLESSEY, 6, BARCODE_RAW_TEXT, "1234567", "123456790", "123456790" },
/* 36*/ { BARCODE_MSI_PLESSEY, 6 + 10, -1, "1234567", "1234567" }, /* 36*/ { BARCODE_MSI_PLESSEY, 6 + 10, -1, "1234567", "1234567", "" },
/* 37*/ { BARCODE_MSI_PLESSEY, 6 + 10, BARCODE_RAW_TEXT, "1234567", "123456790" }, /* 37*/ { BARCODE_MSI_PLESSEY, 6 + 10, BARCODE_RAW_TEXT, "1234567", "1234567", "123456790" },
/* 38*/ { BARCODE_MSI_PLESSEY, 6, -1, "9999999999", "9999999999109" }, /* 38*/ { BARCODE_MSI_PLESSEY, 6, -1, "9999999999", "9999999999109", "" },
/* 39*/ { BARCODE_MSI_PLESSEY, 6, BARCODE_RAW_TEXT, "9999999999", "9999999999109" }, /* 39*/ { BARCODE_MSI_PLESSEY, 6, BARCODE_RAW_TEXT, "9999999999", "9999999999109", "9999999999109" },
/* 40*/ { BARCODE_MSI_PLESSEY, 1, -1, "123456", "1234566" }, /* 40*/ { BARCODE_MSI_PLESSEY, 1, -1, "123456", "1234566", "" },
/* 41*/ { BARCODE_MSI_PLESSEY, 1, BARCODE_RAW_TEXT, "123456", "1234566" }, /* 41*/ { BARCODE_MSI_PLESSEY, 1, BARCODE_RAW_TEXT, "123456", "1234566", "1234566" },
/* 42*/ { BARCODE_MSI_PLESSEY, 2, -1, "123456", "12345666" }, /* 42*/ { BARCODE_MSI_PLESSEY, 2, -1, "123456", "12345666", "" },
/* 43*/ { BARCODE_MSI_PLESSEY, 2, BARCODE_RAW_TEXT, "123456", "12345666" }, /* 43*/ { BARCODE_MSI_PLESSEY, 2, BARCODE_RAW_TEXT, "123456", "12345666", "12345666" },
/* 44*/ { BARCODE_MSI_PLESSEY, 3, -1, "123456", "1234560" }, /* 44*/ { BARCODE_MSI_PLESSEY, 3, -1, "123456", "1234560", "" },
/* 45*/ { BARCODE_MSI_PLESSEY, 3, BARCODE_RAW_TEXT, "123456", "1234560" }, /* 45*/ { BARCODE_MSI_PLESSEY, 3, BARCODE_RAW_TEXT, "123456", "1234560", "1234560" },
/* 46*/ { BARCODE_MSI_PLESSEY, 4, -1, "123456", "12345609" }, /* 46*/ { BARCODE_MSI_PLESSEY, 4, -1, "123456", "12345609", "" },
/* 47*/ { BARCODE_MSI_PLESSEY, 4, BARCODE_RAW_TEXT, "123456", "12345609" }, /* 47*/ { BARCODE_MSI_PLESSEY, 4, BARCODE_RAW_TEXT, "123456", "12345609", "12345609" },
/* 48*/ { BARCODE_MSI_PLESSEY, 3, -1, "2211", "221110" }, /* Mod-11 check digit '10' */ /* 48*/ { BARCODE_MSI_PLESSEY, 3, -1, "2211", "221110", "" }, /* Mod-11 check digit '10' */
/* 49*/ { BARCODE_MSI_PLESSEY, 3, BARCODE_RAW_TEXT, "2211", "221110" }, /* 49*/ { BARCODE_MSI_PLESSEY, 3, BARCODE_RAW_TEXT, "2211", "221110", "221110" },
/* 50*/ { BARCODE_MSI_PLESSEY, 3 + 10, -1, "2211", "2211" }, /* Mod-11 check digit '10' */ /* 50*/ { BARCODE_MSI_PLESSEY, 3 + 10, -1, "2211", "2211", "" }, /* Mod-11 check digit '10' */
/* 51*/ { BARCODE_MSI_PLESSEY, 3 + 10, BARCODE_RAW_TEXT, "2211", "221110" }, /* 51*/ { BARCODE_MSI_PLESSEY, 3 + 10, BARCODE_RAW_TEXT, "2211", "2211", "221110" },
/* 52*/ { BARCODE_MSI_PLESSEY, 4, -1, "2211", "2211100" }, /* 52*/ { BARCODE_MSI_PLESSEY, 4, -1, "2211", "2211100", "" },
/* 53*/ { BARCODE_MSI_PLESSEY, 4, BARCODE_RAW_TEXT, "2211", "2211100" }, /* 53*/ { BARCODE_MSI_PLESSEY, 4, BARCODE_RAW_TEXT, "2211", "2211100", "2211100" },
/* 54*/ { BARCODE_MSI_PLESSEY, 4 + 10, -1, "2211", "2211" }, /* 54*/ { BARCODE_MSI_PLESSEY, 4 + 10, -1, "2211", "2211", "" },
/* 55*/ { BARCODE_MSI_PLESSEY, 4 + 10, BARCODE_RAW_TEXT, "2211", "2211100" }, /* 55*/ { BARCODE_MSI_PLESSEY, 4 + 10, BARCODE_RAW_TEXT, "2211", "2211", "2211100" },
/* 56*/ { BARCODE_PLESSEY, -1, -1, "0123456789ABCDEF", "0123456789ABCDEF" }, /* 56*/ { BARCODE_PLESSEY, -1, -1, "0123456789ABCDEF", "0123456789ABCDEF", "" },
/* 57*/ { BARCODE_PLESSEY, -1, BARCODE_RAW_TEXT, "0123456789ABCDEF", "0123456789ABCDEF90" }, /* 57*/ { BARCODE_PLESSEY, -1, BARCODE_RAW_TEXT, "0123456789ABCDEF", "0123456789ABCDEF", "0123456789ABCDEF90" },
/* 58*/ { BARCODE_PLESSEY, 1, -1, "0123456789ABCDEF", "0123456789ABCDEF90" }, /* 58*/ { BARCODE_PLESSEY, 1, -1, "0123456789ABCDEF", "0123456789ABCDEF90", "" },
/* 59*/ { BARCODE_PLESSEY, 1, BARCODE_RAW_TEXT, "0123456789ABCDEF", "0123456789ABCDEF90" }, /* 59*/ { BARCODE_PLESSEY, 1, BARCODE_RAW_TEXT, "0123456789ABCDEF", "0123456789ABCDEF90", "0123456789ABCDEF90" },
/* 60*/ { BARCODE_PLESSEY, -1, -1, "1", "1" }, /* 60*/ { BARCODE_PLESSEY, -1, -1, "1", "1", "" },
/* 61*/ { BARCODE_PLESSEY, -1, BARCODE_RAW_TEXT, "1", "173" }, /* 61*/ { BARCODE_PLESSEY, -1, BARCODE_RAW_TEXT, "1", "1", "173" },
/* 62*/ { BARCODE_PLESSEY, 1, -1, "1", "173" }, /* 62*/ { BARCODE_PLESSEY, 1, -1, "1", "173", "" },
/* 63*/ { BARCODE_PLESSEY, 1, BARCODE_RAW_TEXT, "1", "173" }, /* 63*/ { BARCODE_PLESSEY, 1, BARCODE_RAW_TEXT, "1", "173", "173" },
/* 64*/ { BARCODE_PLESSEY, -1, -1, "7", "7" }, /* 64*/ { BARCODE_PLESSEY, -1, -1, "7", "7", "" },
/* 65*/ { BARCODE_PLESSEY, -1, BARCODE_RAW_TEXT, "7", "758" }, /* 65*/ { BARCODE_PLESSEY, -1, BARCODE_RAW_TEXT, "7", "7", "758" },
/* 66*/ { BARCODE_PLESSEY, 1, -1, "7", "758" }, /* 66*/ { BARCODE_PLESSEY, 1, -1, "7", "758", "" },
/* 67*/ { BARCODE_PLESSEY, 1, BARCODE_RAW_TEXT, "7", "758" }, /* 67*/ { BARCODE_PLESSEY, 1, BARCODE_RAW_TEXT, "7", "758", "758" },
/* 68*/ { BARCODE_PLESSEY, -1, -1, "75", "75" }, /* 68*/ { BARCODE_PLESSEY, -1, -1, "75", "75", "" },
/* 69*/ { BARCODE_PLESSEY, -1, BARCODE_RAW_TEXT, "75", "7580" }, /* 69*/ { BARCODE_PLESSEY, -1, BARCODE_RAW_TEXT, "75", "75", "7580" },
/* 70*/ { BARCODE_PLESSEY, 1, -1, "75", "7580" }, /* 70*/ { BARCODE_PLESSEY, 1, -1, "75", "7580", "" },
/* 71*/ { BARCODE_PLESSEY, 1, BARCODE_RAW_TEXT, "75", "7580" }, /* 71*/ { BARCODE_PLESSEY, 1, BARCODE_RAW_TEXT, "75", "7580", "7580" },
/* 72*/ { BARCODE_PLESSEY, -1, -1, "993", "993" }, /* 72*/ { BARCODE_PLESSEY, -1, -1, "993", "993", "" },
/* 73*/ { BARCODE_PLESSEY, -1, BARCODE_RAW_TEXT, "993", "993AA" }, /* 73*/ { BARCODE_PLESSEY, -1, BARCODE_RAW_TEXT, "993", "993", "993AA" },
/* 74*/ { BARCODE_PLESSEY, 1, -1, "993", "993AA" }, /* 74*/ { BARCODE_PLESSEY, 1, -1, "993", "993AA", "" },
/* 75*/ { BARCODE_PLESSEY, 1, BARCODE_RAW_TEXT, "993", "993AA", "993AA" },
}; };
const int data_size = ARRAY_SIZE(data); const int data_size = ARRAY_SIZE(data);
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
int expected_length; int expected_length, expected_raw_length;
testStartSymbol("test_hrt", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -210,6 +212,7 @@ static void test_hrt(const testCtx *const p_ctx) {
-1 /*option_1*/, data[i].option_2, -1, data[i].output_options, -1 /*option_1*/, data[i].option_2, -1, data[i].output_options,
data[i].data, -1, debug); data[i].data, -1, debug);
expected_length = (int) strlen(data[i].expected); expected_length = (int) strlen(data[i].expected);
expected_raw_length = (int) strlen(data[i].expected_raw);
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt); assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
@ -218,6 +221,18 @@ static void test_hrt(const testCtx *const p_ctx) {
i, symbol->text_length, expected_length); i, symbol->text_length, expected_length);
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
i, symbol->text, data[i].expected); i, symbol->text, data[i].expected);
if (symbol->output_options & BARCODE_RAW_TEXT) {
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
assert_nonnull(symbol->raw_segs[0].source, "i:%d raw_segs[0].source NULL\n", i);
assert_equal(symbol->raw_segs[0].length, expected_raw_length,
"i:%d raw_segs[0].length %d != expected_raw_length %d\n",
i, symbol->raw_segs[0].length, expected_raw_length);
assert_zero(memcmp(symbol->raw_segs[0].source, data[i].expected_raw, expected_raw_length),
"i:%d memcmp(%s, %s, %d) != 0\n",
i, symbol->raw_segs[0].source, data[i].expected_raw, expected_raw_length);
} else {
assert_null(symbol->raw_segs, "i:%d raw_segs not NULL\n", i);
}
ZBarcode_Delete(symbol); ZBarcode_Delete(symbol);
} }
@ -250,7 +265,7 @@ static void test_input(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_input", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -336,7 +351,7 @@ static void test_encode(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
testStartSymbol("test_encode", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {

View file

@ -66,7 +66,7 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
const char *const have_identify = testUtilHaveIdentify(); const char *const have_identify = testUtilHaveIdentify();
testStart("test_pixel_plot"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int size; int size;
@ -253,7 +253,7 @@ static void test_print(const testCtx *const p_ctx) {
const char *const have_identify = testUtilHaveIdentify(); const char *const have_identify = testUtilHaveIdentify();
testStartSymbol("test_print", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
if (p_ctx->generate) { if (p_ctx->generate) {
char data_dir_path[1024]; char data_dir_path[1024];
@ -375,7 +375,7 @@ static void test_outfile(const testCtx *const p_ctx) {
(void)p_ctx; (void)p_ctx;
testStart("test_outfile"); testStart(p_ctx->func_name);
symbol.symbology = BARCODE_CODE128; symbol.symbology = BARCODE_CODE128;
symbol.bitmap = data; symbol.bitmap = data;
@ -428,7 +428,7 @@ static void test_wpng_error_handler(const testCtx *const p_ctx) {
(void)p_ctx; (void)p_ctx;
testStart("test_wpng_error_handler"); testStart(p_ctx->func_name);
wpng_error.symbol = &symbol; wpng_error.symbol = &symbol;
@ -476,7 +476,7 @@ static void test_large_compliant_height(const testCtx *const p_ctx) {
(void)p_ctx; (void)p_ctx;
testStartSymbol("test_large_compliant_height", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
symbol = ZBarcode_Create(); symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n"); assert_nonnull(symbol, "Symbol not created\n");

View file

@ -84,7 +84,7 @@ static void test_large(const testCtx *const p_ctx) {
char data_buf[4096] = {0}; /* Suppress clang -fsanitize=memory false positive */ char data_buf[4096] = {0}; /* Suppress clang -fsanitize=memory false positive */
testStartSymbol("test_large", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -132,7 +132,7 @@ static void test_koreapost(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_koreapost", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -185,7 +185,7 @@ static void test_japanpost(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_japanpost", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -224,37 +224,38 @@ static void test_hrt(const testCtx *const p_ctx) {
const char *data; const char *data;
const char *expected; const char *expected;
const char *expected_raw;
}; };
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = { static const struct item data[] = {
/* 0*/ { BARCODE_FLAT, -1, -1, "12345", "" }, /* None */ /* 0*/ { BARCODE_FLAT, -1, -1, "12345", "", "" }, /* None */
/* 1*/ { BARCODE_FLAT, -1, BARCODE_RAW_TEXT, "12345", "12345" }, /* 1*/ { BARCODE_FLAT, -1, BARCODE_RAW_TEXT, "12345", "", "12345" },
/* 2*/ { BARCODE_POSTNET, -1, -1, "12345", "" }, /* None */ /* 2*/ { BARCODE_POSTNET, -1, -1, "12345", "", "" }, /* None */
/* 3*/ { BARCODE_POSTNET, -1, BARCODE_RAW_TEXT, "12345", "123455" }, /* 3*/ { BARCODE_POSTNET, -1, BARCODE_RAW_TEXT, "12345", "", "123455" },
/* 4*/ { BARCODE_FIM, -1, -1, "e", "" }, /* None */ /* 4*/ { BARCODE_FIM, -1, -1, "e", "", "" }, /* None */
/* 5*/ { BARCODE_FIM, -1, BARCODE_RAW_TEXT, "e", "E" }, /* 5*/ { BARCODE_FIM, -1, BARCODE_RAW_TEXT, "e", "", "E" },
/* 6*/ { BARCODE_CEPNET, -1, -1, "12345678", "" }, /* None */ /* 6*/ { BARCODE_CEPNET, -1, -1, "12345678", "", "" }, /* None */
/* 7*/ { BARCODE_CEPNET, -1, BARCODE_RAW_TEXT, "12345678", "123456784" }, /* 7*/ { BARCODE_CEPNET, -1, BARCODE_RAW_TEXT, "12345678", "", "123456784" },
/* 8*/ { BARCODE_RM4SCC, -1, -1, "BX11LT1A", "" }, /* None*/ /* 8*/ { BARCODE_RM4SCC, -1, -1, "BX11LT1A", "", "" }, /* None*/
/* 9*/ { BARCODE_RM4SCC, -1, BARCODE_RAW_TEXT, "BX11LT1A", "BX11LT1AI" }, /* 9*/ { BARCODE_RM4SCC, -1, BARCODE_RAW_TEXT, "BX11LT1A", "", "BX11LT1AI" },
/* 10*/ { BARCODE_JAPANPOST, -1, -1, "1234", "" }, /* None*/ /* 10*/ { BARCODE_JAPANPOST, -1, -1, "1234", "", "" }, /* None*/
/* 11*/ { BARCODE_JAPANPOST, -1, BARCODE_RAW_TEXT, "1234", "1234" }, /* Note check char not included */ /* 11*/ { BARCODE_JAPANPOST, -1, BARCODE_RAW_TEXT, "1234", "", "1234" }, /* Note check char not included */
/* 12*/ { BARCODE_JAPANPOST, -1, BARCODE_RAW_TEXT, "123456-AB", "123456-AB" }, /* Ditto */ /* 12*/ { BARCODE_JAPANPOST, -1, BARCODE_RAW_TEXT, "123456-AB", "", "123456-AB" }, /* Ditto */
/* 13*/ { BARCODE_KOREAPOST, -1, -1, "123456", "1234569" }, /* 13*/ { BARCODE_KOREAPOST, -1, -1, "123456", "1234569", "" },
/* 14*/ { BARCODE_KOREAPOST, -1, BARCODE_RAW_TEXT, "123456", "1234569" }, /* No difference */ /* 14*/ { BARCODE_KOREAPOST, -1, BARCODE_RAW_TEXT, "123456", "1234569", "1234569" }, /* No difference */
/* 15*/ { BARCODE_PLANET, -1, -1, "12345678901", "" }, /* None */ /* 15*/ { BARCODE_PLANET, -1, -1, "12345678901", "", "" }, /* None */
/* 16*/ { BARCODE_PLANET, -1, BARCODE_RAW_TEXT, "12345678901", "123456789014" }, /* 16*/ { BARCODE_PLANET, -1, BARCODE_RAW_TEXT, "12345678901", "", "123456789014" },
/* 17*/ { BARCODE_KIX, -1, -1, "0123456789ABCDEFGH", "" }, /* None */ /* 17*/ { BARCODE_KIX, -1, -1, "0123456789ABCDEFGH", "", "" }, /* None */
/* 18*/ { BARCODE_KIX, -1, BARCODE_RAW_TEXT, "0123456789ABCDEFGH", "0123456789ABCDEFGH" }, /* 18*/ { BARCODE_KIX, -1, BARCODE_RAW_TEXT, "0123456789ABCDEFGH", "", "0123456789ABCDEFGH" },
/* 19*/ { BARCODE_DAFT, -1, -1, "DAFT", "" }, /* None */ /* 19*/ { BARCODE_DAFT, -1, -1, "DAFT", "", "" }, /* None */
/* 20*/ { BARCODE_DAFT, -1, BARCODE_RAW_TEXT, "DAFT", "DAFT" }, /* 20*/ { BARCODE_DAFT, -1, BARCODE_RAW_TEXT, "DAFT", "", "DAFT" },
}; };
const int data_size = ARRAY_SIZE(data); const int data_size = ARRAY_SIZE(data);
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
int expected_length; int expected_length, expected_raw_length;
testStartSymbol("test_hrt", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -267,6 +268,7 @@ static void test_hrt(const testCtx *const p_ctx) {
-1 /*option_1*/, data[i].option_2, -1 /*option_3*/, data[i].output_options, -1 /*option_1*/, data[i].option_2, -1 /*option_3*/, data[i].output_options,
data[i].data, -1, debug); data[i].data, -1, debug);
expected_length = (int) strlen(data[i].expected); expected_length = (int) strlen(data[i].expected);
expected_raw_length = (int) strlen(data[i].expected_raw);
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt); assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
@ -275,6 +277,18 @@ static void test_hrt(const testCtx *const p_ctx) {
i, symbol->text_length, expected_length); i, symbol->text_length, expected_length);
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
i, symbol->text, data[i].expected); i, symbol->text, data[i].expected);
if (symbol->output_options & BARCODE_RAW_TEXT) {
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
assert_nonnull(symbol->raw_segs[0].source, "i:%d raw_segs[0].source NULL\n", i);
assert_equal(symbol->raw_segs[0].length, expected_raw_length,
"i:%d raw_segs[0].length %d != expected_raw_length %d\n",
i, symbol->raw_segs[0].length, expected_raw_length);
assert_zero(memcmp(symbol->raw_segs[0].source, data[i].expected_raw, expected_raw_length),
"i:%d memcmp(%s, %s, %d) != 0\n",
i, symbol->raw_segs[0].source, data[i].expected_raw, expected_raw_length);
} else {
assert_null(symbol->raw_segs, "i:%d raw_segs not NULL\n", i);
}
ZBarcode_Delete(symbol); ZBarcode_Delete(symbol);
} }
@ -357,7 +371,7 @@ static void test_input(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
testStartSymbol("test_input", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -555,7 +569,7 @@ static void test_encode(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
testStartSymbol("test_encode", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {

View file

@ -84,7 +84,7 @@ static void test_print(const testCtx *const p_ctx) {
have_tiffinfo = testUtilHaveTiffInfo(); have_tiffinfo = testUtilHaveTiffInfo();
} }
testStartSymbol("test_print", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
assert_nonzero(testUtilDataPath(data_dir, sizeof(data_dir), "/backend/tests/data", NULL), "testUtilDataPath == 0\n"); assert_nonzero(testUtilDataPath(data_dir, sizeof(data_dir), "/backend/tests/data", NULL), "testUtilDataPath == 0\n");

View file

@ -126,7 +126,7 @@ static void test_print(const testCtx *const p_ctx) {
int have_ghostscript = testUtilHaveGhostscript(); int have_ghostscript = testUtilHaveGhostscript();
testStartSymbol("test_print", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
if (p_ctx->generate) { if (p_ctx->generate) {
char data_dir_path[1024]; char data_dir_path[1024];
@ -237,7 +237,7 @@ static void test_ps_convert(const testCtx *const p_ctx) {
unsigned char converted[256] = {0}; /* Suppress clang -fsanitize=memory false positive */ unsigned char converted[256] = {0}; /* Suppress clang -fsanitize=memory false positive */
testStart("test_ps_convert"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -260,7 +260,7 @@ static void test_outfile(const testCtx *const p_ctx) {
(void)p_ctx; (void)p_ctx;
testStart("test_outfile"); testStart(p_ctx->func_name);
symbol.symbology = BARCODE_CODE128; symbol.symbology = BARCODE_CODE128;
symbol.vector = &vector; symbol.vector = &vector;

File diff suppressed because it is too large Load diff

View file

@ -72,7 +72,7 @@ static void test_options(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_options", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -393,7 +393,7 @@ static void test_buffer(const testCtx *const p_ctx) {
const char *text; const char *text;
testStartSymbol("test_buffer", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -465,7 +465,7 @@ static void test_upcean_hrt(const testCtx *const p_ctx) {
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = { static const struct item data[] = {
/* 0*/ { BARCODE_EANX, -1, -1, "123456789012", 0, 50, 1, 95, 226, 116, 102 /*text_row*/, 0, 22, -1, -1, -1 }, /* EAN-13 */ /* 0*/ { BARCODE_EANX, -1, -1, "123456789012", 0, 50, 1, 95, 226, 116, 102 /*text_row*/, 0, 22, -1, -1, -1 }, /* EAN-13 */
/* 1*/ { BARCODE_EANX, -1, BARCODE_RAW_TEXT, "123456789012", ZINT_WARN_HRT_RAW_TEXT, 50, 1, 95, 226, 116, 102 /*text_row*/, 0, 22, -1, -1, -1 }, /* EAN-13 */ /* 1*/ { BARCODE_EANX, -1, BARCODE_RAW_TEXT, "123456789012", 0, 50, 1, 95, 226, 116, 102 /*text_row*/, 0, 22, -1, -1, -1 }, /* EAN-13 */
/* 2*/ { BARCODE_EANX, 0, -1, "123456789012", 0, 50, 1, 95, 226, 110, 102 /*text_row*/, 0, 22, -1, -1, -1 }, /* EAN-13 */ /* 2*/ { BARCODE_EANX, 0, -1, "123456789012", 0, 50, 1, 95, 226, 110, 102 /*text_row*/, 0, 22, -1, -1, -1 }, /* EAN-13 */
/* 3*/ { BARCODE_EANX, -1, EANUPC_GUARD_WHITESPACE, "123456789012", 0, 50, 1, 95, 226, 116, 108 /*text_row*/, 212, 14, -1, -1, -1 }, /* EAN-13 */ /* 3*/ { BARCODE_EANX, -1, EANUPC_GUARD_WHITESPACE, "123456789012", 0, 50, 1, 95, 226, 116, 108 /*text_row*/, 212, 14, -1, -1, -1 }, /* EAN-13 */
/* 4*/ { BARCODE_EANX, 0, EANUPC_GUARD_WHITESPACE, "123456789012", 0, 50, 1, 95, 226, 110, 108 /*text_row*/, 212, 14, -1, -1, -1 }, /* EAN-13 */ /* 4*/ { BARCODE_EANX, 0, EANUPC_GUARD_WHITESPACE, "123456789012", 0, 50, 1, 95, 226, 110, 108 /*text_row*/, 212, 14, -1, -1, -1 }, /* EAN-13 */
@ -473,76 +473,76 @@ static void test_upcean_hrt(const testCtx *const p_ctx) {
/* 6*/ { BARCODE_EANX_CHK, -1, -1, "1234567890128", 0, 50, 1, 95, 226, 116, 102 /*text_row*/, 0, 22, -1, -1, -1 }, /* EAN-13 */ /* 6*/ { BARCODE_EANX_CHK, -1, -1, "1234567890128", 0, 50, 1, 95, 226, 116, 102 /*text_row*/, 0, 22, -1, -1, -1 }, /* EAN-13 */
/* 7*/ { BARCODE_EANX_CHK, 0, -1, "1234567890128", 0, 50, 1, 95, 226, 110, 102 /*text_row*/, 0, 22, -1, -1, -1 }, /* EAN-13 */ /* 7*/ { BARCODE_EANX_CHK, 0, -1, "1234567890128", 0, 50, 1, 95, 226, 110, 102 /*text_row*/, 0, 22, -1, -1, -1 }, /* EAN-13 */
/* 8*/ { BARCODE_EANX_CHK, -1, -1, "1234567890128+12", 0, 50, 1, 122, 276, 116, 102 /*text_row*/, 0, 22, 5, 212, 64 }, /* EAN-13 + EAN-2 */ /* 8*/ { BARCODE_EANX_CHK, -1, -1, "1234567890128+12", 0, 50, 1, 122, 276, 116, 102 /*text_row*/, 0, 22, 5, 212, 64 }, /* EAN-13 + EAN-2 */
/* 9*/ { BARCODE_EANX_CHK, -1, BARCODE_RAW_TEXT, "1234567890128+12", ZINT_WARN_HRT_RAW_TEXT, 50, 1, 122, 276, 116, 102 /*text_row*/, 0, 22, 5, 212, 64 }, /* EAN-13 + EAN-2 */ /* 9*/ { BARCODE_EANX_CHK, -1, BARCODE_RAW_TEXT, "1234567890128+12", 0, 50, 1, 122, 276, 116, 102 /*text_row*/, 0, 22, 5, 212, 64 }, /* EAN-13 + EAN-2 */
/* 10*/ { BARCODE_EANX_CHK, 0, -1, "1234567890128+12", 0, 50, 1, 122, 276, 110, 102 /*text_row*/, 0, 22, 5, 212, 64 }, /* EAN-13 + EAN-2 */ /* 10*/ { BARCODE_EANX_CHK, 0, -1, "1234567890128+12", 0, 50, 1, 122, 276, 110, 102 /*text_row*/, 0, 22, 5, 212, 64 }, /* EAN-13 + EAN-2 */
/* 11*/ { BARCODE_EANX_CHK, -1, EANUPC_GUARD_WHITESPACE, "1234567890128+12", 0, 50, 1, 122, 276, 116, 102 /*text_row*/, 0, 22, 6, 264, 12 }, /* EAN-13 + EAN-2 */ /* 11*/ { BARCODE_EANX_CHK, -1, EANUPC_GUARD_WHITESPACE, "1234567890128+12", 0, 50, 1, 122, 276, 116, 102 /*text_row*/, 0, 22, 6, 264, 12 }, /* EAN-13 + EAN-2 */
/* 12*/ { BARCODE_EANX_CHK, 0, EANUPC_GUARD_WHITESPACE, "1234567890128+12", 0, 50, 1, 122, 276, 110, 102 /*text_row*/, 0, 22, 6, 264, 12 }, /* EAN-13 + EAN-2 */ /* 12*/ { BARCODE_EANX_CHK, 0, EANUPC_GUARD_WHITESPACE, "1234567890128+12", 0, 50, 1, 122, 276, 110, 102 /*text_row*/, 0, 22, 6, 264, 12 }, /* EAN-13 + EAN-2 */
/* 13*/ { BARCODE_EANX_CHK, 1 /*empty*/, -1, "1234567890128+12", 0, 50, 1, 122, 276, 116, 6 /*text_row*/, 264, 12, -1, -1, -1 }, /* EAN-13 + EAN-2 */ /* 13*/ { BARCODE_EANX_CHK, 1 /*empty*/, -1, "1234567890128+12", 0, 50, 1, 122, 276, 116, 6 /*text_row*/, 264, 12, -1, -1, -1 }, /* EAN-13 + EAN-2 */
/* 14*/ { BARCODE_EANX, -1, -1, "1234567890128+12345", 0, 50, 1, 149, 330, 116, 102 /*text_row*/, 0, 22, 5, 212, 118 }, /* EAN-13 + EAN-5 */ /* 14*/ { BARCODE_EANX, -1, -1, "1234567890128+12345", 0, 50, 1, 149, 330, 116, 102 /*text_row*/, 0, 22, 5, 212, 118 }, /* EAN-13 + EAN-5 */
/* 15*/ { BARCODE_EANX, -1, BARCODE_RAW_TEXT, "1234567890128+12345", ZINT_WARN_HRT_RAW_TEXT, 50, 1, 149, 330, 116, 102 /*text_row*/, 0, 22, 5, 212, 118 }, /* EAN-13 + EAN-5 */ /* 15*/ { BARCODE_EANX, -1, BARCODE_RAW_TEXT, "1234567890128+12345", 0, 50, 1, 149, 330, 116, 102 /*text_row*/, 0, 22, 5, 212, 118 }, /* EAN-13 + EAN-5 */
/* 16*/ { BARCODE_EANX, 0, -1, "1234567890128+12345", 0, 50, 1, 149, 330, 110, 102 /*text_row*/, 0, 22, 5, 212, 118 }, /* EAN-13 + EAN-5 */ /* 16*/ { BARCODE_EANX, 0, -1, "1234567890128+12345", 0, 50, 1, 149, 330, 110, 102 /*text_row*/, 0, 22, 5, 212, 118 }, /* EAN-13 + EAN-5 */
/* 17*/ { BARCODE_ISBNX, -1, -1, "9784567890120+12345", 0, 50, 1, 149, 330, 116, 102 /*text_row*/, 0, 22, 5, 212, 118 }, /* ISBNX + EAN-5 */ /* 17*/ { BARCODE_ISBNX, -1, -1, "9784567890120+12345", 0, 50, 1, 149, 330, 116, 102 /*text_row*/, 0, 22, 5, 212, 118 }, /* ISBNX + EAN-5 */
/* 18*/ { BARCODE_ISBNX, -1, BARCODE_RAW_TEXT, "9784567890120+12345", ZINT_WARN_HRT_RAW_TEXT, 50, 1, 149, 330, 116, 102 /*text_row*/, 0, 22, 5, 212, 118 }, /* ISBNX + EAN-5 */ /* 18*/ { BARCODE_ISBNX, -1, BARCODE_RAW_TEXT, "9784567890120+12345", 0, 50, 1, 149, 330, 116, 102 /*text_row*/, 0, 22, 5, 212, 118 }, /* ISBNX + EAN-5 */
/* 19*/ { BARCODE_ISBNX, 0, -1, "9784567890120+12345", 0, 50, 1, 149, 330, 110, 102 /*text_row*/, 0, 22, 5, 212, 118 }, /* ISBNX + EAN-5 */ /* 19*/ { BARCODE_ISBNX, 0, -1, "9784567890120+12345", 0, 50, 1, 149, 330, 110, 102 /*text_row*/, 0, 22, 5, 212, 118 }, /* ISBNX + EAN-5 */
/* 20*/ { BARCODE_ISBNX, -1, EANUPC_GUARD_WHITESPACE, "9784567890120+12345", 0, 50, 1, 149, 330, 116, 102 /*text_row*/, 0, 22, 6, 304, 26 }, /* ISBNX + EAN-5 */ /* 20*/ { BARCODE_ISBNX, -1, EANUPC_GUARD_WHITESPACE, "9784567890120+12345", 0, 50, 1, 149, 330, 116, 102 /*text_row*/, 0, 22, 6, 304, 26 }, /* ISBNX + EAN-5 */
/* 21*/ { BARCODE_ISBNX, 0, EANUPC_GUARD_WHITESPACE, "9784567890120+12345", 0, 50, 1, 149, 330, 110, 102 /*text_row*/, 0, 22, 6, 304, 26 }, /* ISBNX + EAN-5 */ /* 21*/ { BARCODE_ISBNX, 0, EANUPC_GUARD_WHITESPACE, "9784567890120+12345", 0, 50, 1, 149, 330, 110, 102 /*text_row*/, 0, 22, 6, 304, 26 }, /* ISBNX + EAN-5 */
/* 22*/ { BARCODE_ISBNX, 1 /*empty*/, -1, "9784567890120+12345", 0, 50, 1, 149, 330, 116, 6 /*text_row*/, 304, 26, -1, -1, -1 }, /* ISBNX + EAN-5 */ /* 22*/ { BARCODE_ISBNX, 1 /*empty*/, -1, "9784567890120+12345", 0, 50, 1, 149, 330, 116, 6 /*text_row*/, 304, 26, -1, -1, -1 }, /* ISBNX + EAN-5 */
/* 23*/ { BARCODE_EANX, -1, -1, "123456", 0, 50, 1, 67, 162, 116, 106 /*text_row*/, 20, 58, -1, -1, -1 }, /* EAN-8 */ /* 23*/ { BARCODE_EANX, -1, -1, "123456", 0, 50, 1, 67, 162, 116, 106 /*text_row*/, 20, 58, -1, -1, -1 }, /* EAN-8 */
/* 24*/ { BARCODE_EANX, -1, BARCODE_RAW_TEXT, "123456", ZINT_WARN_HRT_RAW_TEXT, 50, 1, 67, 162, 116, 106 /*text_row*/, 20, 58, -1, -1, -1 }, /* EAN-8 */ /* 24*/ { BARCODE_EANX, -1, BARCODE_RAW_TEXT, "123456", 0, 50, 1, 67, 162, 116, 106 /*text_row*/, 20, 58, -1, -1, -1 }, /* EAN-8 */
/* 25*/ { BARCODE_EANX, 0, -1, "123456", 0, 50, 1, 67, 162, 110, 106 /*text_row*/, 20, 58, -1, -1, -1 }, /* EAN-8 */ /* 25*/ { BARCODE_EANX, 0, -1, "123456", 0, 50, 1, 67, 162, 110, 106 /*text_row*/, 20, 58, -1, -1, -1 }, /* EAN-8 */
/* 26*/ { BARCODE_EANX, -1, EANUPC_GUARD_WHITESPACE, "123456", 0, 50, 1, 67, 162, 116, 106 /*text_row*/, 0, 14, 106, 148, 14 }, /* EAN-8 */ /* 26*/ { BARCODE_EANX, -1, EANUPC_GUARD_WHITESPACE, "123456", 0, 50, 1, 67, 162, 116, 106 /*text_row*/, 0, 14, 106, 148, 14 }, /* EAN-8 */
/* 27*/ { BARCODE_EANX, 0, EANUPC_GUARD_WHITESPACE, "123456", 0, 50, 1, 67, 162, 110, 106 /*text_row*/, 0, 14, 106, 148, 14 }, /* EAN-8 */ /* 27*/ { BARCODE_EANX, 0, EANUPC_GUARD_WHITESPACE, "123456", 0, 50, 1, 67, 162, 110, 106 /*text_row*/, 0, 14, 106, 148, 14 }, /* EAN-8 */
/* 28*/ { BARCODE_EANX, 1 /*empty*/, -1, "123456", 0, 50, 1, 67, 162, 116, 106 /*text_row*/, 0, 14, 106, 148, 14 }, /* EAN-8 */ /* 28*/ { BARCODE_EANX, 1 /*empty*/, -1, "123456", 0, 50, 1, 67, 162, 116, 106 /*text_row*/, 0, 14, 106, 148, 14 }, /* EAN-8 */
/* 29*/ { BARCODE_EANX, -1, -1, "123456+12", 0, 50, 1, 94, 212, 116, 106 /*text_row*/, 20, 58, 5, 148, 68 }, /* EAN-8 + EAN-2 */ /* 29*/ { BARCODE_EANX, -1, -1, "123456+12", 0, 50, 1, 94, 212, 116, 106 /*text_row*/, 20, 58, 5, 148, 68 }, /* EAN-8 + EAN-2 */
/* 30*/ { BARCODE_EANX, -1, BARCODE_RAW_TEXT, "123456+12", ZINT_WARN_HRT_RAW_TEXT, 50, 1, 94, 212, 116, 106 /*text_row*/, 20, 58, 5, 148, 68 }, /* EAN-8 + EAN-2 */ /* 30*/ { BARCODE_EANX, -1, BARCODE_RAW_TEXT, "123456+12", 0, 50, 1, 94, 212, 116, 106 /*text_row*/, 20, 58, 5, 148, 68 }, /* EAN-8 + EAN-2 */
/* 31*/ { BARCODE_EANX, 0, -1, "123456+12", 0, 50, 1, 94, 212, 110, 106 /*text_row*/, 20, 58, 5, 148, 68 }, /* EAN-8 + EAN-2 */ /* 31*/ { BARCODE_EANX, 0, -1, "123456+12", 0, 50, 1, 94, 212, 110, 106 /*text_row*/, 20, 58, 5, 148, 68 }, /* EAN-8 + EAN-2 */
/* 32*/ { BARCODE_EANX, -1, EANUPC_GUARD_WHITESPACE, "123456+12", 0, 50, 1, 94, 212, 116, 106 /*text_row*/, 0, 14, 6, 202, 8 }, /* EAN-8 + EAN-2 */ /* 32*/ { BARCODE_EANX, -1, EANUPC_GUARD_WHITESPACE, "123456+12", 0, 50, 1, 94, 212, 116, 106 /*text_row*/, 0, 14, 6, 202, 8 }, /* EAN-8 + EAN-2 */
/* 33*/ { BARCODE_EANX, 0, EANUPC_GUARD_WHITESPACE, "123456+12", 0, 50, 1, 94, 212, 110, 106 /*text_row*/, 0, 14, 6, 202, 8 }, /* EAN-8 + EAN-2 */ /* 33*/ { BARCODE_EANX, 0, EANUPC_GUARD_WHITESPACE, "123456+12", 0, 50, 1, 94, 212, 110, 106 /*text_row*/, 0, 14, 6, 202, 8 }, /* EAN-8 + EAN-2 */
/* 34*/ { BARCODE_EANX, 1 /*empty*/, -1, "123456+12", 0, 50, 1, 94, 212, 116, 106 /*text_row*/, 0, 14, 6, 202, 8 }, /* EAN-8 + EAN-2 */ /* 34*/ { BARCODE_EANX, 1 /*empty*/, -1, "123456+12", 0, 50, 1, 94, 212, 116, 106 /*text_row*/, 0, 14, 6, 202, 8 }, /* EAN-8 + EAN-2 */
/* 35*/ { BARCODE_EANX, -1, -1, "123456+12345", 0, 50, 1, 121, 266, 116, 106 /*text_row*/, 20, 58, 5, 148, 122 }, /* EAN-8 + EAN-5 */ /* 35*/ { BARCODE_EANX, -1, -1, "123456+12345", 0, 50, 1, 121, 266, 116, 106 /*text_row*/, 20, 58, 5, 148, 122 }, /* EAN-8 + EAN-5 */
/* 36*/ { BARCODE_EANX, -1, BARCODE_RAW_TEXT, "123456+12345", ZINT_WARN_HRT_RAW_TEXT, 50, 1, 121, 266, 116, 106 /*text_row*/, 20, 58, 5, 148, 122 }, /* EAN-8 + EAN-5 */ /* 36*/ { BARCODE_EANX, -1, BARCODE_RAW_TEXT, "123456+12345", 0, 50, 1, 121, 266, 116, 106 /*text_row*/, 20, 58, 5, 148, 122 }, /* EAN-8 + EAN-5 */
/* 37*/ { BARCODE_EANX, 0, -1, "123456+12345", 0, 50, 1, 121, 266, 110, 106 /*text_row*/, 20, 58, 5, 148, 122 }, /* EAN-8 + EAN-5 */ /* 37*/ { BARCODE_EANX, 0, -1, "123456+12345", 0, 50, 1, 121, 266, 110, 106 /*text_row*/, 20, 58, 5, 148, 122 }, /* EAN-8 + EAN-5 */
/* 38*/ { BARCODE_EANX, -1, EANUPC_GUARD_WHITESPACE, "123456+12345", 0, 50, 1, 121, 266, 116, 106 /*text_row*/, 0, 14, 6, 256, 10 }, /* EAN-8 + EAN-5 */ /* 38*/ { BARCODE_EANX, -1, EANUPC_GUARD_WHITESPACE, "123456+12345", 0, 50, 1, 121, 266, 116, 106 /*text_row*/, 0, 14, 6, 256, 10 }, /* EAN-8 + EAN-5 */
/* 39*/ { BARCODE_EANX, 0, EANUPC_GUARD_WHITESPACE, "123456+12345", 0, 50, 1, 121, 266, 110, 106 /*text_row*/, 0, 14, 6, 256, 10 }, /* EAN-8 + EAN-5 */ /* 39*/ { BARCODE_EANX, 0, EANUPC_GUARD_WHITESPACE, "123456+12345", 0, 50, 1, 121, 266, 110, 106 /*text_row*/, 0, 14, 6, 256, 10 }, /* EAN-8 + EAN-5 */
/* 40*/ { BARCODE_EANX, 1 /*empty*/, -1, "123456+12345", 0, 50, 1, 121, 266, 116, 106 /*text_row*/, 0, 14, 6, 256, 10 }, /* EAN-8 + EAN-5 */ /* 40*/ { BARCODE_EANX, 1 /*empty*/, -1, "123456+12345", 0, 50, 1, 121, 266, 116, 106 /*text_row*/, 0, 14, 6, 256, 10 }, /* EAN-8 + EAN-5 */
/* 41*/ { BARCODE_EANX, -1, -1, "1234", 0, 50, 1, 47, 104, 116, 0 /*text_row*/, 18, 5, -1, -1, -1 }, /* EAN-5 */ /* 41*/ { BARCODE_EANX, -1, -1, "1234", 0, 50, 1, 47, 104, 116, 0 /*text_row*/, 18, 5, -1, -1, -1 }, /* EAN-5 */
/* 42*/ { BARCODE_EANX, -1, BARCODE_RAW_TEXT, "1234", ZINT_WARN_HRT_RAW_TEXT, 50, 1, 47, 104, 116, 0 /*text_row*/, 18, 5, -1, -1, -1 }, /* EAN-5 */ /* 42*/ { BARCODE_EANX, -1, BARCODE_RAW_TEXT, "1234", 0, 50, 1, 47, 104, 116, 0 /*text_row*/, 18, 5, -1, -1, -1 }, /* EAN-5 */
/* 43*/ { BARCODE_EANX, 0, -1, "1234", 0, 50, 1, 47, 104, 100, -1 /*text_row*/, -1, -1, -1, -1, -1 }, /* EAN-5 */ /* 43*/ { BARCODE_EANX, 0, -1, "1234", 0, 50, 1, 47, 104, 100, -1 /*text_row*/, -1, -1, -1, -1, -1 }, /* EAN-5 */
/* 44*/ { BARCODE_EANX, -1, EANUPC_GUARD_WHITESPACE, "1234", 0, 50, 1, 47, 104, 116, 6 /*text_row*/, 94, 10, -1, -1, -1 }, /* EAN-5 */ /* 44*/ { BARCODE_EANX, -1, EANUPC_GUARD_WHITESPACE, "1234", 0, 50, 1, 47, 104, 116, 6 /*text_row*/, 94, 10, -1, -1, -1 }, /* EAN-5 */
/* 45*/ { BARCODE_EANX, 0, EANUPC_GUARD_WHITESPACE, "1234", 0, 50, 1, 47, 104, 100, -1 /*text_row*/, -1, -1, -1, -1, -1 }, /* EAN-5 */ /* 45*/ { BARCODE_EANX, 0, EANUPC_GUARD_WHITESPACE, "1234", 0, 50, 1, 47, 104, 100, -1 /*text_row*/, -1, -1, -1, -1, -1 }, /* EAN-5 */
/* 46*/ { BARCODE_EANX, 1 /*empty*/, -1, "1234", 0, 50, 1, 47, 104, 116, 6 /*text_row*/, 94, 10, -1, -1, -1 }, /* EAN-5 */ /* 46*/ { BARCODE_EANX, 1 /*empty*/, -1, "1234", 0, 50, 1, 47, 104, 116, 6 /*text_row*/, 94, 10, -1, -1, -1 }, /* EAN-5 */
/* 47*/ { BARCODE_EANX, -1, -1, "12", 0, 50, 1, 20, 50, 116, 0 /*text_row*/, 14, 2, -1, -1, -1 }, /* EAN-2 */ /* 47*/ { BARCODE_EANX, -1, -1, "12", 0, 50, 1, 20, 50, 116, 0 /*text_row*/, 14, 2, -1, -1, -1 }, /* EAN-2 */
/* 48*/ { BARCODE_EANX, -1, BARCODE_RAW_TEXT, "12", ZINT_WARN_HRT_RAW_TEXT, 50, 1, 20, 50, 116, 0 /*text_row*/, 14, 2, -1, -1, -1 }, /* EAN-2 */ /* 48*/ { BARCODE_EANX, -1, BARCODE_RAW_TEXT, "12", 0, 50, 1, 20, 50, 116, 0 /*text_row*/, 14, 2, -1, -1, -1 }, /* EAN-2 */
/* 49*/ { BARCODE_EANX, 0, -1, "12", 0, 50, 1, 20, 50, 100, -1 /*text_row*/, -1, -1, -1, -1, -1 }, /* EAN-2 */ /* 49*/ { BARCODE_EANX, 0, -1, "12", 0, 50, 1, 20, 50, 100, -1 /*text_row*/, -1, -1, -1, -1, -1 }, /* EAN-2 */
/* 50*/ { BARCODE_EANX, -1, EANUPC_GUARD_WHITESPACE, "12", 0, 50, 1, 20, 50, 116, 6 /*text_row*/, 40, 10, -1, -1, -1 }, /* EAN-2 */ /* 50*/ { BARCODE_EANX, -1, EANUPC_GUARD_WHITESPACE, "12", 0, 50, 1, 20, 50, 116, 6 /*text_row*/, 40, 10, -1, -1, -1 }, /* EAN-2 */
/* 51*/ { BARCODE_EANX, 0, EANUPC_GUARD_WHITESPACE, "12", 0, 50, 1, 20, 50, 100, -1 /*text_row*/, -1, -1, -1, -1, -1 }, /* EAN-2 */ /* 51*/ { BARCODE_EANX, 0, EANUPC_GUARD_WHITESPACE, "12", 0, 50, 1, 20, 50, 100, -1 /*text_row*/, -1, -1, -1, -1, -1 }, /* EAN-2 */
/* 52*/ { BARCODE_EANX, 1 /*empty*/, -1, "12", 0, 50, 1, 20, 50, 116, 6 /*text_row*/, 40, 10, -1, -1, -1 }, /* EAN-2 */ /* 52*/ { BARCODE_EANX, 1 /*empty*/, -1, "12", 0, 50, 1, 20, 50, 116, 6 /*text_row*/, 40, 10, -1, -1, -1 }, /* EAN-2 */
/* 53*/ { BARCODE_UPCA, -1, -1, "123456789012", 0, 50, 1, 95, 226, 116, 104 /*text_row*/, 0, 18, -1, -1, -1 }, /* 53*/ { BARCODE_UPCA, -1, -1, "123456789012", 0, 50, 1, 95, 226, 116, 104 /*text_row*/, 0, 18, -1, -1, -1 },
/* 54*/ { BARCODE_UPCA, -1, BARCODE_RAW_TEXT, "123456789012", ZINT_WARN_HRT_RAW_TEXT, 50, 1, 95, 226, 116, 104 /*text_row*/, 0, 18, -1, -1, -1 }, /* 54*/ { BARCODE_UPCA, -1, BARCODE_RAW_TEXT, "123456789012", 0, 50, 1, 95, 226, 116, 104 /*text_row*/, 0, 18, -1, -1, -1 },
/* 55*/ { BARCODE_UPCA, 0, -1, "123456789012", 0, 50, 1, 95, 226, 110, 104 /*text_row*/, 0, 18, -1, -1, -1 }, /* 55*/ { BARCODE_UPCA, 0, -1, "123456789012", 0, 50, 1, 95, 226, 110, 104 /*text_row*/, 0, 18, -1, -1, -1 },
/* 56*/ { BARCODE_UPCA, -1, -1, "123456789012+12", 0, 50, 1, 124, 276, 116, 104 /*text_row*/, 0, 18, 5, 208, 68 }, /* 56*/ { BARCODE_UPCA, -1, -1, "123456789012+12", 0, 50, 1, 124, 276, 116, 104 /*text_row*/, 0, 18, 5, 208, 68 },
/* 57*/ { BARCODE_UPCA, -1, BARCODE_RAW_TEXT, "123456789012+12", ZINT_WARN_HRT_RAW_TEXT, 50, 1, 124, 276, 116, 104 /*text_row*/, 0, 18, 5, 208, 68 }, /* 57*/ { BARCODE_UPCA, -1, BARCODE_RAW_TEXT, "123456789012+12", 0, 50, 1, 124, 276, 116, 104 /*text_row*/, 0, 18, 5, 208, 68 },
/* 58*/ { BARCODE_UPCA, 0, -1, "123456789012+12", 0, 50, 1, 124, 276, 110, 104 /*text_row*/, 0, 18, 5, 208, 68 }, /* 58*/ { BARCODE_UPCA, 0, -1, "123456789012+12", 0, 50, 1, 124, 276, 110, 104 /*text_row*/, 0, 18, 5, 208, 68 },
/* 59*/ { BARCODE_UPCA, -1, EANUPC_GUARD_WHITESPACE, "123456789012+12", 0, 50, 1, 124, 276, 116, 104 /*text_row*/, 0, 18, 5, 266, 10 }, /* 59*/ { BARCODE_UPCA, -1, EANUPC_GUARD_WHITESPACE, "123456789012+12", 0, 50, 1, 124, 276, 116, 104 /*text_row*/, 0, 18, 5, 266, 10 },
/* 60*/ { BARCODE_UPCA, 0, EANUPC_GUARD_WHITESPACE, "123456789012+12", 0, 50, 1, 124, 276, 110, 104 /*text_row*/, 0, 18, 5, 266, 10 }, /* 60*/ { BARCODE_UPCA, 0, EANUPC_GUARD_WHITESPACE, "123456789012+12", 0, 50, 1, 124, 276, 110, 104 /*text_row*/, 0, 18, 5, 266, 10 },
/* 61*/ { BARCODE_UPCA, 1 /*empty*/, -1, "123456789012+12", 0, 50, 1, 124, 276, 116, 5 /*text_row*/, 266, 10, -1, -1, -1 }, /* 61*/ { BARCODE_UPCA, 1 /*empty*/, -1, "123456789012+12", 0, 50, 1, 124, 276, 116, 5 /*text_row*/, 266, 10, -1, -1, -1 },
/* 62*/ { BARCODE_UPCA_CHK, -1, -1, "123456789012+12345", 0, 50, 1, 151, 330, 116, 104 /*text_row*/, 0, 18, 5, 208, 122 }, /* 62*/ { BARCODE_UPCA_CHK, -1, -1, "123456789012+12345", 0, 50, 1, 151, 330, 116, 104 /*text_row*/, 0, 18, 5, 208, 122 },
/* 63*/ { BARCODE_UPCA_CHK, -1, BARCODE_RAW_TEXT, "123456789012+12345", ZINT_WARN_HRT_RAW_TEXT, 50, 1, 151, 330, 116, 104 /*text_row*/, 0, 18, 5, 208, 122 }, /* 63*/ { BARCODE_UPCA_CHK, -1, BARCODE_RAW_TEXT, "123456789012+12345", 0, 50, 1, 151, 330, 116, 104 /*text_row*/, 0, 18, 5, 208, 122 },
/* 64*/ { BARCODE_UPCA_CHK, 0, -1, "123456789012+12345", 0, 50, 1, 151, 330, 110, 104 /*text_row*/, 0, 18, 5, 208, 122 }, /* 64*/ { BARCODE_UPCA_CHK, 0, -1, "123456789012+12345", 0, 50, 1, 151, 330, 110, 104 /*text_row*/, 0, 18, 5, 208, 122 },
/* 65*/ { BARCODE_UPCA_CHK, -1, EANUPC_GUARD_WHITESPACE, "123456789012+12345", 0, 50, 1, 151, 330, 116, 104 /*text_row*/, 0, 18, 6, 320, 10 }, /* 65*/ { BARCODE_UPCA_CHK, -1, EANUPC_GUARD_WHITESPACE, "123456789012+12345", 0, 50, 1, 151, 330, 116, 104 /*text_row*/, 0, 18, 6, 320, 10 },
/* 66*/ { BARCODE_UPCA_CHK, 0, EANUPC_GUARD_WHITESPACE, "123456789012+12345", 0, 50, 1, 151, 330, 110, 104 /*text_row*/, 0, 18, 6, 320, 10 }, /* 66*/ { BARCODE_UPCA_CHK, 0, EANUPC_GUARD_WHITESPACE, "123456789012+12345", 0, 50, 1, 151, 330, 110, 104 /*text_row*/, 0, 18, 6, 320, 10 },
/* 67*/ { BARCODE_UPCA_CHK, 1 /*empty*/, -1, "123456789012+12345", 0, 50, 1, 151, 330, 116, 6 /*text_row*/, 320, 10, -1, -1, -1 }, /* 67*/ { BARCODE_UPCA_CHK, 1 /*empty*/, -1, "123456789012+12345", 0, 50, 1, 151, 330, 116, 6 /*text_row*/, 320, 10, -1, -1, -1 },
/* 68*/ { BARCODE_UPCE, -1, -1, "1234567", 0, 50, 1, 51, 134, 116, 104 /*text_row*/, 0, 18, -1, -1, -1 }, /* 68*/ { BARCODE_UPCE, -1, -1, "1234567", 0, 50, 1, 51, 134, 116, 104 /*text_row*/, 0, 18, -1, -1, -1 },
/* 69*/ { BARCODE_UPCE, -1, BARCODE_RAW_TEXT, "1234567", ZINT_WARN_HRT_RAW_TEXT, 50, 1, 51, 134, 116, 104 /*text_row*/, 0, 18, -1, -1, -1 }, /* 69*/ { BARCODE_UPCE, -1, BARCODE_RAW_TEXT, "1234567", 0, 50, 1, 51, 134, 116, 104 /*text_row*/, 0, 18, -1, -1, -1 },
/* 70*/ { BARCODE_UPCE, 0, -1, "1234567", 0, 50, 1, 51, 134, 110, 104 /*text_row*/, 0, 18, -1, -1, -1 }, /* 70*/ { BARCODE_UPCE, 0, -1, "1234567", 0, 50, 1, 51, 134, 110, 104 /*text_row*/, 0, 18, -1, -1, -1 },
/* 71*/ { BARCODE_UPCE_CHK, -1, -1, "12345670+12", 0, 50, 1, 78, 184, 116, 104 /*text_row*/, 0, 18, 5, 120, 64 }, /* 71*/ { BARCODE_UPCE_CHK, -1, -1, "12345670+12", 0, 50, 1, 78, 184, 116, 104 /*text_row*/, 0, 18, 5, 120, 64 },
/* 72*/ { BARCODE_UPCE_CHK, -1, BARCODE_RAW_TEXT, "12345670+12", ZINT_WARN_HRT_RAW_TEXT, 50, 1, 78, 184, 116, 104 /*text_row*/, 0, 18, 5, 120, 64 }, /* 72*/ { BARCODE_UPCE_CHK, -1, BARCODE_RAW_TEXT, "12345670+12", 0, 50, 1, 78, 184, 116, 104 /*text_row*/, 0, 18, 5, 120, 64 },
/* 73*/ { BARCODE_UPCE_CHK, 0, -1, "12345670+12", 0, 50, 1, 78, 184, 110, 104 /*text_row*/, 0, 18, 5, 120, 64 }, /* 73*/ { BARCODE_UPCE_CHK, 0, -1, "12345670+12", 0, 50, 1, 78, 184, 110, 104 /*text_row*/, 0, 18, 5, 120, 64 },
/* 74*/ { BARCODE_UPCE_CHK, -1, EANUPC_GUARD_WHITESPACE, "12345670+12", 0, 50, 1, 78, 184, 116, 104 /*text_row*/, 0, 18, 6, 174, 10 }, /* 74*/ { BARCODE_UPCE_CHK, -1, EANUPC_GUARD_WHITESPACE, "12345670+12", 0, 50, 1, 78, 184, 116, 104 /*text_row*/, 0, 18, 6, 174, 10 },
/* 75*/ { BARCODE_UPCE_CHK, 0, EANUPC_GUARD_WHITESPACE, "12345670+12", 0, 50, 1, 78, 184, 110, 104 /*text_row*/, 0, 18, 6, 174, 10 }, /* 75*/ { BARCODE_UPCE_CHK, 0, EANUPC_GUARD_WHITESPACE, "12345670+12", 0, 50, 1, 78, 184, 110, 104 /*text_row*/, 0, 18, 6, 174, 10 },
/* 76*/ { BARCODE_UPCE_CHK, 1 /*empty*/, -1, "12345670+12", 0, 50, 1, 78, 184, 116, 6 /*text_row*/, 174, 10, -1, -1, -1 }, /* 76*/ { BARCODE_UPCE_CHK, 1 /*empty*/, -1, "12345670+12", 0, 50, 1, 78, 184, 116, 6 /*text_row*/, 174, 10, -1, -1, -1 },
/* 77*/ { BARCODE_UPCE, -1, -1, "1234567+12345", 0, 50, 1, 105, 238, 116, 104 /*text_row*/, 0, 18, 5, 120, 118 }, /* 77*/ { BARCODE_UPCE, -1, -1, "1234567+12345", 0, 50, 1, 105, 238, 116, 104 /*text_row*/, 0, 18, 5, 120, 118 },
/* 78*/ { BARCODE_UPCE, -1, BARCODE_RAW_TEXT, "1234567+12345", ZINT_WARN_HRT_RAW_TEXT, 50, 1, 105, 238, 116, 104 /*text_row*/, 0, 18, 5, 120, 118 }, /* 78*/ { BARCODE_UPCE, -1, BARCODE_RAW_TEXT, "1234567+12345", 0, 50, 1, 105, 238, 116, 104 /*text_row*/, 0, 18, 5, 120, 118 },
/* 79*/ { BARCODE_UPCE, 0, -1, "1234567+12345", 0, 50, 1, 105, 238, 110, 104 /*text_row*/, 0, 18, 5, 120, 118 }, /* 79*/ { BARCODE_UPCE, 0, -1, "1234567+12345", 0, 50, 1, 105, 238, 110, 104 /*text_row*/, 0, 18, 5, 120, 118 },
/* 80*/ { BARCODE_UPCE, -1, EANUPC_GUARD_WHITESPACE, "1234567+12345", 0, 50, 1, 105, 238, 116, 104 /*text_row*/, 0, 18, 6, 228, 10 }, /* 80*/ { BARCODE_UPCE, -1, EANUPC_GUARD_WHITESPACE, "1234567+12345", 0, 50, 1, 105, 238, 116, 104 /*text_row*/, 0, 18, 6, 228, 10 },
/* 81*/ { BARCODE_UPCE, 0, EANUPC_GUARD_WHITESPACE, "1234567+12345", 0, 50, 1, 105, 238, 110, 104 /*text_row*/, 0, 18, 6, 228, 10 }, /* 81*/ { BARCODE_UPCE, 0, EANUPC_GUARD_WHITESPACE, "1234567+12345", 0, 50, 1, 105, 238, 110, 104 /*text_row*/, 0, 18, 6, 228, 10 },
@ -552,7 +552,7 @@ static void test_upcean_hrt(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_upcean_hrt", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -669,7 +669,7 @@ static void test_row_separator(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_row_separator", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int j, separator_bits_set; int j, separator_bits_set;
@ -750,7 +750,7 @@ static void test_stacking(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_stacking", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int length2; int length2;
@ -814,7 +814,7 @@ static void test_stacking_too_many(const testCtx *const p_ctx) {
char data[] = "A"; char data[] = "A";
char expected_errtxt[] = "Error 770: Too many stacked symbols"; char expected_errtxt[] = "Error 770: Too many stacked symbols";
testStartSymbol("test_stacking_too_many", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
symbol = ZBarcode_Create(); symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n"); assert_nonnull(symbol, "Symbol not created\n");
@ -962,7 +962,7 @@ static void test_output_options(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_output_options", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -1049,7 +1049,7 @@ static void test_draw_string_wrap(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_draw_string_wrap", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int text_bits_set, row, column; int text_bits_set, row, column;
@ -1122,7 +1122,7 @@ static void test_code128_utf8(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_code128_utf8", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int text_bits_set, row, column; int text_bits_set, row, column;
@ -1288,7 +1288,7 @@ static void test_scale(const testCtx *const p_ctx) {
const char *text; const char *text;
testStartSymbol("test_scale", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int row, column; int row, column;
@ -1423,7 +1423,7 @@ static void test_guard_descent(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_guard_descent", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int row, column; int row, column;
@ -1821,7 +1821,7 @@ static void test_quiet_zones(const testCtx *const p_ctx) {
const char *text; const char *text;
static const char composite[] = "[20]12"; static const char composite[] = "[20]12";
testStartSymbol("test_quiet_zones", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int row, column; int row, column;
@ -1991,7 +1991,7 @@ static void test_text_gap(const testCtx *const p_ctx) {
const char *text; const char *text;
testStartSymbol("test_text_gap", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int row, column; int row, column;
@ -2185,7 +2185,7 @@ static void test_buffer_plot(const testCtx *const p_ctx) {
int row, column; int row, column;
int fg_len, bg_len; int fg_len, bg_len;
testStartSymbol("test_buffer_plot", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -2899,7 +2899,7 @@ static void test_height(const testCtx *const p_ctx) {
const char *text; const char *text;
testStartSymbol("test_height", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -3066,7 +3066,7 @@ static void test_height_per_row(const testCtx *const p_ctx) {
const char *text; const char *text;
testStartSymbol("test_height_per_row", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -3138,34 +3138,36 @@ static void test_hrt_raw_text(const testCtx *const p_ctx) {
int expected_bitmap_width; int expected_bitmap_width;
const char *expected; const char *expected;
int expected_length; int expected_length;
const char *expected_raw;
int expected_raw_length;
const char *expected_errtxt; const char *expected_errtxt;
}; };
static const struct item data[] = { static const struct item data[] = {
/* 0*/ { BARCODE_CODE128, -1, -1, BARCODE_MEMORY_FILE, "12345\00067890", 11, 0, 116, 268, "12345 67890", -1, "" }, /* 0*/ { BARCODE_CODE128, -1, -1, BARCODE_MEMORY_FILE, "12345\00067890", 11, 0, 116, 268, "12345 67890", -1, "", -1, "" },
/* 1*/ { BARCODE_CODE128, -1, -1, BARCODE_MEMORY_FILE | BARCODE_RAW_TEXT, "12345\00067890", 11, ZINT_WARN_HRT_RAW_TEXT, 116, 268, "12345\00067890", 11, "Warning 665: HRT outputted as raw text" }, /* 1*/ { BARCODE_CODE128, -1, -1, BARCODE_MEMORY_FILE | BARCODE_RAW_TEXT, "12345\00067890", 11, 0, 116, 268, "12345 67890", -1, "12345\00067890", 11, "" },
/* 2*/ { BARCODE_EXCODE39, -1, -1, BARCODE_MEMORY_FILE, "12345\00067890", 11, 0, 116, 362, "12345 67890", -1, "" }, /* 2*/ { BARCODE_EXCODE39, -1, -1, BARCODE_MEMORY_FILE, "12345\00067890", 11, 0, 116, 362, "12345 67890", -1, "", -1, "" },
/* 3*/ { BARCODE_EXCODE39, -1, -1, BARCODE_MEMORY_FILE | BARCODE_RAW_TEXT, "12345\00067890", 11, ZINT_WARN_HRT_RAW_TEXT, 116, 362, "12345\00067890", 11, "Warning 665: HRT outputted as raw text" }, /* 3*/ { BARCODE_EXCODE39, -1, -1, BARCODE_MEMORY_FILE | BARCODE_RAW_TEXT, "12345\00067890", 11, 0, 116, 362, "12345 67890", -1, "12345\00067890", 11, "" },
/* 4*/ { BARCODE_TELEPEN, -1, -1, BARCODE_MEMORY_FILE, "12345\00067890", 11, 0, 116, 448, "12345 67890", -1, "" }, /* 4*/ { BARCODE_TELEPEN, -1, -1, BARCODE_MEMORY_FILE, "12345\00067890", 11, 0, 116, 448, "12345 67890", -1, "", -1, "" },
/* 5*/ { BARCODE_TELEPEN, -1, -1, BARCODE_MEMORY_FILE | BARCODE_RAW_TEXT, "12345\00067890", 11, ZINT_WARN_HRT_RAW_TEXT, 116, 448, "12345\00067890n", 12, "Warning 665: HRT outputted as raw text" }, /* 5*/ { BARCODE_TELEPEN, -1, -1, BARCODE_MEMORY_FILE | BARCODE_RAW_TEXT, "12345\00067890", 11, 0, 116, 448, "12345 67890", -1, "12345\00067890n", 12, "" },
/* 6*/ { BARCODE_EANX, -1, -1, BARCODE_MEMORY_FILE, "123456789012", -1, 0, 116, 226, "1234567890128", -1, "" }, /* 6*/ { BARCODE_EANX, -1, -1, BARCODE_MEMORY_FILE, "123456789012", -1, 0, 116, 226, "1234567890128", -1, "", -1, "" },
/* 7*/ { BARCODE_EANX, -1, -1, BARCODE_MEMORY_FILE | BARCODE_RAW_TEXT, "123456789012", -1, ZINT_WARN_HRT_RAW_TEXT, 116, 226, "1234567890128", -1, "Warning 665: HRT outputted as raw text" }, /* Warn but no difference */ /* 7*/ { BARCODE_EANX, -1, -1, BARCODE_MEMORY_FILE | BARCODE_RAW_TEXT, "123456789012", -1, 0, 116, 226, "1234567890128", -1, "1234567890128", -1, "" },
/* 8*/ { BARCODE_EANX, -1, -1, BARCODE_MEMORY_FILE, "123456789012+12", -1, 0, 116, 276, "1234567890128+12", -1, "" }, /* 8*/ { BARCODE_EANX, -1, -1, BARCODE_MEMORY_FILE, "123456789012+12", -1, 0, 116, 276, "1234567890128+12", -1, "", -1, "" },
/* 9*/ { BARCODE_EANX, -1, -1, BARCODE_MEMORY_FILE | BARCODE_RAW_TEXT, "123456789012+12", -1, ZINT_WARN_HRT_RAW_TEXT, 116, 276, "1234567890128+12", -1, "Warning 665: HRT outputted as raw text" }, /* 9*/ { BARCODE_EANX, -1, -1, BARCODE_MEMORY_FILE | BARCODE_RAW_TEXT, "123456789012+12", -1, 0, 116, 276, "1234567890128+12", -1, "1234567890128+12", -1, "" },
/* 10*/ { BARCODE_CODE39, -1, -1, BARCODE_MEMORY_FILE, "ABC14", -1, 0, 116, 180, "*ABC14*", -1, "" }, /* 10*/ { BARCODE_CODE39, -1, -1, BARCODE_MEMORY_FILE, "ABC14", -1, 0, 116, 180, "*ABC14*", -1, "", -1, "" },
/* 11*/ { BARCODE_CODE39, -1, -1, BARCODE_MEMORY_FILE | BARCODE_RAW_TEXT, "ABC14", -1, ZINT_WARN_HRT_RAW_TEXT, 116, 180, "ABC14", -1, "Warning 665: HRT outputted as raw text" }, /* 11*/ { BARCODE_CODE39, -1, -1, BARCODE_MEMORY_FILE | BARCODE_RAW_TEXT, "ABC14", -1, 0, 116, 180, "*ABC14*", -1, "ABC14", -1, "" },
/* 12*/ { BARCODE_CODE39, -1, 1, BARCODE_MEMORY_FILE, "ABC14", -1, 0, 116, 206, "*ABC14_*", -1, "" }, /* Check digit space rendered as underscore */ /* 12*/ { BARCODE_CODE39, -1, 1, BARCODE_MEMORY_FILE, "ABC14", -1, 0, 116, 206, "*ABC14_*", -1, "", -1, "" }, /* Check digit space rendered as underscore */
/* 13*/ { BARCODE_CODE39, -1, 1, BARCODE_MEMORY_FILE | BARCODE_RAW_TEXT, "ABC14", -1, ZINT_WARN_HRT_RAW_TEXT, 116, 206, "ABC14 ", -1, "Warning 665: HRT outputted as raw text" }, /* 13*/ { BARCODE_CODE39, -1, 1, BARCODE_MEMORY_FILE | BARCODE_RAW_TEXT, "ABC14", -1, 0, 116, 206, "*ABC14_*", -1, "ABC14 ", -1, "" },
/* 14*/ { BARCODE_POSTNET, -1, -1, BARCODE_MEMORY_FILE, "12345", -1, 0, 24, 126, "", -1, "" }, /* 14*/ { BARCODE_POSTNET, -1, -1, BARCODE_MEMORY_FILE, "12345", -1, 0, 24, 126, "", -1, "", -1, "" },
/* 15*/ { BARCODE_POSTNET, -1, -1, BARCODE_MEMORY_FILE | BARCODE_RAW_TEXT, "12345", -1, ZINT_WARN_HRT_RAW_TEXT, 40, 126, "123455", -1, "Warning 665: HRT outputted as raw text" }, /* HRT printed */ /* 15*/ { BARCODE_POSTNET, -1, -1, BARCODE_MEMORY_FILE | BARCODE_RAW_TEXT, "12345", -1, 0, 24, 126, "", -1, "123455", -1, "" }, /* HRT not printed */
/* 16*/ { BARCODE_POSTNET, 0, -1, BARCODE_MEMORY_FILE, "12345", -1, 0, 24, 126, "", -1, "" }, /* 16*/ { BARCODE_POSTNET, 0, -1, BARCODE_MEMORY_FILE, "12345", -1, 0, 24, 126, "", -1, "", -1, "" },
/* 17*/ { BARCODE_POSTNET, 0, -1, BARCODE_MEMORY_FILE | BARCODE_RAW_TEXT, "12345", -1, 0, 24, 126, "123455", -1, "" }, /* HRT not printed, no warning */ /* 17*/ { BARCODE_POSTNET, 0, -1, BARCODE_MEMORY_FILE | BARCODE_RAW_TEXT, "12345", -1, 0, 24, 126, "", -1, "123455", -1, "" }, /* HRT not printed */
}; };
const int data_size = ARRAY_SIZE(data); const int data_size = ARRAY_SIZE(data);
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
int expected_length; int expected_length, expected_raw_length;
testStartSymbol("test_hrt_raw_text", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -3182,6 +3184,7 @@ static void test_hrt_raw_text(const testCtx *const p_ctx) {
-1 /*option_1*/, data[i].option_2, -1 /*option_3*/, data[i].output_options, -1 /*option_1*/, data[i].option_2, -1 /*option_3*/, data[i].output_options,
data[i].data, data[i].length, debug); data[i].data, data[i].length, debug);
expected_length = data[i].expected_length == -1 ? (int) strlen(data[i].expected) : data[i].expected_length; expected_length = data[i].expected_length == -1 ? (int) strlen(data[i].expected) : data[i].expected_length;
expected_raw_length = data[i].expected_raw_length == -1 ? (int) strlen(data[i].expected_raw) : data[i].expected_raw_length;
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_zero(ret, "i:%d ZBarcode_Encode(%s) ret %d != 0 (%s)\n", assert_zero(ret, "i:%d ZBarcode_Encode(%s) ret %d != 0 (%s)\n",
@ -3191,6 +3194,19 @@ static void test_hrt_raw_text(const testCtx *const p_ctx) {
i, symbol->text_length, expected_length, symbol->text); i, symbol->text_length, expected_length, symbol->text);
assert_zero(memcmp(symbol->text, data[i].expected, expected_length), "i:%d memcmp(%s, %s, %d) != 0\n", assert_zero(memcmp(symbol->text, data[i].expected, expected_length), "i:%d memcmp(%s, %s, %d) != 0\n",
i, symbol->text, data[i].expected, expected_length); i, symbol->text, data[i].expected, expected_length);
if (symbol->output_options & BARCODE_RAW_TEXT) {
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
assert_nonnull(symbol->raw_segs[0].source, "i:%d raw_segs[0].source NULL\n", i);
assert_equal(symbol->raw_segs[0].length, expected_raw_length,
"i:%d raw_segs[0].length %d != expected_raw_length %d\n",
i, symbol->raw_segs[0].length, expected_raw_length);
assert_zero(memcmp(symbol->raw_segs[0].source, data[i].expected_raw, expected_raw_length),
"i:%d memcmp(%.*s, %.*s, %d) != 0\n",
i, symbol->raw_segs[0].length, symbol->raw_segs[0].source, expected_raw_length,
data[i].expected_raw, expected_raw_length);
} else {
assert_null(symbol->raw_segs, "i:%d raw_segs not NULL\n", i);
}
ret = ZBarcode_Print(symbol, 0); ret = ZBarcode_Print(symbol, 0);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Print(%s) ret %d != %d (%s)\n", assert_equal(ret, data[i].ret, "i:%d ZBarcode_Print(%s) ret %d != %d (%s)\n",

View file

@ -147,7 +147,7 @@ static void test_encoding(const testCtx *const p_ctx) {
int data_size = ARRAY_SIZE(data); int data_size = ARRAY_SIZE(data);
int i; int i;
testStart("test_encoding"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int j; int j;
@ -210,7 +210,7 @@ static void test_encoding_uint(const testCtx *const p_ctx) {
int data_size = ARRAY_SIZE(data); int data_size = ARRAY_SIZE(data);
int i; int i;
testStart("test_encoding_uint"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int j; int j;
@ -259,7 +259,7 @@ static void test_uint_encoding(const testCtx *const p_ctx) {
int data_size = ARRAY_SIZE(data); int data_size = ARRAY_SIZE(data);
int i; int i;
testStart("test_uint_encoding"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int j; int j;

View file

@ -127,10 +127,11 @@ static void test_binary_div_modulo_divisor(const testCtx *const p_ctx) {
char cmp_buf[1024]; char cmp_buf[1024];
char cmp_msg[1024]; char cmp_msg[1024];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ /* Only do BWIPP/ZXing-C++ tests if asked, too slow otherwise */
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript();
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder();
testStartSymbol("test_binary_div_modulo_divisor", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -178,12 +179,14 @@ static void test_binary_div_modulo_divisor(const testCtx *const p_ctx) {
int cmp_len, ret_len; int cmp_len, ret_len;
char modules_dump[8192 + 1]; char modules_dump[8192 + 1];
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i);
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, 1 /*zxingcpp_cmp*/, cmp_buf, sizeof(cmp_buf), &cmp_len);
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len); ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/,
escaped, &ret_len);
assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n",
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, escaped); i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len,
escaped);
} }
} }
@ -869,10 +872,11 @@ static void test_examples(const testCtx *const p_ctx) {
char cmp_buf[16384]; char cmp_buf[16384];
char cmp_msg[1024]; char cmp_msg[1024];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ /* Only do BWIPP/ZXing-C++ tests if asked, too slow otherwise */
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript();
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder();
testStartSymbol("test_examples", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -918,12 +922,14 @@ static void test_examples(const testCtx *const p_ctx) {
int cmp_len, ret_len; int cmp_len, ret_len;
char modules_dump[8192 + 1]; char modules_dump[8192 + 1];
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i);
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, 1 /*zxingcpp_cmp*/, cmp_buf, sizeof(cmp_buf), &cmp_len);
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len); ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/,
escaped, &ret_len);
assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n",
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, escaped); i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len,
escaped);
} }
} }
@ -1199,7 +1205,7 @@ static void test_general_field(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_general_field", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -1265,7 +1271,7 @@ static void test_binary_buffer_size(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_binary_buffer_size", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -1306,34 +1312,35 @@ static void test_hrt(const testCtx *const p_ctx) {
int ret; int ret;
const char *expected; const char *expected;
const char *expected_raw;
}; };
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = { static const struct item data[] = {
/* 0*/ { BARCODE_DBAR_OMN, -1, "1234567890123", 0, "(01)12345678901231" }, /* 0*/ { BARCODE_DBAR_OMN, -1, "1234567890123", 0, "(01)12345678901231", "" },
/* 1*/ { BARCODE_DBAR_OMN, BARCODE_RAW_TEXT, "1234567890123", 0, "0112345678901231" }, /* 1*/ { BARCODE_DBAR_OMN, BARCODE_RAW_TEXT, "1234567890123", 0, "(01)12345678901231", "12345678901231" }, /* Implicit "01" not included in raw text */
/* 2*/ { BARCODE_DBAR_OMN, -1, "12345678901231", 0, "(01)12345678901231" }, /* 2*/ { BARCODE_DBAR_OMN, -1, "12345678901231", 0, "(01)12345678901231", "" },
/* 3*/ { BARCODE_DBAR_OMN, BARCODE_RAW_TEXT, "12345678901231", 0, "0112345678901231" }, /* 3*/ { BARCODE_DBAR_OMN, BARCODE_RAW_TEXT, "12345678901231", 0, "(01)12345678901231", "12345678901231" },
/* 4*/ { BARCODE_DBAR_OMN, -1, "1000000000009", 0, "(01)10000000000090" }, /* 4*/ { BARCODE_DBAR_OMN, -1, "1000000000009", 0, "(01)10000000000090", "" },
/* 5*/ { BARCODE_DBAR_OMN, BARCODE_RAW_TEXT, "1000000000009", 0, "0110000000000090" }, /* 5*/ { BARCODE_DBAR_OMN, BARCODE_RAW_TEXT, "1000000000009", 0, "(01)10000000000090", "10000000000090" },
/* 6*/ { BARCODE_DBAR_LTD, -1, "1341056790138", 0, "(01)13410567901384" }, /* 6*/ { BARCODE_DBAR_LTD, -1, "1341056790138", 0, "(01)13410567901384", "" },
/* 7*/ { BARCODE_DBAR_LTD, BARCODE_RAW_TEXT, "1341056790138", 0, "0113410567901384" }, /* 7*/ { BARCODE_DBAR_LTD, BARCODE_RAW_TEXT, "1341056790138", 0, "(01)13410567901384", "13410567901384" }, /* Implicit "01" not included in raw text */
/* 8*/ { BARCODE_DBAR_LTD, -1, "13410567901384", 0, "(01)13410567901384" }, /* 8*/ { BARCODE_DBAR_LTD, -1, "13410567901384", 0, "(01)13410567901384", "" },
/* 9*/ { BARCODE_DBAR_LTD, BARCODE_RAW_TEXT, "13410567901384", 0, "0113410567901384" }, /* 9*/ { BARCODE_DBAR_LTD, BARCODE_RAW_TEXT, "13410567901384", 0, "(01)13410567901384", "13410567901384" },
/* 10*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231", 0, "(01)12345678901231" }, /* See test_hrt() in "test_gs1.c" for full HRT tests */ /* 10*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231", 0, "(01)12345678901231", "" }, /* See test_hrt() in "test_gs1.c" for full HRT tests */
/* 11*/ { BARCODE_DBAR_EXP, BARCODE_RAW_TEXT, "[01]12345678901231", 0, "0112345678901231" }, /* 11*/ { BARCODE_DBAR_EXP, BARCODE_RAW_TEXT, "[01]12345678901231", 0, "(01)12345678901231", "0112345678901231" },
/* 12*/ { BARCODE_DBAR_STK, -1, "12345678901231", 0, "" }, /* No HRT for stacked */ /* 12*/ { BARCODE_DBAR_STK, -1, "12345678901231", 0, "", "" }, /* No HRT for stacked */
/* 13*/ { BARCODE_DBAR_STK, BARCODE_RAW_TEXT, "12345678901231", 0, "0112345678901231" }, /* Unless RAW_TEXT */ /* 13*/ { BARCODE_DBAR_STK, BARCODE_RAW_TEXT, "12345678901231", 0, "", "12345678901231" }, /* But have RAW_TEXT */
/* 14*/ { BARCODE_DBAR_OMNSTK, -1, "10000000000090", 0, "" }, /* 14*/ { BARCODE_DBAR_OMNSTK, -1, "10000000000090", 0, "", "" },
/* 15*/ { BARCODE_DBAR_OMNSTK, BARCODE_RAW_TEXT, "10000000000090", 0, "0110000000000090" }, /* 15*/ { BARCODE_DBAR_OMNSTK, BARCODE_RAW_TEXT, "10000000000090", 0, "", "10000000000090" },
/* 16*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231", 0, "" }, /* 16*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231", 0, "", "" },
/* 17*/ { BARCODE_DBAR_EXPSTK, BARCODE_RAW_TEXT, "[01]12345678901231", 0, "0112345678901231" }, /* 17*/ { BARCODE_DBAR_EXPSTK, BARCODE_RAW_TEXT, "[01]12345678901231", 0, "", "0112345678901231" },
}; };
const int data_size = ARRAY_SIZE(data); const int data_size = ARRAY_SIZE(data);
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
int expected_length; int expected_length, expected_raw_length;
testStartSymbol("test_hrt", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -1346,6 +1353,7 @@ static void test_hrt(const testCtx *const p_ctx) {
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options, -1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options,
data[i].data, -1, debug); data[i].data, -1, debug);
expected_length = (int) strlen(data[i].expected); expected_length = (int) strlen(data[i].expected);
expected_raw_length = (int) strlen(data[i].expected_raw);
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, data[i].ret, ret, symbol->errtxt); assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, data[i].ret, ret, symbol->errtxt);
@ -1354,6 +1362,18 @@ static void test_hrt(const testCtx *const p_ctx) {
i, symbol->text_length, expected_length); i, symbol->text_length, expected_length);
assert_zero(strcmp((const char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", assert_zero(strcmp((const char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
i, symbol->text, data[i].expected); i, symbol->text, data[i].expected);
if (symbol->output_options & BARCODE_RAW_TEXT) {
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
assert_nonnull(symbol->raw_segs[0].source, "i:%d raw_segs[0].source NULL\n", i);
assert_equal(symbol->raw_segs[0].length, expected_raw_length,
"i:%d raw_segs[0].length %d != expected_raw_length %d\n",
i, symbol->raw_segs[0].length, expected_raw_length);
assert_zero(memcmp(symbol->raw_segs[0].source, data[i].expected_raw, expected_raw_length),
"i:%d memcmp(%s, %s, %d) != 0\n",
i, symbol->raw_segs[0].source, data[i].expected_raw, expected_raw_length);
} else {
assert_null(symbol->raw_segs, "i:%d raw_segs not NULL\n", i);
}
ZBarcode_Delete(symbol); ZBarcode_Delete(symbol);
} }
@ -1374,126 +1394,128 @@ static void test_input(const testCtx *const p_ctx) {
int expected_rows; int expected_rows;
int expected_width; int expected_width;
const char *expected_errtxt; const char *expected_errtxt;
int expected_option_2;
int expected_option_3;
}; };
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = { static const struct item data[] = {
/* 0*/ { BARCODE_DBAR_OMN, -1, -1, -1, "1234567890123", 0, 1, 96, "" }, /* 0*/ { BARCODE_DBAR_OMN, -1, -1, -1, "1234567890123", 0, 1, 96, "", 0, 0 },
/* 1*/ { BARCODE_DBAR_OMN, -1, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 13 in input (digits only)" }, /* 1*/ { BARCODE_DBAR_OMN, -1, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 13 in input (digits only)", 0, 0 },
/* 2*/ { BARCODE_DBAR_OMN, GS1NOCHECK_MODE, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 13 in input (digits only)" }, /* 2*/ { BARCODE_DBAR_OMN, GS1NOCHECK_MODE, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 13 in input (digits only)", 0, 0 },
/* 3*/ { BARCODE_DBAR_OMN, -1, -1, -1, "12345678901234", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '4', expecting '1'" }, /* 3*/ { BARCODE_DBAR_OMN, -1, -1, -1, "12345678901234", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '4', expecting '1'", 0, 0 },
/* 4*/ { BARCODE_DBAR_OMN, GS1NOCHECK_MODE, -1, -1, "12345678901234", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '4', expecting '1'" }, /* Still checked */ /* 4*/ { BARCODE_DBAR_OMN, GS1NOCHECK_MODE, -1, -1, "12345678901234", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '4', expecting '1'", 0, 0 }, /* Still checked */
/* 5*/ { BARCODE_DBAR_OMN, -1, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14)" }, /* 5*/ { BARCODE_DBAR_OMN, -1, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14)", 0, 0 },
/* 6*/ { BARCODE_DBAR_OMN, GS1NOCHECK_MODE, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14)" }, /* 6*/ { BARCODE_DBAR_OMN, GS1NOCHECK_MODE, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14)", 0, 0 },
/* 7*/ { BARCODE_DBAR_LTD, -1, -1, -1, "1234567890123", 0, 1, 79, "" }, /* 7*/ { BARCODE_DBAR_LTD, -1, -1, -1, "1234567890123", 0, 1, 79, "", 0, 0 },
/* 8*/ { BARCODE_DBAR_LTD, -1, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 383: Invalid character at position 13 in input (digits only)" }, /* 8*/ { BARCODE_DBAR_LTD, -1, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 383: Invalid character at position 13 in input (digits only)", 0, 0 },
/* 9*/ { BARCODE_DBAR_LTD, GS1NOCHECK_MODE, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 383: Invalid character at position 13 in input (digits only)" }, /* 9*/ { BARCODE_DBAR_LTD, GS1NOCHECK_MODE, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 383: Invalid character at position 13 in input (digits only)", 0, 0 },
/* 10*/ { BARCODE_DBAR_LTD, -1, -1, -1, "12345678901235", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 389: Invalid check digit '5', expecting '1'" }, /* 10*/ { BARCODE_DBAR_LTD, -1, -1, -1, "12345678901235", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 389: Invalid check digit '5', expecting '1'", 0, 0 },
/* 11*/ { BARCODE_DBAR_LTD, GS1NOCHECK_MODE, -1, -1, "12345678901235", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 389: Invalid check digit '5', expecting '1'" }, /* Still checked */ /* 11*/ { BARCODE_DBAR_LTD, GS1NOCHECK_MODE, -1, -1, "12345678901235", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 389: Invalid check digit '5', expecting '1'", 0, 0 }, /* Still checked */
/* 12*/ { BARCODE_DBAR_LTD, -1, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 382: Input length 15 too long (maximum 14)" }, /* 12*/ { BARCODE_DBAR_LTD, -1, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 382: Input length 15 too long (maximum 14)", 0, 0 },
/* 13*/ { BARCODE_DBAR_LTD, GS1NOCHECK_MODE, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 382: Input length 15 too long (maximum 14)" }, /* 13*/ { BARCODE_DBAR_LTD, GS1NOCHECK_MODE, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 382: Input length 15 too long (maximum 14)", 0, 0 },
/* 14*/ { BARCODE_DBAR_LTD, -1, -1, -1, "2234567890123", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 384: Input value out of range (0 to 1999999999999)" }, /* 14*/ { BARCODE_DBAR_LTD, -1, -1, -1, "2234567890123", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 384: Input value out of range (0 to 1999999999999)", 0, 0 },
/* 15*/ { BARCODE_DBAR_LTD, GS1NOCHECK_MODE, -1, -1, "2234567890123", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 384: Input value out of range (0 to 1999999999999)" }, /* 15*/ { BARCODE_DBAR_LTD, GS1NOCHECK_MODE, -1, -1, "2234567890123", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 384: Input value out of range (0 to 1999999999999)", 0, 0 },
/* 16*/ { BARCODE_DBAR_LTD, -1, -1, -1, "22345678901238", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 384: Input value out of range (0 to 1999999999999)" }, /* 16*/ { BARCODE_DBAR_LTD, -1, -1, -1, "22345678901238", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 384: Input value out of range (0 to 1999999999999)", 0, 0 },
/* 17*/ { BARCODE_DBAR_LTD, GS1NOCHECK_MODE, -1, -1, "22345678901238", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 384: Input value out of range (0 to 1999999999999)" }, /* 17*/ { BARCODE_DBAR_LTD, GS1NOCHECK_MODE, -1, -1, "22345678901238", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 384: Input value out of range (0 to 1999999999999)", 0, 0 },
/* 18*/ { BARCODE_DBAR_EXP, -1, -1, -1, "[01]12345678901234", ZINT_WARN_NONCOMPLIANT, 1, 134, "Warning 261: AI (01) position 14: Bad checksum '4', expected '1'" }, /* 18*/ { BARCODE_DBAR_EXP, -1, -1, -1, "[01]12345678901234", ZINT_WARN_NONCOMPLIANT, 1, 134, "Warning 261: AI (01) position 14: Bad checksum '4', expected '1'", 0, 0 },
/* 19*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, -1, "[01]12345678901234", 0, 1, 134, "" }, /* 19*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, -1, "[01]12345678901234", 0, 1, 134, "", 0, 0 },
/* 20*/ { BARCODE_DBAR_EXP, -1, -1, -1, "[01]12345678901231", 0, 1, 134, "" }, /* 20*/ { BARCODE_DBAR_EXP, -1, -1, -1, "[01]12345678901231", 0, 1, 134, "", 0, 0 },
/* 21*/ { BARCODE_DBAR_EXP, -1, -1, -1, "[01]1234567890123A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 385: Invalid character in Compressed Field data (digits only)" }, /* 21*/ { BARCODE_DBAR_EXP, -1, -1, -1, "[01]1234567890123A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 385: Invalid character in Compressed Field data (digits only)", 0, 0 },
/* 22*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, -1, "[01]1234567890123A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 385: Invalid character in Compressed Field data (digits only)" }, /* 22*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, -1, "[01]1234567890123A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 385: Invalid character in Compressed Field data (digits only)", 0, 0 },
/* 23*/ { BARCODE_DBAR_EXP, -1, -1, -1, "[01]123456789012315", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 259: Invalid data length for AI (01)" }, /* 23*/ { BARCODE_DBAR_EXP, -1, -1, -1, "[01]123456789012315", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 259: Invalid data length for AI (01)", 0, 0 },
/* 24*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, -1, "[01]123456789012315", 0, 1, 151, "" }, /* 24*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, -1, "[01]123456789012315", 0, 1, 151, "", 0, 0 },
/* 25*/ { BARCODE_DBAR_EXP, -1, -1, -1, "[01]12345678901234", ZINT_WARN_NONCOMPLIANT, 1, 134, "Warning 261: AI (01) position 14: Bad checksum '4', expected '1'" }, /* 25*/ { BARCODE_DBAR_EXP, -1, -1, -1, "[01]12345678901234", ZINT_WARN_NONCOMPLIANT, 1, 134, "Warning 261: AI (01) position 14: Bad checksum '4', expected '1'", 0, 0 },
/* 26*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, -1, "[01]12345678901234", 0, 1, 134, "" }, /* 26*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, -1, "[01]12345678901234", 0, 1, 134, "", 0, 0 },
/* 27*/ { BARCODE_DBAR_EXP, -1, -1, -1, "[01]12345678901231[91]!\"%&'()*+,-./:;<=>?_ ", ZINT_WARN_NONCOMPLIANT, 1, 526, "Warning 261: AI (91) position 21: Invalid CSET 82 character ' '" }, /* ISOIEC punc */ /* 27*/ { BARCODE_DBAR_EXP, -1, -1, -1, "[01]12345678901231[91]!\"%&'()*+,-./:;<=>?_ ", ZINT_WARN_NONCOMPLIANT, 1, 526, "Warning 261: AI (91) position 21: Invalid CSET 82 character ' '", 0, 0 }, /* ISOIEC punc */
/* 28*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, -1, "[01]12345678901231[91]!\"%&'()*+,-./:;<=>?_ ", 0, 1, 526, "" }, /* 28*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, -1, "[01]12345678901231[91]!\"%&'()*+,-./:;<=>?_ ", 0, 1, 526, "", 0, 0 },
/* 29*/ { BARCODE_DBAR_EXP, -1, -1, -1, "[01]12345678901231[91]!\"%&'()*+,-./:;<=>?_", 0, 1, 494, "" }, /* ISOIEC punc less space */ /* 29*/ { BARCODE_DBAR_EXP, -1, -1, -1, "[01]12345678901231[91]!\"%&'()*+,-./:;<=>?_", 0, 1, 494, "", 0, 0 }, /* ISOIEC punc less space */
/* 30*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, -1, "[01]12345678901231[91]!\"%&'()*+,-./:;<=>?_", 0, 1, 494, "" }, /* 30*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, -1, "[01]12345678901231[91]!\"%&'()*+,-./:;<=>?_", 0, 1, 494, "", 0, 0 },
/* 31*/ { BARCODE_DBAR_STK, -1, -1, -1, "1234567890123", 0, 3, 50, "" }, /* 31*/ { BARCODE_DBAR_STK, -1, -1, -1, "1234567890123", 0, 3, 50, "", 0, 0 },
/* 32*/ { BARCODE_DBAR_STK, GS1NOCHECK_MODE, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 13 in input (digits only)" }, /* 32*/ { BARCODE_DBAR_STK, GS1NOCHECK_MODE, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 13 in input (digits only)", 0, 0 },
/* 33*/ { BARCODE_DBAR_STK, -1, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 13 in input (digits only)" }, /* 33*/ { BARCODE_DBAR_STK, -1, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 13 in input (digits only)", 0, 0 },
/* 34*/ { BARCODE_DBAR_STK, GS1NOCHECK_MODE, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 13 in input (digits only)" }, /* 34*/ { BARCODE_DBAR_STK, GS1NOCHECK_MODE, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 13 in input (digits only)", 0, 0 },
/* 35*/ { BARCODE_DBAR_STK, -1, -1, -1, "12345678901235", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '5', expecting '1'" }, /* 35*/ { BARCODE_DBAR_STK, -1, -1, -1, "12345678901235", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '5', expecting '1'", 0, 0 },
/* 36*/ { BARCODE_DBAR_STK, GS1NOCHECK_MODE, -1, -1, "12345678901235", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '5', expecting '1'" }, /* Still checked */ /* 36*/ { BARCODE_DBAR_STK, GS1NOCHECK_MODE, -1, -1, "12345678901235", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '5', expecting '1'", 0, 0 }, /* Still checked */
/* 37*/ { BARCODE_DBAR_STK, -1, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14)" }, /* 37*/ { BARCODE_DBAR_STK, -1, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14)", 0, 0 },
/* 38*/ { BARCODE_DBAR_STK, GS1NOCHECK_MODE, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14)" }, /* 38*/ { BARCODE_DBAR_STK, GS1NOCHECK_MODE, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14)", 0, 0 },
/* 39*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, "1234567890123", 0, 5, 50, "" }, /* 39*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, "1234567890123", 0, 5, 50, "", 0, 0 },
/* 40*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 13 in input (digits only)" }, /* 40*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 13 in input (digits only)", 0, 0 },
/* 41*/ { BARCODE_DBAR_OMNSTK, GS1NOCHECK_MODE, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 13 in input (digits only)" }, /* 41*/ { BARCODE_DBAR_OMNSTK, GS1NOCHECK_MODE, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 13 in input (digits only)", 0, 0 },
/* 42*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, "12345678901236", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '6', expecting '1'" }, /* 42*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, "12345678901236", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '6', expecting '1'", 0, 0 },
/* 43*/ { BARCODE_DBAR_OMNSTK, GS1NOCHECK_MODE, -1, -1, "12345678901236", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '6', expecting '1'" }, /* Still checked */ /* 43*/ { BARCODE_DBAR_OMNSTK, GS1NOCHECK_MODE, -1, -1, "12345678901236", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '6', expecting '1'", 0, 0 }, /* Still checked */
/* 44*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14)" }, /* 44*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14)", 0, 0 },
/* 45*/ { BARCODE_DBAR_OMNSTK, GS1NOCHECK_MODE, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14)" }, /* 45*/ { BARCODE_DBAR_OMNSTK, GS1NOCHECK_MODE, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14)", 0, 0 },
/* 46*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, "[01]12345678901234", ZINT_WARN_NONCOMPLIANT, 5, 102, "Warning 261: AI (01) position 14: Bad checksum '4', expected '1'" }, /* 46*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, "[01]12345678901234", ZINT_WARN_NONCOMPLIANT, 5, 102, "Warning 261: AI (01) position 14: Bad checksum '4', expected '1'", 2, 0 },
/* 47*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, -1, -1, "[01]12345678901234", 0, 5, 102, "" }, /* 47*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, -1, -1, "[01]12345678901234", 0, 5, 102, "", 2, 0 },
/* 48*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, "[01]12345678901231", 0, 5, 102, "" }, /* 48*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, "[01]12345678901231", 0, 5, 102, "", 2, 0 },
/* 49*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, "[01]1234567890123A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 385: Invalid character in Compressed Field data (digits only)" }, /* 49*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, "[01]1234567890123A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 385: Invalid character in Compressed Field data (digits only)", 0, 0 },
/* 50*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, -1, -1, "[01]1234567890123A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 385: Invalid character in Compressed Field data (digits only)" }, /* 50*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, -1, -1, "[01]1234567890123A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 385: Invalid character in Compressed Field data (digits only)", 0, 0 },
/* 51*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, "[01]123456789012315", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 259: Invalid data length for AI (01)" }, /* 51*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, "[01]123456789012315", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 259: Invalid data length for AI (01)", 0, 0 },
/* 52*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, -1, -1, "[01]123456789012315", 0, 5, 102, "" }, /* 52*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, -1, -1, "[01]123456789012315", 0, 5, 102, "", 2, 0 },
/* 53*/ { BARCODE_DBAR_EXPSTK, -1, 12, -1, "[01]12345678901231", 0, 5, 102, "" }, /* Cols > 11 ignored */ /* 53*/ { BARCODE_DBAR_EXPSTK, -1, 12, -1, "[01]12345678901231", 0, 5, 102, "", 2, 0 }, /* Cols > 11 ignored */
/* 54*/ { BARCODE_DBAR_EXPSTK, -1, -1, 12, "[01]12345678901231", 0, 5, 102, "" }, /* Rows > 11 ignored */ /* 54*/ { BARCODE_DBAR_EXPSTK, -1, -1, 12, "[01]12345678901231", 0, 5, 102, "", 2, 0 }, /* Rows > 11 ignored */
/* 55*/ { BARCODE_DBAR_EXPSTK, -1, 1, -1, "[01]12345678901231", 0, 9, 53, "" }, /* 55*/ { BARCODE_DBAR_EXPSTK, -1, 1, -1, "[01]12345678901231", 0, 9, 53, "", 1, 0 },
/* 56*/ { BARCODE_DBAR_EXPSTK, -1, 2, -1, "[01]12345678901231", 0, 5, 102, "" }, /* 56*/ { BARCODE_DBAR_EXPSTK, -1, 2, -1, "[01]12345678901231", 0, 5, 102, "", 2, 0 },
/* 57*/ { BARCODE_DBAR_EXPSTK, -1, 3, -1, "[01]12345678901231", 0, 1, 134, "" }, /* 57*/ { BARCODE_DBAR_EXPSTK, -1, 3, -1, "[01]12345678901231", 0, 1, 134, "", 3, 0 },
/* 58*/ { BARCODE_DBAR_EXPSTK, -1, 4, -1, "[01]12345678901231", 0, 1, 134, "" }, /* 58*/ { BARCODE_DBAR_EXPSTK, -1, 4, -1, "[01]12345678901231", 0, 1, 134, "", 4, 0 },
/* 59*/ { BARCODE_DBAR_EXPSTK, -1, -1, 2, "[01]12345678901231", 0, 5, 102, "" }, /* 59*/ { BARCODE_DBAR_EXPSTK, -1, -1, 2, "[01]12345678901231", 0, 5, 102, "", 2, 2 },
/* 60*/ { BARCODE_DBAR_EXPSTK, -1, -1, 3, "[01]12345678901231", 0, 5, 102, "" }, /* 60*/ { BARCODE_DBAR_EXPSTK, -1, -1, 3, "[01]12345678901231", 0, 5, 102, "", 2, 3 },
/* 61*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, "[8110]106141416543213500110000310123196000", 0, 13, 102, "" }, /* 61*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, "[8110]106141416543213500110000310123196000", 0, 13, 102, "", 2, 0 },
/* 62*/ { BARCODE_DBAR_EXPSTK, -1, 1, -1, "[8110]106141416543213500110000310123196000", 0, 25, 53, "" }, /* 62*/ { BARCODE_DBAR_EXPSTK, -1, 1, -1, "[8110]106141416543213500110000310123196000", 0, 25, 53, "", 1, 0 },
/* 63*/ { BARCODE_DBAR_EXPSTK, -1, 2, -1, "[8110]106141416543213500110000310123196000", 0, 13, 102, "" }, /* 63*/ { BARCODE_DBAR_EXPSTK, -1, 2, -1, "[8110]106141416543213500110000310123196000", 0, 13, 102, "", 2, 0 },
/* 64*/ { BARCODE_DBAR_EXPSTK, -1, 3, -1, "[8110]106141416543213500110000310123196000", 0, 9, 151, "" }, /* 64*/ { BARCODE_DBAR_EXPSTK, -1, 3, -1, "[8110]106141416543213500110000310123196000", 0, 9, 151, "", 3, 0 },
/* 65*/ { BARCODE_DBAR_EXPSTK, -1, 4, -1, "[8110]106141416543213500110000310123196000", 0, 5, 200, "" }, /* 65*/ { BARCODE_DBAR_EXPSTK, -1, 4, -1, "[8110]106141416543213500110000310123196000", 0, 5, 200, "", 4, 0 },
/* 66*/ { BARCODE_DBAR_EXPSTK, -1, 5, -1, "[8110]106141416543213500110000310123196000", 0, 5, 249, "" }, /* 66*/ { BARCODE_DBAR_EXPSTK, -1, 5, -1, "[8110]106141416543213500110000310123196000", 0, 5, 249, "", 5, 0 },
/* 67*/ { BARCODE_DBAR_EXPSTK, -1, -1, 2, "[8110]106141416543213500110000310123196000", 0, 5, 200, "" }, /* 67*/ { BARCODE_DBAR_EXPSTK, -1, -1, 2, "[8110]106141416543213500110000310123196000", 0, 5, 200, "", 4, 2 },
/* 68*/ { BARCODE_DBAR_EXPSTK, -1, -1, 3, "[8110]106141416543213500110000310123196000", 0, 9, 151, "" }, /* 68*/ { BARCODE_DBAR_EXPSTK, -1, -1, 3, "[8110]106141416543213500110000310123196000", 0, 9, 151, "", 3, 3 },
/* 69*/ { BARCODE_DBAR_EXPSTK, -1, -1, 4, "[8110]106141416543213500110000310123196000", 0, 13, 102, "" }, /* 69*/ { BARCODE_DBAR_EXPSTK, -1, -1, 4, "[8110]106141416543213500110000310123196000", 0, 13, 102, "", 2, 4 },
/* 70*/ { BARCODE_DBAR_EXPSTK, -1, -1, 5, "[8110]106141416543213500110000310123196000", 0, 13, 102, "" }, /* 70*/ { BARCODE_DBAR_EXPSTK, -1, -1, 5, "[8110]106141416543213500110000310123196000", 0, 13, 102, "", 2, 5 },
/* 71*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, "[91]123456789012345678901", 0, 9, 102, "" }, /* 71*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, "[91]123456789012345678901", 0, 9, 102, "", 2, 0 },
/* 72*/ { BARCODE_DBAR_EXPSTK, -1, 1, -1, "[91]123456789012345678901", 0, 17, 53, "" }, /* 72*/ { BARCODE_DBAR_EXPSTK, -1, 1, -1, "[91]123456789012345678901", 0, 17, 53, "", 1, 0 },
/* 73*/ { BARCODE_DBAR_EXPSTK, -1, 2, -1, "[91]123456789012345678901", 0, 9, 102, "" }, /* 73*/ { BARCODE_DBAR_EXPSTK, -1, 2, -1, "[91]123456789012345678901", 0, 9, 102, "", 2, 0 },
/* 74*/ { BARCODE_DBAR_EXPSTK, -1, 3, -1, "[91]123456789012345678901", 0, 5, 151, "" }, /* 74*/ { BARCODE_DBAR_EXPSTK, -1, 3, -1, "[91]123456789012345678901", 0, 5, 151, "", 3, 0 },
/* 75*/ { BARCODE_DBAR_EXPSTK, -1, 4, -1, "[91]123456789012345678901", 0, 5, 200, "" }, /* 75*/ { BARCODE_DBAR_EXPSTK, -1, 4, -1, "[91]123456789012345678901", 0, 5, 200, "", 4, 0 },
/* 76*/ { BARCODE_DBAR_EXPSTK, -1, -1, 2, "[91]123456789012345678901", 0, 5, 151, "" }, /* 76*/ { BARCODE_DBAR_EXPSTK, -1, -1, 2, "[91]123456789012345678901", 0, 5, 151, "", 3, 2 },
/* 77*/ { BARCODE_DBAR_EXPSTK, -1, -1, 3, "[91]123456789012345678901", 0, 9, 102, "" }, /* 77*/ { BARCODE_DBAR_EXPSTK, -1, -1, 3, "[91]123456789012345678901", 0, 9, 102, "", 2, 3 },
/* 78*/ { BARCODE_DBAR_EXPSTK, -1, -1, 4, "[91]123456789012345678901", 0, 9, 102, "" }, /* 78*/ { BARCODE_DBAR_EXPSTK, -1, -1, 4, "[91]123456789012345678901", 0, 9, 102, "", 2, 4 },
/* 79*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, "[91]123456789012345678901", 0, 9, 102, "" }, /* 79*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, "[91]123456789012345678901", 0, 9, 102, "", 2, 0 },
/* 80*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, "[91]1234567890123456789012345678901234567890123456789", 0, 17, 102, "" }, /* 80*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, "[91]1234567890123456789012345678901234567890123456789", 0, 17, 102, "", 2, 0 },
/* 81*/ { BARCODE_DBAR_EXPSTK, -1, 1, -1, "[91]1234567890123456789012345678901234567890123456789", 0, 33, 53, "" }, /* 81*/ { BARCODE_DBAR_EXPSTK, -1, 1, -1, "[91]1234567890123456789012345678901234567890123456789", 0, 33, 53, "", 1, 0 },
/* 82*/ { BARCODE_DBAR_EXPSTK, -1, 2, -1, "[91]1234567890123456789012345678901234567890123456789", 0, 17, 102, "" }, /* 82*/ { BARCODE_DBAR_EXPSTK, -1, 2, -1, "[91]1234567890123456789012345678901234567890123456789", 0, 17, 102, "", 2, 0 },
/* 83*/ { BARCODE_DBAR_EXPSTK, -1, 3, -1, "[91]1234567890123456789012345678901234567890123456789", 0, 9, 151, "" }, /* 83*/ { BARCODE_DBAR_EXPSTK, -1, 3, -1, "[91]1234567890123456789012345678901234567890123456789", 0, 9, 151, "", 3, 0 },
/* 84*/ { BARCODE_DBAR_EXPSTK, -1, 4, -1, "[91]1234567890123456789012345678901234567890123456789", 0, 9, 200, "" }, /* 84*/ { BARCODE_DBAR_EXPSTK, -1, 4, -1, "[91]1234567890123456789012345678901234567890123456789", 0, 9, 200, "", 4, 0 },
/* 85*/ { BARCODE_DBAR_EXPSTK, -1, 4, -1, "[91]1234567890123456789012345678901234567890123456789", 0, 9, 200, "" }, /* 85*/ { BARCODE_DBAR_EXPSTK, -1, 4, -1, "[91]1234567890123456789012345678901234567890123456789", 0, 9, 200, "", 4, 0 },
/* 86*/ { BARCODE_DBAR_EXPSTK, -1, 5, -1, "[91]1234567890123456789012345678901234567890123456789", 0, 5, 249, "" }, /* 86*/ { BARCODE_DBAR_EXPSTK, -1, 5, -1, "[91]1234567890123456789012345678901234567890123456789", 0, 5, 249, "", 5, 0 },
/* 87*/ { BARCODE_DBAR_EXPSTK, -1, 6, -1, "[91]1234567890123456789012345678901234567890123456789", 0, 5, 298, "" }, /* 87*/ { BARCODE_DBAR_EXPSTK, -1, 6, -1, "[91]1234567890123456789012345678901234567890123456789", 0, 5, 298, "", 6, 0 },
/* 88*/ { BARCODE_DBAR_EXPSTK, -1, 7, -1, "[91]1234567890123456789012345678901234567890123456789", 0, 5, 347, "" }, /* 88*/ { BARCODE_DBAR_EXPSTK, -1, 7, -1, "[91]1234567890123456789012345678901234567890123456789", 0, 5, 347, "", 7, 0 },
/* 89*/ { BARCODE_DBAR_EXPSTK, -1, 8, -1, "[91]1234567890123456789012345678901234567890123456789", 0, 5, 396, "" }, /* 89*/ { BARCODE_DBAR_EXPSTK, -1, 8, -1, "[91]1234567890123456789012345678901234567890123456789", 0, 5, 396, "", 8, 0 },
/* 90*/ { BARCODE_DBAR_EXPSTK, -1, 9, -1, "[91]1234567890123456789012345678901234567890123456789", 0, 1, 428, "" }, /* 90*/ { BARCODE_DBAR_EXPSTK, -1, 9, -1, "[91]1234567890123456789012345678901234567890123456789", 0, 1, 428, "", 9, 0 },
/* 91*/ { BARCODE_DBAR_EXPSTK, -1, -1, 2, "[91]1234567890123456789012345678901234567890123456789", 0, 5, 249, "" }, /* 91*/ { BARCODE_DBAR_EXPSTK, -1, -1, 2, "[91]1234567890123456789012345678901234567890123456789", 0, 5, 249, "", 5, 2 },
/* 92*/ { BARCODE_DBAR_EXPSTK, -1, -1, 3, "[91]1234567890123456789012345678901234567890123456789", 0, 9, 151, "" }, /* 92*/ { BARCODE_DBAR_EXPSTK, -1, -1, 3, "[91]1234567890123456789012345678901234567890123456789", 0, 9, 151, "", 3, 3 },
/* 93*/ { BARCODE_DBAR_EXPSTK, -1, -1, 4, "[91]1234567890123456789012345678901234567890123456789", 0, 9, 151, "" }, /* 93*/ { BARCODE_DBAR_EXPSTK, -1, -1, 4, "[91]1234567890123456789012345678901234567890123456789", 0, 9, 151, "", 3, 4 },
/* 94*/ { BARCODE_DBAR_EXPSTK, -1, -1, 5, "[91]1234567890123456789012345678901234567890123456789", 0, 17, 102, "" }, /* 94*/ { BARCODE_DBAR_EXPSTK, -1, -1, 5, "[91]1234567890123456789012345678901234567890123456789", 0, 17, 102, "", 2, 5 },
/* 95*/ { BARCODE_DBAR_EXPSTK, -1, -1, 6, "[91]1234567890123456789012345678901234567890123456789", 0, 17, 102, "" }, /* 95*/ { BARCODE_DBAR_EXPSTK, -1, -1, 6, "[91]1234567890123456789012345678901234567890123456789", 0, 17, 102, "", 2, 6 },
/* 96*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 21, 102, "" }, /* 96*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 21, 102, "", 2, 0 },
/* 97*/ { BARCODE_DBAR_EXPSTK, -1, 1, -1, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 41, 53, "" }, /* 97*/ { BARCODE_DBAR_EXPSTK, -1, 1, -1, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 41, 53, "", 1, 0 },
/* 98*/ { BARCODE_DBAR_EXPSTK, -1, 2, -1, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 21, 102, "" }, /* 98*/ { BARCODE_DBAR_EXPSTK, -1, 2, -1, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 21, 102, "", 2, 0 },
/* 99*/ { BARCODE_DBAR_EXPSTK, -1, 3, -1, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 13, 151, "" }, /* 99*/ { BARCODE_DBAR_EXPSTK, -1, 3, -1, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 13, 151, "", 3, 0 },
/*100*/ { BARCODE_DBAR_EXPSTK, -1, 4, -1, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 9, 200, "" }, /*100*/ { BARCODE_DBAR_EXPSTK, -1, 4, -1, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 9, 200, "", 4, 0 },
/*101*/ { BARCODE_DBAR_EXPSTK, -1, 5, -1, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 9, 249, "" }, /*101*/ { BARCODE_DBAR_EXPSTK, -1, 5, -1, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 9, 249, "", 5, 0 },
/*102*/ { BARCODE_DBAR_EXPSTK, -1, 6, -1, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 5, 298, "" }, /*102*/ { BARCODE_DBAR_EXPSTK, -1, 6, -1, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 5, 298, "", 6, 0 },
/*103*/ { BARCODE_DBAR_EXPSTK, -1, 7, -1, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 5, 347, "" }, /*103*/ { BARCODE_DBAR_EXPSTK, -1, 7, -1, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 5, 347, "", 7, 0 },
/*104*/ { BARCODE_DBAR_EXPSTK, -1, -1, 1, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 21, 102, "" }, /*104*/ { BARCODE_DBAR_EXPSTK, -1, -1, 1, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 21, 102, "", 2, 0 },
/*105*/ { BARCODE_DBAR_EXPSTK, -1, -1, 2, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 5, 298, "" }, /*105*/ { BARCODE_DBAR_EXPSTK, -1, -1, 2, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 5, 298, "", 6, 2 },
/*106*/ { BARCODE_DBAR_EXPSTK, -1, -1, 3, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 9, 200, "" }, /*106*/ { BARCODE_DBAR_EXPSTK, -1, -1, 3, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 9, 200, "", 4, 3 },
/*107*/ { BARCODE_DBAR_EXPSTK, -1, -1, 4, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 13, 151, "" }, /*107*/ { BARCODE_DBAR_EXPSTK, -1, -1, 4, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 13, 151, "", 3, 4 },
/*108*/ { BARCODE_DBAR_EXPSTK, -1, -1, 5, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 13, 151, "" }, /*108*/ { BARCODE_DBAR_EXPSTK, -1, -1, 5, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 13, 151, "", 3, 5 },
/*109*/ { BARCODE_DBAR_EXPSTK, -1, -1, 6, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 21, 102, "" }, /*109*/ { BARCODE_DBAR_EXPSTK, -1, -1, 6, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 21, 102, "", 2, 6 },
/*110*/ { BARCODE_DBAR_EXPSTK, -1, -1, 7, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 21, 102, "" }, /*110*/ { BARCODE_DBAR_EXPSTK, -1, -1, 7, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 21, 102, "", 2, 7 },
}; };
const int data_size = ARRAY_SIZE(data); const int data_size = ARRAY_SIZE(data);
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_input", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -1502,15 +1524,26 @@ static void test_input(const testCtx *const p_ctx) {
symbol = ZBarcode_Create(); symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n"); assert_nonnull(symbol, "Symbol not created\n");
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, data[i].option_3, -1 /*output_options*/, data[i].data, -1, debug); length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/,
-1 /*option_1*/, data[i].option_2, data[i].option_3, -1 /*output_options*/,
data[i].data, -1, debug);
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt); assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n",
i, symbol->errtxt, data[i].expected_errtxt);
if (ret < ZINT_ERROR) { if (ret < ZINT_ERROR) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (symbol->width %d)\n", i, symbol->rows, data[i].expected_rows, symbol->width); assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (symbol->width %d)\n",
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); i, symbol->rows, data[i].expected_rows, symbol->width);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n",
i, symbol->width, data[i].expected_width);
assert_equal(symbol->option_2, data[i].expected_option_2,
"i:%d symbol->option_2 %d != %d (symbol->option_2 %d) (option 3 %d)\n",
i, symbol->option_2, data[i].expected_option_2, symbol->option_2, symbol->option_3);
assert_equal(symbol->option_3, data[i].expected_option_3,
"i:%d symbol->option_3 %d != %d (symbol->option_3 %d)\n",
i, symbol->option_3, data[i].expected_option_3, symbol->option_3);
} }
ZBarcode_Delete(symbol); ZBarcode_Delete(symbol);

View file

@ -116,7 +116,7 @@ static void test_u_sjis_int(const testCtx *const p_ctx) {
(void)debug; (void)debug;
#endif #endif
testStart("test_u_sjis_int"); testStart(p_ctx->func_name);
#ifdef TEST_JUST_SAY_GNO #ifdef TEST_JUST_SAY_GNO
if ((debug & ZINT_DEBUG_TEST_PERFORMANCE)) { /* -d 256 */ if ((debug & ZINT_DEBUG_TEST_PERFORMANCE)) { /* -d 256 */
@ -212,7 +212,7 @@ static void test_sjis_utf8(const testCtx *const p_ctx) {
struct zint_symbol symbol = {0}; struct zint_symbol symbol = {0};
unsigned int jisdata[20] = {0}; /* Suppress clang -fsanitize=memory false positive */ unsigned int jisdata[20] = {0}; /* Suppress clang -fsanitize=memory false positive */
testStart("test_sjis_utf8"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int ret_length; int ret_length;
@ -304,7 +304,7 @@ static void test_sjis_utf8_to_eci(const testCtx *const p_ctx) {
unsigned int jisdata[20] = {0}; /* Suppress clang -fsanitize=memory false positive */ unsigned int jisdata[20] = {0}; /* Suppress clang -fsanitize=memory false positive */
testStart("test_sjis_utf8_to_eci"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int ret_length; int ret_length;
@ -356,7 +356,7 @@ static void test_sjis_cpy(const testCtx *const p_ctx) {
unsigned int jisdata[20] = {0}; /* Suppress clang -fsanitize=memory false positive */ unsigned int jisdata[20] = {0}; /* Suppress clang -fsanitize=memory false positive */
testStart("test_sjis_cpy"); testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int ret_length; int ret_length;

View file

@ -155,7 +155,7 @@ static void test_print(const testCtx *const p_ctx) {
int have_libreoffice = 0; int have_libreoffice = 0;
int have_vnu = 0; int have_vnu = 0;
testStartSymbol("test_print", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
if (p_ctx->generate) { if (p_ctx->generate) {
char data_dir_path[1024]; char data_dir_path[1024];
@ -278,7 +278,7 @@ static void test_outfile(const testCtx *const p_ctx) {
(void)p_ctx; (void)p_ctx;
testStart("test_outfile"); testStart(p_ctx->func_name);
symbol.symbology = BARCODE_CODE128; symbol.symbology = BARCODE_CODE128;
symbol.vector = &vector; symbol.vector = &vector;

View file

@ -56,7 +56,7 @@ static void test_large(const testCtx *const p_ctx) {
char data_buf[256]; char data_buf[256];
testStartSymbol("test_large", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -97,34 +97,36 @@ static void test_hrt(const testCtx *const p_ctx) {
const char *expected; const char *expected;
int expected_length; int expected_length;
const char *expected_raw;
int expected_raw_length;
}; };
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = { static const struct item data[] = {
/* 0*/ { BARCODE_TELEPEN, -1, "ABC1234.;$", -1, "ABC1234.;$", -1 }, /* 0*/ { BARCODE_TELEPEN, -1, "ABC1234.;$", -1, "ABC1234.;$", -1, "", -1 },
/* 1*/ { BARCODE_TELEPEN, BARCODE_RAW_TEXT, "ABC1234.;$", -1, "ABC1234.;$^", -1 }, /* 1*/ { BARCODE_TELEPEN, BARCODE_RAW_TEXT, "ABC1234.;$", -1, "ABC1234.;$", -1, "ABC1234.;$^", -1 },
/* 2*/ { BARCODE_TELEPEN, -1, "abc1234.;$", -1, "abc1234.;$", -1 }, /* 2*/ { BARCODE_TELEPEN, -1, "abc1234.;$", -1, "abc1234.;$", -1, "", -1 },
/* 3*/ { BARCODE_TELEPEN, BARCODE_RAW_TEXT, "abc1234.;$", -1, "abc1234.;$}", -1 }, /* 3*/ { BARCODE_TELEPEN, BARCODE_RAW_TEXT, "abc1234.;$", -1, "abc1234.;$", -1, "abc1234.;$}", -1 },
/* 4*/ { BARCODE_TELEPEN, -1, "ABC1234\001", -1, "ABC1234 ", -1 }, /* Note used to put control chars (apart from NUL) in HRT */ /* 4*/ { BARCODE_TELEPEN, -1, "ABC1234\001", -1, "ABC1234 ", -1, "", -1 }, /* Note used to put control chars (apart from NUL) in HRT */
/* 5*/ { BARCODE_TELEPEN, BARCODE_RAW_TEXT, "ABC1234\001", -1, "ABC1234\001k", -1 }, /* 5*/ { BARCODE_TELEPEN, BARCODE_RAW_TEXT, "ABC1234\001", -1, "ABC1234 ", -1, "ABC1234\001k", -1 },
/* 6*/ { BARCODE_TELEPEN, -1, "ABC\0001234", 8, "ABC 1234", -1 }, /* 6*/ { BARCODE_TELEPEN, -1, "ABC\0001234", 8, "ABC 1234", -1, "", -1 },
/* 7*/ { BARCODE_TELEPEN, BARCODE_RAW_TEXT, "ABC\0001234", 8, "ABC\0001234l", 9 }, /* 7*/ { BARCODE_TELEPEN, BARCODE_RAW_TEXT, "ABC\0001234", 8, "ABC 1234", -1, "ABC\0001234l", 9 },
/* 8*/ { BARCODE_TELEPEN, -1, "ABK0", -1, "ABK0", -1 }, /* 8*/ { BARCODE_TELEPEN, -1, "ABK0", -1, "ABK0", -1, "", -1 },
/* 9*/ { BARCODE_TELEPEN, BARCODE_RAW_TEXT, "ABK0", -1, "ABK0\000", 5 }, /* 9*/ { BARCODE_TELEPEN, BARCODE_RAW_TEXT, "ABK0", -1, "ABK0", -1, "ABK0\000", 5 },
/* 10*/ { BARCODE_TELEPEN_NUM, -1, "1234", -1, "1234", -1 }, /* 10*/ { BARCODE_TELEPEN_NUM, -1, "1234", -1, "1234", -1, "", -1 },
/* 11*/ { BARCODE_TELEPEN_NUM, BARCODE_RAW_TEXT, "1234", -1, "1234\033", -1 }, /* 11*/ { BARCODE_TELEPEN_NUM, BARCODE_RAW_TEXT, "1234", -1, "1234", -1, "1234\033", -1 },
/* 12*/ { BARCODE_TELEPEN_NUM, -1, "123X", -1, "123X", -1 }, /* 12*/ { BARCODE_TELEPEN_NUM, -1, "123X", -1, "123X", -1, "", -1 },
/* 13*/ { BARCODE_TELEPEN_NUM, BARCODE_RAW_TEXT, "123X", -1, "123XD", -1 }, /* 13*/ { BARCODE_TELEPEN_NUM, BARCODE_RAW_TEXT, "123X", -1, "123X", -1, "123XD", -1 },
/* 14*/ { BARCODE_TELEPEN_NUM, -1, "123x", -1, "123X", -1 }, /* Converts to upper */ /* 14*/ { BARCODE_TELEPEN_NUM, -1, "123x", -1, "123X", -1, "", -1 }, /* Converts to upper */
/* 15*/ { BARCODE_TELEPEN_NUM, BARCODE_RAW_TEXT, "123x", -1, "123XD", -1 }, /* 15*/ { BARCODE_TELEPEN_NUM, BARCODE_RAW_TEXT, "123x", -1, "123X", -1, "123XD", -1 },
/* 16*/ { BARCODE_TELEPEN_NUM, -1, "12345", -1, "012345", -1 }, /* Adds leading zero if odd */ /* 16*/ { BARCODE_TELEPEN_NUM, -1, "12345", -1, "012345", -1, "", -1 }, /* Adds leading zero if odd */
/* 17*/ { BARCODE_TELEPEN_NUM, BARCODE_RAW_TEXT, "12345", -1, "012345h", -1 }, /* 17*/ { BARCODE_TELEPEN_NUM, BARCODE_RAW_TEXT, "12345", -1, "012345", -1, "012345h", -1 },
}; };
const int data_size = ARRAY_SIZE(data); const int data_size = ARRAY_SIZE(data);
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
int expected_length; int expected_length, expected_raw_length;
testStartSymbol("test_hrt", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -137,6 +139,7 @@ static void test_hrt(const testCtx *const p_ctx) {
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options, -1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options,
data[i].data, data[i].length, debug); data[i].data, data[i].length, debug);
expected_length = data[i].expected_length == -1 ? (int) strlen(data[i].expected) : data[i].expected_length; expected_length = data[i].expected_length == -1 ? (int) strlen(data[i].expected) : data[i].expected_length;
expected_raw_length = data[i].expected_raw_length == -1 ? (int) strlen(data[i].expected_raw) : data[i].expected_raw_length;
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt); assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
@ -145,6 +148,19 @@ static void test_hrt(const testCtx *const p_ctx) {
i, symbol->text_length, expected_length); i, symbol->text_length, expected_length);
assert_zero(memcmp(symbol->text, data[i].expected, expected_length), "i:%d memcmp(%s, %s, %d) != 0\n", assert_zero(memcmp(symbol->text, data[i].expected, expected_length), "i:%d memcmp(%s, %s, %d) != 0\n",
i, symbol->text, data[i].expected, expected_length); i, symbol->text, data[i].expected, expected_length);
if (symbol->output_options & BARCODE_RAW_TEXT) {
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
assert_nonnull(symbol->raw_segs[0].source, "i:%d raw_segs[0].source NULL\n", i);
assert_equal(symbol->raw_segs[0].length, expected_raw_length,
"i:%d raw_segs[0].length %d != expected_raw_length %d\n",
i, symbol->raw_segs[0].length, expected_raw_length);
assert_zero(memcmp(symbol->raw_segs[0].source, data[i].expected_raw, expected_raw_length),
"i:%d memcmp(%.*s, %.*s, %d) != 0\n",
i, symbol->raw_segs[0].length, symbol->raw_segs[0].source, expected_raw_length,
data[i].expected_raw, expected_raw_length);
} else {
assert_null(symbol->raw_segs, "i:%d raw_segs not NULL\n", i);
}
ZBarcode_Delete(symbol); ZBarcode_Delete(symbol);
} }
@ -180,7 +196,7 @@ static void test_input(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_input", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -267,7 +283,7 @@ static void test_encode(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
testStartSymbol("test_encode", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -340,7 +356,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_fuzz", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {

View file

@ -98,7 +98,7 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
int have_tiffinfo = testUtilHaveTiffInfo(); int have_tiffinfo = testUtilHaveTiffInfo();
const char *const have_identify = testUtilHaveIdentify(); const char *const have_identify = testUtilHaveIdentify();
testStart("test_pixel_plot"); testStart(p_ctx->func_name);
symbol = ZBarcode_Create(); symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n"); assert_nonnull(symbol, "Symbol not created\n");
@ -221,7 +221,7 @@ static void test_print(const testCtx *const p_ctx) {
int have_tiffinfo = testUtilHaveTiffInfo(); int have_tiffinfo = testUtilHaveTiffInfo();
const char *const have_identify = testUtilHaveIdentify(); const char *const have_identify = testUtilHaveIdentify();
testStartSymbol("test_print", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
if (p_ctx->generate) { if (p_ctx->generate) {
char data_dir_path[1024]; char data_dir_path[1024];
@ -336,7 +336,7 @@ static void test_outfile(const testCtx *const p_ctx) {
(void)p_ctx; (void)p_ctx;
testStart("test_outfile"); testStart(p_ctx->func_name);
symbol.symbology = BARCODE_CODE128; symbol.symbology = BARCODE_CODE128;
symbol.bitmap = data; symbol.bitmap = data;

View file

@ -92,7 +92,7 @@ static void test_large(const testCtx *const p_ctx) {
char data_buf[ZINT_MAX_DATA_LEN + 1]; char data_buf[ZINT_MAX_DATA_LEN + 1];
testStartSymbol("test_large", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -149,7 +149,7 @@ static void test_reader_init(const testCtx *const p_ctx) {
char escaped[1024]; char escaped[1024];
testStartSymbol("test_reader_init", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -283,7 +283,7 @@ static void test_input(const testCtx *const p_ctx) {
char escaped[1024]; char escaped[1024];
testStartSymbol("test_input", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -813,7 +813,7 @@ static void test_encode(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
testStartSymbol("test_encode", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -1055,7 +1055,7 @@ static void test_encode_segs(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
testStartSymbol("test_encode_segs", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -1120,6 +1120,180 @@ static void test_encode_segs(const testCtx *const p_ctx) {
testFinish(); testFinish();
} }
static void test_rt(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
int input_mode;
int eci;
int output_options;
const char *data;
int length;
int ret;
int expected_eci;
const char *expected;
int expected_length;
int expected_raw_eci;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, -1, "é", -1, 0, 0, "", -1, 0 },
/* 1*/ { UNICODE_MODE, -1, BARCODE_RAW_TEXT, "é", -1, 0, 0, "\351", -1, 3 },
/* 2*/ { UNICODE_MODE, -1, -1, "", -1, ZINT_WARN_USES_ECI, 13, "", -1, 0 },
/* 3*/ { UNICODE_MODE, -1, BARCODE_RAW_TEXT, "", -1, ZINT_WARN_USES_ECI, 13, "\241", -1, 13 },
/* 4*/ { DATA_MODE, -1, -1, "\351", -1, 0, 0, "", -1, 0 },
/* 5*/ { DATA_MODE, -1, BARCODE_RAW_TEXT, "\351", -1, 0, 0, "\351", -1, 3 },
/* 6*/ { UNICODE_MODE, 26, -1, "é", -1, 0, 26, "", -1, 0 },
/* 7*/ { UNICODE_MODE, 26, BARCODE_RAW_TEXT, "é", -1, 0, 26, "é", -1, 26 },
/* 8*/ { UNICODE_MODE, 899, -1, "é", -1, 0, 899, "", -1, 0 },
/* 9*/ { UNICODE_MODE, 899, BARCODE_RAW_TEXT, "é", -1, 0, 899, "é", -1, 899 },
/* 10*/ { GS1_MODE, -1, -1, "[01]04912345123459[15]970331[30]128[10]ABC123", -1, 0, 0, "", -1, 0 },
/* 11*/ { GS1_MODE, -1, BARCODE_RAW_TEXT, "[01]04912345123459[15]970331[30]128[10]ABC123", -1, 0, 0, "01049123451234591597033130128\03510ABC123", -1, 3 },
};
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
int expected_length;
char escaped[4096];
char escaped2[4096];
testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) {
if (testContinue(p_ctx, i)) continue;
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
length = testUtilSetSymbol(symbol, BARCODE_ULTRA, data[i].input_mode, data[i].eci,
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options,
data[i].data, data[i].length, debug);
expected_length = data[i].expected_length == -1 ? (int) strlen(data[i].expected) : data[i].expected_length;
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n",
i, ret, data[i].ret, symbol->errtxt);
if (ret < ZINT_ERROR) {
assert_equal(symbol->eci, data[i].expected_eci, "i:%d eci %d != %d\n",
i, symbol->eci, data[i].expected_eci);
if (symbol->output_options & BARCODE_RAW_TEXT) {
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
assert_nonnull(symbol->raw_segs[0].source, "i:%d raw_segs[0].source NULL\n", i);
assert_equal(symbol->raw_segs[0].length, expected_length,
"i:%d raw_segs[0].length %d != expected_length %d\n",
i, symbol->raw_segs[0].length, expected_length);
assert_zero(memcmp(symbol->raw_segs[0].source, data[i].expected, expected_length),
"i:%d raw_segs[0].source memcmp(%s, %s, %d) != 0\n", i,
testUtilEscape((const char *) symbol->raw_segs[0].source, symbol->raw_segs[0].length,
escaped, sizeof(escaped)),
testUtilEscape(data[i].expected, expected_length, escaped2, sizeof(escaped2)),
expected_length);
assert_equal(symbol->raw_segs[0].eci, data[i].expected_raw_eci,
"i:%d raw_segs[0].eci %d != expected_raw_eci %d\n",
i, symbol->raw_segs[0].eci, data[i].expected_raw_eci);
} else {
assert_null(symbol->raw_segs, "i:%d raw_segs not NULL\n", i);
}
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_rt_segs(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
int input_mode;
int output_options;
struct zint_seg segs[3];
int ret;
int expected_rows;
int expected_width;
struct zint_seg expected_raw_segs[3];
int expected_raw_seg_count;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, { { TU(""), -1, 0 }, { TU("Ж"), -1, 7 }, {0} }, 0, 13, 15, {{0}}, 0 },
/* 1*/ { UNICODE_MODE, BARCODE_RAW_TEXT, { { TU(""), -1, 0 }, { TU("Ж"), -1, 7 }, { TU(""), 0, 0 } }, 0, 13, 15, { { TU("\266"), 1, 3 }, { TU("\266"), 1, 7 }, {0} }, 2 },
/* 2*/ { UNICODE_MODE, -1, { { TU("éé"), -1, 0 }, { TU("กขฯ"), -1, 0 }, { TU("βββ"), -1, 0 } }, ZINT_WARN_USES_ECI, 13, 20, {{0}}, 0 },
/* 3*/ { UNICODE_MODE, BARCODE_RAW_TEXT, { { TU("éé"), -1, 0 }, { TU("กขฯ"), -1, 0 }, { TU("βββ"), -1, 0 } }, ZINT_WARN_USES_ECI, 13, 20, { { TU("\351\351"), 2, 3 }, { TU("\241\242\317"), 3, 13 }, { TU("\342\342\342"), 3, 9 } }, 3 },
/* 4*/ { DATA_MODE, -1, { { TU(""), -1, 26 }, { TU("Ж"), -1, 0 }, { TU("\223\137"), -1, 20 } }, 0, 13, 19, {{0}}, 0 },
/* 5*/ { DATA_MODE, BARCODE_RAW_TEXT, { { TU(""), -1, 26 }, { TU("Ж"), -1, 0 }, { TU("\223\137"), -1, 20 } }, 0, 13, 19, { { TU(""), 2, 26 }, { TU("\320\226"), 2, 3 }, { TU("\223\137"), 2, 20 } }, 3 },
};
const int data_size = ARRAY_SIZE(data);
int i, j, seg_count, ret;
struct zint_symbol *symbol = NULL;
int expected_length;
char escaped[4096];
char escaped2[4096];
testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) {
if (testContinue(p_ctx, i)) continue;
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
testUtilSetSymbol(symbol, BARCODE_ULTRA, data[i].input_mode, -1 /*eci*/,
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options,
NULL, 0, debug);
for (j = 0, seg_count = 0; j < 3 && data[i].segs[j].length; j++, seg_count++);
ret = ZBarcode_Encode_Segs(symbol, data[i].segs, seg_count);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode_Segs ret %d != %d (%s)\n",
i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (width %d)\n",
i, symbol->rows, data[i].expected_rows, symbol->width);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n",
i, symbol->width, data[i].expected_width);
assert_equal(symbol->raw_seg_count, data[i].expected_raw_seg_count, "i:%d symbol->raw_seg_count %d != %d\n",
i, symbol->raw_seg_count, data[i].expected_raw_seg_count);
if (symbol->output_options & BARCODE_RAW_TEXT) {
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
for (j = 0; j < symbol->raw_seg_count; j++) {
assert_nonnull(symbol->raw_segs[j].source, "i:%d raw_segs[%d].source NULL\n", i, j);
expected_length = data[i].expected_raw_segs[j].length;
assert_equal(symbol->raw_segs[j].length, expected_length,
"i:%d raw_segs[%d].length %d != expected_length %d\n",
i, j, symbol->raw_segs[j].length, expected_length);
assert_zero(memcmp(symbol->raw_segs[j].source, data[i].expected_raw_segs[j].source, expected_length),
"i:%d raw_segs[%d].source memcmp(%s, %s, %d) != 0\n", i, j,
testUtilEscape((const char *) symbol->raw_segs[j].source, expected_length, escaped,
sizeof(escaped)),
testUtilEscape((const char *) data[i].expected_raw_segs[j].source, expected_length,
escaped2, sizeof(escaped2)),
expected_length);
assert_equal(symbol->raw_segs[j].eci, data[i].expected_raw_segs[j].eci,
"i:%d raw_segs[%d].eci %d != expected_raw_segs.eci %d\n",
i, j, symbol->raw_segs[j].eci, data[i].expected_raw_segs[j].eci);
}
} else {
assert_null(symbol->raw_segs, "i:%d raw_segs not NULL\n", i);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
testFunction funcs[] = { /* name, func */ testFunction funcs[] = { /* name, func */
@ -1128,6 +1302,8 @@ int main(int argc, char *argv[]) {
{ "test_input", test_input }, { "test_input", test_input },
{ "test_encode", test_encode }, { "test_encode", test_encode },
{ "test_encode_segs", test_encode_segs }, { "test_encode_segs", test_encode_segs },
{ "test_rt", test_rt },
{ "test_rt_segs", test_rt_segs },
}; };
testRun(argc, argv, funcs, ARRAY_SIZE(funcs)); testRun(argc, argv, funcs, ARRAY_SIZE(funcs));

View file

@ -102,10 +102,11 @@ static void test_upce_input(const testCtx *const p_ctx) {
char cmp_buf[4096] = {0}; /* Suppress clang -fsanitize=memory false positive */ char cmp_buf[4096] = {0}; /* Suppress clang -fsanitize=memory false positive */
char cmp_msg[1024] = {0}; /* Suppress clang -fsanitize=memory false positive */ char cmp_msg[1024] = {0}; /* Suppress clang -fsanitize=memory false positive */
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ /* Only do BWIPP/ZXing-C++ tests if asked, too slow otherwise */
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript();
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder();
testStartSymbol("test_upce_input", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -134,12 +135,14 @@ static void test_upce_input(const testCtx *const p_ctx) {
int cmp_len, ret_len; int cmp_len, ret_len;
char modules_dump[8192 + 1]; char modules_dump[8192 + 1];
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i);
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, 1 /*zxingcpp_cmp*/, cmp_buf, sizeof(cmp_buf), &cmp_len);
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].hrt, (int) strlen(data[i].hrt), NULL /*primary*/, escaped, &ret_len); ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].hrt, (int) strlen(data[i].hrt),
NULL /*primary*/, escaped, &ret_len);
assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n",
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, escaped); i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len,
escaped);
} }
} }
@ -166,7 +169,7 @@ static void test_upca_print(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_upca_print", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -286,7 +289,7 @@ static void test_upca_input(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_upca_input", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -458,7 +461,7 @@ static void test_eanx_input(const testCtx *const p_ctx) {
char errtxt_escaped[256]; char errtxt_escaped[256];
testStartSymbol("test_eanx_input", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -611,7 +614,7 @@ static void test_isbn_input(const testCtx *const p_ctx) {
char errtxt_escaped[256]; char errtxt_escaped[256];
testStartSymbol("test_isbn_input", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -755,7 +758,7 @@ static void test_hrt(const testCtx *const p_ctx) {
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
int expected_length; int expected_length;
testStartSymbol("test_hrt", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -801,7 +804,7 @@ static void test_vector_same(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_vector_same", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
struct zint_vector *vectors[4]; struct zint_vector *vectors[4];
@ -977,10 +980,11 @@ static void test_encode(const testCtx *const p_ctx) {
char cmp_buf[4096] = {0}; /* Suppress clang -fsanitize=memory false positive */ char cmp_buf[4096] = {0}; /* Suppress clang -fsanitize=memory false positive */
char cmp_msg[1024]; char cmp_msg[1024];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ /* Only do BWIPP/ZXing-C++ tests if asked, too slow otherwise */
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript();
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder();
testStartSymbol("test_encode", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -1021,12 +1025,14 @@ static void test_encode(const testCtx *const p_ctx) {
int cmp_len, ret_len; int cmp_len, ret_len;
char modules_dump[8192 + 1]; char modules_dump[8192 + 1];
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i);
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, 1 /*zxingcpp_cmp*/, cmp_buf, sizeof(cmp_buf), &cmp_len);
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len); ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length,
NULL /*primary*/, escaped, &ret_len);
assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n",
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, escaped); i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len,
escaped);
} }
} }
} }
@ -1065,7 +1071,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_fuzz", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {

View file

@ -500,7 +500,7 @@ static void test_options(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_options", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -691,7 +691,7 @@ static void test_buffer_vector(const testCtx *const p_ctx) {
const char *text; const char *text;
char errmsg[128] = {0}; /* Suppress clang -fsanitize=memory false positive */ char errmsg[128] = {0}; /* Suppress clang -fsanitize=memory false positive */
testStartSymbol("test_buffer_vector", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -860,7 +860,7 @@ static void test_has_hrt(const testCtx *const p_ctx) {
const char *text; const char *text;
char errmsg[128] = {0}; /* Suppress clang -fsanitize=memory false positive */ char errmsg[128] = {0}; /* Suppress clang -fsanitize=memory false positive */
testStartSymbol("test_has_hrt", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -918,78 +918,78 @@ static void test_upcean_hrt(const testCtx *const p_ctx) {
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = { struct item data[] = {
/* 0*/ { BARCODE_EANX, -1, -1, "123456789012", 0, 50, 1, 95, 226, 118, 12.2, 117.2, -1, -1, 3 }, /* EAN-13 */ /* 0*/ { BARCODE_EANX, -1, -1, "123456789012", 0, 50, 1, 95, 226, 118, 12.2, 117.2, -1, -1, 3 }, /* EAN-13 */
/* 1*/ { BARCODE_EANX, -1, BARCODE_RAW_TEXT, "123456789012", ZINT_WARN_HRT_RAW_TEXT, 50, 1, 95, 226, 118, 12.2, 117.2, -1, -1, 3 }, /* EAN-13 */ /* 1*/ { BARCODE_EANX, -1, BARCODE_RAW_TEXT, "123456789012", 0, 50, 1, 95, 226, 118, 12.2, 117.2, -1, -1, 3 }, /* EAN-13 */
/* 2*/ { BARCODE_EANX, 0, -1, "123456789012", 0, 50, 1, 95, 226, 110, -1, -1, -1, -1, 0 }, /* EAN-13 */ /* 2*/ { BARCODE_EANX, 0, -1, "123456789012", 0, 50, 1, 95, 226, 110, -1, -1, -1, -1, 0 }, /* EAN-13 */
/* 3*/ { BARCODE_EANX, -1, EANUPC_GUARD_WHITESPACE, "123456789012", 0, 50, 1, 95, 226, 118, 12.2, 117.2, 227, 117.2, 4 }, /* EAN-13 */ /* 3*/ { BARCODE_EANX, -1, EANUPC_GUARD_WHITESPACE, "123456789012", 0, 50, 1, 95, 226, 118, 12.2, 117.2, 227, 117.2, 4 }, /* EAN-13 */
/* 4*/ { BARCODE_EANX_CHK, -1, -1, "1234567890128", 0, 50, 1, 95, 226, 118, 12.2, 117.2, -1, -1, 3 }, /* EAN-13 */ /* 4*/ { BARCODE_EANX_CHK, -1, -1, "1234567890128", 0, 50, 1, 95, 226, 118, 12.2, 117.2, -1, -1, 3 }, /* EAN-13 */
/* 5*/ { BARCODE_EANX_CHK, 0, -1, "1234567890128", 0, 50, 1, 95, 226, 110, -1, -1, -1, -1, 0 }, /* EAN-13 */ /* 5*/ { BARCODE_EANX_CHK, 0, -1, "1234567890128", 0, 50, 1, 95, 226, 110, -1, -1, -1, -1, 0 }, /* EAN-13 */
/* 6*/ { BARCODE_EANX_CHK, -1, EANUPC_GUARD_WHITESPACE, "1234567890128", 0, 50, 1, 95, 226, 118, 12.2, 117.2, 227, 117.2, 4 }, /* EAN-13 */ /* 6*/ { BARCODE_EANX_CHK, -1, EANUPC_GUARD_WHITESPACE, "1234567890128", 0, 50, 1, 95, 226, 118, 12.2, 117.2, 227, 117.2, 4 }, /* EAN-13 */
/* 7*/ { BARCODE_ISBNX, -1, -1, "9784567890120", 0, 50, 1, 95, 226, 118, 12.2, 117.2, -1, -1, 3 }, /* 7*/ { BARCODE_ISBNX, -1, -1, "9784567890120", 0, 50, 1, 95, 226, 118, 12.2, 117.2, -1, -1, 3 },
/* 8*/ { BARCODE_ISBNX, -1, BARCODE_RAW_TEXT, "9784567890120", ZINT_WARN_HRT_RAW_TEXT, 50, 1, 95, 226, 118, 12.2, 117.2, -1, -1, 3 }, /* 8*/ { BARCODE_ISBNX, -1, BARCODE_RAW_TEXT, "9784567890120", 0, 50, 1, 95, 226, 118, 12.2, 117.2, -1, -1, 3 },
/* 9*/ { BARCODE_ISBNX, 0, -1, "9784567890120", 0, 50, 1, 95, 226, 110, -1, -1, -1, -1, 0 }, /* 9*/ { BARCODE_ISBNX, 0, -1, "9784567890120", 0, 50, 1, 95, 226, 110, -1, -1, -1, -1, 0 },
/* 10*/ { BARCODE_ISBNX, -1, EANUPC_GUARD_WHITESPACE, "9784567890120", 0, 50, 1, 95, 226, 118, 12.2, 117.2, 227, 117.2, 4 }, /* 10*/ { BARCODE_ISBNX, -1, EANUPC_GUARD_WHITESPACE, "9784567890120", 0, 50, 1, 95, 226, 118, 12.2, 117.2, 227, 117.2, 4 },
/* 11*/ { BARCODE_EANX, -1, -1, "1234567", 0, 50, 1, 67, 162, 118, 49, 117.2, -1, -1, 2 }, /* EAN-8 */ /* 11*/ { BARCODE_EANX, -1, -1, "1234567", 0, 50, 1, 67, 162, 118, 49, 117.2, -1, -1, 2 }, /* EAN-8 */
/* 12*/ { BARCODE_EANX, -1, BARCODE_RAW_TEXT, "1234567", ZINT_WARN_HRT_RAW_TEXT, 50, 1, 67, 162, 118, 49, 117.2, -1, -1, 2 }, /* EAN-8 */ /* 12*/ { BARCODE_EANX, -1, BARCODE_RAW_TEXT, "1234567", 0, 50, 1, 67, 162, 118, 49, 117.2, -1, -1, 2 }, /* EAN-8 */
/* 13*/ { BARCODE_EANX, 0, -1, "1234567", 0, 50, 1, 67, 162, 110, -1, -1, -1, -1, 0 }, /* EAN-8 */ /* 13*/ { BARCODE_EANX, 0, -1, "1234567", 0, 50, 1, 67, 162, 110, -1, -1, -1, -1, 0 }, /* EAN-8 */
/* 14*/ { BARCODE_EANX, -1, EANUPC_GUARD_WHITESPACE, "1234567", 0, 50, 1, 67, 162, 118, 49, 117.2, -1, 117.2, 4 }, /* EAN-8 */ /* 14*/ { BARCODE_EANX, -1, EANUPC_GUARD_WHITESPACE, "1234567", 0, 50, 1, 67, 162, 118, 49, 117.2, -1, 117.2, 4 }, /* EAN-8 */
/* 15*/ { BARCODE_EANX, -1, -1, "1234", 0, 50, 1, 47, 104, 118, 47, 15.6, -1, -1, 1 }, /* EAN-5 */ /* 15*/ { BARCODE_EANX, -1, -1, "1234", 0, 50, 1, 47, 104, 118, 47, 15.6, -1, -1, 1 }, /* EAN-5 */
/* 16*/ { BARCODE_EANX, -1, BARCODE_RAW_TEXT, "1234", ZINT_WARN_HRT_RAW_TEXT, 50, 1, 47, 104, 118, 47, 15.6, -1, -1, 1 }, /* EAN-5 */ /* 16*/ { BARCODE_EANX, -1, BARCODE_RAW_TEXT, "1234", 0, 50, 1, 47, 104, 118, 47, 15.6, -1, -1, 1 }, /* EAN-5 */
/* 17*/ { BARCODE_EANX, 0, -1, "1234", 0, 50, 1, 47, 104, 100, -1, -1, -1, -1, 0 }, /* EAN-5 */ /* 17*/ { BARCODE_EANX, 0, -1, "1234", 0, 50, 1, 47, 104, 100, -1, -1, -1, -1, 0 }, /* EAN-5 */
/* 18*/ { BARCODE_EANX, -1, EANUPC_GUARD_WHITESPACE, "1234", 0, 50, 1, 47, 104, 118, 47, 15.6, 105, 15.6, 2 }, /* EAN-5 */ /* 18*/ { BARCODE_EANX, -1, EANUPC_GUARD_WHITESPACE, "1234", 0, 50, 1, 47, 104, 118, 47, 15.6, 105, 15.6, 2 }, /* EAN-5 */
/* 19*/ { BARCODE_EANX, -1, -1, "12", 0, 50, 1, 20, 50, 118, 20, 15.6, -1, -1, 1 }, /* EAN-2 */ /* 19*/ { BARCODE_EANX, -1, -1, "12", 0, 50, 1, 20, 50, 118, 20, 15.6, -1, -1, 1 }, /* EAN-2 */
/* 20*/ { BARCODE_EANX, -1, BARCODE_RAW_TEXT, "12", ZINT_WARN_HRT_RAW_TEXT, 50, 1, 20, 50, 118, 20, 15.6, -1, -1, 1 }, /* EAN-2 */ /* 20*/ { BARCODE_EANX, -1, BARCODE_RAW_TEXT, "12", 0, 50, 1, 20, 50, 118, 20, 15.6, -1, -1, 1 }, /* EAN-2 */
/* 21*/ { BARCODE_EANX, 0, -1, "12", 0, 50, 1, 20, 50, 100, -1, -1, -1, -1, 0 }, /* EAN-2 */ /* 21*/ { BARCODE_EANX, 0, -1, "12", 0, 50, 1, 20, 50, 100, -1, -1, -1, -1, 0 }, /* EAN-2 */
/* 22*/ { BARCODE_EANX, -1, EANUPC_GUARD_WHITESPACE, "12", 0, 50, 1, 20, 50, 118, 20, 15.6, 51, 15.6, 2 }, /* EAN-2 */ /* 22*/ { BARCODE_EANX, -1, EANUPC_GUARD_WHITESPACE, "12", 0, 50, 1, 20, 50, 118, 20, 15.6, 51, 15.6, 2 }, /* EAN-2 */
/* 23*/ { BARCODE_UPCA, -1, -1, "12345678901", 0, 50, 1, 95, 226, 118, 8.7, 117.2, -1, -1, 4 }, /* 23*/ { BARCODE_UPCA, -1, -1, "12345678901", 0, 50, 1, 95, 226, 118, 8.7, 117.2, -1, -1, 4 },
/* 24*/ { BARCODE_UPCA, -1, BARCODE_RAW_TEXT, "12345678901", ZINT_WARN_HRT_RAW_TEXT, 50, 1, 95, 226, 118, 8.7, 117.2, -1, -1, 4 }, /* 24*/ { BARCODE_UPCA, -1, BARCODE_RAW_TEXT, "12345678901", 0, 50, 1, 95, 226, 118, 8.7, 117.2, -1, -1, 4 },
/* 25*/ { BARCODE_UPCA, 0, -1, "12345678901", 0, 50, 1, 95, 226, 110, -1, -1, -1, -1, 0 }, /* 25*/ { BARCODE_UPCA, 0, -1, "12345678901", 0, 50, 1, 95, 226, 110, -1, -1, -1, -1, 0 },
/* 26*/ { BARCODE_UPCA, -1, EANUPC_GUARD_WHITESPACE, "12345678901", 0, 50, 1, 95, 226, 118, 8.7, 117.2, -1, -1, 4 }, /* 26*/ { BARCODE_UPCA, -1, EANUPC_GUARD_WHITESPACE, "12345678901", 0, 50, 1, 95, 226, 118, 8.7, 117.2, -1, -1, 4 },
/* 27*/ { BARCODE_UPCA_CHK, -1, -1, "123456789012", 0, 50, 1, 95, 226, 118, 8.7, 117.2, -1, -1, 4 }, /* 27*/ { BARCODE_UPCA_CHK, -1, -1, "123456789012", 0, 50, 1, 95, 226, 118, 8.7, 117.2, -1, -1, 4 },
/* 28*/ { BARCODE_UPCA_CHK, 0, -1, "123456789012", 0, 50, 1, 95, 226, 110, -1, -1, -1, -1, 0 }, /* 28*/ { BARCODE_UPCA_CHK, 0, -1, "123456789012", 0, 50, 1, 95, 226, 110, -1, -1, -1, -1, 0 },
/* 29*/ { BARCODE_UPCA_CHK, -1, EANUPC_GUARD_WHITESPACE, "123456789012", 0, 50, 1, 95, 226, 118, 8.7, 117.2, -1, -1, 4 }, /* 29*/ { BARCODE_UPCA_CHK, -1, EANUPC_GUARD_WHITESPACE, "123456789012", 0, 50, 1, 95, 226, 118, 8.7, 117.2, -1, -1, 4 },
/* 30*/ { BARCODE_UPCE, -1, -1, "1234567", 0, 50, 1, 51, 134, 118, 8.7, 117.2, -1, -1, 3 }, /* 30*/ { BARCODE_UPCE, -1, -1, "1234567", 0, 50, 1, 51, 134, 118, 8.7, 117.2, -1, -1, 3 },
/* 31*/ { BARCODE_UPCE, -1, BARCODE_RAW_TEXT, "1234567", ZINT_WARN_HRT_RAW_TEXT, 50, 1, 51, 134, 118, 8.7, 117.2, -1, -1, 3 }, /* 31*/ { BARCODE_UPCE, -1, BARCODE_RAW_TEXT, "1234567", 0, 50, 1, 51, 134, 118, 8.7, 117.2, -1, -1, 3 },
/* 32*/ { BARCODE_UPCE, 0, -1, "1234567", 0, 50, 1, 51, 134, 110, -1, -1, -1, -1, 0 }, /* 32*/ { BARCODE_UPCE, 0, -1, "1234567", 0, 50, 1, 51, 134, 110, -1, -1, -1, -1, 0 },
/* 33*/ { BARCODE_UPCE, -1, EANUPC_GUARD_WHITESPACE, "1234567", 0, 50, 1, 51, 134, 118, 8.7, 117.2, -1, -1, 3 }, /* 33*/ { BARCODE_UPCE, -1, EANUPC_GUARD_WHITESPACE, "1234567", 0, 50, 1, 51, 134, 118, 8.7, 117.2, -1, -1, 3 },
/* 34*/ { BARCODE_UPCE_CHK, -1, -1, "12345670", 0, 50, 1, 51, 134, 118, 8.7, 117.2, -1, -1, 3 }, /* 34*/ { BARCODE_UPCE_CHK, -1, -1, "12345670", 0, 50, 1, 51, 134, 118, 8.7, 117.2, -1, -1, 3 },
/* 35*/ { BARCODE_UPCE_CHK, 0, -1, "12345670", 0, 50, 1, 51, 134, 110, -1, -1, -1, -1, 0 }, /* 35*/ { BARCODE_UPCE_CHK, 0, -1, "12345670", 0, 50, 1, 51, 134, 110, -1, -1, -1, -1, 0 },
/* 36*/ { BARCODE_UPCE_CHK, -1, EANUPC_GUARD_WHITESPACE, "12345670", 0, 50, 1, 51, 134, 118, 8.7, 117.2, -1, -1, 3 }, /* 36*/ { BARCODE_UPCE_CHK, -1, EANUPC_GUARD_WHITESPACE, "12345670", 0, 50, 1, 51, 134, 118, 8.7, 117.2, -1, -1, 3 },
/* 37*/ { BARCODE_EANX, -1, -1, "123456789012+12", 0, 50, 1, 122, 276.0, 118, 12.2, 117.2, 246, 15.6, 4 }, /* EAN-13 + EAN-2 */ /* 37*/ { BARCODE_EANX, -1, -1, "123456789012+12", 0, 50, 1, 122, 276.0, 118, 12.2, 117.2, 246, 15.6, 4 }, /* EAN-13 + EAN-2 */
/* 38*/ { BARCODE_EANX, -1, BARCODE_RAW_TEXT, "123456789012+12", ZINT_WARN_HRT_RAW_TEXT, 50, 1, 122, 276.0, 118, 12.2, 117.2, 246, 15.6, 4 }, /* EAN-13 + EAN-2 */ /* 38*/ { BARCODE_EANX, -1, BARCODE_RAW_TEXT, "123456789012+12", 0, 50, 1, 122, 276.0, 118, 12.2, 117.2, 246, 15.6, 4 }, /* EAN-13 + EAN-2 */
/* 39*/ { BARCODE_EANX, 0, -1, "123456789012+12", 0, 50, 1, 122, 276.0, 110, -1, -1, -1, -1, 0 }, /* EAN-13 + EAN-2 */ /* 39*/ { BARCODE_EANX, 0, -1, "123456789012+12", 0, 50, 1, 122, 276.0, 110, -1, -1, -1, -1, 0 }, /* EAN-13 + EAN-2 */
/* 40*/ { BARCODE_EANX, -1, EANUPC_GUARD_WHITESPACE, "123456789012+12", 0, 50, 1, 122, 276.0, 118, 12.2, 117.2, 246, 15.6, 5 }, /* EAN-13 + EAN-2 */ /* 40*/ { BARCODE_EANX, -1, EANUPC_GUARD_WHITESPACE, "123456789012+12", 0, 50, 1, 122, 276.0, 118, 12.2, 117.2, 246, 15.6, 5 }, /* EAN-13 + EAN-2 */
/* 41*/ { BARCODE_ISBNX, -1, -1, "9784567890120+12", 0, 50, 1, 122, 276.0, 118, 12.2, 117.2, 246, 15.6, 4 }, /* ISBN + EAN-2 */ /* 41*/ { BARCODE_ISBNX, -1, -1, "9784567890120+12", 0, 50, 1, 122, 276.0, 118, 12.2, 117.2, 246, 15.6, 4 }, /* ISBN + EAN-2 */
/* 42*/ { BARCODE_ISBNX, 0, -1, "9784567890120+12", 0, 50, 1, 122, 276.0, 110, -1, -1, -1, -1, 0 }, /* ISBN + EAN-2 */ /* 42*/ { BARCODE_ISBNX, 0, -1, "9784567890120+12", 0, 50, 1, 122, 276.0, 110, -1, -1, -1, -1, 0 }, /* ISBN + EAN-2 */
/* 43*/ { BARCODE_ISBNX, -1, EANUPC_GUARD_WHITESPACE, "9784567890120+12", 0, 50, 1, 122, 276.0, 118, 246, 15.6, 277, 15.6, 5 }, /* ISBN + EAN-2 */ /* 43*/ { BARCODE_ISBNX, -1, EANUPC_GUARD_WHITESPACE, "9784567890120+12", 0, 50, 1, 122, 276.0, 118, 246, 15.6, 277, 15.6, 5 }, /* ISBN + EAN-2 */
/* 44*/ { BARCODE_EANX, -1, -1, "123456789012+12345", 0, 50, 1, 149, 330.0, 118, 12.2, 117.2, 274, 15.6, 4 }, /* EAN-13 + EAN-5 */ /* 44*/ { BARCODE_EANX, -1, -1, "123456789012+12345", 0, 50, 1, 149, 330.0, 118, 12.2, 117.2, 274, 15.6, 4 }, /* EAN-13 + EAN-5 */
/* 45*/ { BARCODE_EANX, -1, BARCODE_RAW_TEXT, "123456789012+12345", ZINT_WARN_HRT_RAW_TEXT, 50, 1, 149, 330.0, 118, 12.2, 117.2, 274, 15.6, 4 }, /* EAN-13 + EAN-5 */ /* 45*/ { BARCODE_EANX, -1, BARCODE_RAW_TEXT, "123456789012+12345", 0, 50, 1, 149, 330.0, 118, 12.2, 117.2, 274, 15.6, 4 }, /* EAN-13 + EAN-5 */
/* 46*/ { BARCODE_EANX, 0, -1, "123456789012+12345", 0, 50, 1, 149, 330.0, 110, -1, -1, -1, -1, 0 }, /* EAN-13 + EAN-5 */ /* 46*/ { BARCODE_EANX, 0, -1, "123456789012+12345", 0, 50, 1, 149, 330.0, 110, -1, -1, -1, -1, 0 }, /* EAN-13 + EAN-5 */
/* 47*/ { BARCODE_EANX, -1, EANUPC_GUARD_WHITESPACE, "123456789012+12345", 0, 50, 1, 149, 330.0, 118, 12.2, 117.2, 274, 15.6, 5 }, /* EAN-13 + EAN-5 */ /* 47*/ { BARCODE_EANX, -1, EANUPC_GUARD_WHITESPACE, "123456789012+12345", 0, 50, 1, 149, 330.0, 118, 12.2, 117.2, 274, 15.6, 5 }, /* EAN-13 + EAN-5 */
/* 48*/ { BARCODE_ISBNX, -1, -1, "9784567890120+12345", 0, 50, 1, 149, 330.0, 118, 12.2, 117.2, 274, 15.6, 4 }, /* ISBN + EAN-5 */ /* 48*/ { BARCODE_ISBNX, -1, -1, "9784567890120+12345", 0, 50, 1, 149, 330.0, 118, 12.2, 117.2, 274, 15.6, 4 }, /* ISBN + EAN-5 */
/* 49*/ { BARCODE_ISBNX, 0, -1, "9784567890120+12345", 0, 50, 1, 149, 330.0, 110, -1, -1, -1, -1, 0 }, /* ISBN + EAN-5 */ /* 49*/ { BARCODE_ISBNX, 0, -1, "9784567890120+12345", 0, 50, 1, 149, 330.0, 110, -1, -1, -1, -1, 0 }, /* ISBN + EAN-5 */
/* 50*/ { BARCODE_ISBNX, -1, EANUPC_GUARD_WHITESPACE, "9784567890120+12345", 0, 50, 1, 149, 330.0, 118, 274, 15.6, 331, 15.6, 5 }, /* ISBN + EAN-5 */ /* 50*/ { BARCODE_ISBNX, -1, EANUPC_GUARD_WHITESPACE, "9784567890120+12345", 0, 50, 1, 149, 330.0, 118, 274, 15.6, 331, 15.6, 5 }, /* ISBN + EAN-5 */
/* 51*/ { BARCODE_EANX, -1, -1, "1234567+12", 0, 50, 1, 94, 212, 118, 49, 117.2, 182, 15.6, 3 }, /* EAN-8 + EAN-2 */ /* 51*/ { BARCODE_EANX, -1, -1, "1234567+12", 0, 50, 1, 94, 212, 118, 49, 117.2, 182, 15.6, 3 }, /* EAN-8 + EAN-2 */
/* 52*/ { BARCODE_EANX, -1, BARCODE_RAW_TEXT, "1234567+12", ZINT_WARN_HRT_RAW_TEXT, 50, 1, 94, 212, 118, 49, 117.2, 182, 15.6, 3 }, /* EAN-8 + EAN-2 */ /* 52*/ { BARCODE_EANX, -1, BARCODE_RAW_TEXT, "1234567+12", 0, 50, 1, 94, 212, 118, 49, 117.2, 182, 15.6, 3 }, /* EAN-8 + EAN-2 */
/* 53*/ { BARCODE_EANX, 0, -1, "1234567+12", 0, 50, 1, 94, 212, 110, -1, -1, -1, -1, 0 }, /* EAN-8 + EAN-2 */ /* 53*/ { BARCODE_EANX, 0, -1, "1234567+12", 0, 50, 1, 94, 212, 110, -1, -1, -1, -1, 0 }, /* EAN-8 + EAN-2 */
/* 54*/ { BARCODE_EANX, -1, EANUPC_GUARD_WHITESPACE, "1234567+12", 0, 50, 1, 94, 212, 118, 182, 15.6, 213, 15.6, 5 }, /* EAN-8 + EAN-2 */ /* 54*/ { BARCODE_EANX, -1, EANUPC_GUARD_WHITESPACE, "1234567+12", 0, 50, 1, 94, 212, 118, 182, 15.6, 213, 15.6, 5 }, /* EAN-8 + EAN-2 */
/* 55*/ { BARCODE_EANX, -1, -1, "1234567+12345", 0, 50, 1, 121, 266, 118, 49, 117.2, 210, 15.6, 3 }, /* EAN-8 + EAN-5 */ /* 55*/ { BARCODE_EANX, -1, -1, "1234567+12345", 0, 50, 1, 121, 266, 118, 49, 117.2, 210, 15.6, 3 }, /* EAN-8 + EAN-5 */
/* 56*/ { BARCODE_EANX, -1, BARCODE_RAW_TEXT, "1234567+12345", ZINT_WARN_HRT_RAW_TEXT, 50, 1, 121, 266, 118, 49, 117.2, 210, 15.6, 3 }, /* EAN-8 + EAN-5 */ /* 56*/ { BARCODE_EANX, -1, BARCODE_RAW_TEXT, "1234567+12345", 0, 50, 1, 121, 266, 118, 49, 117.2, 210, 15.6, 3 }, /* EAN-8 + EAN-5 */
/* 57*/ { BARCODE_EANX, 0, -1, "1234567+12345", 0, 50, 1, 121, 266, 110, -1, -1, -1, -1, 0 }, /* EAN-8 + EAN-5 */ /* 57*/ { BARCODE_EANX, 0, -1, "1234567+12345", 0, 50, 1, 121, 266, 110, -1, -1, -1, -1, 0 }, /* EAN-8 + EAN-5 */
/* 58*/ { BARCODE_EANX, -1, EANUPC_GUARD_WHITESPACE, "1234567+12345", 0, 50, 1, 121, 266, 118, 210, 15.6, 210, 15.6, 5 }, /* EAN-8 + EAN-5 */ /* 58*/ { BARCODE_EANX, -1, EANUPC_GUARD_WHITESPACE, "1234567+12345", 0, 50, 1, 121, 266, 118, 210, 15.6, 210, 15.6, 5 }, /* EAN-8 + EAN-5 */
/* 59*/ { BARCODE_UPCA, -1, -1, "12345678901+12", 0, 50, 1, 124, 276, 118, 8.7, 117.2, 246, 15.6, 5 }, /* 59*/ { BARCODE_UPCA, -1, -1, "12345678901+12", 0, 50, 1, 124, 276, 118, 8.7, 117.2, 246, 15.6, 5 },
/* 60*/ { BARCODE_UPCA, -1, BARCODE_RAW_TEXT, "12345678901+12", ZINT_WARN_HRT_RAW_TEXT, 50, 1, 124, 276, 118, 8.7, 117.2, 246, 15.6, 5 }, /* 60*/ { BARCODE_UPCA, -1, BARCODE_RAW_TEXT, "12345678901+12", 0, 50, 1, 124, 276, 118, 8.7, 117.2, 246, 15.6, 5 },
/* 61*/ { BARCODE_UPCA, 0, -1, "12345678901+12", 0, 50, 1, 124, 276, 110, -1, -1, -1, -1, 0 }, /* 61*/ { BARCODE_UPCA, 0, -1, "12345678901+12", 0, 50, 1, 124, 276, 110, -1, -1, -1, -1, 0 },
/* 62*/ { BARCODE_UPCA, -1, EANUPC_GUARD_WHITESPACE, "12345678901+12", 0, 50, 1, 124, 276, 118, 8.7, 117.2, 277, 15.6, 6 }, /* 62*/ { BARCODE_UPCA, -1, EANUPC_GUARD_WHITESPACE, "12345678901+12", 0, 50, 1, 124, 276, 118, 8.7, 117.2, 277, 15.6, 6 },
/* 63*/ { BARCODE_UPCA, -1, -1, "12345678901+12345", 0, 50, 1, 151, 330, 118, 8.7, 117.2, 274, 15.6, 5 }, /* 63*/ { BARCODE_UPCA, -1, -1, "12345678901+12345", 0, 50, 1, 151, 330, 118, 8.7, 117.2, 274, 15.6, 5 },
/* 64*/ { BARCODE_UPCA, -1, BARCODE_RAW_TEXT, "12345678901+12345", ZINT_WARN_HRT_RAW_TEXT, 50, 1, 151, 330, 118, 8.7, 117.2, 274, 15.6, 5 }, /* 64*/ { BARCODE_UPCA, -1, BARCODE_RAW_TEXT, "12345678901+12345", 0, 50, 1, 151, 330, 118, 8.7, 117.2, 274, 15.6, 5 },
/* 65*/ { BARCODE_UPCA, 0, -1, "12345678901+12345", 0, 50, 1, 151, 330, 110, -1, -1, -1, -1, 0 }, /* 65*/ { BARCODE_UPCA, 0, -1, "12345678901+12345", 0, 50, 1, 151, 330, 110, -1, -1, -1, -1, 0 },
/* 66*/ { BARCODE_UPCA, -1, EANUPC_GUARD_WHITESPACE, "12345678901+12345", 0, 50, 1, 151, 330, 118, 274, 15.6, 331, 15.6, 6 }, /* 66*/ { BARCODE_UPCA, -1, EANUPC_GUARD_WHITESPACE, "12345678901+12345", 0, 50, 1, 151, 330, 118, 274, 15.6, 331, 15.6, 6 },
/* 67*/ { BARCODE_UPCE, -1, -1, "1234567+12", 0, 50, 1, 78, 184.0, 118, 8.7, 117.2, 154, 15.6, 4 }, /* 67*/ { BARCODE_UPCE, -1, -1, "1234567+12", 0, 50, 1, 78, 184.0, 118, 8.7, 117.2, 154, 15.6, 4 },
/* 68*/ { BARCODE_UPCE, -1, BARCODE_RAW_TEXT, "1234567+12", ZINT_WARN_HRT_RAW_TEXT, 50, 1, 78, 184.0, 118, 8.7, 117.2, 154, 15.6, 4 }, /* 68*/ { BARCODE_UPCE, -1, BARCODE_RAW_TEXT, "1234567+12", 0, 50, 1, 78, 184.0, 118, 8.7, 117.2, 154, 15.6, 4 },
/* 69*/ { BARCODE_UPCE, 0, -1, "1234567+12", 0, 50, 1, 78, 184.0, 110, -1, -1, -1, -1, 0 }, /* 69*/ { BARCODE_UPCE, 0, -1, "1234567+12", 0, 50, 1, 78, 184.0, 110, -1, -1, -1, -1, 0 },
/* 70*/ { BARCODE_UPCE, -1, EANUPC_GUARD_WHITESPACE, "1234567+12", 0, 50, 1, 78, 184.0, 118, 8.7, 117.2, 185, 15.6, 5 }, /* 70*/ { BARCODE_UPCE, -1, EANUPC_GUARD_WHITESPACE, "1234567+12", 0, 50, 1, 78, 184.0, 118, 8.7, 117.2, 185, 15.6, 5 },
/* 71*/ { BARCODE_UPCE, -1, -1, "1234567+12345", 0, 50, 1, 105, 238.0, 118, 8.7, 117.2, 182, 15.6, 4 }, /* 71*/ { BARCODE_UPCE, -1, -1, "1234567+12345", 0, 50, 1, 105, 238.0, 118, 8.7, 117.2, 182, 15.6, 4 },
/* 72*/ { BARCODE_UPCE, -1, BARCODE_RAW_TEXT, "1234567+12345", ZINT_WARN_HRT_RAW_TEXT, 50, 1, 105, 238.0, 118, 8.7, 117.2, 182, 15.6, 4 }, /* 72*/ { BARCODE_UPCE, -1, BARCODE_RAW_TEXT, "1234567+12345", 0, 50, 1, 105, 238.0, 118, 8.7, 117.2, 182, 15.6, 4 },
/* 73*/ { BARCODE_UPCE, 0, -1, "1234567+12345", 0, 50, 1, 105, 238.0, 110, -1, -1, -1, -1, 0 }, /* 73*/ { BARCODE_UPCE, 0, -1, "1234567+12345", 0, 50, 1, 105, 238.0, 110, -1, -1, -1, -1, 0 },
/* 74*/ { BARCODE_UPCE, -1, EANUPC_GUARD_WHITESPACE, "1234567+12345", 0, 50, 1, 105, 238.0, 118, 182, 15.6, 239, 15.6, 5 }, /* 74*/ { BARCODE_UPCE, -1, EANUPC_GUARD_WHITESPACE, "1234567+12345", 0, 50, 1, 105, 238.0, 118, 182, 15.6, 239, 15.6, 5 },
}; };
@ -999,7 +999,7 @@ static void test_upcean_hrt(const testCtx *const p_ctx) {
struct zint_vector_string *string; struct zint_vector_string *string;
testStartSymbol("test_upcean_hrt", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int string_cnt; int string_cnt;
@ -1104,7 +1104,7 @@ static void test_row_separator(const testCtx *const p_ctx) {
struct zint_vector_rect *rect; struct zint_vector_rect *rect;
testStartSymbol("test_row_separator", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -1170,7 +1170,7 @@ static void test_stacking(const testCtx *const p_ctx) {
struct zint_vector_rect *rect; struct zint_vector_rect *rect;
testStartSymbol("test_stacking", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int length2; int length2;
@ -1306,7 +1306,7 @@ static void test_output_options(const testCtx *const p_ctx) {
struct zint_vector_rect *rect; struct zint_vector_rect *rect;
testStartSymbol("test_output_options", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -1385,7 +1385,7 @@ static void test_noncomposite_string_x(const testCtx *const p_ctx) {
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
testStartSymbol("test_noncomposite_string_x", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -1446,7 +1446,7 @@ static void test_upcean_whitespace_width(const testCtx *const p_ctx) {
struct zint_vector_string *string; struct zint_vector_string *string;
int string_cnt; int string_cnt;
testStartSymbol("test_upcean_whitespace_width", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -1533,7 +1533,7 @@ static void test_scale(const testCtx *const p_ctx) {
const char *text; const char *text;
struct zint_vector_rect *rect; struct zint_vector_rect *rect;
testStartSymbol("test_scale", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -1659,7 +1659,7 @@ static void test_guard_descent(const testCtx *const p_ctx) {
struct zint_vector_rect *rect; struct zint_vector_rect *rect;
testStartSymbol("test_guard_descent", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -2040,7 +2040,7 @@ static void test_quiet_zones(const testCtx *const p_ctx) {
struct zint_vector_rect *rect; struct zint_vector_rect *rect;
struct zint_vector_circle *circle; struct zint_vector_circle *circle;
testStartSymbol("test_quiet_zones", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -2201,7 +2201,7 @@ static void test_text_gap(const testCtx *const p_ctx) {
struct zint_vector_string *string; struct zint_vector_string *string;
struct zint_vector_rect *rect; struct zint_vector_rect *rect;
testStartSymbol("test_text_gap", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -2909,7 +2909,7 @@ static void test_height(const testCtx *const p_ctx) {
const char *text; const char *text;
testStartSymbol("test_height", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -3072,7 +3072,7 @@ static void test_height_per_row(const testCtx *const p_ctx) {
const char *text; const char *text;
testStartSymbol("test_height_per_row", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -3142,34 +3142,36 @@ static void test_hrt_raw_text(const testCtx *const p_ctx) {
float expected_vector_width; float expected_vector_width;
const char *expected; const char *expected;
int expected_length; int expected_length;
const char *expected_raw;
int expected_raw_length;
const char *expected_errtxt; const char *expected_errtxt;
}; };
static const struct item data[] = { static const struct item data[] = {
/* 0*/ { BARCODE_CODE128, -1, -1, BARCODE_MEMORY_FILE, "12345\00067890", 11, 0, 116.279999, 268, "12345 67890", -1, "" }, /* 0*/ { BARCODE_CODE128, -1, -1, BARCODE_MEMORY_FILE, "12345\00067890", 11, 0, 116.279999, 268, "12345 67890", -1, "", -1, "" },
/* 1*/ { BARCODE_CODE128, -1, -1, BARCODE_MEMORY_FILE | BARCODE_RAW_TEXT, "12345\00067890", 11, ZINT_WARN_HRT_RAW_TEXT, 116.279999, 268, "12345\00067890", 11, "Warning 698: HRT outputted as raw text" }, /* 1*/ { BARCODE_CODE128, -1, -1, BARCODE_MEMORY_FILE | BARCODE_RAW_TEXT, "12345\00067890", 11, 0, 116.279999, 268, "12345 67890", -1, "12345\00067890", 11, "" },
/* 2*/ { BARCODE_EXCODE39, -1, -1, BARCODE_MEMORY_FILE, "12345\00067890", 11, 0, 116.279999, 362, "12345 67890", -1, "" }, /* 2*/ { BARCODE_EXCODE39, -1, -1, BARCODE_MEMORY_FILE, "12345\00067890", 11, 0, 116.279999, 362, "12345 67890", -1, "", -1, "" },
/* 3*/ { BARCODE_EXCODE39, -1, -1, BARCODE_MEMORY_FILE | BARCODE_RAW_TEXT, "12345\00067890", 11, ZINT_WARN_HRT_RAW_TEXT, 116.279999, 362, "12345\00067890", 11, "Warning 698: HRT outputted as raw text" }, /* 3*/ { BARCODE_EXCODE39, -1, -1, BARCODE_MEMORY_FILE | BARCODE_RAW_TEXT, "12345\00067890", 11, 0, 116.279999, 362, "12345 67890", -1, "12345\00067890", 11, "" },
/* 4*/ { BARCODE_TELEPEN, -1, -1, BARCODE_MEMORY_FILE, "12345\00067890", 11, 0, 116.279999, 448, "12345 67890", -1, "" }, /* 4*/ { BARCODE_TELEPEN, -1, -1, BARCODE_MEMORY_FILE, "12345\00067890", 11, 0, 116.279999, 448, "12345 67890", -1, "", -1, "" },
/* 5*/ { BARCODE_TELEPEN, -1, -1, BARCODE_MEMORY_FILE | BARCODE_RAW_TEXT, "12345\00067890", 11, ZINT_WARN_HRT_RAW_TEXT, 116.279999, 448, "12345\00067890n", 12, "Warning 698: HRT outputted as raw text" }, /* 5*/ { BARCODE_TELEPEN, -1, -1, BARCODE_MEMORY_FILE | BARCODE_RAW_TEXT, "12345\00067890", 11, 0, 116.279999, 448, "12345 67890", -1, "12345\00067890n", 12, "" },
/* 6*/ { BARCODE_EANX, -1, -1, BARCODE_MEMORY_FILE, "123456789012", -1, 0, 118, 226, "1234567890128", -1, "" }, /* 6*/ { BARCODE_EANX, -1, -1, BARCODE_MEMORY_FILE, "123456789012", -1, 0, 118, 226, "1234567890128", -1, "", -1, "" },
/* 7*/ { BARCODE_EANX, -1, -1, BARCODE_MEMORY_FILE | BARCODE_RAW_TEXT, "123456789012", -1, ZINT_WARN_HRT_RAW_TEXT, 118, 226, "1234567890128", -1, "Warning 698: HRT outputted as raw text" }, /* Warn but no difference */ /* 7*/ { BARCODE_EANX, -1, -1, BARCODE_MEMORY_FILE | BARCODE_RAW_TEXT, "123456789012", -1, 0, 118, 226, "1234567890128", -1, "1234567890128", -1, "" },
/* 8*/ { BARCODE_EANX, -1, -1, BARCODE_MEMORY_FILE, "123456789012+12", -1, 0, 118, 276, "1234567890128+12", -1, "" }, /* 8*/ { BARCODE_EANX, -1, -1, BARCODE_MEMORY_FILE, "123456789012+12", -1, 0, 118, 276, "1234567890128+12", -1, "", -1, "" },
/* 9*/ { BARCODE_EANX, -1, -1, BARCODE_MEMORY_FILE | BARCODE_RAW_TEXT, "123456789012+12", -1, ZINT_WARN_HRT_RAW_TEXT, 118, 276, "1234567890128+12", -1, "Warning 698: HRT outputted as raw text" }, /* 9*/ { BARCODE_EANX, -1, -1, BARCODE_MEMORY_FILE | BARCODE_RAW_TEXT, "123456789012+12", -1, 0, 118, 276, "1234567890128+12", -1, "1234567890128+12", -1, "" },
/* 10*/ { BARCODE_CODE39, -1, -1, BARCODE_MEMORY_FILE, "ABC14", -1, 0, 116.279999, 180, "*ABC14*", -1, "" }, /* 10*/ { BARCODE_CODE39, -1, -1, BARCODE_MEMORY_FILE, "ABC14", -1, 0, 116.279999, 180, "*ABC14*", -1, "", -1, "" },
/* 11*/ { BARCODE_CODE39, -1, -1, BARCODE_MEMORY_FILE | BARCODE_RAW_TEXT, "ABC14", -1, ZINT_WARN_HRT_RAW_TEXT, 116.279999, 180, "ABC14", -1, "Warning 698: HRT outputted as raw text" }, /* 11*/ { BARCODE_CODE39, -1, -1, BARCODE_MEMORY_FILE | BARCODE_RAW_TEXT, "ABC14", -1, 0, 116.279999, 180, "*ABC14*", -1, "ABC14", -1, "" },
/* 12*/ { BARCODE_CODE39, -1, 1, BARCODE_MEMORY_FILE, "ABC14", -1, 0, 116.279999, 206, "*ABC14_*", -1, "" }, /* Check digit space rendered as underscore */ /* 12*/ { BARCODE_CODE39, -1, 1, BARCODE_MEMORY_FILE, "ABC14", -1, 0, 116.279999, 206, "*ABC14_*", -1, "", -1, "" }, /* Check digit space rendered as underscore */
/* 13*/ { BARCODE_CODE39, -1, 1, BARCODE_MEMORY_FILE | BARCODE_RAW_TEXT, "ABC14", -1, ZINT_WARN_HRT_RAW_TEXT, 116.279999, 206, "ABC14 ", -1, "Warning 698: HRT outputted as raw text" }, /* 13*/ { BARCODE_CODE39, -1, 1, BARCODE_MEMORY_FILE | BARCODE_RAW_TEXT, "ABC14", -1, 0, 116.279999, 206, "*ABC14_*", -1, "ABC14 ", -1, "" },
/* 14*/ { BARCODE_POSTNET, -1, -1, BARCODE_MEMORY_FILE, "12345", -1, 0, 24, 126, "", -1, "" }, /* 14*/ { BARCODE_POSTNET, -1, -1, BARCODE_MEMORY_FILE, "12345", -1, 0, 24, 126, "", -1, "", -1, "" },
/* 15*/ { BARCODE_POSTNET, -1, -1, BARCODE_MEMORY_FILE | BARCODE_RAW_TEXT, "12345", -1, ZINT_WARN_HRT_RAW_TEXT, 40.2799988, 126, "123455", -1, "Warning 698: HRT outputted as raw text" }, /* HRT printed */ /* 15*/ { BARCODE_POSTNET, -1, -1, BARCODE_MEMORY_FILE | BARCODE_RAW_TEXT, "12345", -1, 0, 24, 126, "", -1, "123455", -1, "" }, /* HRT not printed */
/* 16*/ { BARCODE_POSTNET, 0, -1, BARCODE_MEMORY_FILE, "12345", -1, 0, 24, 126, "", -1, "" }, /* 16*/ { BARCODE_POSTNET, 0, -1, BARCODE_MEMORY_FILE, "12345", -1, 0, 24, 126, "", -1, "", -1, "" },
/* 17*/ { BARCODE_POSTNET, 0, -1, BARCODE_MEMORY_FILE | BARCODE_RAW_TEXT, "12345", -1, 0, 24, 126, "123455", -1, "" }, /* HRT not printed, no warning */ /* 17*/ { BARCODE_POSTNET, 0, -1, BARCODE_MEMORY_FILE | BARCODE_RAW_TEXT, "12345", -1, 0, 24, 126, "", -1, "123455", -1, "" }, /* HRT not printed */
}; };
const int data_size = ARRAY_SIZE(data); const int data_size = ARRAY_SIZE(data);
int i, length, ret; int i, length, ret;
struct zint_symbol *symbol = NULL; struct zint_symbol *symbol = NULL;
int expected_length; int expected_length, expected_raw_length;
testStartSymbol("test_hrt_raw_text", &symbol); testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
@ -3188,6 +3190,7 @@ static void test_hrt_raw_text(const testCtx *const p_ctx) {
-1 /*option_1*/, data[i].option_2, -1 /*option_3*/, data[i].output_options, -1 /*option_1*/, data[i].option_2, -1 /*option_3*/, data[i].output_options,
data[i].data, data[i].length, debug); data[i].data, data[i].length, debug);
expected_length = data[i].expected_length == -1 ? (int) strlen(data[i].expected) : data[i].expected_length; expected_length = data[i].expected_length == -1 ? (int) strlen(data[i].expected) : data[i].expected_length;
expected_raw_length = data[i].expected_raw_length == -1 ? (int) strlen(data[i].expected_raw) : data[i].expected_raw_length;
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_zero(ret, "i:%d ZBarcode_Encode(%s) ret %d != 0 (%s)\n", assert_zero(ret, "i:%d ZBarcode_Encode(%s) ret %d != 0 (%s)\n",
@ -3197,6 +3200,19 @@ static void test_hrt_raw_text(const testCtx *const p_ctx) {
i, symbol->text_length, expected_length, symbol->text); i, symbol->text_length, expected_length, symbol->text);
assert_zero(memcmp(symbol->text, data[i].expected, expected_length), "i:%d memcmp(%s, %s, %d) != 0\n", assert_zero(memcmp(symbol->text, data[i].expected, expected_length), "i:%d memcmp(%s, %s, %d) != 0\n",
i, symbol->text, data[i].expected, expected_length); i, symbol->text, data[i].expected, expected_length);
if (symbol->output_options & BARCODE_RAW_TEXT) {
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
assert_nonnull(symbol->raw_segs[0].source, "i:%d raw_segs[0].source NULL\n", i);
assert_equal(symbol->raw_segs[0].length, expected_raw_length,
"i:%d raw_segs[0].length %d != expected_raw_length %d\n",
i, symbol->raw_segs[0].length, expected_raw_length);
assert_zero(memcmp(symbol->raw_segs[0].source, data[i].expected_raw, expected_raw_length),
"i:%d memcmp(%.*s, %.*s, %d) != 0\n",
i, symbol->raw_segs[0].length, symbol->raw_segs[0].source, expected_raw_length,
data[i].expected_raw, expected_raw_length);
} else {
assert_null(symbol->raw_segs, "i:%d raw_segs not NULL\n", i);
}
ret = ZBarcode_Print(symbol, 0); ret = ZBarcode_Print(symbol, 0);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Print(%s) ret %d != %d (%s)\n", assert_equal(ret, data[i].ret, "i:%d ZBarcode_Print(%s) ret %d != %d (%s)\n",

View file

@ -302,7 +302,7 @@ void testRun(int argc, char *argv[], testFunction funcs[], int funcs_size) {
for (i = 0; i < ZINT_TEST_CTX_EXC_MAX; i++) { for (i = 0; i < ZINT_TEST_CTX_EXC_MAX; i++) {
ctx.exclude[i] = ctx.exclude_end[i] = -1; ctx.exclude[i] = ctx.exclude_end[i] = -1;
} }
ctx.generate = ctx.debug = 0; ctx.arg = ctx.generate = ctx.debug = 0;
if (argc) { if (argc) {
const char *filename; const char *filename;
@ -401,6 +401,18 @@ void testRun(int argc, char *argv[], testFunction funcs[], int funcs_size) {
exclude_idx++; exclude_idx++;
} }
} }
} else if (strcmp(argv[i], "-a") == 0) {
if (i + 1 == argc) {
fprintf(stderr, "***testRun: -a argument value missing, ignoring***\n");
} else {
int a;
opt_arg = argv[++i];
if (!validate_int(opt_arg, &a)) {
fprintf(stderr, "***testRun: -a argument value invalid, ignoring***\n");
} else {
ctx.arg = a;
}
}
} else { } else {
fprintf(stderr, "***testRun: unknown arg '%s', ignoring***\n", argv[i]); fprintf(stderr, "***testRun: unknown arg '%s', ignoring***\n", argv[i]);
} }
@ -417,6 +429,7 @@ void testRun(int argc, char *argv[], testFunction funcs[], int funcs_size) {
if (func_match && strstr(funcs[i].name, func_match) == NULL) { if (func_match && strstr(funcs[i].name, func_match) == NULL) {
continue; continue;
} }
ctx.func_name = funcs[i].name;
(*funcs[i].func)(&ctx); (*funcs[i].func)(&ctx);
ran++; ran++;
} }
@ -508,7 +521,6 @@ const char *testUtilErrorName(int error_number) {
int val; int val;
}; };
static const struct item data[] = { static const struct item data[] = {
{ "ZINT_WARN_HRT_RAW_TEXT", ZINT_WARN_HRT_RAW_TEXT, -1 },
{ "0", 0, 0 }, { "0", 0, 0 },
{ "ZINT_WARN_HRT_TRUNCATED", ZINT_WARN_HRT_TRUNCATED, 1 }, { "ZINT_WARN_HRT_TRUNCATED", ZINT_WARN_HRT_TRUNCATED, 1 },
{ "ZINT_WARN_INVALID_OPTION", ZINT_WARN_INVALID_OPTION, 2 }, { "ZINT_WARN_INVALID_OPTION", ZINT_WARN_INVALID_OPTION, 2 },
@ -525,19 +537,18 @@ const char *testUtilErrorName(int error_number) {
{ "ZINT_ERROR_USES_ECI", ZINT_ERROR_USES_ECI, 13 }, { "ZINT_ERROR_USES_ECI", ZINT_ERROR_USES_ECI, 13 },
{ "ZINT_ERROR_NONCOMPLIANT", ZINT_ERROR_NONCOMPLIANT, 14 }, { "ZINT_ERROR_NONCOMPLIANT", ZINT_ERROR_NONCOMPLIANT, 14 },
{ "ZINT_ERROR_HRT_TRUNCATED", ZINT_ERROR_HRT_TRUNCATED, 15 }, { "ZINT_ERROR_HRT_TRUNCATED", ZINT_ERROR_HRT_TRUNCATED, 15 },
{ "ZINT_ERROR_HRT_RAW_TEXT", ZINT_ERROR_HRT_RAW_TEXT, 16 },
}; };
const int data_size = ARRAY_SIZE(data); const int data_size = ARRAY_SIZE(data);
if (error_number + 1 < 0 || error_number + 1 >= data_size) { if (error_number < 0 || error_number >= data_size) {
return ""; return "";
} }
/* Self-check */ /* Self-check */
if (data[error_number + 1].val != error_number || (data[error_number + 1].define != error_number)) { if (data[error_number].val != error_number || (data[error_number].define != error_number)) {
fprintf(stderr, "testUtilErrorName: data table out of sync (%d)\n", error_number); fprintf(stderr, "testUtilErrorName: data table out of sync (%d)\n", error_number);
abort(); abort();
} }
return data[error_number + 1].name; return data[error_number].name;
} }
/* Pretty name for input mode */ /* Pretty name for input mode */
@ -564,10 +575,10 @@ const char *testUtilInputModeName(int input_mode) {
return "-1"; return "-1";
} }
*buf = '\0'; *buf = '\0';
if ((input_mode & 0x7) & UNICODE_MODE) { if ((input_mode & 0x07) & UNICODE_MODE) {
strcpy(buf, "UNICODE_MODE"); strcpy(buf, "UNICODE_MODE");
set = UNICODE_MODE; set = UNICODE_MODE;
} else if ((input_mode & 0x7) & GS1_MODE) { } else if ((input_mode & 0x07) & GS1_MODE) {
strcpy(buf, "GS1_MODE"); strcpy(buf, "GS1_MODE");
set = GS1_MODE; set = GS1_MODE;
} else { } else {
@ -760,8 +771,8 @@ int testUtilIsValidUTF8(const unsigned char str[], const int length) {
/* Escape data for printing on generate test. Has a number of issues, e.g. need to use octal escapes */ /* Escape data for printing on generate test. Has a number of issues, e.g. need to use octal escapes */
char *testUtilEscape(const char *buffer, const int length, char *escaped, const int escaped_size) { char *testUtilEscape(const char *buffer, const int length, char *escaped, const int escaped_size) {
int i; int i;
unsigned char *b = (unsigned char *) buffer; const unsigned char *b = (const unsigned char *) buffer;
unsigned char *be = b + length; const unsigned char *be = b + length;
int non_utf8 = !testUtilIsValidUTF8(b, length); int non_utf8 = !testUtilIsValidUTF8(b, length);
int chunk = -1; int chunk = -1;
@ -776,28 +787,67 @@ char *testUtilEscape(const char *buffer, const int length, char *escaped, const
} }
i += 3; i += 3;
} }
if (non_utf8 || *b < ' ' || *b == '\177') { if (non_utf8) {
if (i + 4 < escaped_size) { if (!z_isascii(*b) || z_iscntrl(*b)) {
sprintf(escaped + i, "\\%.3o", *b); if (i + 4 < escaped_size) {
sprintf(escaped + i, "\\%.3o", *b);
}
i += 4;
} else {
escaped[i++] = *b;
} }
i += 4;
} else if (*b == '\\' || *b == '"') { } else if (*b == '\\' || *b == '"') {
if (i + 2 < escaped_size) { if (i + 2 < escaped_size) {
escaped[i] = '\\'; escaped[i] = '\\';
escaped[i + 1] = *b; escaped[i + 1] = *b;
} }
i += 2; i += 2;
} else if (b + 1 < be && *b == 0xC2 && *(b + 1) < 0xA0) { } else if (z_iscntrl(*b)) {
if (i + 8 < escaped_size) { if (i + 4 < escaped_size) {
sprintf(escaped + i, "\\%.3o\\%.3o", *b, *(b + 1)); sprintf(escaped + i, "\\%.3o", *b);
} }
i += 8; i += 4;
b++; } else if (z_isascii(*b)) {
} else {
escaped[i++] = *b; escaped[i++] = *b;
} else {
assert(b + 1 < be);
if (*b == 0xC2 && *(b + 1) < 0xA0) {
if (i + 8 < escaped_size) {
sprintf(escaped + i, "\\%.3o\\%.3o", *b, *(b + 1));
}
i += 8;
b++;
} else if (*b < 0xE0) {
if (i + 2 < escaped_size) {
escaped[i] = *b;
escaped[i + 1] = *(b + 1);
}
i += 2;
b++;
} else if (*b < 0xF0) {
assert(b + 2 < be);
if (i + 3 < escaped_size) {
escaped[i] = *b;
escaped[i + 1] = *(b + 1);
escaped[i + 2] = *(b + 2);
}
i += 3;
b += 2;
} else {
assert(b + 3 < be);
if (i + 4 < escaped_size) {
escaped[i] = *b;
escaped[i + 1] = *(b + 1);
escaped[i + 2] = *(b + 2);
escaped[i + 3] = *(b + 3);
}
i += 4;
b += 3;
}
} }
} }
if (i >= escaped_size) { if (i >= escaped_size) {
fprintf(stderr, "testUtilEscape: escape buffer size %d too small\n", escaped_size);
return NULL; return NULL;
} }
escaped[i] = '\0'; escaped[i] = '\0';
@ -2541,13 +2591,13 @@ static void testUtilBwippCvtGS1Data(char *bwipp_data, const int upcean, const in
/* Convert data to Ghostscript format for passing to bwipp_dump.ps */ /* Convert data to Ghostscript format for passing to bwipp_dump.ps */
static char *testUtilBwippEscape(char *bwipp_data, int bwipp_data_size, const char *data, int length, static char *testUtilBwippEscape(char *bwipp_data, int bwipp_data_size, const char *data, int length,
int zint_escape_mode, int eci, int *parse, int *parsefnc) { int zint_escape_mode, int eci, int *parse, int *parsefnc) {
const int init_parsefnc = *parsefnc == 1;
char *b = bwipp_data; char *b = bwipp_data;
char *be = b + bwipp_data_size; char *be = b + bwipp_data_size;
unsigned char *d = (unsigned char *) data; unsigned char *d = (unsigned char *) data;
unsigned char *de = (unsigned char *) data + length; unsigned char *de = (unsigned char *) data + length;
int have_done_single_caret = 0; /* Flag to help debug escaping of carets */
if (eci && !init_parsefnc) { if (eci && !*parsefnc) {
sprintf(bwipp_data, "^ECI%06d", eci); sprintf(bwipp_data, "^ECI%06d", eci);
*parsefnc = 1; *parsefnc = 1;
b = bwipp_data + 10; b = bwipp_data + 10;
@ -2556,15 +2606,30 @@ static char *testUtilBwippEscape(char *bwipp_data, int bwipp_data_size, const ch
while (b < be && d < de) { while (b < be && d < de) {
/* Have to escape double quote otherwise Ghostscript gives "Unterminated quote in @-file" for some reason */ /* Have to escape double quote otherwise Ghostscript gives "Unterminated quote in @-file" for some reason */
/* Escape single quote also to avoid having to do proper shell escaping TODO: proper shell escaping */ /* Escape single quote also to avoid having to do proper shell escaping TODO: proper shell escaping */
if (*d < 0x20 || *d >= 0x7F || (*d == '^' && !init_parsefnc) || *d == '"' || *d == '\'' if (*d < 0x20 || *d >= 0x7F || (*d == '^' && !*parsefnc) || *d == '"' || *d == '\''
|| *d == '(' || (*d == '\\' && !zint_escape_mode)) { || *d == '(' || (*d == '\\' && !zint_escape_mode)) {
if (b + 4 >= be) { if (b + 4 >= be) {
fprintf(stderr, "testUtilBwippEscape: double quote bwipp_data buffer full (%d)\n", bwipp_data_size); fprintf(stderr, "testUtilBwippEscape: double quote bwipp_data buffer full (%d)\n", bwipp_data_size);
return NULL; return NULL;
} }
have_done_single_caret |= *d == '^'; /* Flag non-doubled caret */
sprintf(b, "^%03u", *d++); sprintf(b, "^%03u", *d++);
b += 4; b += 4;
*parse = 1; *parse = 1;
/* Have to double up carets if `parsefnc` and not ECI/FNC */
} else if (*d == '^' && *parsefnc
&& (d + 4 >= de || (memcmp(d + 1, "ECI", 3) != 0 && memcmp(d + 1, "FNC", 3) != 0))) {
if (b + 2 >= be) {
fprintf(stderr, "testUtilBwippEscape: double caret bwipp_data buffer full (%d)\n", bwipp_data_size);
return NULL;
}
strcpy(b, "^^");
d++;
b += 2;
if (have_done_single_caret) {
/* `parsefnc` changed while escaping (see FNC1 processing below) - may cause test to fail */
fprintf(stderr, "testUtilBwippEscape: WARNING: already escaped caret singularly\n");
}
} else if (zint_escape_mode && *d == '\\' && d + 1 < de) { } else if (zint_escape_mode && *d == '\\' && d + 1 < de) {
int val; int val;
switch (*++d) { switch (*++d) {
@ -2620,12 +2685,13 @@ static char *testUtilBwippEscape(char *bwipp_data, int bwipp_data_size, const ch
d++; d++;
if (*d == '1') { if (*d == '1') {
if (b + 5 >= be) { if (b + 5 >= be) {
fprintf(stderr, "testUtilBwippEscape: FNC1 bwipp_data buffer full (%d)\n", bwipp_data_size); fprintf(stderr, "testUtilBwippEscape: FNC1 bwipp_data buffer full (%d)\n",
bwipp_data_size);
return NULL; return NULL;
} }
strcpy(b, "^FNC1"); strcpy(b, "^FNC1");
b += 5; b += 5;
*parsefnc = 1; *parsefnc = 1; /* See `have_done_single_caret` above for issues this may cause */
} }
} else { } else {
if (b + 8 >= be) { if (b + 8 >= be) {
@ -2680,7 +2746,8 @@ static char *testUtilBwippUtf8Convert(const int index, const int symbology, cons
int eci = *p_eci; int eci = *p_eci;
if (eci == 0 && try_sjis if (eci == 0 && try_sjis
&& (symbology == BARCODE_QRCODE || symbology == BARCODE_MICROQR || symbology == BARCODE_RMQR || symbology == BARCODE_UPNQR)) { && (symbology == BARCODE_QRCODE || symbology == BARCODE_MICROQR || symbology == BARCODE_RMQR
|| symbology == BARCODE_UPNQR)) {
if (symbology == BARCODE_UPNQR) { /* Note need to add "force binary mode" to BWIPP for this to work */ if (symbology == BARCODE_UPNQR) { /* Note need to add "force binary mode" to BWIPP for this to work */
if (utf8_to_eci(4, data, converted, p_data_len) != 0) { if (utf8_to_eci(4, data, converted, p_data_len) != 0) {
fprintf(stderr, "i:%d testUtilBwippUtf8Convert: failed to convert UTF-8 data for %s, ECI 4\n", fprintf(stderr, "i:%d testUtilBwippUtf8Convert: failed to convert UTF-8 data for %s, ECI 4\n",
@ -2745,13 +2812,13 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
static const char cmd_opts_fmt2[] = "gs -dNOPAUSE -dBATCH -dNODISPLAY -q -sb=%s -sd='%.2040s' -sd2='%s' -so='%s'" static const char cmd_opts_fmt2[] = "gs -dNOPAUSE -dBATCH -dNODISPLAY -q -sb=%s -sd='%.2040s' -sd2='%s' -so='%s'"
" backend/tests/tools/bwipp_dump.ps"; " backend/tests/tools/bwipp_dump.ps";
/* If data > ~4K and < ~6K */ /* If data > ~4K and < ~6K */
static const char cmd_fmt3[] = "gs -dNOPAUSE -dBATCH -dNODISPLAY -q -sb=%s -sd='%.2040s' -sd2='%.2040s' -sd3='%s'" static const char cmd_fmt3[] = "gs -dNOPAUSE -dBATCH -dNODISPLAY -q -sb=%s -sd='%.2040s' -sd2='%.2040s'"
" backend/tests/tools/bwipp_dump.ps"; " -sd3='%s' backend/tests/tools/bwipp_dump.ps";
static const char cmd_opts_fmt3[] = "gs -dNOPAUSE -dBATCH -dNODISPLAY -q -sb=%s -sd='%.2040s' -sd2='%.2040s' -sd3='%s'" static const char cmd_opts_fmt3[] = "gs -dNOPAUSE -dBATCH -dNODISPLAY -q -sb=%s -sd='%.2040s' -sd2='%.2040s'"
" -so='%s' backend/tests/tools/bwipp_dump.ps"; " -sd3='%s' -so='%s' backend/tests/tools/bwipp_dump.ps";
/* If data > ~6K and < ~8K */ /* If data > ~6K and < ~8K */
static const char cmd_fmt4[] = "gs -dNOPAUSE -dBATCH -dNODISPLAY -q -sb=%s -sd='%.2040s' -sd2='%.2040s' -sd3='%.2040s'" static const char cmd_fmt4[] = "gs -dNOPAUSE -dBATCH -dNODISPLAY -q -sb=%s -sd='%.2040s' -sd2='%.2040s'"
" -sd4='%s' backend/tests/tools/bwipp_dump.ps"; " -sd3='%.2040s' -sd4='%s' backend/tests/tools/bwipp_dump.ps";
static const char cmd_opts_fmt4[] = "gs -dNOPAUSE -dBATCH -dNODISPLAY -q -sb=%s -sd='%.2040s' -sd2='%.2040s'" static const char cmd_opts_fmt4[] = "gs -dNOPAUSE -dBATCH -dNODISPLAY -q -sb=%s -sd='%.2040s' -sd2='%.2040s'"
" -sd3='%.2040s' -sd4='%s' -so='%s' backend/tests/tools/bwipp_dump.ps"; " -sd3='%.2040s' -sd4='%s' -so='%s' backend/tests/tools/bwipp_dump.ps";
@ -2895,9 +2962,11 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
} }
} }
#if 0
if (symbol->input_mode & GS1NOCHECK_MODE) { if (symbol->input_mode & GS1NOCHECK_MODE) {
/* sprintf(bwipp_opts_buf + strlen(bwipp_opts_buf), "%sdontlint", strlen(bwipp_opts_buf) ? " " : ""); */ sprintf(bwipp_opts_buf + strlen(bwipp_opts_buf), "%sdontlint", strlen(bwipp_opts_buf) ? " " : "");
} }
#endif
} else { } else {
const int is_extra_escaped = (symbol->input_mode & EXTRA_ESCAPE_MODE) const int is_extra_escaped = (symbol->input_mode & EXTRA_ESCAPE_MODE)
&& symbol->symbology == BARCODE_CODE128; && symbol->symbology == BARCODE_CODE128;
@ -3011,7 +3080,8 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
|| symbology == BARCODE_USPS_IMAIL || symbology == BARCODE_AUSPOST || symbology == BARCODE_USPS_IMAIL || symbology == BARCODE_AUSPOST
|| symbology == BARCODE_PHARMA_TWO) { || symbology == BARCODE_PHARMA_TWO) {
for (r = 0; r < symbol->rows; r++) bwipp_row_height[r] = 1; /* Zap */ for (r = 0; r < symbol->rows; r++) bwipp_row_height[r] = 1; /* Zap */
if (symbology == BARCODE_RM4SCC || symbology == BARCODE_KIX || symbology == BARCODE_JAPANPOST || symbology == BARCODE_DAFT) { if (symbology == BARCODE_RM4SCC || symbology == BARCODE_KIX || symbology == BARCODE_JAPANPOST
|| symbology == BARCODE_DAFT) {
to_upper((unsigned char *) bwipp_data, (int) strlen(bwipp_data)); to_upper((unsigned char *) bwipp_data, (int) strlen(bwipp_data));
} else if (symbology == BARCODE_USPS_IMAIL) { } else if (symbology == BARCODE_USPS_IMAIL) {
char *dash = strchr(bwipp_data, '-'); char *dash = strchr(bwipp_data, '-');
@ -3505,7 +3575,8 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
} }
cnt = (int) fread(b, 1, symbol->width, fp); cnt = (int) fread(b, 1, symbol->width, fp);
if (cnt != symbol->width) { if (cnt != symbol->width) {
fprintf(stderr, "i:%d testUtilBwipp: failed to read row %d of %d, symbol->width %d bytes, cnt %d (%s)\n", fprintf(stderr,
"i:%d testUtilBwipp: failed to read row %d of %d, symbol->width %d bytes, cnt %d (%s)\n",
index, r + 1, symbol->rows, symbol->width, cnt, cmd); index, r + 1, symbol->rows, symbol->width, cnt, cmd);
testutil_pclose(fp); testutil_pclose(fp);
return -1; return -1;
@ -3544,7 +3615,7 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
int testUtilBwippSegs(int index, struct zint_symbol *symbol, int option_1, int option_2, int option_3, int testUtilBwippSegs(int index, struct zint_symbol *symbol, int option_1, int option_2, int option_3,
const struct zint_seg segs[], const int seg_count, const char *primary, char *buffer, int buffer_size) { const struct zint_seg segs[], const int seg_count, const char *primary, char *buffer, int buffer_size) {
const int symbology = symbol->symbology; const int symbology = symbol->symbology;
const int unicode_mode = (symbol->input_mode & 0x7) == UNICODE_MODE; const int unicode_mode = (symbol->input_mode & 0x07) == UNICODE_MODE;
const int symbol_eci = symbol->eci; const int symbol_eci = symbol->eci;
struct zint_seg *local_segs = (struct zint_seg *) z_alloca(sizeof(struct zint_seg) * seg_count); struct zint_seg *local_segs = (struct zint_seg *) z_alloca(sizeof(struct zint_seg) * seg_count);
int total_len = 0; int total_len = 0;
@ -3619,7 +3690,8 @@ int testUtilBwippSegs(int index, struct zint_symbol *symbol, int option_1, int o
} }
symbol->eci = 0; symbol->eci = 0;
ret = testUtilBwipp(index, symbol, option_1, option_2, option_3, data, total_len, primary, buffer, buffer_size, &parsefnc); ret = testUtilBwipp(index, symbol, option_1, option_2, option_3, data, total_len, primary, buffer, buffer_size,
&parsefnc);
if (unicode_mode) { if (unicode_mode) {
symbol->input_mode = UNICODE_MODE; symbol->input_mode = UNICODE_MODE;
@ -3707,17 +3779,6 @@ int testUtilHaveZXingCPPDecoder(void) {
return system("zxingcppdecoder " DEV_NULL_STDERR) == 0; return system("zxingcppdecoder " DEV_NULL_STDERR) == 0;
} }
/* Helper to test whether have non-ASCII */
static int testUtilHasNonASCII(const char *source, const int length) {
int i;
for (i = 0; i < length; i++) {
if (source[i] & 0x80) {
return 1;
}
}
return 0;
}
/* Map Zint symbology to ZXing-C++ format name */ /* Map Zint symbology to ZXing-C++ format name */
static const char *testUtilZXingCPPName(int index, const struct zint_symbol *symbol, const char *source, static const char *testUtilZXingCPPName(int index, const struct zint_symbol *symbol, const char *source,
const int length, const int debug) { const int length, const int debug) {
@ -3896,15 +3957,7 @@ static const char *testUtilZXingCPPName(int index, const struct zint_symbol *sym
return NULL; return NULL;
} }
if (symbology == BARCODE_QRCODE || symbology == BARCODE_HIBC_QR || symbology == BARCODE_MICROQR if (symbology == BARCODE_CODABLOCKF || symbology == BARCODE_HIBC_BLOCKF) {
|| symbology == BARCODE_RMQR) {
const int full_multibyte = (symbol->option_3 & 0xFF) == ZINT_FULL_MULTIBYTE;
if (full_multibyte && testUtilHasNonASCII(source, length)) { /* TODO: Support in ZXing-C++ */
printf("i:%d %s not ZXing-C++ compatible, ZINT_FULL_MULTIBYTE not supported (with non-ASCII data)\n",
index, testUtilBarcodeName(symbology));
return NULL;
}
} else if (symbology == BARCODE_CODABLOCKF || symbology == BARCODE_HIBC_BLOCKF) {
if (symbol->rows == 1) { /* Single row i.e. CODE128 not supported */ if (symbol->rows == 1) { /* Single row i.e. CODE128 not supported */
if (debug & ZINT_DEBUG_TEST_PRINT) { if (debug & ZINT_DEBUG_TEST_PRINT) {
printf("i:%d %s not ZXing-C++ compatible, single row not supported\n", printf("i:%d %s not ZXing-C++ compatible, single row not supported\n",
@ -3937,9 +3990,35 @@ int testUtilCanZXingCPP(int index, const struct zint_symbol *symbol, const char
return testUtilZXingCPPName(index, symbol, source, length, debug) != NULL; return testUtilZXingCPPName(index, symbol, source, length, debug) != NULL;
} }
static const char *testUtilZXingCPPCharSet(int eci) {
static const struct { int eci; const char *charset; } charsets[] = {
{ 3, "ISO-8859-1" }, { 4, "ISO-8859-2" }, { 5, "ISO-8859-3" }, { 6, "ISO-8859-4" },
{ 7, "ISO-8859-5" }, { 8, "ISO-8859-6" }, { 9, "ISO-8859-7" }, { 10, "ISO-8859-8" },
{ 11, "ISO-8859-9" }, { 12, "ISO-8859-10" }, { 13, "ISO-8859-11" }, { 15, "ISO-8859-13" },
{ 16, "ISO-8859-14" }, { 17, "ISO-8859-15" }, { 18, "ISO-8859-16" }, { 20, "Shift_JIS" },
{ 21, "Cp1250" }, { 22, "Cp1251" }, { 23, "Cp1252" }, { 24, "Cp1256" },
{ 25, "UTF-16BE" }, { 26, "UTF-8" }, { 27, "ASCII" }, { 28, "Big5" },
{ 29, "GB2312" }, { 30, "EUC-CN" }, { 31, "GBK" }, { 32, "GB18030" },
{ 33, "UTF-16LE" }, { 34, "UTF-32BE" }, { 35, "UTF-32LE" }, { 170, "ASCII" },
{ 899, "BINARY" },
};
int s = 0, e = ARRAY_SIZE(charsets);
while (s < e) {
const int m = s + (e - s) / 2;
if (charsets[m].eci < eci) {
s = m + 1;
} else if (charsets[m].eci > eci) {
e = m;
} else {
return charsets[m].charset;
}
}
return NULL;
}
/* Run "zxingcppdecoder", returning result in `buffer` */ /* Run "zxingcppdecoder", returning result in `buffer` */
int testUtilZXingCPP(int index, struct zint_symbol *symbol, const char *source, const int length, char *bits, int testUtilZXingCPP(int index, struct zint_symbol *symbol, const char *source, const int length, const char *bits,
char *buffer, const int buffer_size, int *p_cmp_len) { const int zxingcpp_cmp, char *buffer, const int buffer_size, int *p_cmp_len) {
static const char cmd_fmt[] = "zxingcppdecoder -textonly -format %s -width %d -bits '%s'"; static const char cmd_fmt[] = "zxingcppdecoder -textonly -format %s -width %d -bits '%s'";
static const char opts_cmd_fmt[] = "zxingcppdecoder -textonly -format %s -opts '%s' -width %d -bits '%s'"; static const char opts_cmd_fmt[] = "zxingcppdecoder -textonly -format %s -opts '%s' -width %d -bits '%s'";
static const char cs_cmd_fmt[] = "zxingcppdecoder -textonly -format %s -charset %s -width %d -bits '%s'"; static const char cs_cmd_fmt[] = "zxingcppdecoder -textonly -format %s -charset %s -width %d -bits '%s'";
@ -3950,7 +4029,7 @@ int testUtilZXingCPP(int index, struct zint_symbol *symbol, const char *source,
char *cmd = (char *) z_alloca(bits_len + 1024); char *cmd = (char *) z_alloca(bits_len + 1024);
const char *zxingcpp_barcode = NULL; const char *zxingcpp_barcode = NULL;
const int data_mode = (symbol->input_mode & 0x07) == DATA_MODE; const int data_mode = (symbol->input_mode & 0x07) == DATA_MODE;
int set_charset = 0; const char *charset = NULL;
const char *opts = NULL; const char *opts = NULL;
FILE *fp = NULL; FILE *fp = NULL;
@ -3974,23 +4053,11 @@ int testUtilZXingCPP(int index, struct zint_symbol *symbol, const char *source,
opts = "validateCode39CheckSum"; opts = "validateCode39CheckSum";
} }
if ((symbol->input_mode & 0x07) == UNICODE_MODE && symbol->eci == 0 if (zxingcpp_cmp > 1 && symbol->eci == 0) {
&& (symbology == BARCODE_QRCODE || symbology == BARCODE_MICROQR || symbology == BARCODE_HANXIN)) { charset = testUtilZXingCPPCharSet(zxingcpp_cmp);
int converted_len = length; assert(charset);
unsigned char *converted_buf = (unsigned char *) z_alloca(converted_len + 1);
if (symbology == BARCODE_HANXIN) {
set_charset = utf8_to_eci(0, (const unsigned char *) source, converted_buf, &converted_len) != 0;
} else {
set_charset = utf8_to_eci(0, (const unsigned char *) source, converted_buf, &converted_len) == 0;
}
} }
if (set_charset) { if (charset) {
const char *charset;
if (symbology == BARCODE_HANXIN) {
charset = "GB18030";
} else {
charset = "ISO8859_1";
}
sprintf(cmd, cs_cmd_fmt, zxingcpp_barcode, charset, width, bits); sprintf(cmd, cs_cmd_fmt, zxingcpp_barcode, charset, width, bits);
} else if (opts) { } else if (opts) {
sprintf(cmd, opts_cmd_fmt, zxingcpp_barcode, opts, width, bits); sprintf(cmd, opts_cmd_fmt, zxingcpp_barcode, opts, width, bits);
@ -4024,8 +4091,8 @@ int testUtilZXingCPP(int index, struct zint_symbol *symbol, const char *source,
testutil_pclose(fp); testutil_pclose(fp);
if ((data_mode && is_eci_convertible(symbol->eci)) || symbol->eci >= 899) { if ((data_mode && zxingcpp_cmp > 1 && (zxingcpp_cmp == 899 || is_eci_convertible(zxingcpp_cmp))) || symbol->eci >= 899) {
const int eci = symbol->eci >= 899 ? 3 : symbol->eci; const int eci = symbol->eci > 899 ? 3 : zxingcpp_cmp;
int error_number; int error_number;
const int eci_length = get_eci_length(eci, (const unsigned char *) buffer, cnt); const int eci_length = get_eci_length(eci, (const unsigned char *) buffer, cnt);
unsigned char *preprocessed = (unsigned char *) z_alloca(eci_length + 1); unsigned char *preprocessed = (unsigned char *) z_alloca(eci_length + 1);
@ -4101,8 +4168,8 @@ static int textUtilZXingCPPDX(const char *expected, const int expected_len, cons
} }
/* Massage result from "zxingcppdecoder" so as can compare to Zint input */ /* Massage result from "zxingcppdecoder" so as can compare to Zint input */
int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, int cmp_len, int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, int cmp_len, const char *expected,
const char *expected, int expected_len, const char *primary, char *ret_buf, int *p_ret_len) { int expected_len, const char *primary, char *ret_buf, int *p_ret_len) {
const int symbology = symbol->symbology; const int symbology = symbol->symbology;
const int is_gs1_128_dbar_exp = symbology == BARCODE_GS1_128 || symbology == BARCODE_DBAR_EXP const int is_gs1_128_dbar_exp = symbology == BARCODE_GS1_128 || symbology == BARCODE_DBAR_EXP
@ -4150,7 +4217,7 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in
(unsigned char *) escaped); (unsigned char *) escaped);
if (ret != 0) { if (ret != 0) {
sprintf(msg, "escape_char_process %d != 0", ret); sprintf(msg, "escape_char_process %d != 0", ret);
return 3; return 2;
} }
if (is_extra_escaped) { if (is_extra_escaped) {
/* Remove any Code 128 special escapes */ /* Remove any Code 128 special escapes */
@ -4193,7 +4260,7 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in
&expected_len); &expected_len);
if (ret >= ZINT_ERROR) { if (ret >= ZINT_ERROR) {
sprintf(msg, "gs1_verify %d != 0", ret); sprintf(msg, "gs1_verify %d != 0", ret);
return 4; return 3;
} }
expected = reduced; expected = reduced;
if (primary) { if (primary) {
@ -4207,7 +4274,7 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in
to_upper((unsigned char *) (hibc + 1), expected_len); to_upper((unsigned char *) (hibc + 1), expected_len);
if (not_sane_lookup(TECHNETIUM, sizeof(TECHNETIUM) - 1, (unsigned char *) (hibc + 1), expected_len, posns)) { if (not_sane_lookup(TECHNETIUM, sizeof(TECHNETIUM) - 1, (unsigned char *) (hibc + 1), expected_len, posns)) {
sprintf(msg, "HIBC not_sane_lookup(TECHNETIUM) failed"); sprintf(msg, "HIBC not_sane_lookup(TECHNETIUM) failed");
return 5; return 4;
} }
counter = 41; counter = 41;
for (i = 0; i < expected_len && i < 110; i++) { for (i = 0; i < expected_len && i < 110; i++) {
@ -4521,7 +4588,7 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in
if (cmp_len != expected_len) { if (cmp_len != expected_len) {
sprintf(msg, "cmp_len %d != expected_len %d", cmp_len, expected_len); sprintf(msg, "cmp_len %d != expected_len %d", cmp_len, expected_len);
return 2; return 5;
} }
ret_memcmp = memcmp(cmp_buf, expected, expected_len); ret_memcmp = memcmp(cmp_buf, expected, expected_len);
if (ret_memcmp != 0) { if (ret_memcmp != 0) {
@ -4531,7 +4598,7 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in
} }
} }
sprintf(msg, "memcmp %d != 0, at %d, len %d", ret_memcmp, i, expected_len); sprintf(msg, "memcmp %d != 0, at %d, len %d", ret_memcmp, i, expected_len);
return ret_memcmp; return ret_memcmp + 10;
} }
return 0; return 0;

Some files were not shown because too many files have changed in this diff Show more