diff --git a/backend/code1.c b/backend/code1.c index 8a0f911e..e08d7a57 100644 --- a/backend/code1.c +++ b/backend/code1.c @@ -231,10 +231,10 @@ static int c1_look_ahead_test(const unsigned char source[], const int sourcelen, byte_count += 1.0f; /* Step P2 */ } - /* If not end of data and at least 4 characters processed */ + /* If at least 4 characters processed */ /* NOTE: different than spec, where it's at least 3, but that ends up suppressing C40/TEXT/EDI. - BWIPP uses 4, as does very similar Data Matrix ISO/IEC 16022:2006 Annex P algorithm */ - if (sp + 1 != sourcelen && sp >= position + 3) { + BWIPP also uses 4 (cf very similar Data Matrix ISO/IEC 16022:2006 Annex P algorithm) */ + if (sp >= position + 3) { /* Step Q */ float cnt; ascii_rnded = (int) ceilf(ascii_count); diff --git a/backend/dmatrix.c b/backend/dmatrix.c index eb877114..d02f63a9 100644 --- a/backend/dmatrix.c +++ b/backend/dmatrix.c @@ -2,7 +2,7 @@ /* libzint - the open source barcode library - Copyright (C) 2009 - 2020 Robin Stuart + Copyright (C) 2009 - 2021 Robin Stuart developed from and including some functions from: IEC16022 bar code generation @@ -192,6 +192,7 @@ static void ecc200placement(int *array, const int NR, const int NC) { /* calculate and append ecc code, and if necessary interleave */ static void ecc200(unsigned char *binary, const int bytes, const int datablock, const int rsblock, const int skew) { int blocks = (bytes + 2) / datablock, b; + int rsblocks = rsblock * blocks; int n; rs_t rs; @@ -204,7 +205,7 @@ static void ecc200(unsigned char *binary, const int bytes, const int datablock, buf[p++] = binary[n]; rs_encode(&rs, p, buf, ecc); p = rsblock - 1; // comes back reversed - for (n = b; n < rsblock * blocks; n += blocks) { + for (n = b; n < rsblocks; n += blocks) { if (skew) { /* Rotate ecc data to make 144x144 size symbols acceptable */ /* See http://groups.google.com/group/postscriptbarcode/msg/5ae8fda7757477da */ @@ -220,93 +221,64 @@ static void ecc200(unsigned char *binary, const int bytes, const int datablock, } } -/* Return true (1) if a character is valid in X12 set */ -static int isX12(const int source) { - - switch(source) { - case 13: // CR - case 42: // * - case 62: // > - case 32: // space - return 1; - } - - if ((source >= '0') && (source <= '9')) { +/* Is basic (non-shifted) C40? */ +static int isc40(const unsigned char input) { + if ((input >= '0' && input <= '9') || (input >= 'A' && input <= 'Z') || input == ' ') { return 1; } - if ((source >= 'A') && (source <= 'Z')) { + return 0; +} + +/* Is basic (non-shifted) TEXT? */ +static int istext(const unsigned char input) { + if ((input >= '0' && input <= '9') || (input >= 'a' && input <= 'z') || input == ' ') { + return 1; + } + return 0; +} + +/* Is basic (non-shifted) C40/TEXT? */ +static int isc40text(const int current_mode, const unsigned char input) { + return current_mode == DM_C40 ? isc40(input) : istext(input); +} + +/* Return true (1) if a character is valid in X12 set */ +static int isX12(const int input) { + + if (isc40(input)) { + return 1; + } + if (input == 13 || input == '*' || input == '>') { return 1; } return 0; } -/* Insert a character into the middle of a string at position bin_posn */ -static void dminsert(char binary_string[], const int bin_posn, const char newbit) { - int i, end; - - end = (int) strlen(binary_string); - for (i = end + 1; i > bin_posn; i--) { - binary_string[i] = binary_string[i - 1]; - } - binary_string[bin_posn] = newbit; -} - -static void insert_value(unsigned char binary_stream[], const int bin_posn, const int streamlen, const int newbit) { - int i; - - for (i = streamlen; i > bin_posn; i--) { - binary_stream[i] = binary_stream[i - 1]; - } - binary_stream[bin_posn] = (unsigned char) newbit; -} - static int p_r_6_2_1(const unsigned char inputData[], const int position, const int sourcelen) { /* Annex P section (r)(6)(ii)(I) "If one of the three X12 terminator/separator characters first occurs in the yet to be processed data before a non-X12 character..." */ - int i; - int nonX12Position = 0; - int specialX12Position = 0; - int retval = 0; - for (i = position; i < sourcelen; i++) { - if (nonX12Position == 0) { - if (isX12(inputData[i]) != 1) { - nonX12Position = i; - } - } - - if (specialX12Position == 0) { - if ((inputData[i] == (char) 13) || - (inputData[i] == '*') || - (inputData[i] == '>')) { - specialX12Position = i; - } + for (i = position; i < sourcelen && isX12(inputData[i]); i++) { + if (inputData[i] == 13 || inputData[i] == '*' || inputData[i] == '>') { + return 1; } } - if ((nonX12Position != 0) && (specialX12Position != 0)) { - if (specialX12Position < nonX12Position) { - retval = 1; - } - } - - return retval; + return 0; } /* 'look ahead test' from Annex P */ static int look_ahead_test(const unsigned char inputData[], const int sourcelen, const int position, const int current_mode, const int gs1) { - float ascii_count, c40_count, text_count, x12_count, edf_count, b256_count, best_count; - const float stiction = (1.0F / 24.0F); // smallest change to act on, to get around floating point inaccuracies - int best_scheme; + float ascii_count, c40_count, text_count, x12_count, edf_count, b256_count; + int ascii_rnded, c40_rnded, text_rnded, x12_rnded, edf_rnded, b256_rnded; + float cnt_1; int sp; - best_scheme = DM_NULL; - /* step (j) */ if (current_mode == DM_ASCII) { ascii_count = 0.0F; @@ -337,216 +309,295 @@ static int look_ahead_test(const unsigned char inputData[], const int sourcelen, break; } - sp = position; - - do { - if (sp == sourcelen) { - /* At the end of data ... step (k) */ - ascii_count = ceilf(ascii_count); - b256_count = ceilf(b256_count); - edf_count = ceilf(edf_count); - text_count = ceilf(text_count); - x12_count = ceilf(x12_count); - c40_count = ceilf(c40_count); - - best_count = c40_count; - best_scheme = DM_C40; // (k)(7) - - if (x12_count < (best_count - stiction)) { - best_count = x12_count; - best_scheme = DM_X12; // (k)(6) - } - - if (text_count < (best_count - stiction)) { - best_count = text_count; - best_scheme = DM_TEXT; // (k)(5) - } - - if (edf_count < (best_count - stiction)) { - best_count = edf_count; - best_scheme = DM_EDIFACT; // (k)(4) - } - - if (b256_count < (best_count - stiction)) { - best_count = b256_count; - best_scheme = DM_BASE256; // (k)(3) - } - - if (ascii_count <= (best_count + stiction)) { - best_scheme = DM_ASCII; // (k)(2) - } + for (sp = position; sp < sourcelen; sp++) { + /* ascii ... step (l) */ + if ((inputData[sp] >= '0') && (inputData[sp] <= '9')) { + ascii_count += 0.5F; // (l)(1) } else { - - /* ascii ... step (l) */ - if ((inputData[sp] >= '0') && (inputData[sp] <= '9')) { - ascii_count += 0.5F; // (l)(1) + if (inputData[sp] > 127) { + ascii_count = ceilf(ascii_count) + 2.0F; // (l)(2) } else { - if (inputData[sp] > 127) { - ascii_count = ceilf(ascii_count) + 2.0F; // (l)(2) - } else { - ascii_count = ceilf(ascii_count) + 1.0F; // (l)(3) - } - } - - /* c40 ... step (m) */ - if ((inputData[sp] == ' ') || - (((inputData[sp] >= '0') && (inputData[sp] <= '9')) || - ((inputData[sp] >= 'A') && (inputData[sp] <= 'Z')))) { - c40_count += (2.0F / 3.0F); // (m)(1) - } else { - if (inputData[sp] > 127) { - c40_count += (8.0F / 3.0F); // (m)(2) - } else { - c40_count += (4.0F / 3.0F); // (m)(3) - } - } - - /* text ... step (n) */ - if ((inputData[sp] == ' ') || - (((inputData[sp] >= '0') && (inputData[sp] <= '9')) || - ((inputData[sp] >= 'a') && (inputData[sp] <= 'z')))) { - text_count += (2.0F / 3.0F); // (n)(1) - } else { - if (inputData[sp] > 127) { - text_count += (8.0F / 3.0F); // (n)(2) - } else { - text_count += (4.0F / 3.0F); // (n)(3) - } - } - - /* x12 ... step (o) */ - if (isX12(inputData[sp])) { - x12_count += (2.0F / 3.0F); // (o)(1) - } else { - if (inputData[sp] > 127) { - x12_count += (13.0F / 3.0F); // (o)(2) - } else { - x12_count += (10.0F / 3.0F); // (o)(3) - } - } - - /* edifact ... step (p) */ - if ((inputData[sp] >= ' ') && (inputData[sp] <= '^')) { - edf_count += (3.0F / 4.0F); // (p)(1) - } else { - if (inputData[sp] > 127) { - edf_count += 17.0F; // (p)(2) > Value changed from ISO - } else { - edf_count += 13.0F; // (p)(3) > Value changed from ISO - } - } - if (gs1 && (inputData[sp] == '[')) { - /* fnc1 and gs have the same weight of 13.0f */ - edf_count += 13.0F; // > Value changed from ISO - } - - /* base 256 ... step (q) */ - if ((gs1 == 1) && (inputData[sp] == '[')) { - /* FNC1 separator */ - b256_count += 4.0F; // (q)(1) - } else { - b256_count += 1.0F; // (q)(2) + ascii_count = ceilf(ascii_count) + 1.0F; // (l)(3) } } + /* c40 ... step (m) */ + if (isc40(inputData[sp])) { + c40_count += (2.0F / 3.0F); // (m)(1) + } else { + if (inputData[sp] > 127) { + c40_count += (8.0F / 3.0F); // (m)(2) + } else { + c40_count += (4.0F / 3.0F); // (m)(3) + } + } - if (sp > (position + 3)) { - /* 4 data characters processed ... step (r) */ + /* text ... step (n) */ + if (istext(inputData[sp])) { + text_count += (2.0F / 3.0F); // (n)(1) + } else { + if (inputData[sp] > 127) { + text_count += (8.0F / 3.0F); // (n)(2) + } else { + text_count += (4.0F / 3.0F); // (n)(3) + } + } - /* step (r)(6) */ - if (((c40_count + 1.0F) < (ascii_count - stiction)) && - ((c40_count + 1.0F) < (b256_count - stiction)) && - ((c40_count + 1.0F) < (edf_count - stiction)) && - ((c40_count + 1.0F) < (text_count - stiction))) { + /* x12 ... step (o) */ + if (isX12(inputData[sp])) { + x12_count += (2.0F / 3.0F); // (o)(1) + } else { + if (inputData[sp] > 127) { + x12_count += (13.0F / 3.0F); // (o)(2) + } else { + x12_count += (10.0F / 3.0F); // (o)(3) + } + } - if (c40_count < (x12_count - stiction)) { - best_scheme = DM_C40; + /* edifact ... step (p) */ + if ((inputData[sp] >= ' ') && (inputData[sp] <= '^')) { + edf_count += (3.0F / 4.0F); // (p)(1) + } else { + if (inputData[sp] > 127) { + edf_count += 17.0F / 4.0f; // (p)(2) + } else { + edf_count += 13.0F / 4.0f; // (p)(3) + } + } + + /* base 256 ... step (q) */ + if ((gs1 == 1) && (inputData[sp] == '[')) { + /* FNC1 separator */ + b256_count += 4.0F; // (q)(1) + } else { + b256_count += 1.0F; // (q)(2) + } + + if (sp >= position + 4) { + /* At least 5 data characters processed ... step (r) */ + /* NOTE: different than spec, where it's at least 4. Following previous behaviour here (and BWIPP) */ + + cnt_1 = ascii_count + 1.0f; + if (cnt_1 <= b256_count && cnt_1 <= edf_count && cnt_1 <= text_count && cnt_1 <= x12_count + && cnt_1 <= c40_count) { + return DM_ASCII; /* step (r)(1) */ + } + cnt_1 = b256_count + 1.0f; + if (cnt_1 <= ascii_count || (cnt_1 < edf_count && cnt_1 < text_count && cnt_1 < x12_count + && cnt_1 < c40_count)) { + return DM_BASE256; /* step (r)(2) */ + } + cnt_1 = edf_count + 1.0f; + if (cnt_1 < ascii_count && cnt_1 < b256_count && cnt_1 < text_count && cnt_1 < x12_count + && cnt_1 < c40_count) { + return DM_EDIFACT; /* step (r)(3) */ + } + cnt_1 = text_count + 1.0f; + if (cnt_1 < ascii_count && cnt_1 < b256_count && cnt_1 < edf_count && cnt_1 < x12_count + && cnt_1 < c40_count) { + return DM_TEXT; /* step (r)(4) */ + } + cnt_1 = x12_count + 1.0f; + if (cnt_1 < ascii_count && cnt_1 < b256_count && cnt_1 < edf_count && cnt_1 < text_count + && cnt_1 < c40_count) { + return DM_X12; /* step (r)(5) */ + } + cnt_1 = c40_count + 1.0f; + if (cnt_1 < ascii_count && cnt_1 < b256_count && cnt_1 < edf_count && cnt_1 < text_count) { + if (c40_count < x12_count) { + return DM_C40; /* step (r)(6)(i) */ } - - if ((c40_count >= (x12_count - stiction)) - && (c40_count <= (x12_count + stiction))) { + if (c40_count == x12_count) { if (p_r_6_2_1(inputData, sp, sourcelen) == 1) { - // Test (r)(6)(ii)(i) - best_scheme = DM_X12; - } else { - best_scheme = DM_C40; + return DM_X12; /* step (r)(6)(ii)(I) */ } + return DM_C40; /* step (r)(6)(ii)(II) */ } } - - /* step (r)(5) */ - if (((x12_count + 1.0F) < (ascii_count - stiction)) && - ((x12_count + 1.0F) < (b256_count - stiction)) && - ((x12_count + 1.0F) < (edf_count - stiction)) && - ((x12_count + 1.0F) < (text_count - stiction)) && - ((x12_count + 1.0F) < (c40_count - stiction))) { - best_scheme = DM_X12; - } - - /* step (r)(4) */ - if (((text_count + 1.0F) < (ascii_count - stiction)) && - ((text_count + 1.0F) < (b256_count - stiction)) && - ((text_count + 1.0F) < (edf_count - stiction)) && - ((text_count + 1.0F) < (x12_count - stiction)) && - ((text_count + 1.0F) < (c40_count - stiction))) { - best_scheme = DM_TEXT; - } - - /* step (r)(3) */ - if (((edf_count + 1.0F) < (ascii_count - stiction)) && - ((edf_count + 1.0F) < (b256_count - stiction)) && - ((edf_count + 1.0F) < (text_count - stiction)) && - ((edf_count + 1.0F) < (x12_count - stiction)) && - ((edf_count + 1.0F) < (c40_count - stiction))) { - best_scheme = DM_EDIFACT; - } - - /* step (r)(2) */ - if (((b256_count + 1.0F) <= (ascii_count + stiction)) || - (((b256_count + 1.0F) < (edf_count - stiction)) && - ((b256_count + 1.0F) < (text_count - stiction)) && - ((b256_count + 1.0F) < (x12_count - stiction)) && - ((b256_count + 1.0F) < (c40_count - stiction)))) { - best_scheme = DM_BASE256; - } - - /* step (r)(1) */ - if (((ascii_count + 1.0F) <= (b256_count + stiction)) && - ((ascii_count + 1.0F) <= (edf_count + stiction)) && - ((ascii_count + 1.0F) <= (text_count + stiction)) && - ((ascii_count + 1.0F) <= (x12_count + stiction)) && - ((ascii_count + 1.0F) <= (c40_count + stiction))) { - best_scheme = DM_ASCII; - } } + } - sp++; - } while (best_scheme == DM_NULL); // step (s) + /* At the end of data ... step (k) */ + /* step (k)(1) */ + ascii_rnded = (int) ceilf(ascii_count); + b256_rnded = (int) ceilf(b256_count); + edf_rnded = (int) ceilf(edf_count); + text_rnded = (int) ceilf(text_count); + x12_rnded = (int) ceilf(x12_count); + c40_rnded = (int) ceilf(c40_count); - return best_scheme; + if (ascii_rnded <= b256_rnded && ascii_rnded <= edf_rnded && ascii_rnded <= text_rnded && ascii_rnded <= x12_rnded + && ascii_rnded <= c40_rnded) { + return DM_ASCII; /* step (k)(2) */ + } + if (b256_rnded < ascii_rnded && b256_rnded < edf_rnded && b256_rnded < text_rnded && b256_rnded < x12_rnded + && b256_rnded < c40_rnded) { + return DM_BASE256; /* step (k)(3) */ + } + if (edf_rnded < ascii_rnded && edf_rnded < b256_rnded && edf_rnded < text_rnded && edf_rnded < x12_rnded + && edf_rnded < c40_rnded) { + return DM_EDIFACT; /* step (k)(4) */ + } + if (text_rnded < ascii_rnded && text_rnded < b256_rnded && text_rnded < edf_rnded && text_rnded < x12_rnded + && text_rnded < c40_rnded) { + return DM_TEXT; /* step (k)(5) */ + } + if (x12_rnded < ascii_rnded && x12_rnded < b256_rnded && x12_rnded < edf_rnded && x12_rnded < text_rnded + && x12_rnded < c40_rnded) { + return DM_X12; /* step (k)(6) */ + } + /* Note the algorithm is particularly sub-optimal here, returning C40 even if X12/EDIFACT (much) better, due to + the < comparisons of rounded X12/EDIFACT values to each other above - comparisons would need to be <= or + unrounded (cf. very similar Code One algorithm). Not changed to maintain compatibility with spec and BWIPP */ + return DM_C40; /* step (k)(7) */ +} + +/* Copy C40/TEXT/X12 triplets from buffer to target. Returns elements left in buffer (< 3) */ +static int ctx_process_buffer_transfer(int process_buffer[8], int process_p, unsigned char target[], int *p_tp, + int debug) { + int i, process_e; + int tp = *p_tp; + + process_e = (process_p / 3) * 3; + + for (i = 0; i < process_e; i += 3) { + int iv = (1600 * process_buffer[i]) + (40 * process_buffer[i + 1]) + (process_buffer[i + 2]) + 1; + target[tp++] = (unsigned char) (iv >> 8); + target[tp++] = (unsigned char) (iv & 0xFF); + if (debug) { + printf("[%d %d %d (%d %d)] ", process_buffer[i], process_buffer[i + 1], process_buffer[i + 2], + target[tp - 2], target[tp - 1]); + } + } + + process_p -= process_e; + + if (process_p) { + memmove(process_buffer, process_buffer + process_e, sizeof(int) * process_p); + } + + *p_tp = tp; + + return process_p; +} + +/* Copy EDIFACT quadruplets from buffer to target. Returns elements left in buffer (< 4) */ +static int edi_process_buffer_transfer(int process_buffer[8], int process_p, unsigned char target[], int *p_tp, + int debug) { + int i, process_e; + int tp = *p_tp; + + process_e = (process_p / 4) * 4; + + for (i = 0; i < process_e; i += 4) { + target[tp++] = (unsigned char) (process_buffer[i] << 2 | (process_buffer[i + 1] & 0x30) >> 4); + target[tp++] = (unsigned char) ((process_buffer[i + 1] & 0x0f) << 4 | (process_buffer[i + 2] & 0x3c) >> 2); + target[tp++] = (unsigned char) ((process_buffer[i + 2] & 0x03) << 6 | process_buffer[i + 3]); + if (debug) { + printf("[%d %d %d %d (%d %d %d)] ", process_buffer[i], process_buffer[i + 1], process_buffer[i + 2], + process_buffer[i + 3], target[tp - 3], target[tp - 2], target[tp - 1]); + } + } + + process_p -= process_e; + + if (process_p) { + memmove(process_buffer, process_buffer + process_e, sizeof(int) * process_p); + } + + *p_tp = tp; + + return process_p; +} + +/* Get symbol size, as specified or else smallest containing `minimum` codewords */ +static int get_symbolsize(struct zint_symbol *symbol, const int minimum) { + int i; + + if ((symbol->option_2 >= 1) && (symbol->option_2 <= DMSIZESCOUNT)) { + return intsymbol[symbol->option_2 - 1]; + } + for (i = DMSIZESCOUNT - 2; i >= 0; i--) { + if (minimum > matrixbytes[i]) { + if (symbol->option_3 == DM_DMRE) { + return i + 1; + } + if (symbol->option_3 == DM_SQUARE) { + /* Skip rectangular symbols in square only mode */ + while (i + 1 < DMSIZESCOUNT && matrixH[i + 1] != matrixW[i + 1]) { + i++; + } + return i + 1 < DMSIZESCOUNT ? i + 1 : 0; + } + /* Skip DMRE symbols in no dmre mode */ + while (i + 1 < DMSIZESCOUNT && isDMRE[i + 1]) { + i++; + } + return i + 1 < DMSIZESCOUNT ? i + 1 : 0; + } + } + return 0; +} + +/* Number of codewords remaining in a particular version (may be negative) */ +static int codewords_remaining(struct zint_symbol *symbol, const int tp, const int process_p) { + int symbolsize = get_symbolsize(symbol, tp + process_p); /* Allow for the remaining data characters */ + + return matrixbytes[symbolsize] - tp; +} + +/* Number of C40/TEXT elements needed to encode `input` */ +static int c40text_cnt(const int current_mode, const int gs1, unsigned char input) { + int cnt; + + if (gs1 && input == '[') { + return 2; + } + cnt = 1; + if (input > 127) { + cnt += 2; + input = input - 128; + } + if ((current_mode == DM_C40 && c40_shift[input]) || (current_mode == DM_TEXT && text_shift[input])) { + cnt += 1; + } + + return cnt; +} + +/* Update Base 256 field length */ +static int update_b256_field_length(unsigned char target[], int tp, int b256_start) { + int b256_count = tp - (b256_start + 1); + if (b256_count <= 249) { + target[b256_start] = b256_count; + } else { + /* Insert extra codeword */ + memmove(target + b256_start + 2, target + b256_start + 1, b256_count); + target[b256_start] = (unsigned char) (249 + (b256_count / 250)); + target[b256_start + 1] = (unsigned char) (b256_count % 250); + tp++; + } + + return tp; } /* Encodes data using ASCII, C40, Text, X12, EDIFACT or Base 256 modes as appropriate Supports encoding FNC1 in supporting systems */ static int dm200encode(struct zint_symbol *symbol, const unsigned char source[], unsigned char target[], - int *last_mode, int *last_shift, int *length_p, int process_buffer[], int *process_p, int *binlen_p) { + int *p_length, int *p_binlen) { int sp; int tp, i, gs1; int current_mode, next_mode; - int inputlen = *length_p; + int inputlen = *p_length; + int process_buffer[8]; /* holds remaining data to finalised */ + int process_p = 0; /* number of characters left to finalise */ + int b256_start = 0; + int symbols_left; int debug = symbol->debug & ZINT_DEBUG_PRINT; -#ifndef _MSC_VER - char binary[2 * inputlen + 1 + 4 + 1]; /* Allow for GS1/READER_INIT, ECI and nul chars overhead */ -#else - char* binary = (char*) _alloca(2 * inputlen + 1 + 4 + 1); -#endif sp = 0; tp = 0; - memset(process_buffer, 0, 8 * sizeof(int)); - *process_p = 0; - strcpy(binary, ""); /* step (a) */ current_mode = DM_ASCII; @@ -566,7 +617,6 @@ static int dm200encode(struct zint_symbol *symbol, const unsigned char source[], if (gs1) { target[tp] = 232; tp++; - strcat(binary, " "); if (debug) printf("FN1 "); } /* FNC1 */ @@ -577,7 +627,6 @@ static int dm200encode(struct zint_symbol *symbol, const unsigned char source[], } else { target[tp] = 234; tp++; /* Reader Programming */ - strcat(binary, " "); if (debug) printf("RP "); } } @@ -587,23 +636,20 @@ static int dm200encode(struct zint_symbol *symbol, const unsigned char source[], target[tp] = 241; /* ECI Character */ tp++; if (symbol->eci <= 126) { - target[tp] = (unsigned char) symbol->eci + 1; + target[tp] = (unsigned char) (symbol->eci + 1); tp++; - strcat(binary, " "); } else if (symbol->eci <= 16382) { - target[tp] = (unsigned char) ((symbol->eci - 127) / 254) + 128; + target[tp] = (unsigned char) ((symbol->eci - 127) / 254 + 128); tp++; - target[tp] = (unsigned char) ((symbol->eci - 127) % 254) + 1; + target[tp] = (unsigned char) ((symbol->eci - 127) % 254 + 1); tp++; - strcat(binary, " "); } else { - target[tp] = (unsigned char) ((symbol->eci - 16383) / 64516) + 192; + target[tp] = (unsigned char) ((symbol->eci - 16383) / 64516 + 192); tp++; - target[tp] = (unsigned char) (((symbol->eci - 16383) / 254) % 254) + 1; + target[tp] = (unsigned char) (((symbol->eci - 16383) / 254) % 254 + 1); tp++; - target[tp] = (unsigned char) ((symbol->eci - 16383) % 254) + 1; + target[tp] = (unsigned char) ((symbol->eci - 16383) % 254 + 1); tp++; - strcat(binary, " "); } if (debug) printf("ECI %d ", symbol->eci + 1); } @@ -626,14 +672,12 @@ static int dm200encode(struct zint_symbol *symbol, const unsigned char source[], if (debug) printf("Macro06 "); } tp++; - strcat(binary, " "); /* Remove macro characters from input string */ sp = 7; inputlen -= 2; - *length_p -= 2; + *p_length -= 2; } - while (sp < inputlen) { current_mode = next_mode; @@ -646,7 +690,6 @@ static int dm200encode(struct zint_symbol *symbol, const unsigned char source[], target[tp] = (unsigned char) ((10 * ctoi(source[sp])) + ctoi(source[sp + 1]) + 130); if (debug) printf("N%02d ", target[tp] - 130); tp++; - strcat(binary, " "); sp += 2; } else { next_mode = look_ahead_test(source, inputlen, sp, current_mode, gs1); @@ -655,43 +698,38 @@ static int dm200encode(struct zint_symbol *symbol, const unsigned char source[], switch (next_mode) { case DM_C40: target[tp] = 230; tp++; - strcat(binary, " "); if (debug) printf("C40 "); break; case DM_TEXT: target[tp] = 239; tp++; - strcat(binary, " "); if (debug) printf("TEX "); break; case DM_X12: target[tp] = 238; tp++; - strcat(binary, " "); if (debug) printf("X12 "); break; case DM_EDIFACT: target[tp] = 240; tp++; - strcat(binary, " "); if (debug) printf("EDI "); break; case DM_BASE256: target[tp] = 231; tp++; - strcat(binary, " "); + b256_start = tp; + target[tp++] = 0; /* Byte count holder (may be expanded to 2 codewords) */ if (debug) printf("BAS "); break; } } else { if (source[sp] > 127) { target[tp] = 235; /* FNC4 */ - if (debug) printf("FN4 "); tp++; target[tp] = (source[sp] - 128) + 1; - if (debug) printf("A%02X ", target[tp] - 1); tp++; - strcat(binary, " "); + if (debug) printf("FN4 A%02X ", target[tp - 1] - 1); } else { if (gs1 && (source[sp] == '[')) { - if (gs1==2) { - target[tp] = 29+1; /* GS */ + if (gs1 == 2) { + target[tp] = 29 + 1; /* GS */ if (debug) printf("GS "); } else { target[tp] = 232; /* FNC1 */ @@ -702,272 +740,145 @@ static int dm200encode(struct zint_symbol *symbol, const unsigned char source[], if (debug) printf("A%02X ", target[tp] - 1); } tp++; - strcat(binary, " "); } sp++; } } - } + /* step (c)/(d) C40/TEXT encodation */ + } else if (current_mode == DM_C40 || current_mode == DM_TEXT) { - /* step (c) C40 encodation */ - if (current_mode == DM_C40) { - - next_mode = DM_C40; - if (*process_p == 0) { + next_mode = current_mode; + if (process_p == 0) { next_mode = look_ahead_test(source, inputlen, sp, current_mode, gs1); } - if (next_mode != DM_C40) { - target[tp] = 254; + if (next_mode != current_mode) { + target[tp] = 254; /* Unlatch */ tp++; - strcat(binary, " "); /* Unlatch */ next_mode = DM_ASCII; if (debug) printf("ASC "); } else { int shift_set, value; + const char *ct_shift, *ct_value; + + if (current_mode == DM_C40) { + ct_shift = c40_shift; + ct_value = c40_value; + } else { + ct_shift = text_shift; + ct_value = text_value; + } + if (source[sp] > 127) { - process_buffer[*process_p] = 1; - (*process_p)++; - process_buffer[*process_p] = 30; - (*process_p)++; /* Upper Shift */ - shift_set = c40_shift[source[sp] - 128]; - value = c40_value[source[sp] - 128]; + process_buffer[process_p++] = 1; + process_buffer[process_p++] = 30; /* Upper Shift */ + shift_set = ct_shift[source[sp] - 128]; + value = ct_value[source[sp] - 128]; } else { if (gs1 && (source[sp] == '[')) { if (gs1 == 2) { - shift_set = c40_shift[29]; - value = c40_value[29]; /* GS */ + shift_set = ct_shift[29]; + value = ct_value[29]; /* GS */ } else { shift_set = 2; value = 27; /* FNC1 */ } } else { - shift_set = c40_shift[source[sp]]; - value = c40_value[source[sp]]; - } - if (*process_p % 3 == 2) { - *last_shift = shift_set; + shift_set = ct_shift[source[sp]]; + value = ct_value[source[sp]]; } } if (shift_set != 0) { - process_buffer[*process_p] = shift_set - 1; - (*process_p)++; + process_buffer[process_p++] = shift_set - 1; } - process_buffer[*process_p] = value; - (*process_p)++; + process_buffer[process_p++] = value; - while (*process_p >= 3) { - unsigned int iv; - - iv = (1600 * process_buffer[0]) + (40 * process_buffer[1]) + (process_buffer[2]) + 1; - target[tp] = (unsigned char) (iv >> 8); - tp++; - target[tp] = (unsigned char) (iv & 0xFF); - tp++; - strcat(binary, " "); - if (debug) printf("[%d %d %d] ", process_buffer[0], process_buffer[1], process_buffer[2]); - - process_buffer[0] = process_buffer[3]; - process_buffer[1] = process_buffer[4]; - process_buffer[2] = process_buffer[5]; - process_buffer[3] = 0; - process_buffer[4] = 0; - process_buffer[5] = 0; - *process_p -= 3; + if (process_p >= 3) { + process_p = ctx_process_buffer_transfer(process_buffer, process_p, target, &tp, debug); } sp++; } - } - - /* step (d) Text encodation */ - if (current_mode == DM_TEXT) { - - next_mode = DM_TEXT; - if (*process_p == 0) { - next_mode = look_ahead_test(source, inputlen, sp, current_mode, gs1); - } - - if (next_mode != DM_TEXT) { - target[tp] = 254; - tp++; - strcat(binary, " "); /* Unlatch */ - next_mode = DM_ASCII; - if (debug) printf("ASC "); - } else { - int shift_set, value; - if (source[sp] > 127) { - process_buffer[*process_p] = 1; - (*process_p)++; - process_buffer[*process_p] = 30; - (*process_p)++; /* Upper Shift */ - shift_set = text_shift[source[sp] - 128]; - value = text_value[source[sp] - 128]; - } else { - if (gs1 && (source[sp] == '[')) { - if (gs1 == 2) { - shift_set = text_shift[29]; - value = text_value[29]; /* GS */ - } else { - shift_set = 2; - value = 27; /* FNC1 */ - } - } else { - shift_set = text_shift[source[sp]]; - value = text_value[source[sp]]; - } - if (*process_p % 3 == 2) { - *last_shift = shift_set; - } - } - - if (shift_set != 0) { - process_buffer[*process_p] = shift_set - 1; - (*process_p)++; - } - process_buffer[*process_p] = value; - (*process_p)++; - - while (*process_p >= 3) { - unsigned int iv; - - iv = (1600 * process_buffer[0]) + (40 * process_buffer[1]) + (process_buffer[2]) + 1; - target[tp] = (unsigned char) (iv >> 8); - tp++; - target[tp] = (unsigned char) (iv & 0xFF); - tp++; - strcat(binary, " "); - if (debug) printf("[%d %d %d] ", process_buffer[0], process_buffer[1], process_buffer[2]); - - process_buffer[0] = process_buffer[3]; - process_buffer[1] = process_buffer[4]; - process_buffer[2] = process_buffer[5]; - process_buffer[3] = 0; - process_buffer[4] = 0; - process_buffer[5] = 0; - *process_p -= 3; - } - sp++; - } - } /* step (e) X12 encodation */ - if (current_mode == DM_X12) { + } else if (current_mode == DM_X12) { next_mode = DM_X12; - if (*process_p == 0) { + if (process_p == 0) { next_mode = look_ahead_test(source, inputlen, sp, current_mode, gs1); } if (next_mode != DM_X12) { - target[tp] = 254; + target[tp] = 254; /* Unlatch */ tp++; - strcat(binary, " "); /* Unlatch */ next_mode = DM_ASCII; if (debug) printf("ASC "); } else { + static const char x12_nonalphanum_chars[] = "\015*> "; int value = 0; - if (source[sp] == 13) { - value = 0; - } else if (source[sp] == '*') { - value = 1; - } else if (source[sp] == '>') { - value = 2; - } else if (source[sp] == ' ') { - value = 3; - } else if ((source[sp] >= '0') && (source[sp] <= '9')) { + + if ((source[sp] >= '0') && (source[sp] <= '9')) { value = (source[sp] - '0') + 4; } else if ((source[sp] >= 'A') && (source[sp] <= 'Z')) { value = (source[sp] - 'A') + 14; + } else { + value = posn(x12_nonalphanum_chars, source[sp]); } - process_buffer[*process_p] = value; - (*process_p)++; + process_buffer[process_p++] = value; - while (*process_p >= 3) { - unsigned int iv; - - iv = (1600 * process_buffer[0]) + (40 * process_buffer[1]) + (process_buffer[2]) + 1; - target[tp] = (unsigned char) (iv >> 8); - tp++; - target[tp] = (unsigned char) (iv & 0xFF); - tp++; - strcat(binary, " "); - if (debug) printf("[%d %d %d] ", process_buffer[0], process_buffer[1], process_buffer[2]); - - process_buffer[0] = process_buffer[3]; - process_buffer[1] = process_buffer[4]; - process_buffer[2] = process_buffer[5]; - process_buffer[3] = 0; - process_buffer[4] = 0; - process_buffer[5] = 0; - *process_p -= 3; + if (process_p >= 3) { + process_p = ctx_process_buffer_transfer(process_buffer, process_p, target, &tp, debug); } sp++; } - } /* step (f) EDIFACT encodation */ - if (current_mode == DM_EDIFACT) { + } else if (current_mode == DM_EDIFACT) { next_mode = DM_EDIFACT; - if (*process_p == 3) { + if (process_p == 3) { + /* Note different then spec Step (f)(1), which suggests checking when 0, but this seems to work + better in many cases. */ next_mode = look_ahead_test(source, inputlen, sp, current_mode, gs1); } if (next_mode != DM_EDIFACT) { - process_buffer[*process_p] = 31; - (*process_p)++; + process_buffer[process_p++] = 31; next_mode = DM_ASCII; } else { int value = source[sp]; - if (source[sp] >= 64) { // '@' + if (value >= 64) { // '@' value -= 64; } - process_buffer[*process_p] = value; - (*process_p)++; + process_buffer[process_p++] = value; sp++; } - while (*process_p >= 4) { - target[tp] = (unsigned char) ((process_buffer[0] << 2) + ((process_buffer[1] & 0x30) >> 4)); - tp++; - target[tp] = ((process_buffer[1] & 0x0f) << 4) + ((process_buffer[2] & 0x3c) >> 2); - tp++; - target[tp] = (unsigned char) (((process_buffer[2] & 0x03) << 6) + process_buffer[3]); - tp++; - strcat(binary, " "); - if (debug) { - printf("[%d %d %d %d] ", process_buffer[0], process_buffer[1], process_buffer[2], - process_buffer[3]); - } - - process_buffer[0] = process_buffer[4]; - process_buffer[1] = process_buffer[5]; - process_buffer[2] = process_buffer[6]; - process_buffer[3] = process_buffer[7]; - process_buffer[4] = 0; - process_buffer[5] = 0; - process_buffer[6] = 0; - process_buffer[7] = 0; - *process_p -= 4; + if (process_p >= 4) { + process_p = edi_process_buffer_transfer(process_buffer, process_p, target, &tp, debug); } - } + if (debug && next_mode == DM_ASCII) printf("ASC "); /* step (g) Base 256 encodation */ - if (current_mode == DM_BASE256) { + } else if (current_mode == DM_BASE256) { next_mode = look_ahead_test(source, inputlen, sp, current_mode, gs1); if (next_mode == DM_BASE256) { target[tp] = source[sp]; - if (debug) printf("B%02X ", target[tp]); tp++; sp++; - strcat(binary, "b"); + if (debug) printf("B%02X ", target[tp - 1]); } else { + tp = update_b256_field_length(target, tp, b256_start); + /* B.2.1 255-state randomising algorithm */ + for (i = b256_start; i < tp; i++) { + int prn = ((149 * (i + 1)) % 255) + 1; + target[i] = (unsigned char) ((target[i] + prn) & 0xFF); + } next_mode = DM_ASCII; if (debug) printf("ASC "); } @@ -980,196 +891,141 @@ static int dm200encode(struct zint_symbol *symbol, const unsigned char source[], } /* while */ - if (debug) printf("\n"); + symbols_left = codewords_remaining(symbol, tp, process_p); - /* Add length and randomising algorithm to b256 */ - i = 0; - while (i < tp) { - if (binary[i] == 'b') { - if ((i == 0) || (binary[i - 1] != 'b')) { - /* start of binary data */ - int binary_count; /* length of b256 data */ + if (debug) printf("\nsymbols_left %d, process_p %d ", symbols_left, process_p); - for (binary_count = 0; binary_count + i < tp && binary[binary_count + i] == 'b'; binary_count++); - - if (binary_count <= 249) { - dminsert(binary, i, 'b'); - insert_value(target, i, tp, binary_count); - tp++; - } else { - dminsert(binary, i, 'b'); - dminsert(binary, i + 1, 'b'); - insert_value(target, i, tp, (binary_count / 250) + 249); - tp++; - insert_value(target, i + 1, tp, binary_count % 250); - tp++; - } - } - } - i++; - } - - for (i = 0; i < tp; i++) { - if (binary[i] == 'b') { - int prn, temp; - - prn = ((149 * (i + 1)) % 255) + 1; - temp = target[i] + prn; - if (temp <= 255) { - target[i] = (unsigned char) (temp); - } else { - target[i] = (unsigned char) (temp - 256); - } - } - } - - *(last_mode) = current_mode; - *binlen_p = tp; - return 0; -} - -static int dm200encode_remainder(unsigned char target[], int target_length, const unsigned char source[], - const int inputlen, const int last_mode, const int last_shift, const int process_buffer[], - const int process_p, const int symbols_left, int debug) { - - switch (last_mode) { - case DM_C40: - case DM_TEXT: - /* NOTE: the use of a 0-padded doublet is only mentioned in ISO/IEC 16022:2006 for case 5.2.5.2 (b) - * when 2 symbols and 2 C40/Text characters are left, but using it here also for other cases. This - * matches the behaviour of tec-it (but not BWIPP) and is used for figures 4.15-1-1 and 4.15-1-1 in - * GS1 General Specifications. - */ - if (debug) { - printf("%s last_shift %d, symbols_left %d, process_p %d ", last_mode == DM_C40 ? "C40" : "TEX", - last_shift, symbols_left, process_p); - } - if (process_p == 1) // 1 data character left to encode. - { - if (last_shift) { - // Remove shift from second half of previous doublet leaving pad value (0) - target[target_length - 1] -= last_shift - 1; - } - if (symbols_left > 1) { - target[target_length] = 254; - target_length++; // Unlatch and encode remaining data in ascii. - if (debug) printf("ASC "); - } - target[target_length] = source[inputlen - 1] + 1; - if (debug) printf("A%02X ", target[target_length] - 1); - target_length++; - } else if (process_p == 2) // 2 data characters left to encode. - { - // Pad with shift 1 value (0) and encode as double. - unsigned int intValue = (1600 * process_buffer[0]) + (40 * process_buffer[1]) + 1; // ie (0 + 1). - target[target_length] = (unsigned char) (intValue >> 8); - target_length++; - target[target_length] = (unsigned char) (intValue & 0xFF); - target_length++; - if (debug) printf("[%d %d %d] ", process_buffer[0], process_buffer[1], 0); - if (symbols_left > 2) { - target[target_length] = 254; // Unlatch - target_length++; - if (debug) printf("ASC "); - } - } else { - if (symbols_left > 0) { - target[target_length] = 254; // Unlatch - target_length++; - if (debug) printf("ASC "); - } - } - break; - - case DM_X12: - if (debug) printf("X12 symbols_left %d, process_p %d ", symbols_left, process_p); - if ((symbols_left == process_p) && (process_p == 1)) { - // Unlatch not required! - target[target_length] = source[inputlen - 1] + 1; - if (debug) printf("A%02X ", target[target_length] - 1); - target_length++; - } else if (symbols_left) { - target[target_length] = (254); - target_length++; // Unlatch. + if (current_mode == DM_C40 || current_mode == DM_TEXT) { + /* NOTE: changed to follow spec exactly here, only using Shift 1 padded triplets when 2 symbol chars remain. + This matches the behaviour of BWIPP but not tec-it, nor figures 4.15.1-1 and 4.15-1-2 in GS1 General + Specifications 21.0.1. + */ + if (debug) printf("%s ", current_mode == DM_C40 ? "C40" : "TEX"); + if (process_p == 0) { + if (symbols_left > 0) { + target[tp++] = 254; // Unlatch if (debug) printf("ASC "); - - if (process_p == 1) { - target[target_length] = source[inputlen - 1] + 1; - if (debug) printf("A%02X ", target[target_length] - 1); - target_length++; - } else if (process_p == 2) { - target[target_length] = source[inputlen - 2] + 1; - if (debug) printf("A%02X ", target[target_length] - 1); - target_length++; - target[target_length] = source[inputlen - 1] + 1; - if (debug) printf("A%02X ", target[target_length] - 1); - target_length++; - } } - break; + } else { + if (process_p == 2 && symbols_left == 2) { + /* 5.2.5.2 (b) */ + process_buffer[process_p++] = 0; // Shift 1 + (void)ctx_process_buffer_transfer(process_buffer, process_p, target, &tp, debug); - case DM_EDIFACT: - if (debug) printf("EDI symbols_left %d, process_p %d ", symbols_left, process_p); - if (symbols_left <= 2) // Unlatch not required! - { - if (process_p == 1) { - target[target_length] = source[inputlen - 1] + 1; - if (debug) printf("A%02X ", target[target_length] - 1); - target_length++; - } else if (process_p == 2) { - target[target_length] = source[inputlen - 2] + 1; - if (debug) printf("A%02X ", target[target_length] - 1); - target_length++; - target[target_length] = source[inputlen - 1] + 1; - if (debug) printf("A%02X ", target[target_length] - 1); - target_length++; + } else if (process_p == 1 && symbols_left <= 2 && isc40text(current_mode, source[inputlen - 1])) { + /* 5.2.5.2 (c)/(d) */ + if (symbols_left > 1) { + /* 5.2.5.2 (c) */ + target[tp++] = 254; // Unlatch and encode remaining data in ascii. + if (debug) printf("ASC "); } + target[tp++] = source[inputlen - 1] + 1; + if (debug) printf("A%02X ", target[tp - 1] - 1); + } else { - // Append edifact unlatch value (31) and empty buffer - if (process_p == 0) { - target[target_length] = (unsigned char) (31 << 2); - target_length++; - if (debug) printf("[31 0 0 0] "); - } else if (process_p == 1) { - target[target_length] = (unsigned char) ((process_buffer[0] << 2) + ((31 & 0x30) >> 4)); - target_length++; - target[target_length] = (unsigned char) ((31 & 0x0f) << 4); - target_length++; - if (debug) printf("[%d 31 0 0] ", process_buffer[0]); - } else if (process_p == 2) { - target[target_length] = (unsigned char) ((process_buffer[0] << 2) - + ((process_buffer[1] & 0x30) >> 4)); - target_length++; - target[target_length] = (unsigned char) (((process_buffer[1] & 0x0f) << 4) + ((31 & 0x3c) >> 2)); - target_length++; - target[target_length] = (unsigned char) (((31 & 0x03) << 6)); - target_length++; - if (debug) printf("[%d %d 31 0] ", process_buffer[0], process_buffer[1]); - } else if (process_p == 3) { - target[target_length] = (unsigned char) ((process_buffer[0] << 2) - + ((process_buffer[1] & 0x30) >> 4)); - target_length++; - target[target_length] = (unsigned char) (((process_buffer[1] & 0x0f) << 4) - + ((process_buffer[2] & 0x3c) >> 2)); - target_length++; - target[target_length] = (unsigned char) (((process_buffer[2] & 0x03) << 6) + 31); - target_length++; - if (debug) printf("[%d %d %d 31] ", process_buffer[0], process_buffer[1], process_buffer[2]); + int cnt, total_cnt = 0; + /* Backtrack to last complete triplet (same technique as BWIPP) */ + while (sp > 0 && process_p % 3) { + sp--; + cnt = c40text_cnt(current_mode, gs1, source[sp]); + total_cnt += cnt; + process_p -= cnt; + } + tp -= (total_cnt / 3) * 2; + + target[tp++] = 254; // Unlatch + if (debug) printf("ASC "); + for (; sp < inputlen; sp++) { + if (istwodigits(source, inputlen, sp)) { + target[tp++] = (unsigned char) ((10 * ctoi(source[sp])) + ctoi(source[sp + 1]) + 130); + if (debug) printf("N%02d ", target[tp - 1] - 130); + sp++; + } else if (source[sp] > 127) { + target[tp++] = 235; /* FNC4 */ + target[tp++] = (source[sp] - 128) + 1; + if (debug) printf("FN4 A%02X ", target[tp - 1] - 1); + } else if (gs1 && source[sp] == '[') { + if (gs1 == 2) { + target[tp] = 29 + 1; /* GS */ + if (debug) printf("GS "); + } else { + target[tp] = 232; /* FNC1 */ + if (debug) printf("FN1 "); + } + } else { + target[tp++] = source[sp] + 1; + if (debug) printf("A%02X ", target[tp - 1] - 1); + } } } - break; + } + + } else if (current_mode == DM_X12) { + if (debug) printf("X12 "); + if ((symbols_left == 1) && (process_p == 1)) { + // Unlatch not required! + target[tp++] = source[inputlen - 1] + 1; + if (debug) printf("A%02X ", target[tp - 1] - 1); + } else { + if (symbols_left > 0) { + target[tp++] = (254); // Unlatch. + if (debug) printf("ASC "); + } + + if (process_p == 1) { + target[tp++] = source[inputlen - 1] + 1; + if (debug) printf("A%02X ", target[tp - 1] - 1); + } else if (process_p == 2) { + target[tp++] = source[inputlen - 2] + 1; + target[tp++] = source[inputlen - 1] + 1; + if (debug) printf("A%02X A%02X ", target[tp - 2] - 1, target[tp - 1] - 1); + } + } + + } else if (current_mode == DM_EDIFACT) { + if (debug) printf("EDI "); + if (symbols_left <= 2 && process_p <= symbols_left) { // Unlatch not required! + if (process_p == 1) { + target[tp++] = source[inputlen - 1] + 1; + if (debug) printf("A%02X ", target[tp - 1] - 1); + } else if (process_p == 2) { + target[tp++] = source[inputlen - 2] + 1; + target[tp++] = source[inputlen - 1] + 1; + if (debug) printf("A%02X A%02X ", target[tp - 2] - 1, target[tp - 1] - 1); + } + } else { + // Append edifact unlatch value (31) and empty buffer + if (process_p <= 3) { + process_buffer[process_p++] = 31; + if (process_p < 4) { + memset(process_buffer + process_p, 0, sizeof(int) * (4 - process_p)); + } + } + (void)edi_process_buffer_transfer(process_buffer, 4, target, &tp, debug); + } + + } else if (current_mode == DM_BASE256) { + if (symbols_left > 0) { + tp = update_b256_field_length(target, tp, b256_start); + } + /* B.2.1 255-state randomising algorithm */ + for (i = b256_start; i < tp; i++) { + int prn = ((149 * (i + 1)) % 255) + 1; + target[i] = (unsigned char) ((target[i] + prn) & 0xFF); + } } if (debug) { - int i; - printf("\nData (%d): ", target_length); - for (i = 0; i < target_length; i++) + printf("\nData (%d): ", tp); + for (i = 0; i < tp; i++) printf("%d ", target[i]); printf("\n"); } - return target_length; + *p_binlen = tp; + + return 0; } /* add pad bits */ @@ -1181,6 +1037,7 @@ static void add_tail(unsigned char target[], int tp, const int tail_length) { target[tp] = 129; tp++; /* Pad */ } else { + /* B.1.1 253-state randomising algorithm */ prn = ((149 * (tp + 1)) % 253) + 1; temp = 129 + prn; if (temp <= 254) { @@ -1198,69 +1055,26 @@ static int data_matrix_200(struct zint_symbol *symbol, const unsigned char sourc int i, skew = 0; unsigned char binary[2200]; int binlen; - int process_buffer[8]; /* holds remaining data to finalised */ - int process_p; /* number of characters left to finalise */ - int symbolsize, optionsize, calcsize; + int symbolsize; int taillength, error_number = 0; int H, W, FH, FW, datablock, bytes, rsblock; - int last_mode = DM_ASCII; - int last_shift = 0; - int symbols_left; int debug = symbol->debug & ZINT_DEBUG_PRINT; /* inputlen may be decremented by 2 if macro character is used */ - error_number = dm200encode(symbol, source, binary, &last_mode, &last_shift, &inputlen, process_buffer, - &process_p, &binlen); + error_number = dm200encode(symbol, source, binary, &inputlen, &binlen); if (error_number != 0) { return error_number; } - if ((symbol->option_2 >= 1) && (symbol->option_2 <= DMSIZESCOUNT)) { - optionsize = intsymbol[symbol->option_2 - 1]; - } else { - optionsize = -1; - } - - calcsize = DMSIZESCOUNT - 1; - for (i = DMSIZESCOUNT - 1; i > -1; i--) { - if (matrixbytes[i] >= (binlen + process_p)) { - // Allow for the remaining data characters - calcsize = i; - } - } - - if (optionsize == -1) { - // We are in automatic size mode as the exact symbol size was not given - // Now check the detailed search options square only or no dmre - if (symbol->option_3 == DM_SQUARE) { - /* Skip rectangular symbols in square only mode */ - while (matrixH[calcsize] != matrixW[calcsize]) { - calcsize++; - } - } else if (symbol->option_3 != DM_DMRE) { - /* Skip DMRE symbols in no dmre mode */ - while (isDMRE[calcsize]) { - calcsize++; - } - } - symbolsize = calcsize; - } else { - // The symbol size was given by --ver (option_2) - // Thus check if the data fits into this symbol size and use this size - if (calcsize > optionsize) { - strcpy(symbol->errtxt, "522: Input too long for selected symbol size"); - return ZINT_ERROR_TOO_LONG; - } - symbolsize = optionsize; - } - - // Now we know the symbol size we can handle the remaining data in the process buffer. - symbols_left = matrixbytes[symbolsize] - binlen; - binlen = dm200encode_remainder(binary, binlen, source, inputlen, last_mode, last_shift, process_buffer, - process_p, symbols_left, debug); + symbolsize = get_symbolsize(symbol, binlen); if (binlen > matrixbytes[symbolsize]) { - strcpy(symbol->errtxt, "523: Data too long to fit in symbol"); + if ((symbol->option_2 >= 1) && (symbol->option_2 <= DMSIZESCOUNT)) { + // The symbol size was given by --ver (option_2) + strcpy(symbol->errtxt, "522: Input too long for selected symbol size"); + } else { + strcpy(symbol->errtxt, "523: Data too long to fit in symbol"); + } return ZINT_ERROR_TOO_LONG; } diff --git a/backend/eci.h b/backend/eci.h index 5312342a..f1f6596f 100644 --- a/backend/eci.h +++ b/backend/eci.h @@ -47,5 +47,3 @@ INTERNAL int get_best_eci(const unsigned char source[], int length); #endif #endif /* ECI_H */ - - diff --git a/backend/tests/test_2of5.c b/backend/tests/test_2of5.c index 21adeb04..75a64bd2 100644 --- a/backend/tests/test_2of5.c +++ b/backend/tests/test_2of5.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2020 Robin Stuart + Copyright (C) 2020 - 2021 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -82,7 +82,7 @@ static void test_large(int index, int debug) { ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, 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 < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); } @@ -176,7 +176,7 @@ static void test_input(int index, int debug) { ret = ZBarcode_Encode(symbol, (unsigned char *) 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 < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); } @@ -271,10 +271,10 @@ static void test_encode(int index, int generate, int debug) { printf(" /*%3d*/ { %s, \"%s\", %s, %d, %d, \"%s\",\n", i, testUtilBarcodeName(data[i].symbology), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment); - testUtilModulesDump(symbol, " ", "\n"); + testUtilModulesPrint(symbol, " ", "\n"); printf(" },\n"); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data); diff --git a/backend/tests/test_auspost.c b/backend/tests/test_auspost.c index 1025322f..9c089fb5 100644 --- a/backend/tests/test_auspost.c +++ b/backend/tests/test_auspost.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2020 Robin Stuart + Copyright (C) 2020 - 2021 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -82,7 +82,7 @@ static void test_large(int index, int debug) { ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, 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 < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); } @@ -177,7 +177,7 @@ static void test_input(int index, int debug) { ret = ZBarcode_Encode(symbol, (unsigned char *) 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 < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); } @@ -271,10 +271,10 @@ static void test_encode(int index, int generate, int debug) { printf(" /*%3d*/ { %s, \"%s\", %s, %d, %d, \"%s\",\n", i, testUtilBarcodeName(data[i].symbology), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment); - testUtilModulesDump(symbol, " ", "\n"); + testUtilModulesPrint(symbol, " ", "\n"); printf(" },\n"); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data); @@ -320,7 +320,7 @@ static void test_fuzz(int index, int debug) { /* 4*/ { BARCODE_AUSREDIRECT, "A\000\000\000", 4, ZINT_ERROR_INVALID_DATA }, /* 5*/ { BARCODE_AUSREDIRECT, "1\000\000\000", 4, ZINT_ERROR_INVALID_DATA }, }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); for (int i = 0; i < data_size; i++) { @@ -329,13 +329,7 @@ static void test_fuzz(int index, int debug) { struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - symbol->symbology = data[i].symbology; - symbol->debug |= debug; - - int length = data[i].length; - if (length == -1) { - length = strlen(data[i].data); - } + int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, data[i].length, debug); ret = ZBarcode_Encode(symbol, (unsigned char *) 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); diff --git a/backend/tests/test_aztec.c b/backend/tests/test_aztec.c index ba072090..48e59135 100644 --- a/backend/tests/test_aztec.c +++ b/backend/tests/test_aztec.c @@ -1492,10 +1492,10 @@ static void test_encode(int index, int generate, int debug) { i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), data[i].eci, testUtilOutputOptionsName(data[i].output_options), data[i].option_1, data[i].option_2, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length, testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].comment); - testUtilModulesDump(symbol, " ", "\n"); + testUtilModulesPrint(symbol, " ", "\n"); printf(" },\n"); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data); diff --git a/backend/tests/test_channel.c b/backend/tests/test_channel.c index 6ce7dc3b..37d203bd 100644 --- a/backend/tests/test_channel.c +++ b/backend/tests/test_channel.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2019 - 2020 Robin Stuart + Copyright (C) 2019 - 2021 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -107,7 +107,7 @@ static void test_input(int index, int debug) { ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret); - if (ret < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data); } @@ -369,10 +369,10 @@ static void test_encode(int index, int generate, int debug) { printf(" /*%3d*/ { %d, \"%s\", %s, %d, %d, \"%s\",\n", i, data[i].option_2, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment); - testUtilModulesDump(symbol, " ", "\n"); + testUtilModulesPrint(symbol, " ", "\n"); printf(" },\n"); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data); diff --git a/backend/tests/test_codablock.c b/backend/tests/test_codablock.c index 00427cb5..93aed67b 100644 --- a/backend/tests/test_codablock.c +++ b/backend/tests/test_codablock.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2019 - 2020 Robin Stuart + Copyright (C) 2019 - 2021 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -74,7 +74,7 @@ static void test_large(int index, int debug) { ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, 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 < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); } @@ -141,7 +141,7 @@ static void test_options(int index, int debug) { ret = ZBarcode_Encode(symbol, (unsigned char *) 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 < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data); } @@ -196,7 +196,7 @@ static void test_reader_init(int index, int generate, int debug) { testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->rows, symbol->width, symbol->errtxt, data[i].comment); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { 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->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((char *) symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); @@ -303,7 +303,7 @@ static void test_input(int index, int generate, int debug) { testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length, testUtilErrorName(data[i].ret), symbol->rows, symbol->width, symbol->errtxt, data[i].comment); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { 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->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((char *) symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); @@ -433,10 +433,10 @@ static void test_encode(int index, int generate, int debug) { 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)), testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].comment); - testUtilModulesDump(symbol, " ", "\n"); + testUtilModulesPrint(symbol, " ", "\n"); printf(" },\n"); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data); diff --git a/backend/tests/test_code.c b/backend/tests/test_code.c index 500b627f..65b3e3fd 100644 --- a/backend/tests/test_code.c +++ b/backend/tests/test_code.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2020 Robin Stuart + Copyright (C) 2020 - 2021 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -91,7 +91,7 @@ static void test_large(int index, int debug) { ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, 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 < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); } @@ -226,7 +226,7 @@ static void test_input(int index, int debug) { ret = ZBarcode_Encode(symbol, (unsigned char *) 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 < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); } @@ -358,10 +358,10 @@ static void test_encode(int index, int generate, int debug) { printf(" /*%3d*/ { %s, %d, \"%s\", %d, %s, %d, %d, \"%s\",\n", i, testUtilBarcodeName(data[i].symbology), data[i].option_2, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length, testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment); - testUtilModulesDump(symbol, " ", "\n"); + testUtilModulesPrint(symbol, " ", "\n"); printf(" },\n"); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data); diff --git a/backend/tests/test_code1.c b/backend/tests/test_code1.c index 4cb9f2ba..8dd95dbd 100644 --- a/backend/tests/test_code1.c +++ b/backend/tests/test_code1.c @@ -2525,7 +2525,7 @@ static void test_encode(int index, int generate, int debug) { testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length, testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].comment); if (ret < ZINT_ERROR) { - testUtilModulesDump(symbol, " ", "\n"); + testUtilModulesPrint(symbol, " ", "\n"); } else { printf(" \"\"\n"); } diff --git a/backend/tests/test_code128.c b/backend/tests/test_code128.c index 7929dec5..27ebcb14 100644 --- a/backend/tests/test_code128.c +++ b/backend/tests/test_code128.c @@ -90,7 +90,7 @@ static void test_large(int index, int debug) { ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, 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 < 5) { + if (ret < ZINT_ERROR) { assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); } @@ -256,7 +256,7 @@ static void test_reader_init(int index, int generate, int debug) { testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->rows, symbol->width, symbol->errtxt, data[i].comment); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { 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->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); @@ -327,7 +327,7 @@ static void test_input(int index, int generate, int debug) { /* 32*/ { UNICODE_MODE, "aééééébcdeééé", -1, 0, 244, "(22) 104 65 100 100 73 73 73 73 73 100 66 100 67 100 68 100 69 73 73 73 83 106", "StartB a Latch é (5) Shift b Shift c Shift d Shift e é (3)" }, /* 33*/ { UNICODE_MODE, "aééééébcdefééé", -1, 0, 255, "(23) 104 65 100 100 73 73 73 73 73 100 100 66 67 68 69 70 100 100 73 73 73 67 106", "StartB a Latch é (5) Unlatch b c d e f Latch é (3)" }, }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); char escaped[1024]; @@ -350,7 +350,7 @@ static void test_input(int index, int generate, int debug) { i, testUtilInputModeName(data[i].input_mode), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length, testUtilErrorName(data[i].ret), symbol->width, symbol->errtxt, data[i].comment); } else { - if (ret < 5) { + 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_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); } @@ -397,7 +397,7 @@ static void test_ean128_input(int index, int generate, int debug) { /* 19*/ { "[90]1A[90]1", 0, 134, "(12) 104 102 25 16 17 33 102 25 99 1 65 106", "StartB FNC1 9 0 1 A FNC1 9 CodeC 01" }, /* 20*/ { "[90]12A[90]123", 0, 145, "(13) 105 102 90 12 100 33 102 25 99 1 23 25 106", "StartC FNC1 90 12 CodeB A FNC1 9 CodeC 01 23" }, /* 21*/ { "[90]123[90]A234[90]123", 0, 244, "(22) 105 102 90 12 100 19 99 102 90 100 33 18 99 34 102 100 25 99 1 23 37 106", "StartC FNC1 90 12 CodeB 3 CodeC FNC1 90 CodeB A 2 CodeC 34 FNC1 CodeB 9 CodeC 01 23" } }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); char escaped[1024]; @@ -420,7 +420,7 @@ static void test_ean128_input(int index, int generate, int debug) { i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->width, symbol->errtxt, data[i].comment); } else { - if (ret < 5) { + 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_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); } @@ -471,7 +471,7 @@ static void test_hibc_input(int index, int generate, int debug) { i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->width, symbol->errtxt, data[i].comment); } else { - if (ret < 5) { + 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_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); } @@ -632,7 +632,7 @@ static void test_encode(int index, int generate, int debug) { "110100111001100110110011101101110101110110001000010110011011011110110011011001110110111010111011000100001011001101101111011001101100111011011101011101100010000101100101011110001100011101011" }, }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); char escaped[1024]; char bwipp_buf[8192]; @@ -654,10 +654,10 @@ static void test_encode(int index, int generate, int debug) { printf(" /*%3d*/ { %s, %s, \"%s\", %s, %d, %d, %d, \"%s\",\n", i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].comment); - testUtilModulesDump(symbol, " ", "\n"); + testUtilModulesPrint(symbol, " ", "\n"); printf(" },\n"); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data); diff --git a/backend/tests/test_code16k.c b/backend/tests/test_code16k.c index 5ef7dd59..1262029f 100644 --- a/backend/tests/test_code16k.c +++ b/backend/tests/test_code16k.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2020 Robin Stuart + Copyright (C) 2020 - 2021 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -69,7 +69,7 @@ static void test_large(int index, int debug) { ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, 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 < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); } @@ -125,7 +125,7 @@ static void test_reader_init(int index, int generate, int debug) { testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->rows, symbol->width, symbol->errtxt, data[i].comment); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { 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->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((char *) symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); @@ -203,7 +203,7 @@ static void test_input(int index, int generate, int debug) { i, testUtilInputModeName(data[i].input_mode), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length, testUtilErrorName(data[i].ret), symbol->rows, symbol->width, symbol->errtxt, data[i].comment); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { 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->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((char *) symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); @@ -267,10 +267,10 @@ static void test_encode(int index, int generate, int debug) { printf(" /*%3d*/ { %s, \"%s\", %s, %d, %d, \"%s\",\n", i, testUtilInputModeName(data[i].input_mode), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment); - testUtilModulesDump(symbol, " ", "\n"); + testUtilModulesPrint(symbol, " ", "\n"); printf(" },\n"); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data); diff --git a/backend/tests/test_code49.c b/backend/tests/test_code49.c index 0eba355e..778190e0 100644 --- a/backend/tests/test_code49.c +++ b/backend/tests/test_code49.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2020 Robin Stuart + Copyright (C) 2020 - 2021 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -69,7 +69,7 @@ static void test_large(int index, int debug) { ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, 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 < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); } @@ -136,7 +136,7 @@ static void test_input(int index, int generate, int debug) { i, testUtilInputModeName(data[i].input_mode), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length, testUtilErrorName(data[i].ret), symbol->rows, symbol->width, symbol->errtxt, data[i].comment); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { 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->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((char *) symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); @@ -201,10 +201,10 @@ static void test_encode(int index, int generate, int debug) { printf(" /*%3d*/ { %s, \"%s\", %s, %d, %d, \"%s\",\n", i, testUtilInputModeName(data[i].input_mode), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment); - testUtilModulesDump(symbol, " ", "\n"); + testUtilModulesPrint(symbol, " ", "\n"); printf(" },\n"); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data); diff --git a/backend/tests/test_composite.c b/backend/tests/test_composite.c index 6b40acf9..6bd9650a 100644 --- a/backend/tests/test_composite.c +++ b/backend/tests/test_composite.c @@ -75,7 +75,7 @@ static void test_eanx_leading_zeroes(int index, int debug) { /*25*/ { BARCODE_EANX_CC, "1234567890128+12", "[21]A12345678", 0, 7, 126 }, // EAN-13 + CHK + EAN-2 /*26*/ { BARCODE_EANX_CC, "1234567890128+12345", "[21]A12345678", 0, 7, 153 }, // EAN-13 + CHK + EAN-5 }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); for (int i = 0; i < data_size; i++) { @@ -84,10 +84,7 @@ static void test_eanx_leading_zeroes(int index, int debug) { struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - symbol->symbology = data[i].symbology; - symbol->debug |= debug; - - int length = strlen(data[i].data); + int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug); assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length); strcpy(symbol->primary, data[i].data); @@ -96,7 +93,7 @@ static void test_eanx_leading_zeroes(int index, int debug) { ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].composite, composite_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 < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); } @@ -122,7 +119,7 @@ static void test_helper_generate(const struct zint_symbol *symbol, int ret, int printf(" /*%2d*/ { %s, %d, \"%s\", \"%s\", %d, %d, %d, %d, \"%s\",\n", i, testUtilBarcodeName(symbol->symbology), option_1, esc_data, esc_composite, ret, symbol->rows, symbol->width, bwipp_cmp, comment); } - testUtilModulesDump(symbol, " ", "\n"); + testUtilModulesPrint(symbol, " ", "\n"); printf(" },\n"); } else { if (bwipp_cmp == -1) { @@ -1229,7 +1226,7 @@ static void test_examples(int index, int generate, int debug) { "000101001001101111010011101011000100001010010001010101001000111010011100101100110110110010010001010000000101101011110101110010" }, }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); char bwipp_buf[32768]; char bwipp_msg[1024]; @@ -1242,11 +1239,7 @@ static void test_examples(int index, int generate, int debug) { struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - symbol->symbology = data[i].symbology; - symbol->option_1 = data[i].option_1; - symbol->debug |= debug; - - int length = strlen(data[i].data); + int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, data[i].option_1, -1, -1, -1 /*output_options*/, data[i].data, -1, debug); assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length); strcpy(symbol->primary, data[i].data); @@ -1395,7 +1388,7 @@ static void test_odd_numbered_numeric(int index, int generate, int debug) { "0001010010011011110101000110111001000010100100010101010" }, }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); char bwipp_buf[8192]; char bwipp_msg[1024]; @@ -1408,11 +1401,7 @@ static void test_odd_numbered_numeric(int index, int generate, int debug) { struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - symbol->symbology = data[i].symbology; - symbol->option_1 = data[i].option_1; - symbol->debug |= debug; - - int length = strlen(data[i].data); + int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, data[i].option_1, -1, -1, -1 /*output_options*/, data[i].data, -1, debug); assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length); strcpy(symbol->primary, data[i].data); @@ -1526,7 +1515,7 @@ static void test_ean128_cc_shift(int index, int generate, int debug) { "1101001110011110101110111101101101011001110010001011000111000101101100001010011011110110101111011101001110011010111011110100110100001100011101011" }, }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); char bwipp_buf[8192]; char bwipp_msg[1024]; @@ -1538,11 +1527,7 @@ static void test_ean128_cc_shift(int index, int generate, int debug) { struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - symbol->symbology = data[i].symbology; - symbol->option_1 = data[i].option_1; - symbol->debug |= debug; - - int length = strlen(data[i].data); + int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, data[i].option_1, -1, -1, -1 /*output_options*/, data[i].data, -1, debug); assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length); strcpy(symbol->primary, data[i].data); @@ -1611,7 +1596,7 @@ static void test_ean128_cc_width(int index, int generate, int debug) { /*11*/ { "[00]123456789012345675", "[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[91]1234567890", 0, 32, 579, "With composite 2372 digits == max" }, /*12*/ { "[00]123456789012345675", "[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[91]12345678901", ZINT_ERROR_TOO_LONG, 0, 0, "With composite 2373 digits > max" }, }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); for (int i = 0; i < data_size; i++) { @@ -1620,11 +1605,7 @@ static void test_ean128_cc_width(int index, int generate, int debug) { struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - symbol->symbology = BARCODE_GS1_128_CC; - symbol->option_1 = 3; - symbol->debug |= debug; - - int length = strlen(data[i].data); + int length = testUtilSetSymbol(symbol, BARCODE_GS1_128_CC, -1 /*input_mode*/, -1 /*eci*/, 3, -1, -1, -1 /*output_options*/, data[i].data, -1, debug); assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length); strcpy(symbol->primary, data[i].data); @@ -2077,7 +2058,7 @@ static void test_encodation_0(int index, int generate, int debug) { "0001010010011011110101000110111001000010100100010101010" }, }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); char bwipp_buf[8192]; char bwipp_msg[1024]; @@ -2089,11 +2070,7 @@ static void test_encodation_0(int index, int generate, int debug) { struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - symbol->symbology = data[i].symbology; - symbol->option_1 = data[i].option_1; - symbol->debug |= debug; - - int length = strlen(data[i].data); + int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, data[i].option_1, -1, -1, -1 /*output_options*/, data[i].data, -1, debug); assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length); strcpy(symbol->primary, data[i].data); @@ -2216,7 +2193,7 @@ static void test_encodation_10(int index, int generate, int debug) { "0001010010011011110101000110111001000010100100010101010" }, }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); char bwipp_buf[8192]; char bwipp_msg[1024]; @@ -2228,11 +2205,7 @@ static void test_encodation_10(int index, int generate, int debug) { struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - symbol->symbology = data[i].symbology; - symbol->option_1 = data[i].option_1; - symbol->debug |= debug; - - int length = strlen(data[i].data); + int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, data[i].option_1, -1, -1, -1 /*output_options*/, data[i].data, -1, debug); assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length); strcpy(symbol->primary, data[i].data); @@ -2598,7 +2571,7 @@ static void test_encodation_11(int index, int generate, int debug) { "0001010010011011110101000110111001000010100100010101010" }, }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); char bwipp_buf[8192]; char bwipp_msg[1024]; @@ -2610,11 +2583,7 @@ static void test_encodation_11(int index, int generate, int debug) { struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - symbol->symbology = data[i].symbology; - symbol->option_1 = data[i].option_1; - symbol->debug |= debug; - - int length = strlen(data[i].data); + int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, data[i].option_1, -1, -1, -1 /*output_options*/, data[i].data, -1, debug); assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length); strcpy(symbol->primary, data[i].data); @@ -2629,7 +2598,7 @@ static void test_encodation_11(int index, int generate, int debug) { assert_equal(symbol->rows, data[i].expected_rows, "i:%d %s symbol->rows %d != %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), symbol->rows, data[i].expected_rows, data[i].data); assert_equal(symbol->width, data[i].expected_width, "i:%d %s symbol->width %d != %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), symbol->width, data[i].expected_width, data[i].data); - if (ret < 5) { + if (ret < ZINT_ERROR) { int width, row; ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row); assert_zero(ret, "i:%d %s testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), ret, width, row, data[i].data); @@ -2777,7 +2746,7 @@ static void test_addongap(int index, int generate, int debug) { printf(" /*%3d*/ { %s, %d, %d, \"%s\", %s, %d, %d, \"%s\",\n", i, testUtilBarcodeName(data[i].symbology), data[i].option_1, data[i].option_2, data[i].data, testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment); - testUtilModulesDump(symbol, " ", "\n"); + testUtilModulesPrint(symbol, " ", "\n"); printf(" },\n"); } else { assert_equal(symbol->rows, data[i].expected_rows, "i:%d %s symbol->rows %d != %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), symbol->rows, data[i].expected_rows, data[i].data); @@ -2823,7 +2792,7 @@ static void test_fuzz(int index, int debug) { /* 3*/ { BARCODE_EANX_CC, "+12345", -1, "[21]A12345678", 0 }, /* 4*/ { BARCODE_EANX_CC, "+123456", -1, "[21]A12345678", ZINT_ERROR_TOO_LONG }, }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); for (int i = 0; i < data_size; i++) { @@ -2832,13 +2801,7 @@ static void test_fuzz(int index, int debug) { struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - symbol->symbology = data[i].symbology; - symbol->debug |= debug; - - int length = data[i].length; - if (length == -1) { - length = strlen(data[i].data); - } + int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug); assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length); strcpy(symbol->primary, data[i].data); diff --git a/backend/tests/test_dmatrix.c b/backend/tests/test_dmatrix.c index 03f64aa0..23ed3b81 100644 --- a/backend/tests/test_dmatrix.c +++ b/backend/tests/test_dmatrix.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2019 - 2020 Robin Stuart + Copyright (C) 2019 - 2021 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -38,22 +38,312 @@ static void test_large(int index, int debug) { int ret; struct item { int symbology; + int option_2; char *pattern; int length; int ret; int expected_rows; int expected_width; }; + // ISO/IEC 16022:2006 Table 7 and ISO/IEC 21471:2020 (DMRE) Table 7 // s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<")) struct item data[] = { - /* 0*/ { BARCODE_DATAMATRIX, "1", 3116, 0, 144, 144 }, - /* 1*/ { BARCODE_DATAMATRIX, "1", 3117, ZINT_ERROR_TOO_LONG, -1, -1 }, - /* 2*/ { BARCODE_DATAMATRIX, "A", 2335, 0, 144, 144 }, - /* 3*/ { BARCODE_DATAMATRIX, "A", 2336, ZINT_ERROR_TOO_LONG, -1, -1 }, - /* 4*/ { BARCODE_DATAMATRIX, "\200", 1555, 0, 144, 144 }, - /* 5*/ { BARCODE_DATAMATRIX, "\200", 1556, ZINT_ERROR_TOO_LONG, -1, -1 }, - /* 6*/ { BARCODE_HIBC_DM, "1", 110, 0, 32, 32 }, - /* 7*/ { BARCODE_HIBC_DM, "1", 111, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 0*/ { BARCODE_DATAMATRIX, -1, "1", 3116, 0, 144, 144 }, + /* 1*/ { BARCODE_DATAMATRIX, -1, "1", 3117, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 2*/ { BARCODE_DATAMATRIX, -1, "A", 2335, 0, 144, 144 }, + /* 3*/ { BARCODE_DATAMATRIX, -1, "A", 2336, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 4*/ { BARCODE_DATAMATRIX, -1, "\200", 1556, 0, 144, 144 }, // Spec says 1555 but 1556 correct as only single byte count of 0 required + /* 5*/ { BARCODE_DATAMATRIX, -1, "\200", 1557, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 6*/ { BARCODE_HIBC_DM, -1, "1", 110, 0, 32, 32 }, + /* 7*/ { BARCODE_HIBC_DM, -1, "1", 111, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 8*/ { BARCODE_DATAMATRIX, 1, "1", 6, 0, 10, 10 }, + /* 9*/ { BARCODE_DATAMATRIX, 1, "1", 7, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 10*/ { BARCODE_DATAMATRIX, 1, "A", 3, 0, 10, 10 }, + /* 11*/ { BARCODE_DATAMATRIX, 1, "A", 4, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 12*/ { BARCODE_DATAMATRIX, 1, "\200", 1, 0, 10, 10 }, + /* 13*/ { BARCODE_DATAMATRIX, 1, "\200", 2, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 14*/ { BARCODE_DATAMATRIX, 2, "1", 10, 0, 12, 12 }, + /* 15*/ { BARCODE_DATAMATRIX, 2, "1", 11, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 16*/ { BARCODE_DATAMATRIX, 2, "A", 6, 0, 12, 12 }, + /* 17*/ { BARCODE_DATAMATRIX, 2, "A", 7, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 18*/ { BARCODE_DATAMATRIX, 2, "\200", 3, 0, 12, 12 }, + /* 19*/ { BARCODE_DATAMATRIX, 2, "\200", 4, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 20*/ { BARCODE_DATAMATRIX, 3, "1", 16, 0, 14, 14 }, + /* 21*/ { BARCODE_DATAMATRIX, 3, "1", 17, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 22*/ { BARCODE_DATAMATRIX, 3, "A", 10, 0, 14, 14 }, + /* 23*/ { BARCODE_DATAMATRIX, 3, "A", 11, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 24*/ { BARCODE_DATAMATRIX, 3, "\200", 6, 0, 14, 14 }, + /* 25*/ { BARCODE_DATAMATRIX, 3, "\200", 7, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 26*/ { BARCODE_DATAMATRIX, 4, "1", 24, 0, 16, 16 }, + /* 27*/ { BARCODE_DATAMATRIX, 4, "1", 25, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 28*/ { BARCODE_DATAMATRIX, 4, "A", 16, 0, 16, 16 }, + /* 29*/ { BARCODE_DATAMATRIX, 4, "A", 17, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 30*/ { BARCODE_DATAMATRIX, 4, "\200", 10, 0, 16, 16 }, + /* 31*/ { BARCODE_DATAMATRIX, 4, "\200", 11, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 32*/ { BARCODE_DATAMATRIX, 5, "1", 36, 0, 18, 18 }, + /* 33*/ { BARCODE_DATAMATRIX, 5, "1", 37, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 34*/ { BARCODE_DATAMATRIX, 5, "A", 25, 0, 18, 18 }, + /* 35*/ { BARCODE_DATAMATRIX, 5, "A", 26, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 36*/ { BARCODE_DATAMATRIX, 5, "\200", 16, 0, 18, 18 }, + /* 37*/ { BARCODE_DATAMATRIX, 5, "\200", 17, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 38*/ { BARCODE_DATAMATRIX, 6, "1", 44, 0, 20, 20 }, + /* 39*/ { BARCODE_DATAMATRIX, 6, "1", 45, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 40*/ { BARCODE_DATAMATRIX, 6, "A", 31, 0, 20, 20 }, + /* 41*/ { BARCODE_DATAMATRIX, 6, "A", 32, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 42*/ { BARCODE_DATAMATRIX, 6, "\200", 20, 0, 20, 20 }, + /* 43*/ { BARCODE_DATAMATRIX, 6, "\200", 21, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 44*/ { BARCODE_DATAMATRIX, 7, "1", 60, 0, 22, 22 }, + /* 45*/ { BARCODE_DATAMATRIX, 7, "1", 61, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 46*/ { BARCODE_DATAMATRIX, 7, "A", 43, 0, 22, 22 }, + /* 47*/ { BARCODE_DATAMATRIX, 7, "A", 44, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 48*/ { BARCODE_DATAMATRIX, 7, "\200", 28, 0, 22, 22 }, + /* 49*/ { BARCODE_DATAMATRIX, 7, "\200", 29, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 50*/ { BARCODE_DATAMATRIX, 8, "1", 72, 0, 24, 24 }, + /* 51*/ { BARCODE_DATAMATRIX, 8, "1", 73, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 52*/ { BARCODE_DATAMATRIX, 8, "A", 52, 0, 24, 24 }, + /* 53*/ { BARCODE_DATAMATRIX, 8, "A", 53, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 54*/ { BARCODE_DATAMATRIX, 8, "\200", 34, 0, 24, 24 }, + /* 55*/ { BARCODE_DATAMATRIX, 8, "\200", 35, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 56*/ { BARCODE_DATAMATRIX, 9, "1", 88, 0, 26, 26 }, + /* 57*/ { BARCODE_DATAMATRIX, 9, "1", 89, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 58*/ { BARCODE_DATAMATRIX, 9, "A", 64, 0, 26, 26 }, + /* 59*/ { BARCODE_DATAMATRIX, 9, "A", 65, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 60*/ { BARCODE_DATAMATRIX, 9, "\200", 42, 0, 26, 26 }, + /* 61*/ { BARCODE_DATAMATRIX, 9, "\200", 43, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 62*/ { BARCODE_DATAMATRIX, 10, "1", 124, 0, 32, 32 }, + /* 63*/ { BARCODE_DATAMATRIX, 10, "1", 125, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 64*/ { BARCODE_DATAMATRIX, 10, "A", 91, 0, 32, 32 }, + /* 65*/ { BARCODE_DATAMATRIX, 10, "A", 92, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 66*/ { BARCODE_DATAMATRIX, 10, "\200", 60, 0, 32, 32 }, + /* 67*/ { BARCODE_DATAMATRIX, 10, "\200", 61, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 68*/ { BARCODE_DATAMATRIX, 11, "1", 172, 0, 36, 36 }, + /* 69*/ { BARCODE_DATAMATRIX, 11, "1", 173, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 70*/ { BARCODE_DATAMATRIX, 11, "A", 127, 0, 36, 36 }, + /* 71*/ { BARCODE_DATAMATRIX, 11, "A", 128, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 72*/ { BARCODE_DATAMATRIX, 11, "\200", 84, 0, 36, 36 }, + /* 73*/ { BARCODE_DATAMATRIX, 11, "\200", 85, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 74*/ { BARCODE_DATAMATRIX, 12, "1", 228, 0, 40, 40 }, + /* 75*/ { BARCODE_DATAMATRIX, 12, "1", 229, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 76*/ { BARCODE_DATAMATRIX, 12, "A", 169, 0, 40, 40 }, + /* 77*/ { BARCODE_DATAMATRIX, 12, "A", 170, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 78*/ { BARCODE_DATAMATRIX, 12, "\200", 112, 0, 40, 40 }, + /* 79*/ { BARCODE_DATAMATRIX, 12, "\200", 113, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 80*/ { BARCODE_DATAMATRIX, 13, "1", 288, 0, 44, 44 }, + /* 81*/ { BARCODE_DATAMATRIX, 13, "1", 289, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 82*/ { BARCODE_DATAMATRIX, 13, "A", 214, 0, 44, 44 }, + /* 83*/ { BARCODE_DATAMATRIX, 13, "A", 215, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 84*/ { BARCODE_DATAMATRIX, 13, "\200", 142, 0, 44, 44 }, + /* 85*/ { BARCODE_DATAMATRIX, 13, "\200", 143, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 86*/ { BARCODE_DATAMATRIX, 14, "1", 348, 0, 48, 48 }, + /* 87*/ { BARCODE_DATAMATRIX, 14, "1", 349, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 88*/ { BARCODE_DATAMATRIX, 14, "A", 259, 0, 48, 48 }, + /* 89*/ { BARCODE_DATAMATRIX, 14, "A", 260, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 90*/ { BARCODE_DATAMATRIX, 14, "\200", 172, 0, 48, 48 }, + /* 91*/ { BARCODE_DATAMATRIX, 14, "\200", 173, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 92*/ { BARCODE_DATAMATRIX, 15, "1", 408, 0, 52, 52 }, + /* 93*/ { BARCODE_DATAMATRIX, 15, "1", 409, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 94*/ { BARCODE_DATAMATRIX, 15, "A", 304, 0, 52, 52 }, + /* 95*/ { BARCODE_DATAMATRIX, 15, "A", 305, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 96*/ { BARCODE_DATAMATRIX, 15, "\200", 202, 0, 52, 52 }, + /* 97*/ { BARCODE_DATAMATRIX, 15, "\200", 203, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 98*/ { BARCODE_DATAMATRIX, 16, "1", 560, 0, 64, 64 }, + /* 99*/ { BARCODE_DATAMATRIX, 16, "1", 561, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*100*/ { BARCODE_DATAMATRIX, 16, "A", 418, 0, 64, 64 }, + /*101*/ { BARCODE_DATAMATRIX, 16, "A", 419, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*102*/ { BARCODE_DATAMATRIX, 16, "\200", 278, 0, 64, 64 }, // Spec says 277 but 278 correct as only single byte count of 0 required + /*103*/ { BARCODE_DATAMATRIX, 16, "\200", 279, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*104*/ { BARCODE_DATAMATRIX, 17, "1", 736, 0, 72, 72 }, + /*105*/ { BARCODE_DATAMATRIX, 17, "1", 737, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*106*/ { BARCODE_DATAMATRIX, 17, "A", 550, 0, 72, 72 }, + /*107*/ { BARCODE_DATAMATRIX, 17, "A", 551, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*108*/ { BARCODE_DATAMATRIX, 17, "\200", 366, 0, 72, 72 }, // Spec says 365 but 366 correct as only single byte count of 0 required + /*109*/ { BARCODE_DATAMATRIX, 17, "\200", 367, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*110*/ { BARCODE_DATAMATRIX, 18, "1", 912, 0, 80, 80 }, + /*111*/ { BARCODE_DATAMATRIX, 18, "1", 913, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*112*/ { BARCODE_DATAMATRIX, 18, "A", 682, 0, 80, 80 }, + /*113*/ { BARCODE_DATAMATRIX, 18, "A", 683, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*114*/ { BARCODE_DATAMATRIX, 18, "\200", 454, 0, 80, 80 }, // Spec says 453 but 454 correct as only single byte count of 0 required + /*115*/ { BARCODE_DATAMATRIX, 18, "\200", 455, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*116*/ { BARCODE_DATAMATRIX, 19, "1", 1152, 0, 88, 88 }, + /*117*/ { BARCODE_DATAMATRIX, 19, "1", 1153, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*118*/ { BARCODE_DATAMATRIX, 19, "A", 862, 0, 88, 88 }, + /*119*/ { BARCODE_DATAMATRIX, 19, "A", 863, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*120*/ { BARCODE_DATAMATRIX, 19, "\200", 574, 0, 88, 88 }, // Spec says 573 but 574 correct as only single byte count of 0 required + /*121*/ { BARCODE_DATAMATRIX, 19, "\200", 575, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*122*/ { BARCODE_DATAMATRIX, 20, "1", 1392, 0, 96, 96 }, + /*123*/ { BARCODE_DATAMATRIX, 20, "1", 1393, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*124*/ { BARCODE_DATAMATRIX, 20, "A", 1042, 0, 96, 96 }, + /*125*/ { BARCODE_DATAMATRIX, 20, "A", 1043, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*126*/ { BARCODE_DATAMATRIX, 20, "\200", 694, 0, 96, 96 }, // Spec says 693 but 694 correct as only single byte count of 0 required + /*127*/ { BARCODE_DATAMATRIX, 20, "\200", 695, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*128*/ { BARCODE_DATAMATRIX, 21, "1", 1632, 0, 104, 104 }, + /*129*/ { BARCODE_DATAMATRIX, 21, "1", 1633, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*130*/ { BARCODE_DATAMATRIX, 21, "A", 1222, 0, 104, 104 }, + /*131*/ { BARCODE_DATAMATRIX, 21, "A", 1223, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*132*/ { BARCODE_DATAMATRIX, 21, "\200", 814, 0, 104, 104 }, // Spec says 813 but 814 correct as only single byte count of 0 required + /*133*/ { BARCODE_DATAMATRIX, 21, "\200", 815, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*134*/ { BARCODE_DATAMATRIX, 22, "1", 2100, 0, 120, 120 }, + /*135*/ { BARCODE_DATAMATRIX, 22, "1", 2101, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*136*/ { BARCODE_DATAMATRIX, 22, "A", 1573, 0, 120, 120 }, + /*137*/ { BARCODE_DATAMATRIX, 22, "A", 1574, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*138*/ { BARCODE_DATAMATRIX, 22, "\200", 1048, 0, 120, 120 }, // Spec says 1047 but 1048 correct as only single byte count of 0 required + /*139*/ { BARCODE_DATAMATRIX, 22, "\200", 1049, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*140*/ { BARCODE_DATAMATRIX, 23, "1", 2608, 0, 132, 132 }, + /*141*/ { BARCODE_DATAMATRIX, 23, "1", 2609, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*142*/ { BARCODE_DATAMATRIX, 23, "A", 1954, 0, 132, 132 }, + /*143*/ { BARCODE_DATAMATRIX, 23, "A", 1955, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*144*/ { BARCODE_DATAMATRIX, 23, "\200", 1302, 0, 132, 132 }, // Spec says 1301 but 1302 correct as only single byte count of 0 required + /*145*/ { BARCODE_DATAMATRIX, 23, "\200", 1303, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*146*/ { BARCODE_DATAMATRIX, 24, "1", 3116, 0, 144, 144 }, + /*147*/ { BARCODE_DATAMATRIX, 24, "1", 3117, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*148*/ { BARCODE_DATAMATRIX, 24, "A", 2335, 0, 144, 144 }, + /*149*/ { BARCODE_DATAMATRIX, 24, "A", 2336, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*150*/ { BARCODE_DATAMATRIX, 24, "\200", 1556, 0, 144, 144 }, // Spec says 1555 but 1556 correct as only single byte count of 0 required + /*151*/ { BARCODE_DATAMATRIX, 24, "\200", 1557, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*152*/ { BARCODE_DATAMATRIX, 25, "1", 10, 0, 8, 18 }, + /*153*/ { BARCODE_DATAMATRIX, 25, "1", 11, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*154*/ { BARCODE_DATAMATRIX, 25, "A", 6, 0, 8, 18 }, + /*155*/ { BARCODE_DATAMATRIX, 25, "A", 7, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*156*/ { BARCODE_DATAMATRIX, 25, "\200", 3, 0, 8, 18 }, + /*157*/ { BARCODE_DATAMATRIX, 25, "\200", 4, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*158*/ { BARCODE_DATAMATRIX, 26, "1", 20, 0, 8, 32 }, + /*159*/ { BARCODE_DATAMATRIX, 26, "1", 21, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*160*/ { BARCODE_DATAMATRIX, 26, "A", 13, 0, 8, 32 }, + /*161*/ { BARCODE_DATAMATRIX, 26, "A", 14, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*162*/ { BARCODE_DATAMATRIX, 26, "\200", 8, 0, 8, 32 }, + /*163*/ { BARCODE_DATAMATRIX, 26, "\200", 9, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*164*/ { BARCODE_DATAMATRIX, 27, "1", 32, 0, 12, 26 }, + /*165*/ { BARCODE_DATAMATRIX, 27, "1", 33, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*166*/ { BARCODE_DATAMATRIX, 27, "A", 22, 0, 12, 26 }, + /*167*/ { BARCODE_DATAMATRIX, 27, "A", 23, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*168*/ { BARCODE_DATAMATRIX, 27, "\200", 14, 0, 12, 26 }, + /*169*/ { BARCODE_DATAMATRIX, 27, "\200", 15, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*170*/ { BARCODE_DATAMATRIX, 28, "1", 44, 0, 12, 36 }, + /*171*/ { BARCODE_DATAMATRIX, 28, "1", 45, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*172*/ { BARCODE_DATAMATRIX, 28, "A", 31, 0, 12, 36 }, + /*173*/ { BARCODE_DATAMATRIX, 28, "A", 32, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*174*/ { BARCODE_DATAMATRIX, 28, "\200", 20, 0, 12, 36 }, + /*175*/ { BARCODE_DATAMATRIX, 28, "\200", 21, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*176*/ { BARCODE_DATAMATRIX, 29, "1", 64, 0, 16, 36 }, + /*177*/ { BARCODE_DATAMATRIX, 29, "1", 65, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*178*/ { BARCODE_DATAMATRIX, 29, "A", 46, 0, 16, 36 }, + /*179*/ { BARCODE_DATAMATRIX, 29, "A", 47, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*180*/ { BARCODE_DATAMATRIX, 29, "\200", 30, 0, 16, 36 }, + /*181*/ { BARCODE_DATAMATRIX, 29, "\200", 31, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*182*/ { BARCODE_DATAMATRIX, 30, "1", 98, 0, 16, 48 }, + /*183*/ { BARCODE_DATAMATRIX, 30, "1", 99, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*184*/ { BARCODE_DATAMATRIX, 30, "A", 72, 0, 16, 48 }, + /*185*/ { BARCODE_DATAMATRIX, 30, "A", 73, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*186*/ { BARCODE_DATAMATRIX, 30, "\200", 47, 0, 16, 48 }, + /*187*/ { BARCODE_DATAMATRIX, 30, "\200", 48, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*188*/ { BARCODE_DATAMATRIX, 31, "1", 36, 0, 8, 48 }, + /*189*/ { BARCODE_DATAMATRIX, 31, "1", 37, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*190*/ { BARCODE_DATAMATRIX, 31, "A", 25, 0, 8, 48 }, + /*191*/ { BARCODE_DATAMATRIX, 31, "A", 26, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*192*/ { BARCODE_DATAMATRIX, 31, "\200", 16, 0, 8, 48 }, + /*193*/ { BARCODE_DATAMATRIX, 31, "\200", 17, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*194*/ { BARCODE_DATAMATRIX, 32, "1", 48, 0, 8, 64 }, + /*195*/ { BARCODE_DATAMATRIX, 32, "1", 49, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*196*/ { BARCODE_DATAMATRIX, 32, "A", 34, 0, 8, 64 }, + /*197*/ { BARCODE_DATAMATRIX, 32, "A", 35, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*198*/ { BARCODE_DATAMATRIX, 32, "\200", 22, 0, 8, 64 }, + /*199*/ { BARCODE_DATAMATRIX, 32, "\200", 23, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*200*/ { BARCODE_DATAMATRIX, 33, "1", 64, 0, 8, 80 }, + /*201*/ { BARCODE_DATAMATRIX, 33, "1", 65, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*202*/ { BARCODE_DATAMATRIX, 33, "A", 46, 0, 8, 80 }, + /*203*/ { BARCODE_DATAMATRIX, 33, "A", 47, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*204*/ { BARCODE_DATAMATRIX, 33, "\200", 30, 0, 8, 80 }, + /*205*/ { BARCODE_DATAMATRIX, 33, "\200", 31, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*206*/ { BARCODE_DATAMATRIX, 34, "1", 76, 0, 8, 96 }, + /*207*/ { BARCODE_DATAMATRIX, 34, "1", 77, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*208*/ { BARCODE_DATAMATRIX, 34, "A", 55, 0, 8, 96 }, + /*209*/ { BARCODE_DATAMATRIX, 34, "A", 56, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*210*/ { BARCODE_DATAMATRIX, 34, "\200", 36, 0, 8, 96 }, + /*211*/ { BARCODE_DATAMATRIX, 34, "\200", 37, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*212*/ { BARCODE_DATAMATRIX, 35, "1", 98, 0, 8, 120 }, + /*213*/ { BARCODE_DATAMATRIX, 35, "1", 99, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*214*/ { BARCODE_DATAMATRIX, 35, "A", 72, 0, 8, 120 }, + /*215*/ { BARCODE_DATAMATRIX, 35, "A", 73, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*216*/ { BARCODE_DATAMATRIX, 35, "\200", 47, 0, 8, 120 }, + /*217*/ { BARCODE_DATAMATRIX, 35, "\200", 48, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*218*/ { BARCODE_DATAMATRIX, 36, "1", 126, 0, 8, 144 }, + /*219*/ { BARCODE_DATAMATRIX, 36, "1", 127, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*220*/ { BARCODE_DATAMATRIX, 36, "A", 93, 0, 8, 144 }, + /*221*/ { BARCODE_DATAMATRIX, 36, "A", 94, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*222*/ { BARCODE_DATAMATRIX, 36, "\200", 61, 0, 8, 144 }, + /*223*/ { BARCODE_DATAMATRIX, 36, "\200", 62, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*224*/ { BARCODE_DATAMATRIX, 37, "1", 86, 0, 12, 64 }, + /*225*/ { BARCODE_DATAMATRIX, 37, "1", 87, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*226*/ { BARCODE_DATAMATRIX, 37, "A", 63, 0, 12, 64 }, + /*227*/ { BARCODE_DATAMATRIX, 37, "A", 64, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*228*/ { BARCODE_DATAMATRIX, 37, "\200", 41, 0, 12, 64 }, + /*229*/ { BARCODE_DATAMATRIX, 37, "\200", 42, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*230*/ { BARCODE_DATAMATRIX, 38, "1", 128, 0, 12, 88 }, + /*231*/ { BARCODE_DATAMATRIX, 38, "1", 129, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*232*/ { BARCODE_DATAMATRIX, 38, "A", 94, 0, 12, 88 }, + /*233*/ { BARCODE_DATAMATRIX, 38, "A", 95, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*234*/ { BARCODE_DATAMATRIX, 38, "\200", 62, 0, 12, 88 }, + /*235*/ { BARCODE_DATAMATRIX, 38, "\200", 63, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*236*/ { BARCODE_DATAMATRIX, 39, "1", 124, 0, 16, 64 }, + /*237*/ { BARCODE_DATAMATRIX, 39, "1", 125, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*238*/ { BARCODE_DATAMATRIX, 39, "A", 91, 0, 16, 64 }, + /*239*/ { BARCODE_DATAMATRIX, 39, "A", 92, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*240*/ { BARCODE_DATAMATRIX, 39, "\200", 60, 0, 16, 64 }, + /*241*/ { BARCODE_DATAMATRIX, 39, "\200", 61, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*242*/ { BARCODE_DATAMATRIX, 40, "1", 88, 0, 20, 36 }, + /*243*/ { BARCODE_DATAMATRIX, 40, "1", 89, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*244*/ { BARCODE_DATAMATRIX, 40, "A", 64, 0, 20, 36 }, + /*245*/ { BARCODE_DATAMATRIX, 40, "A", 65, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*246*/ { BARCODE_DATAMATRIX, 40, "\200", 42, 0, 20, 36 }, + /*247*/ { BARCODE_DATAMATRIX, 40, "\200", 43, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*248*/ { BARCODE_DATAMATRIX, 41, "1", 112, 0, 20, 44 }, + /*249*/ { BARCODE_DATAMATRIX, 41, "1", 113, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*250*/ { BARCODE_DATAMATRIX, 41, "A", 82, 0, 20, 44 }, + /*251*/ { BARCODE_DATAMATRIX, 41, "A", 83, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*252*/ { BARCODE_DATAMATRIX, 41, "\200", 54, 0, 20, 44 }, + /*253*/ { BARCODE_DATAMATRIX, 41, "\200", 55, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*254*/ { BARCODE_DATAMATRIX, 42, "1", 168, 0, 20, 64 }, // Spec says 186 but typo + /*255*/ { BARCODE_DATAMATRIX, 42, "1", 169, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*256*/ { BARCODE_DATAMATRIX, 42, "A", 124, 0, 20, 64 }, + /*257*/ { BARCODE_DATAMATRIX, 42, "A", 125, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*258*/ { BARCODE_DATAMATRIX, 42, "\200", 82, 0, 20, 64 }, + /*259*/ { BARCODE_DATAMATRIX, 42, "\200", 83, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*260*/ { BARCODE_DATAMATRIX, 43, "1", 144, 0, 22, 48 }, + /*261*/ { BARCODE_DATAMATRIX, 43, "1", 145, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*262*/ { BARCODE_DATAMATRIX, 43, "A", 106, 0, 22, 48 }, + /*263*/ { BARCODE_DATAMATRIX, 43, "A", 107, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*264*/ { BARCODE_DATAMATRIX, 43, "\200", 70, 0, 22, 48 }, + /*265*/ { BARCODE_DATAMATRIX, 43, "\200", 71, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*266*/ { BARCODE_DATAMATRIX, 44, "1", 160, 0, 24, 48 }, + /*267*/ { BARCODE_DATAMATRIX, 44, "1", 161, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*268*/ { BARCODE_DATAMATRIX, 44, "A", 118, 0, 24, 48 }, + /*269*/ { BARCODE_DATAMATRIX, 44, "A", 119, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*270*/ { BARCODE_DATAMATRIX, 44, "\200", 78, 0, 24, 48 }, + /*271*/ { BARCODE_DATAMATRIX, 44, "\200", 79, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*272*/ { BARCODE_DATAMATRIX, 45, "1", 216, 0, 24, 64 }, + /*273*/ { BARCODE_DATAMATRIX, 45, "1", 217, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*274*/ { BARCODE_DATAMATRIX, 45, "A", 160, 0, 24, 64 }, + /*275*/ { BARCODE_DATAMATRIX, 45, "A", 161, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*276*/ { BARCODE_DATAMATRIX, 45, "\200", 106, 0, 24, 64 }, + /*277*/ { BARCODE_DATAMATRIX, 45, "\200", 107, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*278*/ { BARCODE_DATAMATRIX, 46, "1", 140, 0, 26, 40 }, + /*279*/ { BARCODE_DATAMATRIX, 46, "1", 141, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*280*/ { BARCODE_DATAMATRIX, 46, "A", 103, 0, 26, 40 }, + /*281*/ { BARCODE_DATAMATRIX, 46, "A", 104, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*282*/ { BARCODE_DATAMATRIX, 46, "\200", 68, 0, 26, 40 }, + /*283*/ { BARCODE_DATAMATRIX, 46, "\200", 69, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*284*/ { BARCODE_DATAMATRIX, 47, "1", 180, 0, 26, 48 }, + /*285*/ { BARCODE_DATAMATRIX, 47, "1", 181, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*286*/ { BARCODE_DATAMATRIX, 47, "A", 133, 0, 26, 48 }, + /*287*/ { BARCODE_DATAMATRIX, 47, "A", 134, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*288*/ { BARCODE_DATAMATRIX, 47, "\200", 88, 0, 26, 48 }, + /*289*/ { BARCODE_DATAMATRIX, 47, "\200", 89, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*290*/ { BARCODE_DATAMATRIX, 48, "1", 236, 0, 26, 64 }, + /*291*/ { BARCODE_DATAMATRIX, 48, "1", 237, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*292*/ { BARCODE_DATAMATRIX, 48, "A", 175, 0, 26, 64 }, + /*293*/ { BARCODE_DATAMATRIX, 48, "A", 176, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*294*/ { BARCODE_DATAMATRIX, 48, "\200", 116, 0, 26, 64 }, + /*295*/ { BARCODE_DATAMATRIX, 48, "\200", 117, ZINT_ERROR_TOO_LONG, -1, -1 }, }; int data_size = ARRAY_SIZE(data); @@ -69,12 +359,12 @@ static void test_large(int index, int debug) { testUtilStrCpyRepeat(data_buf, data[i].pattern, data[i].length); assert_equal(data[i].length, (int) strlen(data_buf), "i:%d length %d != strlen(data_buf) %d\n", i, data[i].length, (int) strlen(data_buf)); - int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data_buf, data[i].length, debug); + int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data_buf, data[i].length, debug); ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, 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 < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); } @@ -223,7 +513,7 @@ static void test_reader_init(int index, int generate, int debug) { testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->rows, symbol->width, symbol->errtxt, data[i].comment); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { 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->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); @@ -240,6 +530,8 @@ static void test_input(int index, int generate, int debug) { testStart(""); + int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); // Only do BWIPP test if asked, too slow otherwise + int ret; struct item { int input_mode; @@ -263,75 +555,97 @@ static void test_input(int index, int generate, int debug) { /* 4*/ { UNICODE_MODE, 0, 5, -1, "0466010592130100000k*AGUATY80U", ZINT_ERROR_TOO_LONG, -1, 0, 0, "Error 522: Input too long for selected symbol size", "" }, /* 5*/ { UNICODE_MODE, 0, 6, -1, "0466010592130100000k*AGUATY80U", 0, 0, 20, 20, "(40) 86 C4 83 87 DE 8F 83 82 82 31 6C EE 08 85 D6 D2 EF 65 FE 56 81 76 4F AB 22 B8 6F 0A", "" }, /* 6*/ { UNICODE_MODE, 0, -1, -1, "0466010592130100000k*AGUATY80UA", 0, 0, 20, 20, "(40) 86 C4 83 87 DE 8F 83 82 82 31 6C E6 07 B7 82 5F D4 3D 1E 5F FE 81 1E 1B B0 FE E7 54", "" }, - /* 7*/ { UNICODE_MODE, 0, -1, -1, "A*0>B1*", 0, 0, 14, 14, "EE 57 AD 0E DE FE 2B 81 F8 05 75 94 1E 5F 24 0C A0 D3", "X12 symbols_left 3, process_p 1" }, - /* 8*/ { UNICODE_MODE, 0, -1, -1, "A*0>B1*2", 0, 0, 14, 14, "EE 57 AD 0E DE FE 2B 33 E7 BB FB 78 F9 F5 4B 11 BB 5A", "X12 symbols_left 3, process_p 2" }, - /* 9*/ { UNICODE_MODE, 0, -1, -1, "A*0>B1*2>", 0, 0, 14, 14, "EE 57 AD 0E DE 07 33 FE 75 99 1B 4D 76 0E 9E 49 E0 37", "X12 symbols_left 1, process_p 0" }, - /* 10*/ { UNICODE_MODE, 0, -1, -1, "ABCDEF", 0, 0, 12, 12, "E6 59 E9 6D 24 3D 15 EF AA 21 F9 59", "C40 last_shift 0, symbols_left 0, process_p 0" }, - /* 11*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFG", 0, 0, 14, 14, "E6 59 E9 6D 24 FE 48 81 8C 7E 09 5E 10 64 BC 5F 4C 91", "C40 last_shift 0, symbols_left 3, process_p 1" }, - /* 12*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGH", 0, 0, 14, 14, "E6 59 E9 6D 24 80 49 FE DD 85 9E 5B E9 8F 4D F3 02 9C", "C40 last_shift 0, symbols_left 3, process_p 2" }, - /* 13*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGHI", 0, 0, 14, 14, "E6 59 E9 6D 24 80 5F FE 01 DE 20 9F AA C2 FF 8F 08 97", "C40 last_shift 0, symbols_left 1, process_p 0" }, - /* 14*/ { UNICODE_MODE, 0, -1, -1, "ABCDEF\001G", 0, 0, 14, 14, "E6 59 E9 6D 24 00 3D FE 5D 5A F5 0A 8A 4E 1D 63 07 B9", "C40 last_shift 0, symbols_left 1, process_p 0" }, - /* 15*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFG\001", 0, 0, 14, 14, "E6 59 E9 6D 24 7D 02 FE 14 A3 27 63 01 2F B1 94 FE FA", "C40 last_shift 0, symbols_left 1, process_p 0" }, - /* 16*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFG\001H", 0, 0, 14, 14, "E6 59 E9 6D 24 7D 02 49 C2 E6 DD 06 89 51 BA 8E 9D 1F", "C40 last_shift 0, symbols_left 1, process_p 1" }, - /* 17*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGH\001", 0, 0, 14, 14, "E6 59 E9 6D 24 80 49 02 4F 4D 86 23 5F 1B F9 8C 67 7E", "C40 last_shift 1, symbols_left 1, process_p 1" }, - /* 18*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGH\001I", 0, 0, 8, 32, "E6 59 E9 6D 24 80 49 09 B1 FE 27 19 F1 CA B7 85 D0 25 0D 5E 24", "C40 last_shift 1, symbols_left 3, process_p 2" }, - /* 19*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGHI\001", 0, 0, 8, 32, "E6 59 E9 6D 24 80 5F FE 02 81 47 6C 3E 49 D3 FA 46 47 53 6E E5", "Switches to ASC for last char" }, - /* 20*/ { UNICODE_MODE, 0, -1, -1, "ABCDEF+G", 0, 0, 14, 14, "E6 59 E9 6D 24 07 E5 FE 6B 35 71 7F 3D 57 59 46 F7 B9", "C40 last_shift 0, symbols_left 1, process_p 0" }, - /* 21*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFG+", 0, 0, 14, 14, "E6 59 E9 6D 24 7D 33 FE 33 F5 97 60 73 48 13 2E E5 74", "C40 last_shift 0, symbols_left 1, process_p 0" }, - /* 22*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFG+H", 0, 0, 14, 14, "E6 59 E9 6D 24 7D 33 49 E5 B0 6D 05 FB 36 18 34 86 91", "C40 last_shift 0, symbols_left 1, process_p 1" }, - /* 23*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGH+", 0, 0, 14, 14, "E6 59 E9 6D 24 80 49 2C 67 1F 09 CA 1A CD 0D 55 80 21", "C40 last_shift 2, symbols_left 1, process_p 1" }, - /* 24*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGH+I", 0, 0, 8, 32, "E6 59 E9 6D 24 80 4A 41 F1 FE 41 81 CF 13 E2 64 43 2F E1 D1 11", "C40 last_shift 2, symbols_left 3, process_p 2" }, - /* 25*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGHI+", 0, 0, 8, 32, "E6 59 E9 6D 24 80 5F FE 2C 81 F8 BC 8D 12 17 7E 22 27 DE 7F E2", "Switches to ASC for last char" }, - /* 26*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFjG", 0, 0, 14, 14, "E6 59 E9 6D 24 0E 25 FE DA 14 D7 15 47 69 9D 4A 54 6D", "C40 last_shift 0, symbols_left 1, process_p 0" }, - /* 27*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGj", 0, 0, 14, 14, "E6 59 E9 6D 24 7D 5B FE B5 F3 24 0A 99 26 D6 CC A8 40", "C40 last_shift 0, symbols_left 1, process_p 0" }, - /* 28*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGjH", 0, 0, 14, 14, "E6 59 E9 6D 24 7D 5B 49 63 B6 DE 6F 11 58 DD D6 CB A5", "C40 last_shift 0, symbols_left 1, process_p 1" }, - /* 29*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGHj", 0, 0, 14, 14, "E6 59 E9 6D 24 80 49 6B 12 00 5B FD B0 3A D9 DF 26 B6", "C40 last_shift 3, symbols_left 1, process_p 1" }, - /* 30*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGHjI", 0, 0, 8, 32, "E6 59 E9 6D 24 80 4B 41 F1 FE FB 10 AC 51 A1 56 8F 20 98 18 1B", "C40 last_shift 3, symbols_left 3, process_p 2" }, - /* 31*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGHIj", 0, 0, 8, 32, "E6 59 E9 6D 24 80 5F FE 6B 81 17 79 06 42 7E 96 B2 70 79 F8 3C", "Switches to ASC for last char" }, - /* 32*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGHIJÊ", 0, 0, 16, 16, "E6 59 E9 6D 24 80 5F FE 4B EB 4B 81 DD D9 F9 C9 C5 38 F3 4B DB 80 92 A7", "Switches to ASC for last 2 chars" }, - /* 33*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGHIJKÊ", 0, 0, 16, 16, "E6 59 E9 6D 24 80 5F 93 82 BF 19 FE E7 50 32 B4 0B CC 8C 07 D2 78 8D F5", "C40 last_shift 0, symbols_left 3, process_p 2" }, - /* 34*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGHIJKª", 0, 0, 16, 16, "E6 59 E9 6D 24 80 5F 93 82 BB B2 FE 11 5C 60 32 A6 DE FC 7B 30 F1 03 56", "C40 last_shift 0, symbols_left 1, process_p 0" }, - /* 35*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGHIJKê", 0, 0, 16, 16, "E6 59 E9 6D 24 80 5F 93 82 BB DB FE 78 43 69 3C C2 FE F5 2E 1B 4F B6 04", "C40 last_shift 0, symbols_left 1, process_p 0" }, - /* 36*/ { UNICODE_MODE, 0, -1, -1, "abcdef", 0, 0, 12, 12, "EF 59 E9 6D 24 E2 CC D9 B4 55 E2 6A", "TEX last_shift 0, symbols_left 0, process_p 0" }, - /* 37*/ { UNICODE_MODE, 0, -1, -1, "abcdefg", 0, 0, 14, 14, "EF 59 E9 6D 24 FE 68 81 A9 65 CD 3A A2 E9 E0 B7 E1 E5", "TEX last_shift 0, symbols_left 3, process_p 1" }, - /* 38*/ { UNICODE_MODE, 0, -1, -1, "abcdefgh", 0, 0, 14, 14, "EF 59 E9 6D 24 80 49 FE 06 E4 44 D2 32 58 90 31 E9 F8", "TEX last_shift 0, symbols_left 3, process_p 2" }, - /* 39*/ { UNICODE_MODE, 0, -1, -1, "abcdefghi", 0, 0, 14, 14, "EF 59 E9 6D 24 80 5F FE DA BF FA 16 71 15 22 4D E3 F3", "TEX last_shift 0, symbols_left 1, process_p 0" }, - /* 40*/ { UNICODE_MODE, 0, -1, -1, "abcdef\001g", 0, 0, 14, 14, "EF 59 E9 6D 24 00 3D FE 86 3B 2F 83 51 99 C0 A1 EC DD", "TEX last_shift 0, symbols_left 1, process_p 0" }, - /* 41*/ { UNICODE_MODE, 0, -1, -1, "abcdefg\001", 0, 0, 14, 14, "EF 59 E9 6D 24 7D 02 FE CF C2 FD EA DA F8 6C 56 15 9E", "TEX last_shift 0, symbols_left 1, process_p 0" }, - /* 42*/ { UNICODE_MODE, 0, -1, -1, "abcdefg\001h", 0, 0, 14, 14, "EF 59 E9 6D 24 7D 02 69 7A 9B EB A4 5E DE 99 25 01 8C", "TEX last_shift 0, symbols_left 1, process_p 1" }, - /* 43*/ { UNICODE_MODE, 0, -1, -1, "abcdefgh\001", 0, 0, 14, 14, "EF 59 E9 6D 24 80 49 02 94 2C 5C AA 84 CC 24 4E 8C 1A", "TEX last_shift 1, symbols_left 1, process_p 1" }, - /* 44*/ { UNICODE_MODE, 0, -1, -1, "abcdefgh\001i", 0, 0, 8, 32, "EF 59 E9 6D 24 80 49 09 B1 FE 2D DE FF 05 A9 AE 0B 91 4B C5 70", "TEX last_shift 1, symbols_left 3, process_p 2" }, - /* 45*/ { UNICODE_MODE, 0, -1, -1, "abcdefghi\001", 0, 0, 8, 32, "EF 59 E9 6D 24 80 5F FE 02 81 4D AB 30 86 CD D1 9D F3 15 F5 B1", "Switches to ASC for last char" }, - /* 46*/ { UNICODE_MODE, 0, -1, -1, "abcdefJg", 0, 0, 14, 14, "EF 59 E9 6D 24 0E 25 FE 01 75 0D 9C 9C BE 40 88 BF 09", "TEX last_shift 0, symbols_left 1, process_p 0" }, - /* 47*/ { UNICODE_MODE, 0, -1, -1, "abcdefgJ", 0, 0, 14, 14, "EF 59 E9 6D 24 7D 5B FE 6E 92 FE 83 42 F1 0B 0E 43 24", "TEX last_shift 0, symbols_left 1, process_p 0" }, - /* 48*/ { UNICODE_MODE, 0, -1, -1, "abcdefgJh", 0, 0, 14, 14, "EF 59 E9 6D 24 7D 5B 69 DB CB E8 CD C6 D7 FE 7D 57 36", "TEX last_shift 0, symbols_left 1, process_p 1" }, - /* 49*/ { UNICODE_MODE, 0, -1, -1, "abcdefghJ", 0, 0, 14, 14, "EF 59 E9 6D 24 80 49 4B AA 7D 6D 5F 67 B5 FA 74 BA 25", "TEX last_shift 3, symbols_left 1, process_p 1" }, - /* 50*/ { UNICODE_MODE, 0, -1, -1, "abcdefghJi", 0, 0, 8, 32, "EF 59 E9 6D 24 80 4B 41 F1 FE F1 D7 A2 9E BF 7D 54 94 DE 83 4F", "TEX last_shift 3, symbols_left 3, process_p 2" }, - /* 51*/ { UNICODE_MODE, 0, -1, -1, "abcdefghiJ", 0, 0, 8, 32, "EF 59 E9 6D 24 80 5F FE 4B 81 B3 A5 20 E3 DC F9 74 40 09 30 46", "Switches to ASC for last char" }, - /* 52*/ { UNICODE_MODE, 0, -1, -1, "abcdefghijkÊ", 0, 0, 16, 16, "EF 59 E9 6D 24 80 5F 93 82 BB DB FE 3E C8 EC 73 58 A7 42 46 10 49 25 99", "TEX last_shift 0, symbols_left 1, process_p 0" }, - /* 53*/ { UNICODE_MODE, 0, -1, -1, "abcdefghijkª", 0, 0, 16, 16, "EF 59 E9 6D 24 80 5F 93 82 BB B2 FE 57 D7 E5 7D 3C 87 4B 13 3B F7 90 CB", "TEX last_shift 0, symbols_left 1, process_p 0" }, - /* 54*/ { UNICODE_MODE, 0, -1, -1, "abcdefghijkê", 0, 0, 16, 16, "EF 59 E9 6D 24 80 5F 93 82 BF 19 FE A1 DB B7 FB 91 95 3B 6F D9 7E 1E 68", "TEX last_shift 2, symbols_left 3, process_p 2" }, - /* 55*/ { UNICODE_MODE, 0, -1, -1, "@AB@CD@E", 0, 0, 14, 14, "F0 00 10 80 0C 40 05 81 45 D9 9B 1F BC 09 CD E4 7F F4", "EDIFACT symbols_left 1, process_p 0" }, - /* 56*/ { UNICODE_MODE, 0, -1, -1, "@AB@CD@EF", 0, 0, 14, 14, "F0 00 10 80 0C 40 05 47 AC D8 F1 F0 DE 6C 30 5E 30 D4", "EDIFACT symbols_left 1, process_p 1" }, - /* 57*/ { UNICODE_MODE, 0, -1, -1, "@AB@CD@EF@", 0, 0, 8, 32, "F0 00 10 80 0C 40 05 18 07 C0 6C 60 CA 7E 7B F3 38 A1 9D D0 CC", "EDIFACT symbols_left 3, process_p 2" }, - /* 58*/ { UNICODE_MODE, 0, -1, -1, "@AB@CD@EF@G", 0, 0, 8, 32, "F0 00 10 80 0C 40 05 18 01 DF 71 FB 95 EA E6 4B 36 E0 23 9B 4C", "EDIFACT symbols_left 3, process_p 3" }, - /* 59*/ { UNICODE_MODE, 0, -1, -1, "@AB@CD@EF@GH", 0, 0, 8, 32, "F0 00 10 80 0C 40 05 18 01 C8 77 0F 96 AD 39 FB F3 04 3B BF 99", "EDIFACT symbols_left 0, process_p 0" }, - /* 60*/ { UNICODE_MODE, 0, -1, -1, "@AB@CD@EF@GH@", 0, 0, 16, 16, "F0 00 10 80 0C 40 05 18 01 C8 41 81 4A 43 1E F1 26 2E 4B EB B8 6A 2B 64", "EDIFACT symbols_left 2, process_p 1" }, - /* 61*/ { UNICODE_MODE, 0, -1, -1, "@AB@CD@EF@GH@I", 0, 0, 16, 16, "F0 00 10 80 0C 40 05 18 01 C8 41 4A 49 B3 34 91 8C 2A C4 0E 16 2F 45 9B", "EDIFACT symbols_left 2, process_p 2" }, - /* 62*/ { DATA_MODE, 0, -1, -1, "\377\376", 0, 0, 12, 12, "EB 80 EB 7F 81 6F A8 0F 21 6F 5F 88", "FN4 A7F FN4 A7E" }, - /* 63*/ { DATA_MODE, 0, -1, -1, "\377\376\375", 0, 0, 12, 12, "E7 2F C0 55 E9 52 B7 8D 38 76 E8 6E", "BAS BFF BFE BFD" }, - /* 64*/ { DATA_MODE, 3, -1, -1, "\101\102\103\104\300\105\310", 0, 3, 16, 16, "F1 04 E7 5E 2D C4 5B F1 03 1D 36 81 64 0E C0 77 9A 18 52 B2 F9 F0 04 39", "ECI 4 BAS B41 B42 B43 B44 BC0 B45 BC8" }, - /* 65*/ { UNICODE_MODE, 26, -1, -1, "ABCDÀEÈ", 0, 26, 12, 26, "F1 1B E7 60 2D C4 5B F1 06 58 B3 C7 21 81 57 ED 3D C0 12 2E 6C 80 58 CC 2C 05 0D 31 FC 2D", "ECI 27 BAS B41 B42 B43 B44 BC3 B80 B45 BC3 B88" }, - /* 66*/ { UNICODE_MODE, 0, -1, -1, "β", ZINT_WARN_USES_ECI, 9, 12, 12, "Warning F1 0A EB 63 81 41 56 DA C0 3D 2D CC", "ECI 10 FN4 A62" }, - /* 67*/ { UNICODE_MODE, 127, -1, -1, "A", 0, 127, 12, 12, "F1 80 01 42 81 14 A2 86 07 F5 27 30", "ECI 128 A41" }, - /* 68*/ { UNICODE_MODE, 16382, -1, -1, "A", 0, 16382, 12, 12, "F1 BF FE 42 81 29 57 AA A0 92 B2 45", "ECI 16383 A41" }, - /* 69*/ { UNICODE_MODE, 810899, -1, -1, "A", 0, 810899, 12, 12, "F1 CC 51 05 42 BB A5 A7 8A C6 6E 0F", "ECI 810900 A41" }, - /* 70*/ { UNICODE_MODE, 26, -1, -1, "abcdefghi1234FGHIJKLMNabc@@@@@@@@@é", 0, 26, 24, 24, "(60) F1 1B EF 59 E9 6D 24 80 5F FE 8E A4 E6 79 F6 8D 31 A0 6C FE 62 63 64 F0 00 00 00 00", "Mix of modes TEX ASC C40 ASC EDI BAS" }, - /* 71*/ { UNICODE_MODE | ESCAPE_MODE, -1, -1, -1, "[)>\\R05\\GA\\R\\E", 0, 0, 10, 10, "EC 42 81 5D 17 49 F6 B6", "Macro05 A41" }, + /* 7*/ { UNICODE_MODE, 0, -1, -1, ">*\015>*\015>", 0, 0, 14, 14, "EE 0C A9 0C A9 FE 3F 81 42 B2 11 A8 F9 0A EC C1 1E 41", "X12 symbols_left 3, process_p 1" }, + /* 8*/ { UNICODE_MODE, 0, -1, -1, ">*\015>*\015>*", 0, 0, 14, 14, "EE 0C A9 0C A9 FE 3F 2B 3F 05 D2 10 1B 9A 55 2F 68 C5", "X12 symbols_left 3, process_p 2" }, + /* 9*/ { UNICODE_MODE, 0, -1, -1, ">*\015>*\015>*\015", 0, 0, 14, 14, "EE 0C A9 0C A9 0C A9 FE 1F 30 3F EE 45 C1 1C D7 5F 7E", "X12 symbols_left 1, process_p 0" }, + /* 10*/ { UNICODE_MODE, 0, -1, -1, "ABCDEF", 0, 0, 12, 12, "E6 59 E9 6D 24 3D 15 EF AA 21 F9 59", "C40 symbols_left 0, process_p 0" }, + /* 11*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFG", 0, 0, 14, 14, "E6 59 E9 6D 24 FE 48 81 8C 7E 09 5E 10 64 BC 5F 4C 91", "C40 symbols_left 3, process_p 1" }, + /* 12*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGH", 0, 0, 14, 14, "E6 59 E9 6D 24 FE 48 49 2E 31 00 73 3B 8F 4B 55 93 19", "C40 symbols_left 3, process_p 2" }, + /* 13*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGHI", 0, 0, 14, 14, "E6 59 E9 6D 24 80 5F FE 01 DE 20 9F AA C2 FF 8F 08 97", "C40 symbols_left 1, process_p 0" }, + /* 14*/ { UNICODE_MODE, 0, -1, -1, "ABCDEF\001G", 0, 0, 14, 14, "E6 59 E9 6D 24 00 3D FE 5D 5A F5 0A 8A 4E 1D 63 07 B9", "C40 symbols_left 1, process_p 0" }, + /* 15*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFG\001", 0, 0, 14, 14, "E6 59 E9 6D 24 7D 02 FE 14 A3 27 63 01 2F B1 94 FE FA", "C40 symbols_left 1, process_p 0" }, + /* 16*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFG\001H", 0, 0, 14, 14, "E6 59 E9 6D 24 7D 02 49 C2 E6 DD 06 89 51 BA 8E 9D 1F", "C40 symbols_left 1, process_p 1" }, + /* 17*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGH\001", 0, 0, 8, 32, "E6 59 E9 6D 24 FE 48 49 02 81 BD 6D F3 94 FF 82 A6 BF BB F1 4F", "C40 symbols_left 1, process_p 1, backtracks" }, + /* 18*/ { UNICODE_MODE, 0, -1, DM_SQUARE, "ABCDEFGH\001", 0, 0, 16, 16, "E6 59 E9 6D 24 FE 48 49 02 81 FB 93 AE 8B 1C 90 DF FE EB C5 A0 2A 6A 4F", "C40 symbols_left 1, process_p 1, backtracks" }, + /* 19*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGH\001I", 0, 0, 8, 32, "E6 59 E9 6D 24 FE 48 49 02 4A E1 0D DD BC 56 E4 66 52 E6 AE 02", "C40 symbols_left 3, process_p 2, backtracks" }, + /* 20*/ { UNICODE_MODE, 0, -1, DM_SQUARE, "ABCDEFGH\001I", 0, 0, 16, 16, "E6 59 E9 6D 24 FE 48 49 02 4A 81 93 51 DF C0 0C D3 F9 72 13 17 52 5B 7E", "C40 symbols_left 5, process_p 2, backtracks" }, + /* 21*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGHI\001", 0, 0, 8, 32, "E6 59 E9 6D 24 80 5F FE 02 81 47 6C 3E 49 D3 FA 46 47 53 6E E5", "Switches to ASC for last char" }, + /* 22*/ { UNICODE_MODE, 0, -1, DM_SQUARE, "ABCDEFGHI\001", 0, 0, 16, 16, "E6 59 E9 6D 24 80 5F FE 02 81 FB 93 33 E3 4F F7 2D 08 8A BF 64 C3 B0 26", "Switches to ASC for last char" }, + /* 23*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGH\001I\001", 0, 0, 16, 16, "E6 59 E9 6D 24 FE 48 49 02 4A 02 81 BD 5D C0 B9 09 25 87 3A 09 23 9D C0", "C40 symbols_left 1, process_p 1, backtracks 2" }, + /* 24*/ { UNICODE_MODE, 0, -1, -1, "ABCDEF+G", 0, 0, 14, 14, "E6 59 E9 6D 24 07 E5 FE 6B 35 71 7F 3D 57 59 46 F7 B9", "C40 symbols_left 1, process_p 0" }, + /* 25*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFG+", 0, 0, 14, 14, "E6 59 E9 6D 24 7D 33 FE 33 F5 97 60 73 48 13 2E E5 74", "C40 symbols_left 1, process_p 0" }, + /* 26*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFG+H", 0, 0, 14, 14, "E6 59 E9 6D 24 7D 33 49 E5 B0 6D 05 FB 36 18 34 86 91", "C40 symbols_left 1, process_p 1" }, + /* 27*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGH+", 0, 0, 8, 32, "E6 59 E9 6D 24 FE 48 49 2C 81 02 BD 40 CF 3B 06 C2 DF 36 E0 48", "C40 symbols_left 1, process_p 1, backtracks" }, + /* 28*/ { UNICODE_MODE, 0, -1, DM_SQUARE, "ABCDEFGH+", 0, 0, 16, 16, "E6 59 E9 6D 24 FE 48 49 2C 81 FB 93 F6 78 B5 69 0B 83 C6 32 62 1A D2 FF", "C40 symbols_left 1, process_p 1, backtracks" }, + /* 29*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGH+I", 0, 0, 8, 32, "E6 59 E9 6D 24 FE 48 49 2C 4A 5E DD 6E E7 92 60 02 32 6B BF 05", "C40 symbols_left 3, process_p 2, backtracks" }, + /* 30*/ { UNICODE_MODE, 0, -1, DM_SQUARE, "ABCDEFGH+I", 0, 0, 16, 16, "E6 59 E9 6D 24 FE 48 49 2C 4A 81 93 09 2C 69 F5 07 84 5F E4 D5 62 E3 CE", "C40 symbols_left 5, process_p 2, backtracks" }, + /* 31*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGHI+", 0, 0, 8, 32, "E6 59 E9 6D 24 80 5F FE 2C 81 F8 BC 8D 12 17 7E 22 27 DE 7F E2", "C40 symbols_left 3, process_p 2, backtracks" }, + /* 32*/ { UNICODE_MODE, 0, -1, DM_SQUARE, "ABCDEFGHI+", 0, 0, 16, 16, "E6 59 E9 6D 24 80 5F FE 2C 81 FB 93 6B 10 E6 0E F9 75 A7 48 A6 F3 08 96", "Switches to ASC for last char" }, + /* 33*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFjG", 0, 0, 14, 14, "E6 59 E9 6D 24 0E 25 FE DA 14 D7 15 47 69 9D 4A 54 6D", "C40 symbols_left 1, process_p 0" }, + /* 34*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGj", 0, 0, 14, 14, "E6 59 E9 6D 24 7D 5B FE B5 F3 24 0A 99 26 D6 CC A8 40", "C40 symbols_left 1, process_p 0" }, + /* 35*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGjH", 0, 0, 14, 14, "E6 59 E9 6D 24 7D 5B 49 63 B6 DE 6F 11 58 DD D6 CB A5", "C40 symbols_left 1, process_p 1" }, + /* 36*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGHj", 0, 0, 8, 32, "E6 59 E9 6D 24 FE 48 49 6B 81 ED 78 CB 9F 52 EE 52 88 91 67 96", "C40 symbols_left 1, process_p 1, backtracks" }, + /* 37*/ { UNICODE_MODE, 0, -1, DM_SQUARE, "ABCDEFGHj", 0, 0, 16, 16, "E6 59 E9 6D 24 FE 48 49 6B 81 FB 93 BF 72 03 35 09 37 98 FF 39 A7 E3 6D", "C40 symbols_left 1, process_p 1, backtracks" }, + /* 38*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGHjI", 0, 0, 8, 32, "E6 59 E9 6D 24 FE 48 49 6B 4A B1 18 E5 B7 FB 88 92 65 CC 38 DB", "C40 symbols_left 3, process_p 2, backtracks" }, + /* 39*/ { UNICODE_MODE, 0, -1, DM_SQUARE, "ABCDEFGHjI", 0, 0, 16, 16, "E6 59 E9 6D 24 FE 48 49 6B 4A 81 93 40 26 DF A9 05 30 01 29 8E DF D2 5C", "C40 symbols_left 5, process_p 2, backtracks" }, + /* 40*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGHIj", 0, 0, 8, 32, "E6 59 E9 6D 24 80 5F FE 6B 81 17 79 06 42 7E 96 B2 70 79 F8 3C", "Switches to ASC for last char" }, + /* 41*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGHIJÊ", 0, 0, 16, 16, "E6 59 E9 6D 24 80 5F FE 4B EB 4B 81 DD D9 F9 C9 C5 38 F3 4B DB 80 92 A7", "Switches to ASC for last 2 chars" }, + /* 42*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGHIJKÊ", 0, 0, 16, 16, "E6 59 E9 6D 24 80 5F FE 4B 4C EB 4B 15 17 46 06 70 F3 15 74 45 26 72 2D", "C40 symbols_left 3, process_p 2, backtracks" }, + /* 43*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGHIJKª", 0, 0, 16, 16, "E6 59 E9 6D 24 80 5F 93 82 BB B2 FE 11 5C 60 32 A6 DE FC 7B 30 F1 03 56", "C40 symbols_left 1, process_p 0" }, + /* 44*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGHIJKê", 0, 0, 16, 16, "E6 59 E9 6D 24 80 5F 93 82 BB DB FE 78 43 69 3C C2 FE F5 2E 1B 4F B6 04", "C40 symbols_left 1, process_p 0" }, + /* 45*/ { UNICODE_MODE, 0, -1, -1, "abcdef", 0, 0, 12, 12, "EF 59 E9 6D 24 E2 CC D9 B4 55 E2 6A", "TEX symbols_left 0, process_p 0" }, + /* 46*/ { UNICODE_MODE, 0, -1, -1, "abcdefg", 0, 0, 14, 14, "EF 59 E9 6D 24 FE 68 81 A9 65 CD 3A A2 E9 E0 B7 E1 E5", "TEX symbols_left 3, process_p 1" }, + /* 47*/ { UNICODE_MODE, 0, -1, -1, "abcdefgh", 0, 0, 14, 14, "EF 59 E9 6D 24 FE 68 69 68 36 28 3C 85 5A E9 D4 49 9A", "TEX symbols_left 3, process_p 2" }, + /* 48*/ { UNICODE_MODE, 0, -1, -1, "abcdefghi", 0, 0, 14, 14, "EF 59 E9 6D 24 80 5F FE DA BF FA 16 71 15 22 4D E3 F3", "TEX symbols_left 1, process_p 0" }, + /* 49*/ { UNICODE_MODE, 0, -1, -1, "abcdef\001g", 0, 0, 14, 14, "EF 59 E9 6D 24 00 3D FE 86 3B 2F 83 51 99 C0 A1 EC DD", "TEX symbols_left 1, process_p 0" }, + /* 50*/ { UNICODE_MODE, 0, -1, -1, "abcdefg\001", 0, 0, 14, 14, "EF 59 E9 6D 24 7D 02 FE CF C2 FD EA DA F8 6C 56 15 9E", "TEX symbols_left 1, process_p 0" }, + /* 51*/ { UNICODE_MODE, 0, -1, -1, "abcdefg\001h", 0, 0, 14, 14, "EF 59 E9 6D 24 7D 02 69 7A 9B EB A4 5E DE 99 25 01 8C", "TEX symbols_left 1, process_p 1" }, + /* 52*/ { UNICODE_MODE, 0, -1, -1, "abcdefgh\001", 0, 0, 8, 32, "EF 59 E9 6D 24 FE 68 69 02 81 EB 84 25 32 6E 1B 5A FB 1D 25 4A", "TEX symbols_left 1, process_p 1, backtracks" }, + /* 53*/ { UNICODE_MODE, 0, -1, DM_SQUARE, "abcdefgh\001", 0, 0, 16, 16, "EF 59 E9 6D 24 FE 68 69 02 81 FB 93 93 FD 1E 3B BA 1D 16 4D 59 41 EC B9", "TEX symbols_left 1, process_p 1, backtracks" }, + /* 54*/ { UNICODE_MODE, 0, -1, -1, "abcdefgh\001i", 0, 0, 8, 32, "EF 59 E9 6D 24 FE 68 69 02 6A 31 35 48 9B 93 6E 15 BB 02 9D F4", "TEX symbols_left 3, process_p 2, backtracks" }, + /* 55*/ { UNICODE_MODE, 0, -1, DM_SQUARE, "abcdefgh\001i", 0, 0, 16, 16, "EF 59 E9 6D 24 FE 68 69 02 6A 81 93 DE D7 EC 9B 7D 72 9C 68 B8 6E CF 31", "TEX symbols_left 3, process_p 2, backtracks" }, + /* 56*/ { UNICODE_MODE, 0, -1, -1, "abcdefghi\001", 0, 0, 8, 32, "EF 59 E9 6D 24 80 5F FE 02 81 4D AB 30 86 CD D1 9D F3 15 F5 B1", "Switches to ASC for last char" }, + /* 57*/ { UNICODE_MODE, 0, -1, -1, "abcdefgh\001i\001", 0, 0, 16, 16, "EF 59 E9 6D 24 FE 68 69 02 6A 02 81 32 55 EC 2E A7 AE 69 41 A6 1F 09 8F", "TEX symbols_left 1, process_p 1, backtracks 2" }, + /* 58*/ { UNICODE_MODE, 0, -1, -1, "abcdefJg", 0, 0, 14, 14, "EF 59 E9 6D 24 0E 25 FE 01 75 0D 9C 9C BE 40 88 BF 09", "TEX symbols_left 1, process_p 0" }, + /* 59*/ { UNICODE_MODE, 0, -1, -1, "abcdefgJ", 0, 0, 14, 14, "EF 59 E9 6D 24 7D 5B FE 6E 92 FE 83 42 F1 0B 0E 43 24", "TEX symbols_left 1, process_p 0" }, + /* 60*/ { UNICODE_MODE, 0, -1, -1, "abcdefgJh", 0, 0, 14, 14, "EF 59 E9 6D 24 7D 5B 69 DB CB E8 CD C6 D7 FE 7D 57 36", "TEX symbols_left 1, process_p 1" }, + /* 61*/ { UNICODE_MODE, 0, -1, -1, "abcdefghJ", 0, 0, 8, 32, "EF 59 E9 6D 24 FE 68 69 4B 81 15 8A 35 57 7F 33 B3 48 01 E0 BD", "TEX symbols_left 1, process_p 1, backtracks" }, + /* 62*/ { UNICODE_MODE, 0, -1, DM_SQUARE, "abcdefghJ", 0, 0, 16, 16, "EF 59 E9 6D 24 FE 68 69 4B 81 FB 93 5B D4 D2 8B EE 85 F2 3E 3F 8E E5 04", "TEX symbols_left 1, process_p 1, backtracks" }, + /* 63*/ { UNICODE_MODE, 0, -1, -1, "abcdefghJi", 0, 0, 8, 32, "EF 59 E9 6D 24 FE 68 69 4B 6A CF 3B 58 FE 82 46 FC 08 1E 58 03", "TEX symbols_left 3, process_p 2, backtracks" }, + /* 64*/ { UNICODE_MODE, 0, -1, DM_SQUARE, "abcdefghJi", 0, 0, 16, 16, "EF 59 E9 6D 24 FE 68 69 4B 6A 81 93 16 FE 20 2B 29 EA 78 1B DE A1 C6 8C", "TEX symbols_left 3, process_p 2, backtracks" }, + /* 65*/ { UNICODE_MODE, 0, -1, -1, "abcdefghiJ", 0, 0, 8, 32, "EF 59 E9 6D 24 80 5F FE 4B 81 B3 A5 20 E3 DC F9 74 40 09 30 46", "Switches to ASC for last char" }, + /* 66*/ { UNICODE_MODE, 0, -1, -1, "abcdefghijkÊ", 0, 0, 16, 16, "EF 59 E9 6D 24 80 5F 93 82 BB DB FE 3E C8 EC 73 58 A7 42 46 10 49 25 99", "TEX symbols_left 1, process_p 0" }, + /* 67*/ { UNICODE_MODE, 0, -1, -1, "abcdefghijkª", 0, 0, 16, 16, "EF 59 E9 6D 24 80 5F 93 82 BB B2 FE 57 D7 E5 7D 3C 87 4B 13 3B F7 90 CB", "TEX symbols_left 1, process_p 0" }, + /* 68*/ { UNICODE_MODE, 0, -1, -1, "abcdefghijkê", 0, 0, 16, 16, "EF 59 E9 6D 24 80 5F FE 6B 6C EB 6B 59 43 1A B1 96 F4 FF C5 B5 08 AE 2F", "TEX symbols_left 3, process_p 2, backtracks" }, + /* 69*/ { UNICODE_MODE, 0, -1, -1, "\015*>\015*>", 0, 0, 12, 12, "EE 00 2B 00 2B 83 3B 0A CE 32 36 65", "X12 symbols_left 0, process_p 0" }, + /* 70*/ { UNICODE_MODE, 0, -1, -1, "\015*>\015*>\015", 0, 0, 14, 14, "EE 00 2B 00 2B FE 0E 81 C0 6C BF 37 F6 D6 48 71 E2 38", "Switches to ASC for last char" }, + /* 71*/ { UNICODE_MODE, 0, -1, -1, "\015*>\015*>\015*", 0, 0, 14, 14, "EE 00 2B 00 2B FE 0E 2B BD DB 7C 8F 14 46 F1 9F 94 BC", "Switches to ASC for last 2 chars" }, + /* 72*/ { UNICODE_MODE, 0, -1, -1, "\015*>\015*>\015*>", 0, 0, 14, 14, "EE 00 2B 00 2B 00 2B FE BF 81 70 74 1C 65 10 0C 06 38", "X12 symbols_left 1, process_p 0, ASC unlatch at end" }, + /* 73*/ { UNICODE_MODE, 0, -1, -1, "\015*>\015*>\015*>\015", 0, 0, 14, 14, "EE 00 2B 00 2B 00 2B 0E 1C DB D8 26 3E EC CF 9C C3 4A", "X12 symbols_left 1, process_p 1, ASC no latch at end" }, + /* 74*/ { UNICODE_MODE, 0, -1, -1, "\015*>\015*>\015*>\015*", 0, 0, 8, 32, "EE 00 2B 00 2B 00 2B FE 0E 2B 65 37 5F 2F F3 96 BE 9A 03 55 68", "X12 symbols_left 3, process_p 2, ASC last 2 chars" }, + /* 75*/ { UNICODE_MODE, 0, -1, -1, "\015*>\015*>\015*>\015*>", 0, 0, 8, 32, "EE 00 2B 00 2B 00 2B 00 2B FE 6E 95 3A 10 58 4E 96 06 79 09 94", "X12 symbols_left 1, process_p 0, ASC unlatch at end" }, + /* 76*/ { UNICODE_MODE, 0, -1, -1, "@A1^B2?C", 0, 0, 14, 14, "F0 00 1C 5E 0B 2F C3 81 2D 71 45 13 9B FF A1 B0 0B E2", "EDIFACT symbols_left 1, process_p 0" }, + /* 77*/ { UNICODE_MODE, 0, -1, -1, "@A1^B2?C3", 0, 0, 14, 14, "F0 00 1C 5E 0B 2F C3 34 81 E8 6C 9E CE 12 CB F5 58 3F", "EDIFACT symbols_left 1, process_p 1" }, + /* 78*/ { UNICODE_MODE, 0, -1, -1, "@A1^B2?C3+", 0, 0, 8, 32, "F0 00 1C 5E 0B 2F C3 CE B7 C0 33 C6 81 E1 63 6E 5E B4 27 30 C9", "EDIFACT symbols_left 3, process_p 2" }, + /* 79*/ { UNICODE_MODE, 0, -1, -1, "@A1^B2?C3+D", 0, 0, 8, 32, "F0 00 1C 5E 0B 2F C3 CE B1 1F 4D E1 79 04 2B BC 05 6C 38 73 39", "EDIFACT symbols_left 3, process_p 3" }, + /* 80*/ { UNICODE_MODE, 0, -1, -1, "@A1^B2?C3+D4", 0, 0, 8, 32, "F0 00 1C 5E 0B 2F C3 CE B1 34 F4 EC B3 DC 03 A3 1F B5 86 C3 F7", "EDIFACT symbols_left 0, process_p 0" }, + /* 81*/ { UNICODE_MODE, 0, -1, -1, "@A1^B2?C3+D4=", 0, 0, 16, 16, "F0 00 1C 5E 0B 2F C3 CE B1 34 3E 81 42 96 43 6E 92 0D A9 B1 65 3C CF 9B", "EDIFACT symbols_left 2, process_p 1" }, + /* 82*/ { UNICODE_MODE, 0, -1, -1, "@A1^B2?C3+D4=E", 0, 0, 16, 16, "F0 00 1C 5E 0B 2F C3 CE B1 34 3E 46 AD 8C F2 D8 5D AF F3 65 08 1F E3 A5", "EDIFACT symbols_left 2, process_p 2" }, + /* 83*/ { DATA_MODE, 0, -1, -1, "\377\376", 0, 0, 12, 12, "EB 80 EB 7F 81 6F A8 0F 21 6F 5F 88", "FN4 A7F FN4 A7E, 1 pad" }, + /* 84*/ { DATA_MODE, 0, -1, -1, "\377\376\375", 0, 0, 12, 12, "E7 2C C0 55 E9 67 45 8A D2 7E A9 23", "BAS BFF BFE BFD, no padding" }, + /* 85*/ { DATA_MODE, 3, -1, -1, "\101\102\103\104\300\105\310", 0, 3, 16, 16, "F1 04 E7 5E 2D C4 5B F1 03 1D 36 81 64 0E C0 77 9A 18 52 B2 F9 F0 04 39", "ECI 4 BAS B41 B42 B43 B44 BC0 B45 BC8" }, + /* 86*/ { UNICODE_MODE, 26, -1, -1, "ABCDÀEÈ", 0, 26, 12, 26, "F1 1B E7 60 2D C4 5B F1 06 58 B3 C7 21 81 57 ED 3D C0 12 2E 6C 80 58 CC 2C 05 0D 31 FC 2D", "ECI 27 BAS B41 B42 B43 B44 BC3 B80 B45 BC3 B88" }, + /* 87*/ { UNICODE_MODE, 0, -1, -1, "β", ZINT_WARN_USES_ECI, 9, 12, 12, "Warning F1 0A EB 63 81 41 56 DA C0 3D 2D CC", "ECI 10 FN4 A62" }, + /* 88*/ { UNICODE_MODE, 127, -1, -1, "A", 0, 127, 12, 12, "F1 80 01 42 81 14 A2 86 07 F5 27 30", "ECI 128 A41" }, + /* 89*/ { UNICODE_MODE, 16382, -1, -1, "A", 0, 16382, 12, 12, "F1 BF FE 42 81 29 57 AA A0 92 B2 45", "ECI 16383 A41" }, + /* 90*/ { UNICODE_MODE, 810899, -1, -1, "A", 0, 810899, 12, 12, "F1 CC 51 05 42 BB A5 A7 8A C6 6E 0F", "ECI 810900 A41" }, + /* 91*/ { UNICODE_MODE | ESCAPE_MODE, -1, -1, -1, "[)>\\R05\\GA\\R\\E", 0, 0, 10, 10, "EC 42 81 5D 17 49 F6 B6", "Macro05 A41" }, }; int data_size = ARRAY_SIZE(data); - char escaped[1024]; + char escaped[8192]; + char bwipp_buf[32768]; + char bwipp_msg[1024]; for (int i = 0; i < data_size; i++) { @@ -345,18 +659,30 @@ static void test_input(int index, int generate, int debug) { int length = testUtilSetSymbol(symbol, BARCODE_DATAMATRIX, data[i].input_mode, data[i].eci, -1 /*option_1*/, data[i].option_2, data[i].option_3, -1 /*output_options*/, data[i].data, -1, debug); ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); - assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret); + assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); if (generate) { - printf(" /*%3d*/ { %s, %d, %d, %d, \"%s\", %s, %d, %d, %d, \"%s\", \"%s\" },\n", - i, testUtilInputModeName(data[i].input_mode), data[i].eci, data[i].option_2, data[i].option_3, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), - testUtilErrorName(data[i].ret), ret < 5 ? symbol->eci : -1, symbol->rows, symbol->width, symbol->errtxt, data[i].comment); + printf(" /*%3d*/ { %s, %d, %d, %s, \"%s\", %s, %d, %d, %d, \"%s\", \"%s\" },\n", + i, testUtilInputModeName(data[i].input_mode), data[i].eci, data[i].option_2, testUtilOption3Name(data[i].option_3), + testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), + testUtilErrorName(data[i].ret), ret < ZINT_ERROR ? symbol->eci : -1, symbol->rows, symbol->width, symbol->errtxt, data[i].comment); } else { - if (ret < 5) { + 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); assert_equal(symbol->rows, data[i].expected_rows, "i:%d rows %d != %d\n", i, symbol->rows, data[i].expected_rows); assert_equal(symbol->width, data[i].expected_width, "i:%d width %d != %d\n", i, symbol->width, data[i].expected_width); assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); + + if (do_bwipp && testUtilCanBwipp(i, symbol, -1, data[i].option_2, data[i].option_3, debug)) { + char modules_dump[8192]; + assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump != -1\n", i); + ret = testUtilBwipp(i, symbol, -1, data[i].option_2, data[i].option_3, data[i].data, length, NULL, bwipp_buf, sizeof(bwipp_buf)); + assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); + + ret = testUtilBwippCmp(symbol, bwipp_msg, bwipp_buf, modules_dump); + assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n", + i, testUtilBarcodeName(symbol->symbology), ret, bwipp_msg, bwipp_buf, modules_dump); + } } } @@ -389,7 +715,8 @@ static void test_encode(int index, int generate, int debug) { char *comment; char *expected; }; - // Verified manually against ISO/IEC 16022:2006, GS1 General Specifications 21.0.1 (GGS), ANSI/HIBC LIC 2.6-2016 (HIBC/LIC) and ANSI/HIBC PAS 1.3-2010 (HIBC/PAS), with noted exceptions + // Verified manually against ISO/IEC 16022:2006, ISO/IEC 21471:2020, GS1 General Specifications 21.0.1 (GGS), ANSI/HIBC LIC 2.6-2016 (HIBC/LIC) and + // ANSI/HIBC PAS 1.3-2010 (HIBC/PAS), with noted exceptions struct item data[] = { /* 0*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, "1234abcd", 0, 14, 14, 1, "", "10101010101010" @@ -407,7 +734,7 @@ static void test_encode(int index, int generate, int debug) { "10011111000100" "11111111111111" }, - /* 1*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, "A1B2C3D4E5F6G7H8I9J0K1L2", 0, 18, 18, 1, "ISO 16022:2006 Figure 1", + /* 1*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, "A1B2C3D4E5F6G7H8I9J0K1L2", 0, 18, 18, 1, "16022:2006 Figure 1", "101010101010101010" "101000101010001111" "101100000111000010" @@ -427,7 +754,7 @@ static void test_encode(int index, int generate, int debug) { "100011000000100100" "111111111111111111" }, - /* 2*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, "123456", 0, 10, 10, 1, "ISO 16022:2006 Figure O.2", + /* 2*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, "123456", 0, 10, 10, 1, "16022:2006 Figure O.2", "1010101010" "1100101101" "1100000100" @@ -439,7 +766,7 @@ static void test_encode(int index, int generate, int debug) { "1001110100" "1111111111" }, - /* 3*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, "30Q324343430794\\R06\\G+/ACMRN123456/V2009121908334\\R\\E", 0, 20, 20, 1, "HIBC/PAS Section 2.2 Patient Id Macro, same", + /* 24*/ { BARCODE_DATAMATRIX, DATA_MODE | ESCAPE_MODE, -1, -1, -1, -1, "[)>\\R06\\G+/ACMRN123456/V2009121908334\\R\\E", 0, 20, 20, 1, "HIBC/PAS 1.3-2010 Section 2.2 Patient Id Macro, same", "10101010101010101010" "10000000001110001111" "11010101001010011100" @@ -849,7 +1238,7 @@ static void test_encode(int index, int generate, int debug) { "11100110001010111010" "11111111111111111111" }, - /* 21*/ { BARCODE_HIBC_DM, -1, -1, -1, -1, -1, "/EO523201", 0, 14, 14, 1, "HIBC/PAS Section 2.2 Purchase Order, same", + /* 25*/ { BARCODE_HIBC_DM, -1, -1, -1, -1, -1, "/EO523201", 0, 14, 14, 1, "HIBC/PAS Section 2.2 Purchase Order, same", "10101010101010" "10011001010101" "11101000011010" @@ -865,7 +1254,7 @@ static void test_encode(int index, int generate, int debug) { "10010010000100" "11111111111111" }, - /* 22*/ { BARCODE_HIBC_DM, -1, -1, -1, -1, DM_SQUARE, "/EU720060FF0/O523201", 0, 18, 18, 1, "HIBC/PAS Section 2.2 2nd Purchase Order, same", + /* 26*/ { BARCODE_HIBC_DM, -1, -1, -1, -1, DM_SQUARE, "/EU720060FF0/O523201", 0, 18, 18, 1, "HIBC/PAS Section 2.2 2nd Purchase Order, same", "101010101010101010" "100110010100100001" "111011110110010110" @@ -885,7 +1274,7 @@ static void test_encode(int index, int generate, int debug) { "111000010011001010" "111111111111111111" }, - /* 23*/ { BARCODE_HIBC_DM, -1, -1, -1, -1, -1, "/EU720060FF0/O523201/Z34H159/M9842431340", 0, 22, 22, 1, "HIBC/PAS Section 2.2 3rd Purchase Order (left), same", + /* 27*/ { BARCODE_HIBC_DM, -1, -1, -1, -1, -1, "/EU720060FF0/O523201/Z34H159/M9842431340", 0, 22, 22, 1, "HIBC/PAS Section 2.2 3rd Purchase Order (left), same", "1010101010101010101010" "1001100101001000000011" "1110111101100001111010" @@ -909,7 +1298,7 @@ static void test_encode(int index, int generate, int debug) { "1010110000010001001000" "1111111111111111111111" }, - /* 24*/ { BARCODE_DATAMATRIX, DATA_MODE | ESCAPE_MODE, -1, -1, -1, -1, "[)>\\R06\\G+/EU720060FF0/O523201/Z34H159/M9842431340V\\R\\E", 0, 22, 22, 1, "HIBC/PAS Section 2.2 3rd Purchase Order (right), same", + /* 28*/ { BARCODE_DATAMATRIX, DATA_MODE | ESCAPE_MODE, -1, -1, -1, -1, "[)>\\R06\\G+/EU720060FF0/O523201/Z34H159/M9842431340V\\R\\E", 0, 22, 22, 1, "HIBC/PAS Section 2.2 3rd Purchase Order (right), same", "1010101010101010101010" "1000000000111010011101" "1101011100101001011100" @@ -933,7 +1322,7 @@ static void test_encode(int index, int generate, int debug) { "1001110110011101101000" "1111111111111111111111" }, - /* 25*/ { BARCODE_HIBC_DM, -1, -1, -1, -1, -1, "/E+/KN12345", 0, 16, 16, 1, "HIBC/PAS Section 2.2 Asset Tag **NOT SAME** check digit 'A' in figure is for '/KN12345', but actual data is as given here, when check digit is 'J'", + /* 29*/ { BARCODE_HIBC_DM, -1, -1, -1, -1, -1, "/E+/KN12345", 0, 16, 16, 1, "HIBC/PAS Section 2.2 Asset Tag **NOT SAME** check digit 'A' in figure is for '/KN12345', but actual data is as given here, when check digit is 'J'", "1010101010101010" "1001101010001111" "1110001000101100" @@ -951,7 +1340,7 @@ static void test_encode(int index, int generate, int debug) { "1001000000000010" "1111111111111111" }, - /* 26*/ { BARCODE_HIBC_DM, -1, -1, -1, -1, -1, "/LAH123/NC903", 0, 16, 16, 1, "HIBC/PAS Section 2.2 Surgical Instrument, same", + /* 30*/ { BARCODE_HIBC_DM, -1, -1, -1, -1, -1, "/LAH123/NC903", 0, 16, 16, 1, "HIBC/PAS Section 2.2 Surgical Instrument, same", "1010101010101010" "1001010001010001" "1110010100000100" @@ -969,7 +1358,67 @@ static void test_encode(int index, int generate, int debug) { "1100000101010010" "1111111111111111" }, - /* 27*/ { BARCODE_DATAMATRIX, DATA_MODE, 3, -1, -1, -1, "\101\300", 0, 12, 12, 1, "AÀ", + /* 31*/ { BARCODE_DATAMATRIX, DATA_MODE | ESCAPE_MODE, -1, -1, 7, -1, "[)>\\R06\\G18VD89536\\G1P8902A\\GS3122A02965\\R\\E", 0, 22, 22, 1, "ANSI MH10.8.17-2017 Figure 4 Macro06 **NOT SAME** 253-state randomising of padding in figure seems incorrect", + "1010101010101010101010" + "1101110000111001011011" + "1010111010001010001110" + "1100011100101001000111" + "1110011000100010001100" + "1111011100011001000101" + "1011101101000101111010" + "1100101100010101010111" + "1110101001001000001100" + "1000010001111000110101" + "1110111001110000001000" + "1010100011101000011011" + "1100010101011110111010" + "1011011000011100011111" + "1011001001000101100110" + "1000000111001100000001" + "1011110001100011000010" + "1100110100000110100111" + "1100011111110000001110" + "1100110010010010001101" + "1000001010010010110100" + "1111111111111111111111" + }, + /* 32*/ { BARCODE_DATAMATRIX, DATA_MODE | ESCAPE_MODE, -1, -1, -1, -1, "[)>\\R06\\G25S0614141MH80312\\R\\E", 0, 16, 16, 1, "ANSI MH10.8.17-2017 Table B.1 B7", + "1010101010101010" + "1101000010101111" + "1011100001011100" + "1011010001010101" + "1110000110111010" + "1101010011011111" + "1000010001111100" + "1101100111110101" + "1100101101001100" + "1010100000001111" + "1001100010010100" + "1001000000000101" + "1011110011000010" + "1110101111010101" + "1010101010001010" + "1111111111111111" + }, + /* 33*/ { BARCODE_DATAMATRIX, DATA_MODE | ESCAPE_MODE, -1, -1, -1, -1, "[)>\\R05\\G80040614141MH80312\\R\\E", 0, 16, 16, 1, "ANSI MH10.8.17-2017 Table B.1 B8", + "1010101010101010" + "1111100010001111" + "1010100001100100" + "1010010001011001" + "1110000110000110" + "1001010011101111" + "1000010010001100" + "1101100111110101" + "1100101000101100" + "1010100001010011" + "1001001100111100" + "1001110010011101" + "1001011000010100" + "1100110000010101" + "1010000010101010" + "1111111111111111" + }, + /* 34*/ { BARCODE_DATAMATRIX, DATA_MODE, 3, -1, -1, -1, "\101\300", 0, 12, 12, 1, "AÀ", "101010101010" "100010101111" "100001011110" @@ -983,7 +1432,7 @@ static void test_encode(int index, int generate, int debug) { "100011011010" "111111111111" }, - /* 28*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 26, -1, -1, -1, "AÀ", 0, 14, 14, 1, "AÀ", + /* 35*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 26, -1, -1, -1, "AÀ", 0, 14, 14, 1, "AÀ", "10101010101010" "10001010100001" "10110101100100" @@ -999,27 +1448,601 @@ static void test_encode(int index, int generate, int debug) { "11000110001100" "11111111111111" }, - /* 29*/ { BARCODE_DATAMATRIX, UNICODE_MODE, -1, -1, -1, -1, "abcdefgh+", 0, 14, 14, 0, "TEX last_shift 2, symbols_left 1, process_p 1; BWIPP different encodation (does not use 0 padded Text)", - "10101010101010" - "10100110111011" - "10110010100010" - "10011000100101" - "11101000000000" - "11000110110111" - "11000010110100" - "10101011010111" - "10111110000100" - "11011001001111" - "11110111100000" - "11001011110101" - "10010111010100" - "11111111111111" + /* 36*/ { BARCODE_DATAMATRIX, UNICODE_MODE, -1, -1, -1, DM_SQUARE, "abcdefgh+", 0, 16, 16, 1, "TEX last_shift 2, symbols_left 1, process_p 1", + "1010101010101010" + "1010011011101001" + "1011001010010010" + "1001100100110011" + "1111100010101100" + "1111111011110111" + "1111011111111100" + "1011001100001111" + "1000000101011000" + "1000011011000111" + "1101011100110100" + "1100100100110101" + "1000000111001000" + "1111111010001101" + "1101110101001010" + "1111111111111111" + }, + /* 37*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, -1, -1, -1, "\200\200\200\200\200\200\200", 0, 8, 32, 1, "7 BASE256s, 1 pad", + "10101010101010101010101010101010" + "10000101000011011000110100100001" + "11100111110101001011101110100010" + "10111011010100111110010110001011" + "11001000110001101000001111000010" + "11000010000001111000100101001011" + "11010000111100001010011101100100" + "11111111111111111111111111111111" + }, + /* 38*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, -1, -1, -1, "\200\200\200\200\200\200\200\200", 0, 8, 32, 1, "8 BASE256s, no padding", + "10101010101010101010101010101010" + "10000101000011011111001101000001" + "11010111110101001001011001100010" + "11001011010111111010001100100011" + "11001000110000101011101100011010" + "11000010000001111000010010110011" + "11010000110010001001010001111000" + "11111111111111111111111111111111" + }, + /* 39*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, -1, -1, DM_SQUARE, "\200\200\200\200\200\200\200\200\200\200", 0, 16, 16, 1, "8 BASE256s, square, no padding", + "1010101010101010" + "1000010100001101" + "1101011111101110" + "1100101101000101" + "1000100000110000" + "1100011100010111" + "1001010100101100" + "1110111010010111" + "1000111000010110" + "1110001101001001" + "1000110011010000" + "1011110101001101" + "1000000010101100" + "1001001000100101" + "1111000011111010" + "1111111111111111" + }, + /* 40*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, -1, -1, -1, "\200\200\200\200\200\200\200\200\200", 0, 16, 16, 1, "9 BASE256s, 1 pad", + "1010101010101010" + "1000010101001101" + "1110011111000010" + "1101101101010101" + "1000100000001010" + "1100011001101111" + "1001010111100100" + "1110111001100111" + "1000111101000010" + "1110001101001101" + "1000011111001000" + "1011001101010111" + "1010101000000000" + "1011001001011101" + "1100000011011010" + "1111111111111111" + }, + /* 41*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, -1, -1, -1, "\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200", 0, 22, 22, 1, "22 BASE256s, 6 pads", + "1010101010101010101010" + "1010010100011100010101" + "1000011110111110001100" + "1010101100010111000101" + "1000100000010100110110" + "1100011100101000100101" + "1001010100111101110100" + "1110111000010101110111" + "1000111010101000101100" + "1110000111111001100111" + "1000000111110100001010" + "1011110011101111101001" + "1111000101101110010000" + "1100011000111101111001" + "1111001010100110101110" + "1111000100111010000001" + "1110000100011110101100" + "1100010001111011110101" + "1000101001101111011100" + "1111110010000111001001" + "1111101000110111010100" + "1111111111111111111111" + }, + /* 42*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, -1, -1, DM_DMRE, "\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200", 0, 8, 64, 1, "22 BASE256s, no padding", + "1010101010101010101010101010101010101010101010101010101010101010" + "1000010101100011101010101011101111110100100110011100010011010111" + "1101011110001010110000001110001010001011010111001010101101100000" + "1100101000110001110100000001100110010100111101111110000010011111" + "1000100101001000110110101110011011110110111010101110010111001100" + "1100001101011011111101111000110110110101110110111111011010011111" + "1101000011001010111101101101110010111100111101001010010011001000" + "1111111111111111111111111111111111111111111111111111111111111111" + }, + /* 43*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, -1, -1, -1, "\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\061\062\063\064\065\066", 0, 64, 64, 1, "249 BASE256s + 6 ASCII (3 double-digits)", + "1010101010101010101010101010101010101010101010101010101010101010" + "1000010100011101100000010111100110100010110111011011111010000001" + "1100011110111110100110111101111010101101000010001101001011001100" + "1101101100010111110011110010101111111101101111111000111010011111" + "1000100000010100101110100100010011101111110111101111000010011100" + "1100011100101001111000111100010110100000001000111000010111011111" + "1001010100111000110001000111000010000110010001101001010100110110" + "1110111000001001100110011110010110100111101011111101110000100001" + "1000111010111010101111110111010011110010010000101011111100100100" + "1110000111101011110100011110010111101001010010011010011100101111" + "1000000110110110101100000110101010111110101110001001100111001010" + "1011110011010011100100010101110110010111100011011011000101010001" + "1111000000110100100110001000001010110000101101001000110010011100" + "1100010111100011111010011010011110001011111110011001011110110101" + "1111011001000110110011110110010010011101001110101110100000100000" + "1111111111111111111111111111111111111111111111111111111111111111" + "1010101010101010101010101010101010101010101010101010101010101010" + "1110001011011001101110110011001111000100100101111110101111000101" + "1110110010110010111000100100011010010000000010101111111101011000" + "1101000010101101110111100001111110100100111100111100010010010011" + "1000100110010100110000111011001011101101110101001001100110110100" + "1111100101011001100001011010011111100110001111111010101010010111" + "1000001111111110110101011001100011101101000010101100111010001110" + "1111000000111101101111010011010111000001100001111110000100000001" + "1111010010101010100000011000001010001110111110101110000001111010" + "1011001001000111100000011010011110111101001101011110111011000001" + "1000010001100010101101001011010011100111000010101001111100101110" + "1111011010100001111100001110110111001001101010111111110010101101" + "1110100001010010100001011000100010001010100100001101110101001100" + "1111111110101101111011010111110111101000001011011110100000000011" + "1001110010110010111011001000101011011110110101101001001010101100" + "1111111111111111111111111111111111111111111111111111111111111111" + "1010101010101010101010101010101010101010101010101010101010101010" + "1101000101000011110110000010110111101010011000011011010101000001" + "1101111101111010110111110101100011001010001010101100011011100010" + "1011011101111111111111010000101111011110000101011000011000100011" + "1011011110000100101000101100100011100101110101001110000101001100" + "1000101100001001110001110111011111000100111010111111011110001001" + "1010100101101000110000011111110011001100101111101000111000101100" + "1100001101001011101001110000100110000100011001011100010001000011" + "1100000011000000110100100100111011000111110110001101011110011110" + "1001100111111111101100110100011110111000010011111000001000111111" + "1010100111101010101001000101100011100100011101001000011100011010" + "1100100101001111101001111111011111100110000101111001111100010011" + "1111100101100000100001110001101011001111010110101000001110010100" + "1110111011000011110010010010111111001001010110011011010111010011" + "1011110001011110101100100110011010111110100001001010011101010110" + "1111111111111111111111111111111111111111111111111111111111111111" + "1010101010101010101010101010101010101010101010101010101010101010" + "1110111000110011111011100100010111000011100101011011101100010011" + "1110110010010110100100001110111010010110110001101111010100110000" + "1001001101100001111011100010000110011101011001111010001001111001" + "1010011111000110111100001110010010011010011010101000100111101000" + "1011111111010001100011010010011111110100000001111000101111110011" + "1011011011010000111100000011000010100000011010001100111100001100" + "1010100010001111100111010000110110101100110010011011101100010101" + "1010001000011110101101010000111011011001111110001100011011110010" + "1100100011011111101101110100101111011111010101011000011100100101" + "1110001110100110101011000111000011111100100000001001111000001110" + "1111011111010111111111110100001110110110001101011111010010010111" + "1111110000011000100110001110001010111110000000001010111101111100" + "1010101010110001100001110010110111111100001000011001001011101101" + "1000001101010100110010010110101010000000001010101100100011101010" + "1111111111111111111111111111111111111111111111111111111111111111" + }, + /* 44*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, -1, -1, -1, "\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\061\062\063\064\065\066", 0, 64, 64, 1, "250 BASE256s + 6 ASCII (3 double-digits)", + "1010101010101010101010101010101010101010101010101010101010101010" + "1000010100011101100000010111100110100010110111011011111010000001" + "1100011110111110100110111101111010101101000010001101001011001100" + "1110101100010111110011110010101111111101101111111000111010011111" + "1000100000010100101110100100010011101111110111101111000010011100" + "1100011100101001111000111100010110100000001000111000010111011111" + "1001010100111000110001000111000010000110010001101001010100110110" + "1110111000001001100110011110010110100111101011111101110000100001" + "1000111010111010101111110111010011110010010000101011111100100100" + "1110000111101011110100011110010111101001010010011010011100101111" + "1000000110110110101100000110101010111110101110001001100111001010" + "1011110011010011100100010101110110010111100011011011000101010001" + "1111000000110100100110001000001010110000101101001000110010011100" + "1100010111100011111010011010011110001011111110011001011110111101" + "1111011001000110110011110110010010011101001110101110100000101100" + "1111111111111111111111111111111111111111111111111111111111111111" + "1010101010101010101010101010101010101010101010101010101010101010" + "1110001011011001101110110011001111000100100101111110101111100101" + "1110110010110010111000100100011010010000000010101111111100111100" + "1101000010101101110111100001111110100100111100111100010100100111" + "1000100110010100110000111011001011101101110101001001100010111100" + "1111100101011001100001011010011111100110001111111010111110011111" + "1000001111111110110101011001100011101101000010101100111001110110" + "1111000000111101101111010011010111000001100001111110011100001001" + "1111010010101010100000011000001010001110111110101111111000000110" + "1011001001000111100000011010011110111101001101011101101101000001" + "1000010001100010101101001011010011100111000010101100000111001110" + "1111011010100001111100001110110111001001101010111000001101110001" + "1110100001010010100001011000100010001010110100101111101011111010" + "1111111110101101111011010111110111101000000011011100011010110011" + "1001110010110010111011001000101011011101000101001101001000111100" + "1111111111111111111111111111111111111111111111111111111111111111" + "1010101010101010101010101010101010101010101010101010101010101010" + "1101000101000011110110000010110111101001011000111010110010100001" + "1101111101111010110111110101100011001010101001101000101001101010" + "1011011101111111111111010000101111010010000101111010110001110011" + "1011011110000100101000101100100011101101110110001000100001011000" + "1000101100001001110001110111011111100100110001111010001000000011" + "1010100101101000110000011111111010100100111100001000101101101010" + "1100001101001011101001110000101111100100010010111110010000001011" + "1100000011000000110100100100100011000110000010101000010110110110" + "1001100111111111101100110100000110111000011000011100001111101111" + "1010100111101010101001000101001011100101100111001001001111010110" + "1100100101001111101001111111011111100001111110011101111100010111" + "1111100101100000100001110001101011001010100100101100010000010100" + "1110111011000011110010010010111111100100100001111100111010001101" + "1011110001011110101100100110010010101001010100101101000001110010" + "1111111111111111111111111111111111111111111111111111111111111111" + "1010101010101010101010101010101010101010101010101010101010101010" + "1110111000110011111011100100011111101101100100111111000011010011" + "1110110010010110100100001110010011101110010000001010101110001000" + "1001001101100001111011100010101111000101010111011100100110111001" + "1010011111000110111100001101100010111100111111101001010010101100" + "1011111111010001100011010010100111101001000010111010100101101111" + "1011011011010000111100001110110011011110010110101010011100011000" + "1010100010001111100111010011101110110010101101111101010110000111" + "1010001000011110101101100000011010001010000001001110110101111010" + "1100100011011111101101111000111110011111110000111101110101101101" + "1110001110100110101001011010011010100101010101101100001001011110" + "1111011111010111111101011100110110100100010110011100011100000111" + "1111110000011000101010001010011011001100101101101000111111001000" + "1011101010110001101111110010010111001010000001111001100011111101" + "1000001101010100111000010100101010000010001011101100100111101010" + "1111111111111111111111111111111111111111111111111111111111111111" + }, + /* 45*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, -1, -1, -1, "\101\102\103\104\105\106\107\110\111\112\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\061\062\063\064\065\066", 0, 64, 64, 1, "10 ASCII + 251 BASE256s + 6 ASCII", + "1010101010101010101010101010101010101010101010101010101010101010" + "1010011010011101100000010111100110100010110111011011111010000001" + "1011001010111110100110111101111010101101000010001101001011001100" + "1001100010010111110011110010101111111101101111111000111010011111" + "1010100001010100101110100100010011101111110111101111000010011100" + "1000001110101001111000111100010110100000001000111000010111011111" + "1100011000111000110001000111000010000110010001101001010100110100" + "1111100000001001100110011110010110100111101011111101110000100001" + "1110101010111010101111110111010011110010010000101011111100100110" + "1110100111101011110100011110010111101001010010011010011100101111" + "1100000110110110101100000110101010111110101110001001100111001010" + "1111110011010011100100010101110110010111100011011011000101010111" + "1111000000110100100110001000001010110000101101001000110010011110" + "1000010111100011111010011010011110001011111110011001011110100111" + "1111011001000110110011110110010010011101001110101110100000101000" + "1111111111111111111111111111111111111111111111111111111111111111" + "1010101010101010101010101010101010101010101010101010101010101010" + "1110001011011001101110110011001111000100100101111110101111000001" + "1110110010110010111000100100011010010000000010101111111100010100" + "1101000010101101110111100001111110100100111100111100010100011011" + "1000100110010100110000111011001011101101110101001001100011101110" + "1111100101011001100001011010011111100110001111111010110111111111" + "1000001111111110110101011001100011101101000010101100110011000110" + "1111000000111101101111010011010111000001100001111110000000101001" + "1111010010101010100000011000001010001110111110101111000001010010" + "1011001001000111100000011010011110111101001101011011010101100001" + "1000010001100010101101001011010011100111000010101000000000111110" + "1111011010100001111100001110110111001001101010111000100011100111" + "1110100001010010100001011000100010001010110100101010000001111100" + "1111111110101101111011010111110111101000000011111010000111001011" + "1001110010110010111011001000101011011101000101001100110000010100" + "1111111111111111111111111111111111111111111111111111111111111111" + "1010101010101010101010101010101010101010101010101010101010101010" + "1101000101000011110110000010110111101001011000111100010011010001" + "1101111101111010110111110101100011001110101011001010000000010110" + "1011011101111111111111010000101111011010000100111110111001010011" + "1011011110000100101000101100100011100111110011001111110100000000" + "1000101100001001110001110111011111000100110101111011010110000011" + "1010100101101000110000011111110010001100110000001001101010011010" + "1100001101001011101001110000100111000100100111111111011000011011" + "1100000011000000110100100100101011000111011101101001000000110110" + "1001100111111111101100110100101110111010010111011011011001111111" + "1010100111101010101001000101100011101100010100001111010110111110" + "1100100101001111101001111100011111101100001000111010011110100111" + "1111100101100000100001111100101011011100011111101010000100001100" + "1110111011000011110010010100111111001101110101011011101100110001" + "1011110001011110101100011110011011000000100000001111100001111110" + "1111111111111111111111111111111111111111111111111111111111111111" + "1010101010101010101010101010101010101010101010101010101010101010" + "1110111000110011111011101100010111001111000011011001011111010011" + "1110110010010110100100100110001010110011000011101001101000101000" + "1001001101100001111000000010010110101111101001011010001101010001" + "1010011111000110111001001100001010000000011111101000001111111100" + "1011111111010001100111010000111110111110101101111110101011100011" + "1011011011010000100000000000001011001011001110001000100100100000" + "1010100010001111101111011011100110010010101001111111100001101111" + "1010001000011010101101100001111010010101101111001101000111100100" + "1100100011010011101101101000000111010011100001011011101110111101" + "1110001110101100101010000000001011111110110100101001000111100110" + "1111011111100101111110011110011110100000010010011001010011111111" + "1111110010100000101110000101001011111010000011001100110100101100" + "1011101011110001110011111110010111100110000000011001001101100001" + "1001010101010100111010010100101010000010001011001100101011101010" + "1111111111111111111111111111111111111111111111111111111111111111" + }, + /* 46*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, -1, -1, -1, "\101\102\103\104\105\106\107\110\111\112\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\061\062\063\064\065\066\067\070\071\060\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\061\062\063\064\065\066", 0, 88, 88, 1, "10 ASCII + 252 BASE256s + 10 ASCII + 253 BASE256 + 6 ASCII", + "1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010" + "1010011010011100000001110111100010001011011111001111101000000110011111111000100110101111" + "1011001010111110011010111101111010110100001010010100101100110010101011111110101001100000" + "1001100010010111001111110010101111110110111111100011101001100100011100101011100101001111" + "1010100001010100111010100100010110111111011011111100001001111100101011000101111000110100" + "1000001110101001100011111100010010000000100110100001011101011010111111000101011110001111" + "1100011000111001000100100111000000011001000011100101010011011101001001110001001001110000" + "1111100100001000011001111110010010011110101111110111000000010000011111100000101111100001" + "1110101010111010111110110111010111001001000010101111110010010001101101110001010010011110" + "1110100111101011010001111110010110100101001110001001101011010100011111101100001000111101" + "1100000110110110110000100110101011111010111010000110011111101100001001111011110110101100" + "1111110011010010010001110101110001011110001111001101110110100100011101111010010101001111" + "1111000000110100011000101000001011000010110011000011011001100110001011000110010000100110" + "1000010111100011101001111010011000101111111110000010000000111010011010011110000010000111" + "1111011001000111001110110110010001110100111010111010000011110011101001000010011000110100" + "1110001011011000111011110011001100010010010111110010010110001111011011001010101101010101" + "1110110010110011100010100100011001000000001010111110110100111001101010111110011110101100" + "1101000010101101011111100001111010010011110110010110101011010001111010011100001111100001" + "1000100110010101000010111011001110110111010011000110000101010100001010101111100111010110" + "1111100101011000000101111010011110011000110111110001010110010000111110111110001110011111" + "1000001111111111010100111001100110110100001010110011111111100111001100010101010111010110" + "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" + "1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010" + "1111000000111100111101110011010100000111101110010000001111101101011100011101100011000001" + "1111010010101010000000111000001000111011110011111100101011100100001110001110101000011010" + "1011001001000110000001111010011011110011001110110010010011011000011100001000010010101101" + "1000010001100010110100101011010110011100001010000100011011111010101110101111000001010010" + "1111011010100001110001101110110100111110000111110110111111111101111010010011011011011001" + "1110100001010010000100111000100000101010010011101000000110011001001001110010111100111010" + "1111111110101101101101110111110110000101101111111110001001011001111111010011010100101011" + "1001110010110011101100101000101101110000010010011101100000111011001000000110100011000100" + "1101000101000011011001100010110100111011100111010101001000101100111100010010100111001001" + "1101111101111011011110110101100100111010011011011011101100110111001111111000010011111010" + "1011011101111111111101110000100110000001001110100111111111011001011010100101111100001011" + "1011011110000100100010101100101010011110010010100101100001110111001001010111001010000000" + "1000101100001001000111110110100000110110111110100101000000111101011011101000010010011011" + "1010100101101001000000111111111011010000110011101100111010001001001000101111110001101010" + "1100001101001010100111110110101000000101011110111001001000101110011101100011110100001011" + "1100000011000001010010100100101000011010001011011110110011100010001010111111100011110110" + "1001100111111110110011101101111010111010111110111001011001010010011001011111111001100111" + "1010100111101010100100100111010110000100010010100000101001010011101001100100000000001010" + "1100100101001110100101111101011101111100000111001111111001111110011100101010000001010011" + "1111100101100000000110111100010011111110100011011001010011111100101010100100101010010000" + "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" + "1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010" + "1110111011000011000011100110100001000011101111100100110001010001011000011011100111110001" + "1011110001011110110010111000010110101100000010111111100001100111101100111000101001100100" + "1110111000110011010011100100101011010111101111001001110010101000111110100000111110011011" + "1110110010010110010110111110000100011110100010011011010001100111101101000010111011100000" + "1001001101100111110101100101000110000101011110111011100001110110111001101000010000100001" + "1010011111000111111000101110000110010111100010010011100110100111001001010110010011000100" + "1011111111001001110101111101001010101000010111011000011111100111011000010010010100110111" + "1011011011010000010000110011001111000011100010000000001110111001101100010000011000110000" + "1010100011101100011011101011110011110011100110001111000000101000011110010010011010111011" + "1010001000011010111010110110001011000000110011011100000000100010001001100000110110001110" + "1100100001100110110001100001110101111011110111010000001110000011111000111000000000011101" + "1110001111000110110100101110001001101101101011011100011100011010001110000101100100100110" + "1111010000110111100101110001101010000100000110011110010110010001111011000100000111100111" + "1111110011000001111100101110001011010010001011101111011001001111001011100011001001110100" + "1010001100000001101001110011111010100010101111001101101010101110011011011111110001001001" + "1000010111011010100000100111100011110101100011111000111101011110101000010110011111001110" + "1011010111001100001111100100010111111100001110101000110101100001011111010100111000110101" + "1110110110110001011010111001011010001000011011010100110101001111101001100111110001010100" + "1111110001100101100011101101110100111110000111000000000000101001011111111011011110000111" + "1010001001101110110100110011000100001001011010111110010111000110001101010100100000101100" + "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" + "1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010" + "1000001000101010111111100010100100011111100111111001010000110111111110011011011110111011" + "1011111001101000001110100010111101010001001011011011100111011000101110111011010100011000" + "1111101000010101010011110011100100001101001110001011010000001000011000010111011000100001" + "1000111101011010101100110110101011111111110010011100110000100001101000110110001000101010" + "1011010110000010111111100101011010000011000111111101010000001001111101010101000111000101" + "1000010000110101101110110100000110110000101011001010111110101001101000010100010001000010" + "1111101100100000100111101110011111010101011110111101101010000000011001001011011011110101" + "1000101000110000000100100101001000011010011010101101100111101101101100111010010010011110" + "1000011101010100111111101011010111101000100110001100101100101000011010110111010010011011" + "1001110101110101001010101010100110010011100011101110011000110100001101000101101101110110" + "1110111110100110010111110110101110010100101111010011011000001100011010110111000001001001" + "1010110001101110011000100101010001110100011010110110100111110101001100000110010011001000" + "1110010001000010100001100001100011000001011111111010001110100010011100111001100100100001" + "1000100010000000110110110010011101011111000010001010111110101001101010000011000101010000" + "1100010110111111001001110000010001011010100110010111110001000011111100101101010000001001" + "1100111101111100100110111110111100111011011011110010110000001001101011011100110100100100" + "1010101101010111011011110011001001010101101111111011110110101011011001010111101011000111" + "1110001001100111001100101100111100010100100011110101011111010101001000101001111001111010" + "1001111110110111000111110010110001110001110111100111011110000010111010010101111110111001" + "1101010100110101110000110100001000100000101010010010101110100111001111100010001001001100" + "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" + }, + /* 47*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, -1, -1, -1, "\101\102\103\104\105\106\107\110\111\112\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\061\062\063\064\065\066\067\070\071\060\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200", 0, 88, 88, 1, "10 ASCII + 252 BASE256s + 10 ASCII + 304 BASE256, no padding", + "1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010" + "1010011010011100000001110111100010001011011111001111101000000110011111111000100110101111" + "1011001010111110011010111101111010110100001010010100101100110010101011111110101001100000" + "1001100010010111001111110010101111110110111111100011101001100100011100101011100101001111" + "1010100001010100111010100100010110111111011011111100001001111100101011000101111000110100" + "1000001110101001100011111100010010000000100110100001011101011010111111000101011110001111" + "1100011000111001000100100111000000011001000011100101010011011101001001110001001001110000" + "1111100100001000011001111110010010011110101111110111000000010000011111100000101111100001" + "1110101010111010111110110111010111001001000010101111110010010001101101110001010010011110" + "1110100111101011010001111110010110100101001110001001101011010100011111101100001000111101" + "1100000110110110110000100110101011111010111010000110011111101100001001111011110110101100" + "1111110011010010010001110101110001011110001111001101110110100100011101111010010101001111" + "1111000000110100011000101000001011000010110011000011011001100110001011000110010000100110" + "1000010111100011101001111010011000101111111110000010000000111010011010011110000010010111" + "1111011001000111001110110110010001110100111010111010000011110011101001000010011000111000" + "1110001011011000111011110011001100010010010111110010010110001111011011001010101100001001" + "1110110010110011100010100100011001000000001010111110110100111001101010111110011110110100" + "1101000010101101011111100001111010010011110110010110101011010001111010011100001101000001" + "1000100110010101000010111011001110110111010011000110000101010100001010101111100000111110" + "1111100101011000000101111010011110011000110111110001010110010000111110111110011111011111" + "1000001111111111010100111001100110110100001010110011111111100111001100010101011001101110" + "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" + "1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010" + "1111000000111100111101110011010100000111101110010000001111101101011100011100100111001001" + "1111010010101010000000111000001000111011110011111100101011100100001110001110110001001110" + "1011001001000110000001111010011011110011001110110010010011011000011100001110110011111001" + "1000010001100010110100101011010110011100001010000100011011111010101110101000100001100110" + "1111011010100001110001101110110100111110000111110110111111111101111010000110011011011111" + "1110100001010010000100111000100000101010010011101000000110011001001001111000110000001010" + "1111111110101101101101110111110110000101101111111110001001011001111111000011011101111011" + "1001110010110011101100101000101101110000010010011101100000111011001000111101111101001100" + "1101000101000011011001100010110100111011100111010101001000101100111000110010101011010001" + "1101111101111011011110110101100100111010011011011011101100110111001000010011100100011010" + "1011011101111111111101110000100110000001001110100111111111011000111101011111111010010111" + "1011011110000100100010101100101010011110010010100101100001110111001111110101011010110000" + "1000101100001001000111110110100000110110111110100101000000111111111111001001000011000101" + "1010100101101001000000111111111011010000110011101100111010001011101010000101111001101100" + "1100001101001010100111110110101000000101011110111001001000101010011011001011001111101011" + "1100000011000001010010100100101000011010001011011110110011100000001101100001100011010110" + "1001100111111110110011101101111010111010111110111001011001010001111101011110100111001111" + "1010100111101010100100100111010110000100010010100000101001011011101000011100010100100110" + "1100100101001110100101111101011101111100000111001111111001111101011101010000100010110011" + "1111100101100000000110111100010011111110100011011001010011011011101100000001010000110000" + "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" + "1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010" + "1110111011000011000011100110100001000011101111100100110001001110011000000001000001111101" + "1011110001011110110010111000010110101100000010111111100011010000001100111010011101011110" + "1110111000110011010011100100101011010111101111001001110010000000011111110111111010000011" + "1110110010010110010110111110000100011110100010011011010100011000101110110101100000000000" + "1001001101100111110101100101000110000101011110111011101100001010011110111100001101010001" + "1010011111000111001000101110000110010111100010010011001010101100001010000101101001101000" + "1011111111001001100101111101001010101000010111011000001001000001111101001011000001000011" + "1011011011010000101000110011001111000011100010000010011011111110001000111101000110010100" + "1010100011101100011011101011110011110011100110001110000000111111111011101011111111101111" + "1010001000011010111010110110001011000000110011010000101011000001001010100000101011100010" + "1100100001100110110001100001110101111011110111011101100000010010011001011001111001001101" + "1110001111000110110100101110001001101101101011111101111000110001001001100000100000001110" + "1111010000110111100101110001101010000100000110001101010110100010111100100101011100011111" + "1111110011000001111100101110001011010010000011100001110011100110001000000101100010100100" + "1010001100000001101001110011111010100010101110010111111000110101011100110010101111100001" + "1000010111011010100000100111100011110101110010110110000110001100101101001111000001111010" + "1011010111001100001111100100010111111100110110100000011010110110111110100011100110010011" + "1110110110110001011010111001011010001010111010001010101001110100101010110101100011110000" + "1111110001100101100011101101110100111100101110111011010111011110111010101011110011010111" + "1010001001101110110100110011000100000010110010011110011101101001001101001001010011000100" + "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" + "1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010" + "1000001000101010111111100010100100011001111111000011111100010010111110000100000100101011" + "1011111001101000001110100010111101100101011011010001000100111101101100101010001011101100" + "1111101000010101010011110011100100111000101110000011000001010011111011000110101100110101" + "1000111101011010101100110110101001000010101010001010111111110101001010001001001010010110" + "1011010110000010111111100101011000101001010110001101010110100000111110110000111101110001" + "1000010000110101101110110100001110111101001011010010000111011111101111011101001000100110" + "1111101100100000100111101110011001101110101110100001011100101001011110010100111111100101" + "1000101000110000000100100101010111001110010010011011001010001000101000100100100101001110" + "1000011101010100111111101011111011101010110111111110000000111001111100011101100110100011" + "1001110101110101001010101000000010000010110011100010010000111011101111111100101110011110" + "1110111110100110010111110100110000100101000110001000000010101101111010000001011110010001" + "1010110001101110011000101011011111001111011010011011011000010100001011100101011010111100" + "1110010001000010100001101000001111111101000110101000001000010010011001110111101011100011" + "1000100010000000110100101001001001000100110010110000000001011100001001100001000110001110" + "1100010110111111001011111101011101110010100110111111010100001010111100011011100011100001" + "1100111101111100101100101010011100111101001010011110000111110011101100100000001011011100" + "1010101101010111010011111000011100100011011110011011010001011000111010101000010111010111" + "1110001001100111011110111101000101001011000011100101001111000111101100100000000000011110" + "1001111110110111100111101011110100110001000110000111011111101000111100001101011010100001" + "1101010100110101100000110110001000001000101011110010001110100101001111000010001111001100" + "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" + }, + /* 48*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, "@@@@@@@@@_", 0, 8, 32, 0, "EDI; BWIPP uses different encodation, switching to ASC for last 2 chars, not last 3 like Zint", + "10101010101010101010101010101010" + "10000000001001111001101100001101" + "10000000000001001001110011001100" + "10000000000110011111100101100001" + "11000000110101101100001101111000" + "11000001110100111000111101101011" + "11000000000000001001000001011010" + "11111111111111111111111111111111" + }, + /* 49*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, "@@@@@@@@@@_", 0, 16, 16, 0, "EDI; BWIPP uses different encodation, switching to ASC for last 3 chars, not last 4 like Zint", + "1010101010101010" + "1000000001000001" + "1000000000111110" + "1000000100010001" + "1000000000101110" + "1000001001110111" + "1000010001010110" + "1110100011110001" + "1110001110011000" + "1010010110010101" + "1000111010010110" + "1001011001000001" + "1000110101100010" + "1110100110001101" + "1010100000010010" + "1111111111111111" + }, + /* 50*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, "@@@@@@@@@@@_", 0, 16, 16, 0, "EDI; BWIPP uses different encodation, switching to ASC for last 4 chars, not last 5 like Zint", + "1010101010101010" + "1000000000100001" + "1000000000001010" + "1000000010001001" + "1000000100001000" + "1000001000110111" + "1000000011101110" + "1110100111100001" + "1110000111010100" + "1010011001111101" + "1000000000000110" + "1001010011101111" + "1010000011111000" + "1101100111110101" + "1001100000100010" + "1111111111111111" + }, + /* 51*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, "@@@@@@@@@@@@_", 0, 16, 16, 0, "EDI; BWIPP uses same encodation for this case, switching to ASC for last 5 chars, not last 2 like Zint", + "1010101010101010" + "1000000000100001" + "1000000000111000" + "1000000010111001" + "1000000100100100" + "1000001000100111" + "1000000011111110" + "1000000110111001" + "1000110010010100" + "1001111110000101" + "1000000010010000" + "1000101101011001" + "1001010001011110" + "1000000111000101" + "1011100000010010" + "1111111111111111" + }, + /* 52*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, "@@@@@@@@@@@@@_", 0, 12, 26, 0, "EDI; BWIPP uses different encodation, switching to ASC for last 2 chars, not last 3 like Zint", + "10101010101010101010101010" + "10000000001001100100101011" + "10000000000010000000111000" + "10000000000100011100111111" + "10000000110100111100011110" + "10000001110100100011100001" + "10000000111110000011001100" + "10000000101110100110101101" + "10000000101010000110010000" + "10000010101001111100101001" + "10000001000001101011010000" + "11111111111111111111111111" + }, + /* 53*/ { BARCODE_DATAMATRIX, -1, 26, -1, -1, -1, "abcdefghi1234FGHIJKLMNabc@@@@@@@@@é", 0, 24, 24, 0, "Mix of modes TEX ASC C40 ASC EDI BAS; BWIPP uses different encodation for EDI as above", + "101010101010101010101010" + "100111011110011100100101" + "101111001100101100001100" + "101110110110001010011011" + "100100110000101000010110" + "111011010011000001000111" + "101010011000101111100110" + "100111101000011110110001" + "100111010000000001111100" + "101110101000001010011011" + "101111100000000100111110" + "111111100000101101010001" + "100111000000111111101100" + "101000000001011001011101" + "110100000001101010011000" + "100000001000001001110001" + "111000011110010010110100" + "111000110011110110101011" + "111011010100011100100000" + "100010010011101010000101" + "100010001010001100011100" + "110011110000001011001101" + "110111010101111111011010" + "111111111111111111111111" }, }; int data_size = ARRAY_SIZE(data); - char escaped[1024]; - char bwipp_buf[8192]; + char escaped[8192]; + char bwipp_buf[32768]; char bwipp_msg[1024]; for (int i = 0; i < data_size; i++) { @@ -1039,10 +2062,10 @@ static void test_encode(int index, int generate, int debug) { i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), data[i].eci, testUtilOutputOptionsName(data[i].output_options), data[i].option_2, testUtilOption3Name(data[i].option_3), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].comment); - testUtilModulesDump(symbol, " ", "\n"); + testUtilModulesPrint(symbol, " ", "\n"); printf(" },\n"); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data); @@ -1071,6 +2094,108 @@ static void test_encode(int index, int generate, int debug) { testFinish(); } +#include + +#define TEST_PERF_ITERATIONS 1000 + +// Not a real test, just performance indicator +static void test_perf(int index, int debug) { + + if (!(debug & ZINT_DEBUG_TEST_PERFORMANCE)) { /* -d 256 */ + return; + } + + int ret; + struct item { + int symbology; + int input_mode; + int option_1; + int option_2; + char *data; + int ret; + + int expected_rows; + int expected_width; + char *comment; + }; + struct item data[] = { + /* 0*/ { BARCODE_DATAMATRIX, -1, -1, -1, + "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz&,:#-.$/+%*=^ABCDEFGHIJKLMNOPQRSTUVWXYZ12345678901234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLM" + "NOPQRSTUVWXYZ;<>@[]_`~!||()?{}'123456789012345678901234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJK" + "LMNOPQRSTUVWXYZ12345678912345678912345678912345678900001234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFG" + "HIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ12345678901234567" + "890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcde" + "fghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNO", + 0, 96, 96, "960 chars, text/numeric" }, + /* 1*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, -1, + "\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240" + "\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240" + "\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240" + "\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240" + "\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240" + "\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240" + "\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240" + "\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240" + "\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240" + "\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240" + "\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240" + "\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240" + "\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240" + "\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240" + "\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240" + "\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240" + "\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240" + "\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240" + "\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240" + "\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240" + "\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240" + "\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240" + "\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240" + "\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240", + 0, 120, 120, "960 chars, byte" }, + }; + int data_size = ARRAY_SIZE(data); + + clock_t start, total_encode = 0, total_buffer = 0, diff_encode, diff_buffer; + + for (int i = 0; i < data_size; i++) { + + if (index != -1 && i != index) continue; + + diff_encode = diff_buffer = 0; + + for (int j = 0; j < TEST_PERF_ITERATIONS; j++) { + struct zint_symbol *symbol = ZBarcode_Create(); + assert_nonnull(symbol, "Symbol not created\n"); + + int length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, data[i].option_1, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug); + + start = clock(); + ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); + diff_encode += clock() - start; + assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode 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 (%s)\n", 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); + + start = clock(); + ret = ZBarcode_Buffer(symbol, 0 /*rotate_angle*/); + diff_buffer += clock() - start; + assert_zero(ret, "i:%d ZBarcode_Buffer ret %d != 0 (%s)\n", i, ret, symbol->errtxt); + + ZBarcode_Delete(symbol); + } + + printf("%s: diff_encode %gms, diff_buffer %gms\n", data[i].comment, diff_encode * 1000.0 / CLOCKS_PER_SEC, diff_buffer * 1000.0 / CLOCKS_PER_SEC); + + total_encode += diff_encode; + total_buffer += diff_buffer; + } + if (index != -1) { + printf("totals: encode %gms, buffer %gms\n", total_encode * 1000.0 / CLOCKS_PER_SEC, total_buffer * 1000.0 / CLOCKS_PER_SEC); + } +} + int main(int argc, char *argv[]) { testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */ @@ -1080,6 +2205,7 @@ int main(int argc, char *argv[]) { { "test_reader_init", test_reader_init, 1, 1, 1 }, { "test_input", test_input, 1, 1, 1 }, { "test_encode", test_encode, 1, 1, 1 }, + { "test_perf", test_perf, 1, 0, 1 }, }; testRun(argc, argv, funcs, ARRAY_SIZE(funcs)); diff --git a/backend/tests/test_dotcode.c b/backend/tests/test_dotcode.c index bebe5a9f..ff21caac 100644 --- a/backend/tests/test_dotcode.c +++ b/backend/tests/test_dotcode.c @@ -650,7 +650,7 @@ static void test_encode(int index, int generate, int debug) { i, testUtilInputModeName(data[i].input_mode), data[i].option_2, testUtilOption3Name(data[i].option_3), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length, testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].comment); - testUtilModulesDump(symbol, " ", "\n"); + testUtilModulesPrint(symbol, " ", "\n"); printf(" },\n"); } else { if (ret < ZINT_ERROR) { diff --git a/backend/tests/test_gridmtx.c b/backend/tests/test_gridmtx.c index c5dc140c..f5c1f03e 100644 --- a/backend/tests/test_gridmtx.c +++ b/backend/tests/test_gridmtx.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2008-2021 Robin Stuart + Copyright (C) 2019-2021 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -71,7 +71,7 @@ static void test_large(int index, int debug) { ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, 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 < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); } @@ -269,9 +269,9 @@ static void test_input(int index, int generate, int debug) { printf(" /*%3d*/ { %s, %d, %s, \"%s\", %s, %d, \"%s\", \"%s\" },\n", i, testUtilInputModeName(data[i].input_mode), data[i].eci, testUtilOption3Name(data[i].option_3), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), - testUtilErrorName(data[i].ret), ret < 5 ? symbol->eci : -1, symbol->errtxt, data[i].comment); + testUtilErrorName(data[i].ret), ret < ZINT_ERROR ? symbol->eci : -1, symbol->errtxt, data[i].comment); } else { - if (ret < 5) { + 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); assert_zero(strcmp((char *) symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); @@ -417,10 +417,10 @@ static void test_encode(int index, int generate, int debug) { printf(" /*%3d*/ { \"%s\", %s, %d, %d, %s, %d, %d, \"%s\",\n", i, data[i].data, testUtilInputModeName(data[i].input_mode), data[i].option_1, data[i].option_2, testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment); - testUtilModulesDump(symbol, " ", "\n"); + testUtilModulesPrint(symbol, " ", "\n"); printf(" },\n"); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data); diff --git a/backend/tests/test_gs1.c b/backend/tests/test_gs1.c index c41dcfe1..ca515ee5 100644 --- a/backend/tests/test_gs1.c +++ b/backend/tests/test_gs1.c @@ -179,19 +179,13 @@ static void test_gs1_reduce(int index, int generate, int debug) { struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - symbol->symbology = data[i].symbology; - if (data[i].input_mode != -1) { - symbol->input_mode = data[i].input_mode; - } - symbol->debug |= debug; - if (strlen(data[i].composite)) { text = data[i].composite; strcpy(symbol->primary, data[i].data); } else { text = data[i].data; } - int length = strlen(text); + int length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, text, -1, debug); ret = ZBarcode_Encode(symbol, (unsigned char *) text, length); @@ -199,7 +193,7 @@ static void test_gs1_reduce(int index, int generate, int debug) { if (data[i].ret == 0) { printf(" /*%2d*/ { %s, %s, \"%s\", \"%s\", %d, \"%s\",\n", i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), data[i].data, data[i].composite, data[i].ret, data[i].comment); - testUtilModulesDump(symbol, " ", "\n"); + testUtilModulesPrint(symbol, " ", "\n"); printf(" },\n"); } else { printf(" /*%2d*/ { %s, %s, \"%s\", \"%s\", %s, \"%s\", \"\" },\n", @@ -208,7 +202,7 @@ static void test_gs1_reduce(int index, int generate, int debug) { } else { assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d %s\n", i, ret, data[i].ret, symbol->errtxt); - if (ret < 5) { + if (ret < ZINT_ERROR) { int width, row; ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row); assert_zero(ret, "i:%d %s testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), ret, width, row, data[i].data); @@ -271,16 +265,13 @@ static void test_hrt(int index, int debug) { struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - symbol->symbology = data[i].symbology; - symbol->debug |= debug; - if (strlen(data[i].composite)) { text = data[i].composite; strcpy(symbol->primary, data[i].data); } else { text = data[i].data; } - int length = strlen(text); + int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, text, -1, debug); ret = ZBarcode_Encode(symbol, (unsigned char *) text, length); assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, data[i].ret, ret, symbol->errtxt); @@ -1781,20 +1772,13 @@ static void test_input_mode(int index, int debug) { struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - symbol->symbology = data[i].symbology; - symbol->input_mode = data[i].input_mode; - if (data[i].output_options != -1) { - symbol->output_options = data[i].output_options; - } - symbol->debug |= debug; - if (strlen(data[i].composite)) { text = data[i].composite; strcpy(symbol->primary, data[i].data); } else { text = data[i].data; } - int length = strlen(text); + int length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, data[i].output_options, text, -1, debug); ret = ZBarcode_Encode(symbol, (unsigned char *) text, length); assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d %s\n", i, ret, data[i].ret, symbol->errtxt); diff --git a/backend/tests/test_hanxin.c b/backend/tests/test_hanxin.c index cbb4da1f..23b875e5 100644 --- a/backend/tests/test_hanxin.c +++ b/backend/tests/test_hanxin.c @@ -71,7 +71,7 @@ static void test_large(int index, int debug) { ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, 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 < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); } @@ -265,9 +265,9 @@ static void test_input(int index, int generate, int debug) { printf(" /*%3d*/ { %s, %d, %s, \"%s\", %d, %s, %d, \"%s\", \"%s\" },\n", i, testUtilInputModeName(data[i].input_mode), data[i].eci, testUtilOption3Name(data[i].option_3), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length, - testUtilErrorName(data[i].ret), ret < 5 ? symbol->eci : -1, symbol->errtxt, data[i].comment); + testUtilErrorName(data[i].ret), ret < ZINT_ERROR ? symbol->eci : -1, symbol->errtxt, data[i].comment); } else { - if (ret < 5) { + 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); assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); } @@ -1467,10 +1467,10 @@ static void test_encode(int index, int generate, int debug) { i, testUtilInputModeName(data[i].input_mode), data[i].option_1, data[i].option_2, testUtilOption3Name(data[i].option_3), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment); - testUtilModulesDump(symbol, " ", "\n"); + testUtilModulesPrint(symbol, " ", "\n"); printf(" },\n"); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data); diff --git a/backend/tests/test_imail.c b/backend/tests/test_imail.c index fb501e25..231f76da 100644 --- a/backend/tests/test_imail.c +++ b/backend/tests/test_imail.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2019 - 2020 Robin Stuart + Copyright (C) 2019 - 2021 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -200,7 +200,7 @@ static void test_input(int index, int debug) { ret = ZBarcode_Encode(symbol, (unsigned char *) 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 < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); } @@ -256,10 +256,10 @@ static void test_encode(int index, int generate, int debug) { printf(" /*%3d*/ { \"%s\", %s, %d, %d, \"%s\",\n", i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment); - testUtilModulesDump(symbol, " ", "\n"); + testUtilModulesPrint(symbol, " ", "\n"); printf(" },\n"); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data); diff --git a/backend/tests/test_library.c b/backend/tests/test_library.c index 3a1f193b..d7885234 100644 --- a/backend/tests/test_library.c +++ b/backend/tests/test_library.c @@ -197,7 +197,7 @@ static void test_escape_char_process(int index, int generate, int debug) { char *comment; }; struct item data[] = { - /* 0*/ { DATA_MODE, -1, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\e\\G\\R\\x81\\\\", 0, 26, "01 05 08 09 0A 0B 0C 0D E7 DE 7B 1F B6 4D 45 B6 E6 78 98 0D 54 2E 58 21 AE 22 2B 3E 8B 22", 0, "" }, + /* 0*/ { DATA_MODE, -1, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\e\\G\\R\\x81\\\\", 0, 26, "01 05 08 09 0A 0B 0C 0D E7 D8 7B 1F B6 4D 45 B6 45 7C EF DD 8C 4C 8D 1E D0 55 AD FE A8 52", 0, "" }, /* 1*/ { DATA_MODE, -1, "\\c", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character in input data", 0, "" }, /* 2*/ { DATA_MODE, -1, "\\", ZINT_ERROR_INVALID_DATA, 0, "Error 236: Incomplete escape character in input data", 0, "" }, /* 3*/ { DATA_MODE, -1, "\\x", ZINT_ERROR_INVALID_DATA, 0, "Error 232: Incomplete escape character in input data", 0, "" }, diff --git a/backend/tests/test_mailmark.c b/backend/tests/test_mailmark.c index 5e509bcb..a09c4a5f 100644 --- a/backend/tests/test_mailmark.c +++ b/backend/tests/test_mailmark.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2019 - 2020 Robin Stuart + Copyright (C) 2019 - 2021 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -113,7 +113,7 @@ static void test_input(int index, int debug) { ret = ZBarcode_Encode(symbol, (unsigned char *) 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 < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); } @@ -164,7 +164,7 @@ static void test_encode_vector(int index, int debug) { /* 18*/ { "31833333333333333C12JQ3U ", 0, 100, 30, 0, "DTTAFFDATATFAADAFDFATFFTFFTTTADTTTDTAAATDDTFFDDFTAADTTDTFFFDAFTFAADFDDAFDFTAFF" }, // F N N L L N L S S /* 19*/ { "22799999999999999C123JQ4U ", 0, 100, 30, 0, "DDATTDDATATTTAFDTAADATDDFFTFFDFFDTFAADDFAADFDFFTFFTFFDFDFTATATFDDFTFFFTFFTDDTF" }, // F N N N L L N L S }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); char actual_daft[80]; @@ -175,10 +175,7 @@ static void test_encode_vector(int index, int debug) { struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - symbol->symbology = BARCODE_MAILMARK; - symbol->debug |= debug; - - int length = strlen(data[i].data); + int length = testUtilSetSymbol(symbol, BARCODE_MAILMARK, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug); ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); assert_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret_encode, symbol->errtxt); @@ -239,10 +236,10 @@ static void test_encode(int index, int generate, int debug) { printf(" /*%3d*/ { \"%s\", %s, %d, %d, \"%s\",\n", i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment); - testUtilModulesDump(symbol, " ", "\n"); + testUtilModulesPrint(symbol, " ", "\n"); printf(" },\n"); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data); diff --git a/backend/tests/test_maxicode.c b/backend/tests/test_maxicode.c index 669e1dc2..831dd065 100644 --- a/backend/tests/test_maxicode.c +++ b/backend/tests/test_maxicode.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2019 - 2020 Robin Stuart + Copyright (C) 2019 - 2021 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -101,7 +101,7 @@ static void test_large(int index, int debug) { ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, 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 < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); } @@ -166,7 +166,7 @@ static void test_input(int index, int generate, int debug) { /* 32*/ { UNICODE_MODE, 32768, -1, -1, "A", -1, "", 0, 30, "(144) 04 1B 38 08 00 00 01 21 21 21 10 30 3A 04 26 23 0E 21 3D 0F 21 21 21 21 21 21 21 21", "" }, /* 33*/ { UNICODE_MODE, -1, 1, -1, "A", -1, "", ZINT_ERROR_INVALID_OPTION, 0, "Error 550: Invalid MaxiCode Mode", "" }, }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); char escaped[1024]; @@ -191,7 +191,7 @@ static void test_input(int index, int generate, int debug) { testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length, data[i].primary, testUtilErrorName(data[i].ret), symbol->width, symbol->errtxt, data[i].comment); } else { - if (ret < 5) { + 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_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); @@ -560,10 +560,10 @@ static void test_encode(int index, int generate, int debug) { printf(" /*%3d*/ { %s, %d, %d, \"%s\", %d, \"%s\", %s, %d, %d, \"%s\",\n", i, testUtilInputModeName(data[i].input_mode), data[i].option_1, data[i].option_2, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length, data[i].primary, testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment); - testUtilModulesDump(symbol, " ", "\n"); + testUtilModulesPrint(symbol, " ", "\n"); printf(" },\n"); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data); @@ -633,7 +633,7 @@ static void test_best_supported_set(int index, int generate, int debug) { "010100101001110111101010110010" }, }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); char escaped_data[1024]; @@ -644,10 +644,7 @@ static void test_best_supported_set(int index, int generate, int debug) { struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - symbol->symbology = BARCODE_MAXICODE; - symbol->debug |= debug; - - int length = strlen(data[i].data); + int length = testUtilSetSymbol(symbol, BARCODE_MAXICODE, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug); ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret); @@ -656,7 +653,7 @@ static void test_best_supported_set(int index, int generate, int debug) { printf(" /*%2d*/ { \"%s\", %d, %.0f, %.0f, %d, %d, %d, \"%s\",\n", i, testUtilEscape(data[i].data, length, escaped_data, sizeof(escaped_data)), ret, data[i].w, data[i].h, data[i].ret_vector, symbol->rows, symbol->width, data[i].comment); - testUtilModulesDump(symbol, " ", "\n"); + testUtilModulesPrint(symbol, " ", "\n"); printf(" },\n"); } else { assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows); @@ -696,7 +693,7 @@ static void test_fuzz(int index, int debug) { /* 3*/ { -1, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", -1, ZINT_ERROR_TOO_LONG }, /* 4*/ { 32768, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678", -1, ZINT_ERROR_TOO_LONG }, }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); for (int i = 0; i < data_size; i++) { diff --git a/backend/tests/test_medical.c b/backend/tests/test_medical.c index 36cdc056..d3fc94fc 100644 --- a/backend/tests/test_medical.c +++ b/backend/tests/test_medical.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2020 Robin Stuart + Copyright (C) 2020 - 2021 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -77,7 +77,7 @@ static void test_large(int index, int debug) { ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, 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 < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); } @@ -187,7 +187,7 @@ static void test_input(int index, int debug) { ret = ZBarcode_Encode(symbol, (unsigned char *) 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 < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); } @@ -272,10 +272,10 @@ static void test_encode(int index, int generate, int debug) { 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)), testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment); - testUtilModulesDump(symbol, " ", "\n"); + testUtilModulesPrint(symbol, " ", "\n"); printf(" },\n"); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data); diff --git a/backend/tests/test_pdf417.c b/backend/tests/test_pdf417.c index be18a12b..750eedd1 100644 --- a/backend/tests/test_pdf417.c +++ b/backend/tests/test_pdf417.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2019 - 2020 Robin Stuart + Copyright (C) 2019 - 2021 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -67,7 +67,7 @@ static void test_options(int index, int debug) { /* 11*/ { BARCODE_MICROPDF417, -1, 5, -1, "12345", ZINT_WARN_INVALID_OPTION, 0, -1, 1, 11, 38, -1 }, // Invalid cols, auto-set to 1 /* 12*/ { BARCODE_MICROPDF417, -1, 1, -1, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM", ZINT_WARN_INVALID_OPTION, 0, -1, 2, 17, 55, -1 }, // Cols 1 too small, auto-upped to 2 with warning }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); struct zint_symbol previous_symbol; @@ -83,16 +83,16 @@ static void test_options(int index, int debug) { ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); assert_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret_encode, symbol->errtxt); - assert_equal(symbol->option_1, data[i].expected_option_1, "i:%d symbol->option_1 %d != %d (%d) (%s)\n", i, symbol->option_1, data[i].expected_option_1, data[i].option_1, symbol->errtxt); - assert_equal(symbol->option_2, data[i].expected_option_2, "i:%d symbol->option_2 %d != %d (%d) (%s)\n", i, symbol->option_2, data[i].expected_option_2, data[i].option_2, symbol->errtxt); - if (data[i].option_3 != -1) { - assert_equal(symbol->option_3, data[i].option_3, "i:%d symbol->option_3 %d != %d\n", i, symbol->option_3, data[i].option_3); // Unchanged - } else { - assert_zero(symbol->option_3, "i:%d symbol->option_3 %d != 0\n", i, symbol->option_3); - } + assert_equal(symbol->option_1, data[i].expected_option_1, "i:%d symbol->option_1 %d != %d (%d) (%s)\n", i, symbol->option_1, data[i].expected_option_1, data[i].option_1, symbol->errtxt); + assert_equal(symbol->option_2, data[i].expected_option_2, "i:%d symbol->option_2 %d != %d (%d) (%s)\n", i, symbol->option_2, data[i].expected_option_2, data[i].option_2, symbol->errtxt); + if (data[i].option_3 != -1) { + assert_equal(symbol->option_3, data[i].option_3, "i:%d symbol->option_3 %d != %d\n", i, symbol->option_3, data[i].option_3); // Unchanged + } else { + assert_zero(symbol->option_3, "i:%d symbol->option_3 %d != 0\n", i, symbol->option_3); + } - assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, symbol->errtxt); - assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, symbol->errtxt); + assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, symbol->errtxt); + assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, symbol->errtxt); if (index == -1 && data[i].compare_previous != -1) { ret = testUtilSymbolCmp(symbol, &previous_symbol); @@ -155,7 +155,7 @@ static void test_reader_init(int index, int generate, int debug) { testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->rows, symbol->width, symbol->errtxt, data[i].comment); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { 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->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); @@ -240,7 +240,7 @@ static void test_input(int index, int generate, int debug) { testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->eci, symbol->rows, symbol->width, symbol->errtxt, data[i].comment); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { assert_equal(symbol->eci, data[i].expected_eci, "i:%d symbol->eci %d != %d (%s)\n", i, symbol->eci, data[i].expected_eci, data[i].data); 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->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data); @@ -718,7 +718,7 @@ static void test_encode(int index, int generate, int debug) { "11101101001101001001111100011101101001" }, }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); char escaped[1024]; char bwipp_buf[8192]; @@ -741,10 +741,10 @@ static void test_encode(int index, int generate, int debug) { i, testUtilBarcodeName(data[i].symbology), data[i].eci, testUtilInputModeName(data[i].input_mode), 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); - testUtilModulesDump(symbol, " ", "\n"); + testUtilModulesPrint(symbol, " ", "\n"); printf(" },\n"); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data); @@ -1042,7 +1042,7 @@ static void test_fuzz(int index, int debug) { "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQ", 251, -1, ZINT_ERROR_TOO_LONG }, }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); for (int i = 0; i < data_size; i++) { @@ -1073,6 +1073,8 @@ static void test_fuzz(int index, int debug) { #include +#define TEST_PERF_ITERATIONS 1000 + // Not a real test, just performance indicator static void test_perf(int index, int debug) { @@ -1139,7 +1141,7 @@ static void test_perf(int index, int debug) { diff_encode = diff_buffer = 0; - for (int j = 0; j < 1000; j++) { + for (int j = 0; j < TEST_PERF_ITERATIONS; j++) { struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); diff --git a/backend/tests/test_plessey.c b/backend/tests/test_plessey.c index e981a26b..2bfdf9eb 100644 --- a/backend/tests/test_plessey.c +++ b/backend/tests/test_plessey.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2020 Robin Stuart + Copyright (C) 2020 - 2021 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -79,7 +79,7 @@ static void test_large(int index, int debug) { ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, 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 < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); } @@ -174,7 +174,7 @@ static void test_input(int index, int debug) { ret = ZBarcode_Encode(symbol, (unsigned char *) 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 < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); } @@ -254,10 +254,10 @@ static void test_encode(int index, int generate, int debug) { 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)), testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment); - testUtilModulesDump(symbol, " ", "\n"); + testUtilModulesPrint(symbol, " ", "\n"); printf(" },\n"); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data); diff --git a/backend/tests/test_postal.c b/backend/tests/test_postal.c index e766cf33..177a4701 100644 --- a/backend/tests/test_postal.c +++ b/backend/tests/test_postal.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2019 - 2020 Robin Stuart + Copyright (C) 2019 - 2021 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -88,7 +88,7 @@ static void test_large(int index, int debug) { ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, 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 < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); } @@ -116,7 +116,7 @@ static void test_koreapost(int index, int debug) { struct item data[] = { /* 0*/ { "123456", 0, 0, 50, 1, 167 }, }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); for (int i = 0; i < data_size; i++) { @@ -125,15 +125,12 @@ static void test_koreapost(int index, int debug) { struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - symbol->symbology = BARCODE_KOREAPOST; - symbol->debug |= debug; - - int length = strlen(data[i].data); + int length = testUtilSetSymbol(symbol, BARCODE_KOREAPOST, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug); ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); assert_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret_encode); - if (data[i].ret_vector != -1) { + if (ret < ZINT_ERROR) { assert_equal(symbol->height, data[i].expected_height, "i:%d symbol->height %d != %d\n", i, symbol->height, data[i].expected_height); 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->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); @@ -168,7 +165,7 @@ static void test_japanpost(int index, int debug) { /* 1*/ { "123456-AB", 0, 0, 8, 3, 133, "Check 10" }, /* 2*/ { "123456", 0, 0, 8, 3, 133, "Check 11" }, }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); for (int i = 0; i < data_size; i++) { @@ -177,15 +174,12 @@ static void test_japanpost(int index, int debug) { struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - symbol->symbology = BARCODE_JAPANPOST; - symbol->debug |= debug; - - int length = strlen(data[i].data); + int length = testUtilSetSymbol(symbol, BARCODE_JAPANPOST, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug); ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); assert_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret_encode); - if (data[i].ret_vector != -1) { + if (ret < ZINT_ERROR) { assert_equal(symbol->height, data[i].expected_height, "i:%d symbol->height %d != %d\n", i, symbol->height, data[i].expected_height); 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->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); @@ -264,7 +258,7 @@ static void test_input(int index, int debug) { ret = ZBarcode_Encode(symbol, (unsigned char *) 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 < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); } @@ -395,10 +389,10 @@ static void test_encode(int index, int generate, int debug) { printf(" /*%3d*/ { %s, \"%s\", %s, %d, %d, \"%s\",\n", i, testUtilBarcodeName(data[i].symbology), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment); - testUtilModulesDump(symbol, " ", "\n"); + testUtilModulesPrint(symbol, " ", "\n"); printf(" },\n"); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data); diff --git a/backend/tests/test_qr.c b/backend/tests/test_qr.c index 1befaec3..047010d7 100644 --- a/backend/tests/test_qr.c +++ b/backend/tests/test_qr.c @@ -295,9 +295,9 @@ static void test_qr_input(int index, int generate, int debug) { printf(" /*%3d*/ { %s, %d, %s, \"%s\", %s, %d, \"%s\", \"%s\" },\n", i, testUtilInputModeName(data[i].input_mode), data[i].eci, testUtilOption3Name(data[i].option_3), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), - testUtilErrorName(data[i].ret), ret < 5 ? symbol->eci : -1, symbol->errtxt, data[i].comment); + testUtilErrorName(data[i].ret), ret < ZINT_ERROR ? symbol->eci : -1, symbol->errtxt, data[i].comment); } else { - if (ret < 5) { + 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); assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); @@ -356,7 +356,7 @@ static void test_qr_gs1(int index, int generate, int debug) { printf(" /*%3d*/ { \"%s\", %s, \"%s\", \"%s\" },\n", i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->errtxt, data[i].comment); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); } } @@ -1279,10 +1279,10 @@ static void test_qr_encode(int index, int generate, int debug) { i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), data[i].option_1, data[i].option_2, testUtilOption3Name(data[i].option_3), data[i].data, testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment); - testUtilModulesDump(symbol, " ", "\n"); + testUtilModulesPrint(symbol, " ", "\n"); printf(" },\n"); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data); @@ -1574,7 +1574,7 @@ static void test_microqr_input(int index, int generate, int debug) { i, testUtilInputModeName(data[i].input_mode), data[i].option_3, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->errtxt, data[i].comment); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); } } @@ -1625,7 +1625,7 @@ static void test_microqr_padding(int index, int generate, int debug) { /* 23*/ { "ABCDEFGHIJKLMNOPQR", 2, 0, "32 39 A8 A5 42 AE 16 7A E6 5F AC 51 95 A0", "M4-M, bits left 5" }, /* 24*/ { "ABCDEFGHIJKLM", 3, 0, "2D 39 A8 A5 42 AE 16 7A E6 56", "M4-Q, bits left 0" }, }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); char escaped[1024]; @@ -1654,7 +1654,7 @@ static void test_microqr_padding(int index, int generate, int debug) { i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].option_1, testUtilErrorName(data[i].ret), symbol->errtxt, data[i].comment); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); } } @@ -2025,10 +2025,10 @@ static void test_microqr_encode(int index, int generate, int debug) { i, testUtilInputModeName(data[i].input_mode), data[i].option_1, data[i].option_2, testUtilOption3Name(data[i].option_3), data[i].data, testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment); - testUtilModulesDump(symbol, " ", "\n"); + testUtilModulesPrint(symbol, " ", "\n"); printf(" },\n"); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data); @@ -2135,7 +2135,7 @@ static void test_upnqr_input(int index, int generate, int debug) { /* 1*/ { UNICODE_MODE, "é", 0, "(415) 70 44 00 01 E9 00 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11", "ECI-4 B1 (ISO 8859-2)" }, /* 2*/ { UNICODE_MODE, "β", ZINT_ERROR_INVALID_DATA, "Error 572: Invalid characters in input data", "β not in ISO 8859-2" }, }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); char escaped[1024]; @@ -2146,12 +2146,9 @@ static void test_upnqr_input(int index, int generate, int debug) { struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - symbol->symbology = BARCODE_UPNQR; - symbol->input_mode = data[i].input_mode; - symbol->debug = ZINT_DEBUG_TEST; // Needed to get codeword dump in errtxt - symbol->debug |= debug; + debug |= ZINT_DEBUG_TEST; // Needed to get codeword dump in errtxt - int length = strlen(data[i].data); + int length = testUtilSetSymbol(symbol, BARCODE_UPNQR, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug); ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret); @@ -2162,7 +2159,7 @@ static void test_upnqr_input(int index, int generate, int debug) { i, testUtilInputModeName(data[i].input_mode), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->errtxt, data[i].comment); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); } } @@ -2272,7 +2269,7 @@ static void test_upnqr_encode(int index, int generate, int debug) { "11111110110101111101111001011101111100101101111101100101000101100100011101000" }, }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); for (int i = 0; i < data_size; i++) { @@ -2281,17 +2278,7 @@ static void test_upnqr_encode(int index, int generate, int debug) { struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - symbol->symbology = BARCODE_UPNQR; - symbol->input_mode = data[i].input_mode; - if (data[i].option_1 != -1) { - symbol->option_1 = data[i].option_1; - } - if (data[i].option_2 != -1) { - symbol->option_2 = data[i].option_2; - } - symbol->debug |= debug; - - int length = strlen(data[i].data); + int length = testUtilSetSymbol(symbol, BARCODE_UPNQR, data[i].input_mode, -1 /*eci*/, data[i].option_1, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug); ret = ZBarcode_Encode(symbol, (unsigned char *) 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); @@ -2300,10 +2287,10 @@ static void test_upnqr_encode(int index, int generate, int debug) { printf(" /*%3d*/ { %s, \"%s\", %d, %d, %s, %d, %d, \"%s\",\n", i, testUtilInputModeName(data[i].input_mode), data[i].data, data[i].option_1, data[i].option_2, testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment); - testUtilModulesDump(symbol, " ", "\n"); + testUtilModulesPrint(symbol, " ", "\n"); printf(" },\n"); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data); @@ -2404,7 +2391,7 @@ static void test_rmqr_options(int index, int debug) { /* 64*/ { "点茗点茗点茗点茗点茗点茗点茗点茗点茗", 4, 38, 0, 0, 17, 77 }, // ECC set to H, version 38 (R17xAuto-width) auto-sets R17x77 /* 65*/ { "点茗点", -1, 39, ZINT_ERROR_INVALID_OPTION, -1, 0, 0 }, }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); for (int i = 0; i < data_size; i++) { @@ -2413,26 +2400,17 @@ static void test_rmqr_options(int index, int debug) { struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - symbol->symbology = BARCODE_RMQR; - symbol->input_mode = UNICODE_MODE; - if (data[i].option_1 != -1) { - symbol->option_1 = data[i].option_1; - } - if (data[i].option_2 != -1) { - symbol->option_2 = data[i].option_2; - } - symbol->debug |= debug; - - int length = strlen(data[i].data); + int length = testUtilSetSymbol(symbol, BARCODE_RMQR, UNICODE_MODE, -1 /*eci*/, data[i].option_1, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug); ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); assert_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret_encode, symbol->errtxt); - if (data[i].ret_vector != -1) { - ret = ZBarcode_Buffer_Vector(symbol, 0); - assert_equal(ret, data[i].ret_vector, "i:%d ZBarcode_Buffer_Vector ret %d != %d\n", i, ret, data[i].ret_vector); + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); + + ret = ZBarcode_Buffer_Vector(symbol, 0); + assert_equal(ret, data[i].ret_vector, "i:%d ZBarcode_Buffer_Vector ret %d != %d\n", i, ret, data[i].ret_vector); } ZBarcode_Delete(symbol); @@ -2476,7 +2454,7 @@ static void test_rmqr_input(int index, int generate, int debug) { /* 10*/ { UNICODE_MODE, -1, "áA", 0, "6B 85 04 00 EC", "B2 (ISO 8859-1)" }, /* 11*/ { UNICODE_MODE, 200, "áA", 0, "8E 00 40 EC 11", "K1 (ISO 8859-1) (full multibyte)" }, }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); char escaped[1024]; @@ -2487,15 +2465,9 @@ static void test_rmqr_input(int index, int generate, int debug) { struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - symbol->symbology = BARCODE_RMQR; - symbol->input_mode = data[i].input_mode; - if (data[i].option_3 != -1) { - symbol->option_3 = data[i].option_3; - } - symbol->debug = ZINT_DEBUG_TEST; // Needed to get codeword dump in errtxt - symbol->debug |= debug; + debug |= ZINT_DEBUG_TEST; // Needed to get codeword dump in errtxt - int length = strlen(data[i].data); + int length = testUtilSetSymbol(symbol, BARCODE_RMQR, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, data[i].option_3, -1 /*output_options*/, data[i].data, -1, debug); ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret); @@ -2505,7 +2477,7 @@ static void test_rmqr_input(int index, int generate, int debug) { i, testUtilInputModeName(data[i].input_mode), data[i].option_3, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->errtxt, data[i].comment); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); } } @@ -2540,7 +2512,7 @@ static void test_rmqr_gs1(int index, int generate, int debug) { /* 9*/ { "[91]A%%%%12345678A%A", 0, "A8 A6 58 F4 4C C6 4A 4A 4A 48 1E DC 89 C8 87 A3 5C 00 EC", "A4(5) B3 N8 A3(4)" }, /* 10*/ { "[91]%23%%6789%%%34567%%%%234%%%%%", 0, "(33) AA 63 2D B5 02 EE D4 DA 84 54 B8 ED 4D A9 B5 04 58 E7 2C 3B 53 6A 6D 4D 60 22 F6 A3", "A27(38) B4" }, }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); char escaped[1024]; @@ -2551,12 +2523,9 @@ static void test_rmqr_gs1(int index, int generate, int debug) { struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - symbol->symbology = BARCODE_RMQR; - symbol->input_mode = GS1_MODE; - symbol->debug = ZINT_DEBUG_TEST; // Needed to get codeword dump in errtxt - symbol->debug |= debug; + debug |= ZINT_DEBUG_TEST; // Needed to get codeword dump in errtxt - int length = strlen(data[i].data); + int length = testUtilSetSymbol(symbol, BARCODE_RMQR, GS1_MODE, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug); ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret); @@ -2565,7 +2534,7 @@ static void test_rmqr_gs1(int index, int generate, int debug) { printf(" /*%3d*/ { \"%s\", %s, \"%s\", \"%s\" },\n", i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->errtxt, data[i].comment); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); } } @@ -2613,7 +2582,7 @@ static void test_rmqr_optimize(int index, int generate, int debug) { /* 20*/ { UNICODE_MODE, "テaAB1", -1, 0, "6E 0D 95 85 19 CD 04", "B3 A3" }, /* 21*/ { UNICODE_MODE, "貫やぐ識禁ぱい再2間変字全ノレ没無8裁花ほゃ過法ひなご札17能つーびれ投覧マ勝動エヨ額界よみ作皇ナヲニ打題ヌルヲ掲布益フが。入35能ト権話しこを断兆モヘ細情おじ名4減エヘイハ側機", -1, 0, "(152) 82 0E A2 16 20 97 28 BD 02 C1 4F 09 12 61 08 04 A0 83 AA 3E 3D 43 4C 13 0D 68 73 1F", "K8 N1 K8 N1 K10 N2 K33 N2 K16 N1 K7" }, }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); char escaped[1024]; @@ -2624,16 +2593,9 @@ static void test_rmqr_optimize(int index, int generate, int debug) { struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - symbol->symbology = BARCODE_RMQR; - symbol->input_mode = data[i].input_mode; - if (data[i].option_1 != -1) { - symbol->option_1 = data[i].option_1; - } - symbol->option_3 = ZINT_FULL_MULTIBYTE; - symbol->debug = ZINT_DEBUG_TEST; - symbol->debug |= debug; + debug |= ZINT_DEBUG_TEST; // Needed to get codeword dump in errtxt - int length = strlen(data[i].data); + int length = testUtilSetSymbol(symbol, BARCODE_RMQR, data[i].input_mode, -1 /*eci*/, data[i].option_1, -1, ZINT_FULL_MULTIBYTE, -1 /*output_options*/, data[i].data, -1, debug); ret = ZBarcode_Encode(symbol, (unsigned char *) 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); @@ -2699,7 +2661,7 @@ static void test_rmqr_encode(int index, int generate, int debug) { "111010101010101010101011111" }, }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); for (int i = 0; i < data_size; i++) { @@ -2708,17 +2670,7 @@ static void test_rmqr_encode(int index, int generate, int debug) { struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - symbol->symbology = BARCODE_RMQR; - symbol->input_mode = data[i].input_mode; - if (data[i].option_1 != -1) { - symbol->option_1 = data[i].option_1; - } - if (data[i].option_2 != -1) { - symbol->option_2 = data[i].option_2; - } - symbol->debug |= debug; - - int length = strlen(data[i].data); + int length = testUtilSetSymbol(symbol, BARCODE_RMQR, data[i].input_mode, -1 /*eci*/, data[i].option_1, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug); ret = ZBarcode_Encode(symbol, (unsigned char *) 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); @@ -2727,10 +2679,10 @@ static void test_rmqr_encode(int index, int generate, int debug) { printf(" /*%3d*/ { %s, \"%s\", %d, %d, %s, %d, %d, \"%s\",\n", i, testUtilInputModeName(data[i].input_mode), data[i].data, data[i].option_1, data[i].option_2, testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment); - testUtilModulesDump(symbol, " ", "\n"); + testUtilModulesPrint(symbol, " ", "\n"); printf(" },\n"); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data); diff --git a/backend/tests/test_rss.c b/backend/tests/test_rss.c index 51dd8904..90130f88 100644 --- a/backend/tests/test_rss.c +++ b/backend/tests/test_rss.c @@ -121,7 +121,7 @@ static void test_binary_div_modulo_divisor(int index, int generate, int debug) { /* 69*/ { BARCODE_DBAR_LTD, "1651257071912", 100, 30, 1, 79, "0100000111100011110101010101010111010100100101010101010101111110111111110100000" }, /* 70*/ { BARCODE_DBAR_LTD_CC, "0987144605916", 100, 30, 6, 79, "0101010101010011111000011111011010110100100101010101010100111110000111110100000" }, }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); char *text; @@ -135,16 +135,13 @@ static void test_binary_div_modulo_divisor(int index, int generate, int debug) { struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - symbol->symbology = data[i].symbology; - symbol->debug |= debug; - - if (symbol->symbology == BARCODE_DBAR_OMN_CC || symbol->symbology == BARCODE_DBAR_LTD_CC) { + if (data[i].symbology == BARCODE_DBAR_OMN_CC || data[i].symbology == BARCODE_DBAR_LTD_CC) { text = "[20]01"; strcpy(symbol->primary, data[i].data); } else { text = data[i].data; } - int length = strlen(text); + int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, text, -1, debug); ret = ZBarcode_Encode(symbol, (const unsigned char *) text, length); assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 (%s)\n", i, ret, symbol->errtxt); @@ -152,7 +149,7 @@ static void test_binary_div_modulo_divisor(int index, int generate, int debug) { if (generate) { printf(" /*%3d*/ { %s, \"%s\", %.0f, %.0f, %d, %d, ", i, testUtilBarcodeName(data[i].symbology), data[i].data, data[i].w, data[i].h, symbol->rows, symbol->width); - testUtilModulesDumpRow(symbol, symbol->rows - 1, "", " },\n"); + testUtilModulesPrintRow(symbol, symbol->rows - 1, "", " },\n"); } else { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); @@ -774,7 +771,7 @@ static void test_examples(int index, int generate, int debug) { "101110001111011010010111111000011100001011011100011000011110110010110001100000000101100000001010010011101101001100000101111100000011000010101111101110001110110011001100110000000001011100111000110100111101100101111101011111111100110100000000000000000" }, }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); char bwipp_buf[4096]; char bwipp_msg[1024]; @@ -795,7 +792,7 @@ static void test_examples(int index, int generate, int debug) { if (generate) { printf(" /*%3d*/ { %s, %d, \"%s\", %d, %d, %d, %d, \"%s\",\n", i, testUtilBarcodeName(symbol->symbology), data[i].option_2, data[i].data, data[i].ret, symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].comment); - testUtilModulesDump(symbol, " ", "\n"); + testUtilModulesPrint(symbol, " ", "\n"); printf(" },\n"); } else { assert_equal(symbol->rows, data[i].expected_rows, "i:%d %s symbol->rows %d != %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), symbol->rows, data[i].expected_rows, data[i].data); @@ -1089,7 +1086,7 @@ static void test_general_field(int index, int generate, int debug) { "101110011100010010011100111111110100111101001000011000010010001011110100001111110001100010100000100010" }, }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); for (int i = 0; i < data_size; i++) { @@ -1098,10 +1095,7 @@ static void test_general_field(int index, int generate, int debug) { struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - symbol->symbology = data[i].symbology; - symbol->debug |= debug; - - int length = strlen(data[i].data); + int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug); ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].data, length); assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 (%s)\n", i, ret, symbol->errtxt); @@ -1109,7 +1103,7 @@ static void test_general_field(int index, int generate, int debug) { if (generate) { printf(" /*%2d*/ { %s, \"%s\", %d, %d, %d, \"%s\",\n", i, testUtilBarcodeName(symbol->symbology), data[i].data, ret, symbol->rows, symbol->width, data[i].comment); - testUtilModulesDump(symbol, " ", "\n"); + testUtilModulesPrint(symbol, " ", "\n"); printf(" },\n"); } else { assert_equal(symbol->rows, data[i].expected_rows, "i:%d %s symbol->rows %d != %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), symbol->rows, data[i].expected_rows, data[i].data); @@ -1149,7 +1143,7 @@ static void test_binary_buffer_size(int index, int generate, int debug) { /* 6*/ { "[01]92345678901237[3920]123456789012345[00]123456789012345675[91]1234567890123456789", 0, 1, 543, "77 (incl. FNC1 after 3920) == 01 + 392x + other AIs max" }, /* 7*/ { "[01]92345678901237[3920]123456789012345[00]123456789012345675[91]12345678901234567890", ZINT_ERROR_TOO_LONG, 0, 0, "78 > 01 + 392x + other AIs max" }, }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); for (int i = 0; i < data_size; i++) { @@ -1158,10 +1152,7 @@ static void test_binary_buffer_size(int index, int generate, int debug) { struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - symbol->symbology = BARCODE_DBAR_EXP; - symbol->debug |= debug; - - int length = strlen(data[i].data); + int length = testUtilSetSymbol(symbol, BARCODE_DBAR_EXP, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug); ret = ZBarcode_Encode(symbol, (const unsigned char *) 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); @@ -1280,7 +1271,7 @@ static void test_input(int index, int debug) { ret = ZBarcode_Encode(symbol, (const unsigned char *) 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 < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); } diff --git a/backend/tests/test_telepen.c b/backend/tests/test_telepen.c index d31fd9e0..4b5824d4 100644 --- a/backend/tests/test_telepen.c +++ b/backend/tests/test_telepen.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2020 Robin Stuart + Copyright (C) 2020 - 2021 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -247,7 +247,7 @@ static void test_encode(int index, int generate, int debug) { printf(" /*%3d*/ { %s, \"%s\", %d, %s, %d, %d, \"%s\",\n", i, testUtilBarcodeName(data[i].symbology), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length, testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment); - testUtilModulesDump(symbol, " ", "\n"); + testUtilModulesPrint(symbol, " ", "\n"); printf(" },\n"); } else { if (ret < 5) { diff --git a/backend/tests/test_ultra.c b/backend/tests/test_ultra.c index 19e56295..f19c8dc4 100644 --- a/backend/tests/test_ultra.c +++ b/backend/tests/test_ultra.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2020 Robin Stuart + Copyright (C) 2020 - 2021 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -75,7 +75,7 @@ static void test_reader_init(int index, int generate, int debug) { testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->rows, symbol->width, symbol->errtxt, data[i].comment); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { 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->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); @@ -173,7 +173,7 @@ static void test_input(int index, int generate, int debug) { i, testUtilInputModeName(data[i].input_mode), data[i].eci, data[i].option_1, testUtilOption3Name(data[i].option_3), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->errtxt, data[i].comment); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); } } @@ -497,10 +497,10 @@ static void test_encode(int index, int generate, int debug) { printf(" /*%3d*/ { %s, %d, %d, %s, \"%s\", %s, %d, %d, \"%s\",\n", i, testUtilInputModeName(data[i].input_mode), data[i].eci, data[i].option_1, testUtilOption3Name(data[i].option_3), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment); - testUtilModulesDump(symbol, " ", "\n"); + testUtilModulesPrint(symbol, " ", "\n"); printf(" },\n"); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data); diff --git a/backend/tests/test_upcean.c b/backend/tests/test_upcean.c index ca13a29f..b0a200c7 100644 --- a/backend/tests/test_upcean.c +++ b/backend/tests/test_upcean.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2019 - 2020 Robin Stuart + Copyright (C) 2019 - 2021 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -87,7 +87,7 @@ static void test_upce_input(int index, int debug) { /* 41*/ { BARCODE_UPCE, "000001", 0 }, /* 42*/ { BARCODE_UPCE, "000002", 0 }, }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); for (int i = 0; i < data_size; i++) { @@ -96,10 +96,7 @@ static void test_upce_input(int index, int debug) { struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - symbol->symbology = data[i].symbology; - symbol->debug |= debug; - - int length = strlen(data[i].data); + int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug); ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); assert_equal(ret, data[i].ret, "i:%d ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); @@ -125,7 +122,7 @@ static void test_upca_print(int index, int debug) { struct item data[] = { /* 0*/ { BARCODE_UPCA, "01234567890", 0 }, }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); for (int i = 0; i < data_size; i++) { @@ -134,10 +131,7 @@ static void test_upca_print(int index, int debug) { struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - symbol->symbology = data[i].symbology; - symbol->debug |= debug; - - int length = strlen(data[i].data); + int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug); ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); assert_equal(ret, data[i].ret, "i:%d ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); @@ -458,7 +452,7 @@ static void test_isbn_input(int index, int debug) { /* 53*/ { "97912345678961+12345", ZINT_ERROR_TOO_LONG, -1 }, /* 54*/ { "9791234567896+123456", ZINT_ERROR_TOO_LONG, -1 }, }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); for (int i = 0; i < data_size; i++) { @@ -468,10 +462,7 @@ static void test_isbn_input(int index, int debug) { struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - symbol->symbology = BARCODE_ISBNX; - symbol->debug |= debug; - - int length = strlen(data[i].data); + int length = testUtilSetSymbol(symbol, BARCODE_ISBNX, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug); ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); assert_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret_encode, symbol->errtxt); @@ -503,7 +494,7 @@ static void test_vector_same(int index, int debug) { /* 1*/ { BARCODE_UPCE_CHK, "1234565", 0, 0 }, // 5 is correct check digit /* 2*/ { BARCODE_ISBNX, "0195049969", 0, 0 }, // 9 is correct check digit }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); for (int i = 0; i < data_size; i++) { @@ -516,10 +507,7 @@ static void test_vector_same(int index, int debug) { struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - symbol->symbology = data[i].symbology; - symbol->debug |= debug; - - int length = strlen(data[i].data); + int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug); ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); assert_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret_encode, symbol->errtxt); @@ -698,10 +686,10 @@ static void test_encode(int index, int generate, int debug) { if (generate) { printf(" /*%3d*/ { %s, %d, \"%s\", %s, %d, %d, \"%s\",\n", i, testUtilBarcodeName(data[i].symbology), data[i].option_2, data[i].data, testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment); - testUtilModulesDump(symbol, " ", "\n"); + testUtilModulesPrint(symbol, " ", "\n"); printf(" },\n"); } else { - if (ret < 5) { + if (ret < ZINT_ERROR) { 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->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data); @@ -751,7 +739,7 @@ static void test_fuzz(int index, int debug) { /* 8*/ { BARCODE_EANX, "+12345", -1, 0 }, /* 9*/ { BARCODE_EANX, "+123456", -1, ZINT_ERROR_TOO_LONG }, }; - int data_size = sizeof(data) / sizeof(struct item); + int data_size = ARRAY_SIZE(data); for (int i = 0; i < data_size; i++) { @@ -760,13 +748,7 @@ static void test_fuzz(int index, int debug) { struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - symbol->symbology = data[i].symbology; - symbol->debug |= debug; - - int length = data[i].length; - if (length == -1) { - length = strlen(data[i].data); - } + int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, data[i].length, debug); ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); assert_equal(ret, data[i].ret, "i:%d ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); diff --git a/backend/tests/testcommon.c b/backend/tests/testcommon.c index 1461f2d8..73456e8c 100644 --- a/backend/tests/testcommon.c +++ b/backend/tests/testcommon.c @@ -34,6 +34,7 @@ */ #include "testcommon.h" +#include "../eci.h" #ifndef NO_PNG #include #include @@ -594,8 +595,8 @@ int testUtilDAFTConvert(const struct zint_symbol *symbol, char *buffer, int buff } /* Is string valid UTF-8? */ -int testUtilIsValidUTF8(const unsigned char str[], const size_t length) { - size_t i; +int testUtilIsValidUTF8(const unsigned char str[], const int length) { + int i; unsigned int codepoint, state = 0; for (i = 0; i < length; i++) { @@ -918,14 +919,37 @@ int testUtilVectorCmp(const struct zint_vector *a, const struct zint_vector *b) return 0; } -void testUtilModulesDump(const struct zint_symbol *symbol, const char *prefix, const char *postfix) { +int testUtilModulesDump(const struct zint_symbol *symbol, char dump[], int dump_size) { + int r, w; + char *d = dump; + char *de = dump + dump_size; + + for (r = 0; r < symbol->rows && d < de; r++) { + if (symbol->symbology == BARCODE_ULTRA) { + for (w = 0; w < symbol->width && d < de; w++) { + *d++ = module_colour_is_set(symbol, r, w) + '0'; + } + } else { + for (w = 0; w < symbol->width && d < de; w++) { + *d++ = module_is_set(symbol, r, w) + '0'; + } + } + } + if (d == de) { + return -1; + } + *d = '\0'; + return d - dump; +} + +void testUtilModulesPrint(const struct zint_symbol *symbol, const char *prefix, const char *postfix) { int r; for (r = 0; r < symbol->rows; r++) { - testUtilModulesDumpRow(symbol, r, prefix, postfix); + testUtilModulesPrintRow(symbol, r, prefix, postfix); } } -void testUtilModulesDumpRow(const struct zint_symbol *symbol, int row, const char *prefix, const char *postfix) { +void testUtilModulesPrintRow(const struct zint_symbol *symbol, int row, const char *prefix, const char *postfix) { int w; if (*prefix) { fputs(prefix, stdout); @@ -1756,7 +1780,7 @@ static const char *testUtilBwippName(int index, const struct zint_symbol *symbol { "", BARCODE_AUSREDIRECT, 68, 0, 0, 0, 0, 0, }, { "isbn", BARCODE_ISBNX, 69, 0, 1, 0, 0, 1 /*gs1_cvt*/, }, { "royalmail", BARCODE_RM4SCC, 70, 0, 0, 0, 0, 0, }, - { "datamatrix", BARCODE_DATAMATRIX, 71, 0, 1, 1, 0, 0, }, + { "datamatrix", BARCODE_DATAMATRIX, 71, 0, 1, 1, 1, 0, }, { "ean14", BARCODE_EAN14, 72, 0, 0, 0, 0, 1 /*gs1_cvt*/, }, { "code39", BARCODE_VIN, 73, 0, 0, 0, 0, 0, }, { "codablockf", BARCODE_CODABLOCKF, 74, 1, 1, 0, 10 /*linear_row_height*/, 0, }, @@ -1883,12 +1907,6 @@ static const char *testUtilBwippName(int index, const struct zint_symbol *symbol } if (gs1) { if (symbology == BARCODE_DATAMATRIX) { - if (symbol->output_options & GS1_GS_SEPARATOR) { /* Not supported */ - if (debug & ZINT_DEBUG_TEST_PRINT) { - printf("i:%d %s not BWIPP compatible, GS1_GS_SEPARATOR not supported\n", index, testUtilBarcodeName(symbology)); - } - return NULL; - } if (gs1_cvt) { *gs1_cvt = 1; } @@ -2031,6 +2049,8 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int int primary_len = primary ? (int) strlen(primary) : 0; int max_data_len = 4 + primary_len + 1 + 1 + data_len * 4 + 32; /* 4 AI prefix + primary + '|' + leading zero + escaped data + fudge */ + int eci_length = get_eci_length(symbol->eci, (const unsigned char *) data, data_len); + char converted[eci_length + 1]; char cmd[max_data_len + 1024]; const char *bwipp_barcode = NULL; char *bwipp_opts = NULL; @@ -2052,6 +2072,7 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int int upcean = is_extendable(symbology); int upca = symbology == BARCODE_UPCA || symbology == BARCODE_UPCA_CHK || symbology == BARCODE_UPCA_CC; int addon_posn; + int eci; bwipp_data[0] = bwipp_opts_buf[0] = '\0'; @@ -2073,6 +2094,26 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int bwipp_row_height[symbol->rows - 1] = 36; } + if ((symbol->input_mode & 0x07) == UNICODE_MODE && ZBarcode_Cap(symbology, ZINT_CAP_ECI) && is_eci_convertible(symbol->eci)) { + if (utf8_to_eci(symbol->eci, (const unsigned char *) data, (unsigned char *) converted, &data_len) == 0) { + eci = symbol->eci; + } else { + if (symbol->eci != 0) { + eci = get_best_eci((const unsigned char *) data, data_len); + if (utf8_to_eci(eci, (const unsigned char *) data, (unsigned char *) converted, &data_len) != 0) { + fprintf(stderr, "i:%d testUtilBwipp: failed to convert Unicode data for %s\n", index, testUtilBarcodeName(symbology)); + return -1; + } + } else { + fprintf(stderr, "i:%d testUtilBwipp: failed to convert Unicode data for %s\n", index, testUtilBarcodeName(symbology)); + return -1; + } + } + data = converted; + } else { + eci = symbol->eci >= 3 && ZBarcode_Cap(symbology, ZINT_CAP_ECI) ? symbol->eci : 0; + } + if (is_composite(symbology)) { if (!primary) { fprintf(stderr, "i:%d testUtilBwipp: no primary data given %s\n", index, testUtilBarcodeName(symbology)); @@ -2133,7 +2174,6 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int } } } else { - int eci = symbol->eci >= 3 && ZBarcode_Cap(symbology, ZINT_CAP_ECI) ? symbol->eci : 0; if (testUtilBwippEscape(bwipp_data, sizeof(bwipp_data), data, data_len, symbol->input_mode & ESCAPE_MODE, eci, &parse, &parsefnc) == NULL) { return -1; } @@ -2329,16 +2369,29 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int } if (symbology == BARCODE_DATAMATRIX || symbology == BARCODE_HIBC_DM) { + int added_dmre = 0; #include "../dmatrix.h" (void)matrixrsblock; (void)matrixdatablock; (void)matrixbytes; (void)matrixFW; (void)matrixFH; (void)isDMRE; (void)text_value; (void)text_shift; (void)c40_value; (void)c40_shift; + if (symbol->output_options & GS1_GS_SEPARATOR) { + sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%sgssep", strlen(bwipp_opts_buf) ? " " : ""); + bwipp_opts = bwipp_opts_buf; + } if (option_2 >= 1 && option_2 <= (int) sizeof(intsymbol)) { int idx = intsymbol[option_2 - 1]; sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%srows=%d columns=%d", strlen(bwipp_opts_buf) ? " " : "", matrixH[idx], matrixW[idx]); bwipp_opts = bwipp_opts_buf; + if (option_2 >= 31) { + sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%sdmre", strlen(bwipp_opts_buf) ? " " : ""); + added_dmre = 1; + } } if (option_3 != DM_SQUARE && symbol->width != symbol->height) { + if (option_3 == DM_DMRE && !added_dmre) { + sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%sdmre", strlen(bwipp_opts_buf) ? " " : ""); + added_dmre = 1; + } sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%sformat=rectangle", strlen(bwipp_opts_buf) ? " " : ""); bwipp_opts = bwipp_opts_buf; } @@ -2365,7 +2418,7 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int return -1; } - if (bwipp_opts) { + if (bwipp_opts && strlen(bwipp_opts)) { if (strlen(bwipp_data) >= 2043) { /* Ghostscript's `arg_str_max` 2048 less "-sd=" */ sprintf(cmd, cmd_opts_fmt2, bwipp_barcode, bwipp_data, bwipp_data + 2043, bwipp_opts); } else { diff --git a/backend/tests/testcommon.h b/backend/tests/testcommon.h index e59cbf69..6a806b98 100644 --- a/backend/tests/testcommon.h +++ b/backend/tests/testcommon.h @@ -88,15 +88,16 @@ const char *testUtilInputModeName(int input_mode); const char *testUtilOption3Name(int option_3); const char *testUtilOutputOptionsName(int output_options); int testUtilDAFTConvert(const struct zint_symbol *symbol, char *buffer, int buffer_size); -int testUtilIsValidUTF8(const unsigned char str[], const size_t length); +int testUtilIsValidUTF8(const unsigned char str[], const int length); char *testUtilEscape(char *buffer, int length, char *escaped, int escaped_size); char *testUtilReadCSVField(char *buffer, char *field, int field_size); void testUtilStrCpyRepeat(char *buffer, char *repeat, int size); int testUtilSymbolCmp(const struct zint_symbol *a, const struct zint_symbol *b); struct zint_vector *testUtilVectorCpy(const struct zint_vector *in); int testUtilVectorCmp(const struct zint_vector *a, const struct zint_vector *b); -void testUtilModulesDump(const struct zint_symbol *symbol, const char *prefix, const char *postfix); // TODO: should be called Print not Dump -void testUtilModulesDumpRow(const struct zint_symbol *symbol, int row, const char *prefix, const char *postfix); // TODO: should be called Print not Dump +int testUtilModulesDump(const struct zint_symbol *symbol, char dump[], int dump_size); +void testUtilModulesPrint(const struct zint_symbol *symbol, const char *prefix, const char *postfix); +void testUtilModulesPrintRow(const struct zint_symbol *symbol, int row, const char *prefix, const char *postfix); int testUtilModulesCmp(const struct zint_symbol *symbol, const char *expected, int *width, int *row); int testUtilModulesCmpRow(const struct zint_symbol *symbol, int row, const char *expected, int *width); int testUtilModulesDumpHex(const struct zint_symbol *symbol, char dump[], int dump_size); diff --git a/backend/tests/tools/run_bwipp_tests.sh b/backend/tests/tools/run_bwipp_tests.sh index 80b099ed..330411ff 100755 --- a/backend/tests/tools/run_bwipp_tests.sh +++ b/backend/tests/tools/run_bwipp_tests.sh @@ -24,7 +24,7 @@ run_bwipp_test "test_code128" "encode" run_bwipp_test "test_code16k" "encode" run_bwipp_test "test_code49" "encode" run_bwipp_test "test_composite" -run_bwipp_test "test_dmatrix" "encode" +run_bwipp_test "test_dmatrix" run_bwipp_test "test_dotcode" "encode" run_bwipp_test "test_gs1" "gs1_reduce" run_bwipp_test "test_imail" "encode"