1
0
mirror of https://git.code.sf.net/p/zint/code synced 2026-07-31 02:19:50 +00:00

Integrate GS1 Syntax Engine

This commit is contained in:
gitlost
2025-09-12 04:20:55 +01:00
parent ad95d8f2b0
commit 0650d5798e
32 changed files with 2109 additions and 723 deletions
+13 -3
View File
@@ -8,6 +8,9 @@ project(zint)
if(ZINT_USE_PNG)
find_package(PNG)
endif()
if(ZINT_USE_GS1SE)
find_library(GS1SE gs1encoders)
endif()
set(zint_COMMON_SRCS common.c eci.c filemem.c general_field.c gs1.c large.c library.c reedsol.c)
set(zint_ONEDIM_SRCS 2of5.c 2of5inter.c 2of5inter_based.c bc412.c channel.c codabar.c code.c code11.c code128.c
@@ -15,10 +18,9 @@ set(zint_ONEDIM_SRCS 2of5.c 2of5inter.c 2of5inter_based.c bc412.c channel.c coda
set(zint_POSTAL_SRCS auspost.c imail.c mailmark.c postal.c)
set(zint_TWODIM_SRCS aztec.c codablock.c code1.c code16k.c code49.c composite.c dmatrix.c dotcode.c gridmtx.c
hanxin.c maxicode.c pdf417.c qr.c ultra.c)
set(zint_OUTPUT_SRCS bmp.c emf.c gif.c output.c pcx.c ps.c raster.c svg.c tif.c vector.c)
if(ZINT_USE_PNG AND PNG_FOUND)
set(zint_OUTPUT_SRCS bmp.c emf.c gif.c output.c pcx.c png.c ps.c raster.c svg.c tif.c vector.c)
else()
set(zint_OUTPUT_SRCS bmp.c emf.c gif.c output.c pcx.c ps.c raster.c svg.c tif.c vector.c)
set(zint_OUTPUT_SRCS ${zint_OUTPUT_SRCS} png.c)
endif()
set(zint_SRCS ${zint_OUTPUT_SRCS} ${zint_COMMON_SRCS} ${zint_ONEDIM_SRCS} ${zint_POSTAL_SRCS} ${zint_TWODIM_SRCS})
@@ -88,6 +90,14 @@ else()
message(STATUS "Not using PNG")
endif()
if(ZINT_USE_GS1SE AND NOT GS1SE-NOTFOUND)
zint_target_link_libraries(${GS1SE})
zint_target_compile_definitions(PRIVATE ZINT_HAVE_GS1SE)
message(STATUS "Using GS1 Syntax Engine")
else()
message(STATUS "Not using GS1 Syntax Engine")
endif()
# Incompatible with ZINT_SANITIZE (and also with ZINT_USE_PNG unless libpng instrumented)
if(NOT ZINT_SANITIZE AND ZINT_SANITIZEM AND CMAKE_C_COMPILER_ID MATCHES "Clang")
add_compile_options(-fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -O2)
+1 -1
View File
@@ -539,7 +539,7 @@ INTERNAL int zint_gs1_128_cc(struct zint_symbol *symbol, unsigned char source[],
symbol->row_height[separator_row] = 1;
}
error_number = zint_gs1_verify(symbol, source, &length, reduced, &reduced_length);
error_number = zint_gs1_verify(symbol, source, length, reduced, &reduced_length);
if (error_number >= ZINT_ERROR) {
return error_number;
}
+7 -5
View File
@@ -74,6 +74,7 @@ INTERNAL void z_to_upper(unsigned char source[], const int length) {
INTERNAL int z_chr_cnt(const unsigned char source[], const int length, const unsigned char c) {
int count = 0;
int i;
for (i = 0; i < length; i++) {
count += source[i] == c;
}
@@ -240,6 +241,7 @@ INTERNAL void z_expand(struct zint_symbol *symbol, const char data[], const int
/* Helper for `z_errtxt()` & `z_errtxtf()` to set "err_id: " part of error message, returning length */
static int errtxt_id_str(char *errtxt, int num) {
int len = 0;
if (num == -1) {
errtxt[0] = '\0';
return 0;
@@ -258,6 +260,7 @@ static int errtxt_id_str(char *errtxt, int num) {
errtxt[len++] = '0' + num;
errtxt[len++] = ':';
errtxt[len++] = ' ';
return len;
}
@@ -285,6 +288,7 @@ static int errtxtf_dpad(const char *fmt); /* Forward reference */
static int errtxtf_num_arg(const char *fmt, int *p_arg) {
int ret = 0;
int arg = -2;
if (!errtxtf_dpad(fmt) && z_isdigit(fmt[0])) {
arg = fmt[1] == '$' ? fmt[0] - '0' - 1 : -1;
ret = 2;
@@ -299,6 +303,7 @@ static int errtxtf_num_arg(const char *fmt, int *p_arg) {
static int errtxtf_slen(const char *fmt, const int arg, int *p_arg_cnt, int *p_len) {
int ret = 0;
int len = -1;
if (fmt[0] == '.') {
if (z_isdigit(fmt[1]) && fmt[1] != '0') {
len = fmt[1] - '0';
@@ -326,6 +331,7 @@ static int errtxtf_slen(const char *fmt, const int arg, int *p_arg_cnt, int *p_l
if (p_len) {
*p_len = len;
}
return ret;
}
@@ -662,11 +668,7 @@ INTERNAL int z_is_fixed_ratio(const int symbology) {
/* Whether next two characters are digits */
INTERNAL int z_is_twodigits(const unsigned char source[], const int length, const int position) {
if (position + 1 < length && z_isdigit(source[position]) && z_isdigit(source[position + 1])) {
return 1;
}
return 0;
return position + 1 < length && z_isdigit(source[position]) && z_isdigit(source[position + 1]);
}
/* Returns how many consecutive digits lie immediately ahead up to `max`, or all if `max` is -1 */
+25 -24
View File
@@ -1094,16 +1094,17 @@ static int cc_binary_string(struct zint_symbol *symbol, const unsigned char sour
}
/* Calculate the width of the linear part (primary) */
static int cc_linear_dummy_run(struct zint_symbol *symbol, unsigned char *source, int *p_length) {
static int cc_linear_dummy_run(struct zint_symbol *symbol, unsigned char *source, int length) {
struct zint_symbol dummy = {0};
int error_number;
int linear_width;
dummy.symbology = BARCODE_GS1_128_CC;
dummy.option_1 = -1;
dummy.input_mode = symbol->input_mode;
/* Verified later via `linear` symbol (unless GS1SYNTAXENGINE_MODE, when already verified) */
dummy.input_mode = symbol->input_mode | GS1NOCHECK_MODE;
dummy.debug = symbol->debug;
error_number = zint_gs1_128_cc(&dummy, source, *p_length, 3 /*cc_mode*/, 0 /*cc_rows*/);
error_number = zint_gs1_128_cc(&dummy, source, length, 3 /*cc_mode*/, 0 /*cc_rows*/);
linear_width = dummy.width;
if (error_number >= ZINT_ERROR || (symbol->debug & ZINT_DEBUG_TEST)) {
(void) z_errtxt(0, symbol, -1, dummy.errtxt);
@@ -1112,8 +1113,6 @@ static int cc_linear_dummy_run(struct zint_symbol *symbol, unsigned char *source
if (error_number >= ZINT_ERROR) {
return 0;
}
/* May have changed if ESCAPE_MODE & GS1PARENS_MODE and escaped parentheses */
*p_length = (int) z_ustrlen(source);
return linear_width;
}
@@ -1128,7 +1127,6 @@ INTERNAL int zint_composite(struct zint_symbol *symbol, unsigned char source[],
struct zint_symbol *linear;
int top_shift, bottom_shift;
int linear_width = 0;
unsigned char primary[sizeof(symbol->primary)];
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT;
const int debug_print = symbol->debug & ZINT_DEBUG_PRINT;
@@ -1155,13 +1153,10 @@ INTERNAL int zint_composite(struct zint_symbol *symbol, unsigned char source[],
"Invalid mode (CC-C only valid with GS1-128 linear component)");
}
/* Take copy of primary so passed-in remains unchanged */
memcpy(primary, symbol->primary, primary_len + 1); /* Include terminating NUL */
if (symbol->symbology == BARCODE_GS1_128_CC) {
/* Do a test run of encoding the linear component to establish its width */
linear_width = cc_linear_dummy_run(symbol, primary, &primary_len); /* Length can change */
if (linear_width == 0) {
linear_width = cc_linear_dummy_run(symbol, ZUCP(symbol->primary), primary_len);
if (linear_width == 0) { /* Only catches `GS1NOCHECK_MODE` errors */
return z_errtxt_adj(ZINT_ERROR_INVALID_DATA, symbol, "%1$s%2$s", " (linear component)");
}
if (debug_print) {
@@ -1178,7 +1173,8 @@ INTERNAL int zint_composite(struct zint_symbol *symbol, unsigned char source[],
int padded_primary_len;
int with_addon;
unsigned char padded_primary[21];
if (!zint_ean_leading_zeroes(symbol, primary, primary_len, padded_primary, &with_addon, NULL, NULL)) {
if (!zint_ean_leading_zeroes(symbol, ZCUCP(symbol->primary), primary_len, padded_primary,
&with_addon, NULL, NULL)) {
return z_errtxt_adj(ZINT_ERROR_TOO_LONG, symbol, "%1$s%2$s", " (linear component)");
}
padded_primary_len = (int) z_ustrlen(padded_primary);
@@ -1278,6 +1274,11 @@ INTERNAL int zint_composite(struct zint_symbol *symbol, unsigned char source[],
linear->symbology = symbol->symbology;
linear->input_mode = symbol->input_mode;
#ifdef ZINT_HAVE_GS1SE
if (symbol->input_mode & GS1SYNTAXENGINE_MODE) {
linear->input_mode |= GS1NOCHECK_MODE; /* Already verified in `ZBarcode_Encode_Segs()` */
}
#endif
linear->output_options = symbol->output_options;
linear->show_hrt = symbol->show_hrt;
linear->option_2 = symbol->option_2;
@@ -1295,35 +1296,35 @@ INTERNAL int zint_composite(struct zint_symbol *symbol, unsigned char source[],
case BARCODE_EANX_CC:
case BARCODE_EAN8_CC:
case BARCODE_EAN13_CC:
error_number = zint_eanx_cc(linear, primary, primary_len, symbol->rows);
error_number = zint_eanx_cc(linear, ZUCP(symbol->primary), primary_len, symbol->rows);
break;
case BARCODE_GS1_128_CC:
/* GS1-128 needs to know which type of 2D component is used */
error_number = zint_gs1_128_cc(linear, primary, primary_len, cc_mode, symbol->rows);
error_number = zint_gs1_128_cc(linear, ZUCP(symbol->primary), primary_len, cc_mode, symbol->rows);
break;
case BARCODE_DBAR_OMN_CC:
error_number = zint_dbar_omn_cc(linear, primary, primary_len, symbol->rows);
error_number = zint_dbar_omn_cc(linear, ZUCP(symbol->primary), primary_len, symbol->rows);
break;
case BARCODE_DBAR_LTD_CC:
error_number = zint_dbar_ltd_cc(linear, primary, primary_len, symbol->rows);
error_number = zint_dbar_ltd_cc(linear, ZUCP(symbol->primary), primary_len, symbol->rows);
break;
case BARCODE_DBAR_EXP_CC:
error_number = zint_dbar_exp_cc(linear, primary, primary_len, symbol->rows);
error_number = zint_dbar_exp_cc(linear, ZUCP(symbol->primary), primary_len, symbol->rows);
break;
case BARCODE_UPCA_CC:
error_number = zint_eanx_cc(linear, primary, primary_len, symbol->rows);
error_number = zint_eanx_cc(linear, ZUCP(symbol->primary), primary_len, symbol->rows);
break;
case BARCODE_UPCE_CC:
error_number = zint_eanx_cc(linear, primary, primary_len, symbol->rows);
error_number = zint_eanx_cc(linear, ZUCP(symbol->primary), primary_len, symbol->rows);
break;
case BARCODE_DBAR_STK_CC:
error_number = zint_dbar_omn_cc(linear, primary, primary_len, symbol->rows);
error_number = zint_dbar_omn_cc(linear, ZUCP(symbol->primary), primary_len, symbol->rows);
break;
case BARCODE_DBAR_OMNSTK_CC:
error_number = zint_dbar_omn_cc(linear, primary, primary_len, symbol->rows);
error_number = zint_dbar_omn_cc(linear, ZUCP(symbol->primary), primary_len, symbol->rows);
break;
case BARCODE_DBAR_EXPSTK_CC:
error_number = zint_dbar_exp_cc(linear, primary, primary_len, symbol->rows);
error_number = zint_dbar_exp_cc(linear, ZUCP(symbol->primary), primary_len, symbol->rows);
break;
}
@@ -1461,7 +1462,7 @@ INTERNAL int zint_composite(struct zint_symbol *symbol, unsigned char source[],
error_number = zint_dbar_omnstk_set_height(symbol, symbol->rows - linear->rows + 1 /*first_row*/);
} else if (symbol->symbology == BARCODE_DBAR_EXP_CC || symbol->symbology == BARCODE_DBAR_EXPSTK_CC) {
/* If symbol->height given then min row height was returned, else default height */
if (error_number == 0) { /* Avoid overwriting any `gs1_verify()` warning */
if (error_number == 0) { /* Avoid overwriting any `zint_gs1_verify()` warning */
error_number = z_set_height(symbol, symbol->height ? linear->height : 0.0f,
symbol->height ? 0.0f : linear->height, 0.0f, 0 /*no_errtxt*/);
} else {
@@ -1491,7 +1492,7 @@ INTERNAL int zint_composite(struct zint_symbol *symbol, unsigned char source[],
if (raw_text) {
assert(linear->raw_segs && linear->raw_segs[0].source);
/* First linear, then pipe '|' separator (following BWIPP), then composite */
/* First linear, then pipe '|' separator (following BWIPP & GS1 Syntax Engine), then composite */
if (z_rt_cpy_cat(symbol, linear->raw_segs[0].source, linear->raw_segs[0].length, '|', source, length)) {
ZBarcode_Delete(linear);
return ZINT_ERROR_MEMORY; /* `z_rt_cpy_cat()` only fails with OOM */
+365 -177
View File
@@ -33,6 +33,9 @@
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
#ifdef ZINT_HAVE_GS1SE
#include <gs1encoders.h>
#endif
#include "common.h"
#include "gs1.h"
@@ -1609,52 +1612,227 @@ static int gs1_packagetype(const unsigned char *data, int data_len, int offset,
/* Generated by "php backend/tools/gen_gs1_linter.php > backend/gs1_lint.h" */
#include "gs1_lint.h"
/* Whether starts with Digital Link URI */
static int gs1_is_digital_link(const unsigned char *source, const int length) {
return (length >= 8 && (memcmp(source, "https://", 8) == 0 || memcmp(source, "HTTPS://", 8) == 0))
|| (length >= 7 && (memcmp(source, "http://", 7) == 0 || memcmp(source, "HTTP://", 7) == 0));
}
/* If built with GS1 Syntax Engine library */
#ifdef ZINT_HAVE_GS1SE
/* Use GS1 Syntax Engine to verify */
static int gs1se_verify(struct zint_symbol *symbol, const unsigned char source[], const int length,
unsigned char reduced[], int *p_reduced_length) {
int i, j;
const int is_composite = z_is_composite(symbol->symbology);
const int primary_len = is_composite ? (int) strlen(symbol->primary) : 0;
const int gs1parens_mode = symbol->input_mode & GS1PARENS_MODE;
const char obracket = gs1parens_mode ? '(' : '[';
const int parens_cnt = !gs1parens_mode ? z_chr_cnt(source, length, '(') : 0;
int local_length = length;
const unsigned char *local_source = source;
const unsigned char *local_source2 = source;
unsigned char *local_source_buf = (unsigned char *) z_alloca(ARRAY_SIZE(symbol->primary) + length + 1);
unsigned char *local_source2_buf = (unsigned char *) z_alloca(ARRAY_SIZE(symbol->primary) * 2 + length
+ parens_cnt + 1);
int is_digital_link = 0;
gs1_encoder *ctx;
int gs1se_ret;
/* Need "linear|composite" format to check required AIs */
if (is_composite && primary_len) {
if (symbol->symbology == BARCODE_GS1_128_CC || symbol->symbology == BARCODE_DBAR_EXP_CC
|| symbol->symbology == BARCODE_DBAR_EXPSTK_CC) {
memcpy(local_source_buf, symbol->primary, primary_len);
local_source_buf[primary_len] = '|';
memcpy(local_source_buf + 1 + primary_len, source, length + 1); /* Include terminating NUL */
local_length += 1 + primary_len;
} else {
/* Just use dummy "01" linear */
memcpy(local_source_buf, gs1parens_mode ? "(01)12345678901231|" : "[01]12345678901231|", 19);
memcpy(local_source_buf + 19, source, length + 1); /* Include terminating NUL */
local_length += 19;
}
local_source = local_source_buf;
local_source2 = local_source_buf;
}
if (local_source[0] != obracket) {
if (!z_is_fixed_ratio(symbol->symbology)) { /* Only matrix symbols can encode Digital Link URIs */
return z_errtxt(ZINT_ERROR_INVALID_DATA, symbol, 264, "Data does not start with an AI");
}
if (!(is_digital_link = gs1_is_digital_link(local_source, local_length))) {
return z_errtxt(ZINT_ERROR_INVALID_DATA, symbol, 265,
"Data does not start with an AI or a Digital Link URI");
}
}
if (!is_digital_link) {
/* Convert to GS1 Syntax Engine parenthesis mode */
if (!gs1parens_mode) {
/* Replace '[' and ']' with '(' and ')' & escape any data opening parentheses (not closing parentheses) */
int bracket_level = 0; /* Non-compliant closing square brackets may be in text */
for (i = 0, j = 0; i < local_length; i++) {
if (local_source[i] == '[') {
local_source2_buf[j++] = '(';
bracket_level++;
} else if (local_source[i] == ']' && bracket_level) {
local_source2_buf[j++] = ')';
bracket_level--;
} else {
if (local_source[i] == '(') {
local_source2_buf[j++] = '\\';
}
local_source2_buf[j++] = local_source[i];
}
}
local_source2_buf[j] = '\0';
local_source2 = local_source2_buf;
/* Unescape any backslashed closing parentheses */
} else if (strchr(ZCCP(local_source), '\\') != NULL) {
for (i = 0, j = 0; i < local_length; i++) {
if (local_source[i] == '\\' && i + 1 < local_length && local_source[i + 1] == ')') {
i++;
}
local_source2_buf[j++] = local_source[i];
}
local_source2_buf[j] = '\0';
local_source2 = local_source2_buf;
}
}
if (!(ctx = gs1_encoder_init(NULL))) {
return z_errtxt(ZINT_ERROR_MEMORY, symbol, 266, "Insufficient memory for GS1 Syntax Engine");
}
if (is_digital_link) {
gs1se_ret = gs1_encoder_setDataStr(ctx, ZCCP(local_source2));
} else {
gs1se_ret = gs1_encoder_setAIdataStr(ctx, ZCCP(local_source2));
}
if (!gs1se_ret) {
const char *errmsg = gs1_encoder_getErrMsg(ctx);
const int errmsg_len = (int) strlen(errmsg);
const char *errmarkup = gs1_encoder_getErrMarkup(ctx);
int errmarkup_len = (int) strlen(errmarkup);
if (errmarkup_len && errmsg_len + 1 + errmarkup_len < ARRAY_SIZE(symbol->errtxt)) {
char *local_errmarkup = (char *) z_alloca(errmarkup_len * 4 + 1);
z_debug_print_escape(ZCUCP(errmarkup), errmarkup_len, local_errmarkup);
errmarkup_len = (int) strlen(local_errmarkup);
if (errmsg_len + 1 + errmarkup_len < ARRAY_SIZE(symbol->errtxt)) {
ZEXT z_errtxtf(0, symbol, 267, "%1$s %2$s", errmsg, local_errmarkup);
} else {
z_errtxt(0, symbol, 268, errmsg);
}
} else {
z_errtxt(0, symbol, 268, errmsg);
}
gs1_encoder_free(ctx);
return ZINT_ERROR_INVALID_DATA;
}
/* If Digital Link, set `reduced` */
if (is_digital_link) {
const char *scan_data;
gs1_encoder_setSym(ctx, gs1_encoder_sDM); /* Required for `gs1_encoder_getScanData()` */
if (!(scan_data = gs1_encoder_getScanData(ctx))) { /* Shouldn't happen */
const char *errmsg = gs1_encoder_getErrMsg(ctx);
z_errtxt(0, symbol, 269, strlen(errmsg) ? errmsg : "Internal error");
gs1_encoder_free(ctx);
return ZINT_ERROR_ENCODING_PROBLEM;
}
*p_reduced_length = (int) strlen(scan_data);
/* Skip over Symbology Identifier */
if (*p_reduced_length >= 3 && scan_data[0] == ']') {
scan_data += 3;
*p_reduced_length -= 3;
}
memcpy(reduced, scan_data, *p_reduced_length + 1); /* Include terminating NUL */
} else {
*p_reduced_length = 0; /* Not Digital Link & `reduced` not set */
}
gs1_encoder_free(ctx);
return 0;
}
#endif /* ZINT_HAVE_GS1SE */
#define GS1_PARENS_PLACEHOLDER_MASK 0x20 /* Mask `(` or `)` by this if escaped (get BS (\x08) or HT (\x09)) */
/* Verify a GS1 input string */
INTERNAL int zint_gs1_verify(struct zint_symbol *symbol, unsigned char source[], int *p_length,
INTERNAL int zint_gs1_verify(struct zint_symbol *symbol, const unsigned char source[], const int length,
unsigned char reduced[], int *p_reduced_length) {
int i, j;
int error_value = 0;
int bracket_level = 0, max_bracket_level = 0;
int ai_length, ai_latch;
int max_ai_length = 0, min_ai_length = 5;
int max_ai_pos = 0, min_ai_pos = 0; /* Suppress gcc 14 "-Wmaybe-uninitialized" false positives */
int ai_zero_len_no_data = 0, ai_single_digit = 0, ai_nonnumeric = 0;
int ai_nonnumeric_pos = 0; /* Suppress gcc 14 "-Wmaybe-uninitialized" false positive */
int length = *p_length;
const char obracket = symbol->input_mode & GS1PARENS_MODE ? '(' : '[';
const char cbracket = symbol->input_mode & GS1PARENS_MODE ? ')' : ']';
const int ai_max = z_chr_cnt(source, length, obracket) + 1; /* Plus 1 so non-zero */
int *ai_value = (int *) z_alloca(sizeof(int) * ai_max);
int *ai_location = (int *) z_alloca(sizeof(int) * ai_max);
int *data_location = (int *) z_alloca(sizeof(int) * ai_max);
int *data_length = (int *) z_alloca(sizeof(int) * ai_max);
int error_number = 0;
int bracket_level = 0;
int ai_latch;
int local_length = length;
const unsigned char *local_source = source;
unsigned char *local_source_buf = (unsigned char *) z_alloca(length + 1);
const int gs1parens_mode = symbol->input_mode & GS1PARENS_MODE;
const char obracket = gs1parens_mode ? '(' : '[';
const char cbracket = gs1parens_mode ? ')' : ']';
int done_gs1se = 0;
int is_digital_link = 0; /* Is Digital Link? */
assert(p_length != p_reduced_length); /* Make sure we don't overwrite one with the other */
/* Note: Digital Link URIs only validated if have GS1 Syntax Engine and GS1SYNTAXENGINE_MODE set */
/* Detect control and extended ASCII characters */
for (i = 0; i < length; i++) {
if (source[i] >= 128) {
return z_errtxt(ZINT_ERROR_INVALID_DATA, symbol, 250,
"Extended ASCII characters are not supported by GS1");
#ifdef ZINT_HAVE_GS1SE
if ((symbol->input_mode & GS1SYNTAXENGINE_MODE) && !(symbol->input_mode & GS1NOCHECK_MODE)) {
/* Strict verification */
if ((error_number = gs1se_verify(symbol, source, length, reduced, p_reduced_length))) {
return error_number;
}
if (source[i] == '\0') {
return z_errtxt(ZINT_ERROR_INVALID_DATA, symbol, 262, "NUL characters not permitted in GS1 mode");
done_gs1se = 1;
is_digital_link = *p_reduced_length != 0; /* `p_reduced_length` will be set if Digital Link */
}
#endif
if (!done_gs1se) {
/* Detect control and extended ASCII characters */
for (i = 0; i < length; i++) {
if (!z_isascii(source[i])) {
return z_errtxt(ZINT_ERROR_INVALID_DATA, symbol, 250,
"Extended ASCII characters are not supported by GS1");
}
if (source[i] == '\0') {
return z_errtxt(ZINT_ERROR_INVALID_DATA, symbol, 262, "NUL characters not permitted in GS1 mode");
}
if (source[i] < 32) {
return z_errtxt(ZINT_ERROR_INVALID_DATA, symbol, 251, "Control characters are not supported by GS1");
}
if (source[i] == 127) {
return z_errtxt(ZINT_ERROR_INVALID_DATA, symbol, 263, "DEL characters are not supported by GS1");
}
}
if (source[i] < 32) {
return z_errtxt(ZINT_ERROR_INVALID_DATA, symbol, 251, "Control characters are not supported by GS1");
}
if (source[i] == 127) {
return z_errtxt(ZINT_ERROR_INVALID_DATA, symbol, 263, "DEL characters are not supported by GS1");
if (source[0] != obracket) {
if (!z_is_fixed_ratio(symbol->symbology)) { /* Only matrix symbols can encode Digital Link URIs */
return z_errtxt(ZINT_ERROR_INVALID_DATA, symbol, 252, "Data does not start with an AI");
}
if (!(is_digital_link = gs1_is_digital_link(source, length))) {
return z_errtxt(ZINT_ERROR_INVALID_DATA, symbol, 855,
"Data does not start with an AI or Digital Link URI");
}
}
}
if (source[0] != obracket) {
return z_errtxt(ZINT_ERROR_INVALID_DATA, symbol, 252, "Data does not start with an AI");
if (is_digital_link) {
if (!done_gs1se) {
/* Just copy over Digital Link URI - no verification */
memcpy(reduced, source, length + 1); /* Include terminating NUL */
*p_reduced_length = length;
}
return 0;
}
if ((symbol->input_mode & (ESCAPE_MODE | GS1PARENS_MODE)) == (ESCAPE_MODE | GS1PARENS_MODE)) {
if (gs1parens_mode) {
/* Check for escaped parentheses */
for (i = 0; i < length; i++) {
if (source[i] == '\\' && i + 1 < length && (source[i + 1] == '(' || source[i + 1] == ')')) {
@@ -1662,151 +1840,167 @@ INTERNAL int zint_gs1_verify(struct zint_symbol *symbol, unsigned char source[],
}
}
if (i != length) {
local_source = local_source_buf;
/* Replace with control-char placeholders */
for (i = 0, j = 0; i < length; i++) {
if (source[i] == '\\' && i + 1 < length && (source[i + 1] == '(' || source[i + 1] == ')')) {
source[j++] = source[++i] & ~GS1_PARENS_PLACEHOLDER_MASK; /* BS (\x08) or HT (\x09) */
local_source_buf[j++] = source[++i] & ~GS1_PARENS_PLACEHOLDER_MASK; /* BS (\x08) or HT (\x09) */
} else {
source[j++] = source[i];
local_source_buf[j++] = source[i];
}
}
source[j] = '\0';
length = j;
local_source_buf[j] = '\0';
local_length = j;
}
}
/* Check the balance of the brackets & AI lengths */
ai_length = 0;
ai_latch = 0;
for (i = 0; i < length; i++) {
if (source[i] == obracket) {
bracket_level++;
if (bracket_level > max_bracket_level) {
max_bracket_level = bracket_level;
}
ai_latch = 1;
} else if (source[i] == cbracket && bracket_level) {
bracket_level--;
if (ai_length > max_ai_length) {
max_ai_length = ai_length;
max_ai_pos = i - ai_length;
}
if (ai_length < min_ai_length) {
min_ai_length = ai_length;
min_ai_pos = i - ai_length;
}
/* Check zero-length AI has data */
if (ai_length == 0 && (i + 1 == length || source[i + 1] == obracket)) {
ai_zero_len_no_data = 1;
} else if (ai_length == 1) {
ai_single_digit = 1;
}
ai_length = 0;
ai_latch = 0;
} else if (ai_latch) {
ai_length++;
if (!z_isdigit(source[i])) {
ai_nonnumeric = 1;
ai_nonnumeric_pos = i - ai_length + 1;
}
}
}
if (!done_gs1se) {
/* Verify AIs */
int max_ai_length = 0, min_ai_length = 5;
int max_bracket_level = 0;
int ai_length = 0;
int max_ai_pos = 0, min_ai_pos = 0; /* Suppress gcc 14 "-Wmaybe-uninitialized" false positives */
int ai_zero_len_no_data = 0, ai_single_digit = 0, ai_nonnumeric = 0;
int ai_nonnumeric_pos = 0; /* Suppress gcc 14 "-Wmaybe-uninitialized" false positive */
const int ai_max = z_chr_cnt(local_source, local_length, obracket) + 1; /* Plus 1 so non-zero */
int *ai_value = (int *) z_alloca(sizeof(int) * ai_max);
int *ai_location = (int *) z_alloca(sizeof(int) * ai_max);
int *data_location = (int *) z_alloca(sizeof(int) * ai_max);
int *data_length = (int *) z_alloca(sizeof(int) * ai_max);
if (bracket_level != 0) {
/* Not all brackets are closed */
return z_errtxt(ZINT_ERROR_INVALID_DATA, symbol, 253, "Malformed AI in input (brackets don\'t match)");
}
if (max_bracket_level > 1) {
/* Nested brackets */
return z_errtxt(ZINT_ERROR_INVALID_DATA, symbol, 254, "Found nested brackets in input");
}
if (max_ai_length > 4) {
/* AI is too long */
return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 255,
"Invalid AI at position %d in input (AI too long)", max_ai_pos);
}
if (min_ai_length <= 1) {
/* Allow too short AI if GS1NOCHECK_MODE and no single-digit AIs and all zero-length AIs have some data
- permits dummy "[]" workaround for ticket #204 data with no valid AI */
if (!(symbol->input_mode & GS1NOCHECK_MODE) || ai_single_digit || ai_zero_len_no_data) {
/* AI is too short */
return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 256,
"Invalid AI at position %d in input (AI too short)", min_ai_pos);
}
}
if (ai_nonnumeric) {
/* Non-numeric data in AI */
return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 257,
"Invalid AI at position %d in input (non-numeric characters in AI)", ai_nonnumeric_pos);
}
if (!(symbol->input_mode & GS1NOCHECK_MODE)) {
unsigned char *local_source = source;
unsigned char *local_source_buf = (unsigned char *) z_alloca(length + 1);
int ai_count = 0;
for (i = 1; i < length; i++) {
if (source[i - 1] == obracket) {
ai_location[ai_count] = i;
for (j = 1; source[i + j] != cbracket; j++);
ai_value[ai_count] = z_to_int(source + i, j);
ai_count++;
i += j;
}
}
for (i = 0; i < ai_count; i++) {
if (ai_value[i] >= 1000) {
data_location[i] = ai_location[i] + 5;
} else if (ai_value[i] >= 100) {
data_location[i] = ai_location[i] + 4;
} else {
data_location[i] = ai_location[i] + 3;
}
data_length[i] = 0;
while (data_location[i] + data_length[i] < length
&& source[data_location[i] + data_length[i]] != obracket) {
data_length[i]++;
}
if (data_length[i] == 0) {
/* No data for given AI */
return z_errtxt(ZINT_ERROR_INVALID_DATA, symbol, 258, "Empty data field in input");
}
}
if (length != *p_length) {
/* Temporarily re-instate escaped parentheses before linting */
local_source = local_source_buf;
memcpy(local_source, source, length + 1); /* Include terminating NUL */
for (i = 0; i < length; i++) {
if (local_source[i] < '\x1D') {
local_source[i] |= GS1_PARENS_PLACEHOLDER_MASK;
/* Check the balance of the brackets & AI lengths */
ai_latch = 0;
for (i = 0; i < local_length; i++) {
if (local_source[i] == obracket) {
bracket_level++;
if (bracket_level > max_bracket_level) {
max_bracket_level = bracket_level;
}
ai_latch = 1;
} else if (local_source[i] == cbracket && bracket_level) {
bracket_level--;
if (ai_length > max_ai_length) {
max_ai_length = ai_length;
max_ai_pos = i - ai_length;
}
if (ai_length < min_ai_length) {
min_ai_length = ai_length;
min_ai_pos = i - ai_length;
}
/* Check zero-length AI has data */
if (ai_length == 0 && (i + 1 == local_length || local_source[i + 1] == obracket)) {
ai_zero_len_no_data = 1;
} else if (ai_length == 1) {
ai_single_digit = 1;
}
ai_length = 0;
ai_latch = 0;
} else if (ai_latch) {
ai_length++;
if (!z_isdigit(local_source[i])) {
ai_nonnumeric = 1;
ai_nonnumeric_pos = i - ai_length + 1;
}
}
}
/* Check for valid AI values and data lengths according to GS1 General
Specifications Release 25, January 2025 */
for (i = 0; i < ai_count; i++) {
int err_no, err_posn;
char err_msg[50];
if (!gs1_lint(ai_value[i], local_source + data_location[i], data_length[i], &err_no, &err_posn,
err_msg)) {
if (err_no == 1) {
z_errtxtf(0, symbol, 260, "Invalid AI (%02d)", ai_value[i]);
} else if (err_no == 2 || err_no == 4) { /* 4 is backward-incompatible bad length */
z_errtxtf(0, symbol, 259, "Invalid data length for AI (%02d)", ai_value[i]);
if (bracket_level != 0) {
/* Not all brackets are closed */
return z_errtxt(ZINT_ERROR_INVALID_DATA, symbol, 253, "Malformed AI in input (brackets don\'t match)");
}
if (max_bracket_level > 1) {
/* Nested brackets */
return z_errtxt(ZINT_ERROR_INVALID_DATA, symbol, 254, "Found nested brackets in input");
}
if (max_ai_length > 4) {
/* AI is too long */
return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 255,
"Invalid AI at position %d in input (AI too long)", max_ai_pos);
}
if (min_ai_length <= 1) {
/* Allow too short AI if GS1NOCHECK_MODE and no single-digit AIs and all zero-length AIs have some data
- permits dummy "[]" workaround for ticket #204 data with no valid AI */
if (!(symbol->input_mode & GS1NOCHECK_MODE) || ai_single_digit || ai_zero_len_no_data) {
/* AI is too short */
return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 256,
"Invalid AI at position %d in input (AI too short)", min_ai_pos);
}
}
if (ai_nonnumeric) {
/* Non-numeric data in AI */
return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 257,
"Invalid AI at position %d in input (non-numeric characters in AI)", ai_nonnumeric_pos);
}
if (!(symbol->input_mode & GS1NOCHECK_MODE)) {
const unsigned char *local_source2 = local_source;
unsigned char *local_source2_buf = (unsigned char *) z_alloca(local_length + 1);
int ai_count = 0;
for (i = 1; i < local_length; i++) {
if (local_source[i - 1] == obracket) {
ai_location[ai_count] = i;
for (j = 1; local_source[i + j] != cbracket; j++);
ai_value[ai_count] = z_to_int(local_source + i, j);
ai_count++;
i += j;
}
}
for (i = 0; i < ai_count; i++) {
if (ai_value[i] >= 1000) {
data_location[i] = ai_location[i] + 5;
} else if (ai_value[i] >= 100) {
data_location[i] = ai_location[i] + 4;
} else {
ZEXT z_errtxtf(0, symbol, 261, "AI (%1$02d) position %2$d: %3$s", ai_value[i], err_posn, err_msg);
data_location[i] = ai_location[i] + 3;
}
/* For backward compatibility only error on unknown AI or bad length */
if (err_no == 1 || err_no == 2) {
return ZINT_ERROR_INVALID_DATA;
data_length[i] = 0;
while (data_location[i] + data_length[i] < local_length
&& local_source[data_location[i] + data_length[i]] != obracket) {
data_length[i]++;
}
if (data_length[i] == 0) {
/* No data for given AI */
return z_errtxt(ZINT_ERROR_INVALID_DATA, symbol, 258, "Empty data field in input");
}
}
if (local_length != length) {
/* Temporarily re-instate escaped parentheses before linting */
local_source2 = local_source2_buf;
memcpy(local_source2_buf, local_source, local_length + 1); /* Include terminating NUL */
for (i = 0; i < local_length; i++) {
if (local_source2_buf[i] < '\x1D') {
local_source2_buf[i] |= GS1_PARENS_PLACEHOLDER_MASK;
}
}
}
/* Check for valid AI values and data lengths according to GS1 General
Specifications Release 25, January 2025 */
for (i = 0; i < ai_count; i++) {
int err_no, err_posn;
char err_msg[50];
if (!gs1_lint(ai_value[i], local_source2 + data_location[i], data_length[i], &err_no, &err_posn,
err_msg)) {
if (err_no == 1) {
z_errtxtf(0, symbol, 260, "Invalid AI (%02d)", ai_value[i]);
} else if (err_no == 2 || err_no == 4) { /* 4 is backward-incompatible bad length */
z_errtxtf(0, symbol, 259, "Invalid data length for AI (%02d)", ai_value[i]);
} else {
ZEXT z_errtxtf(0, symbol, 261, "AI (%1$02d) position %2$d: %3$s", ai_value[i], err_posn,
err_msg);
}
/* For backward compatibility only error on unknown AI or bad length */
if (err_no == 1 || err_no == 2) {
return ZINT_ERROR_INVALID_DATA;
}
error_number = ZINT_WARN_NONCOMPLIANT;
}
error_value = ZINT_WARN_NONCOMPLIANT;
}
}
}
@@ -1814,53 +2008,47 @@ INTERNAL int zint_gs1_verify(struct zint_symbol *symbol, unsigned char source[],
/* Resolve AI data - put resulting string in 'reduced' */
j = 0;
ai_latch = 1;
for (i = 0; i < length; i++) {
if (source[i] == obracket) {
for (i = 0; i < local_length; i++) {
if (local_source[i] == obracket) {
bracket_level++;
/* Start of an AI string */
if (ai_latch == 0) {
reduced[j++] = '\x1D';
}
if (i + 1 != length) {
int last_ai = z_to_int(source + i + 1, 2);
if (i + 1 != local_length) {
int last_ai = z_to_int(local_source + i + 1, 2);
ai_latch = 0;
/* The following values from GS1 General Specifications Release 25.0
Figure 7.8.5-2 "Element strings with predefined length using GS1 Application Identifiers" */
if ((last_ai >= 0 && last_ai <= 4) || (last_ai >= 11 && last_ai <= 20)
/* NOTE: as noted by Terry Burton the following complies with ISO/IEC 24724:2011 Table D.1,
but clashes with TPX AI [235], introduced May 2019; awaiting feedback from GS1 */
/* NOTE: as noted by Terry Burton the following complies with ISO/IEC 24724:2011 Table
D.1, but clashes with TPX AI [235], introduced May 2019; awaiting feedback from GS1 */
|| last_ai == 23 /* legacy support */ /* TODO: probably remove */
|| (last_ai >= 31 && last_ai <= 36) || last_ai == 41) {
ai_latch = 1;
}
}
} else if (source[i] == cbracket && bracket_level) {
} else if (local_source[i] == cbracket && bracket_level) {
/* The closing bracket is simply dropped from the input */
bracket_level--;
} else {
reduced[j++] = source[i];
reduced[j++] = local_source[i];
}
}
reduced[j] = '\0';
*p_reduced_length = j;
if (length != *p_length) {
if (local_length != length) {
/* Re-instate escaped parentheses */
for (i = 0; i < *p_reduced_length; i++) {
if (reduced[i] < '\x1D') {
reduced[i] |= GS1_PARENS_PLACEHOLDER_MASK;
}
}
for (i = 0; i < length; i++) {
if (source[i] < '\x1D') {
source[i] |= GS1_PARENS_PLACEHOLDER_MASK;
}
}
*p_length = length;
}
/* The character '\x1D' (GS) in the reduced string refers to the FNC1 character */
return error_value;
return error_number;
}
/* Helper to return standard GS1 check digit (GS1 General Specifications 7.9.1) */
+1 -1
View File
@@ -37,7 +37,7 @@
extern "C" {
#endif /* __cplusplus */
INTERNAL int zint_gs1_verify(struct zint_symbol *symbol, unsigned char source[], int *p_length,
INTERNAL int zint_gs1_verify(struct zint_symbol *symbol, const unsigned char source[], const int length,
unsigned char reduced[], int *p_reduced_length);
INTERNAL char zint_gs1_check_digit(const unsigned char source[], const int length);
INTERNAL int zint_gs1_iso3166_alpha2(const unsigned char *cc);
+20 -6
View File
@@ -1192,7 +1192,7 @@ int ZBarcode_Encode_Segs(struct zint_symbol *symbol, const struct zint_seg segs[
if (gs1_compliant(symbol->symbology)) {
/* Reduce input for composite and non-forced symbologies, others (GS1_128 and DBAR_EXP based) will
handle it themselves */
const int have_composite = z_is_composite(symbol->symbology);
const int is_composite = z_is_composite(symbol->symbology);
/* Deal with any ECI first */
if (symbol->eci) {
@@ -1205,15 +1205,20 @@ int ZBarcode_Encode_Segs(struct zint_symbol *symbol, const struct zint_seg segs[
symbologies, as standards are inconsistent in mentioning it */
}
if (have_composite || !check_force_gs1(symbol->symbology)) {
if (is_composite || !check_force_gs1(symbol->symbology)) {
unsigned char *reduced = (unsigned char *) z_alloca(local_segs[0].length + 1);
int source_len = local_segs[0].length;
error_number = zint_gs1_verify(symbol, local_segs[0].source, &source_len, reduced,
error_number = zint_gs1_verify(symbol, local_segs[0].source, local_segs[0].length, reduced,
&local_segs[0].length);
if (error_number) {
if (have_composite) {
#ifdef ZINT_HAVE_GS1SE
if (is_composite && !(symbol->input_mode & GS1SYNTAXENGINE_MODE)) {
z_errtxt_adj(0, symbol, "%1$s%2$s", " (2D component)");
}
#else
if (is_composite) {
z_errtxt_adj(0, symbol, "%1$s%2$s", " (2D component)");
}
#endif
error_number = error_tag(error_number, symbol, -1, NULL);
if (error_number >= ZINT_ERROR) {
return error_number;
@@ -1222,7 +1227,7 @@ int ZBarcode_Encode_Segs(struct zint_symbol *symbol, const struct zint_seg segs[
}
memcpy(local_segs[0].source, reduced, local_segs[0].length + 1); /* Include terminating NUL */
/* Set raw text for non-composites (composites set their own raw text) */
if (!have_composite && raw_text && z_rt_cpy(symbol, reduced, local_segs[0].length)) {
if (!is_composite && raw_text && z_rt_cpy(symbol, reduced, local_segs[0].length)) {
return error_tag(ZINT_ERROR_MEMORY, symbol, -1, NULL); /* `z_rt_cpy()` only fails with OOM */
}
}
@@ -2218,6 +2223,15 @@ int ZBarcode_NoPng(void) {
#endif
}
/* Whether Zint built with GS1 Syntext Engine support */
int ZBarcode_HaveGS1SyntaxEngine(void) {
#ifdef ZINT_HAVE_GS1SE
return 1;
#else
return 0;
#endif
}
/* Return the version of Zint linked to */
int ZBarcode_Version(void) {
#if ZINT_VERSION_BUILD
+1 -1
View File
@@ -1226,7 +1226,7 @@ INTERNAL int zint_dbar_exp_cc(struct zint_symbol *symbol, unsigned char source[]
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT;
const int debug_print = symbol->debug & ZINT_DEBUG_PRINT;
error_number = zint_gs1_verify(symbol, source, &length, reduced, &reduced_length);
error_number = zint_gs1_verify(symbol, source, length, reduced, &reduced_length);
if (error_number >= ZINT_ERROR) {
return error_number;
}
+3
View File
@@ -72,6 +72,9 @@ zint_add_test(gb2312 test_gb2312)
zint_add_test(gif test_gif)
zint_add_test(gridmtx test_gridmtx)
zint_add_test(gs1 test_gs1)
if(ZINT_USE_GS1SE AND NOT GS1SE-NOTFOUND)
zint_add_test(gs1se test_gs1se)
endif()
zint_add_test(hanxin test_hanxin)
zint_add_test(imail test_imail)
zint_add_test(iso3166 test_iso3166)
+1 -1
View File
@@ -306,7 +306,7 @@ static void test_options(const testCtx *const p_ctx) {
/* 25*/ { BARCODE_AZTEC, GS1_MODE, -1, -1, -1, { 0, 0, "" }, "[91]A", 0, 15, 15, "", (41 << 8) | 3, 1 },
/* 26*/ { BARCODE_AZTEC, GS1_MODE | GS1PARENS_MODE, -1, -1, -1, { 0, 0, "" }, "(91)A", 0, 15, 15, "", (41 << 8) | 3, 1 },
/* 27*/ { BARCODE_AZTEC, GS1_MODE | GS1PARENS_MODE, -1, -1, -1, { 0, 0, "" }, "(91)(", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 253: Malformed AI in input (brackets don't match)", -1, 0 },
/* 28*/ { BARCODE_AZTEC, GS1_MODE | GS1PARENS_MODE, -1, -1, -1, { 0, 0, "" }, "(91)\\(", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 253: Malformed AI in input (brackets don't match)", -1, 0 },
/* 28*/ { BARCODE_AZTEC, GS1_MODE | GS1PARENS_MODE, -1, -1, -1, { 0, 0, "" }, "(91)\\(", 0, 15, 15, "", (41 << 8) | 3, 1 }, /* Escaped parens now work without ESCAPE_MODE */
/* 29*/ { BARCODE_AZTEC, GS1_MODE | ESCAPE_MODE | GS1PARENS_MODE, -1, -1, -1, { 0, 0, "" }, "(91)\\(", 0, 15, 15, "", (41 << 8) | 3, 1 },
/* 30*/ { BARCODE_AZTEC, -1, READER_INIT, -1, 26, { 0, 0, "" }, "A", 0, 109, 109, "", (99 << 8) | 4, 26 }, /* 22 layers */
/* 31*/ { BARCODE_AZTEC, -1, READER_INIT, -1, 27, { 0, 0, "" }, "A", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 709: Version '27' out of range for Reader Initialisation symbols (maximum 26)", -1, 27 }, /* 23 layers */
+2 -3
View File
@@ -688,7 +688,7 @@ static void test_options(const testCtx *const p_ctx) {
/* 81*/ { BARCODE_DATAMATRIX, GS1_MODE | GS1PARENS_MODE, -1, -1, -1, -1, { 0, 0, "" }, "(90)12", 0, 10, 10, "", 1, 1, "" },
/* 82*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, -1, -1, -1, { 0, 0, "" }, "[90](", 0, 10, 10, "", 1, 1, "" },
/* 83*/ { BARCODE_DATAMATRIX, GS1_MODE | GS1PARENS_MODE, -1, -1, -1, -1, { 0, 0, "" }, "(90)(", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 253: Malformed AI in input (brackets don't match)", 0, 1, "" },
/* 84*/ { BARCODE_DATAMATRIX, GS1_MODE | GS1PARENS_MODE, -1, -1, -1, -1, { 0, 0, "" }, "(90)\\(", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 253: Malformed AI in input (brackets don't match)", 0, 1, "" },
/* 84*/ { BARCODE_DATAMATRIX, GS1_MODE | GS1PARENS_MODE, -1, -1, -1, -1, { 0, 0, "" }, "(90)\\(", 0, 10, 10, "", 1, 1, "" }, /* Escaped parens now work without ESCAPE_MODE */
/* 85*/ { BARCODE_DATAMATRIX, GS1_MODE | ESCAPE_MODE | GS1PARENS_MODE, -1, -1, -1, -1, { 0, 0, "" }, "(90)\\(", 0, 10, 10, "", 1, 1, "" },
/* 86*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, { 1, 2, "" }, "1", 0, 12, 12, "", 2, 1, "" },
/* 87*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, { 16, 16, "" }, "1", 0, 12, 12, "", 2, 1, "" },
@@ -1319,8 +1319,7 @@ static void test_input(const testCtx *const p_ctx) {
i, expected_rows_width, prev_expected_rows_width);
if ((data[i].input_mode & 0x07) == GS1_MODE) {
int data_len = length;
ret = zint_gs1_verify(symbol, ZUCP(data[i].data), &data_len, reduced, &length);
ret = zint_gs1_verify(symbol, ZUCP(data[i].data), length, reduced, &length);
assert_zero(ret, "i:%d zint_gs1_verify() ret %d != 0 (%s)\n", i, ret, symbol->errtxt);
text = reduced;
} else {
+203 -190
View File
@@ -395,77 +395,88 @@ static void test_hrt(const testCtx *const p_ctx) {
/* 31*/ { BARCODE_GS1_128_CC, -1, -1, "[01]12345678901234[20]12", "[21]12345", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234(20)12", "" }, /* Incorrect check digit */
/* 32*/ { BARCODE_GS1_128, -1, -1, "[91]ABCDEF)GH", "", 0, "(91)ABCDEF)GH", "" },
/* 33*/ { BARCODE_GS1_128, -1, BARCODE_RAW_TEXT, "[91]ABCDEF)GH", "", 0, "(91)ABCDEF)GH", "91ABCDEF)GH" },
/* 34*/ { BARCODE_GS1_128, ESCAPE_MODE | GS1PARENS_MODE, -1, "(91)ABCDEF\\)GH", "", 0, "(91)ABCDEF)GH", "" },
/* 35*/ { BARCODE_GS1_128, ESCAPE_MODE | GS1PARENS_MODE, BARCODE_RAW_TEXT, "(91)ABCDEF\\)GH", "", 0, "(91)ABCDEF)GH", "91ABCDEF)GH" },
/* 36*/ { BARCODE_GS1_128, -1, -1, "[91]ABCDEF(GH", "", 0, "(91)ABCDEF(GH", "" },
/* 37*/ { BARCODE_GS1_128, -1, BARCODE_RAW_TEXT, "[91]ABCDEF(GH", "", 0, "(91)ABCDEF(GH", "91ABCDEF(GH" },
/* 38*/ { BARCODE_GS1_128, ESCAPE_MODE | GS1PARENS_MODE, -1, "(91)ABCDEF\\(GH", "", 0, "(91)ABCDEF(GH", "" },
/* 39*/ { BARCODE_GS1_128, ESCAPE_MODE | GS1PARENS_MODE, BARCODE_RAW_TEXT, "(91)ABCDEF\\(GH", "", 0, "(91)ABCDEF(GH", "91ABCDEF(GH" },
/* 40*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, "[01]12345678901234[20]12", "[21]12345", 0, "(01)12345678901234(20)12", "" },
/* 41*/ { BARCODE_GS1_128_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901234[20]12", "[21]12345", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234(20)12", "01123456789012342012|2112345" },
/* 42*/ { BARCODE_GS1_128_CC, -1, -1, "[01]12345678901231[20]12", "[21]12345", 0, "(01)12345678901231(20)12", "" },
/* 43*/ { BARCODE_GS1_128_CC, -1, -1, "[01]12345678901231[10]12[20]AB", "[21]12345", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231(10)12(20)AB", "" }, /* AI (20) should be 2 nos. */
/* 44*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, "[01]12345678901231[10]12[20]AB", "[21]12345", 0, "(01)12345678901231(10)12(20)AB", "" },
/* 45*/ { BARCODE_GS1_128_CC, -1, -1, "[01]12345678901231[10]AB[20]12", "[21]12345", 0, "(01)12345678901231(10)AB(20)12", "" },
/* 46*/ { BARCODE_GS1_128_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12", "[21]12345", 0, "(01)12345678901231(10)AB(20)12", "011234567890123110AB\0352012|2112345" },
/* 47*/ { BARCODE_GS1_128_CC, -1, -1, "[01]12345678901231[10]AB[20]12", "[30]1234567A", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231(10)AB(20)12", "" },
/* 48*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, "[01]12345678901231[10]AB[20]12", "[30]1234567A", 0, "(01)12345678901231(10)AB(20)12", "" },
/* 49*/ { BARCODE_EAN14, -1, -1, "1234567890123", "", 0, "(01)12345678901231", "" },
/* 50*/ { BARCODE_EAN14, -1, BARCODE_RAW_TEXT, "1234567890123", "", 0, "(01)12345678901231", "0112345678901231" },
/* 51*/ { BARCODE_EAN14, -1, -1, "1234", "", 0, "(01)00000000012348", "" },
/* 52*/ { BARCODE_EAN14, -1, BARCODE_RAW_TEXT, "1234", "", 0, "(01)00000000012348", "0100000000012348" },
/* 53*/ { BARCODE_EAN14, -1, -1, "12345", "", 0, "(01)00000000123457", "" },
/* 54*/ { BARCODE_EAN14, -1, -1, "12340", "", 0, "(01)00000000123402", "" },
/* 55*/ { BARCODE_NVE18, -1, -1, "12345678901234567", "", 0, "(00)123456789012345675", "" },
/* 56*/ { BARCODE_NVE18, -1, BARCODE_RAW_TEXT, "12345678901234567", "", 0, "(00)123456789012345675", "00123456789012345675" },
/* 57*/ { BARCODE_NVE18, -1, -1, "1234", "", 0, "(00)000000000000012348", "" },
/* 58*/ { BARCODE_NVE18, -1, BARCODE_RAW_TEXT, "1234", "", 0, "(00)000000000000012348", "00000000000000012348" },
/* 59*/ { BARCODE_NVE18, -1, -1, "12345", "", 0, "(00)000000000000123457", "" },
/* 60*/ { BARCODE_NVE18, -1, -1, "12340", "", 0, "(00)000000000000123402", "" },
/* 61*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234(20)12", "" }, /* Incorrect check digit */
/* 62*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, "[01]12345678901234[20]12", "", 0, "(01)12345678901234(20)12", "" },
/* 63*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234(20)12", "01123456789012342012" },
/* 64*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[20]12", "", 0, "(01)12345678901231(20)12", "" },
/* 65*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[20]12", "", 0, "(01)12345678901231(20)12", "01123456789012312012" },
/* 66*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]12[20]AB", "", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231(10)12(20)AB", "" }, /* AI (20) should be 2 nos. */
/* 67*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, "[01]12345678901231[10]12[20]AB", "", 0, "(01)12345678901231(10)12(20)AB", "" },
/* 68*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]12[20]AB", "", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231(10)12(20)AB", "01123456789012311012\03520AB" },
/* 69*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]AB[20]12", "", 0, "(01)12345678901231(10)AB(20)12", "" },
/* 70*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12", "", 0, "(01)12345678901231(10)AB(20)12", "011234567890123110AB\0352012" },
/* 71*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC(2012", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC(2012", "" },
/* 72*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12[90]ABC(2012", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC(2012", "011234567890123110AB\035201290ABC(2012" },
/* 73*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC20)12", "" },
/* 74*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC20)12", "011234567890123110AB\035201290ABC20)12" },
/* 75*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC(20)12", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC(20)12", "" },
/* 76*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12[90]ABC(20)12", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC(20)12", "011234567890123110AB\035201290ABC(20)12" },
/* 77*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC(20)12[91]12(", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC(20)12(91)12(" , ""},
/* 78*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12[90]ABC(20)12[91]12(", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC(20)12(91)12(" , "011234567890123110AB\035201290ABC(20)12\0359112(" },
/* 79*/ { BARCODE_DBAR_EXP_CC, -1, -1, "[01]12345678901234", "[21]12345", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234", "" },
/* 80*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, -1, "[01]12345678901234", "[21]12345", 0, "(01)12345678901234", "" },
/* 81*/ { BARCODE_DBAR_EXP_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901234", "[21]12345", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234", "0112345678901234|2112345" },
/* 82*/ { BARCODE_DBAR_EXP_CC, -1, -1, "[01]12345678901231", "[21]12345", 0, "(01)12345678901231", "" },
/* 83*/ { BARCODE_DBAR_EXP_CC, -1, -1, "[01]12345678901231[20]12[21]12345", "[21]12345", 0, "(01)12345678901231(20)12(21)12345", "" },
/* 84*/ { BARCODE_DBAR_EXP_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901231[20]12[21]12345", "[21]12345", 0, "(01)12345678901231(20)12(21)12345", "011234567890123120122112345|2112345" },
/* 85*/ { BARCODE_DBAR_EXP_CC, -1, -1, "[01]12345678901231[10](", "[21]123()", 0, "(01)12345678901231(10)(", "" },
/* 86*/ { BARCODE_DBAR_EXP_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10](", "[21]123()", 0, "(01)12345678901231(10)(", "011234567890123110(|21123()" },
/* 87*/ { BARCODE_DBAR_EXP_CC, ESCAPE_MODE | GS1PARENS_MODE, -1, "(01)12345678901231(10)\\(", "(21)123\\(\\)", 0, "(01)12345678901231(10)(", "" },
/* 88*/ { BARCODE_DBAR_EXP_CC, ESCAPE_MODE | GS1PARENS_MODE, BARCODE_RAW_TEXT, "(01)12345678901231(10)\\(", "(21)123\\(\\)", 0, "(01)12345678901231(10)(", "011234567890123110(|21123()" },
/* 89*/ { BARCODE_DBAR_EXPSTK, -1, -1, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "", "" },
/* 90*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, -1, "[01]12345678901234[20]12", "", 0, "", "" },
/* 91*/ { BARCODE_DBAR_EXPSTK, -1, BARCODE_RAW_TEXT, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "", "01123456789012342012" },
/* 92*/ { BARCODE_DBAR_EXPSTK, -1, -1, "[01]12345678901231[20]12", "", 0, "", "" },
/* 93*/ { BARCODE_DBAR_EXPSTK, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "", 0, "", "" },
/* 94*/ { BARCODE_DBAR_EXPSTK, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "", 0, "", "011234567890123110AB\035201290ABC20)12" },
/* 95*/ { BARCODE_DBAR_EXPSTK, ESCAPE_MODE | GS1PARENS_MODE, -1, "(01)12345678901231(10)AB(20)12(90)ABC20\\)12", "", 0, "", "" },
/* 96*/ { BARCODE_DBAR_EXPSTK, ESCAPE_MODE | GS1PARENS_MODE, BARCODE_RAW_TEXT, "(01)12345678901231(10)AB(20)12(90)ABC20\\)12", "", 0, "", "011234567890123110AB\035201290ABC20)12" },
/* 97*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, "[01]12345678901234[20]12", "[21]12345", ZINT_WARN_NONCOMPLIANT, "" , ""},
/* 98*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, -1, "[01]12345678901234[20]12", "[21]12345", 0, "", "" },
/* 99*/ { BARCODE_DBAR_EXPSTK_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901234[20]12", "[21]12345", ZINT_WARN_NONCOMPLIANT, "", "01123456789012342012|2112345" },
/*100*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, "[01]12345678901231[20]12", "[21]12345", 0, "", "" },
/*101*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "[21]12345", 0, "", "" },
/*102*/ { BARCODE_DBAR_EXPSTK_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "[21]12345", 0, "", "011234567890123110AB\035201290ABC20)12|2112345" },
/*103*/ { BARCODE_DBAR_EXPSTK_CC, ESCAPE_MODE | GS1PARENS_MODE, -1, "(01)12345678901231(10)AB(20)12(90)ABC20\\)12", "(21)12345", 0, "", "" },
/*104*/ { BARCODE_DBAR_EXPSTK_CC, ESCAPE_MODE | GS1PARENS_MODE, BARCODE_RAW_TEXT, "(01)12345678901231(10)AB(20)12(90)ABC20\\)12", "(21)12345", 0, "", "011234567890123110AB\035201290ABC20)12|2112345" },
/* 34*/ { BARCODE_GS1_128, GS1PARENS_MODE, -1, "(91)ABCDEF\\)GH", "", 0, "(91)ABCDEF\\)GH", "" }, /* Escaped parens now work without ESCAPE_MODE & now kept in HRT */
/* 35*/ { BARCODE_GS1_128, ESCAPE_MODE | GS1PARENS_MODE, -1, "(91)ABCDEF\\)GH", "", 0, "(91)ABCDEF\\)GH", "" }, /* Escaped parens now kept in HRT */
/* 36*/ { BARCODE_GS1_128, GS1PARENS_MODE, BARCODE_RAW_TEXT, "(91)ABCDEF\\)GH", "", 0, "(91)ABCDEF\\)GH", "91ABCDEF)GH" },
/* 37*/ { BARCODE_GS1_128, ESCAPE_MODE | GS1PARENS_MODE, BARCODE_RAW_TEXT, "(91)ABCDEF\\)GH", "", 0, "(91)ABCDEF\\)GH", "91ABCDEF)GH" },
/* 38*/ { BARCODE_GS1_128, -1, -1, "[91]ABCDEF(GH", "", 0, "(91)ABCDEF(GH", "" },
/* 39*/ { BARCODE_GS1_128, -1, BARCODE_RAW_TEXT, "[91]ABCDEF(GH", "", 0, "(91)ABCDEF(GH", "91ABCDEF(GH" },
/* 40*/ { BARCODE_GS1_128, GS1PARENS_MODE, -1, "(91)ABCDEF\\(GH", "", 0, "(91)ABCDEF\\(GH", "" },
/* 41*/ { BARCODE_GS1_128, ESCAPE_MODE | GS1PARENS_MODE, -1, "(91)ABCDEF\\(GH", "", 0, "(91)ABCDEF\\(GH", "" },
/* 42*/ { BARCODE_GS1_128, GS1PARENS_MODE, BARCODE_RAW_TEXT, "(91)ABCDEF\\(GH", "", 0, "(91)ABCDEF\\(GH", "91ABCDEF(GH" },
/* 43*/ { BARCODE_GS1_128, ESCAPE_MODE | GS1PARENS_MODE, BARCODE_RAW_TEXT, "(91)ABCDEF\\(GH", "", 0, "(91)ABCDEF\\(GH", "91ABCDEF(GH" },
/* 44*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, "[01]12345678901234[20]12", "[21]12345", 0, "(01)12345678901234(20)12", "" },
/* 45*/ { BARCODE_GS1_128_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901234[20]12", "[21]12345", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234(20)12", "01123456789012342012|2112345" },
/* 46*/ { BARCODE_GS1_128_CC, -1, -1, "[01]12345678901231[20]12", "[21]12345", 0, "(01)12345678901231(20)12", "" },
/* 47*/ { BARCODE_GS1_128_CC, -1, -1, "[01]12345678901231[10]12[20]AB", "[21]12345", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231(10)12(20)AB", "" }, /* AI (20) should be 2 nos. */
/* 48*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, "[01]12345678901231[10]12[20]AB", "[21]12345", 0, "(01)12345678901231(10)12(20)AB", "" },
/* 49*/ { BARCODE_GS1_128_CC, -1, -1, "[01]12345678901231[10]AB[20]12", "[21]12345", 0, "(01)12345678901231(10)AB(20)12", "" },
/* 50*/ { BARCODE_GS1_128_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12", "[21]12345", 0, "(01)12345678901231(10)AB(20)12", "011234567890123110AB\0352012|2112345" },
/* 51*/ { BARCODE_GS1_128_CC, -1, -1, "[01]12345678901231[10]AB[20]12", "[30]1234567A", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231(10)AB(20)12", "" },
/* 52*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, "[01]12345678901231[10]AB[20]12", "[30]1234567A", 0, "(01)12345678901231(10)AB(20)12", "" },
/* 53*/ { BARCODE_EAN14, -1, -1, "1234567890123", "", 0, "(01)12345678901231", "" },
/* 54*/ { BARCODE_EAN14, -1, BARCODE_RAW_TEXT, "1234567890123", "", 0, "(01)12345678901231", "0112345678901231" },
/* 55*/ { BARCODE_EAN14, -1, -1, "1234", "", 0, "(01)00000000012348", "" },
/* 56*/ { BARCODE_EAN14, -1, BARCODE_RAW_TEXT, "1234", "", 0, "(01)00000000012348", "0100000000012348" },
/* 57*/ { BARCODE_EAN14, -1, -1, "12345", "", 0, "(01)00000000123457", "" },
/* 58*/ { BARCODE_EAN14, -1, -1, "12340", "", 0, "(01)00000000123402", "" },
/* 59*/ { BARCODE_NVE18, -1, -1, "12345678901234567", "", 0, "(00)123456789012345675", "" },
/* 60*/ { BARCODE_NVE18, -1, BARCODE_RAW_TEXT, "12345678901234567", "", 0, "(00)123456789012345675", "00123456789012345675" },
/* 61*/ { BARCODE_NVE18, -1, -1, "1234", "", 0, "(00)000000000000012348", "" },
/* 62*/ { BARCODE_NVE18, -1, BARCODE_RAW_TEXT, "1234", "", 0, "(00)000000000000012348", "00000000000000012348" },
/* 63*/ { BARCODE_NVE18, -1, -1, "12345", "", 0, "(00)000000000000123457", "" },
/* 64*/ { BARCODE_NVE18, -1, -1, "12340", "", 0, "(00)000000000000123402", "" },
/* 65*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234(20)12", "" }, /* Incorrect check digit */
/* 66*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, "[01]12345678901234[20]12", "", 0, "(01)12345678901234(20)12", "" },
/* 67*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234(20)12", "01123456789012342012" },
/* 68*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[20]12", "", 0, "(01)12345678901231(20)12", "" },
/* 69*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[20]12", "", 0, "(01)12345678901231(20)12", "01123456789012312012" },
/* 70*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]12[20]AB", "", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231(10)12(20)AB", "" }, /* AI (20) should be 2 nos. */
/* 71*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, "[01]12345678901231[10]12[20]AB", "", 0, "(01)12345678901231(10)12(20)AB", "" },
/* 72*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]12[20]AB", "", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231(10)12(20)AB", "01123456789012311012\03520AB" },
/* 73*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]AB[20]12", "", 0, "(01)12345678901231(10)AB(20)12", "" },
/* 74*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12", "", 0, "(01)12345678901231(10)AB(20)12", "011234567890123110AB\0352012" },
/* 75*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC(2012", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC(2012", "" },
/* 76*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12[90]ABC(2012", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC(2012", "011234567890123110AB\035201290ABC(2012" },
/* 77*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC20)12", "" },
/* 78*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC20)12", "011234567890123110AB\035201290ABC20)12" },
/* 79*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC(20)12", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC(20)12", "" },
/* 80*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12[90]ABC(20)12", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC(20)12", "011234567890123110AB\035201290ABC(20)12" },
/* 81*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC(20)12[91]12(", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC(20)12(91)12(" , ""},
/* 82*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12[90]ABC(20)12[91]12(", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC(20)12(91)12(" , "011234567890123110AB\035201290ABC(20)12\0359112(" },
/* 83*/ { BARCODE_DBAR_EXP_CC, -1, -1, "[01]12345678901234", "[21]12345", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234", "" },
/* 84*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, -1, "[01]12345678901234", "[21]12345", 0, "(01)12345678901234", "" },
/* 85*/ { BARCODE_DBAR_EXP_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901234", "[21]12345", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234", "0112345678901234|2112345" },
/* 86*/ { BARCODE_DBAR_EXP_CC, -1, -1, "[01]12345678901231", "[21]12345", 0, "(01)12345678901231", "" },
/* 87*/ { BARCODE_DBAR_EXP_CC, -1, -1, "[01]12345678901231[20]12[21]12345", "[21]12345", 0, "(01)12345678901231(20)12(21)12345", "" },
/* 88*/ { BARCODE_DBAR_EXP_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901231[20]12[21]12345", "[21]12345", 0, "(01)12345678901231(20)12(21)12345", "011234567890123120122112345|2112345" },
/* 89*/ { BARCODE_DBAR_EXP_CC, -1, -1, "[01]12345678901231[10](", "[21]123()", 0, "(01)12345678901231(10)(", "" },
/* 90*/ { BARCODE_DBAR_EXP_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10](", "[21]123()", 0, "(01)12345678901231(10)(", "011234567890123110(|21123()" },
/* 91*/ { BARCODE_DBAR_EXP_CC, GS1PARENS_MODE, -1, "(01)12345678901231(10)\\(", "(21)123\\(\\)", 0, "(01)12345678901231(10)\\(", "" }, /* Escaped parens now work without ESCAPE_MODE & now kept in HRT */
/* 92*/ { BARCODE_DBAR_EXP_CC, ESCAPE_MODE | GS1PARENS_MODE, -1, "(01)12345678901231(10)\\(", "(21)123\\(\\)", 0, "(01)12345678901231(10)\\(", "" },
/* 93*/ { BARCODE_DBAR_EXP_CC, GS1PARENS_MODE, BARCODE_RAW_TEXT, "(01)12345678901231(10)\\(", "(21)123\\(\\)", 0, "(01)12345678901231(10)\\(", "011234567890123110(|21123()" },
/* 94*/ { BARCODE_DBAR_EXP_CC, ESCAPE_MODE | GS1PARENS_MODE, BARCODE_RAW_TEXT, "(01)12345678901231(10)\\(", "(21)123\\(\\)", 0, "(01)12345678901231(10)\\(", "011234567890123110(|21123()" },
/* 95*/ { BARCODE_DBAR_EXPSTK, -1, -1, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "", "" },
/* 96*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, -1, "[01]12345678901234[20]12", "", 0, "", "" },
/* 97*/ { BARCODE_DBAR_EXPSTK, -1, BARCODE_RAW_TEXT, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "", "01123456789012342012" },
/* 98*/ { BARCODE_DBAR_EXPSTK, -1, -1, "[01]12345678901231[20]12", "", 0, "", "" },
/* 99*/ { BARCODE_DBAR_EXPSTK, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "", 0, "", "" },
/*100*/ { BARCODE_DBAR_EXPSTK, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "", 0, "", "011234567890123110AB\035201290ABC20)12" },
/*101*/ { BARCODE_DBAR_EXPSTK, GS1PARENS_MODE, -1, "(01)12345678901231(10)AB(20)12(90)ABC20\\)12", "", 0, "", "" },
/*102*/ { BARCODE_DBAR_EXPSTK, ESCAPE_MODE | GS1PARENS_MODE, -1, "(01)12345678901231(10)AB(20)12(90)ABC20\\)12", "", 0, "", "" },
/*103*/ { BARCODE_DBAR_EXPSTK, GS1PARENS_MODE, BARCODE_RAW_TEXT, "(01)12345678901231(10)AB(20)12(90)ABC20\\)12", "", 0, "", "011234567890123110AB\035201290ABC20)12" },
/*104*/ { BARCODE_DBAR_EXPSTK, ESCAPE_MODE | GS1PARENS_MODE, BARCODE_RAW_TEXT, "(01)12345678901231(10)AB(20)12(90)ABC20\\)12", "", 0, "", "011234567890123110AB\035201290ABC20)12" },
/*105*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, "[01]12345678901234[20]12", "[21]12345", ZINT_WARN_NONCOMPLIANT, "" , ""},
/*106*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, -1, "[01]12345678901234[20]12", "[21]12345", 0, "", "" },
/*107*/ { BARCODE_DBAR_EXPSTK_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901234[20]12", "[21]12345", ZINT_WARN_NONCOMPLIANT, "", "01123456789012342012|2112345" },
/*108*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, "[01]12345678901231[20]12", "[21]12345", 0, "", "" },
/*109*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "[21]12345", 0, "", "" },
/*110*/ { BARCODE_DBAR_EXPSTK_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "[21]12345", 0, "", "011234567890123110AB\035201290ABC20)12|2112345" },
/*111*/ { BARCODE_DBAR_EXPSTK_CC, GS1PARENS_MODE, -1, "(01)12345678901231(10)AB(20)12(90)ABC20\\)12", "(21)12345", 0, "", "" },
/*112*/ { BARCODE_DBAR_EXPSTK_CC, ESCAPE_MODE | GS1PARENS_MODE, -1, "(01)12345678901231(10)AB(20)12(90)ABC20\\)12", "(21)12345", 0, "", "" },
/*113*/ { BARCODE_DBAR_EXPSTK_CC, GS1PARENS_MODE, -1, "(01)12345678901231(10)AB(20)12(90)ABC20\\)12", "(21)12345", 0, "", "" },
/*114*/ { BARCODE_DBAR_EXPSTK_CC, ESCAPE_MODE | GS1PARENS_MODE, BARCODE_RAW_TEXT, "(01)12345678901231(10)AB(20)12(90)ABC20\\)12", "(21)12345", 0, "", "011234567890123110AB\035201290ABC20)12|2112345" },
/*115*/ { BARCODE_DBAR_EXPSTK_CC, GS1PARENS_MODE, BARCODE_RAW_TEXT, "(01)12345678901231(10)AB(20)12(90)ABC20\\)12", "(21)12345", 0, "", "011234567890123110AB\035201290ABC20)12|2112345" },
};
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
@@ -497,7 +508,7 @@ static void test_hrt(const testCtx *const p_ctx) {
ret = ZBarcode_Encode(symbol, TCU(text), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n",
i, data[i].ret, ret, symbol->errtxt);
i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d\n",
i, symbol->text_length, expected_length);
@@ -1584,7 +1595,7 @@ static void test_gs1_verify(const testCtx *const p_ctx) {
length = (int) strlen(data[i].data);
ret = zint_gs1_verify(symbol, ZUCP(data[i].data), &length, ZUCP(reduced), &reduced_length);
ret = zint_gs1_verify(symbol, ZUCP(data[i].data), length, ZUCP(reduced), &reduced_length);
if (p_ctx->generate) {
printf(" /*%3d*/ { \"%s\", %s, \"%s\", \"%s\" },\n",
@@ -2294,7 +2305,7 @@ static void test_gs1_lint(const testCtx *const p_ctx) {
length = (int) strlen(data[i].data);
ret = zint_gs1_verify(symbol, ZUCP(data[i].data), &length, ZUCP(reduced), &reduced_length);
ret = zint_gs1_verify(symbol, ZUCP(data[i].data), length, ZUCP(reduced), &reduced_length);
assert_equal(ret, data[i].ret, "i:%d ret %d != %d (length %d \"%s\") (%s)\n",
i, ret, data[i].ret, length, data[i].data, symbol->errtxt);
@@ -2595,122 +2606,124 @@ static void test_gs1nocheck_mode(const testCtx *const p_ctx) {
/* 63*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]12345678901231", "[20]123", 0, "" },
/* 64*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901231", "[20]1A", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (20) position 2: Non-numeric character 'A' (2D component)" },
/* 65*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]12345678901231", "[20]1A", 0, "" },
/* 66*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (2D component)" },
/* 67*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (2D component)" }, /* Nonprintable ASCII still checked */
/* 68*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121\200", "[20]12", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (linear component)" },
/* 69*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121\200", "[20]12", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (linear component)" },
/* 70*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[20]1\200", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (2D component)" },
/* 71*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]1\200", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (2D component)" }, /* Extended ASCII still checked */
/* 72*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "2012", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI (2D component)" },
/* 73*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "2012", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI (2D component)" }, /* Format still checked */
/* 74*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[20]", ZINT_ERROR_INVALID_DATA, "Error 258: Empty data field in input (2D component)" },
/* 75*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]", 0, "" }, /* Zero-length data not checked */
/* 76*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[2]12", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" },
/* 77*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[2]12", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, /* Length 1 AI still checked */
/* 78*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[]12", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" },
/* 79*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[]12", 0, "" }, /* Length 0 AI with data not checked */
/* 80*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[1]2[]1", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 5 in input (AI too short) (2D component)" },
/* 81*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[1]2[]1", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 5 in input (AI too short) (2D component)" }, /* Length 1 AI still checked */
/* 82*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[]", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" },
/* 83*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[]", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, /* Length 0 AI with no data still checked */
/* 84*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[][20]12", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" },
/* 85*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[][20]12", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, /* Length 0 AI with no data still checked */
/* 86*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[20]12[]", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 7 in input (AI too short) (2D component)" },
/* 87*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]12[]", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 7 in input (AI too short) (2D component)" }, /* Length 0 AI with no data still checked */
/* 88*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901231", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 441: Invalid character in input (2D component)" },
/* 89*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]12345678901231", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 441: Invalid character in input (2D component)" }, /* Non-CSET 82 always checked for composite data */
/* 90*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231", "", 0, "" },
/* 91*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[01]12345678901231", "", 0, "" },
/* 92*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231[10]123[11]1234", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11)" },
/* 93*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]1234", "", 0, "" },
/* 94*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231[10]123[11]1234A", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11)" },
/* 95*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]1234A", "", 0, "" },
/* 96*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231[10]123[11]12345A", "", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (11) position 6: Non-numeric character 'A'" },
/* 97*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]12345A", "", 0, "" },
/* 98*/ { BARCODE_DBAR_EXP, -1, "[01]1234567890121\177", "", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1" },
/* 99*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[01]1234567890121\177", "", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1" }, /* Nonprintable ASCII still checked */
/*100*/ { BARCODE_DBAR_EXP, -1, "[01]1234567890121\200", "", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1" },
/*101*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[01]1234567890121\200", "", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1" }, /* Extended ASCII still checked */
/*102*/ { BARCODE_DBAR_EXP, -1, "011234567890121", "", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI" },
/*103*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "011234567890121", "", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI" }, /* Format still checked */
/*104*/ { BARCODE_DBAR_EXP, -1, "[10]", "", ZINT_ERROR_INVALID_DATA, "Error 258: Empty data field in input" },
/*105*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[10]", "", 0, "" }, /* Zero-length data not checked */
/*106*/ { BARCODE_DBAR_EXP, -1, "[2]1", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" },
/*107*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[2]1", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, /* Length 1 AI still checked */
/*108*/ { BARCODE_DBAR_EXP, -1, "[]1", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" },
/*109*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[]1", "", 0, "" }, /* Length 0 AI with data not checked */
/*110*/ { BARCODE_DBAR_EXP, -1, "[]", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" },
/*111*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[]", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, /* Length 0 AI with no data still checked */
/*112*/ { BARCODE_DBAR_EXP, -1, "[20]12[]", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 7 in input (AI too short)" },
/*113*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[20]12[]", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 7 in input (AI too short)" }, /* Length 0 AI with no data still checked */
/*114*/ { BARCODE_DBAR_EXP, -1, "[90]12]34", "", ZINT_ERROR_INVALID_DATA, "Error 386: Invalid character in General Field data" },
/*115*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[90]12]34", "", ZINT_ERROR_INVALID_DATA, "Error 386: Invalid character in General Field data" }, /* Non-CSET 82 always checked for DBAR_EXP */
/*116*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345", 0, "" },
/*117*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]123456789012[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345", 0, "" },
/*118*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231[10]123[11]1234", "[21]ABC123[22]12345", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11) (linear component)" },
/*119*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]1234", "[21]ABC123[22]12345", 0, "" },
/*120*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231[10]123[11]123456", "[21]ABC123[22]12345", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (11) position 3: Invalid month '34' (linear component)" },
/*121*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]123456", "[21]ABC123[22]12345", 0, "" },
/*122*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]123456789", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (30) (2D component)" },
/*123*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]123456789012[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]123456789", 0, "" },
/*124*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]1234567A", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (30) position 8: Non-numeric character 'A' (2D component)" },
/*125*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]123456789012[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]1234567A", 0, "" },
/*126*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (2D component)" },
/*127*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (2D component)" }, /* Nonprintable ASCII still checked */
/*128*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[20]1\200", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (2D component)" },
/*129*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]1\200", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (2D component)" }, /* Extended ASCII still checked */
/*130*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "2012", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI (2D component)" },
/*131*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "2012", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI (2D component)" }, /* Format still checked */
/*132*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[10]", ZINT_ERROR_INVALID_DATA, "Error 258: Empty data field in input (2D component)" },
/*133*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[10]", 0, "" }, /* Zero-length data not checked */
/*134*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[2]1", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" },
/*135*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[2]1", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, /* Length 1 AI still checked */
/*136*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[]12", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" },
/*137*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[]12", 0, "" }, /* Length 0 AI with data not checked */
/*138*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[]", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" },
/*139*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[]", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, /* Length 0 AI with no data still checked */
/*140*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[20]12[][10]123", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 7 in input (AI too short) (2D component)" },
/*141*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]12[][10]123", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 7 in input (AI too short) (2D component)" }, /* Length 0 AI with no data still checked */
/*142*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 441: Invalid character in input (2D component)" },
/*143*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 441: Invalid character in input (2D component)" }, /* Non-CSET 82 always checked for composite */
/*144*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231", "", 0, "" },
/*145*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[01]12345678901231", "", 0, "" },
/*146*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231[10]123[11]1234", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11)" },
/*147*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]1234", "", 0, "" },
/*148*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231[10]123[11]1234A", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11)" },
/*149*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]1234A", "", 0, "" },
/*150*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231[10]123[11]12345A", "", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (11) position 6: Non-numeric character 'A'" },
/*151*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]12345A", "", 0, "" },
/*152*/ { BARCODE_DBAR_EXPSTK, -1, "[01]1234567890121\177", "", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1" },
/*153*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[01]1234567890121\177", "", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1" }, /* Nonprintable ASCII still checked */
/*154*/ { BARCODE_DBAR_EXPSTK, -1, "[01]1234567890121\200", "", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1" },
/*155*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[01]1234567890121\200", "", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1" }, /* Extended ASCII still checked */
/*156*/ { BARCODE_DBAR_EXPSTK, -1, "011234567890121", "", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI" },
/*157*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "011234567890121", "", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI" }, /* Format still checked */
/*158*/ { BARCODE_DBAR_EXPSTK, -1, "[01]", "", ZINT_ERROR_INVALID_DATA, "Error 258: Empty data field in input" },
/*159*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[01]", "", 0, "" }, /* Zero-length data not checked */
/*160*/ { BARCODE_DBAR_EXPSTK, -1, "[90]12]34", "", ZINT_ERROR_INVALID_DATA, "Error 386: Invalid character in General Field data" },
/*161*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[90]12]34", "", ZINT_ERROR_INVALID_DATA, "Error 386: Invalid character in General Field data" }, /* Non-CSET 82 always checked for DBAR_EXPSTK */
/*162*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345", 0, "" },
/*163*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]123456789012[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345", 0, "" },
/*164*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[10]123[11]1234", "[21]ABC123[22]12345", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11) (linear component)" },
/*165*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]1234", "[21]ABC123[22]12345", 0, "" },
/*166*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[10]123[11]123456", "[21]ABC123[22]12345", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (11) position 3: Invalid month '34' (linear component)" },
/*167*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]123456", "[21]ABC123[22]12345", 0, "" },
/*168*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]123456789", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (30) (2D component)" },
/*169*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]123456789012[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]123456789", 0, "" },
/*170*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]1234567A", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (30) position 8: Non-numeric character 'A' (2D component)" },
/*171*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]123456789012[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]1234567A", 0, "" },
/*172*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]1234567890121", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (2D component)" },
/*173*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (2D component)" }, /* Nonprintable ASCII still checked */
/*174*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]1234567890121", "[20]1\200", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (2D component)" },
/*175*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]1\200", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (2D component)" }, /* Extended ASCII still checked */
/*176*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]1234567890121", "2012", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI (2D component)" },
/*177*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]1234567890121", "2012", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI (2D component)" }, /* Format still checked */
/*178*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]1234567890121", "[235]", ZINT_ERROR_INVALID_DATA, "Error 258: Empty data field in input (2D component)" },
/*179*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[235]", 0, "" }, /* Zero-length data not checked */
/*180*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]1234567890121", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 441: Invalid character in input (2D component)" },
/*181*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 441: Invalid character in input (2D component)" }, /* Non-CSET 82 always checked for composite */
/* 66*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121\177", "[20]12", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (linear component)" },
/* 67*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121\177", "[20]12", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (linear component)" }, /* Nonprintable ASCII still checked */
/* 68*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (2D component)" },
/* 69*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (2D component)" }, /* Nonprintable ASCII still checked */
/* 70*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121\200", "[20]12", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (linear component)" },
/* 71*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121\200", "[20]12", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (linear component)" },
/* 72*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[20]1\200", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (2D component)" },
/* 73*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]1\200", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (2D component)" }, /* Extended ASCII still checked */
/* 74*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "2012", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI (2D component)" },
/* 75*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "2012", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI (2D component)" }, /* Format still checked */
/* 76*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[20]", ZINT_ERROR_INVALID_DATA, "Error 258: Empty data field in input (2D component)" },
/* 77*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]", 0, "" }, /* Zero-length data not checked */
/* 78*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[2]12", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" },
/* 79*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[2]12", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, /* Length 1 AI still checked */
/* 80*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[]12", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" },
/* 81*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[]12", 0, "" }, /* Length 0 AI with data not checked */
/* 82*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[1]2[]1", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 5 in input (AI too short) (2D component)" },
/* 83*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[1]2[]1", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 5 in input (AI too short) (2D component)" }, /* Length 1 AI still checked */
/* 84*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[]", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" },
/* 85*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[]", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, /* Length 0 AI with no data still checked */
/* 86*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[][20]12", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" },
/* 87*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[][20]12", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, /* Length 0 AI with no data still checked */
/* 88*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[20]12[]", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 7 in input (AI too short) (2D component)" },
/* 89*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]12[]", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 7 in input (AI too short) (2D component)" }, /* Length 0 AI with no data still checked */
/* 90*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901231", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 441: Invalid character in input (2D component)" },
/* 91*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]12345678901231", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 441: Invalid character in input (2D component)" }, /* Non-CSET 82 always checked for composite data */
/* 92*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231", "", 0, "" },
/* 93*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[01]12345678901231", "", 0, "" },
/* 94*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231[10]123[11]1234", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11)" },
/* 95*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]1234", "", 0, "" },
/* 96*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231[10]123[11]1234A", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11)" },
/* 97*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]1234A", "", 0, "" },
/* 98*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231[10]123[11]12345A", "", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (11) position 6: Non-numeric character 'A'" },
/* 99*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]12345A", "", 0, "" },
/*100*/ { BARCODE_DBAR_EXP, -1, "[01]1234567890121\177", "", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1" },
/*101*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[01]1234567890121\177", "", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1" }, /* Nonprintable ASCII still checked */
/*102*/ { BARCODE_DBAR_EXP, -1, "[01]1234567890121\200", "", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1" },
/*103*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[01]1234567890121\200", "", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1" }, /* Extended ASCII still checked */
/*104*/ { BARCODE_DBAR_EXP, -1, "011234567890121", "", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI" },
/*105*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "011234567890121", "", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI" }, /* Format still checked */
/*106*/ { BARCODE_DBAR_EXP, -1, "[10]", "", ZINT_ERROR_INVALID_DATA, "Error 258: Empty data field in input" },
/*107*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[10]", "", 0, "" }, /* Zero-length data not checked */
/*108*/ { BARCODE_DBAR_EXP, -1, "[2]1", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" },
/*109*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[2]1", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, /* Length 1 AI still checked */
/*110*/ { BARCODE_DBAR_EXP, -1, "[]1", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" },
/*111*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[]1", "", 0, "" }, /* Length 0 AI with data not checked */
/*112*/ { BARCODE_DBAR_EXP, -1, "[]", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" },
/*113*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[]", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, /* Length 0 AI with no data still checked */
/*114*/ { BARCODE_DBAR_EXP, -1, "[20]12[]", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 7 in input (AI too short)" },
/*115*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[20]12[]", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 7 in input (AI too short)" }, /* Length 0 AI with no data still checked */
/*116*/ { BARCODE_DBAR_EXP, -1, "[90]12]34", "", ZINT_ERROR_INVALID_DATA, "Error 386: Invalid character in General Field data" },
/*117*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[90]12]34", "", ZINT_ERROR_INVALID_DATA, "Error 386: Invalid character in General Field data" }, /* Non-CSET 82 always checked for DBAR_EXP */
/*118*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345", 0, "" },
/*119*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]123456789012[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345", 0, "" },
/*120*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231[10]123[11]1234", "[21]ABC123[22]12345", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11) (linear component)" },
/*121*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]1234", "[21]ABC123[22]12345", 0, "" },
/*122*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231[10]123[11]123456", "[21]ABC123[22]12345", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (11) position 3: Invalid month '34' (linear component)" },
/*123*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]123456", "[21]ABC123[22]12345", 0, "" },
/*124*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]123456789", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (30) (2D component)" },
/*125*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]123456789012[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]123456789", 0, "" },
/*126*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]1234567A", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (30) position 8: Non-numeric character 'A' (2D component)" },
/*127*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]123456789012[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]1234567A", 0, "" },
/*128*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (2D component)" },
/*129*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (2D component)" }, /* Nonprintable ASCII still checked */
/*130*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[20]1\200", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (2D component)" },
/*131*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]1\200", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (2D component)" }, /* Extended ASCII still checked */
/*132*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "2012", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI (2D component)" },
/*133*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "2012", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI (2D component)" }, /* Format still checked */
/*134*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[10]", ZINT_ERROR_INVALID_DATA, "Error 258: Empty data field in input (2D component)" },
/*135*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[10]", 0, "" }, /* Zero-length data not checked */
/*136*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[2]1", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" },
/*137*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[2]1", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, /* Length 1 AI still checked */
/*138*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[]12", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" },
/*139*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[]12", 0, "" }, /* Length 0 AI with data not checked */
/*140*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[]", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" },
/*141*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[]", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, /* Length 0 AI with no data still checked */
/*142*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[20]12[][10]123", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 7 in input (AI too short) (2D component)" },
/*143*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]12[][10]123", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 7 in input (AI too short) (2D component)" }, /* Length 0 AI with no data still checked */
/*144*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 441: Invalid character in input (2D component)" },
/*145*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 441: Invalid character in input (2D component)" }, /* Non-CSET 82 always checked for composite */
/*146*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231", "", 0, "" },
/*147*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[01]12345678901231", "", 0, "" },
/*148*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231[10]123[11]1234", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11)" },
/*149*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]1234", "", 0, "" },
/*150*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231[10]123[11]1234A", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11)" },
/*151*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]1234A", "", 0, "" },
/*152*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231[10]123[11]12345A", "", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (11) position 6: Non-numeric character 'A'" },
/*153*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]12345A", "", 0, "" },
/*154*/ { BARCODE_DBAR_EXPSTK, -1, "[01]1234567890121\177", "", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1" },
/*155*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[01]1234567890121\177", "", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1" }, /* Nonprintable ASCII still checked */
/*156*/ { BARCODE_DBAR_EXPSTK, -1, "[01]1234567890121\200", "", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1" },
/*157*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[01]1234567890121\200", "", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1" }, /* Extended ASCII still checked */
/*158*/ { BARCODE_DBAR_EXPSTK, -1, "011234567890121", "", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI" },
/*159*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "011234567890121", "", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI" }, /* Format still checked */
/*160*/ { BARCODE_DBAR_EXPSTK, -1, "[01]", "", ZINT_ERROR_INVALID_DATA, "Error 258: Empty data field in input" },
/*161*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[01]", "", 0, "" }, /* Zero-length data not checked */
/*162*/ { BARCODE_DBAR_EXPSTK, -1, "[90]12]34", "", ZINT_ERROR_INVALID_DATA, "Error 386: Invalid character in General Field data" },
/*163*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[90]12]34", "", ZINT_ERROR_INVALID_DATA, "Error 386: Invalid character in General Field data" }, /* Non-CSET 82 always checked for DBAR_EXPSTK */
/*164*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345", 0, "" },
/*165*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]123456789012[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345", 0, "" },
/*166*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[10]123[11]1234", "[21]ABC123[22]12345", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11) (linear component)" },
/*167*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]1234", "[21]ABC123[22]12345", 0, "" },
/*168*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[10]123[11]123456", "[21]ABC123[22]12345", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (11) position 3: Invalid month '34' (linear component)" },
/*169*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]123456", "[21]ABC123[22]12345", 0, "" },
/*170*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]123456789", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (30) (2D component)" },
/*171*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]123456789012[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]123456789", 0, "" },
/*172*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]1234567A", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (30) position 8: Non-numeric character 'A' (2D component)" },
/*173*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]123456789012[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]1234567A", 0, "" },
/*174*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]1234567890121", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (2D component)" },
/*175*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (2D component)" }, /* Nonprintable ASCII still checked */
/*176*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]1234567890121", "[20]1\200", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (2D component)" },
/*177*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]1\200", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (2D component)" }, /* Extended ASCII still checked */
/*178*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]1234567890121", "2012", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI (2D component)" },
/*179*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]1234567890121", "2012", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI (2D component)" }, /* Format still checked */
/*180*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]1234567890121", "[235]", ZINT_ERROR_INVALID_DATA, "Error 258: Empty data field in input (2D component)" },
/*181*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[235]", 0, "" }, /* Zero-length data not checked */
/*182*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]1234567890121", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 441: Invalid character in input (2D component)" },
/*183*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 441: Invalid character in input (2D component)" }, /* Non-CSET 82 always checked for composite */
};
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
+971
View File
@@ -0,0 +1,971 @@
/*
libzint - the open source barcode library
Copyright (C) 2025 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* SPDX-License-Identifier: BSD-3-Clause */
#include "testcommon.h"
#include "../gs1.h"
/*
* Check that GS1_128-based and DBAR_EXP-based symbologies reduce GS1 data
*/
static void test_gs1_reduce(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
int symbology;
int input_mode;
const char *data;
const char *composite;
int ret;
const char *comment;
const char *expected;
};
static const struct item data[] = {
/* 0*/ { BARCODE_GS1_128, -1, "12345678901234", "", ZINT_ERROR_INVALID_DATA, "GS1 data required", "" },
/* 1*/ { BARCODE_GS1_128, -1, "[01]12345678901231", "", 0, "Input mode ignored; verified manually against TEC-IT",
"11010011100111101011101100110110010110011100100010110001110001011011000010100110111101101011001110011011000110100001100101100011101011"
},
/* 2*/ { BARCODE_GS1_128, GS1PARENS_MODE, "(01)12345678901231", "", 0, "Input mode ignored (parentheses instead of square brackets)",
"11010011100111101011101100110110010110011100100010110001110001011011000010100110111101101011001110011011000110100001100101100011101011"
},
/* 3*/ { BARCODE_GS1_128, GS1_MODE, "[01]12345678901231[21]()", "", 0, "Parentheses in AI data",
"1101001110011110101110110011011001011001110010001011000111000101101100001010011011110110101100111001101100011011011100100101111011101000110010011001001000110111000101100011101011"
},
/* 4*/ { BARCODE_GS1_128, ESCAPE_MODE | GS1PARENS_MODE, "(01)12345678901231(21)\\(\\)", "", 0, "Parentheses in AI data",
"1101001110011110101110110011011001011001110010001011000111000101101100001010011011110110101100111001101100011011011100100101111011101000110010011001001000110111000101100011101011"
},
/* 5*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901231", "[21]1234", 0, "Input mode ignored",
"0000000000000000000001101101110110100001000001101001100111011000010011101001100001010001100010010011011000000110110001010000000000000000000000000"
"0000000000000000000001101101100111110100010011001101011100100000010011001001001111001011110011101011001000000110010001010000000000000000000000000"
"0000000000000000000001101101000101111100110000101001111010000001010011001101011101110011110010011110110000110111010001010000000000000000000000000"
"0010110001100001010001001100100110100110001101110100111000111010010011110101100100001001010011000110010011100100010100001000101001110011100010100"
"1101001110011110101110110011011001011001110010001011000111000101101100001010011011110110101100111001101100011011101011110111010110001100011101011"
},
/* 6*/ { BARCODE_GS1_128_CC, GS1PARENS_MODE, "(01)12345678901231", "(21)1234", 0, "Input mode ignored (parentheses instead of square brackets)",
"0000000000000000000001101101110110100001000001101001100111011000010011101001100001010001100010010011011000000110110001010000000000000000000000000"
"0000000000000000000001101101100111110100010011001101011100100000010011001001001111001011110011101011001000000110010001010000000000000000000000000"
"0000000000000000000001101101000101111100110000101001111010000001010011001101011101110011110010011110110000110111010001010000000000000000000000000"
"0010110001100001010001001100100110100110001101110100111000111010010011110101100100001001010011000110010011100100010100001000101001110011100010100"
"1101001110011110101110110011011001011001110010001011000111000101101100001010011011110110101100111001101100011011101011110111010110001100011101011"
},
/* 7*/ { BARCODE_GS1_128_CC, GS1_MODE, "[01]12345678901231[10])", "[21](", 0, "Parentheses in AI data",
"0000000000000000000000000000000000000000000110110111010100001000001000110000110001010001001110100111010100011100001110001100101100011011000101000000000000000000000000000000000000"
"0000000000000000000000000000000000000000000110110110011100000101110110110000010011100101001100100100011110010111101101011100010000011001000101000000000000000000000000000000000000"
"0000000000000000000000000000000000000000000110110100010001000100011110111100101111001001001100110111111010011010001111100100011101011101000101000000000000000000000000000000000000"
"0010110001100001010001001100100110100110001101110100111000111010010011110101100100001001010011000110010011100100110111011010000100010011011011101000100001011101000010011100010100"
"1101001110011110101110110011011001011001110010001011000111000101101100001010011011110110101100111001101100011011001000100101111011101100100100010111011110100010111101100011101011"
},
/* 8*/ { BARCODE_GS1_128_CC, ESCAPE_MODE | GS1PARENS_MODE, "(01)12345678901231(10)\\)", "(21)\\(", 0, "Parentheses in AI data",
"0000000000000000000000000000000000000000000110110111010100001000001000110000110001010001001110100111010100011100001110001100101100011011000101000000000000000000000000000000000000"
"0000000000000000000000000000000000000000000110110110011100000101110110110000010011100101001100100100011110010111101101011100010000011001000101000000000000000000000000000000000000"
"0000000000000000000000000000000000000000000110110100010001000100011110111100101111001001001100110111111010011010001111100100011101011101000101000000000000000000000000000000000000"
"0010110001100001010001001100100110100110001101110100111000111010010011110101100100001001010011000110010011100100110111011010000100010011011011101000100001011101000010011100010100"
"1101001110011110101110110011011001011001110010001011000111000101101100001010011011110110101100111001101100011011001000100101111011101100100100010111011110100010111101100011101011"
},
/* 9*/ { BARCODE_EAN14, -1, "1234567890123", "", 0, "Input mode ignored; verified manually against TEC-IT",
"11010011100111101011101100110110010110011100100010110001110001011011000010100110111101101011001110011011000110100001100101100011101011"
},
/*10*/ { BARCODE_EAN14, GS1PARENS_MODE, "1234567890123", "", 0, "Input mode ignored (parentheses instead of square brackets)",
"11010011100111101011101100110110010110011100100010110001110001011011000010100110111101101011001110011011000110100001100101100011101011"
},
/*11*/ { BARCODE_NVE18, -1, "12345678901234567", "", 0, "Input mode ignored; verified manually against TEC-IT",
"110100111001111010111011011001100101100111001000101100011100010110110000101001101111011010110011100100010110001110001011011000010010101101110001100011101011"
},
/*12*/ { BARCODE_NVE18, GS1PARENS_MODE, "12345678901234567", "", 0, "Input mode ignored (parentheses instead of square brackets)",
"110100111001111010111011011001100101100111001000101100011100010110110000101001101111011010110011100100010110001110001011011000010010101101110001100011101011"
},
/*13*/ { BARCODE_DBAR_EXP, -1, "2012", "", ZINT_ERROR_INVALID_DATA, "GS1 data required", "" },
/*14*/ { BARCODE_DBAR_EXP, -1, "[20]12[01]12345678901231", "", 0, "Input mode ignored",
"01001100000110011010111111110000101000001000011001010111110010001110101111110000111010001001111101110111111001110010100011111100001011110011101000010110111000011010001011111111001110000110111101011101"
},
/*15*/ { BARCODE_DBAR_EXP, GS1PARENS_MODE, "(20)12(01)12345678901231", "", 0, "Input mode ignored (parentheses instead of square brackets)",
"01001100000110011010111111110000101000001000011001010111110010001110101111110000111010001001111101110111111001110010100011111100001011110011101000010110111000011010001011111111001110000110111101011101"
},
/*16*/ { BARCODE_DBAR_EXP, UNICODE_MODE, "[20]12[01]12345678901231", "", 0, "Input mode ignored",
"01001100000110011010111111110000101000001000011001010111110010001110101111110000111010001001111101110111111001110010100011111100001011110011101000010110111000011010001011111111001110000110111101011101"
},
/*17*/ { BARCODE_DBAR_EXP, -1, "[21])[8006]123456789012310102", "", 0, "Parentheses in AI data",
"01011100110010001110111111110000101010100000001100010011011111101110101111100000011011011001110000010101100000010000100011111100001010001011100000110100011001011110001011111111001110000100101110000100001110001001101000110000000010100000001100101001110101111011000010111111111001101"
},
/*18*/ { BARCODE_DBAR_EXP, ESCAPE_MODE | GS1PARENS_MODE, "(21)\\)(8006)123456789012310102", "", 0, "Parentheses in AI data",
"01011100110010001110111111110000101010100000001100010011011111101110101111100000011011011001110000010101100000010000100011111100001010001011100000110100011001011110001011111111001110000100101110000100001110001001101000110000000010100000001100101001110101111011000010111111111001101"
},
/*19*/ { BARCODE_DBAR_EXP_CC, -1, "[20]12", "[21]1234[8006]123456789012310102", 0, "",
"001101001000110100001000001101001100111011000010010001101100001000001011011110111000101100111011001010"
"001101011000111110110100001001000111011111101010010000101101100001111001010100001111000100110011001010"
"001101011100100110011001111001001000001001111010110000101011011000011110010100110001111100110111001010"
"001101011110111100111001001101101001000011000010111000101111011100001011011010011101111000110111101010"
"000001111111010110010000000010100100111001100001011010000011010001110100001010101001010000011110100000"
"010010000000101001101111111100001011000110011110100101111100101110001011110000000010101111100001011101"
},
/*20*/ { BARCODE_DBAR_EXP_CC, UNICODE_MODE, "[20]12", "[21]1234[8006]123456789012310102", 0, "Input mode ignored",
"001101001000110100001000001101001100111011000010010001101100001000001011011110111000101100111011001010"
"001101011000111110110100001001000111011111101010010000101101100001111001010100001111000100110011001010"
"001101011100100110011001111001001000001001111010110000101011011000011110010100110001111100110111001010"
"001101011110111100111001001101101001000011000010111000101111011100001011011010011101111000110111101010"
"000001111111010110010000000010100100111001100001011010000011010001110100001010101001010000011110100000"
"010010000000101001101111111100001011000110011110100101111100101110001011110000000010101111100001011101"
},
/*21*/ { BARCODE_DBAR_EXP_CC, -1, "[10]()[8006]123456789012310202", "[21]()", 0, "Parentheses in AI data",
"00110110111010100001000001000110000110001010001001110100111010111001111101100111011001000011011000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
"00110110110010001000111110110111101100001101001001100100111110111101110101111101000110111011001000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
"00110110100010111110110100000100001111011011001001100110100111001100111001000001001001111011101000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
"00000110111001100001000000001010010101110011000001101100100000010001010000010101000100011011110001101110101110111000010100000010100101111101110010111000100010111101110100000000100001100000110011010010001100011000100111001111111101010001101110011110001111011100100101000000000110000"
"01011001000110011110111111110000101010001100111110010011011111101110101111100000011011100100001110010001010001000111100011111100001010000010001101000111011101000010001011111111001110011111001100101101110011100111011000110000000010101110010001100001110000100011011010111111111001101"
},
/*22*/ { BARCODE_DBAR_EXP_CC, GS1PARENS_MODE, "(10)\\(\\)(8006)123456789012310202", "(21)\\(\\)", 0, "Parentheses in AI data",
"00110110111010100001000001000110000110001010001001110100111010111001111101100111011001000011011000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
"00110110110010001000111110110111101100001101001001100100111110111101110101111101000110111011001000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
"00110110100010111110110100000100001111011011001001100110100111001100111001000001001001111011101000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
"00000110111001100001000000001010010101110011000001101100100000010001010000010101000100011011110001101110101110111000010100000010100101111101110010111000100010111101110100000000100001100000110011010010001100011000100111001111111101010001101110011110001111011100100101000000000110000"
"01011001000110011110111111110000101010001100111110010011011111101110101111100000011011100100001110010001010001000111100011111100001010000010001101000111011101000010001011111111001110011111001100101101110011100111011000110000000010101110010001100001110000100011011010111111111001101"
},
/*23*/ { BARCODE_DBAR_EXPSTK, -1, "12", "", ZINT_ERROR_INVALID_DATA, "GS1 data required", "" },
/*24*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231[20]12", "", 0, "Input mode ignored",
"010011010011100000101111111100001011000011101110010111000110110001001011111100001110001111000010101101"
"000000101100011111010000000010100100111100010001101000111001001110110100000010100001110000111101010000"
"000001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000"
"000000100000000101110010000110100011000111110110010100101000000101001000001111010000000000000000000000"
"101110011111111010001101111001011100111000001001101010000111111000110111110000101001000000000000000000"
},
/*25*/ { BARCODE_DBAR_EXPSTK, UNICODE_MODE, "[01]12345678901231[20]12", "", 0, "Input mode ignored",
"010011010011100000101111111100001011000011101110010111000110110001001011111100001110001111000010101101"
"000000101100011111010000000010100100111100010001101000111001001110110100000010100001110000111101010000"
"000001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000"
"000000100000000101110010000110100011000111110110010100101000000101001000001111010000000000000000000000"
"101110011111111010001101111001011100111000001001101010000111111000110111110000101001000000000000000000"
},
/*26*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231[21](21)", "", 0, "Parentheses in AI data",
"010000100011011001101111111100001010010000111011000111000110110001001011111000000110001111000010101101"
"000011011100100110010000000010100101101111000100111000111001001110110100000101010001110000111101010000"
"000001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000"
"000011000011100010100001000000001011001000110110000111010011011110001001010000001010010000011110100000"
"101100111100011101011100111111110100110111001001111000101100100001110100001111110001101111100001010010"
"000011000011100010100001000000001011001000110110000111010011011110001001010000001010010000011110100000"
"000001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000"
"000010010011100000010100001010100101011111000010100000000000000000000000000000000000000000000000000000"
"010101101100011111100011110000001010100000111101000100000000000000000000000000000000000000000000000000"
},
/*27*/ { BARCODE_DBAR_EXPSTK, ESCAPE_MODE | GS1PARENS_MODE, "(01)12345678901231(21)\\(21\\)", "", 0, "Parentheses in AI data",
"010000100011011001101111111100001010010000111011000111000110110001001011111000000110001111000010101101"
"000011011100100110010000000010100101101111000100111000111001001110110100000101010001110000111101010000"
"000001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000"
"000011000011100010100001000000001011001000110110000111010011011110001001010000001010010000011110100000"
"101100111100011101011100111111110100110111001001111000101100100001110100001111110001101111100001010010"
"000011000011100010100001000000001011001000110110000111010011011110001001010000001010010000011110100000"
"000001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000"
"000010010011100000010100001010100101011111000010100000000000000000000000000000000000000000000000000000"
"010101101100011111100011110000001010100000111101000100000000000000000000000000000000000000000000000000"
},
/*28*/ { BARCODE_DBAR_EXPSTK_CC, -1, "12", "[21]1234", ZINT_ERROR_INVALID_DATA, "GS1 data required", "" },
/*29*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[20]12", "[21]1234[8006]123456789012310102", 0, "Input mode ignored; (same as BARCODE_DBAR_EXP_CC above)",
"001101001000110100001000001101001100111011000010010001101100001000001011011110111000101100111011001010"
"001101011000111110110100001001000111011111101010010000101101100001111001010100001111000100110011001010"
"001101011100100110011001111001001000001001111010110000101011011000011110010100110001111100110111001010"
"001101011110111100111001001101101001000011000010111000101111011100001011011010011101111000110111101010"
"000001111111010110010000000010100100111001100001011010000011010001110100001010101001010000011110100000"
"010010000000101001101111111100001011000110011110100101111100101110001011110000000010101111100001011101"
},
/*30*/ { BARCODE_DBAR_EXPSTK_CC, GS1PARENS_MODE, "(20)12", "(21)1234(8006)123456789012310102", 0, "Input mode ignored (parentheses instead of square brackets)",
"001101001000110100001000001101001100111011000010010001101100001000001011011110111000101100111011001010"
"001101011000111110110100001001000111011111101010010000101101100001111001010100001111000100110011001010"
"001101011100100110011001111001001000001001111010110000101011011000011110010100110001111100110111001010"
"001101011110111100111001001101101001000011000010111000101111011100001011011010011101111000110111101010"
"000001111111010110010000000010100100111001100001011010000011010001110100001010101001010000011110100000"
"010010000000101001101111111100001011000110011110100101111100101110001011110000000010101111100001011101"
},
/*31*/ { BARCODE_DBAR_EXPSTK_CC, UNICODE_MODE, "[20]12", "[21]1234[8006]123456789012310102", 0, "Input mode ignored",
"001101001000110100001000001101001100111011000010010001101100001000001011011110111000101100111011001010"
"001101011000111110110100001001000111011111101010010000101101100001111001010100001111000100110011001010"
"001101011100100110011001111001001000001001111010110000101011011000011110010100110001111100110111001010"
"001101011110111100111001001101101001000011000010111000101111011100001011011010011101111000110111101010"
"000001111111010110010000000010100100111001100001011010000011010001110100001010101001010000011110100000"
"010010000000101001101111111100001011000110011110100101111100101110001011110000000010101111100001011101"
},
/*32*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[10]1)", "[21]12)(", 0, "Parentheses in AI data",
"001101101110110100001000001101110111011100111010011101001000010010000001010010001000010000110110001010"
"001101101100111101000010001001110000110111010010011001001101100011110001011010111000100000110010001010"
"001101101000111001111101011001011100100000011010011001101001111001000001010000011110010100111010001010"
"000000111001111001010000000010100100001100110001001000111001001110110100000010100001110000111101010000"
"010011000110000110101111111100001011110011001110110111000110110001001011111100001110001111000010101101"
"000000111001111001010000000010100100001100110001001000111001001110110100000010100001110000111101010000"
"000001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000"
"000000011001001111100001000000001010000110111100110101111011011100001001010000001010010000011110100000"
"101011100110110000011100111111110101111001000011001010000100100011110100001111110001101111100001010010"
},
/*33*/ { BARCODE_DBAR_EXPSTK_CC, GS1PARENS_MODE, "(01)12345678901231(10)1\\)", "(21)12\\)\\(", 0, "Parentheses in AI data",
"001101101110110100001000001101110111011100111010011101001000010010000001010010001000010000110110001010"
"001101101100111101000010001001110000110111010010011001001101100011110001011010111000100000110010001010"
"001101101000111001111101011001011100100000011010011001101001111001000001010000011110010100111010001010"
"000000111001111001010000000010100100001100110001001000111001001110110100000010100001110000111101010000"
"010011000110000110101111111100001011110011001110110111000110110001001011111100001110001111000010101101"
"000000111001111001010000000010100100001100110001001000111001001110110100000010100001110000111101010000"
"000001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000"
"000000011001001111100001000000001010000110111100110101111011011100001001010000001010010000011110100000"
"101011100110110000011100111111110101111001000011001010000100100011110100001111110001101111100001010010"
},
};
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
const char *text;
char escaped[1024];
char escaped2[1024];
char bwipp_buf[8196];
char bwipp_msg[1024];
/* Only do BWIPP test if asked, too slow otherwise */
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript();
testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) {
if (testContinue(p_ctx, i)) continue;
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
if (data[i].composite[0]) {
text = data[i].composite;
strcpy(symbol->primary, data[i].data);
} else {
text = data[i].data;
}
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/,
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, -1 /*output_options*/,
text, -1, debug);
symbol->input_mode |= GS1SYNTAXENGINE_MODE;
ret = ZBarcode_Encode(symbol, TCU(text), length);
if (p_ctx->generate) {
const int data_len = (int) strlen(data[i].data);
const int composite_len = (int) strlen(data[i].composite);
if (data[i].ret == 0) {
printf(" /*%2d*/ { %s, %s, \"%s\", \"%s\", %d, \"%s\",\n",
i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode),
testUtilEscape(data[i].data, data_len, escaped, sizeof(escaped)),
testUtilEscape(data[i].composite, composite_len, escaped2, sizeof(escaped2)),
data[i].ret, data[i].comment);
testUtilModulesPrint(symbol, " ", "\n");
printf(" },\n");
} else {
printf(" /*%2d*/ { %s, %s, \"%s\", \"%s\", %s, \"%s\", \"\" },\n",
i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode),
testUtilEscape(data[i].data, data_len, escaped, sizeof(escaped)),
testUtilEscape(data[i].composite, composite_len, escaped2, sizeof(escaped2)),
testUtilErrorName(data[i].ret), data[i].comment);
}
} 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 < 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);
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, -1, -1, debug)) {
ret = testUtilBwipp(i, symbol, -1, -1, -1, text, length, symbol->primary, bwipp_buf,
sizeof(bwipp_buf), NULL);
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n",
i, testUtilBarcodeName(symbol->symbology), ret);
ret = testUtilBwippCmp(symbol, bwipp_msg, bwipp_buf, data[i].expected);
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,
data[i].expected);
}
}
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_hrt(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
int symbology;
int input_mode;
int output_options;
const char *data;
const char *composite;
int ret;
const char *expected;
const char *expected_raw;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 0*/ { BARCODE_EAN8_CC, -1, -1, "1234567", "[20]12", 0, "12345670", "" },
/* 1*/ { BARCODE_EANX_CC, -1, -1, "1234567", "[20]12", 0, "12345670", "" }, /* EAN-8 */
/* 2*/ { BARCODE_EAN8_CC, -1, BARCODE_RAW_TEXT, "1234567", "[20]12", 0, "12345670", "12345670|2012" },
/* 3*/ { BARCODE_EANX_CC, -1, BARCODE_RAW_TEXT, "1234567", "[20]12", 0, "12345670", "12345670|2012" },
/* 4*/ { BARCODE_EAN13_CC, -1, -1, "123456789012", "[20]12", 0, "1234567890128", "" },
/* 5*/ { BARCODE_EANX_CC, -1, -1, "123456789012", "[20]12", 0, "1234567890128", "" }, /* EAN-13 */
/* 6*/ { BARCODE_EAN13_CC, -1, BARCODE_RAW_TEXT, "123456789012", "[20]12", 0, "1234567890128", "1234567890128|2012" },
/* 7*/ { BARCODE_EANX_CC, -1, BARCODE_RAW_TEXT, "123456789012", "[20]12", 0, "1234567890128", "1234567890128|2012" }, /* EAN-13 */
/* 8*/ { BARCODE_EAN13_CC, -1, -1, "123456789012", "[10]LOT123[20]12", 0, "1234567890128", "" },
/* 9*/ { BARCODE_EANX_CC, -1, -1, "123456789012", "[10]LOT123[20]12", 0, "1234567890128", "" }, /* EAN-13 */
/* 10*/ { BARCODE_EAN13_CC, -1, BARCODE_RAW_TEXT, "123456789012", "[10]LOT123[20]12", 0, "1234567890128", "1234567890128|10LOT123\0352012" },
/* 11*/ { BARCODE_EANX_CC, -1, BARCODE_RAW_TEXT, "123456789012", "[10]LOT123[20]12", 0, "1234567890128", "1234567890128|10LOT123\0352012" }, /* EAN-13 */
/* 12*/ { BARCODE_EAN13_CC, -1, -1, "1234567890128", "[20]12", 0, "1234567890128", "" },
/* 13*/ { BARCODE_EANX_CC, -1, -1, "1234567890128", "[20]12", 0, "1234567890128", "" },
/* 14*/ { BARCODE_EAN13_CC, -1, -1, "1234567890123", "[20]12", ZINT_ERROR_INVALID_CHECK, "", "" },
/* 15*/ { BARCODE_EANX_CC, -1, -1, "1234567890123", "[20]12", ZINT_ERROR_INVALID_CHECK, "", "" },
/* 16*/ { BARCODE_EAN13_CC, GS1NOCHECK_MODE, -1, "1234567890123", "[20]12", ZINT_ERROR_INVALID_CHECK, "", "" }, /* Still checked */
/* 17*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, -1, "1234567890123", "[20]12", ZINT_ERROR_INVALID_CHECK, "", "" }, /* Still checked */
/* 18*/ { BARCODE_EAN13_CC, -1, -1, "1234567890128", "[20]1A", ZINT_ERROR_INVALID_DATA, "", "" }, /* AI (20) should be 2 nos. */
/* 19*/ { BARCODE_EANX_CC, -1, -1, "1234567890128", "[20]1A", ZINT_ERROR_INVALID_DATA, "", "" }, /* AI (20) should be 2 nos. */
/* 20*/ { BARCODE_EAN13_CC, GS1NOCHECK_MODE, -1, "1234567890128", "[20]1A", 0, "1234567890128", "" },
/* 21*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, -1, "1234567890128", "[20]1A", 0, "1234567890128", "" },
/* 22*/ { BARCODE_EAN13_CC, -1, -1, "1234567890128+12", "[20]12", 0, "1234567890128+12", "" },
/* 23*/ { BARCODE_EANX_CC, -1, -1, "1234567890128+12", "[20]12", 0, "1234567890128+12", "" },
/* 24*/ { BARCODE_EAN13_CC, -1, BARCODE_RAW_TEXT, "1234567890128+12", "[20]12", 0, "1234567890128+12", "123456789012812|2012" },
/* 25*/ { BARCODE_EANX_CC, -1, BARCODE_RAW_TEXT, "1234567890128+12", "[20]12", 0, "1234567890128+12", "123456789012812|2012" },
/* 26*/ { BARCODE_DBAR_OMN_CC, -1, -1, "1234567890123", "[20]12", 0, "(01)12345678901231", "" },
/* 27*/ { BARCODE_DBAR_OMN_CC, -1, BARCODE_RAW_TEXT, "1234567890123", "[20]12", 0, "(01)12345678901231", "0112345678901231|2012" },
/* 28*/ { BARCODE_DBAR_OMN_CC, -1, -1, "12345678901231", "[20]12", 0, "(01)12345678901231", "" },
/* 29*/ { BARCODE_DBAR_OMN_CC, -1, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, "", "" },
/* 30*/ { BARCODE_DBAR_OMN_CC, GS1NOCHECK_MODE, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, "", "" }, /* Still checked */
/* 31*/ { BARCODE_DBAR_OMN_CC, -1, -1, "12345678901231", "[20]1A", ZINT_ERROR_INVALID_DATA, "", "" }, /* AI (20) should be 2 nos. */
/* 32*/ { BARCODE_DBAR_OMN_CC, GS1NOCHECK_MODE, -1, "12345678901231", "[20]1A", 0, "(01)12345678901231", "" },
/* 33*/ { BARCODE_DBAR_LTD_CC, -1, -1, "1234567890123", "[20]12", 0, "(01)12345678901231", "" },
/* 34*/ { BARCODE_DBAR_LTD_CC, -1, BARCODE_RAW_TEXT, "1234567890123", "[20]12", 0, "(01)12345678901231", "0112345678901231|2012" },
/* 35*/ { BARCODE_DBAR_LTD_CC, -1, -1, "12345678901231", "[20]12", 0, "(01)12345678901231", "" },
/* 36*/ { BARCODE_DBAR_LTD_CC, -1, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, "", "" },
/* 37*/ { BARCODE_DBAR_LTD_CC, GS1NOCHECK_MODE, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, "", "" }, /* Still checked */
/* 38*/ { BARCODE_DBAR_LTD_CC, -1, -1, "12345678901231", "[20]1A", ZINT_ERROR_INVALID_DATA, "", "" }, /* AI (20) should be 2 nos. */
/* 39*/ { BARCODE_DBAR_LTD_CC, GS1NOCHECK_MODE, -1, "12345678901231", "[20]1A", 0, "(01)12345678901231", "" },
/* 40*/ { BARCODE_UPCA_CC, -1, -1, "12345678901", "[20]12", 0, "123456789012", "" },
/* 41*/ { BARCODE_UPCA_CC, -1, BARCODE_RAW_TEXT, "12345678901", "[20]12", 0, "123456789012", "0123456789012|2012" },
/* 42*/ { BARCODE_UPCA_CC, -1, -1, "123456789012", "[20]12", 0, "123456789012", "" },
/* 43*/ { BARCODE_UPCA_CC, -1, -1, "123456789013", "[20]12", ZINT_ERROR_INVALID_CHECK, "", "" },
/* 44*/ { BARCODE_UPCA_CC, GS1NOCHECK_MODE, -1, "123456789013", "[20]12", ZINT_ERROR_INVALID_CHECK, "", "" }, /* Still checked */
/* 45*/ { BARCODE_UPCA_CC, -1, -1, "123456789012", "[20]1A", ZINT_ERROR_INVALID_DATA, "", "" }, /* AI (20) should be 2 nos. */
/* 46*/ { BARCODE_UPCA_CC, GS1NOCHECK_MODE, -1, "123456789012", "[20]1A", 0, "123456789012", "" },
/* 47*/ { BARCODE_UPCA_CC, -1, -1, "123456789012+123", "[20]12", 0, "123456789012+00123", "" },
/* 48*/ { BARCODE_UPCA_CC, -1, BARCODE_RAW_TEXT, "123456789012+123", "[20]12", 0, "123456789012+00123", "012345678901200123|2012" },
/* 49*/ { BARCODE_UPCE_CC, -1, -1, "123456", "[20]12", 0, "01234565", "" },
/* 50*/ { BARCODE_UPCE_CC, -1, BARCODE_RAW_TEXT, "123456", "[20]12", 0, "01234565", "0012345000065|2012" },
/* 51*/ { BARCODE_UPCE_CC, -1, -1, "1234567", "[20]12", 0, "12345670", "" },
/* 52*/ { BARCODE_UPCE_CC, -1, -1, "12345670", "[20]12", 0, "12345670", "" },
/* 53*/ { BARCODE_UPCE_CC, -1, -1, "12345671", "[20]12", ZINT_ERROR_INVALID_CHECK, "", "" },
/* 54*/ { BARCODE_UPCE_CC, GS1NOCHECK_MODE, -1, "12345671", "[20]12", ZINT_ERROR_INVALID_CHECK, "", "" }, /* Still checked */
/* 55*/ { BARCODE_UPCE_CC, -1, -1, "12345670", "[20]12", 0, "12345670", "" }, /* Check digit can now be given for UPCE_CC, like UPCA_CC */
/* 56*/ { BARCODE_UPCE_CC, -1, -1, "1234567", "[20]1A", ZINT_ERROR_INVALID_DATA, "", "" }, /* AI (20) should be 2 nos. */
/* 57*/ { BARCODE_UPCE_CC, GS1NOCHECK_MODE, -1, "1234567", "[20]1A", 0, "12345670", "" },
/* 58*/ { BARCODE_UPCE_CC, -1, BARCODE_RAW_TEXT, "1234567+2", "[20]12", 0, "12345670+02", "012345600007002|2012" },
/* 59*/ { BARCODE_DBAR_STK_CC, -1, -1, "12345678901231", "[20]12", 0, "", "" }, /* No HRT for stacked symbologies */
/* 60*/ { BARCODE_DBAR_STK_CC, -1, BARCODE_RAW_TEXT, "12345678901231", "[20]12", 0, "", "0112345678901231|2012" }, /* But have RAW_TEXT */
/* 61*/ { BARCODE_DBAR_OMNSTK_CC, -1, -1, "12345678901231", "[20]12", 0, "", "" },
/* 62*/ { BARCODE_DBAR_OMNSTK_CC, -1, BARCODE_RAW_TEXT, "12345678901231", "[20]12", 0, "", "0112345678901231|2012" },
};
const int data_size = ARRAY_SIZE(data);
int i, length, composite_length, ret;
struct zint_symbol *symbol = NULL;
int expected_length, expected_raw_length;
testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) {
if (testContinue(p_ctx, i)) continue;
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/,
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options,
data[i].data, -1, debug);
assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length);
symbol->input_mode |= GS1SYNTAXENGINE_MODE;
strcpy(symbol->primary, data[i].data);
expected_length = (int) strlen(data[i].expected);
expected_raw_length = (int) strlen(data[i].expected_raw);
composite_length = (int) strlen(data[i].composite);
ret = ZBarcode_Encode(symbol, TCU(data[i].composite), composite_length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, data[i].ret, ret, symbol->errtxt);
assert_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d\n",
i, symbol->text_length, expected_length);
assert_zero(strcmp((const char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
i, symbol->text, data[i].expected);
if (symbol->output_options & BARCODE_RAW_TEXT) {
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
assert_nonnull(symbol->raw_segs[0].source, "i:%d raw_segs[0].source NULL\n", i);
assert_equal(symbol->raw_segs[0].length, expected_raw_length,
"i:%d raw_segs[0].length %d != expected_raw_length %d\n",
i, symbol->raw_segs[0].length, expected_raw_length);
assert_zero(memcmp(symbol->raw_segs[0].source, data[i].expected_raw, expected_raw_length),
"i:%d memcmp(%.*s, %s, %d) != 0\n",
i, symbol->raw_segs[0].length, symbol->raw_segs[0].source, data[i].expected_raw,
expected_raw_length);
} else {
assert_null(symbol->raw_segs, "i:%d raw_segs not NULL\n", i);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_gs1_verify(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
int input_mode;
const char *data;
int ret;
const char *expected;
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 0*/ { -1, "", ZINT_ERROR_INVALID_DATA, "", "264: Data does not start with an AI" },
/* 1*/ { -1, "A", ZINT_ERROR_INVALID_DATA, "", "264: Data does not start with an AI" },
/* 2*/ { -1, "[", ZINT_ERROR_INVALID_DATA, "", "268: Failed to parse AI data" },
/* 3*/ { -1, "[]12", ZINT_ERROR_INVALID_DATA, "", "268: Unrecognised AI: " },
/* 4*/ { -1, "[1]12", ZINT_ERROR_INVALID_DATA, "", "268: Unrecognised AI: 1" },
/* 5*/ { -1, "[242]123456[1]12", ZINT_ERROR_INVALID_DATA, "", "268: Unrecognised AI: 1" },
/* 6*/ { -1, "[12345]12", ZINT_ERROR_INVALID_DATA, "", "268: Unrecognised AI: 12345" },
/* 7*/ { -1, "[9999]1234", ZINT_ERROR_INVALID_DATA, "", "268: Unrecognised AI: 9999" },
/* 8*/ { -1, "[[01]]1234", ZINT_ERROR_INVALID_DATA, "", "268: Unrecognised AI: (01" },
/* 9*/ { GS1PARENS_MODE, "((01))1234", ZINT_ERROR_INVALID_DATA, "", "268: Unrecognised AI: (01" },
/* 10*/ { -1, "[1A]12", ZINT_ERROR_INVALID_DATA, "", "268: Unrecognised AI: 1A" },
/* 11*/ { -1, "[10]", ZINT_ERROR_INVALID_DATA, "", "268: Failed to parse AI data" },
/* 12*/ { -1, "[90]\012", ZINT_ERROR_INVALID_DATA, "", "267: AI (90): A non-CSET 82 character was found where a CSET 82 character is expected. (90)|\\x0A|" },
/* 13*/ { -1, "[00]123456789012345678", ZINT_ERROR_INVALID_DATA, "", "267: AI (00): The numeric check digit is incorrect. (00)12345678901234567|8|" },
/* 14*/ { -1, "[00]123456789012345675", 0, "00123456789012345675", "" },
/* 15*/ { GS1PARENS_MODE, "(00)123456789012345675", 0, "00123456789012345675", "" },
/* 16*/ { -1, "[00]12345678901234567", ZINT_ERROR_INVALID_DATA, "", "268: AI (00) value is too short" },
/* 17*/ { -1, "[00]1234567890123456789", ZINT_ERROR_INVALID_DATA, "", "268: AI (00) value is too long" },
/* 18*/ { -1, "[3910]123123456789012345", ZINT_ERROR_INVALID_DATA, "", "267: AI (3910): A valid ISO 4217 three-digit currency code is required. (3910)|123|" },
/* 19*/ { -1, "[3910]997123456789012345", ZINT_ERROR_INVALID_DATA, "", "268: Required AIs for AI (3910) are not satisfied: 8020" },
/* 20*/ { -1, "[3910]997123456789012345[8020]REF123", ZINT_ERROR_INVALID_DATA, "", "268: Required AIs for AI (8020) are not satisfied: 415" },
/* 21*/ { -1, "[3910]997123456789012345[8020]REF123[415]1234567890123", ZINT_ERROR_INVALID_DATA, "", "267: AI (415): The numeric check digit is incorrect. (415)123456789012|3|" },
/* 22*/ { -1, "[3910]997123456789012345[8020]REF123[415]1234567890128", 0, "3910997123456789012345\0358020REF123\0354151234567890128", "" },
/* 23*/ { GS1PARENS_MODE, "(3910)997123456789012345(8020)REF123(415)1234567890128", 0, "3910997123456789012345\0358020REF123\0354151234567890128", "" },
/* 24*/ { -1, "[402]13131313131313132", ZINT_ERROR_INVALID_DATA, "", "267: AI (402): The numeric check digit is incorrect. (402)1313131313131313|2|" },
/* 25*/ { -1, "[402]13131313131313130", 0, "40213131313131313130", "" },
/* 26*/ { -1, "[4309]1234567890123456789A", ZINT_ERROR_INVALID_DATA, "", "267: AI (4309): A non-digit character was found where a digit is expected. (4309)1234567890123456789|A|" },
/* 27*/ { -1, "[7006]200132", ZINT_ERROR_INVALID_DATA, "", "267: AI (7006): The date contains an illegal day of the month. (7006)2001|32|" },
/* 28*/ { -1, "[7006]200131", ZINT_ERROR_INVALID_DATA, "7006200131", "268: Required AIs for AI (7006) are not satisfied: 01,02" },
/* 29*/ { -1, "[7006]200131[01]12345678901231", 0, "7006200131\0350112345678901231", "" },
/* 30*/ { -1, "[8001]12345678901234", ZINT_ERROR_INVALID_DATA, "", "267: AI (8001): The winding direction must be either \"0\", \"1\" or \"9\". (8001)123456789012|3|" },
/* 31*/ { -1, "[8001]12345678901294", ZINT_ERROR_INVALID_DATA, "", "268: Required AIs for AI (8001) are not satisfied: 01" },
/* 32*/ { -1, "[8001]12345678901294[01]12345678901231", 0, "800112345678901294\0350112345678901231", "" },
/* 33*/ { -1, "[8004]abcdefghijklmnopqrstuvwxyz1234", ZINT_ERROR_INVALID_DATA, "", "267: AI (8004): The GS1 Company Prefix is invalid. (8004)|a|bcdefghijklmnopqrstuvwxyz1234" },
/* 34*/ { -1, "[8004]123", ZINT_ERROR_INVALID_DATA, "", "267: AI (8004): The component is shorter than the minimum length GS1 Company Prefix. (8004)|123|" },
/* 35*/ { -1, "[8004]1234efghijklmnopqrstuvwxyz1234", 0, "80041234efghijklmnopqrstuvwxyz1234", "" },
/* 36*/ { -1, "[8007]abcdefghijklmnopqrstuvwxyz12345678", ZINT_ERROR_INVALID_DATA, "", "267: AI (8007): The IBAN must start with a valid ISO 3166 two-character country code. (8007)|ab|cdefghijklmnopqrstuvwxyz12345678" },
/* 37*/ { -1, "[8007]AD95EFGHIJKLMNOPQRSTUVWXYZ12345678", ZINT_ERROR_INVALID_DATA, "", "268: Required AIs for AI (8007) are not satisfied: 415" },
/* 38*/ { -1, "[8007]AD95EFGHIJKLMNOPQRSTUVWXYZ12345678[415]1234567890128", ZINT_ERROR_INVALID_DATA, "", "268: Required AIs for AI (415) are not satisfied: 8020" },
/* 39*/ { -1, "[8007]AD95EFGHIJKLMNOPQRSTUVWXYZ12345678[415]1234567890128[8020]REF123", 0, "8007AD95EFGHIJKLMNOPQRSTUVWXYZ12345678\03541512345678901288020REF123", "" },
/* 40*/ { -1, "[8030]-1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXY^", ZINT_ERROR_INVALID_DATA, "", "268: AI (8030) contains illegal ^ character" },
/* 41*/ { -1, "[8030]-1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ", ZINT_ERROR_INVALID_DATA, "", "268: Required AIs for AI (8030) are not satisfied: 00,01+21,253,255,8003,8004,8006+21,8010+8011,8017,8018" },
/* 42*/ { -1, "[8030]-1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ[8018]123456789012345675", 0, "8030-1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ\0358018123456789012345675", "" },
/* 43*/ { -1, "[01]12345678901234[7006]200101", ZINT_ERROR_INVALID_DATA, "", "267: AI (01): The numeric check digit is incorrect. (01)1234567890123|4|" },
/* 44*/ { -1, "[01]12345678901231[7006]200101", 0, "01123456789012317006200101", "" },
/* 45*/ { -1, "[253]12345678901284[01]12345678901231[3901]12345678901234[20]12", ZINT_ERROR_INVALID_DATA, "", "268: Required AIs for AI (3901) are not satisfied: 255,8020" },
/* 46*/ { -1, "[253]12345678901284[01]12345678901231[3901]12345678901234[20]12[255]1234567890128", ZINT_ERROR_INVALID_DATA, "", "268: It is invalid to pair AI (01) with AI (255)" },
/* 47*/ { -1, "[253]12345678901284[01]12345678901231[3901]12345678901234[20]12[8020]REF123", ZINT_ERROR_INVALID_DATA, "", "268: Required AIs for AI (8020) are not satisfied: 415" },
/* 48*/ { -1, "[253]12345678901284[01]12345678901231[3901]12345678901234[20]12[8020]REF123[415]1234567890128", 0, "25312345678901284\0350112345678901231390112345678901234\03520128020REF123\0354151234567890128", "" },
/* 49*/ { -1, "[253]12345678901284[01]12345678901231[3901]12345678901234[20]12[8020]REF123[415]1234567890128[90]123", 0, "25312345678901284\0350112345678901231390112345678901234\03520128020REF123\035415123456789012890123", "" },
/* 50*/ { -1, "[8001]12345678901294[01]12345678901231|[8012]VER1", 0, "800112345678901294\0350112345678901231|8012VER1", "" }, /* Composite */
/* 51*/ { -1, "[8001]12345678901294[01]12345678901231[415]1234567890128|[8020]ABCDEFGHIJKLMNOPQRSTUVXWY", 0, "800112345678901294\03501123456789012314151234567890128|8020ABCDEFGHIJKLMNOPQRSTUVXWY", "" },
/* 52*/ { -1, "[8001]12345678901294[01]12345678901231|[415]1234567890128[8020]ABCDEFGHIJKLMNOPQRSTUVXWY", 0, "800112345678901294\0350112345678901231|41512345678901288020ABCDEFGHIJKLMNOPQRSTUVXWY", "" },
};
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
int reduced_length = 0; /* Suppress clang -fsanitize=memory false positive */
char reduced[1024] = {0}; /* Suppress clang -fsanitize=memory false positive */
char escaped[1024];
char escaped2[1024];
testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) {
if (testContinue(p_ctx, i)) continue;
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
length = testUtilSetSymbol(symbol, BARCODE_GS1_128, data[i].input_mode, -1 /*eci*/,
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, -1 /*output_options*/,
data[i].data, -1, debug);
symbol->input_mode |= GS1SYNTAXENGINE_MODE;
ret = zint_gs1_verify(symbol, ZUCP(data[i].data), length, ZUCP(reduced), &reduced_length);
if (p_ctx->generate) {
printf(" /*%3d*/ { %s, \"%s\", %s, \"%s\", \"%s\" },\n",
i, testUtilInputModeName(data[i].input_mode),
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(ret),
data[i].expected, symbol->errtxt);
} else {
assert_equal(ret, data[i].ret, "i:%d ret %d != %d (length %d \"%s\") (%s)\n",
i, ret, data[i].ret, length, data[i].data, symbol->errtxt);
if (ret < ZINT_ERROR) {
const int expected_length = (int) strlen(data[i].expected);
assert_zero(strcmp(reduced, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
i, testUtilEscape(reduced, (int) strlen(reduced), escaped, (int) sizeof(escaped)),
testUtilEscape(data[i].expected, expected_length, escaped2, (int) sizeof(escaped2)));
assert_equal(reduced_length, (int) strlen(reduced), "i:%d reduced_length %d != strlen %d\n",
i, reduced_length, (int) strlen(reduced));
}
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n",
i, symbol->errtxt, data[i].expected_errtxt);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_gs1_digital_link(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
int input_mode;
const char *data;
int ret;
const char *expected;
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 53*/ { -1, "https://", ZINT_ERROR_INVALID_DATA, "", "268: URI must contain a domain and path info" },
/* 54*/ { -1, "HTTPS://", ZINT_ERROR_INVALID_DATA, "", "268: URI must contain a domain and path info" },
/* 55*/ { -1, "http://", ZINT_ERROR_INVALID_DATA, "", "268: URI must contain a domain and path info" },
/* 56*/ { -1, "HTTP://", ZINT_ERROR_INVALID_DATA, "", "268: URI must contain a domain and path info" },
/* 57*/ { -1, "Https://", ZINT_ERROR_INVALID_DATA, "", "265: Data does not start with an AI or a Digital Link URI" },
/* 58*/ { -1, "http:/", ZINT_ERROR_INVALID_DATA, "", "265: Data does not start with an AI or a Digital Link URI" },
/* 59*/ { -1, "https://example.com/123", ZINT_ERROR_INVALID_DATA, "", "268: No GS1 DL keys found in path info" },
/* 60*/ { -1, "https://example.com/01/12345678901231", 0, "https://example.com/01/12345678901231", "" },
/* 61*/ { -1, "https://example.com/gtin/12345678901231", ZINT_ERROR_INVALID_DATA, "", "268: No GS1 DL keys found in path info" },
/* 62*/ { -1, "https://example.com/gtin/01/12345678901231", 0, "https://example.com/gtin/01/12345678901231", "" },
/* 63*/ { -1, "https://example.com/01/12345678901231/90/123", ZINT_ERROR_INVALID_DATA, "", "268: The AIs in the path are not a valid key-qualifier sequence for the key" },
/* 64*/ { -1, "https://example.com/01/12345678901231/10/123", 0, "https://example.com/01/12345678901231/10/123", "" },
/* 65*/ { -1, "https://example.com/01/12345678901231/10/12+3", 0, "https://example.com/01/12345678901231/10/12+3", "" },
/* 66*/ { -1, "https://example.com/01/12345678901231/10/12%2B3", 0, "https://example.com/01/12345678901231/10/12%2B3", "" },
/* 67*/ { -1, "http://example.com/01/09520123456788/22/2A?linkType=gs1:traceability", 0, "http://example.com/01/09520123456788/22/2A?linkType=gs1:traceability", "" },
/* 68*/ { -1, "https://example.com/01/12345678901231/10/12?3", 0, "https://example.com/01/12345678901231/10/12?3", "" },
/* 69*/ { -1, "https://example.com/01/12345678901231/10/12=3", 0, "https://example.com/01/12345678901231/10/12=3", "" },
/* 70*/ { -1, "https://example.com/01/12345678901231/10/1?2=3", ZINT_ERROR_INVALID_DATA, "", "268: Unknown AI (2) in query parameters" },
/* 71*/ { -1, "https://example.com/01/12345678901231/10/1%3F2=3", 0, "https://example.com/01/12345678901231/10/1%3F2=3", "" },
/* 72*/ { -1, "https://example.com/01/12345678901231?3103=000195", 0, "https://example.com/01/12345678901231?3103=000195", "" },
/* 73*/ { -1, "https://example.com/01/12345678901231|(20)12", ZINT_ERROR_INVALID_DATA, "", "268: URI contains illegal characters" },
/* 74*/ { -1, "https://example.com/01/12345678901231|", ZINT_ERROR_INVALID_DATA, "", "268: URI contains illegal characters" },
/* 75*/ { -1, "https://example.com/01/12345678901231(", ZINT_ERROR_INVALID_DATA, "", "268: AI (01) value is too long" },
};
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
int reduced_length = 0; /* Suppress clang -fsanitize=memory false positive */
char reduced[1024] = {0}; /* Suppress clang -fsanitize=memory false positive */
char escaped[1024];
char escaped2[1024];
testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) {
if (testContinue(p_ctx, i)) continue;
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
length = testUtilSetSymbol(symbol, BARCODE_QRCODE, GS1_MODE | GS1SYNTAXENGINE_MODE, -1 /*eci*/,
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, -1 /*output_options*/,
data[i].data, -1, debug);
if (data[i].input_mode != -1) {
symbol->input_mode |= data[i].input_mode;
}
ret = zint_gs1_verify(symbol, ZUCP(data[i].data), length, ZUCP(reduced), &reduced_length);
if (p_ctx->generate) {
printf(" /*%3d*/ { %s, \"%s\", %s, \"%s\", \"%s\" },\n",
i, testUtilInputModeName(data[i].input_mode),
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(ret),
data[i].expected, symbol->errtxt);
} else {
assert_equal(ret, data[i].ret, "i:%d ret %d != %d (length %d \"%s\") (%s)\n",
i, ret, data[i].ret, length, data[i].data, symbol->errtxt);
if (ret < ZINT_ERROR) {
const int expected_length = (int) strlen(data[i].expected);
assert_zero(strcmp(reduced, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
i, testUtilEscape(reduced, (int) strlen(reduced), escaped, (int) sizeof(escaped)),
testUtilEscape(data[i].expected, expected_length, escaped2, (int) sizeof(escaped2)));
assert_equal(reduced_length, (int) strlen(reduced), "i:%d reduced_length %d != strlen %d\n",
i, reduced_length, (int) strlen(reduced));
}
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n",
i, symbol->errtxt, data[i].expected_errtxt);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
/* Check non-forced GS1 compliant symbologies (see gs1_compliant() in library.c) */
static void test_non_forced(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
int symbology;
const char *data;
int input_mode;
int output_options;
int ret;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 0*/ { BARCODE_AZTEC, "[01]12345678901231", GS1_MODE, -1, 0 },
/* 1*/ { BARCODE_AZTEC, "(01)12345678901231", GS1_MODE | GS1PARENS_MODE, -1, 0 },
/* 2*/ { BARCODE_AZTEC, "(01)12345678901234", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 3*/ { BARCODE_AZTEC, "(01)12345678901234", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 4*/ { BARCODE_AZTEC, "(01)123456789012345", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 5*/ { BARCODE_AZTEC, "(01)123456789012345", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 6*/ { BARCODE_AZTEC, "(01)12345678901234A", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 7*/ { BARCODE_AZTEC, "(01)12345678901234A", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 8*/ { BARCODE_AZTEC, "(01)1234567890123A", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 9*/ { BARCODE_AZTEC, "(01)1234567890123A", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 10*/ { BARCODE_AZTEC, "[01]1234567890123", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 11*/ { BARCODE_AZTEC, "[01]1234567890123", GS1_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 12*/ { BARCODE_AZTEC, "[01]12345678901231", GS1_MODE, READER_INIT, ZINT_ERROR_INVALID_OPTION },
/* 13*/ { BARCODE_AZTEC, "[01]12345678901231[10]()", GS1_MODE, -1, 0 },
/* 14*/ { BARCODE_AZTEC, "(01)12345678901231(10)()", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 15*/ { BARCODE_AZTEC, "(01)12345678901231(10)\\(\\)", GS1_MODE | GS1PARENS_MODE, -1, 0 },
/* 16*/ { BARCODE_AZTEC, "1234", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 17*/ { BARCODE_AZTEC, "1234", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, ZINT_ERROR_INVALID_DATA }, /* Must still begin with AI */
/* 18*/ { BARCODE_CODABLOCKF, "[01]12345678901231", GS1_MODE, -1, ZINT_ERROR_INVALID_OPTION }, /* Codablock-F does not support GS1 */
/* 19*/ { BARCODE_CODABLOCKF, "[01]12345678901231", GS1_MODE | GS1NOCHECK_MODE, -1, ZINT_ERROR_INVALID_OPTION },
/* 20*/ { BARCODE_CODABLOCKF, "1234", GS1_MODE, -1, ZINT_ERROR_INVALID_OPTION },
/* 21*/ { BARCODE_CODEONE, "[01]12345678901231", GS1_MODE, -1, 0 },
/* 22*/ { BARCODE_CODEONE, "(01)12345678901231", GS1_MODE | GS1PARENS_MODE, -1, 0 },
/* 23*/ { BARCODE_CODEONE, "(01)12345678901234", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 24*/ { BARCODE_CODEONE, "(01)12345678901234", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 25*/ { BARCODE_CODEONE, "(01)123456789012345", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 26*/ { BARCODE_CODEONE, "(01)123456789012345", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 27*/ { BARCODE_CODEONE, "(01)12345678901234A", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 28*/ { BARCODE_CODEONE, "(01)12345678901234A", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 29*/ { BARCODE_CODEONE, "(01)1234567890123A", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 30*/ { BARCODE_CODEONE, "(01)1234567890123A", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 31*/ { BARCODE_CODEONE, "[01]1234567890123", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 32*/ { BARCODE_CODEONE, "[01]1234567890123", GS1_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 33*/ { BARCODE_CODEONE, "[10]()[01]12345678901231", GS1_MODE, -1, 0 },
/* 34*/ { BARCODE_CODEONE, "(10)()(01)12345678901231", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 35*/ { BARCODE_CODEONE, "(10)\\(\\)(01)12345678901231", GS1_MODE | GS1PARENS_MODE, -1, 0 },
/* 36*/ { BARCODE_CODEONE, "1234", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 37*/ { BARCODE_CODE16K, "[01]12345678901231", GS1_MODE, -1, 0 },
/* 38*/ { BARCODE_CODE16K, "(01)12345678901231", GS1_MODE | GS1PARENS_MODE, -1, 0 },
/* 39*/ { BARCODE_CODE16K, "(01)12345678901234", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 40*/ { BARCODE_CODE16K, "(01)12345678901234", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 41*/ { BARCODE_CODE16K, "(01)123456789012345", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 42*/ { BARCODE_CODE16K, "(01)123456789012345", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 43*/ { BARCODE_CODE16K, "(01)12345678901234A", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 44*/ { BARCODE_CODE16K, "(01)12345678901234A", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 45*/ { BARCODE_CODE16K, "(01)1234567890123A", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 46*/ { BARCODE_CODE16K, "(01)1234567890123A", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 47*/ { BARCODE_CODE16K, "[01]1234567890123", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 48*/ { BARCODE_CODE16K, "[01]1234567890123", GS1_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 49*/ { BARCODE_CODE16K, "[01]12345678901231", GS1_MODE, READER_INIT, ZINT_ERROR_INVALID_OPTION },
/* 50*/ { BARCODE_CODE16K, "[01]12345678901231[10]()", GS1_MODE, -1, 0 },
/* 51*/ { BARCODE_CODE16K, "(01)12345678901231(10)()", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 52*/ { BARCODE_CODE16K, "(01)12345678901231(10)\\(\\)", GS1_MODE | GS1PARENS_MODE, -1, 0 },
/* 53*/ { BARCODE_CODE16K, "1234", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 54*/ { BARCODE_CODE49, "[01]12345678901231", GS1_MODE, -1, 0 },
/* 55*/ { BARCODE_CODE49, "(01)12345678901231", GS1_MODE | GS1PARENS_MODE, -1, 0 },
/* 56*/ { BARCODE_CODE49, "(01)12345678901234", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 57*/ { BARCODE_CODE49, "(01)12345678901234", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 58*/ { BARCODE_CODE49, "(01)123456789012345", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 59*/ { BARCODE_CODE49, "(01)123456789012345", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 60*/ { BARCODE_CODE49, "(01)12345678901234A", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 61*/ { BARCODE_CODE49, "(01)12345678901234A", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 62*/ { BARCODE_CODE49, "(01)1234567890123A", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 63*/ { BARCODE_CODE49, "(01)1234567890123A", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 64*/ { BARCODE_CODE49, "[01]1234567890123", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 65*/ { BARCODE_CODE49, "[01]1234567890123", GS1_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 66*/ { BARCODE_CODE49, "[01]12345678901231[10]()", GS1_MODE, -1, 0 },
/* 67*/ { BARCODE_CODE49, "(01)12345678901231(10)()", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 68*/ { BARCODE_CODE49, "(01)12345678901231(10)\\(\\)", GS1_MODE | GS1PARENS_MODE, -1, 0 },
/* 69*/ { BARCODE_CODE49, "1234", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 70*/ { BARCODE_DATAMATRIX, "[01]12345678901231", GS1_MODE, -1, 0 },
/* 71*/ { BARCODE_DATAMATRIX, "(01)12345678901231", GS1_MODE | GS1PARENS_MODE, -1, 0 },
/* 72*/ { BARCODE_DATAMATRIX, "(01)12345678901234", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 73*/ { BARCODE_DATAMATRIX, "(01)12345678901234", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 74*/ { BARCODE_DATAMATRIX, "(01)123456789012345", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 75*/ { BARCODE_DATAMATRIX, "(01)123456789012345", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 76*/ { BARCODE_DATAMATRIX, "(01)12345678901234A", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 77*/ { BARCODE_DATAMATRIX, "(01)12345678901234A", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 78*/ { BARCODE_DATAMATRIX, "(01)1234567890123A", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 79*/ { BARCODE_DATAMATRIX, "(01)1234567890123A", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 80*/ { BARCODE_DATAMATRIX, "[01]1234567890123", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 81*/ { BARCODE_DATAMATRIX, "[01]1234567890123", GS1_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 82*/ { BARCODE_DATAMATRIX, "[01]12345678901231", GS1_MODE, READER_INIT, ZINT_ERROR_INVALID_OPTION },
/* 83*/ { BARCODE_DATAMATRIX, "[01]12345678901231[10]()", GS1_MODE, -1, 0 },
/* 84*/ { BARCODE_DATAMATRIX, "(01)12345678901231(10)()", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 85*/ { BARCODE_DATAMATRIX, "(01)12345678901231(10)\\(\\)", GS1_MODE | GS1PARENS_MODE, -1, 0 },
/* 86*/ { BARCODE_DATAMATRIX, "1234", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 87*/ { BARCODE_DOTCODE, "[01]12345678901231", GS1_MODE, -1, 0 },
/* 88*/ { BARCODE_DOTCODE, "(01)12345678901231", GS1_MODE | GS1PARENS_MODE, -1, 0 },
/* 89*/ { BARCODE_DOTCODE, "(01)12345678901234", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 90*/ { BARCODE_DOTCODE, "(01)12345678901234", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 91*/ { BARCODE_DOTCODE, "(01)123456789012345", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 92*/ { BARCODE_DOTCODE, "(01)123456789012345", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 93*/ { BARCODE_DOTCODE, "(01)12345678901234A", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 94*/ { BARCODE_DOTCODE, "(01)12345678901234A", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 95*/ { BARCODE_DOTCODE, "(01)1234567890123A", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 96*/ { BARCODE_DOTCODE, "(01)1234567890123A", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 97*/ { BARCODE_DOTCODE, "[01]1234567890123", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 98*/ { BARCODE_DOTCODE, "[01]1234567890123", GS1_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 99*/ { BARCODE_DOTCODE, "[01]12345678901231", GS1_MODE, READER_INIT, 0 }, /* Reader Init permissible with default GS1 mode */
/*100*/ { BARCODE_DOTCODE, "[10]()[01]12345678901231", GS1_MODE, -1, 0 },
/*101*/ { BARCODE_DOTCODE, "(10)()(01)12345678901231", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/*102*/ { BARCODE_DOTCODE, "(10)\\(\\)(01)12345678901231", GS1_MODE | GS1PARENS_MODE, -1, 0 },
/*103*/ { BARCODE_DOTCODE, "1234", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA },
/*104*/ { BARCODE_QRCODE, "[01]12345678901231", GS1_MODE, -1, 0 },
/*105*/ { BARCODE_QRCODE, "(01)12345678901231", GS1_MODE | GS1PARENS_MODE, -1, 0 },
/*106*/ { BARCODE_QRCODE, "(01)12345678901234", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/*107*/ { BARCODE_QRCODE, "(01)12345678901234", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/*108*/ { BARCODE_QRCODE, "(01)123456789012345", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/*109*/ { BARCODE_QRCODE, "(01)123456789012345", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/*110*/ { BARCODE_QRCODE, "(01)12345678901234A", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/*111*/ { BARCODE_QRCODE, "(01)12345678901234A", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/*112*/ { BARCODE_QRCODE, "(01)1234567890123A", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/*113*/ { BARCODE_QRCODE, "(01)1234567890123A", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/*114*/ { BARCODE_QRCODE, "[01]1234567890123", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA },
/*115*/ { BARCODE_QRCODE, "[01]1234567890123", GS1_MODE | GS1NOCHECK_MODE, -1, 0 },
/*116*/ { BARCODE_QRCODE, "[02]12345678901231[10]()[37]12345678[00]123456789012345675", GS1_MODE, -1, 0 },
/*117*/ { BARCODE_QRCODE, "(02)12345678901231(10)()(37)12345678(00)123456789012345675", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/*118*/ { BARCODE_QRCODE, "(02)12345678901231(10)\\(\\)(37)12345678(00)123456789012345675", GS1_MODE | GS1PARENS_MODE, -1, 0 },
/*119*/ { BARCODE_QRCODE, "1234", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA },
};
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) {
if (testContinue(p_ctx, i)) continue;
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/,
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options,
data[i].data, -1, debug);
symbol->input_mode |= GS1SYNTAXENGINE_MODE;
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n",
i, ret, data[i].ret, symbol->errtxt);
ZBarcode_Delete(symbol);
}
testFinish();
}
/* Check GS1_128-based and DBAR_EXP-based symbologies */
static void test_gs1_128_dbar_exp(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
int symbology;
int input_mode;
const char *data;
const char *composite;
int ret;
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 0*/ { BARCODE_GS1_128, -1, "[01]12345678901231", "", 0, "" },
/* 1*/ { BARCODE_GS1_128, -1, "[01]12345678901234", "", ZINT_ERROR_INVALID_DATA, "Error 267: AI (01): The numeric check digit is incorrect. (01)1234567890123|4|" },
/* 2*/ { BARCODE_GS1_128, -1, "[01]123456789012345", "", ZINT_ERROR_INVALID_DATA, "Error 268: AI (01) value is too long" },
/* 3*/ { BARCODE_GS1_128, -1, "[01]1234567890123", "", ZINT_ERROR_INVALID_DATA, "Error 268: AI (01) value is too short" },
/* 4*/ { BARCODE_GS1_128, -1, "[01]12345678901231[20]1", "", ZINT_ERROR_INVALID_DATA, "Error 268: AI (20) value is too short" },
/* 5*/ { BARCODE_GS1_128, -1, "[04]1234[05]12345[06]123456", "", ZINT_ERROR_INVALID_DATA, "Error 268: Unrecognised AI: 04" },
/* 6*/ { BARCODE_GS1_128, -1, "[01]1234567890123A", "", ZINT_ERROR_INVALID_DATA, "Error 267: AI (01): A non-digit character was found where a digit is expected. (01)1234567890123|A|" },
/* 7*/ { BARCODE_GS1_128, -1, "[01]1234567890123.", "", ZINT_ERROR_INVALID_DATA, "Error 267: AI (01): A non-digit character was found where a digit is expected. (01)1234567890123|.|" },
/* 8*/ { BARCODE_GS1_128, -1, "[01]1234567890123\177", "", ZINT_ERROR_INVALID_DATA, "Error 267: AI (01): A non-digit character was found where a digit is expected. (01)1234567890123|\\x7F|" },
/* 9*/ { BARCODE_GS1_128, -1, "[01]1234567890123\200", "", ZINT_ERROR_INVALID_DATA, "Error 267: AI (01): A non-digit character was found where a digit is expected. (01)1234567890123|\\x80|" },
/* 10*/ { BARCODE_GS1_128, -1, "0112345678901231", "", ZINT_ERROR_INVALID_DATA, "Error 264: Data does not start with an AI" },
/* 11*/ { BARCODE_GS1_128, -1, "[01]", "", ZINT_ERROR_INVALID_DATA, "Error 268: Failed to parse AI data" },
/* 12*/ { BARCODE_GS1_128, -1, "[01][20]12", "", ZINT_ERROR_INVALID_DATA, "Error 268: AI (01) value is too short" },
/* 13*/ { BARCODE_GS1_128, -1, "[0]123", "", ZINT_ERROR_INVALID_DATA, "Error 268: Unrecognised AI: 0" },
/* 14*/ { BARCODE_GS1_128, -1, "[0]", "", ZINT_ERROR_INVALID_DATA, "Error 268: Unrecognised AI: 0" },
/* 15*/ { BARCODE_GS1_128, -1, "[]", "", ZINT_ERROR_INVALID_DATA, "Error 268: Unrecognised AI: " },
/* 16*/ { BARCODE_GS1_128, -1, "[01]12345678901231[]", "", ZINT_ERROR_INVALID_DATA, "Error 268: Unrecognised AI: " },
/* 17*/ { BARCODE_GS1_128, -1, "[123456789012345]123", "", ZINT_ERROR_INVALID_DATA, "Error 268: Unrecognised AI: 123456789012345" },
/* 18*/ { BARCODE_GS1_128, GS1PARENS_MODE, "(91)AB[", "", ZINT_ERROR_INVALID_DATA, "Error 267: AI (91): A non-CSET 82 character was found where a CSET 82 character is expected. (91)AB|[|" },
/* 19*/ { BARCODE_GS1_128, GS1PARENS_MODE, "(91)12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789[", "", ZINT_ERROR_INVALID_DATA, "Error 268: AI (91): A non-CSET 82 character was found where a CSET 82 character is expected." },
/* 20*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901231", "[20]12", 0, "" },
/* 21*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901234", "[20]12", ZINT_ERROR_INVALID_DATA, "Error 267: AI (01): The numeric check digit is incorrect. (01)1234567890123|4|" },
/* 22*/ { BARCODE_GS1_128_CC, -1, "[01]123456789012345", "[20]12", ZINT_ERROR_INVALID_DATA, "Error 268: AI (01) value is too long" },
/* 23*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901231", "[20]123", ZINT_ERROR_INVALID_DATA, "Error 268: AI (20) value is too long" },
/* 24*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901231", "[20]1A", ZINT_ERROR_INVALID_DATA, "Error 267: AI (20): A non-digit character was found where a digit is expected. (20)1|A|" },
/* 25*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[20]", ZINT_ERROR_INVALID_DATA, "Error 268: AI (01) value is too short" },
/* 26*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[2]12", ZINT_ERROR_INVALID_DATA, "Error 268: AI (01) value is too short" },
/* 27*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901231", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 267: AI (90): A non-CSET 82 character was found where a CSET 82 character is expected. (90)12|]|34" },
/* 28*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901231", "[90]12[34", ZINT_ERROR_INVALID_DATA, "Error 268: Failed to parse AI data" },
/* 29*/ { BARCODE_GS1_128_CC, -1, "https://example.com/01/12345678901231", "[20]12", ZINT_ERROR_INVALID_DATA, "Error 264: Data does not start with an AI" },
/* 30*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231", "", 0, "" },
/* 31*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231[10]123[11]12345", "", ZINT_ERROR_INVALID_DATA, "Error 268: AI (11) value is too short" },
/* 32*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231[10]123[11]12345A", "", ZINT_ERROR_INVALID_DATA, "Error 267: AI (11): A non-digit character was found where a digit is expected. (11)12345|A|" },
/* 33*/ { BARCODE_DBAR_EXP, -1, "011234567890121", "", ZINT_ERROR_INVALID_DATA, "Error 264: Data does not start with an AI" },
/* 34*/ { BARCODE_DBAR_EXP, -1, "[10]", "", ZINT_ERROR_INVALID_DATA, "Error 268: Failed to parse AI data" },
/* 35*/ { BARCODE_DBAR_EXP, -1, "[2]1", "", ZINT_ERROR_INVALID_DATA, "Error 268: Unrecognised AI: 2" },
/* 36*/ { BARCODE_DBAR_EXP, -1, "[]1", "", ZINT_ERROR_INVALID_DATA, "Error 268: Unrecognised AI: " },
/* 37*/ { BARCODE_DBAR_EXP, -1, "[]", "", ZINT_ERROR_INVALID_DATA, "Error 268: Unrecognised AI: " },
/* 38*/ { BARCODE_DBAR_EXP, -1, "[20]12[]", "", ZINT_ERROR_INVALID_DATA, "Error 268: Unrecognised AI: " },
/* 39*/ { BARCODE_DBAR_EXP, -1, "[90]12]34", "", ZINT_ERROR_INVALID_DATA, "Error 267: AI (90): A non-CSET 82 character was found where a CSET 82 character is expected. (90)12|]|34" },
/* 40*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345", 0, "" },
/* 41*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231[10]123[11]1234", "[21]ABC123[22]12345", ZINT_ERROR_INVALID_DATA, "Error 268: AI (11) value is too short" },
/* 42*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231[10]123[11]123456", "[21]ABC123[22]12345", ZINT_ERROR_INVALID_DATA, "Error 267: AI (11): The date contains an illegal month of the year. (11)12|34|56" },
/* 43*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]123456789", ZINT_ERROR_INVALID_DATA, "Error 268: AI (30) value is too long" },
/* 44*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]1234567A", ZINT_ERROR_INVALID_DATA, "Error 267: AI (30): A non-digit character was found where a digit is expected. (30)1234567|A|" },
/* 45*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121\177", "[20]12", ZINT_ERROR_INVALID_DATA, "Error 267: AI (01): A non-digit character was found where a digit is expected. (01)1234567890121|\\x7F|" },
/* 46*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 267: AI (20): A non-digit character was found where a digit is expected. (20)1|\\x7F|" },
/* 47*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "2012", ZINT_ERROR_INVALID_DATA, "Error 268: AI (01) value is too short" },
/* 48*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231", "2012", ZINT_ERROR_INVALID_DATA, "Error 268: Failed to parse AI data" },
/* 49*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[10]", ZINT_ERROR_INVALID_DATA, "Error 268: AI (01) value is too short" },
/* 50*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231", "[10]", ZINT_ERROR_INVALID_DATA, "Error 268: Failed to parse AI data" },
/* 51*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231", "[2]1", ZINT_ERROR_INVALID_DATA, "Error 268: Unrecognised AI: 2" },
/* 52*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231", "[]12", ZINT_ERROR_INVALID_DATA, "Error 268: Unrecognised AI: " },
/* 53*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231", "[]", ZINT_ERROR_INVALID_DATA, "Error 268: Unrecognised AI: " },
/* 54*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 267: AI (90): A non-CSET 82 character was found where a CSET 82 character is expected. (90)12|]|34" },
/* 55*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231", "", 0, "" },
/* 56*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231[10]123[11]1234", "", ZINT_ERROR_INVALID_DATA, "Error 268: AI (11) value is too short" },
/* 57*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231[10]123[11]12345A", "", ZINT_ERROR_INVALID_DATA, "Error 267: AI (11): A non-digit character was found where a digit is expected. (11)12345|A|" },
/* 58*/ { BARCODE_DBAR_EXPSTK, -1, "[01]1234567890121\177", "", ZINT_ERROR_INVALID_DATA, "Error 267: AI (01): A non-digit character was found where a digit is expected. (01)1234567890121|\\x7F|" },
/* 59*/ { BARCODE_DBAR_EXPSTK, -1, "[01]1234567890121\200", "", ZINT_ERROR_INVALID_DATA, "Error 267: AI (01): A non-digit character was found where a digit is expected. (01)1234567890121|\\x80|" },
/* 60*/ { BARCODE_DBAR_EXPSTK, -1, "011234567890121", "", ZINT_ERROR_INVALID_DATA, "Error 264: Data does not start with an AI" },
/* 61*/ { BARCODE_DBAR_EXPSTK, -1, "[01]", "", ZINT_ERROR_INVALID_DATA, "Error 268: Failed to parse AI data" },
/* 62*/ { BARCODE_DBAR_EXPSTK, -1, "[90]12]34", "", ZINT_ERROR_INVALID_DATA, "Error 267: AI (90): A non-CSET 82 character was found where a CSET 82 character is expected. (90)12|]|34" },
/* 63*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345", 0, "" },
/* 64*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[10]123[11]1234", "[21]ABC123[22]12345", ZINT_ERROR_INVALID_DATA, "Error 268: AI (11) value is too short" },
/* 65*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[10]123[11]123456", "[21]ABC123[22]12345", ZINT_ERROR_INVALID_DATA, "Error 267: AI (11): The date contains an illegal month of the year. (11)12|34|56" },
/* 66*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]123456789", ZINT_ERROR_INVALID_DATA, "Error 268: AI (30) value is too long" },
/* 67*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]1234567A", ZINT_ERROR_INVALID_DATA, "Error 267: AI (30): A non-digit character was found where a digit is expected. (30)1234567|A|" },
/* 68*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]1234567890121", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 268: AI (01) value is too short" },
/* 69*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231", "[20]1\200", ZINT_ERROR_INVALID_DATA, "Error 267: AI (20): A non-digit character was found where a digit is expected. (20)1|\\x80|" },
/* 70*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231", "2012", ZINT_ERROR_INVALID_DATA, "Error 268: Failed to parse AI data" },
/* 71*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]1234567890121", "[235]", ZINT_ERROR_INVALID_DATA, "Error 268: AI (01) value is too short" },
/* 72*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231", "[235]", ZINT_ERROR_INVALID_DATA, "Error 268: Failed to parse AI data" },
/* 73*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 267: AI (90): A non-CSET 82 character was found where a CSET 82 character is expected. (90)12|]|34" },
};
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
const char *text;
testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) {
if (testContinue(p_ctx, i)) continue;
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
if (data[i].composite[0]) {
text = data[i].composite;
strcpy(symbol->primary, data[i].data);
} else {
text = data[i].data;
}
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/,
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, -1 /*output_options*/,
text, -1, debug);
symbol->input_mode |= GS1SYNTAXENGINE_MODE;
ret = ZBarcode_Encode(symbol, TCU(text), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n",
i, ret, data[i].ret, symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n",
i, symbol->errtxt, data[i].expected_errtxt);
ZBarcode_Delete(symbol);
}
testFinish();
}
int main(int argc, char *argv[]) {
testFunction funcs[] = { /* name, func */
{ "test_gs1_reduce", test_gs1_reduce },
{ "test_hrt", test_hrt },
{ "test_gs1_verify", test_gs1_verify },
{ "test_gs1_digital_link", test_gs1_digital_link },
{ "test_non_forced", test_non_forced },
{ "test_gs1_128_dbar_exp", test_gs1_128_dbar_exp },
};
testRun(argc, argv, funcs, ARRAY_SIZE(funcs));
testReport();
return 0;
}
/* vim: set ts=4 sw=4 et : */
+1 -2
View File
@@ -4351,8 +4351,7 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in
expected = escaped;
}
if (gs1 && symbology != BARCODE_EAN14 && symbology != BARCODE_NVE18) {
int len = expected_len;
ret = zint_gs1_verify(symbol, ZUCP(expected), &len, ZUCP(reduced), &expected_len);
ret = zint_gs1_verify(symbol, ZUCP(expected), expected_len, ZUCP(reduced), &expected_len);
if (ret >= ZINT_ERROR) {
sprintf(msg, "zint_gs1_verify %d != 0", ret);
return 3;
+4
View File
@@ -325,6 +325,7 @@ extern "C" {
/* Note: affects DATAMATRIX, MICROPDF417, PDF417, QRCODE & UPNQR only */
#define EXTRA_ESCAPE_MODE 0x0100 /* Process special symbology-specific escape sequences as well as others */
/* Note: currently Code 128 only */
#define GS1SYNTAXENGINE_MODE 0x0200 /* Use the GS1 Syntax Engine (if available) to strictly validate GS1 input */
/* Data Matrix specific options (`symbol->option_3`) */
#define DM_SQUARE 100 /* Only consider square versions on automatic symbol size selection */
@@ -511,6 +512,9 @@ extern "C" {
/* Whether Zint built without PNG support */
ZINT_EXTERN int ZBarcode_NoPng(void);
/* Whether Zint built with GS1 Syntax Engine support */
ZINT_EXTERN int ZBarcode_HaveGS1SyntaxEngine(void);
/* Return the version of Zint linked to */
ZINT_EXTERN int ZBarcode_Version(void);