mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
DATAMATRIX: make EOD encodation strictly ISO 16022 compliant
This commit is contained in:
parent
63053c4c0f
commit
88d1a9f625
@ -231,10 +231,10 @@ static int c1_look_ahead_test(const unsigned char source[], const int sourcelen,
|
|||||||
byte_count += 1.0f; /* Step P2 */
|
byte_count += 1.0f; /* Step P2 */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If not end of data and at least 4 characters processed */
|
/* If at least 4 characters processed */
|
||||||
/* NOTE: different than spec, where it's at least 3, but that ends up suppressing C40/TEXT/EDI.
|
/* NOTE: different than spec, where it's at least 3, but that ends up suppressing C40/TEXT/EDI.
|
||||||
BWIPP uses 4, as does very similar Data Matrix ISO/IEC 16022:2006 Annex P algorithm */
|
BWIPP also uses 4 (cf very similar Data Matrix ISO/IEC 16022:2006 Annex P algorithm) */
|
||||||
if (sp + 1 != sourcelen && sp >= position + 3) {
|
if (sp >= position + 3) {
|
||||||
/* Step Q */
|
/* Step Q */
|
||||||
float cnt;
|
float cnt;
|
||||||
ascii_rnded = (int) ceilf(ascii_count);
|
ascii_rnded = (int) ceilf(ascii_count);
|
||||||
|
1046
backend/dmatrix.c
1046
backend/dmatrix.c
File diff suppressed because it is too large
Load Diff
@ -47,5 +47,3 @@ INTERNAL int get_best_eci(const unsigned char source[], int length);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* ECI_H */
|
#endif /* ECI_H */
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
libzint - the open source barcode library
|
libzint - the open source barcode library
|
||||||
Copyright (C) 2020 Robin Stuart <rstuart114@gmail.com>
|
Copyright (C) 2020 - 2021 Robin Stuart <rstuart114@gmail.com>
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions
|
modification, are permitted provided that the following conditions
|
||||||
@ -82,7 +82,7 @@ static void test_large(int index, int debug) {
|
|||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
|
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
|
||||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||||
|
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
||||||
}
|
}
|
||||||
@ -176,7 +176,7 @@ static void test_input(int index, int debug) {
|
|||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
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);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||||
|
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
||||||
}
|
}
|
||||||
@ -271,10 +271,10 @@ static void test_encode(int index, int generate, int debug) {
|
|||||||
printf(" /*%3d*/ { %s, \"%s\", %s, %d, %d, \"%s\",\n",
|
printf(" /*%3d*/ { %s, \"%s\", %s, %d, %d, \"%s\",\n",
|
||||||
i, testUtilBarcodeName(data[i].symbology), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
i, testUtilBarcodeName(data[i].symbology), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
||||||
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
|
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
|
||||||
testUtilModulesDump(symbol, " ", "\n");
|
testUtilModulesPrint(symbol, " ", "\n");
|
||||||
printf(" },\n");
|
printf(" },\n");
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
libzint - the open source barcode library
|
libzint - the open source barcode library
|
||||||
Copyright (C) 2020 Robin Stuart <rstuart114@gmail.com>
|
Copyright (C) 2020 - 2021 Robin Stuart <rstuart114@gmail.com>
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions
|
modification, are permitted provided that the following conditions
|
||||||
@ -82,7 +82,7 @@ static void test_large(int index, int debug) {
|
|||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
|
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
|
||||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||||
|
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
||||||
}
|
}
|
||||||
@ -177,7 +177,7 @@ static void test_input(int index, int debug) {
|
|||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
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);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||||
|
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
||||||
}
|
}
|
||||||
@ -271,10 +271,10 @@ static void test_encode(int index, int generate, int debug) {
|
|||||||
printf(" /*%3d*/ { %s, \"%s\", %s, %d, %d, \"%s\",\n",
|
printf(" /*%3d*/ { %s, \"%s\", %s, %d, %d, \"%s\",\n",
|
||||||
i, testUtilBarcodeName(data[i].symbology), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
i, testUtilBarcodeName(data[i].symbology), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
||||||
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
|
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
|
||||||
testUtilModulesDump(symbol, " ", "\n");
|
testUtilModulesPrint(symbol, " ", "\n");
|
||||||
printf(" },\n");
|
printf(" },\n");
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
|
|
||||||
@ -320,7 +320,7 @@ static void test_fuzz(int index, int debug) {
|
|||||||
/* 4*/ { BARCODE_AUSREDIRECT, "A\000\000\000", 4, ZINT_ERROR_INVALID_DATA },
|
/* 4*/ { BARCODE_AUSREDIRECT, "A\000\000\000", 4, ZINT_ERROR_INVALID_DATA },
|
||||||
/* 5*/ { BARCODE_AUSREDIRECT, "1\000\000\000", 4, ZINT_ERROR_INVALID_DATA },
|
/* 5*/ { BARCODE_AUSREDIRECT, "1\000\000\000", 4, ZINT_ERROR_INVALID_DATA },
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
for (int i = 0; i < data_size; i++) {
|
for (int i = 0; i < data_size; i++) {
|
||||||
|
|
||||||
@ -329,13 +329,7 @@ static void test_fuzz(int index, int debug) {
|
|||||||
struct zint_symbol *symbol = ZBarcode_Create();
|
struct zint_symbol *symbol = ZBarcode_Create();
|
||||||
assert_nonnull(symbol, "Symbol not created\n");
|
assert_nonnull(symbol, "Symbol not created\n");
|
||||||
|
|
||||||
symbol->symbology = data[i].symbology;
|
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
|
||||||
symbol->debug |= debug;
|
|
||||||
|
|
||||||
int length = data[i].length;
|
|
||||||
if (length == -1) {
|
|
||||||
length = strlen(data[i].data);
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
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);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||||
|
@ -1492,10 +1492,10 @@ static void test_encode(int index, int generate, int debug) {
|
|||||||
i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), data[i].eci, testUtilOutputOptionsName(data[i].output_options),
|
i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), data[i].eci, testUtilOutputOptionsName(data[i].output_options),
|
||||||
data[i].option_1, data[i].option_2, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length,
|
data[i].option_1, data[i].option_2, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length,
|
||||||
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].comment);
|
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].comment);
|
||||||
testUtilModulesDump(symbol, " ", "\n");
|
testUtilModulesPrint(symbol, " ", "\n");
|
||||||
printf(" },\n");
|
printf(" },\n");
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
libzint - the open source barcode library
|
libzint - the open source barcode library
|
||||||
Copyright (C) 2019 - 2020 Robin Stuart <rstuart114@gmail.com>
|
Copyright (C) 2019 - 2021 Robin Stuart <rstuart114@gmail.com>
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions
|
modification, are permitted provided that the following conditions
|
||||||
@ -107,7 +107,7 @@ static void test_input(int index, int debug) {
|
|||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
||||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret);
|
||||||
|
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
}
|
}
|
||||||
@ -369,10 +369,10 @@ static void test_encode(int index, int generate, int debug) {
|
|||||||
printf(" /*%3d*/ { %d, \"%s\", %s, %d, %d, \"%s\",\n",
|
printf(" /*%3d*/ { %d, \"%s\", %s, %d, %d, \"%s\",\n",
|
||||||
i, data[i].option_2, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
i, data[i].option_2, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
||||||
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
|
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
|
||||||
testUtilModulesDump(symbol, " ", "\n");
|
testUtilModulesPrint(symbol, " ", "\n");
|
||||||
printf(" },\n");
|
printf(" },\n");
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
libzint - the open source barcode library
|
libzint - the open source barcode library
|
||||||
Copyright (C) 2019 - 2020 Robin Stuart <rstuart114@gmail.com>
|
Copyright (C) 2019 - 2021 Robin Stuart <rstuart114@gmail.com>
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions
|
modification, are permitted provided that the following conditions
|
||||||
@ -74,7 +74,7 @@ static void test_large(int index, int debug) {
|
|||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
|
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
|
||||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||||
|
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
||||||
}
|
}
|
||||||
@ -141,7 +141,7 @@ static void test_options(int index, int debug) {
|
|||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
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);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||||
|
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
}
|
}
|
||||||
@ -196,7 +196,7 @@ static void test_reader_init(int index, int generate, int debug) {
|
|||||||
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
||||||
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, symbol->errtxt, data[i].comment);
|
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, symbol->errtxt, data[i].comment);
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
assert_zero(strcmp((char *) symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
assert_zero(strcmp((char *) symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||||
@ -303,7 +303,7 @@ static void test_input(int index, int generate, int debug) {
|
|||||||
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length,
|
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length,
|
||||||
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, symbol->errtxt, data[i].comment);
|
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, symbol->errtxt, data[i].comment);
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
assert_zero(strcmp((char *) symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
assert_zero(strcmp((char *) symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||||
@ -433,10 +433,10 @@ static void test_encode(int index, int generate, int debug) {
|
|||||||
printf(" /*%3d*/ { %s, %d, %d, \"%s\", %s, %d, %d, %d, \"%s\",\n",
|
printf(" /*%3d*/ { %s, %d, %d, \"%s\", %s, %d, %d, %d, \"%s\",\n",
|
||||||
i, testUtilBarcodeName(data[i].symbology), data[i].option_1, data[i].option_2, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
i, testUtilBarcodeName(data[i].symbology), data[i].option_1, data[i].option_2, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
||||||
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].comment);
|
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].comment);
|
||||||
testUtilModulesDump(symbol, " ", "\n");
|
testUtilModulesPrint(symbol, " ", "\n");
|
||||||
printf(" },\n");
|
printf(" },\n");
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
libzint - the open source barcode library
|
libzint - the open source barcode library
|
||||||
Copyright (C) 2020 Robin Stuart <rstuart114@gmail.com>
|
Copyright (C) 2020 - 2021 Robin Stuart <rstuart114@gmail.com>
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions
|
modification, are permitted provided that the following conditions
|
||||||
@ -91,7 +91,7 @@ static void test_large(int index, int debug) {
|
|||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
|
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
|
||||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||||
|
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
||||||
}
|
}
|
||||||
@ -226,7 +226,7 @@ static void test_input(int index, int debug) {
|
|||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
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);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||||
|
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
||||||
}
|
}
|
||||||
@ -358,10 +358,10 @@ static void test_encode(int index, int generate, int debug) {
|
|||||||
printf(" /*%3d*/ { %s, %d, \"%s\", %d, %s, %d, %d, \"%s\",\n",
|
printf(" /*%3d*/ { %s, %d, \"%s\", %d, %s, %d, %d, \"%s\",\n",
|
||||||
i, testUtilBarcodeName(data[i].symbology), data[i].option_2, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length,
|
i, testUtilBarcodeName(data[i].symbology), data[i].option_2, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length,
|
||||||
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
|
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
|
||||||
testUtilModulesDump(symbol, " ", "\n");
|
testUtilModulesPrint(symbol, " ", "\n");
|
||||||
printf(" },\n");
|
printf(" },\n");
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
|
|
||||||
|
@ -2525,7 +2525,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||||||
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length,
|
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length,
|
||||||
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].comment);
|
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].comment);
|
||||||
if (ret < ZINT_ERROR) {
|
if (ret < ZINT_ERROR) {
|
||||||
testUtilModulesDump(symbol, " ", "\n");
|
testUtilModulesPrint(symbol, " ", "\n");
|
||||||
} else {
|
} else {
|
||||||
printf(" \"\"\n");
|
printf(" \"\"\n");
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ static void test_large(int index, int debug) {
|
|||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
|
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
|
||||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||||
|
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,7 +256,7 @@ static void test_reader_init(int index, int generate, int debug) {
|
|||||||
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
||||||
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, symbol->errtxt, data[i].comment);
|
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, symbol->errtxt, data[i].comment);
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||||
@ -327,7 +327,7 @@ static void test_input(int index, int generate, int debug) {
|
|||||||
/* 32*/ { UNICODE_MODE, "aééééébcdeééé", -1, 0, 244, "(22) 104 65 100 100 73 73 73 73 73 100 66 100 67 100 68 100 69 73 73 73 83 106", "StartB a Latch é (5) Shift b Shift c Shift d Shift e é (3)" },
|
/* 32*/ { UNICODE_MODE, "aééééébcdeééé", -1, 0, 244, "(22) 104 65 100 100 73 73 73 73 73 100 66 100 67 100 68 100 69 73 73 73 83 106", "StartB a Latch é (5) Shift b Shift c Shift d Shift e é (3)" },
|
||||||
/* 33*/ { UNICODE_MODE, "aééééébcdefééé", -1, 0, 255, "(23) 104 65 100 100 73 73 73 73 73 100 100 66 67 68 69 70 100 100 73 73 73 67 106", "StartB a Latch é (5) Unlatch b c d e f Latch é (3)" },
|
/* 33*/ { UNICODE_MODE, "aééééébcdefééé", -1, 0, 255, "(23) 104 65 100 100 73 73 73 73 73 100 100 66 67 68 69 70 100 100 73 73 73 67 106", "StartB a Latch é (5) Unlatch b c d e f Latch é (3)" },
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
char escaped[1024];
|
char escaped[1024];
|
||||||
|
|
||||||
@ -350,7 +350,7 @@ static void test_input(int index, int generate, int debug) {
|
|||||||
i, testUtilInputModeName(data[i].input_mode), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length,
|
i, testUtilInputModeName(data[i].input_mode), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length,
|
||||||
testUtilErrorName(data[i].ret), symbol->width, symbol->errtxt, data[i].comment);
|
testUtilErrorName(data[i].ret), symbol->width, symbol->errtxt, data[i].comment);
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||||
}
|
}
|
||||||
@ -397,7 +397,7 @@ static void test_ean128_input(int index, int generate, int debug) {
|
|||||||
/* 19*/ { "[90]1A[90]1", 0, 134, "(12) 104 102 25 16 17 33 102 25 99 1 65 106", "StartB FNC1 9 0 1 A FNC1 9 CodeC 01" },
|
/* 19*/ { "[90]1A[90]1", 0, 134, "(12) 104 102 25 16 17 33 102 25 99 1 65 106", "StartB FNC1 9 0 1 A FNC1 9 CodeC 01" },
|
||||||
/* 20*/ { "[90]12A[90]123", 0, 145, "(13) 105 102 90 12 100 33 102 25 99 1 23 25 106", "StartC FNC1 90 12 CodeB A FNC1 9 CodeC 01 23" },
|
/* 20*/ { "[90]12A[90]123", 0, 145, "(13) 105 102 90 12 100 33 102 25 99 1 23 25 106", "StartC FNC1 90 12 CodeB A FNC1 9 CodeC 01 23" },
|
||||||
/* 21*/ { "[90]123[90]A234[90]123", 0, 244, "(22) 105 102 90 12 100 19 99 102 90 100 33 18 99 34 102 100 25 99 1 23 37 106", "StartC FNC1 90 12 CodeB 3 CodeC FNC1 90 CodeB A 2 CodeC 34 FNC1 CodeB 9 CodeC 01 23" } };
|
/* 21*/ { "[90]123[90]A234[90]123", 0, 244, "(22) 105 102 90 12 100 19 99 102 90 100 33 18 99 34 102 100 25 99 1 23 37 106", "StartC FNC1 90 12 CodeB 3 CodeC FNC1 90 CodeB A 2 CodeC 34 FNC1 CodeB 9 CodeC 01 23" } };
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
char escaped[1024];
|
char escaped[1024];
|
||||||
|
|
||||||
@ -420,7 +420,7 @@ static void test_ean128_input(int index, int generate, int debug) {
|
|||||||
i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
||||||
testUtilErrorName(data[i].ret), symbol->width, symbol->errtxt, data[i].comment);
|
testUtilErrorName(data[i].ret), symbol->width, symbol->errtxt, data[i].comment);
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||||
}
|
}
|
||||||
@ -471,7 +471,7 @@ static void test_hibc_input(int index, int generate, int debug) {
|
|||||||
i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
||||||
testUtilErrorName(data[i].ret), symbol->width, symbol->errtxt, data[i].comment);
|
testUtilErrorName(data[i].ret), symbol->width, symbol->errtxt, data[i].comment);
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||||
}
|
}
|
||||||
@ -632,7 +632,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||||||
"110100111001100110110011101101110101110110001000010110011011011110110011011001110110111010111011000100001011001101101111011001101100111011011101011101100010000101100101011110001100011101011"
|
"110100111001100110110011101101110101110110001000010110011011011110110011011001110110111010111011000100001011001101101111011001101100111011011101011101100010000101100101011110001100011101011"
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
char escaped[1024];
|
char escaped[1024];
|
||||||
char bwipp_buf[8192];
|
char bwipp_buf[8192];
|
||||||
@ -654,10 +654,10 @@ static void test_encode(int index, int generate, int debug) {
|
|||||||
printf(" /*%3d*/ { %s, %s, \"%s\", %s, %d, %d, %d, \"%s\",\n",
|
printf(" /*%3d*/ { %s, %s, \"%s\", %s, %d, %d, %d, \"%s\",\n",
|
||||||
i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
||||||
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].comment);
|
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].comment);
|
||||||
testUtilModulesDump(symbol, " ", "\n");
|
testUtilModulesPrint(symbol, " ", "\n");
|
||||||
printf(" },\n");
|
printf(" },\n");
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
libzint - the open source barcode library
|
libzint - the open source barcode library
|
||||||
Copyright (C) 2020 Robin Stuart <rstuart114@gmail.com>
|
Copyright (C) 2020 - 2021 Robin Stuart <rstuart114@gmail.com>
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions
|
modification, are permitted provided that the following conditions
|
||||||
@ -69,7 +69,7 @@ static void test_large(int index, int debug) {
|
|||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
|
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
|
||||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||||
|
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
||||||
}
|
}
|
||||||
@ -125,7 +125,7 @@ static void test_reader_init(int index, int generate, int debug) {
|
|||||||
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
||||||
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, symbol->errtxt, data[i].comment);
|
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, symbol->errtxt, data[i].comment);
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
assert_zero(strcmp((char *) symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
assert_zero(strcmp((char *) symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||||
@ -203,7 +203,7 @@ static void test_input(int index, int generate, int debug) {
|
|||||||
i, testUtilInputModeName(data[i].input_mode), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length,
|
i, testUtilInputModeName(data[i].input_mode), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length,
|
||||||
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, symbol->errtxt, data[i].comment);
|
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, symbol->errtxt, data[i].comment);
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
assert_zero(strcmp((char *) symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
assert_zero(strcmp((char *) symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||||
@ -267,10 +267,10 @@ static void test_encode(int index, int generate, int debug) {
|
|||||||
printf(" /*%3d*/ { %s, \"%s\", %s, %d, %d, \"%s\",\n",
|
printf(" /*%3d*/ { %s, \"%s\", %s, %d, %d, \"%s\",\n",
|
||||||
i, testUtilInputModeName(data[i].input_mode), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
i, testUtilInputModeName(data[i].input_mode), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
||||||
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
|
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
|
||||||
testUtilModulesDump(symbol, " ", "\n");
|
testUtilModulesPrint(symbol, " ", "\n");
|
||||||
printf(" },\n");
|
printf(" },\n");
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
libzint - the open source barcode library
|
libzint - the open source barcode library
|
||||||
Copyright (C) 2020 Robin Stuart <rstuart114@gmail.com>
|
Copyright (C) 2020 - 2021 Robin Stuart <rstuart114@gmail.com>
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions
|
modification, are permitted provided that the following conditions
|
||||||
@ -69,7 +69,7 @@ static void test_large(int index, int debug) {
|
|||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
|
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
|
||||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||||
|
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
||||||
}
|
}
|
||||||
@ -136,7 +136,7 @@ static void test_input(int index, int generate, int debug) {
|
|||||||
i, testUtilInputModeName(data[i].input_mode), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length,
|
i, testUtilInputModeName(data[i].input_mode), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length,
|
||||||
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, symbol->errtxt, data[i].comment);
|
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, symbol->errtxt, data[i].comment);
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
assert_zero(strcmp((char *) symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
assert_zero(strcmp((char *) symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||||
@ -201,10 +201,10 @@ static void test_encode(int index, int generate, int debug) {
|
|||||||
printf(" /*%3d*/ { %s, \"%s\", %s, %d, %d, \"%s\",\n",
|
printf(" /*%3d*/ { %s, \"%s\", %s, %d, %d, \"%s\",\n",
|
||||||
i, testUtilInputModeName(data[i].input_mode), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
i, testUtilInputModeName(data[i].input_mode), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
||||||
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
|
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
|
||||||
testUtilModulesDump(symbol, " ", "\n");
|
testUtilModulesPrint(symbol, " ", "\n");
|
||||||
printf(" },\n");
|
printf(" },\n");
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ static void test_eanx_leading_zeroes(int index, int debug) {
|
|||||||
/*25*/ { BARCODE_EANX_CC, "1234567890128+12", "[21]A12345678", 0, 7, 126 }, // EAN-13 + CHK + EAN-2
|
/*25*/ { BARCODE_EANX_CC, "1234567890128+12", "[21]A12345678", 0, 7, 126 }, // EAN-13 + CHK + EAN-2
|
||||||
/*26*/ { BARCODE_EANX_CC, "1234567890128+12345", "[21]A12345678", 0, 7, 153 }, // EAN-13 + CHK + EAN-5
|
/*26*/ { BARCODE_EANX_CC, "1234567890128+12345", "[21]A12345678", 0, 7, 153 }, // EAN-13 + CHK + EAN-5
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
for (int i = 0; i < data_size; i++) {
|
for (int i = 0; i < data_size; i++) {
|
||||||
|
|
||||||
@ -84,10 +84,7 @@ static void test_eanx_leading_zeroes(int index, int debug) {
|
|||||||
struct zint_symbol *symbol = ZBarcode_Create();
|
struct zint_symbol *symbol = ZBarcode_Create();
|
||||||
assert_nonnull(symbol, "Symbol not created\n");
|
assert_nonnull(symbol, "Symbol not created\n");
|
||||||
|
|
||||||
symbol->symbology = data[i].symbology;
|
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||||
symbol->debug |= debug;
|
|
||||||
|
|
||||||
int length = strlen(data[i].data);
|
|
||||||
assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length);
|
assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length);
|
||||||
strcpy(symbol->primary, data[i].data);
|
strcpy(symbol->primary, data[i].data);
|
||||||
|
|
||||||
@ -96,7 +93,7 @@ static void test_eanx_leading_zeroes(int index, int debug) {
|
|||||||
ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].composite, composite_length);
|
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);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||||
|
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
||||||
}
|
}
|
||||||
@ -122,7 +119,7 @@ static void test_helper_generate(const struct zint_symbol *symbol, int ret, int
|
|||||||
printf(" /*%2d*/ { %s, %d, \"%s\", \"%s\", %d, %d, %d, %d, \"%s\",\n",
|
printf(" /*%2d*/ { %s, %d, \"%s\", \"%s\", %d, %d, %d, %d, \"%s\",\n",
|
||||||
i, testUtilBarcodeName(symbol->symbology), option_1, esc_data, esc_composite, ret, symbol->rows, symbol->width, bwipp_cmp, comment);
|
i, testUtilBarcodeName(symbol->symbology), option_1, esc_data, esc_composite, ret, symbol->rows, symbol->width, bwipp_cmp, comment);
|
||||||
}
|
}
|
||||||
testUtilModulesDump(symbol, " ", "\n");
|
testUtilModulesPrint(symbol, " ", "\n");
|
||||||
printf(" },\n");
|
printf(" },\n");
|
||||||
} else {
|
} else {
|
||||||
if (bwipp_cmp == -1) {
|
if (bwipp_cmp == -1) {
|
||||||
@ -1229,7 +1226,7 @@ static void test_examples(int index, int generate, int debug) {
|
|||||||
"000101001001101111010011101011000100001010010001010101001000111010011100101100110110110010010001010000000101101011110101110010"
|
"000101001001101111010011101011000100001010010001010101001000111010011100101100110110110010010001010000000101101011110101110010"
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
char bwipp_buf[32768];
|
char bwipp_buf[32768];
|
||||||
char bwipp_msg[1024];
|
char bwipp_msg[1024];
|
||||||
@ -1242,11 +1239,7 @@ static void test_examples(int index, int generate, int debug) {
|
|||||||
struct zint_symbol *symbol = ZBarcode_Create();
|
struct zint_symbol *symbol = ZBarcode_Create();
|
||||||
assert_nonnull(symbol, "Symbol not created\n");
|
assert_nonnull(symbol, "Symbol not created\n");
|
||||||
|
|
||||||
symbol->symbology = data[i].symbology;
|
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, data[i].option_1, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||||
symbol->option_1 = data[i].option_1;
|
|
||||||
symbol->debug |= debug;
|
|
||||||
|
|
||||||
int length = strlen(data[i].data);
|
|
||||||
assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length);
|
assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length);
|
||||||
strcpy(symbol->primary, data[i].data);
|
strcpy(symbol->primary, data[i].data);
|
||||||
|
|
||||||
@ -1395,7 +1388,7 @@ static void test_odd_numbered_numeric(int index, int generate, int debug) {
|
|||||||
"0001010010011011110101000110111001000010100100010101010"
|
"0001010010011011110101000110111001000010100100010101010"
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
char bwipp_buf[8192];
|
char bwipp_buf[8192];
|
||||||
char bwipp_msg[1024];
|
char bwipp_msg[1024];
|
||||||
@ -1408,11 +1401,7 @@ static void test_odd_numbered_numeric(int index, int generate, int debug) {
|
|||||||
struct zint_symbol *symbol = ZBarcode_Create();
|
struct zint_symbol *symbol = ZBarcode_Create();
|
||||||
assert_nonnull(symbol, "Symbol not created\n");
|
assert_nonnull(symbol, "Symbol not created\n");
|
||||||
|
|
||||||
symbol->symbology = data[i].symbology;
|
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, data[i].option_1, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||||
symbol->option_1 = data[i].option_1;
|
|
||||||
symbol->debug |= debug;
|
|
||||||
|
|
||||||
int length = strlen(data[i].data);
|
|
||||||
assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length);
|
assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length);
|
||||||
strcpy(symbol->primary, data[i].data);
|
strcpy(symbol->primary, data[i].data);
|
||||||
|
|
||||||
@ -1526,7 +1515,7 @@ static void test_ean128_cc_shift(int index, int generate, int debug) {
|
|||||||
"1101001110011110101110111101101101011001110010001011000111000101101100001010011011110110101111011101001110011010111011110100110100001100011101011"
|
"1101001110011110101110111101101101011001110010001011000111000101101100001010011011110110101111011101001110011010111011110100110100001100011101011"
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
char bwipp_buf[8192];
|
char bwipp_buf[8192];
|
||||||
char bwipp_msg[1024];
|
char bwipp_msg[1024];
|
||||||
@ -1538,11 +1527,7 @@ static void test_ean128_cc_shift(int index, int generate, int debug) {
|
|||||||
struct zint_symbol *symbol = ZBarcode_Create();
|
struct zint_symbol *symbol = ZBarcode_Create();
|
||||||
assert_nonnull(symbol, "Symbol not created\n");
|
assert_nonnull(symbol, "Symbol not created\n");
|
||||||
|
|
||||||
symbol->symbology = data[i].symbology;
|
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, data[i].option_1, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||||
symbol->option_1 = data[i].option_1;
|
|
||||||
symbol->debug |= debug;
|
|
||||||
|
|
||||||
int length = strlen(data[i].data);
|
|
||||||
assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length);
|
assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length);
|
||||||
strcpy(symbol->primary, data[i].data);
|
strcpy(symbol->primary, data[i].data);
|
||||||
|
|
||||||
@ -1611,7 +1596,7 @@ static void test_ean128_cc_width(int index, int generate, int debug) {
|
|||||||
/*11*/ { "[00]123456789012345675", "[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[91]1234567890", 0, 32, 579, "With composite 2372 digits == max" },
|
/*11*/ { "[00]123456789012345675", "[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[91]1234567890", 0, 32, 579, "With composite 2372 digits == max" },
|
||||||
/*12*/ { "[00]123456789012345675", "[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[91]12345678901", ZINT_ERROR_TOO_LONG, 0, 0, "With composite 2373 digits > max" },
|
/*12*/ { "[00]123456789012345675", "[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[91]12345678901", ZINT_ERROR_TOO_LONG, 0, 0, "With composite 2373 digits > max" },
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
for (int i = 0; i < data_size; i++) {
|
for (int i = 0; i < data_size; i++) {
|
||||||
|
|
||||||
@ -1620,11 +1605,7 @@ static void test_ean128_cc_width(int index, int generate, int debug) {
|
|||||||
struct zint_symbol *symbol = ZBarcode_Create();
|
struct zint_symbol *symbol = ZBarcode_Create();
|
||||||
assert_nonnull(symbol, "Symbol not created\n");
|
assert_nonnull(symbol, "Symbol not created\n");
|
||||||
|
|
||||||
symbol->symbology = BARCODE_GS1_128_CC;
|
int length = testUtilSetSymbol(symbol, BARCODE_GS1_128_CC, -1 /*input_mode*/, -1 /*eci*/, 3, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||||
symbol->option_1 = 3;
|
|
||||||
symbol->debug |= debug;
|
|
||||||
|
|
||||||
int length = strlen(data[i].data);
|
|
||||||
assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length);
|
assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length);
|
||||||
strcpy(symbol->primary, data[i].data);
|
strcpy(symbol->primary, data[i].data);
|
||||||
|
|
||||||
@ -2077,7 +2058,7 @@ static void test_encodation_0(int index, int generate, int debug) {
|
|||||||
"0001010010011011110101000110111001000010100100010101010"
|
"0001010010011011110101000110111001000010100100010101010"
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
char bwipp_buf[8192];
|
char bwipp_buf[8192];
|
||||||
char bwipp_msg[1024];
|
char bwipp_msg[1024];
|
||||||
@ -2089,11 +2070,7 @@ static void test_encodation_0(int index, int generate, int debug) {
|
|||||||
struct zint_symbol *symbol = ZBarcode_Create();
|
struct zint_symbol *symbol = ZBarcode_Create();
|
||||||
assert_nonnull(symbol, "Symbol not created\n");
|
assert_nonnull(symbol, "Symbol not created\n");
|
||||||
|
|
||||||
symbol->symbology = data[i].symbology;
|
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, data[i].option_1, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||||
symbol->option_1 = data[i].option_1;
|
|
||||||
symbol->debug |= debug;
|
|
||||||
|
|
||||||
int length = strlen(data[i].data);
|
|
||||||
assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length);
|
assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length);
|
||||||
strcpy(symbol->primary, data[i].data);
|
strcpy(symbol->primary, data[i].data);
|
||||||
|
|
||||||
@ -2216,7 +2193,7 @@ static void test_encodation_10(int index, int generate, int debug) {
|
|||||||
"0001010010011011110101000110111001000010100100010101010"
|
"0001010010011011110101000110111001000010100100010101010"
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
char bwipp_buf[8192];
|
char bwipp_buf[8192];
|
||||||
char bwipp_msg[1024];
|
char bwipp_msg[1024];
|
||||||
@ -2228,11 +2205,7 @@ static void test_encodation_10(int index, int generate, int debug) {
|
|||||||
struct zint_symbol *symbol = ZBarcode_Create();
|
struct zint_symbol *symbol = ZBarcode_Create();
|
||||||
assert_nonnull(symbol, "Symbol not created\n");
|
assert_nonnull(symbol, "Symbol not created\n");
|
||||||
|
|
||||||
symbol->symbology = data[i].symbology;
|
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, data[i].option_1, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||||
symbol->option_1 = data[i].option_1;
|
|
||||||
symbol->debug |= debug;
|
|
||||||
|
|
||||||
int length = strlen(data[i].data);
|
|
||||||
assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length);
|
assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length);
|
||||||
strcpy(symbol->primary, data[i].data);
|
strcpy(symbol->primary, data[i].data);
|
||||||
|
|
||||||
@ -2598,7 +2571,7 @@ static void test_encodation_11(int index, int generate, int debug) {
|
|||||||
"0001010010011011110101000110111001000010100100010101010"
|
"0001010010011011110101000110111001000010100100010101010"
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
char bwipp_buf[8192];
|
char bwipp_buf[8192];
|
||||||
char bwipp_msg[1024];
|
char bwipp_msg[1024];
|
||||||
@ -2610,11 +2583,7 @@ static void test_encodation_11(int index, int generate, int debug) {
|
|||||||
struct zint_symbol *symbol = ZBarcode_Create();
|
struct zint_symbol *symbol = ZBarcode_Create();
|
||||||
assert_nonnull(symbol, "Symbol not created\n");
|
assert_nonnull(symbol, "Symbol not created\n");
|
||||||
|
|
||||||
symbol->symbology = data[i].symbology;
|
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, data[i].option_1, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||||
symbol->option_1 = data[i].option_1;
|
|
||||||
symbol->debug |= debug;
|
|
||||||
|
|
||||||
int length = strlen(data[i].data);
|
|
||||||
assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length);
|
assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length);
|
||||||
strcpy(symbol->primary, data[i].data);
|
strcpy(symbol->primary, data[i].data);
|
||||||
|
|
||||||
@ -2629,7 +2598,7 @@ static void test_encodation_11(int index, int generate, int debug) {
|
|||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d %s symbol->rows %d != %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), symbol->rows, data[i].expected_rows, data[i].data);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d %s symbol->rows %d != %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d %s symbol->width %d != %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d %s symbol->width %d != %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), symbol->width, data[i].expected_width, data[i].data);
|
||||||
|
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
int width, row;
|
int width, row;
|
||||||
ret = testUtilModulesCmp(symbol, data[i].expected, &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);
|
assert_zero(ret, "i:%d %s testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), ret, width, row, data[i].data);
|
||||||
@ -2777,7 +2746,7 @@ static void test_addongap(int index, int generate, int debug) {
|
|||||||
printf(" /*%3d*/ { %s, %d, %d, \"%s\", %s, %d, %d, \"%s\",\n",
|
printf(" /*%3d*/ { %s, %d, %d, \"%s\", %s, %d, %d, \"%s\",\n",
|
||||||
i, testUtilBarcodeName(data[i].symbology), data[i].option_1, data[i].option_2, data[i].data,
|
i, testUtilBarcodeName(data[i].symbology), data[i].option_1, data[i].option_2, data[i].data,
|
||||||
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
|
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
|
||||||
testUtilModulesDump(symbol, " ", "\n");
|
testUtilModulesPrint(symbol, " ", "\n");
|
||||||
printf(" },\n");
|
printf(" },\n");
|
||||||
} else {
|
} else {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d %s symbol->rows %d != %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), symbol->rows, data[i].expected_rows, data[i].data);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d %s symbol->rows %d != %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
@ -2823,7 +2792,7 @@ static void test_fuzz(int index, int debug) {
|
|||||||
/* 3*/ { BARCODE_EANX_CC, "+12345", -1, "[21]A12345678", 0 },
|
/* 3*/ { BARCODE_EANX_CC, "+12345", -1, "[21]A12345678", 0 },
|
||||||
/* 4*/ { BARCODE_EANX_CC, "+123456", -1, "[21]A12345678", ZINT_ERROR_TOO_LONG },
|
/* 4*/ { BARCODE_EANX_CC, "+123456", -1, "[21]A12345678", ZINT_ERROR_TOO_LONG },
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
for (int i = 0; i < data_size; i++) {
|
for (int i = 0; i < data_size; i++) {
|
||||||
|
|
||||||
@ -2832,13 +2801,7 @@ static void test_fuzz(int index, int debug) {
|
|||||||
struct zint_symbol *symbol = ZBarcode_Create();
|
struct zint_symbol *symbol = ZBarcode_Create();
|
||||||
assert_nonnull(symbol, "Symbol not created\n");
|
assert_nonnull(symbol, "Symbol not created\n");
|
||||||
|
|
||||||
symbol->symbology = data[i].symbology;
|
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||||
symbol->debug |= debug;
|
|
||||||
|
|
||||||
int length = data[i].length;
|
|
||||||
if (length == -1) {
|
|
||||||
length = strlen(data[i].data);
|
|
||||||
}
|
|
||||||
assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length);
|
assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length);
|
||||||
strcpy(symbol->primary, data[i].data);
|
strcpy(symbol->primary, data[i].data);
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -650,7 +650,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||||||
i, testUtilInputModeName(data[i].input_mode), data[i].option_2, testUtilOption3Name(data[i].option_3),
|
i, testUtilInputModeName(data[i].input_mode), data[i].option_2, testUtilOption3Name(data[i].option_3),
|
||||||
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length,
|
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length,
|
||||||
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].comment);
|
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].comment);
|
||||||
testUtilModulesDump(symbol, " ", "\n");
|
testUtilModulesPrint(symbol, " ", "\n");
|
||||||
printf(" },\n");
|
printf(" },\n");
|
||||||
} else {
|
} else {
|
||||||
if (ret < ZINT_ERROR) {
|
if (ret < ZINT_ERROR) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
libzint - the open source barcode library
|
libzint - the open source barcode library
|
||||||
Copyright (C) 2008-2021 Robin Stuart <rstuart114@gmail.com>
|
Copyright (C) 2019-2021 Robin Stuart <rstuart114@gmail.com>
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions
|
modification, are permitted provided that the following conditions
|
||||||
@ -71,7 +71,7 @@ static void test_large(int index, int debug) {
|
|||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
|
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
|
||||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||||
|
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
||||||
}
|
}
|
||||||
@ -269,9 +269,9 @@ static void test_input(int index, int generate, int debug) {
|
|||||||
printf(" /*%3d*/ { %s, %d, %s, \"%s\", %s, %d, \"%s\", \"%s\" },\n",
|
printf(" /*%3d*/ { %s, %d, %s, \"%s\", %s, %d, \"%s\", \"%s\" },\n",
|
||||||
i, testUtilInputModeName(data[i].input_mode), data[i].eci, testUtilOption3Name(data[i].option_3),
|
i, testUtilInputModeName(data[i].input_mode), data[i].eci, testUtilOption3Name(data[i].option_3),
|
||||||
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
||||||
testUtilErrorName(data[i].ret), ret < 5 ? symbol->eci : -1, symbol->errtxt, data[i].comment);
|
testUtilErrorName(data[i].ret), ret < ZINT_ERROR ? symbol->eci : -1, symbol->errtxt, data[i].comment);
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
|
|
||||||
assert_equal(symbol->eci, data[i].expected_eci, "i:%d eci %d != %d\n", i, symbol->eci, data[i].expected_eci);
|
assert_equal(symbol->eci, data[i].expected_eci, "i:%d eci %d != %d\n", i, symbol->eci, data[i].expected_eci);
|
||||||
assert_zero(strcmp((char *) symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
assert_zero(strcmp((char *) symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||||
@ -417,10 +417,10 @@ static void test_encode(int index, int generate, int debug) {
|
|||||||
printf(" /*%3d*/ { \"%s\", %s, %d, %d, %s, %d, %d, \"%s\",\n",
|
printf(" /*%3d*/ { \"%s\", %s, %d, %d, %s, %d, %d, \"%s\",\n",
|
||||||
i, data[i].data, testUtilInputModeName(data[i].input_mode), data[i].option_1, data[i].option_2, testUtilErrorName(data[i].ret),
|
i, data[i].data, testUtilInputModeName(data[i].input_mode), data[i].option_1, data[i].option_2, testUtilErrorName(data[i].ret),
|
||||||
symbol->rows, symbol->width, data[i].comment);
|
symbol->rows, symbol->width, data[i].comment);
|
||||||
testUtilModulesDump(symbol, " ", "\n");
|
testUtilModulesPrint(symbol, " ", "\n");
|
||||||
printf(" },\n");
|
printf(" },\n");
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
|
|
||||||
|
@ -179,19 +179,13 @@ static void test_gs1_reduce(int index, int generate, int debug) {
|
|||||||
struct zint_symbol *symbol = ZBarcode_Create();
|
struct zint_symbol *symbol = ZBarcode_Create();
|
||||||
assert_nonnull(symbol, "Symbol not created\n");
|
assert_nonnull(symbol, "Symbol not created\n");
|
||||||
|
|
||||||
symbol->symbology = data[i].symbology;
|
|
||||||
if (data[i].input_mode != -1) {
|
|
||||||
symbol->input_mode = data[i].input_mode;
|
|
||||||
}
|
|
||||||
symbol->debug |= debug;
|
|
||||||
|
|
||||||
if (strlen(data[i].composite)) {
|
if (strlen(data[i].composite)) {
|
||||||
text = data[i].composite;
|
text = data[i].composite;
|
||||||
strcpy(symbol->primary, data[i].data);
|
strcpy(symbol->primary, data[i].data);
|
||||||
} else {
|
} else {
|
||||||
text = data[i].data;
|
text = data[i].data;
|
||||||
}
|
}
|
||||||
int length = strlen(text);
|
int length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, text, -1, debug);
|
||||||
|
|
||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) text, length);
|
ret = ZBarcode_Encode(symbol, (unsigned char *) text, length);
|
||||||
|
|
||||||
@ -199,7 +193,7 @@ static void test_gs1_reduce(int index, int generate, int debug) {
|
|||||||
if (data[i].ret == 0) {
|
if (data[i].ret == 0) {
|
||||||
printf(" /*%2d*/ { %s, %s, \"%s\", \"%s\", %d, \"%s\",\n",
|
printf(" /*%2d*/ { %s, %s, \"%s\", \"%s\", %d, \"%s\",\n",
|
||||||
i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), data[i].data, data[i].composite, data[i].ret, data[i].comment);
|
i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), data[i].data, data[i].composite, data[i].ret, data[i].comment);
|
||||||
testUtilModulesDump(symbol, " ", "\n");
|
testUtilModulesPrint(symbol, " ", "\n");
|
||||||
printf(" },\n");
|
printf(" },\n");
|
||||||
} else {
|
} else {
|
||||||
printf(" /*%2d*/ { %s, %s, \"%s\", \"%s\", %s, \"%s\", \"\" },\n",
|
printf(" /*%2d*/ { %s, %s, \"%s\", \"%s\", %s, \"%s\", \"\" },\n",
|
||||||
@ -208,7 +202,7 @@ static void test_gs1_reduce(int index, int generate, int debug) {
|
|||||||
} else {
|
} else {
|
||||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d %s\n", i, ret, data[i].ret, symbol->errtxt);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d %s\n", i, ret, data[i].ret, symbol->errtxt);
|
||||||
|
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
int width, row;
|
int width, row;
|
||||||
ret = testUtilModulesCmp(symbol, data[i].expected, &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);
|
assert_zero(ret, "i:%d %s testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), ret, width, row, data[i].data);
|
||||||
@ -271,16 +265,13 @@ static void test_hrt(int index, int debug) {
|
|||||||
struct zint_symbol *symbol = ZBarcode_Create();
|
struct zint_symbol *symbol = ZBarcode_Create();
|
||||||
assert_nonnull(symbol, "Symbol not created\n");
|
assert_nonnull(symbol, "Symbol not created\n");
|
||||||
|
|
||||||
symbol->symbology = data[i].symbology;
|
|
||||||
symbol->debug |= debug;
|
|
||||||
|
|
||||||
if (strlen(data[i].composite)) {
|
if (strlen(data[i].composite)) {
|
||||||
text = data[i].composite;
|
text = data[i].composite;
|
||||||
strcpy(symbol->primary, data[i].data);
|
strcpy(symbol->primary, data[i].data);
|
||||||
} else {
|
} else {
|
||||||
text = data[i].data;
|
text = data[i].data;
|
||||||
}
|
}
|
||||||
int length = strlen(text);
|
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, text, -1, debug);
|
||||||
|
|
||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) text, length);
|
ret = ZBarcode_Encode(symbol, (unsigned char *) text, length);
|
||||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, data[i].ret, ret, symbol->errtxt);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, data[i].ret, ret, symbol->errtxt);
|
||||||
@ -1781,20 +1772,13 @@ static void test_input_mode(int index, int debug) {
|
|||||||
struct zint_symbol *symbol = ZBarcode_Create();
|
struct zint_symbol *symbol = ZBarcode_Create();
|
||||||
assert_nonnull(symbol, "Symbol not created\n");
|
assert_nonnull(symbol, "Symbol not created\n");
|
||||||
|
|
||||||
symbol->symbology = data[i].symbology;
|
|
||||||
symbol->input_mode = data[i].input_mode;
|
|
||||||
if (data[i].output_options != -1) {
|
|
||||||
symbol->output_options = data[i].output_options;
|
|
||||||
}
|
|
||||||
symbol->debug |= debug;
|
|
||||||
|
|
||||||
if (strlen(data[i].composite)) {
|
if (strlen(data[i].composite)) {
|
||||||
text = data[i].composite;
|
text = data[i].composite;
|
||||||
strcpy(symbol->primary, data[i].data);
|
strcpy(symbol->primary, data[i].data);
|
||||||
} else {
|
} else {
|
||||||
text = data[i].data;
|
text = data[i].data;
|
||||||
}
|
}
|
||||||
int length = strlen(text);
|
int length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, data[i].output_options, text, -1, debug);
|
||||||
|
|
||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) text, length);
|
ret = ZBarcode_Encode(symbol, (unsigned char *) text, length);
|
||||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d %s\n", i, ret, data[i].ret, symbol->errtxt);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d %s\n", i, ret, data[i].ret, symbol->errtxt);
|
||||||
|
@ -71,7 +71,7 @@ static void test_large(int index, int debug) {
|
|||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
|
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
|
||||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||||
|
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
||||||
}
|
}
|
||||||
@ -265,9 +265,9 @@ static void test_input(int index, int generate, int debug) {
|
|||||||
printf(" /*%3d*/ { %s, %d, %s, \"%s\", %d, %s, %d, \"%s\", \"%s\" },\n",
|
printf(" /*%3d*/ { %s, %d, %s, \"%s\", %d, %s, %d, \"%s\", \"%s\" },\n",
|
||||||
i, testUtilInputModeName(data[i].input_mode), data[i].eci, testUtilOption3Name(data[i].option_3),
|
i, testUtilInputModeName(data[i].input_mode), data[i].eci, testUtilOption3Name(data[i].option_3),
|
||||||
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length,
|
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length,
|
||||||
testUtilErrorName(data[i].ret), ret < 5 ? symbol->eci : -1, symbol->errtxt, data[i].comment);
|
testUtilErrorName(data[i].ret), ret < ZINT_ERROR ? symbol->eci : -1, symbol->errtxt, data[i].comment);
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->eci, data[i].expected_eci, "i:%d eci %d != %d\n", i, symbol->eci, data[i].expected_eci);
|
assert_equal(symbol->eci, data[i].expected_eci, "i:%d eci %d != %d\n", i, symbol->eci, data[i].expected_eci);
|
||||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||||
}
|
}
|
||||||
@ -1467,10 +1467,10 @@ static void test_encode(int index, int generate, int debug) {
|
|||||||
i, testUtilInputModeName(data[i].input_mode), data[i].option_1, data[i].option_2, testUtilOption3Name(data[i].option_3),
|
i, testUtilInputModeName(data[i].input_mode), data[i].option_1, data[i].option_2, testUtilOption3Name(data[i].option_3),
|
||||||
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret),
|
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret),
|
||||||
symbol->rows, symbol->width, data[i].comment);
|
symbol->rows, symbol->width, data[i].comment);
|
||||||
testUtilModulesDump(symbol, " ", "\n");
|
testUtilModulesPrint(symbol, " ", "\n");
|
||||||
printf(" },\n");
|
printf(" },\n");
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
libzint - the open source barcode library
|
libzint - the open source barcode library
|
||||||
Copyright (C) 2019 - 2020 Robin Stuart <rstuart114@gmail.com>
|
Copyright (C) 2019 - 2021 Robin Stuart <rstuart114@gmail.com>
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions
|
modification, are permitted provided that the following conditions
|
||||||
@ -200,7 +200,7 @@ static void test_input(int index, int debug) {
|
|||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
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);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||||
|
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
||||||
}
|
}
|
||||||
@ -256,10 +256,10 @@ static void test_encode(int index, int generate, int debug) {
|
|||||||
printf(" /*%3d*/ { \"%s\", %s, %d, %d, \"%s\",\n",
|
printf(" /*%3d*/ { \"%s\", %s, %d, %d, \"%s\",\n",
|
||||||
i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
||||||
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
|
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
|
||||||
testUtilModulesDump(symbol, " ", "\n");
|
testUtilModulesPrint(symbol, " ", "\n");
|
||||||
printf(" },\n");
|
printf(" },\n");
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ static void test_escape_char_process(int index, int generate, int debug) {
|
|||||||
char *comment;
|
char *comment;
|
||||||
};
|
};
|
||||||
struct item data[] = {
|
struct item data[] = {
|
||||||
/* 0*/ { DATA_MODE, -1, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\e\\G\\R\\x81\\\\", 0, 26, "01 05 08 09 0A 0B 0C 0D E7 DE 7B 1F B6 4D 45 B6 E6 78 98 0D 54 2E 58 21 AE 22 2B 3E 8B 22", 0, "" },
|
/* 0*/ { DATA_MODE, -1, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\e\\G\\R\\x81\\\\", 0, 26, "01 05 08 09 0A 0B 0C 0D E7 D8 7B 1F B6 4D 45 B6 45 7C EF DD 8C 4C 8D 1E D0 55 AD FE A8 52", 0, "" },
|
||||||
/* 1*/ { DATA_MODE, -1, "\\c", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character in input data", 0, "" },
|
/* 1*/ { DATA_MODE, -1, "\\c", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character in input data", 0, "" },
|
||||||
/* 2*/ { DATA_MODE, -1, "\\", ZINT_ERROR_INVALID_DATA, 0, "Error 236: Incomplete escape character in input data", 0, "" },
|
/* 2*/ { DATA_MODE, -1, "\\", ZINT_ERROR_INVALID_DATA, 0, "Error 236: Incomplete escape character in input data", 0, "" },
|
||||||
/* 3*/ { DATA_MODE, -1, "\\x", ZINT_ERROR_INVALID_DATA, 0, "Error 232: Incomplete escape character in input data", 0, "" },
|
/* 3*/ { DATA_MODE, -1, "\\x", ZINT_ERROR_INVALID_DATA, 0, "Error 232: Incomplete escape character in input data", 0, "" },
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
libzint - the open source barcode library
|
libzint - the open source barcode library
|
||||||
Copyright (C) 2019 - 2020 Robin Stuart <rstuart114@gmail.com>
|
Copyright (C) 2019 - 2021 Robin Stuart <rstuart114@gmail.com>
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions
|
modification, are permitted provided that the following conditions
|
||||||
@ -113,7 +113,7 @@ static void test_input(int index, int debug) {
|
|||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
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);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||||
|
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
||||||
}
|
}
|
||||||
@ -164,7 +164,7 @@ static void test_encode_vector(int index, int debug) {
|
|||||||
/* 18*/ { "31833333333333333C12JQ3U ", 0, 100, 30, 0, "DTTAFFDATATFAADAFDFATFFTFFTTTADTTTDTAAATDDTFFDDFTAADTTDTFFFDAFTFAADFDDAFDFTAFF" }, // F N N L L N L S S
|
/* 18*/ { "31833333333333333C12JQ3U ", 0, 100, 30, 0, "DTTAFFDATATFAADAFDFATFFTFFTTTADTTTDTAAATDDTFFDDFTAADTTDTFFFDAFTFAADFDDAFDFTAFF" }, // F N N L L N L S S
|
||||||
/* 19*/ { "22799999999999999C123JQ4U ", 0, 100, 30, 0, "DDATTDDATATTTAFDTAADATDDFFTFFDFFDTFAADDFAADFDFFTFFTFFDFDFTATATFDDFTFFFTFFTDDTF" }, // F N N N L L N L S
|
/* 19*/ { "22799999999999999C123JQ4U ", 0, 100, 30, 0, "DDATTDDATATTTAFDTAADATDDFFTFFDFFDTFAADDFAADFDFFTFFTFFDFDFTATATFDDFTFFFTFFTDDTF" }, // F N N N L L N L S
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
char actual_daft[80];
|
char actual_daft[80];
|
||||||
|
|
||||||
@ -175,10 +175,7 @@ static void test_encode_vector(int index, int debug) {
|
|||||||
struct zint_symbol *symbol = ZBarcode_Create();
|
struct zint_symbol *symbol = ZBarcode_Create();
|
||||||
assert_nonnull(symbol, "Symbol not created\n");
|
assert_nonnull(symbol, "Symbol not created\n");
|
||||||
|
|
||||||
symbol->symbology = BARCODE_MAILMARK;
|
int length = testUtilSetSymbol(symbol, BARCODE_MAILMARK, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||||
symbol->debug |= debug;
|
|
||||||
|
|
||||||
int length = strlen(data[i].data);
|
|
||||||
|
|
||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
||||||
assert_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret_encode, symbol->errtxt);
|
assert_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret_encode, symbol->errtxt);
|
||||||
@ -239,10 +236,10 @@ static void test_encode(int index, int generate, int debug) {
|
|||||||
printf(" /*%3d*/ { \"%s\", %s, %d, %d, \"%s\",\n",
|
printf(" /*%3d*/ { \"%s\", %s, %d, %d, \"%s\",\n",
|
||||||
i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
||||||
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
|
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
|
||||||
testUtilModulesDump(symbol, " ", "\n");
|
testUtilModulesPrint(symbol, " ", "\n");
|
||||||
printf(" },\n");
|
printf(" },\n");
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
libzint - the open source barcode library
|
libzint - the open source barcode library
|
||||||
Copyright (C) 2019 - 2020 Robin Stuart <rstuart114@gmail.com>
|
Copyright (C) 2019 - 2021 Robin Stuart <rstuart114@gmail.com>
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions
|
modification, are permitted provided that the following conditions
|
||||||
@ -101,7 +101,7 @@ static void test_large(int index, int debug) {
|
|||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
|
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
|
||||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||||
|
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
||||||
}
|
}
|
||||||
@ -166,7 +166,7 @@ static void test_input(int index, int generate, int debug) {
|
|||||||
/* 32*/ { UNICODE_MODE, 32768, -1, -1, "A", -1, "", 0, 30, "(144) 04 1B 38 08 00 00 01 21 21 21 10 30 3A 04 26 23 0E 21 3D 0F 21 21 21 21 21 21 21 21", "" },
|
/* 32*/ { UNICODE_MODE, 32768, -1, -1, "A", -1, "", 0, 30, "(144) 04 1B 38 08 00 00 01 21 21 21 10 30 3A 04 26 23 0E 21 3D 0F 21 21 21 21 21 21 21 21", "" },
|
||||||
/* 33*/ { UNICODE_MODE, -1, 1, -1, "A", -1, "", ZINT_ERROR_INVALID_OPTION, 0, "Error 550: Invalid MaxiCode Mode", "" },
|
/* 33*/ { UNICODE_MODE, -1, 1, -1, "A", -1, "", ZINT_ERROR_INVALID_OPTION, 0, "Error 550: Invalid MaxiCode Mode", "" },
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
char escaped[1024];
|
char escaped[1024];
|
||||||
|
|
||||||
@ -191,7 +191,7 @@ static void test_input(int index, int generate, int debug) {
|
|||||||
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length, data[i].primary,
|
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length, data[i].primary,
|
||||||
testUtilErrorName(data[i].ret), symbol->width, symbol->errtxt, data[i].comment);
|
testUtilErrorName(data[i].ret), symbol->width, symbol->errtxt, data[i].comment);
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
}
|
}
|
||||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||||
@ -560,10 +560,10 @@ static void test_encode(int index, int generate, int debug) {
|
|||||||
printf(" /*%3d*/ { %s, %d, %d, \"%s\", %d, \"%s\", %s, %d, %d, \"%s\",\n",
|
printf(" /*%3d*/ { %s, %d, %d, \"%s\", %d, \"%s\", %s, %d, %d, \"%s\",\n",
|
||||||
i, testUtilInputModeName(data[i].input_mode), data[i].option_1, data[i].option_2, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length,
|
i, testUtilInputModeName(data[i].input_mode), data[i].option_1, data[i].option_2, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length,
|
||||||
data[i].primary, testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
|
data[i].primary, testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
|
||||||
testUtilModulesDump(symbol, " ", "\n");
|
testUtilModulesPrint(symbol, " ", "\n");
|
||||||
printf(" },\n");
|
printf(" },\n");
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
|
|
||||||
@ -633,7 +633,7 @@ static void test_best_supported_set(int index, int generate, int debug) {
|
|||||||
"010100101001110111101010110010"
|
"010100101001110111101010110010"
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
char escaped_data[1024];
|
char escaped_data[1024];
|
||||||
|
|
||||||
@ -644,10 +644,7 @@ static void test_best_supported_set(int index, int generate, int debug) {
|
|||||||
struct zint_symbol *symbol = ZBarcode_Create();
|
struct zint_symbol *symbol = ZBarcode_Create();
|
||||||
assert_nonnull(symbol, "Symbol not created\n");
|
assert_nonnull(symbol, "Symbol not created\n");
|
||||||
|
|
||||||
symbol->symbology = BARCODE_MAXICODE;
|
int length = testUtilSetSymbol(symbol, BARCODE_MAXICODE, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||||
symbol->debug |= debug;
|
|
||||||
|
|
||||||
int length = strlen(data[i].data);
|
|
||||||
|
|
||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
||||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret);
|
||||||
@ -656,7 +653,7 @@ static void test_best_supported_set(int index, int generate, int debug) {
|
|||||||
printf(" /*%2d*/ { \"%s\", %d, %.0f, %.0f, %d, %d, %d, \"%s\",\n",
|
printf(" /*%2d*/ { \"%s\", %d, %.0f, %.0f, %d, %d, %d, \"%s\",\n",
|
||||||
i, testUtilEscape(data[i].data, length, escaped_data, sizeof(escaped_data)), ret,
|
i, testUtilEscape(data[i].data, length, escaped_data, sizeof(escaped_data)), ret,
|
||||||
data[i].w, data[i].h, data[i].ret_vector, symbol->rows, symbol->width, data[i].comment);
|
data[i].w, data[i].h, data[i].ret_vector, symbol->rows, symbol->width, data[i].comment);
|
||||||
testUtilModulesDump(symbol, " ", "\n");
|
testUtilModulesPrint(symbol, " ", "\n");
|
||||||
printf(" },\n");
|
printf(" },\n");
|
||||||
} else {
|
} else {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
||||||
@ -696,7 +693,7 @@ static void test_fuzz(int index, int debug) {
|
|||||||
/* 3*/ { -1, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", -1, ZINT_ERROR_TOO_LONG },
|
/* 3*/ { -1, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", -1, ZINT_ERROR_TOO_LONG },
|
||||||
/* 4*/ { 32768, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678", -1, ZINT_ERROR_TOO_LONG },
|
/* 4*/ { 32768, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678", -1, ZINT_ERROR_TOO_LONG },
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
for (int i = 0; i < data_size; i++) {
|
for (int i = 0; i < data_size; i++) {
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
libzint - the open source barcode library
|
libzint - the open source barcode library
|
||||||
Copyright (C) 2020 Robin Stuart <rstuart114@gmail.com>
|
Copyright (C) 2020 - 2021 Robin Stuart <rstuart114@gmail.com>
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions
|
modification, are permitted provided that the following conditions
|
||||||
@ -77,7 +77,7 @@ static void test_large(int index, int debug) {
|
|||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
|
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
|
||||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||||
|
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
||||||
}
|
}
|
||||||
@ -187,7 +187,7 @@ static void test_input(int index, int debug) {
|
|||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
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);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||||
|
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
||||||
}
|
}
|
||||||
@ -272,10 +272,10 @@ static void test_encode(int index, int generate, int debug) {
|
|||||||
printf(" /*%3d*/ { %s, %d, \"%s\", %s, %d, %d, \"%s\",\n",
|
printf(" /*%3d*/ { %s, %d, \"%s\", %s, %d, %d, \"%s\",\n",
|
||||||
i, testUtilBarcodeName(data[i].symbology), data[i].option_2, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
i, testUtilBarcodeName(data[i].symbology), data[i].option_2, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
||||||
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
|
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
|
||||||
testUtilModulesDump(symbol, " ", "\n");
|
testUtilModulesPrint(symbol, " ", "\n");
|
||||||
printf(" },\n");
|
printf(" },\n");
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
libzint - the open source barcode library
|
libzint - the open source barcode library
|
||||||
Copyright (C) 2019 - 2020 Robin Stuart <rstuart114@gmail.com>
|
Copyright (C) 2019 - 2021 Robin Stuart <rstuart114@gmail.com>
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions
|
modification, are permitted provided that the following conditions
|
||||||
@ -67,7 +67,7 @@ static void test_options(int index, int debug) {
|
|||||||
/* 11*/ { BARCODE_MICROPDF417, -1, 5, -1, "12345", ZINT_WARN_INVALID_OPTION, 0, -1, 1, 11, 38, -1 }, // Invalid cols, auto-set to 1
|
/* 11*/ { BARCODE_MICROPDF417, -1, 5, -1, "12345", ZINT_WARN_INVALID_OPTION, 0, -1, 1, 11, 38, -1 }, // Invalid cols, auto-set to 1
|
||||||
/* 12*/ { BARCODE_MICROPDF417, -1, 1, -1, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM", ZINT_WARN_INVALID_OPTION, 0, -1, 2, 17, 55, -1 }, // Cols 1 too small, auto-upped to 2 with warning
|
/* 12*/ { BARCODE_MICROPDF417, -1, 1, -1, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM", ZINT_WARN_INVALID_OPTION, 0, -1, 2, 17, 55, -1 }, // Cols 1 too small, auto-upped to 2 with warning
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
struct zint_symbol previous_symbol;
|
struct zint_symbol previous_symbol;
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ static void test_reader_init(int index, int generate, int debug) {
|
|||||||
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
||||||
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, symbol->errtxt, data[i].comment);
|
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, symbol->errtxt, data[i].comment);
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||||
@ -240,7 +240,7 @@ static void test_input(int index, int generate, int debug) {
|
|||||||
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret),
|
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret),
|
||||||
symbol->eci, symbol->rows, symbol->width, symbol->errtxt, data[i].comment);
|
symbol->eci, symbol->rows, symbol->width, symbol->errtxt, data[i].comment);
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->eci, data[i].expected_eci, "i:%d symbol->eci %d != %d (%s)\n", i, symbol->eci, data[i].expected_eci, data[i].data);
|
assert_equal(symbol->eci, data[i].expected_eci, "i:%d symbol->eci %d != %d (%s)\n", i, symbol->eci, data[i].expected_eci, data[i].data);
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
@ -718,7 +718,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||||||
"11101101001101001001111100011101101001"
|
"11101101001101001001111100011101101001"
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
char escaped[1024];
|
char escaped[1024];
|
||||||
char bwipp_buf[8192];
|
char bwipp_buf[8192];
|
||||||
@ -741,10 +741,10 @@ static void test_encode(int index, int generate, int debug) {
|
|||||||
i, testUtilBarcodeName(data[i].symbology), data[i].eci, testUtilInputModeName(data[i].input_mode), data[i].option_1, data[i].option_2,
|
i, testUtilBarcodeName(data[i].symbology), data[i].eci, testUtilInputModeName(data[i].input_mode), data[i].option_1, data[i].option_2,
|
||||||
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret),
|
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret),
|
||||||
symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].comment);
|
symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].comment);
|
||||||
testUtilModulesDump(symbol, " ", "\n");
|
testUtilModulesPrint(symbol, " ", "\n");
|
||||||
printf(" },\n");
|
printf(" },\n");
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
|
|
||||||
@ -1042,7 +1042,7 @@ static void test_fuzz(int index, int debug) {
|
|||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQ",
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQ",
|
||||||
251, -1, ZINT_ERROR_TOO_LONG },
|
251, -1, ZINT_ERROR_TOO_LONG },
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
for (int i = 0; i < data_size; i++) {
|
for (int i = 0; i < data_size; i++) {
|
||||||
|
|
||||||
@ -1073,6 +1073,8 @@ static void test_fuzz(int index, int debug) {
|
|||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
#define TEST_PERF_ITERATIONS 1000
|
||||||
|
|
||||||
// Not a real test, just performance indicator
|
// Not a real test, just performance indicator
|
||||||
static void test_perf(int index, int debug) {
|
static void test_perf(int index, int debug) {
|
||||||
|
|
||||||
@ -1139,7 +1141,7 @@ static void test_perf(int index, int debug) {
|
|||||||
|
|
||||||
diff_encode = diff_buffer = 0;
|
diff_encode = diff_buffer = 0;
|
||||||
|
|
||||||
for (int j = 0; j < 1000; j++) {
|
for (int j = 0; j < TEST_PERF_ITERATIONS; j++) {
|
||||||
struct zint_symbol *symbol = ZBarcode_Create();
|
struct zint_symbol *symbol = ZBarcode_Create();
|
||||||
assert_nonnull(symbol, "Symbol not created\n");
|
assert_nonnull(symbol, "Symbol not created\n");
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
libzint - the open source barcode library
|
libzint - the open source barcode library
|
||||||
Copyright (C) 2020 Robin Stuart <rstuart114@gmail.com>
|
Copyright (C) 2020 - 2021 Robin Stuart <rstuart114@gmail.com>
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions
|
modification, are permitted provided that the following conditions
|
||||||
@ -79,7 +79,7 @@ static void test_large(int index, int debug) {
|
|||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
|
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
|
||||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||||
|
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
||||||
}
|
}
|
||||||
@ -174,7 +174,7 @@ static void test_input(int index, int debug) {
|
|||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
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);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||||
|
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
||||||
}
|
}
|
||||||
@ -254,10 +254,10 @@ static void test_encode(int index, int generate, int debug) {
|
|||||||
printf(" /*%3d*/ { %s, %d, \"%s\", %s, %d, %d, \"%s\",\n",
|
printf(" /*%3d*/ { %s, %d, \"%s\", %s, %d, %d, \"%s\",\n",
|
||||||
i, testUtilBarcodeName(data[i].symbology), data[i].option_2, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
i, testUtilBarcodeName(data[i].symbology), data[i].option_2, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
||||||
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
|
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
|
||||||
testUtilModulesDump(symbol, " ", "\n");
|
testUtilModulesPrint(symbol, " ", "\n");
|
||||||
printf(" },\n");
|
printf(" },\n");
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
libzint - the open source barcode library
|
libzint - the open source barcode library
|
||||||
Copyright (C) 2019 - 2020 Robin Stuart <rstuart114@gmail.com>
|
Copyright (C) 2019 - 2021 Robin Stuart <rstuart114@gmail.com>
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions
|
modification, are permitted provided that the following conditions
|
||||||
@ -88,7 +88,7 @@ static void test_large(int index, int debug) {
|
|||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
|
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
|
||||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||||
|
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
||||||
}
|
}
|
||||||
@ -116,7 +116,7 @@ static void test_koreapost(int index, int debug) {
|
|||||||
struct item data[] = {
|
struct item data[] = {
|
||||||
/* 0*/ { "123456", 0, 0, 50, 1, 167 },
|
/* 0*/ { "123456", 0, 0, 50, 1, 167 },
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
for (int i = 0; i < data_size; i++) {
|
for (int i = 0; i < data_size; i++) {
|
||||||
|
|
||||||
@ -125,15 +125,12 @@ static void test_koreapost(int index, int debug) {
|
|||||||
struct zint_symbol *symbol = ZBarcode_Create();
|
struct zint_symbol *symbol = ZBarcode_Create();
|
||||||
assert_nonnull(symbol, "Symbol not created\n");
|
assert_nonnull(symbol, "Symbol not created\n");
|
||||||
|
|
||||||
symbol->symbology = BARCODE_KOREAPOST;
|
int length = testUtilSetSymbol(symbol, BARCODE_KOREAPOST, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||||
symbol->debug |= debug;
|
|
||||||
|
|
||||||
int length = strlen(data[i].data);
|
|
||||||
|
|
||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
||||||
assert_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret_encode);
|
assert_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret_encode);
|
||||||
|
|
||||||
if (data[i].ret_vector != -1) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->height, data[i].expected_height, "i:%d symbol->height %d != %d\n", i, symbol->height, data[i].expected_height);
|
assert_equal(symbol->height, data[i].expected_height, "i:%d symbol->height %d != %d\n", i, symbol->height, data[i].expected_height);
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
||||||
@ -168,7 +165,7 @@ static void test_japanpost(int index, int debug) {
|
|||||||
/* 1*/ { "123456-AB", 0, 0, 8, 3, 133, "Check 10" },
|
/* 1*/ { "123456-AB", 0, 0, 8, 3, 133, "Check 10" },
|
||||||
/* 2*/ { "123456", 0, 0, 8, 3, 133, "Check 11" },
|
/* 2*/ { "123456", 0, 0, 8, 3, 133, "Check 11" },
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
for (int i = 0; i < data_size; i++) {
|
for (int i = 0; i < data_size; i++) {
|
||||||
|
|
||||||
@ -177,15 +174,12 @@ static void test_japanpost(int index, int debug) {
|
|||||||
struct zint_symbol *symbol = ZBarcode_Create();
|
struct zint_symbol *symbol = ZBarcode_Create();
|
||||||
assert_nonnull(symbol, "Symbol not created\n");
|
assert_nonnull(symbol, "Symbol not created\n");
|
||||||
|
|
||||||
symbol->symbology = BARCODE_JAPANPOST;
|
int length = testUtilSetSymbol(symbol, BARCODE_JAPANPOST, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||||
symbol->debug |= debug;
|
|
||||||
|
|
||||||
int length = strlen(data[i].data);
|
|
||||||
|
|
||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
||||||
assert_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret_encode);
|
assert_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret_encode);
|
||||||
|
|
||||||
if (data[i].ret_vector != -1) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->height, data[i].expected_height, "i:%d symbol->height %d != %d\n", i, symbol->height, data[i].expected_height);
|
assert_equal(symbol->height, data[i].expected_height, "i:%d symbol->height %d != %d\n", i, symbol->height, data[i].expected_height);
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
||||||
@ -264,7 +258,7 @@ static void test_input(int index, int debug) {
|
|||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
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);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||||
|
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
||||||
}
|
}
|
||||||
@ -395,10 +389,10 @@ static void test_encode(int index, int generate, int debug) {
|
|||||||
printf(" /*%3d*/ { %s, \"%s\", %s, %d, %d, \"%s\",\n",
|
printf(" /*%3d*/ { %s, \"%s\", %s, %d, %d, \"%s\",\n",
|
||||||
i, testUtilBarcodeName(data[i].symbology), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
i, testUtilBarcodeName(data[i].symbology), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
||||||
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
|
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
|
||||||
testUtilModulesDump(symbol, " ", "\n");
|
testUtilModulesPrint(symbol, " ", "\n");
|
||||||
printf(" },\n");
|
printf(" },\n");
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
|
|
||||||
|
@ -295,9 +295,9 @@ static void test_qr_input(int index, int generate, int debug) {
|
|||||||
printf(" /*%3d*/ { %s, %d, %s, \"%s\", %s, %d, \"%s\", \"%s\" },\n",
|
printf(" /*%3d*/ { %s, %d, %s, \"%s\", %s, %d, \"%s\", \"%s\" },\n",
|
||||||
i, testUtilInputModeName(data[i].input_mode), data[i].eci, testUtilOption3Name(data[i].option_3),
|
i, testUtilInputModeName(data[i].input_mode), data[i].eci, testUtilOption3Name(data[i].option_3),
|
||||||
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
||||||
testUtilErrorName(data[i].ret), ret < 5 ? symbol->eci : -1, symbol->errtxt, data[i].comment);
|
testUtilErrorName(data[i].ret), ret < ZINT_ERROR ? symbol->eci : -1, symbol->errtxt, data[i].comment);
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
|
|
||||||
assert_equal(symbol->eci, data[i].expected_eci, "i:%d eci %d != %d\n", i, symbol->eci, data[i].expected_eci);
|
assert_equal(symbol->eci, data[i].expected_eci, "i:%d eci %d != %d\n", i, symbol->eci, data[i].expected_eci);
|
||||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||||
@ -356,7 +356,7 @@ static void test_qr_gs1(int index, int generate, int debug) {
|
|||||||
printf(" /*%3d*/ { \"%s\", %s, \"%s\", \"%s\" },\n",
|
printf(" /*%3d*/ { \"%s\", %s, \"%s\", \"%s\" },\n",
|
||||||
i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->errtxt, data[i].comment);
|
i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->errtxt, data[i].comment);
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1279,10 +1279,10 @@ static void test_qr_encode(int index, int generate, int debug) {
|
|||||||
i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), data[i].option_1, data[i].option_2, testUtilOption3Name(data[i].option_3),
|
i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), data[i].option_1, data[i].option_2, testUtilOption3Name(data[i].option_3),
|
||||||
data[i].data, testUtilErrorName(data[i].ret),
|
data[i].data, testUtilErrorName(data[i].ret),
|
||||||
symbol->rows, symbol->width, data[i].comment);
|
symbol->rows, symbol->width, data[i].comment);
|
||||||
testUtilModulesDump(symbol, " ", "\n");
|
testUtilModulesPrint(symbol, " ", "\n");
|
||||||
printf(" },\n");
|
printf(" },\n");
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
|
|
||||||
@ -1574,7 +1574,7 @@ static void test_microqr_input(int index, int generate, int debug) {
|
|||||||
i, testUtilInputModeName(data[i].input_mode), data[i].option_3, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
i, testUtilInputModeName(data[i].input_mode), data[i].option_3, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
||||||
testUtilErrorName(data[i].ret), symbol->errtxt, data[i].comment);
|
testUtilErrorName(data[i].ret), symbol->errtxt, data[i].comment);
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1625,7 +1625,7 @@ static void test_microqr_padding(int index, int generate, int debug) {
|
|||||||
/* 23*/ { "ABCDEFGHIJKLMNOPQR", 2, 0, "32 39 A8 A5 42 AE 16 7A E6 5F AC 51 95 A0", "M4-M, bits left 5" },
|
/* 23*/ { "ABCDEFGHIJKLMNOPQR", 2, 0, "32 39 A8 A5 42 AE 16 7A E6 5F AC 51 95 A0", "M4-M, bits left 5" },
|
||||||
/* 24*/ { "ABCDEFGHIJKLM", 3, 0, "2D 39 A8 A5 42 AE 16 7A E6 56", "M4-Q, bits left 0" },
|
/* 24*/ { "ABCDEFGHIJKLM", 3, 0, "2D 39 A8 A5 42 AE 16 7A E6 56", "M4-Q, bits left 0" },
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
char escaped[1024];
|
char escaped[1024];
|
||||||
|
|
||||||
@ -1654,7 +1654,7 @@ static void test_microqr_padding(int index, int generate, int debug) {
|
|||||||
i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].option_1,
|
i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].option_1,
|
||||||
testUtilErrorName(data[i].ret), symbol->errtxt, data[i].comment);
|
testUtilErrorName(data[i].ret), symbol->errtxt, data[i].comment);
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2025,10 +2025,10 @@ static void test_microqr_encode(int index, int generate, int debug) {
|
|||||||
i, testUtilInputModeName(data[i].input_mode), data[i].option_1, data[i].option_2, testUtilOption3Name(data[i].option_3),
|
i, testUtilInputModeName(data[i].input_mode), data[i].option_1, data[i].option_2, testUtilOption3Name(data[i].option_3),
|
||||||
data[i].data, testUtilErrorName(data[i].ret),
|
data[i].data, testUtilErrorName(data[i].ret),
|
||||||
symbol->rows, symbol->width, data[i].comment);
|
symbol->rows, symbol->width, data[i].comment);
|
||||||
testUtilModulesDump(symbol, " ", "\n");
|
testUtilModulesPrint(symbol, " ", "\n");
|
||||||
printf(" },\n");
|
printf(" },\n");
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
|
|
||||||
@ -2135,7 +2135,7 @@ static void test_upnqr_input(int index, int generate, int debug) {
|
|||||||
/* 1*/ { UNICODE_MODE, "é", 0, "(415) 70 44 00 01 E9 00 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11", "ECI-4 B1 (ISO 8859-2)" },
|
/* 1*/ { UNICODE_MODE, "é", 0, "(415) 70 44 00 01 E9 00 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11 EC 11", "ECI-4 B1 (ISO 8859-2)" },
|
||||||
/* 2*/ { UNICODE_MODE, "β", ZINT_ERROR_INVALID_DATA, "Error 572: Invalid characters in input data", "β not in ISO 8859-2" },
|
/* 2*/ { UNICODE_MODE, "β", ZINT_ERROR_INVALID_DATA, "Error 572: Invalid characters in input data", "β not in ISO 8859-2" },
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
char escaped[1024];
|
char escaped[1024];
|
||||||
|
|
||||||
@ -2146,12 +2146,9 @@ static void test_upnqr_input(int index, int generate, int debug) {
|
|||||||
struct zint_symbol *symbol = ZBarcode_Create();
|
struct zint_symbol *symbol = ZBarcode_Create();
|
||||||
assert_nonnull(symbol, "Symbol not created\n");
|
assert_nonnull(symbol, "Symbol not created\n");
|
||||||
|
|
||||||
symbol->symbology = BARCODE_UPNQR;
|
debug |= ZINT_DEBUG_TEST; // Needed to get codeword dump in errtxt
|
||||||
symbol->input_mode = data[i].input_mode;
|
|
||||||
symbol->debug = ZINT_DEBUG_TEST; // Needed to get codeword dump in errtxt
|
|
||||||
symbol->debug |= debug;
|
|
||||||
|
|
||||||
int length = strlen(data[i].data);
|
int length = testUtilSetSymbol(symbol, BARCODE_UPNQR, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||||
|
|
||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
||||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret);
|
||||||
@ -2162,7 +2159,7 @@ static void test_upnqr_input(int index, int generate, int debug) {
|
|||||||
i, testUtilInputModeName(data[i].input_mode), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret),
|
i, testUtilInputModeName(data[i].input_mode), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret),
|
||||||
symbol->errtxt, data[i].comment);
|
symbol->errtxt, data[i].comment);
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2272,7 +2269,7 @@ static void test_upnqr_encode(int index, int generate, int debug) {
|
|||||||
"11111110110101111101111001011101111100101101111101100101000101100100011101000"
|
"11111110110101111101111001011101111100101101111101100101000101100100011101000"
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
for (int i = 0; i < data_size; i++) {
|
for (int i = 0; i < data_size; i++) {
|
||||||
|
|
||||||
@ -2281,17 +2278,7 @@ static void test_upnqr_encode(int index, int generate, int debug) {
|
|||||||
struct zint_symbol *symbol = ZBarcode_Create();
|
struct zint_symbol *symbol = ZBarcode_Create();
|
||||||
assert_nonnull(symbol, "Symbol not created\n");
|
assert_nonnull(symbol, "Symbol not created\n");
|
||||||
|
|
||||||
symbol->symbology = BARCODE_UPNQR;
|
int length = testUtilSetSymbol(symbol, BARCODE_UPNQR, data[i].input_mode, -1 /*eci*/, data[i].option_1, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||||
symbol->input_mode = data[i].input_mode;
|
|
||||||
if (data[i].option_1 != -1) {
|
|
||||||
symbol->option_1 = data[i].option_1;
|
|
||||||
}
|
|
||||||
if (data[i].option_2 != -1) {
|
|
||||||
symbol->option_2 = data[i].option_2;
|
|
||||||
}
|
|
||||||
symbol->debug |= debug;
|
|
||||||
|
|
||||||
int length = strlen(data[i].data);
|
|
||||||
|
|
||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
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);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||||
@ -2300,10 +2287,10 @@ static void test_upnqr_encode(int index, int generate, int debug) {
|
|||||||
printf(" /*%3d*/ { %s, \"%s\", %d, %d, %s, %d, %d, \"%s\",\n",
|
printf(" /*%3d*/ { %s, \"%s\", %d, %d, %s, %d, %d, \"%s\",\n",
|
||||||
i, testUtilInputModeName(data[i].input_mode), data[i].data, data[i].option_1, data[i].option_2, testUtilErrorName(data[i].ret),
|
i, testUtilInputModeName(data[i].input_mode), data[i].data, data[i].option_1, data[i].option_2, testUtilErrorName(data[i].ret),
|
||||||
symbol->rows, symbol->width, data[i].comment);
|
symbol->rows, symbol->width, data[i].comment);
|
||||||
testUtilModulesDump(symbol, " ", "\n");
|
testUtilModulesPrint(symbol, " ", "\n");
|
||||||
printf(" },\n");
|
printf(" },\n");
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
|
|
||||||
@ -2404,7 +2391,7 @@ static void test_rmqr_options(int index, int debug) {
|
|||||||
/* 64*/ { "点茗点茗点茗点茗点茗点茗点茗点茗点茗", 4, 38, 0, 0, 17, 77 }, // ECC set to H, version 38 (R17xAuto-width) auto-sets R17x77
|
/* 64*/ { "点茗点茗点茗点茗点茗点茗点茗点茗点茗", 4, 38, 0, 0, 17, 77 }, // ECC set to H, version 38 (R17xAuto-width) auto-sets R17x77
|
||||||
/* 65*/ { "点茗点", -1, 39, ZINT_ERROR_INVALID_OPTION, -1, 0, 0 },
|
/* 65*/ { "点茗点", -1, 39, ZINT_ERROR_INVALID_OPTION, -1, 0, 0 },
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
for (int i = 0; i < data_size; i++) {
|
for (int i = 0; i < data_size; i++) {
|
||||||
|
|
||||||
@ -2413,26 +2400,17 @@ static void test_rmqr_options(int index, int debug) {
|
|||||||
struct zint_symbol *symbol = ZBarcode_Create();
|
struct zint_symbol *symbol = ZBarcode_Create();
|
||||||
assert_nonnull(symbol, "Symbol not created\n");
|
assert_nonnull(symbol, "Symbol not created\n");
|
||||||
|
|
||||||
symbol->symbology = BARCODE_RMQR;
|
int length = testUtilSetSymbol(symbol, BARCODE_RMQR, UNICODE_MODE, -1 /*eci*/, data[i].option_1, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||||
symbol->input_mode = UNICODE_MODE;
|
|
||||||
if (data[i].option_1 != -1) {
|
|
||||||
symbol->option_1 = data[i].option_1;
|
|
||||||
}
|
|
||||||
if (data[i].option_2 != -1) {
|
|
||||||
symbol->option_2 = data[i].option_2;
|
|
||||||
}
|
|
||||||
symbol->debug |= debug;
|
|
||||||
|
|
||||||
int length = strlen(data[i].data);
|
|
||||||
|
|
||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
||||||
assert_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret_encode, symbol->errtxt);
|
assert_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret_encode, symbol->errtxt);
|
||||||
|
|
||||||
if (data[i].ret_vector != -1) {
|
if (ret < ZINT_ERROR) {
|
||||||
ret = ZBarcode_Buffer_Vector(symbol, 0);
|
|
||||||
assert_equal(ret, data[i].ret_vector, "i:%d ZBarcode_Buffer_Vector ret %d != %d\n", i, ret, data[i].ret_vector);
|
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
||||||
|
|
||||||
|
ret = ZBarcode_Buffer_Vector(symbol, 0);
|
||||||
|
assert_equal(ret, data[i].ret_vector, "i:%d ZBarcode_Buffer_Vector ret %d != %d\n", i, ret, data[i].ret_vector);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZBarcode_Delete(symbol);
|
ZBarcode_Delete(symbol);
|
||||||
@ -2476,7 +2454,7 @@ static void test_rmqr_input(int index, int generate, int debug) {
|
|||||||
/* 10*/ { UNICODE_MODE, -1, "áA", 0, "6B 85 04 00 EC", "B2 (ISO 8859-1)" },
|
/* 10*/ { UNICODE_MODE, -1, "áA", 0, "6B 85 04 00 EC", "B2 (ISO 8859-1)" },
|
||||||
/* 11*/ { UNICODE_MODE, 200, "áA", 0, "8E 00 40 EC 11", "K1 (ISO 8859-1) (full multibyte)" },
|
/* 11*/ { UNICODE_MODE, 200, "áA", 0, "8E 00 40 EC 11", "K1 (ISO 8859-1) (full multibyte)" },
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
char escaped[1024];
|
char escaped[1024];
|
||||||
|
|
||||||
@ -2487,15 +2465,9 @@ static void test_rmqr_input(int index, int generate, int debug) {
|
|||||||
struct zint_symbol *symbol = ZBarcode_Create();
|
struct zint_symbol *symbol = ZBarcode_Create();
|
||||||
assert_nonnull(symbol, "Symbol not created\n");
|
assert_nonnull(symbol, "Symbol not created\n");
|
||||||
|
|
||||||
symbol->symbology = BARCODE_RMQR;
|
debug |= ZINT_DEBUG_TEST; // Needed to get codeword dump in errtxt
|
||||||
symbol->input_mode = data[i].input_mode;
|
|
||||||
if (data[i].option_3 != -1) {
|
|
||||||
symbol->option_3 = data[i].option_3;
|
|
||||||
}
|
|
||||||
symbol->debug = ZINT_DEBUG_TEST; // Needed to get codeword dump in errtxt
|
|
||||||
symbol->debug |= debug;
|
|
||||||
|
|
||||||
int length = strlen(data[i].data);
|
int length = testUtilSetSymbol(symbol, BARCODE_RMQR, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, data[i].option_3, -1 /*output_options*/, data[i].data, -1, debug);
|
||||||
|
|
||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
||||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret);
|
||||||
@ -2505,7 +2477,7 @@ static void test_rmqr_input(int index, int generate, int debug) {
|
|||||||
i, testUtilInputModeName(data[i].input_mode), data[i].option_3, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
i, testUtilInputModeName(data[i].input_mode), data[i].option_3, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
||||||
testUtilErrorName(data[i].ret), symbol->errtxt, data[i].comment);
|
testUtilErrorName(data[i].ret), symbol->errtxt, data[i].comment);
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2540,7 +2512,7 @@ static void test_rmqr_gs1(int index, int generate, int debug) {
|
|||||||
/* 9*/ { "[91]A%%%%12345678A%A", 0, "A8 A6 58 F4 4C C6 4A 4A 4A 48 1E DC 89 C8 87 A3 5C 00 EC", "A4(5) B3 N8 A3(4)" },
|
/* 9*/ { "[91]A%%%%12345678A%A", 0, "A8 A6 58 F4 4C C6 4A 4A 4A 48 1E DC 89 C8 87 A3 5C 00 EC", "A4(5) B3 N8 A3(4)" },
|
||||||
/* 10*/ { "[91]%23%%6789%%%34567%%%%234%%%%%", 0, "(33) AA 63 2D B5 02 EE D4 DA 84 54 B8 ED 4D A9 B5 04 58 E7 2C 3B 53 6A 6D 4D 60 22 F6 A3", "A27(38) B4" },
|
/* 10*/ { "[91]%23%%6789%%%34567%%%%234%%%%%", 0, "(33) AA 63 2D B5 02 EE D4 DA 84 54 B8 ED 4D A9 B5 04 58 E7 2C 3B 53 6A 6D 4D 60 22 F6 A3", "A27(38) B4" },
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
char escaped[1024];
|
char escaped[1024];
|
||||||
|
|
||||||
@ -2551,12 +2523,9 @@ static void test_rmqr_gs1(int index, int generate, int debug) {
|
|||||||
struct zint_symbol *symbol = ZBarcode_Create();
|
struct zint_symbol *symbol = ZBarcode_Create();
|
||||||
assert_nonnull(symbol, "Symbol not created\n");
|
assert_nonnull(symbol, "Symbol not created\n");
|
||||||
|
|
||||||
symbol->symbology = BARCODE_RMQR;
|
debug |= ZINT_DEBUG_TEST; // Needed to get codeword dump in errtxt
|
||||||
symbol->input_mode = GS1_MODE;
|
|
||||||
symbol->debug = ZINT_DEBUG_TEST; // Needed to get codeword dump in errtxt
|
|
||||||
symbol->debug |= debug;
|
|
||||||
|
|
||||||
int length = strlen(data[i].data);
|
int length = testUtilSetSymbol(symbol, BARCODE_RMQR, GS1_MODE, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||||
|
|
||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
||||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret);
|
||||||
@ -2565,7 +2534,7 @@ static void test_rmqr_gs1(int index, int generate, int debug) {
|
|||||||
printf(" /*%3d*/ { \"%s\", %s, \"%s\", \"%s\" },\n",
|
printf(" /*%3d*/ { \"%s\", %s, \"%s\", \"%s\" },\n",
|
||||||
i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->errtxt, data[i].comment);
|
i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->errtxt, data[i].comment);
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2613,7 +2582,7 @@ static void test_rmqr_optimize(int index, int generate, int debug) {
|
|||||||
/* 20*/ { UNICODE_MODE, "テaAB1", -1, 0, "6E 0D 95 85 19 CD 04", "B3 A3" },
|
/* 20*/ { UNICODE_MODE, "テaAB1", -1, 0, "6E 0D 95 85 19 CD 04", "B3 A3" },
|
||||||
/* 21*/ { UNICODE_MODE, "貫やぐ識禁ぱい再2間変字全ノレ没無8裁花ほゃ過法ひなご札17能つーびれ投覧マ勝動エヨ額界よみ作皇ナヲニ打題ヌルヲ掲布益フが。入35能ト権話しこを断兆モヘ細情おじ名4減エヘイハ側機", -1, 0, "(152) 82 0E A2 16 20 97 28 BD 02 C1 4F 09 12 61 08 04 A0 83 AA 3E 3D 43 4C 13 0D 68 73 1F", "K8 N1 K8 N1 K10 N2 K33 N2 K16 N1 K7" },
|
/* 21*/ { UNICODE_MODE, "貫やぐ識禁ぱい再2間変字全ノレ没無8裁花ほゃ過法ひなご札17能つーびれ投覧マ勝動エヨ額界よみ作皇ナヲニ打題ヌルヲ掲布益フが。入35能ト権話しこを断兆モヘ細情おじ名4減エヘイハ側機", -1, 0, "(152) 82 0E A2 16 20 97 28 BD 02 C1 4F 09 12 61 08 04 A0 83 AA 3E 3D 43 4C 13 0D 68 73 1F", "K8 N1 K8 N1 K10 N2 K33 N2 K16 N1 K7" },
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
char escaped[1024];
|
char escaped[1024];
|
||||||
|
|
||||||
@ -2624,16 +2593,9 @@ static void test_rmqr_optimize(int index, int generate, int debug) {
|
|||||||
struct zint_symbol *symbol = ZBarcode_Create();
|
struct zint_symbol *symbol = ZBarcode_Create();
|
||||||
assert_nonnull(symbol, "Symbol not created\n");
|
assert_nonnull(symbol, "Symbol not created\n");
|
||||||
|
|
||||||
symbol->symbology = BARCODE_RMQR;
|
debug |= ZINT_DEBUG_TEST; // Needed to get codeword dump in errtxt
|
||||||
symbol->input_mode = data[i].input_mode;
|
|
||||||
if (data[i].option_1 != -1) {
|
|
||||||
symbol->option_1 = data[i].option_1;
|
|
||||||
}
|
|
||||||
symbol->option_3 = ZINT_FULL_MULTIBYTE;
|
|
||||||
symbol->debug = ZINT_DEBUG_TEST;
|
|
||||||
symbol->debug |= debug;
|
|
||||||
|
|
||||||
int length = strlen(data[i].data);
|
int length = testUtilSetSymbol(symbol, BARCODE_RMQR, data[i].input_mode, -1 /*eci*/, data[i].option_1, -1, ZINT_FULL_MULTIBYTE, -1 /*output_options*/, data[i].data, -1, debug);
|
||||||
|
|
||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
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);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||||
@ -2699,7 +2661,7 @@ static void test_rmqr_encode(int index, int generate, int debug) {
|
|||||||
"111010101010101010101011111"
|
"111010101010101010101011111"
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
for (int i = 0; i < data_size; i++) {
|
for (int i = 0; i < data_size; i++) {
|
||||||
|
|
||||||
@ -2708,17 +2670,7 @@ static void test_rmqr_encode(int index, int generate, int debug) {
|
|||||||
struct zint_symbol *symbol = ZBarcode_Create();
|
struct zint_symbol *symbol = ZBarcode_Create();
|
||||||
assert_nonnull(symbol, "Symbol not created\n");
|
assert_nonnull(symbol, "Symbol not created\n");
|
||||||
|
|
||||||
symbol->symbology = BARCODE_RMQR;
|
int length = testUtilSetSymbol(symbol, BARCODE_RMQR, data[i].input_mode, -1 /*eci*/, data[i].option_1, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||||
symbol->input_mode = data[i].input_mode;
|
|
||||||
if (data[i].option_1 != -1) {
|
|
||||||
symbol->option_1 = data[i].option_1;
|
|
||||||
}
|
|
||||||
if (data[i].option_2 != -1) {
|
|
||||||
symbol->option_2 = data[i].option_2;
|
|
||||||
}
|
|
||||||
symbol->debug |= debug;
|
|
||||||
|
|
||||||
int length = strlen(data[i].data);
|
|
||||||
|
|
||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
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);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||||
@ -2727,10 +2679,10 @@ static void test_rmqr_encode(int index, int generate, int debug) {
|
|||||||
printf(" /*%3d*/ { %s, \"%s\", %d, %d, %s, %d, %d, \"%s\",\n",
|
printf(" /*%3d*/ { %s, \"%s\", %d, %d, %s, %d, %d, \"%s\",\n",
|
||||||
i, testUtilInputModeName(data[i].input_mode), data[i].data, data[i].option_1, data[i].option_2, testUtilErrorName(data[i].ret),
|
i, testUtilInputModeName(data[i].input_mode), data[i].data, data[i].option_1, data[i].option_2, testUtilErrorName(data[i].ret),
|
||||||
symbol->rows, symbol->width, data[i].comment);
|
symbol->rows, symbol->width, data[i].comment);
|
||||||
testUtilModulesDump(symbol, " ", "\n");
|
testUtilModulesPrint(symbol, " ", "\n");
|
||||||
printf(" },\n");
|
printf(" },\n");
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ static void test_binary_div_modulo_divisor(int index, int generate, int debug) {
|
|||||||
/* 69*/ { BARCODE_DBAR_LTD, "1651257071912", 100, 30, 1, 79, "0100000111100011110101010101010111010100100101010101010101111110111111110100000" },
|
/* 69*/ { BARCODE_DBAR_LTD, "1651257071912", 100, 30, 1, 79, "0100000111100011110101010101010111010100100101010101010101111110111111110100000" },
|
||||||
/* 70*/ { BARCODE_DBAR_LTD_CC, "0987144605916", 100, 30, 6, 79, "0101010101010011111000011111011010110100100101010101010100111110000111110100000" },
|
/* 70*/ { BARCODE_DBAR_LTD_CC, "0987144605916", 100, 30, 6, 79, "0101010101010011111000011111011010110100100101010101010100111110000111110100000" },
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
char *text;
|
char *text;
|
||||||
|
|
||||||
@ -135,16 +135,13 @@ static void test_binary_div_modulo_divisor(int index, int generate, int debug) {
|
|||||||
struct zint_symbol *symbol = ZBarcode_Create();
|
struct zint_symbol *symbol = ZBarcode_Create();
|
||||||
assert_nonnull(symbol, "Symbol not created\n");
|
assert_nonnull(symbol, "Symbol not created\n");
|
||||||
|
|
||||||
symbol->symbology = data[i].symbology;
|
if (data[i].symbology == BARCODE_DBAR_OMN_CC || data[i].symbology == BARCODE_DBAR_LTD_CC) {
|
||||||
symbol->debug |= debug;
|
|
||||||
|
|
||||||
if (symbol->symbology == BARCODE_DBAR_OMN_CC || symbol->symbology == BARCODE_DBAR_LTD_CC) {
|
|
||||||
text = "[20]01";
|
text = "[20]01";
|
||||||
strcpy(symbol->primary, data[i].data);
|
strcpy(symbol->primary, data[i].data);
|
||||||
} else {
|
} else {
|
||||||
text = data[i].data;
|
text = data[i].data;
|
||||||
}
|
}
|
||||||
int length = strlen(text);
|
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, text, -1, debug);
|
||||||
|
|
||||||
ret = ZBarcode_Encode(symbol, (const unsigned char *) text, length);
|
ret = ZBarcode_Encode(symbol, (const unsigned char *) text, length);
|
||||||
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 (%s)\n", i, ret, symbol->errtxt);
|
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 (%s)\n", i, ret, symbol->errtxt);
|
||||||
@ -152,7 +149,7 @@ static void test_binary_div_modulo_divisor(int index, int generate, int debug) {
|
|||||||
if (generate) {
|
if (generate) {
|
||||||
printf(" /*%3d*/ { %s, \"%s\", %.0f, %.0f, %d, %d, ",
|
printf(" /*%3d*/ { %s, \"%s\", %.0f, %.0f, %d, %d, ",
|
||||||
i, testUtilBarcodeName(data[i].symbology), data[i].data, data[i].w, data[i].h, symbol->rows, symbol->width);
|
i, testUtilBarcodeName(data[i].symbology), data[i].data, data[i].w, data[i].h, symbol->rows, symbol->width);
|
||||||
testUtilModulesDumpRow(symbol, symbol->rows - 1, "", " },\n");
|
testUtilModulesPrintRow(symbol, symbol->rows - 1, "", " },\n");
|
||||||
} else {
|
} else {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
||||||
@ -774,7 +771,7 @@ static void test_examples(int index, int generate, int debug) {
|
|||||||
"101110001111011010010111111000011100001011011100011000011110110010110001100000000101100000001010010011101101001100000101111100000011000010101111101110001110110011001100110000000001011100111000110100111101100101111101011111111100110100000000000000000"
|
"101110001111011010010111111000011100001011011100011000011110110010110001100000000101100000001010010011101101001100000101111100000011000010101111101110001110110011001100110000000001011100111000110100111101100101111101011111111100110100000000000000000"
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
char bwipp_buf[4096];
|
char bwipp_buf[4096];
|
||||||
char bwipp_msg[1024];
|
char bwipp_msg[1024];
|
||||||
@ -795,7 +792,7 @@ static void test_examples(int index, int generate, int debug) {
|
|||||||
if (generate) {
|
if (generate) {
|
||||||
printf(" /*%3d*/ { %s, %d, \"%s\", %d, %d, %d, %d, \"%s\",\n",
|
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);
|
||||||
testUtilModulesDump(symbol, " ", "\n");
|
testUtilModulesPrint(symbol, " ", "\n");
|
||||||
printf(" },\n");
|
printf(" },\n");
|
||||||
} else {
|
} else {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d %s symbol->rows %d != %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), symbol->rows, data[i].expected_rows, data[i].data);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d %s symbol->rows %d != %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
@ -1089,7 +1086,7 @@ static void test_general_field(int index, int generate, int debug) {
|
|||||||
"101110011100010010011100111111110100111101001000011000010010001011110100001111110001100010100000100010"
|
"101110011100010010011100111111110100111101001000011000010010001011110100001111110001100010100000100010"
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
for (int i = 0; i < data_size; i++) {
|
for (int i = 0; i < data_size; i++) {
|
||||||
|
|
||||||
@ -1098,10 +1095,7 @@ static void test_general_field(int index, int generate, int debug) {
|
|||||||
struct zint_symbol *symbol = ZBarcode_Create();
|
struct zint_symbol *symbol = ZBarcode_Create();
|
||||||
assert_nonnull(symbol, "Symbol not created\n");
|
assert_nonnull(symbol, "Symbol not created\n");
|
||||||
|
|
||||||
symbol->symbology = data[i].symbology;
|
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||||
symbol->debug |= debug;
|
|
||||||
|
|
||||||
int length = strlen(data[i].data);
|
|
||||||
|
|
||||||
ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].data, length);
|
ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].data, length);
|
||||||
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 (%s)\n", i, ret, symbol->errtxt);
|
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 (%s)\n", i, ret, symbol->errtxt);
|
||||||
@ -1109,7 +1103,7 @@ static void test_general_field(int index, int generate, int debug) {
|
|||||||
if (generate) {
|
if (generate) {
|
||||||
printf(" /*%2d*/ { %s, \"%s\", %d, %d, %d, \"%s\",\n",
|
printf(" /*%2d*/ { %s, \"%s\", %d, %d, %d, \"%s\",\n",
|
||||||
i, testUtilBarcodeName(symbol->symbology), data[i].data, ret, symbol->rows, symbol->width, data[i].comment);
|
i, testUtilBarcodeName(symbol->symbology), data[i].data, ret, symbol->rows, symbol->width, data[i].comment);
|
||||||
testUtilModulesDump(symbol, " ", "\n");
|
testUtilModulesPrint(symbol, " ", "\n");
|
||||||
printf(" },\n");
|
printf(" },\n");
|
||||||
} else {
|
} else {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d %s symbol->rows %d != %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), symbol->rows, data[i].expected_rows, data[i].data);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d %s symbol->rows %d != %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
@ -1149,7 +1143,7 @@ static void test_binary_buffer_size(int index, int generate, int debug) {
|
|||||||
/* 6*/ { "[01]92345678901237[3920]123456789012345[00]123456789012345675[91]1234567890123456789", 0, 1, 543, "77 (incl. FNC1 after 3920) == 01 + 392x + other AIs max" },
|
/* 6*/ { "[01]92345678901237[3920]123456789012345[00]123456789012345675[91]1234567890123456789", 0, 1, 543, "77 (incl. FNC1 after 3920) == 01 + 392x + other AIs max" },
|
||||||
/* 7*/ { "[01]92345678901237[3920]123456789012345[00]123456789012345675[91]12345678901234567890", ZINT_ERROR_TOO_LONG, 0, 0, "78 > 01 + 392x + other AIs max" },
|
/* 7*/ { "[01]92345678901237[3920]123456789012345[00]123456789012345675[91]12345678901234567890", ZINT_ERROR_TOO_LONG, 0, 0, "78 > 01 + 392x + other AIs max" },
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
for (int i = 0; i < data_size; i++) {
|
for (int i = 0; i < data_size; i++) {
|
||||||
|
|
||||||
@ -1158,10 +1152,7 @@ static void test_binary_buffer_size(int index, int generate, int debug) {
|
|||||||
struct zint_symbol *symbol = ZBarcode_Create();
|
struct zint_symbol *symbol = ZBarcode_Create();
|
||||||
assert_nonnull(symbol, "Symbol not created\n");
|
assert_nonnull(symbol, "Symbol not created\n");
|
||||||
|
|
||||||
symbol->symbology = BARCODE_DBAR_EXP;
|
int length = testUtilSetSymbol(symbol, BARCODE_DBAR_EXP, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||||
symbol->debug |= debug;
|
|
||||||
|
|
||||||
int length = strlen(data[i].data);
|
|
||||||
|
|
||||||
ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].data, length);
|
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);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||||
@ -1280,7 +1271,7 @@ static void test_input(int index, int debug) {
|
|||||||
ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].data, length);
|
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);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||||
|
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
libzint - the open source barcode library
|
libzint - the open source barcode library
|
||||||
Copyright (C) 2020 Robin Stuart <rstuart114@gmail.com>
|
Copyright (C) 2020 - 2021 Robin Stuart <rstuart114@gmail.com>
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions
|
modification, are permitted provided that the following conditions
|
||||||
@ -247,7 +247,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||||||
printf(" /*%3d*/ { %s, \"%s\", %d, %s, %d, %d, \"%s\",\n",
|
printf(" /*%3d*/ { %s, \"%s\", %d, %s, %d, %d, \"%s\",\n",
|
||||||
i, testUtilBarcodeName(data[i].symbology), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length,
|
i, testUtilBarcodeName(data[i].symbology), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length,
|
||||||
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
|
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
|
||||||
testUtilModulesDump(symbol, " ", "\n");
|
testUtilModulesPrint(symbol, " ", "\n");
|
||||||
printf(" },\n");
|
printf(" },\n");
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < 5) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
libzint - the open source barcode library
|
libzint - the open source barcode library
|
||||||
Copyright (C) 2020 Robin Stuart <rstuart114@gmail.com>
|
Copyright (C) 2020 - 2021 Robin Stuart <rstuart114@gmail.com>
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions
|
modification, are permitted provided that the following conditions
|
||||||
@ -75,7 +75,7 @@ static void test_reader_init(int index, int generate, int debug) {
|
|||||||
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
||||||
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, symbol->errtxt, data[i].comment);
|
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, symbol->errtxt, data[i].comment);
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||||
@ -173,7 +173,7 @@ static void test_input(int index, int generate, int debug) {
|
|||||||
i, testUtilInputModeName(data[i].input_mode), data[i].eci, data[i].option_1, testUtilOption3Name(data[i].option_3),
|
i, testUtilInputModeName(data[i].input_mode), data[i].eci, data[i].option_1, testUtilOption3Name(data[i].option_3),
|
||||||
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->errtxt, data[i].comment);
|
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->errtxt, data[i].comment);
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -497,10 +497,10 @@ static void test_encode(int index, int generate, int debug) {
|
|||||||
printf(" /*%3d*/ { %s, %d, %d, %s, \"%s\", %s, %d, %d, \"%s\",\n",
|
printf(" /*%3d*/ { %s, %d, %d, %s, \"%s\", %s, %d, %d, \"%s\",\n",
|
||||||
i, testUtilInputModeName(data[i].input_mode), data[i].eci, data[i].option_1, testUtilOption3Name(data[i].option_3),
|
i, testUtilInputModeName(data[i].input_mode), data[i].eci, data[i].option_1, testUtilOption3Name(data[i].option_3),
|
||||||
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
|
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
|
||||||
testUtilModulesDump(symbol, " ", "\n");
|
testUtilModulesPrint(symbol, " ", "\n");
|
||||||
printf(" },\n");
|
printf(" },\n");
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
libzint - the open source barcode library
|
libzint - the open source barcode library
|
||||||
Copyright (C) 2019 - 2020 Robin Stuart <rstuart114@gmail.com>
|
Copyright (C) 2019 - 2021 Robin Stuart <rstuart114@gmail.com>
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions
|
modification, are permitted provided that the following conditions
|
||||||
@ -87,7 +87,7 @@ static void test_upce_input(int index, int debug) {
|
|||||||
/* 41*/ { BARCODE_UPCE, "000001", 0 },
|
/* 41*/ { BARCODE_UPCE, "000001", 0 },
|
||||||
/* 42*/ { BARCODE_UPCE, "000002", 0 },
|
/* 42*/ { BARCODE_UPCE, "000002", 0 },
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
for (int i = 0; i < data_size; i++) {
|
for (int i = 0; i < data_size; i++) {
|
||||||
|
|
||||||
@ -96,10 +96,7 @@ static void test_upce_input(int index, int debug) {
|
|||||||
struct zint_symbol *symbol = ZBarcode_Create();
|
struct zint_symbol *symbol = ZBarcode_Create();
|
||||||
assert_nonnull(symbol, "Symbol not created\n");
|
assert_nonnull(symbol, "Symbol not created\n");
|
||||||
|
|
||||||
symbol->symbology = data[i].symbology;
|
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||||
symbol->debug |= debug;
|
|
||||||
|
|
||||||
int length = strlen(data[i].data);
|
|
||||||
|
|
||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
||||||
assert_equal(ret, data[i].ret, "i:%d ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
assert_equal(ret, data[i].ret, "i:%d ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||||
@ -125,7 +122,7 @@ static void test_upca_print(int index, int debug) {
|
|||||||
struct item data[] = {
|
struct item data[] = {
|
||||||
/* 0*/ { BARCODE_UPCA, "01234567890", 0 },
|
/* 0*/ { BARCODE_UPCA, "01234567890", 0 },
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
for (int i = 0; i < data_size; i++) {
|
for (int i = 0; i < data_size; i++) {
|
||||||
|
|
||||||
@ -134,10 +131,7 @@ static void test_upca_print(int index, int debug) {
|
|||||||
struct zint_symbol *symbol = ZBarcode_Create();
|
struct zint_symbol *symbol = ZBarcode_Create();
|
||||||
assert_nonnull(symbol, "Symbol not created\n");
|
assert_nonnull(symbol, "Symbol not created\n");
|
||||||
|
|
||||||
symbol->symbology = data[i].symbology;
|
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||||
symbol->debug |= debug;
|
|
||||||
|
|
||||||
int length = strlen(data[i].data);
|
|
||||||
|
|
||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
||||||
assert_equal(ret, data[i].ret, "i:%d ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
assert_equal(ret, data[i].ret, "i:%d ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||||
@ -458,7 +452,7 @@ static void test_isbn_input(int index, int debug) {
|
|||||||
/* 53*/ { "97912345678961+12345", ZINT_ERROR_TOO_LONG, -1 },
|
/* 53*/ { "97912345678961+12345", ZINT_ERROR_TOO_LONG, -1 },
|
||||||
/* 54*/ { "9791234567896+123456", ZINT_ERROR_TOO_LONG, -1 },
|
/* 54*/ { "9791234567896+123456", ZINT_ERROR_TOO_LONG, -1 },
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
for (int i = 0; i < data_size; i++) {
|
for (int i = 0; i < data_size; i++) {
|
||||||
|
|
||||||
@ -468,10 +462,7 @@ static void test_isbn_input(int index, int debug) {
|
|||||||
struct zint_symbol *symbol = ZBarcode_Create();
|
struct zint_symbol *symbol = ZBarcode_Create();
|
||||||
assert_nonnull(symbol, "Symbol not created\n");
|
assert_nonnull(symbol, "Symbol not created\n");
|
||||||
|
|
||||||
symbol->symbology = BARCODE_ISBNX;
|
int length = testUtilSetSymbol(symbol, BARCODE_ISBNX, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||||
symbol->debug |= debug;
|
|
||||||
|
|
||||||
int length = strlen(data[i].data);
|
|
||||||
|
|
||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
||||||
assert_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret_encode, symbol->errtxt);
|
assert_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret_encode, symbol->errtxt);
|
||||||
@ -503,7 +494,7 @@ static void test_vector_same(int index, int debug) {
|
|||||||
/* 1*/ { BARCODE_UPCE_CHK, "1234565", 0, 0 }, // 5 is correct check digit
|
/* 1*/ { BARCODE_UPCE_CHK, "1234565", 0, 0 }, // 5 is correct check digit
|
||||||
/* 2*/ { BARCODE_ISBNX, "0195049969", 0, 0 }, // 9 is correct check digit
|
/* 2*/ { BARCODE_ISBNX, "0195049969", 0, 0 }, // 9 is correct check digit
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
for (int i = 0; i < data_size; i++) {
|
for (int i = 0; i < data_size; i++) {
|
||||||
|
|
||||||
@ -516,10 +507,7 @@ static void test_vector_same(int index, int debug) {
|
|||||||
struct zint_symbol *symbol = ZBarcode_Create();
|
struct zint_symbol *symbol = ZBarcode_Create();
|
||||||
assert_nonnull(symbol, "Symbol not created\n");
|
assert_nonnull(symbol, "Symbol not created\n");
|
||||||
|
|
||||||
symbol->symbology = data[i].symbology;
|
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||||
symbol->debug |= debug;
|
|
||||||
|
|
||||||
int length = strlen(data[i].data);
|
|
||||||
|
|
||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
||||||
assert_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret_encode, symbol->errtxt);
|
assert_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret_encode, symbol->errtxt);
|
||||||
@ -698,10 +686,10 @@ static void test_encode(int index, int generate, int debug) {
|
|||||||
if (generate) {
|
if (generate) {
|
||||||
printf(" /*%3d*/ { %s, %d, \"%s\", %s, %d, %d, \"%s\",\n",
|
printf(" /*%3d*/ { %s, %d, \"%s\", %s, %d, %d, \"%s\",\n",
|
||||||
i, testUtilBarcodeName(data[i].symbology), data[i].option_2, data[i].data, testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
|
i, testUtilBarcodeName(data[i].symbology), data[i].option_2, data[i].data, testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
|
||||||
testUtilModulesDump(symbol, " ", "\n");
|
testUtilModulesPrint(symbol, " ", "\n");
|
||||||
printf(" },\n");
|
printf(" },\n");
|
||||||
} else {
|
} else {
|
||||||
if (ret < 5) {
|
if (ret < ZINT_ERROR) {
|
||||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
|
|
||||||
@ -751,7 +739,7 @@ static void test_fuzz(int index, int debug) {
|
|||||||
/* 8*/ { BARCODE_EANX, "+12345", -1, 0 },
|
/* 8*/ { BARCODE_EANX, "+12345", -1, 0 },
|
||||||
/* 9*/ { BARCODE_EANX, "+123456", -1, ZINT_ERROR_TOO_LONG },
|
/* 9*/ { BARCODE_EANX, "+123456", -1, ZINT_ERROR_TOO_LONG },
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
for (int i = 0; i < data_size; i++) {
|
for (int i = 0; i < data_size; i++) {
|
||||||
|
|
||||||
@ -760,13 +748,7 @@ static void test_fuzz(int index, int debug) {
|
|||||||
struct zint_symbol *symbol = ZBarcode_Create();
|
struct zint_symbol *symbol = ZBarcode_Create();
|
||||||
assert_nonnull(symbol, "Symbol not created\n");
|
assert_nonnull(symbol, "Symbol not created\n");
|
||||||
|
|
||||||
symbol->symbology = data[i].symbology;
|
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
|
||||||
symbol->debug |= debug;
|
|
||||||
|
|
||||||
int length = data[i].length;
|
|
||||||
if (length == -1) {
|
|
||||||
length = strlen(data[i].data);
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
||||||
assert_equal(ret, data[i].ret, "i:%d ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
assert_equal(ret, data[i].ret, "i:%d ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "testcommon.h"
|
#include "testcommon.h"
|
||||||
|
#include "../eci.h"
|
||||||
#ifndef NO_PNG
|
#ifndef NO_PNG
|
||||||
#include <png.h>
|
#include <png.h>
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
@ -594,8 +595,8 @@ int testUtilDAFTConvert(const struct zint_symbol *symbol, char *buffer, int buff
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Is string valid UTF-8? */
|
/* Is string valid UTF-8? */
|
||||||
int testUtilIsValidUTF8(const unsigned char str[], const size_t length) {
|
int testUtilIsValidUTF8(const unsigned char str[], const int length) {
|
||||||
size_t i;
|
int i;
|
||||||
unsigned int codepoint, state = 0;
|
unsigned int codepoint, state = 0;
|
||||||
|
|
||||||
for (i = 0; i < length; i++) {
|
for (i = 0; i < length; i++) {
|
||||||
@ -918,14 +919,37 @@ int testUtilVectorCmp(const struct zint_vector *a, const struct zint_vector *b)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void testUtilModulesDump(const struct zint_symbol *symbol, const char *prefix, const char *postfix) {
|
int testUtilModulesDump(const struct zint_symbol *symbol, char dump[], int dump_size) {
|
||||||
|
int r, w;
|
||||||
|
char *d = dump;
|
||||||
|
char *de = dump + dump_size;
|
||||||
|
|
||||||
|
for (r = 0; r < symbol->rows && d < de; r++) {
|
||||||
|
if (symbol->symbology == BARCODE_ULTRA) {
|
||||||
|
for (w = 0; w < symbol->width && d < de; w++) {
|
||||||
|
*d++ = module_colour_is_set(symbol, r, w) + '0';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (w = 0; w < symbol->width && d < de; w++) {
|
||||||
|
*d++ = module_is_set(symbol, r, w) + '0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (d == de) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
*d = '\0';
|
||||||
|
return d - dump;
|
||||||
|
}
|
||||||
|
|
||||||
|
void testUtilModulesPrint(const struct zint_symbol *symbol, const char *prefix, const char *postfix) {
|
||||||
int r;
|
int r;
|
||||||
for (r = 0; r < symbol->rows; r++) {
|
for (r = 0; r < symbol->rows; r++) {
|
||||||
testUtilModulesDumpRow(symbol, r, prefix, postfix);
|
testUtilModulesPrintRow(symbol, r, prefix, postfix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void testUtilModulesDumpRow(const struct zint_symbol *symbol, int row, const char *prefix, const char *postfix) {
|
void testUtilModulesPrintRow(const struct zint_symbol *symbol, int row, const char *prefix, const char *postfix) {
|
||||||
int w;
|
int w;
|
||||||
if (*prefix) {
|
if (*prefix) {
|
||||||
fputs(prefix, stdout);
|
fputs(prefix, stdout);
|
||||||
@ -1756,7 +1780,7 @@ static const char *testUtilBwippName(int index, const struct zint_symbol *symbol
|
|||||||
{ "", BARCODE_AUSREDIRECT, 68, 0, 0, 0, 0, 0, },
|
{ "", BARCODE_AUSREDIRECT, 68, 0, 0, 0, 0, 0, },
|
||||||
{ "isbn", BARCODE_ISBNX, 69, 0, 1, 0, 0, 1 /*gs1_cvt*/, },
|
{ "isbn", BARCODE_ISBNX, 69, 0, 1, 0, 0, 1 /*gs1_cvt*/, },
|
||||||
{ "royalmail", BARCODE_RM4SCC, 70, 0, 0, 0, 0, 0, },
|
{ "royalmail", BARCODE_RM4SCC, 70, 0, 0, 0, 0, 0, },
|
||||||
{ "datamatrix", BARCODE_DATAMATRIX, 71, 0, 1, 1, 0, 0, },
|
{ "datamatrix", BARCODE_DATAMATRIX, 71, 0, 1, 1, 1, 0, },
|
||||||
{ "ean14", BARCODE_EAN14, 72, 0, 0, 0, 0, 1 /*gs1_cvt*/, },
|
{ "ean14", BARCODE_EAN14, 72, 0, 0, 0, 0, 1 /*gs1_cvt*/, },
|
||||||
{ "code39", BARCODE_VIN, 73, 0, 0, 0, 0, 0, },
|
{ "code39", BARCODE_VIN, 73, 0, 0, 0, 0, 0, },
|
||||||
{ "codablockf", BARCODE_CODABLOCKF, 74, 1, 1, 0, 10 /*linear_row_height*/, 0, },
|
{ "codablockf", BARCODE_CODABLOCKF, 74, 1, 1, 0, 10 /*linear_row_height*/, 0, },
|
||||||
@ -1883,12 +1907,6 @@ static const char *testUtilBwippName(int index, const struct zint_symbol *symbol
|
|||||||
}
|
}
|
||||||
if (gs1) {
|
if (gs1) {
|
||||||
if (symbology == BARCODE_DATAMATRIX) {
|
if (symbology == BARCODE_DATAMATRIX) {
|
||||||
if (symbol->output_options & GS1_GS_SEPARATOR) { /* Not supported */
|
|
||||||
if (debug & ZINT_DEBUG_TEST_PRINT) {
|
|
||||||
printf("i:%d %s not BWIPP compatible, GS1_GS_SEPARATOR not supported\n", index, testUtilBarcodeName(symbology));
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if (gs1_cvt) {
|
if (gs1_cvt) {
|
||||||
*gs1_cvt = 1;
|
*gs1_cvt = 1;
|
||||||
}
|
}
|
||||||
@ -2031,6 +2049,8 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
|
|||||||
int primary_len = primary ? (int) strlen(primary) : 0;
|
int primary_len = primary ? (int) strlen(primary) : 0;
|
||||||
int max_data_len = 4 + primary_len + 1 + 1 + data_len * 4 + 32; /* 4 AI prefix + primary + '|' + leading zero + escaped data + fudge */
|
int max_data_len = 4 + primary_len + 1 + 1 + data_len * 4 + 32; /* 4 AI prefix + primary + '|' + leading zero + escaped data + fudge */
|
||||||
|
|
||||||
|
int eci_length = get_eci_length(symbol->eci, (const unsigned char *) data, data_len);
|
||||||
|
char converted[eci_length + 1];
|
||||||
char cmd[max_data_len + 1024];
|
char cmd[max_data_len + 1024];
|
||||||
const char *bwipp_barcode = NULL;
|
const char *bwipp_barcode = NULL;
|
||||||
char *bwipp_opts = NULL;
|
char *bwipp_opts = NULL;
|
||||||
@ -2052,6 +2072,7 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
|
|||||||
int upcean = is_extendable(symbology);
|
int upcean = is_extendable(symbology);
|
||||||
int upca = symbology == BARCODE_UPCA || symbology == BARCODE_UPCA_CHK || symbology == BARCODE_UPCA_CC;
|
int upca = symbology == BARCODE_UPCA || symbology == BARCODE_UPCA_CHK || symbology == BARCODE_UPCA_CC;
|
||||||
int addon_posn;
|
int addon_posn;
|
||||||
|
int eci;
|
||||||
|
|
||||||
bwipp_data[0] = bwipp_opts_buf[0] = '\0';
|
bwipp_data[0] = bwipp_opts_buf[0] = '\0';
|
||||||
|
|
||||||
@ -2073,6 +2094,26 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
|
|||||||
bwipp_row_height[symbol->rows - 1] = 36;
|
bwipp_row_height[symbol->rows - 1] = 36;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((symbol->input_mode & 0x07) == UNICODE_MODE && ZBarcode_Cap(symbology, ZINT_CAP_ECI) && is_eci_convertible(symbol->eci)) {
|
||||||
|
if (utf8_to_eci(symbol->eci, (const unsigned char *) data, (unsigned char *) converted, &data_len) == 0) {
|
||||||
|
eci = symbol->eci;
|
||||||
|
} else {
|
||||||
|
if (symbol->eci != 0) {
|
||||||
|
eci = get_best_eci((const unsigned char *) data, data_len);
|
||||||
|
if (utf8_to_eci(eci, (const unsigned char *) data, (unsigned char *) converted, &data_len) != 0) {
|
||||||
|
fprintf(stderr, "i:%d testUtilBwipp: failed to convert Unicode data for %s\n", index, testUtilBarcodeName(symbology));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "i:%d testUtilBwipp: failed to convert Unicode data for %s\n", index, testUtilBarcodeName(symbology));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data = converted;
|
||||||
|
} else {
|
||||||
|
eci = symbol->eci >= 3 && ZBarcode_Cap(symbology, ZINT_CAP_ECI) ? symbol->eci : 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (is_composite(symbology)) {
|
if (is_composite(symbology)) {
|
||||||
if (!primary) {
|
if (!primary) {
|
||||||
fprintf(stderr, "i:%d testUtilBwipp: no primary data given %s\n", index, testUtilBarcodeName(symbology));
|
fprintf(stderr, "i:%d testUtilBwipp: no primary data given %s\n", index, testUtilBarcodeName(symbology));
|
||||||
@ -2133,7 +2174,6 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int eci = symbol->eci >= 3 && ZBarcode_Cap(symbology, ZINT_CAP_ECI) ? symbol->eci : 0;
|
|
||||||
if (testUtilBwippEscape(bwipp_data, sizeof(bwipp_data), data, data_len, symbol->input_mode & ESCAPE_MODE, eci, &parse, &parsefnc) == NULL) {
|
if (testUtilBwippEscape(bwipp_data, sizeof(bwipp_data), data, data_len, symbol->input_mode & ESCAPE_MODE, eci, &parse, &parsefnc) == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -2329,16 +2369,29 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (symbology == BARCODE_DATAMATRIX || symbology == BARCODE_HIBC_DM) {
|
if (symbology == BARCODE_DATAMATRIX || symbology == BARCODE_HIBC_DM) {
|
||||||
|
int added_dmre = 0;
|
||||||
#include "../dmatrix.h"
|
#include "../dmatrix.h"
|
||||||
(void)matrixrsblock; (void)matrixdatablock; (void)matrixbytes; (void)matrixFW; (void)matrixFH;
|
(void)matrixrsblock; (void)matrixdatablock; (void)matrixbytes; (void)matrixFW; (void)matrixFH;
|
||||||
(void)isDMRE; (void)text_value; (void)text_shift; (void)c40_value; (void)c40_shift;
|
(void)isDMRE; (void)text_value; (void)text_shift; (void)c40_value; (void)c40_shift;
|
||||||
|
|
||||||
|
if (symbol->output_options & GS1_GS_SEPARATOR) {
|
||||||
|
sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%sgssep", strlen(bwipp_opts_buf) ? " " : "");
|
||||||
|
bwipp_opts = bwipp_opts_buf;
|
||||||
|
}
|
||||||
if (option_2 >= 1 && option_2 <= (int) sizeof(intsymbol)) {
|
if (option_2 >= 1 && option_2 <= (int) sizeof(intsymbol)) {
|
||||||
int idx = intsymbol[option_2 - 1];
|
int idx = intsymbol[option_2 - 1];
|
||||||
sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%srows=%d columns=%d", strlen(bwipp_opts_buf) ? " " : "", matrixH[idx], matrixW[idx]);
|
sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%srows=%d columns=%d", strlen(bwipp_opts_buf) ? " " : "", matrixH[idx], matrixW[idx]);
|
||||||
bwipp_opts = bwipp_opts_buf;
|
bwipp_opts = bwipp_opts_buf;
|
||||||
|
if (option_2 >= 31) {
|
||||||
|
sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%sdmre", strlen(bwipp_opts_buf) ? " " : "");
|
||||||
|
added_dmre = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (option_3 != DM_SQUARE && symbol->width != symbol->height) {
|
if (option_3 != DM_SQUARE && symbol->width != symbol->height) {
|
||||||
|
if (option_3 == DM_DMRE && !added_dmre) {
|
||||||
|
sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%sdmre", strlen(bwipp_opts_buf) ? " " : "");
|
||||||
|
added_dmre = 1;
|
||||||
|
}
|
||||||
sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%sformat=rectangle", strlen(bwipp_opts_buf) ? " " : "");
|
sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%sformat=rectangle", strlen(bwipp_opts_buf) ? " " : "");
|
||||||
bwipp_opts = bwipp_opts_buf;
|
bwipp_opts = bwipp_opts_buf;
|
||||||
}
|
}
|
||||||
@ -2365,7 +2418,7 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bwipp_opts) {
|
if (bwipp_opts && strlen(bwipp_opts)) {
|
||||||
if (strlen(bwipp_data) >= 2043) { /* Ghostscript's `arg_str_max` 2048 less "-sd=" */
|
if (strlen(bwipp_data) >= 2043) { /* Ghostscript's `arg_str_max` 2048 less "-sd=" */
|
||||||
sprintf(cmd, cmd_opts_fmt2, bwipp_barcode, bwipp_data, bwipp_data + 2043, bwipp_opts);
|
sprintf(cmd, cmd_opts_fmt2, bwipp_barcode, bwipp_data, bwipp_data + 2043, bwipp_opts);
|
||||||
} else {
|
} else {
|
||||||
|
@ -88,15 +88,16 @@ const char *testUtilInputModeName(int input_mode);
|
|||||||
const char *testUtilOption3Name(int option_3);
|
const char *testUtilOption3Name(int option_3);
|
||||||
const char *testUtilOutputOptionsName(int output_options);
|
const char *testUtilOutputOptionsName(int output_options);
|
||||||
int testUtilDAFTConvert(const struct zint_symbol *symbol, char *buffer, int buffer_size);
|
int testUtilDAFTConvert(const struct zint_symbol *symbol, char *buffer, int buffer_size);
|
||||||
int testUtilIsValidUTF8(const unsigned char str[], const size_t length);
|
int testUtilIsValidUTF8(const unsigned char str[], const int length);
|
||||||
char *testUtilEscape(char *buffer, int length, char *escaped, int escaped_size);
|
char *testUtilEscape(char *buffer, int length, char *escaped, int escaped_size);
|
||||||
char *testUtilReadCSVField(char *buffer, char *field, int field_size);
|
char *testUtilReadCSVField(char *buffer, char *field, int field_size);
|
||||||
void testUtilStrCpyRepeat(char *buffer, char *repeat, int size);
|
void testUtilStrCpyRepeat(char *buffer, char *repeat, int size);
|
||||||
int testUtilSymbolCmp(const struct zint_symbol *a, const struct zint_symbol *b);
|
int testUtilSymbolCmp(const struct zint_symbol *a, const struct zint_symbol *b);
|
||||||
struct zint_vector *testUtilVectorCpy(const struct zint_vector *in);
|
struct zint_vector *testUtilVectorCpy(const struct zint_vector *in);
|
||||||
int testUtilVectorCmp(const struct zint_vector *a, const struct zint_vector *b);
|
int testUtilVectorCmp(const struct zint_vector *a, const struct zint_vector *b);
|
||||||
void testUtilModulesDump(const struct zint_symbol *symbol, const char *prefix, const char *postfix); // TODO: should be called Print not Dump
|
int testUtilModulesDump(const struct zint_symbol *symbol, char dump[], int dump_size);
|
||||||
void testUtilModulesDumpRow(const struct zint_symbol *symbol, int row, const char *prefix, const char *postfix); // TODO: should be called Print not Dump
|
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 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 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);
|
int testUtilModulesDumpHex(const struct zint_symbol *symbol, char dump[], int dump_size);
|
||||||
|
@ -24,7 +24,7 @@ run_bwipp_test "test_code128" "encode"
|
|||||||
run_bwipp_test "test_code16k" "encode"
|
run_bwipp_test "test_code16k" "encode"
|
||||||
run_bwipp_test "test_code49" "encode"
|
run_bwipp_test "test_code49" "encode"
|
||||||
run_bwipp_test "test_composite"
|
run_bwipp_test "test_composite"
|
||||||
run_bwipp_test "test_dmatrix" "encode"
|
run_bwipp_test "test_dmatrix"
|
||||||
run_bwipp_test "test_dotcode" "encode"
|
run_bwipp_test "test_dotcode" "encode"
|
||||||
run_bwipp_test "test_gs1" "gs1_reduce"
|
run_bwipp_test "test_gs1" "gs1_reduce"
|
||||||
run_bwipp_test "test_imail" "encode"
|
run_bwipp_test "test_imail" "encode"
|
||||||
|
Loading…
Reference in New Issue
Block a user