mirror of
https://git.code.sf.net/p/zint/code
synced 2026-06-09 15:13:35 +00:00
C25/DBAR: use new func gs1_check_digit() for common GS1 check digit calc
CODE11/CODE39/EXCODE39/CODE93/PZN/CHANNEL/VIN/DBAR/UPCEAN: fuller error messages DATAMATRIX: look_ahead_test debug counts DBAR: consolidate option_2 cols_per_row CMakeLists.txt: restore -fno-var-tracking-assignments for gcc no DEBUG overall: suppress various warnings on various configs testcommon.c: clean-up
This commit is contained in:
@@ -205,11 +205,12 @@ static void test_input(int index, int debug) {
|
||||
/* 20*/ { BARCODE_PZN, -1, "A", -1, ZINT_ERROR_INVALID_DATA, -1, -1 },
|
||||
/* 21*/ { BARCODE_PZN, -1, "1000006", -1, ZINT_ERROR_INVALID_DATA, -1, -1 }, // Check digit == 10 so can't be used
|
||||
/* 22*/ { BARCODE_VIN, -1, "5GZCZ43D13S812715", -1, 0, 1, 246 },
|
||||
/* 23*/ { BARCODE_VIN, -1, "5GZCZ43D23S812715", -1, ZINT_ERROR_INVALID_DATA, -1, -1 }, // North American with invalid check character
|
||||
/* 23*/ { BARCODE_VIN, -1, "5GZCZ43D23S812715", -1, ZINT_ERROR_INVALID_CHECK, -1, -1 }, // North American with invalid check character
|
||||
/* 24*/ { BARCODE_VIN, -1, "WP0ZZZ99ZTS392124", -1, 0, 1, 246 }, // Not North American so no check
|
||||
/* 25*/ { BARCODE_HIBC_39, -1, "a", -1, 0, 1, 79 }, // Converts to upper
|
||||
/* 26*/ { BARCODE_HIBC_39, -1, ",", -1, ZINT_ERROR_INVALID_DATA, -1, -1 },
|
||||
/* 27*/ { BARCODE_HIBC_39, -1, "\000", 1, ZINT_ERROR_INVALID_DATA, -1, -1 },
|
||||
/* 25*/ { BARCODE_VIN, -1, "WPOZZZ99ZTS392124", -1, ZINT_ERROR_INVALID_DATA, -1, -1 }, // O not allowed
|
||||
/* 26*/ { BARCODE_HIBC_39, -1, "a", -1, 0, 1, 79 }, // Converts to upper
|
||||
/* 27*/ { BARCODE_HIBC_39, -1, ",", -1, ZINT_ERROR_INVALID_DATA, -1, -1 },
|
||||
/* 28*/ { BARCODE_HIBC_39, -1, "\000", 1, ZINT_ERROR_INVALID_DATA, -1, -1 },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
|
||||
@@ -153,7 +153,7 @@ static void test_hrt_cpy_iso8859_1(int index, int debug) {
|
||||
}
|
||||
assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret);
|
||||
assert_equal(ret, (int) ustrlen(symbol.text), "i:%d ret %d != strlen %d\n", i, ret, (int) ustrlen(symbol.text));
|
||||
assert_nonzero(testUtilIsValidUTF8(symbol.text, ustrlen(symbol.text)), "i:%d testUtilIsValidUTF8(%s) != 1\n", i, symbol.text);
|
||||
assert_nonzero(testUtilIsValidUTF8(symbol.text, (int) ustrlen(symbol.text)), "i:%d testUtilIsValidUTF8(%s) != 1\n", i, symbol.text);
|
||||
assert_zero(strcmp((char *) symbol.text, data[i].expected), "i:%d symbol.text (%s) != expected (%s)\n", i, symbol.text, data[i].expected);
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ static void test_eanx_leading_zeroes(int index, int debug) {
|
||||
assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length);
|
||||
strcpy(symbol->primary, data[i].data);
|
||||
|
||||
composite_length = strlen(data[i].composite);
|
||||
composite_length = (int) strlen(data[i].composite);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].composite, composite_length);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||
@@ -109,8 +109,8 @@ static void test_helper_generate(const struct zint_symbol *symbol, int ret, int
|
||||
char esc_data[1024];
|
||||
char esc_composite[4096];
|
||||
|
||||
testUtilEscape(data, strlen(data), esc_data, sizeof(esc_data));
|
||||
testUtilEscape(composite, strlen(composite), esc_composite, sizeof(esc_composite));
|
||||
testUtilEscape(data, (int) strlen(data), esc_data, sizeof(esc_data));
|
||||
testUtilEscape(composite, (int) strlen(composite), esc_composite, sizeof(esc_composite));
|
||||
|
||||
if (ret == 0) {
|
||||
if (bwipp_cmp == -1) {
|
||||
@@ -1245,7 +1245,7 @@ static void test_examples(int index, int generate, int debug) {
|
||||
assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length);
|
||||
strcpy(symbol->primary, data[i].data);
|
||||
|
||||
composite_length = strlen(data[i].composite);
|
||||
composite_length = (int) strlen(data[i].composite);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].composite, composite_length);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||
@@ -1409,7 +1409,7 @@ static void test_odd_numbered_numeric(int index, int generate, int debug) {
|
||||
assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length);
|
||||
strcpy(symbol->primary, data[i].data);
|
||||
|
||||
composite_length = strlen(data[i].composite);
|
||||
composite_length = (int) strlen(data[i].composite);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].composite, composite_length);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||
@@ -1537,7 +1537,7 @@ static void test_ean128_cc_shift(int index, int generate, int debug) {
|
||||
assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length);
|
||||
strcpy(symbol->primary, data[i].data);
|
||||
|
||||
composite_length = strlen(data[i].composite);
|
||||
composite_length = (int) strlen(data[i].composite);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].composite, composite_length);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||
@@ -1617,7 +1617,7 @@ static void test_ean128_cc_width(int index, int generate, int debug) {
|
||||
assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length);
|
||||
strcpy(symbol->primary, data[i].data);
|
||||
|
||||
composite_length = strlen(data[i].composite);
|
||||
composite_length = (int) strlen(data[i].composite);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].composite, composite_length);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||
@@ -2083,7 +2083,7 @@ static void test_encodation_0(int index, int generate, int debug) {
|
||||
assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length);
|
||||
strcpy(symbol->primary, data[i].data);
|
||||
|
||||
composite_length = strlen(data[i].composite);
|
||||
composite_length = (int) strlen(data[i].composite);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].composite, composite_length);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||
@@ -2220,7 +2220,7 @@ static void test_encodation_10(int index, int generate, int debug) {
|
||||
assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length);
|
||||
strcpy(symbol->primary, data[i].data);
|
||||
|
||||
composite_length = strlen(data[i].composite);
|
||||
composite_length = (int) strlen(data[i].composite);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].composite, composite_length);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||
@@ -2601,7 +2601,7 @@ static void test_encodation_11(int index, int generate, int debug) {
|
||||
assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length);
|
||||
strcpy(symbol->primary, data[i].data);
|
||||
|
||||
composite_length = strlen(data[i].composite);
|
||||
composite_length = (int) strlen(data[i].composite);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].composite, composite_length);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||
@@ -2753,7 +2753,7 @@ static void test_addongap(int index, int generate, int debug) {
|
||||
assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length);
|
||||
strcpy(symbol->primary, data[i].data);
|
||||
|
||||
composite_length = strlen(composite);
|
||||
composite_length = (int) strlen(composite);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (const unsigned char *) composite, composite_length);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||
@@ -2843,7 +2843,7 @@ static void test_gs1parens(int index, int debug) {
|
||||
assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length);
|
||||
strcpy(symbol->primary, data[i].data);
|
||||
|
||||
composite_length = strlen(data[i].composite);
|
||||
composite_length = (int) strlen(data[i].composite);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].composite, composite_length);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||
@@ -2894,7 +2894,7 @@ static void test_fuzz(int index, int debug) {
|
||||
assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length);
|
||||
strcpy(symbol->primary, data[i].data);
|
||||
|
||||
composite_length = strlen(data[i].composite);
|
||||
composite_length = (int) strlen(data[i].composite);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].composite, composite_length);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||
@@ -2966,7 +2966,7 @@ static void test_perf(int index, int debug) {
|
||||
assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length);
|
||||
strcpy(symbol->primary, data[i].data);
|
||||
|
||||
composite_length = strlen(data[i].composite);
|
||||
composite_length = (int) strlen(data[i].composite);
|
||||
|
||||
start = clock();
|
||||
ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].composite, composite_length);
|
||||
|
||||
@@ -1325,7 +1325,7 @@ static void test_gs1_verify(int index, int debug) {
|
||||
symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
length = strlen(data[i].data);
|
||||
length = (int) strlen(data[i].data);
|
||||
|
||||
ret = gs1_verify(symbol, (unsigned char *) data[i].data, length, (unsigned char *) reduced);
|
||||
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);
|
||||
@@ -1730,7 +1730,7 @@ static void test_gs1_lint(int index, int debug) {
|
||||
symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
length = strlen(data[i].data);
|
||||
length = (int) strlen(data[i].data);
|
||||
|
||||
ret = gs1_verify(symbol, (unsigned char *) data[i].data, length, (unsigned char *) reduced);
|
||||
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);
|
||||
|
||||
@@ -109,7 +109,7 @@ static void test_csv(int index, int debug) {
|
||||
symbol->symbology = BARCODE_USPS_IMAIL;
|
||||
symbol->debug |= debug;
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data, strlen(data));
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data, (int) strlen(data));
|
||||
|
||||
if (strcmp(return_code, "00") == 0) {
|
||||
|
||||
|
||||
@@ -33,13 +33,17 @@
|
||||
#include "../large.h"
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
# define LX_FMT "I64"
|
||||
# if __WORDSIZE == 32
|
||||
# define LX_FMT "I32"
|
||||
# else
|
||||
# define LX_FMT "I64"
|
||||
# endif
|
||||
# if defined(__clang__)
|
||||
# pragma GCC diagnostic ignored "-Wformat-non-iso"
|
||||
# elif defined(__GNUC__)
|
||||
# pragma GCC diagnostic ignored "-Wformat" /* Unfortunately doesn't seem to be way to only avoid non-ISO warnings */
|
||||
# endif
|
||||
#elif defined(_MSC_VER)
|
||||
#elif defined(_MSC_VER) || __WORDSIZE == 32
|
||||
# define LX_FMT "ll"
|
||||
#else
|
||||
# define LX_FMT "l"
|
||||
|
||||
@@ -379,7 +379,7 @@ static void test_encode_file_too_large(void) {
|
||||
|
||||
fstream = fopen(filename, "w+");
|
||||
assert_nonnull(fstream, "fopen(%s) failed (%d)\n", filename, ferror(fstream));
|
||||
ret = fwrite(buf, 1, sizeof(buf), fstream);
|
||||
ret = (int) fwrite(buf, 1, sizeof(buf), fstream);
|
||||
assert_equal(ret, sizeof(buf), "fwrite return value: %d != %d\n", ret, (int)sizeof(buf));
|
||||
ret = fclose(fstream);
|
||||
assert_zero(ret, "fclose(%s) %d != 0\n", filename, ret);
|
||||
|
||||
@@ -93,7 +93,7 @@ static void test_pcx(int index, int debug) {
|
||||
}
|
||||
symbol->debug |= debug;
|
||||
|
||||
length = strlen(data[i].data);
|
||||
length = (int) strlen(data[i].data);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
||||
assert_zero(ret, "i:%d %s ZBarcode_Encode ret %d != 0 %s\n", i, testUtilBarcodeName(data[i].symbology), ret, symbol->errtxt);
|
||||
|
||||
@@ -1074,7 +1074,7 @@ static void test_fuzz(int index, int debug) {
|
||||
|
||||
length = data[i].length;
|
||||
if (length == -1) {
|
||||
length = strlen(data[i].data);
|
||||
length = (int) strlen(data[i].data);
|
||||
}
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
||||
|
||||
@@ -1656,7 +1656,7 @@ static void test_microqr_padding(int index, int generate, int debug) {
|
||||
symbol->debug = ZINT_DEBUG_TEST; // Needed to get codeword dump in errtxt
|
||||
symbol->debug |= debug;
|
||||
|
||||
length = strlen(data[i].data);
|
||||
length = (int) strlen(data[i].data);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||
|
||||
@@ -274,7 +274,7 @@ static void test_buffer(int index, int generate, int debug) {
|
||||
} else {
|
||||
text = data[i].data;
|
||||
}
|
||||
length = strlen(text);
|
||||
length = (int) strlen(text);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) text, length);
|
||||
assert_zero(ret, "i:%d ZBarcode_Encode(%s) ret %d != 0 (%s)\n", i, testUtilBarcodeName(data[i].symbology), ret, symbol->errtxt);
|
||||
@@ -380,7 +380,7 @@ static void test_upcean_hrt(int index, int debug) {
|
||||
}
|
||||
symbol->debug |= debug;
|
||||
|
||||
length = strlen(data[i].data);
|
||||
length = (int) strlen(data[i].data);
|
||||
|
||||
ret = ZBarcode_Encode_and_Buffer(symbol, (unsigned char *) data[i].data, length, 0);
|
||||
assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret);
|
||||
@@ -574,7 +574,7 @@ static void test_stacking(int index, int debug) {
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
||||
assert_zero(ret, "i:%d ret %d != zero\n", i, ret);
|
||||
|
||||
length2 = strlen(data[i].data2);
|
||||
length2 = (int) strlen(data[i].data2);
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data2, length2);
|
||||
assert_zero(ret, "i:%d ret %d != zero\n", i, ret);
|
||||
|
||||
@@ -995,7 +995,7 @@ static void test_scale(int index, int debug) {
|
||||
} else {
|
||||
text = data[i].data;
|
||||
}
|
||||
length = strlen(text);
|
||||
length = (int) strlen(text);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) text, length);
|
||||
assert_zero(ret, "i:%d ZBarcode_Encode(%d) ret %d != 0 %s\n", i, data[i].symbology, ret, symbol->errtxt);
|
||||
@@ -1207,8 +1207,8 @@ static void test_buffer_plot(int index, int generate, int debug) {
|
||||
ret = testUtilBitmapCmp(symbol, data[i].expected_bitmap, &row, &column);
|
||||
assert_zero(ret, "i:%d (%s) testUtilBitmapCmp ret %d != 0 column %d row %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), ret, column, row, data[i].data);
|
||||
|
||||
fg_len = strlen(data[i].fgcolour);
|
||||
bg_len = strlen(data[i].bgcolour);
|
||||
fg_len = (int) strlen(data[i].fgcolour);
|
||||
bg_len = (int) strlen(data[i].bgcolour);
|
||||
if (fg_len > 6 || bg_len > 6) {
|
||||
assert_nonnull(symbol->alphamap, "i:%d ZBarcode_Buffer(%s) alphamap NULL\n", i, testUtilBarcodeName(data[i].symbology));
|
||||
// TODO: check alphamap
|
||||
@@ -1674,7 +1674,7 @@ static void test_height(int index, int generate, int debug) {
|
||||
} else {
|
||||
text = data[i].data;
|
||||
}
|
||||
length = strlen(text);
|
||||
length = (int) strlen(text);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) text, length);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode(%s) ret %d != %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), ret, data[i].ret, symbol->errtxt);
|
||||
|
||||
+31
-28
@@ -794,7 +794,8 @@ static void test_examples(int index, int generate, int debug) {
|
||||
|
||||
if (generate) {
|
||||
printf(" /*%3d*/ { %s, %d, \"%s\", %d, %d, %d, %d, \"%s\",\n",
|
||||
i, testUtilBarcodeName(symbol->symbology), data[i].option_2, data[i].data, data[i].ret, symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].comment);
|
||||
i, testUtilBarcodeName(symbol->symbology), data[i].option_2,
|
||||
data[i].data, data[i].ret, symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].comment);
|
||||
testUtilModulesPrint(symbol, " ", "\n");
|
||||
printf(" },\n");
|
||||
} else {
|
||||
@@ -1228,6 +1229,7 @@ static void test_input(int index, int debug) {
|
||||
|
||||
struct item {
|
||||
int symbology;
|
||||
int option_2;
|
||||
char *data;
|
||||
int ret;
|
||||
int expected_rows;
|
||||
@@ -1235,32 +1237,33 @@ static void test_input(int index, int debug) {
|
||||
};
|
||||
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
|
||||
struct item data[] = {
|
||||
/* 0*/ { BARCODE_DBAR_OMN, "1234567890123", 0, 1, 96 },
|
||||
/* 1*/ { BARCODE_DBAR_OMN, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
||||
/* 2*/ { BARCODE_DBAR_OMN, "12345678901234", ZINT_ERROR_INVALID_CHECK, -1, -1 },
|
||||
/* 3*/ { BARCODE_DBAR_OMN, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 4*/ { BARCODE_DBAR_LTD, "1234567890123", 0, 1, 79 },
|
||||
/* 5*/ { BARCODE_DBAR_LTD, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
||||
/* 6*/ { BARCODE_DBAR_LTD, "12345678901235", ZINT_ERROR_INVALID_CHECK, -1, -1 },
|
||||
/* 7*/ { BARCODE_DBAR_LTD, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 8*/ { BARCODE_DBAR_LTD, "2234567890123", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
||||
/* 9*/ { BARCODE_DBAR_LTD, "22345678901238", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
||||
/* 10*/ { BARCODE_DBAR_EXP, "[01]12345678901234", ZINT_WARN_NONCOMPLIANT, 1, 134 },
|
||||
/* 11*/ { BARCODE_DBAR_EXP, "[01]12345678901231", 0, 1, 134 },
|
||||
/* 12*/ { BARCODE_DBAR_EXP, "[01]1234567890123A", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
||||
/* 13*/ { BARCODE_DBAR_EXP, "[01]123456789012315", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
||||
/* 14*/ { BARCODE_DBAR_STK, "1234567890123", 0, 3, 50 },
|
||||
/* 15*/ { BARCODE_DBAR_STK, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
||||
/* 16*/ { BARCODE_DBAR_STK, "12345678901235", ZINT_ERROR_INVALID_CHECK, -1, -1 },
|
||||
/* 17*/ { BARCODE_DBAR_STK, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 18*/ { BARCODE_DBAR_OMNSTK, "1234567890123", 0, 5, 50 },
|
||||
/* 19*/ { BARCODE_DBAR_OMNSTK, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
||||
/* 20*/ { BARCODE_DBAR_OMNSTK, "12345678901236", ZINT_ERROR_INVALID_CHECK, -1, -1 },
|
||||
/* 21*/ { BARCODE_DBAR_OMNSTK, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 22*/ { BARCODE_DBAR_EXPSTK, "[01]12345678901234", ZINT_WARN_NONCOMPLIANT, 5, 102 },
|
||||
/* 22*/ { BARCODE_DBAR_EXPSTK, "[01]12345678901231", 0, 5, 102 },
|
||||
/* 23*/ { BARCODE_DBAR_EXPSTK, "[01]123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
||||
/* 24*/ { BARCODE_DBAR_EXPSTK, "[01]123456789012315", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
||||
/* 0*/ { BARCODE_DBAR_OMN, -1, "1234567890123", 0, 1, 96 },
|
||||
/* 1*/ { BARCODE_DBAR_OMN, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
||||
/* 2*/ { BARCODE_DBAR_OMN, -1, "12345678901234", ZINT_ERROR_INVALID_CHECK, -1, -1 },
|
||||
/* 3*/ { BARCODE_DBAR_OMN, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 4*/ { BARCODE_DBAR_LTD, -1, "1234567890123", 0, 1, 79 },
|
||||
/* 5*/ { BARCODE_DBAR_LTD, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
||||
/* 6*/ { BARCODE_DBAR_LTD, -1, "12345678901235", ZINT_ERROR_INVALID_CHECK, -1, -1 },
|
||||
/* 7*/ { BARCODE_DBAR_LTD, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 8*/ { BARCODE_DBAR_LTD, -1, "2234567890123", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
||||
/* 9*/ { BARCODE_DBAR_LTD, -1, "22345678901238", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
||||
/* 10*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901234", ZINT_WARN_NONCOMPLIANT, 1, 134 },
|
||||
/* 11*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231", 0, 1, 134 },
|
||||
/* 12*/ { BARCODE_DBAR_EXP, -1, "[01]1234567890123A", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
||||
/* 13*/ { BARCODE_DBAR_EXP, -1, "[01]123456789012315", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
||||
/* 14*/ { BARCODE_DBAR_STK, -1, "1234567890123", 0, 3, 50 },
|
||||
/* 15*/ { BARCODE_DBAR_STK, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
||||
/* 16*/ { BARCODE_DBAR_STK, -1, "12345678901235", ZINT_ERROR_INVALID_CHECK, -1, -1 },
|
||||
/* 17*/ { BARCODE_DBAR_STK, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 18*/ { BARCODE_DBAR_OMNSTK, -1, "1234567890123", 0, 5, 50 },
|
||||
/* 19*/ { BARCODE_DBAR_OMNSTK, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
||||
/* 20*/ { BARCODE_DBAR_OMNSTK, -1, "12345678901236", ZINT_ERROR_INVALID_CHECK, -1, -1 },
|
||||
/* 21*/ { BARCODE_DBAR_OMNSTK, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 22*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901234", ZINT_WARN_NONCOMPLIANT, 5, 102 },
|
||||
/* 23*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231", 0, 5, 102 },
|
||||
/* 24*/ { BARCODE_DBAR_EXPSTK, -1, "[01]123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
||||
/* 25*/ { BARCODE_DBAR_EXPSTK, -1, "[01]123456789012315", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
||||
/* 26*/ { BARCODE_DBAR_EXPSTK, 1, "[01]12345678901231", 0, 9, 53 },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
@@ -1275,7 +1278,7 @@ static void test_input(int index, int debug) {
|
||||
symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].data, length);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||
|
||||
@@ -155,7 +155,7 @@ static void test_print(int index, int generate, int debug) {
|
||||
} else {
|
||||
text = data[i].data;
|
||||
}
|
||||
text_length = strlen(text);
|
||||
text_length = (int) strlen(text);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) text, text_length);
|
||||
assert_equal(ret, data[i].ret, "i:%d %s ZBarcode_Encode ret %d != %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), ret, data[i].ret, symbol->errtxt);
|
||||
|
||||
@@ -238,7 +238,7 @@ static void test_print(int index, int generate, int debug) {
|
||||
} else {
|
||||
text = data[i].data;
|
||||
}
|
||||
text_length = strlen(text);
|
||||
text_length = (int) strlen(text);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) text, text_length);
|
||||
assert_zero(ret, "i:%d %s ZBarcode_Encode ret %d != 0 %s\n", i, testUtilBarcodeName(data[i].symbology), ret, symbol->errtxt);
|
||||
|
||||
@@ -290,7 +290,7 @@ static void test_buffer_vector(int index, int generate, int debug) {
|
||||
} else {
|
||||
text = data[i].data;
|
||||
}
|
||||
length = strlen(text);
|
||||
length = (int) strlen(text);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) text, length);
|
||||
assert_zero(ret, "i:%d ZBarcode_Encode(%d) ret %d != 0 %s\n", i, data[i].symbology, ret, symbol->errtxt);
|
||||
@@ -397,7 +397,7 @@ static void test_upcean_hrt(int index, int debug) {
|
||||
}
|
||||
symbol->debug |= debug;
|
||||
|
||||
length = strlen(data[i].data);
|
||||
length = (int) strlen(data[i].data);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
||||
assert_zero(ret, "i:%d ZBarcode_Encode(%d) ret %d != 0 %s\n", i, data[i].symbology, ret, symbol->errtxt);
|
||||
@@ -554,7 +554,7 @@ static void test_stacking(int index, int debug) {
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
||||
assert_zero(ret, "i:%d ret %d != zero\n", i, ret);
|
||||
|
||||
length2 = strlen(data[i].data2);
|
||||
length2 = (int) strlen(data[i].data2);
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data2, length2);
|
||||
assert_zero(ret, "i:%d ret %d != zero\n", i, ret);
|
||||
|
||||
@@ -754,7 +754,7 @@ static void test_noncomposite_string_x(int index, int debug) {
|
||||
symbol->input_mode = UNICODE_MODE;
|
||||
symbol->debug |= debug;
|
||||
|
||||
length = strlen(data[i].data);
|
||||
length = (int) strlen(data[i].data);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
||||
assert_zero(ret, "i:%d ZBarcode_Encode(%d) ret %d != 0 %s\n", i, data[i].symbology, ret, symbol->errtxt);
|
||||
@@ -815,7 +815,7 @@ static void test_upcean_whitespace_width(int index, int debug) {
|
||||
symbol->whitespace_width = data[i].whitespace_width;
|
||||
symbol->debug |= debug;
|
||||
|
||||
length = strlen(data[i].data);
|
||||
length = (int) strlen(data[i].data);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
||||
assert_zero(ret, "i:%d ZBarcode_Encode(%d) ret %d != 0 %s\n", i, data[i].symbology, ret, symbol->errtxt);
|
||||
@@ -1298,7 +1298,7 @@ static void test_height(int index, int generate, int debug) {
|
||||
} else {
|
||||
text = data[i].data;
|
||||
}
|
||||
length = strlen(text);
|
||||
length = (int) strlen(text);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) text, length);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode(%s) ret %d != %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), ret, data[i].ret, symbol->errtxt);
|
||||
|
||||
+403
-306
File diff suppressed because it is too large
Load Diff
@@ -70,20 +70,19 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef ARRAY_SIZE
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
#define ARRAY_SIZE(x) ((int) (sizeof(x) / sizeof((x)[0])))
|
||||
#endif
|
||||
|
||||
extern int assertionFailed;
|
||||
extern int assertionNum;
|
||||
extern const char *assertionFilename;
|
||||
|
||||
#if _MSC_VER == 1200 /* VC6 */
|
||||
#define testStart(__arg__) (testStartReal("", __arg__))
|
||||
#else
|
||||
#define testStart(__arg__) (testStartReal(__func__, __arg__))
|
||||
#endif
|
||||
#define testEndExp(__arg__) (testEnd(!(__arg__)))
|
||||
void testStartReal(const char *func, const char *name);
|
||||
void testEnd(int result);
|
||||
void testFinish(void);
|
||||
void testSkip(const char *msg);
|
||||
void testReport();
|
||||
@@ -104,7 +103,8 @@ void assert_equalu64(uint64_t e1, uint64_t e2, const char *fmt, ...);
|
||||
void assert_notequal(int e1, int e2, ...);
|
||||
#else
|
||||
#define assert_exp(__exp__, ...) \
|
||||
{assertionNum++; if (!(__exp__)) {assertionFailed++; printf(__VA_ARGS__); testFinish(); return;}}
|
||||
{ assertionNum++; if (!(__exp__)) { assertionFailed++; printf("%s:%d ", assertionFilename, __LINE__); \
|
||||
printf(__VA_ARGS__); testFinish(); return; } }
|
||||
|
||||
#define assert_zero(__exp__, ...) assert_exp((__exp__) == 0, __VA_ARGS__)
|
||||
#define assert_nonzero(__exp__, ...) assert_exp((__exp__) != 0, __VA_ARGS__)
|
||||
@@ -119,40 +119,47 @@ INTERNAL void vector_free(struct zint_symbol *symbol); /* Free vector structures
|
||||
|
||||
int testUtilSetSymbol(struct zint_symbol *symbol, int symbology, int input_mode, int eci,
|
||||
int option_1, int option_2, int option_3, int output_options, char *data, int length, int debug);
|
||||
|
||||
const char *testUtilBarcodeName(int symbology);
|
||||
const char *testUtilErrorName(int error_number);
|
||||
const char *testUtilInputModeName(int input_mode);
|
||||
const char *testUtilOption3Name(int option_3);
|
||||
const char *testUtilOutputOptionsName(int output_options);
|
||||
|
||||
int testUtilDAFTConvert(const struct zint_symbol *symbol, char *buffer, int buffer_size);
|
||||
int testUtilIsValidUTF8(const unsigned char str[], const int length);
|
||||
char *testUtilEscape(char *buffer, int length, char *escaped, int escaped_size);
|
||||
char *testUtilReadCSVField(char *buffer, char *field, int field_size);
|
||||
void testUtilStrCpyRepeat(char *buffer, char *repeat, int size);
|
||||
|
||||
int testUtilSymbolCmp(const struct zint_symbol *a, const struct zint_symbol *b);
|
||||
struct zint_vector *testUtilVectorCpy(const struct zint_vector *in);
|
||||
int testUtilVectorCmp(const struct zint_vector *a, const struct zint_vector *b);
|
||||
|
||||
int testUtilModulesDump(const struct zint_symbol *symbol, char dump[], int dump_size);
|
||||
void testUtilModulesPrint(const struct zint_symbol *symbol, const char *prefix, const char *postfix);
|
||||
void testUtilModulesPrintRow(const struct zint_symbol *symbol, int row, const char *prefix, const char *postfix);
|
||||
int testUtilModulesCmp(const struct zint_symbol *symbol, const char *expected, int *width, int *row);
|
||||
int testUtilModulesCmpRow(const struct zint_symbol *symbol, int row, const char *expected, int *width);
|
||||
int testUtilModulesDumpHex(const struct zint_symbol *symbol, char dump[], int dump_size);
|
||||
char *testUtilUIntArrayDump(unsigned int *array, int size, char *dump, int dump_size);
|
||||
char *testUtilUCharArrayDump(unsigned char *array, int size, char *dump, int dump_size);
|
||||
int testUtilDataPath(char *buffer, int buffer_size, const char *subdir, const char *filename);
|
||||
|
||||
void testUtilBitmapPrint(const struct zint_symbol *symbol, const char *prefix, const char *postfix);
|
||||
int testUtilBitmapCmp(const struct zint_symbol *symbol, const char *expected, int *row, int *column);
|
||||
|
||||
int testUtilDataPath(char *buffer, int buffer_size, const char *subdir, const char *filename);
|
||||
int testUtilExists(const char *filename);
|
||||
int testUtilDirExists(const char *dirname);
|
||||
int testUtilMkDir(const char *dirname);
|
||||
int testUtilRmDir(const char *dirname);
|
||||
int testUtilRename(const char *oldpath, const char *newpath);
|
||||
|
||||
int testUtilCmpPngs(const char *file1, const char *file2);
|
||||
int testUtilCmpTxts(const char *txt1, const char *txt2);
|
||||
int testUtilCmpBins(const char *bin1, const char *bin2);
|
||||
int testUtilCmpSvgs(const char *svg1, const char *svg2);
|
||||
int testUtilCmpEpss(const char *eps1, const char *eps2);
|
||||
|
||||
int testUtilHaveIdentify();
|
||||
int testUtilVerifyIdentify(const char *filename, int debug);
|
||||
int testUtilHaveLibreOffice();
|
||||
@@ -163,6 +170,7 @@ int testUtilHaveVnu();
|
||||
int testUtilVerifyVnu(const char *filename, int debug);
|
||||
int testUtilHaveTiffInfo();
|
||||
int testUtilVerifyTiffInfo(const char *filename, int debug);
|
||||
|
||||
int testUtilCanBwipp(int index, const struct zint_symbol *symbol, int option_1, int option_2, int option_3,
|
||||
int debug);
|
||||
int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int option_2, int option_3,
|
||||
|
||||
Reference in New Issue
Block a user