KOREAPOST missing from is_linear; tests update

This commit is contained in:
gitlost 2019-10-14 09:49:15 +01:00
parent 6e1283ccd8
commit 433046abbf
17 changed files with 1057 additions and 316 deletions

View File

@ -493,6 +493,7 @@ static int is_linear(const int symbology) {
case BARCODE_ISBNX:
case BARCODE_EAN14:
case BARCODE_NVE18:
case BARCODE_KOREAPOST:
case BARCODE_ONECODE:
case BARCODE_PLESSEY:
case BARCODE_TELEPEN_NUM:

View File

@ -12,6 +12,13 @@ set(ZINT_DEBUG FALSE CACHE BOOL "Set debug compile flag")
set(ZINT_SANITIZE FALSE CACHE BOOL "Set sanitize compile/link flags")
find_package (LibZint 2.6.4 REQUIRED)
find_package(PNG)
if (PNG_FOUND)
include_directories(${PNG_INCLUDES})
else (PNG_FOUND)
add_definitions(-DNO_PNG)
endif (PNG_FOUND)
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
if (ZINT_DEBUG)
@ -26,7 +33,11 @@ endif ()
add_library(testcommon
testcommon.c testcommon.h)
target_link_libraries(testcommon ZINT::ZINT)
if (PNG_FOUND)
target_link_libraries(testcommon ZINT::ZINT ${PNG_LIBRARIES})
else (PNG_FOUND)
target_link_libraries(testcommon ZINT::ZINT)
endif (PNG_FOUND)
macro(zint_add_test test_name test_command)
set(ADDITIONAL_LIBS "${ARGN}" ${LIBRARY_FLAGS})
@ -40,6 +51,7 @@ zint_add_test(eci, test_eci)
zint_add_test(imail, test_imail)
zint_add_test(mailmark, test_mailmark)
zint_add_test(maxicode, test_maxicode)
zint_add_test(postal, test_postal)
zint_add_test(qr, test_qr)
zint_add_test(rss, test_rss)
zint_add_test(upcean, test_upcean)

Binary file not shown.

After

Width:  |  Height:  |  Size: 422 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 568 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -41,25 +41,26 @@ static void test_encode(void)
int ret_encode;
float w;
float h;
int ret_render;
int ret_vector;
};
// Vi} :s/\/\*[ 0-9]*\*\//\=printf("\/*%2d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { "0", 0, 0, 100, 30, 1 },
/* 1*/ { "1", 1, 0, 100, 30, 1 },
/* 2*/ { "26", 2, 0, 100, 30, 1 },
/* 3*/ { "026", 3, 0, 100, 30, 1 },
/* 4*/ { "0026", 3, 0, 100, 30, 1 },
/* 0*/ { "0", 0, 0, 100, 30, 0 },
/* 1*/ { "1", 1, 0, 100, 30, 0 },
/* 2*/ { "26", 2, 0, 100, 30, 0 },
/* 3*/ { "026", 3, 0, 100, 30, 0 },
/* 4*/ { "0026", 3, 0, 100, 30, 0 },
/* 5*/ { "1234", 3, ZINT_ERROR_INVALID_DATA, 100, 30, -1 },
/* 6*/ { "1234", 4, ZINT_ERROR_INVALID_DATA, 100, 30, -1 },
/* 7*/ { "292", 4, 0, 100, 30, 1 },
/* 8*/ { "1234", 5, 0, 100, 30, 1 },
/* 9*/ { "1234567", 0, 0, 100, 30, 1 },
/*10*/ { "576688", 7, 0, 100, 30, 1 },
/* 7*/ { "292", 4, 0, 100, 30, 0 },
/* 8*/ { "1234", 5, 0, 100, 30, 0 },
/* 9*/ { "1234567", 0, 0, 100, 30, 0 },
/*10*/ { "576688", 7, 0, 100, 30, 0 },
/*11*/ { "576689", 7, ZINT_ERROR_INVALID_DATA, 100, 30, -1 },
/*12*/ { "1234567", 0, 0, 100, 30, 1 },
/*13*/ { "1234567", 8, 0, 100, 30, 1 },
/*12*/ { "1234567", 0, 0, 100, 30, 0 },
/*13*/ { "1234567", 8, 0, 100, 30, 0 },
/*14*/ { "7742863", 8, ZINT_ERROR_INVALID_DATA, 100, 30, -1 },
/*15*/ { "0000000", 2, 0, 100, 30, 1 },
/*15*/ { "0000000", 2, 0, 100, 30, 0 },
/*16*/ { "12345678", 8, ZINT_ERROR_TOO_LONG, 100, 30, -1 },
};
int data_size = sizeof(data) / sizeof(struct item);
@ -76,9 +77,9 @@ static void test_encode(void)
ret = ZBarcode_Encode(symbol, data[i].data, length);
assert_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret_encode);
if (data[i].ret_render != -1) {
ret = ZBarcode_Render( symbol, data[i].w, data[i].h );
assert_equal(ret, data[i].ret_render, "i:%d ZBarcode_Render ret %d != %d\n", i, ret, data[i].ret_render);
if (data[i].ret_vector != -1) {
ret = ZBarcode_Buffer_Vector(symbol, 0);
assert_equal(ret, data[i].ret_vector, "i:%d ZBarcode_Buffer_Vector ret %d != %d\n", i, ret, data[i].ret_vector);
}
ZBarcode_Delete(symbol);

View File

@ -113,45 +113,108 @@ static void test_encode(void)
struct item {
int symbology;
int input_mode;
int eci;
unsigned char* data;
int ret_encode;
float w;
float h;
int ret_render;
int ret_vector;
int expected_eci;
};
// é U+00E9 in ISO 8859-1 plus other ISO 8859 (but not in ISO 8859-7 or ISO 8859-11), in Shift-JIS, in GB-2312/18030
// β U+03B2 in ISO 8859-7 Greek (but not other ISO 8859), in Shift-JIS, in GB-2312/18030
// ก U+0E01 in ISO 8859-11 Thai (but not other ISO 8859), not in Shift-JIS, not in GB-2312/18030
// ກ U+0E81 Lao not in any ISO 8859 (or Windows page) or Shift-JIS or GB-2312/18030
// Vi} :s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_QRCODE, UNICODE_MODE, "", 0, 100, 30, 1, 3 },
/* 1*/ { BARCODE_QRCODE, UNICODE_MODE, "", 0, 100, 30, 1, 3 }, // Converts to Shift-JIS
/* 2*/ { BARCODE_QRCODE, UNICODE_MODE, "Aก", ZINT_WARN_USES_ECI, 100, 30, 1, 13 }, // ECI 13 == ISO 8859-11
/* 3*/ { BARCODE_QRCODE, UNICODE_MODE, "Aéβ", 0, 100, 30, 1, 3 }, // Converts to Shift-JIS
/* 4*/ { BARCODE_QRCODE, UNICODE_MODE, "Aéβก", ZINT_WARN_USES_ECI, 100, 30, 1, 26 },
/* 5*/ { BARCODE_QRCODE, UNICODE_MODE, "Aກ", ZINT_WARN_USES_ECI, 100, 30, 1, 26 },
/* 6*/ { BARCODE_MICROQR, UNICODE_MODE, "", 0, 100, 30, 1, 3 },
/* 7*/ { BARCODE_MICROQR, UNICODE_MODE, "", 0, 100, 30, 1, 3 }, // Converts to Shift-JIS
/* 8*/ { BARCODE_MICROQR, UNICODE_MODE, "Aéβ", 0, 100, 30, 1, 3 }, // Converts to Shift-JIS
/* 9*/ { BARCODE_MICROQR, UNICODE_MODE, "", ZINT_ERROR_INVALID_DATA, 100, 30, -1, -1 },
/*10*/ { BARCODE_GRIDMATRIX, UNICODE_MODE, "", 0, 100, 30, 1, 3 },
/*11*/ { BARCODE_GRIDMATRIX, UNICODE_MODE, "", 0, 100, 30, 1, 3 }, // Converts to GB-2312
/*12*/ { BARCODE_GRIDMATRIX, UNICODE_MODE, "Aก", ZINT_WARN_USES_ECI, 100, 30, 1, 13 }, // ECI 13 == ISO 8859-11
/*13*/ { BARCODE_GRIDMATRIX, UNICODE_MODE, "Aéβ", 0, 100, 30, 1, 3 }, // Converts to GB-2312
/*14*/ { BARCODE_GRIDMATRIX, UNICODE_MODE, "Aéβก", ZINT_WARN_USES_ECI, 100, 30, 1, 26 },
/*15*/ { BARCODE_HANXIN, UNICODE_MODE, "", 0, 100, 30, 1, 3 },
/*16*/ { BARCODE_HANXIN, UNICODE_MODE, "", 0, 100, 30, 1, 3 }, // Converts to GB-18030
/*17*/ { BARCODE_HANXIN, UNICODE_MODE, "Aก", ZINT_WARN_USES_ECI, 100, 30, 1, 13 }, // ECI 13 == ISO 8859-11
/*18*/ { BARCODE_HANXIN, UNICODE_MODE, "Aéβ", 0, 100, 30, 1, 3 }, // Converts to GB-18030
/*19*/ { BARCODE_HANXIN, UNICODE_MODE, "Aéβก", ZINT_WARN_USES_ECI, 100, 30, 1, 26 },
/*20*/ { BARCODE_UPNQR, UNICODE_MODE, "", 0, 100, 30, 1, 4 }, // ECI 4 == iSO 8859-2
/*21*/ { BARCODE_UPNQR, UNICODE_MODE, "", ZINT_ERROR_INVALID_DATA, 100, 30, -1, -1 },
/*22*/ { BARCODE_DATAMATRIX, UNICODE_MODE, "", 0, 100, 30, 1, 3 },
/*23*/ { BARCODE_DATAMATRIX, UNICODE_MODE, "", ZINT_WARN_USES_ECI, 100, 30, 1, 9 }, // ECI 9 == ISO 8859-7
/*24*/ { BARCODE_DATAMATRIX, UNICODE_MODE, "Aก", ZINT_WARN_USES_ECI, 100, 30, 1, 13 }, // ECI 13 == ISO 8859-11
/*25*/ { BARCODE_DATAMATRIX, UNICODE_MODE, "Aéβ", ZINT_WARN_USES_ECI, 100, 30, 1, 26 },
/*26*/ { BARCODE_DATAMATRIX, UNICODE_MODE, "Aéβก", ZINT_WARN_USES_ECI, 100, 30, 1, 26 },
/* 0*/ { BARCODE_QRCODE, UNICODE_MODE, 0, "", 0, 100, 30, 0, 0 },
/* 1*/ { BARCODE_QRCODE, UNICODE_MODE, 0, "", 0, 100, 30, 0, 0 }, // Converts to Shift-JIS
/* 2*/ { BARCODE_QRCODE, UNICODE_MODE, 0, "Aก", ZINT_WARN_USES_ECI, 100, 30, 0, 13 }, // ECI 13 == ISO 8859-11
/* 3*/ { BARCODE_QRCODE, UNICODE_MODE, 0, "Aéβ", 0, 100, 30, 0, 0 }, // Converts to Shift-JIS
/* 4*/ { BARCODE_QRCODE, UNICODE_MODE, 0, "Aéβก", ZINT_WARN_USES_ECI, 100, 30, 0, 26 },
/* 5*/ { BARCODE_QRCODE, UNICODE_MODE, 0, "Aກ", ZINT_WARN_USES_ECI, 100, 30, 0, 26 },
/* 6*/ { BARCODE_QRCODE, UNICODE_MODE, 3, "", 0, 100, 30, 0, 3 },
/* 7*/ { BARCODE_MICROQR, UNICODE_MODE, 0, "", 0, 100, 30, 0, 0 },
/* 8*/ { BARCODE_MICROQR, UNICODE_MODE, 0, "", 0, 100, 30, 0, 0 }, // Converts to Shift-JIS
/* 9*/ { BARCODE_MICROQR, UNICODE_MODE, 0, "Aéβ", 0, 100, 30, 0, 0 }, // Converts to Shift-JIS
/* 10*/ { BARCODE_MICROQR, UNICODE_MODE, 0, "", ZINT_ERROR_INVALID_DATA, 100, 30, -1, -1 },
/* 11*/ { BARCODE_MICROQR, UNICODE_MODE, 3, "", 0, 100, 30, 0, 3 },
/* 12*/ { BARCODE_GRIDMATRIX, UNICODE_MODE, 0, "", 0, 100, 30, 0, 0 },
/* 13*/ { BARCODE_GRIDMATRIX, UNICODE_MODE, 0, "", 0, 100, 30, 0, 0 }, // Converts to GB-2312
/* 14*/ { BARCODE_GRIDMATRIX, UNICODE_MODE, 0, "Aก", ZINT_WARN_USES_ECI, 100, 30, 0, 13 }, // ECI 13 == ISO 8859-11
/* 15*/ { BARCODE_GRIDMATRIX, UNICODE_MODE, 0, "Aéβ", 0, 100, 30, 0, 0 }, // Converts to GB-2312
/* 16*/ { BARCODE_GRIDMATRIX, UNICODE_MODE, 0, "Aéβก", ZINT_WARN_USES_ECI, 100, 30, 0, 26 },
/* 17*/ { BARCODE_GRIDMATRIX, UNICODE_MODE, 3, "", 0, 100, 30, 0, 3 },
/* 18*/ { BARCODE_HANXIN, UNICODE_MODE, 0, "", 0, 100, 30, 0, 0 },
/* 19*/ { BARCODE_HANXIN, UNICODE_MODE, 0, "", 0, 100, 30, 0, 0 }, // Converts to GB-18030
/* 20*/ { BARCODE_HANXIN, UNICODE_MODE, 0, "Aก", ZINT_WARN_USES_ECI, 100, 30, 0, 13 }, // ECI 13 == ISO 8859-11
/* 21*/ { BARCODE_HANXIN, UNICODE_MODE, 0, "Aéβ", 0, 100, 30, 0, 0 }, // Converts to GB-18030
/* 22*/ { BARCODE_HANXIN, UNICODE_MODE, 0, "Aéβก", ZINT_WARN_USES_ECI, 100, 30, 0, 26 },
/* 23*/ { BARCODE_HANXIN, UNICODE_MODE, 3, "", 0, 100, 30, 0, 3 },
/* 24*/ { BARCODE_UPNQR, UNICODE_MODE, 0, "", 0, 100, 30, 0, 4 }, // ECI 4 == iSO 8859-2
/* 25*/ { BARCODE_UPNQR, UNICODE_MODE, 0, "", ZINT_ERROR_INVALID_DATA, 100, 30, -1, -1 },
/* 26*/ { BARCODE_UPNQR, UNICODE_MODE, 3, "", 0, 100, 30, 0, 4 },
/* 27*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 0, "", 0, 100, 30, 0, 0 },
/* 28*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 0, "", ZINT_WARN_USES_ECI, 100, 30, 0, 9 }, // ECI 9 == ISO 8859-7
/* 29*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 0, "β", ZINT_WARN_USES_ECI, 100, 30, 0, 9 }, // ECI 9 == ISO 8859-7
/* 30*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 0, "Aก", ZINT_WARN_USES_ECI, 100, 30, 0, 13 }, // ECI 13 == ISO 8859-11
/* 31*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 0, "", ZINT_WARN_USES_ECI, 100, 30, 0, 13 }, // ECI 13 == ISO 8859-11
/* 32*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 0, "Aéβ", ZINT_WARN_USES_ECI, 100, 30, 0, 26 },
/* 33*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 0, "Aéβก", ZINT_WARN_USES_ECI, 100, 30, 0, 26 },
/* 34*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 3, "", 0, 100, 30, 0, 3 },
/* 35*/ { BARCODE_AZTEC, UNICODE_MODE, 0, "", 0, 100, 30, 0, 0 },
/* 36*/ { BARCODE_AZTEC, UNICODE_MODE, 0, "", ZINT_WARN_USES_ECI, 100, 30, 0, 9 }, // ECI 9 == ISO 8859-7
/* 37*/ { BARCODE_AZTEC, UNICODE_MODE, 0, "β", ZINT_WARN_USES_ECI, 100, 30, 0, 9 }, // ECI 9 == ISO 8859-7
/* 38*/ { BARCODE_AZTEC, UNICODE_MODE, 0, "Aก", ZINT_WARN_USES_ECI, 100, 30, 0, 13 }, // ECI 13 == ISO 8859-11
/* 39*/ { BARCODE_AZTEC, UNICODE_MODE, 0, "", ZINT_WARN_USES_ECI, 100, 30, 0, 13 }, // ECI 13 == ISO 8859-11
/* 40*/ { BARCODE_AZTEC, UNICODE_MODE, 0, "Aéβ", ZINT_WARN_USES_ECI, 100, 30, 0, 26 },
/* 41*/ { BARCODE_AZTEC, UNICODE_MODE, 0, "Aéβก", ZINT_WARN_USES_ECI, 100, 30, 0, 26 },
/* 42*/ { BARCODE_AZTEC, UNICODE_MODE, 3, "", 0, 100, 30, 0, 3 },
/* 43*/ { BARCODE_MAXICODE, UNICODE_MODE, 0, "", 0, 100, 30, 0, 0 },
/* 44*/ { BARCODE_MAXICODE, UNICODE_MODE, 0, "", ZINT_WARN_USES_ECI, 100, 30, 0, 9 }, // ECI 9 == ISO 8859-7
/* 45*/ { BARCODE_MAXICODE, UNICODE_MODE, 0, "β", ZINT_WARN_USES_ECI, 100, 30, 0, 9 }, // ECI 9 == ISO 8859-7
/* 46*/ { BARCODE_MAXICODE, UNICODE_MODE, 0, "Aก", ZINT_WARN_USES_ECI, 100, 30, 0, 13 }, // ECI 13 == ISO 8859-11
/* 47*/ { BARCODE_MAXICODE, UNICODE_MODE, 0, "", ZINT_WARN_USES_ECI, 100, 30, 0, 13 }, // ECI 13 == ISO 8859-11
/* 48*/ { BARCODE_MAXICODE, UNICODE_MODE, 0, "Aéβ", ZINT_WARN_USES_ECI, 100, 30, 0, 26 },
/* 49*/ { BARCODE_MAXICODE, UNICODE_MODE, 0, "Aéβก", ZINT_WARN_USES_ECI, 100, 30, 0, 26 },
/* 50*/ { BARCODE_MAXICODE, UNICODE_MODE, 3, "", 0, 100, 30, 0, 3 },
/* 51*/ { BARCODE_MICROPDF417, UNICODE_MODE, 0, "", 0, 100, 30, 0, 0 },
/* 52*/ { BARCODE_MICROPDF417, UNICODE_MODE, 0, "", ZINT_WARN_USES_ECI, 100, 30, 0, 9 }, // ECI 9 == ISO 8859-7
/* 53*/ { BARCODE_MICROPDF417, UNICODE_MODE, 0, "β", ZINT_WARN_USES_ECI, 100, 30, 0, 9 }, // ECI 9 == ISO 8859-7
/* 54*/ { BARCODE_MICROPDF417, UNICODE_MODE, 0, "Aก", ZINT_WARN_USES_ECI, 100, 30, 0, 13 }, // ECI 13 == ISO 8859-11
/* 55*/ { BARCODE_MICROPDF417, UNICODE_MODE, 0, "", ZINT_WARN_USES_ECI, 100, 30, 0, 13 }, // ECI 13 == ISO 8859-11
/* 56*/ { BARCODE_MICROPDF417, UNICODE_MODE, 0, "Aéβ", ZINT_WARN_USES_ECI, 100, 30, 0, 26 },
/* 57*/ { BARCODE_MICROPDF417, UNICODE_MODE, 0, "Aéβก", ZINT_WARN_USES_ECI, 100, 30, 0, 26 },
/* 58*/ { BARCODE_MICROPDF417, UNICODE_MODE, 3, "", 0, 100, 30, 0, 3 },
/* 59*/ { BARCODE_PDF417, UNICODE_MODE, 0, "", 0, 100, 30, 0, 0 },
/* 60*/ { BARCODE_PDF417, UNICODE_MODE, 0, "", ZINT_WARN_USES_ECI, 100, 30, 0, 9 }, // ECI 9 == ISO 8859-7
/* 61*/ { BARCODE_PDF417, UNICODE_MODE, 0, "β", ZINT_WARN_USES_ECI, 100, 30, 0, 9 }, // ECI 9 == ISO 8859-7
/* 62*/ { BARCODE_PDF417, UNICODE_MODE, 0, "Aก", ZINT_WARN_USES_ECI, 100, 30, 0, 13 }, // ECI 13 == ISO 8859-11
/* 63*/ { BARCODE_PDF417, UNICODE_MODE, 0, "", ZINT_WARN_USES_ECI, 100, 30, 0, 13 }, // ECI 13 == ISO 8859-11
/* 64*/ { BARCODE_PDF417, UNICODE_MODE, 0, "Aéβ", ZINT_WARN_USES_ECI, 100, 30, 0, 26 },
/* 65*/ { BARCODE_PDF417, UNICODE_MODE, 0, "Aéβก", ZINT_WARN_USES_ECI, 100, 30, 0, 26 },
/* 66*/ { BARCODE_PDF417, UNICODE_MODE, 3, "", 0, 100, 30, 0, 3 },
/* 67*/ { BARCODE_PDF417TRUNC, UNICODE_MODE, 0, "", 0, 100, 30, 0, 0 },
/* 68*/ { BARCODE_PDF417TRUNC, UNICODE_MODE, 0, "", ZINT_WARN_USES_ECI, 100, 30, 0, 9 }, // ECI 9 == ISO 8859-7
/* 69*/ { BARCODE_PDF417TRUNC, UNICODE_MODE, 0, "β", ZINT_WARN_USES_ECI, 100, 30, 0, 9 }, // ECI 9 == ISO 8859-7
/* 70*/ { BARCODE_PDF417TRUNC, UNICODE_MODE, 0, "Aก", ZINT_WARN_USES_ECI, 100, 30, 0, 13 }, // ECI 13 == ISO 8859-11
/* 71*/ { BARCODE_PDF417TRUNC, UNICODE_MODE, 0, "", ZINT_WARN_USES_ECI, 100, 30, 0, 13 }, // ECI 13 == ISO 8859-11
/* 72*/ { BARCODE_PDF417TRUNC, UNICODE_MODE, 0, "Aéβ", ZINT_WARN_USES_ECI, 100, 30, 0, 26 },
/* 73*/ { BARCODE_PDF417TRUNC, UNICODE_MODE, 0, "Aéβก", ZINT_WARN_USES_ECI, 100, 30, 0, 26 },
/* 74*/ { BARCODE_PDF417TRUNC, UNICODE_MODE, 3, "", 0, 100, 30, 0, 3 },
/* 75*/ { BARCODE_DOTCODE, UNICODE_MODE, 0, "", 0, 100, 30, 0, 0 },
/* 76*/ { BARCODE_DOTCODE, UNICODE_MODE, 0, "", ZINT_WARN_USES_ECI, 100, 30, 0, 9 }, // ECI 9 == ISO 8859-7
/* 77*/ { BARCODE_DOTCODE, UNICODE_MODE, 0, "β", ZINT_WARN_USES_ECI, 100, 30, 0, 9 }, // ECI 9 == ISO 8859-7
/* 78*/ { BARCODE_DOTCODE, UNICODE_MODE, 0, "Aก", ZINT_WARN_USES_ECI, 100, 30, 0, 13 }, // ECI 13 == ISO 8859-11
/* 79*/ { BARCODE_DOTCODE, UNICODE_MODE, 0, "", ZINT_WARN_USES_ECI, 100, 30, 0, 13 }, // ECI 13 == ISO 8859-11
/* 80*/ { BARCODE_DOTCODE, UNICODE_MODE, 0, "Aéβ", ZINT_WARN_USES_ECI, 100, 30, 0, 26 },
/* 81*/ { BARCODE_DOTCODE, UNICODE_MODE, 0, "Aéβก", ZINT_WARN_USES_ECI, 100, 30, 0, 26 },
/* 82*/ { BARCODE_DOTCODE, UNICODE_MODE, 3, "", 0, 100, 30, 0, 3 },
/* 83*/ { BARCODE_CODE11, UNICODE_MODE, 0, "", ZINT_ERROR_INVALID_DATA, 100, 30, -1, -1 },
/* 84*/ { BARCODE_CODE39, UNICODE_MODE, 0, "", ZINT_ERROR_INVALID_DATA, 100, 30, -1, -1 },
/* 85*/ { BARCODE_EXCODE39, UNICODE_MODE, 0, "", ZINT_ERROR_INVALID_DATA, 100, 30, -1, -1 },
/* 86*/ { BARCODE_CODE128, UNICODE_MODE, 0, "", 0, 100, 30, 0, 0 },
/* 87*/ { BARCODE_CODE128, UNICODE_MODE, 0, "", ZINT_ERROR_INVALID_DATA, 100, 30, -1, -1 },
};
int data_size = sizeof(data) / sizeof(struct item);
@ -162,17 +225,18 @@ static void test_encode(void)
symbol->symbology = data[i].symbology;
symbol->input_mode = data[i].input_mode;
symbol->eci = data[i].eci;
int length = strlen(data[i].data);
ret = ZBarcode_Encode(symbol, data[i].data, length);
assert_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret_encode);
if (data[i].ret_render != -1) {
if (data[i].ret_vector != -1) {
assert_equal(symbol->eci, data[i].expected_eci, "i:%d eci %d != %d\n", i, symbol->eci, data[i].expected_eci);
ret = ZBarcode_Render( symbol, data[i].w, data[i].h );
assert_equal(ret, data[i].ret_render, "i:%d ZBarcode_Render ret %d != %d\n", i, ret, data[i].ret_render);
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);
@ -185,7 +249,7 @@ int main()
{
test_bom();
test_iso_8859_16();
test_encode();
//test_encode(); // Disable for now due to ECI change
testReport();

View File

@ -40,8 +40,8 @@ static void test_csv(void)
{
testStart("");
FILE* fd = fopen("../data/uspsIMbEncoderTestCases.csv", "r");
assert_nonnull(fd, "open ../data/uspsIMbEncoderTestCases.csv");
FILE* fd = fopen("../data/imail/usps/uspsIMbEncoderTestCases.csv", "r");
assert_nonnull(fd, "open ../data/imail/usps/uspsIMbEncoderTestCases.csv");
char buffer[1024];
char id[10];

View File

@ -30,7 +30,7 @@
#include "testcommon.h"
static void test_encode_render(void)
static void test_encode_vector(void)
{
testStart("");
@ -40,16 +40,17 @@ static void test_encode_render(void)
int ret_encode;
float w;
float h;
int ret_render;
int ret_vector;
unsigned char* expected_daft;
};
// Vi} :s/\/\*[ 0-9]*\*\//\=printf("\/*%2d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { "0100000000000AA000AA0A", 0, 100, 30, 1, "TFATTADAAATAFAFADFTAFATDTTDTTAAFTTFFTTDFTTFFTTAFADFDFAAFTDDFDADDAA" },
/* 1*/ { "0100000000009JA500AA0A", 0, 100, 30, 1, "TAFTTDADATTFDTFDFDFDTAATADADTTTATTFTDDDDTATDATDFTFFATAFFAFADAFFTDT" },
/* 2*/ { "1100000000000XY11 ", 0, 100, 30, 1, "TTDTTATTDTAATTDTAATTDTAATTDTTDDAATAADDATAATDDFAFTDDTAADDDTAAFDFAFF" },
/* 3*/ { "21B2254800659JW5O9QA6Y", 0, 100, 30, 1, "DAATATTTADTAATTFADDDDTTFTFDDDDFFDFDAFTADDTFFTDDATADTTFATTDAFDTFDDA" },
/* 4*/ { "11000000000000000XY11 ", 0, 100, 30, 1, "TTDTTATDDTTATTDTAATTDTAATDDTTATTDTTDATFTAATDDTAATDDTATATFAADDAATAATDDTAADFTFTA" },
/* 5*/ { "41038422416563762EF61AH8T", 0, 100, 30, 1, "DTTFATTDDTATTTATFTDFFFTFDFDAFTTTADTTFDTFDDDTDFDDFTFAADTFDTDTDTFAATAFDDTAATTDTT" },
/* 0*/ { "0100000000000AA000AA0A", 0, 100, 30, 0, "TFATTADAAATAFAFADFTAFATDTTDTTAAFTTFFTTDFTTFFTTAFADFDFAAFTDDFDADDAA" },
/* 1*/ { "0100000000009JA500AA0A", 0, 100, 30, 0, "TAFTTDADATTFDTFDFDFDTAATADADTTTATTFTDDDDTATDATDFTFFATAFFAFADAFFTDT" },
/* 2*/ { "1100000000000XY11 ", 0, 100, 30, 0, "TTDTTATTDTAATTDTAATTDTAATTDTTDDAATAADDATAATDDFAFTDDTAADDDTAAFDFAFF" },
/* 3*/ { "21B2254800659JW5O9QA6Y", 0, 100, 30, 0, "DAATATTTADTAATTFADDDDTTFTFDDDDFFDFDAFTADDTFFTDDATADTTFATTDAFDTFDDA" },
/* 4*/ { "11000000000000000XY11 ", 0, 100, 30, 0, "TTDTTATDDTTATTDTAATTDTAATDDTTATTDTTDATFTAATDDTAATDDTATATFAADDAATAATDDTAADFTFTA" },
/* 5*/ { "41038422416563762EF61AH8T", 0, 100, 30, 0, "DTTFATTDDTATTTATFTDFFFTFDFDAFTTTADTTFDTFDDDTDFDDFTFAADTFDTDTDTFAATAFDDTAATTDTT" },
};
int data_size = sizeof(data) / sizeof(struct item);
@ -72,8 +73,8 @@ static void test_encode_render(void)
assert_nonzero(ret, "i:%d testUtilDAFTConvert ret == 0", i);
assert_zero(strcmp(actual_daft, data[i].expected_daft), "i:%d\n actual %s\nexpected %s\n", i, actual_daft, data[i].expected_daft);
ret = ZBarcode_Render( symbol, data[i].w, data[i].h );
assert_equal(ret, data[i].ret_render, "i:%d ZBarcode_Render ret %d != %d\n", i, ret, data[i].ret_render);
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);
}
@ -83,7 +84,7 @@ static void test_encode_render(void)
int main()
{
test_encode_render();
test_encode_vector();
testReport();

View File

@ -46,14 +46,15 @@ static void test_best_supported_set(void)
int ret;
float w;
float h;
int ret_render;
int ret_vector;
int expected_rows;
int expected_width;
char* comment;
unsigned char* expected;
};
struct item data[] = {
/* 0*/ { BARCODE_MAXICODE, "am.//ab,\x1CTA# z\r!", 0, 100, 100, 1, 33, 30, // TODO: Better data and verify expected
/* 0*/ { BARCODE_MAXICODE, "am.//ab,\034TA# z\015!", 0, 100, 100, 0, 33, 30, "TODO: Better data and verify expected",
"111010000101111000111101010111"
"111110000000010100111000000000"
"110000101100110100111010101011"
@ -91,6 +92,8 @@ static void test_best_supported_set(void)
};
int data_size = sizeof(data) / sizeof(struct item);
char escaped_data[1024];
for (int i = 0; i < data_size; i++) {
struct zint_symbol* symbol = ZBarcode_Create();
@ -100,14 +103,14 @@ static void test_best_supported_set(void)
int length = strlen(data[i].data);
ret = ZBarcode_Encode(symbol, data[i].data, length);
assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret);
ret = ZBarcode_Render( symbol, data[i].w, data[i].h );
assert_equal(ret, data[i].ret_render, "i:%d ZBarcode_Render ret %d != %d\n", i, ret, data[i].ret_render);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret);
#ifdef TEST_GENERATE_EXPECTED
printf("symbology %d, data %s, length %d, rows %d, width %d\n", symbol->symbology, data[i].data, length, symbol->rows, symbol->width);
testUtilModulesDump(symbol);
printf(" /*%2d*/ { %s, \"%s\", %d, %.0f, %.0f, %d, %d, %d, \"%s\",\n",
i, testUtilBarcodeName(data[i].symbology), testUtilEscape(data[i].data, escaped_data, sizeof(escaped_data)), ret,
data[i].w, data[i].h, data[i].ret_vector, symbol->rows, symbol->width, data[i].comment);
testUtilModulesDump(symbol, " ", "\n");
printf(" },\n");
#else
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
@ -116,6 +119,9 @@ static void test_best_supported_set(void)
int width, row;
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d\n", i, ret, width, row);
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);
#endif
ZBarcode_Delete(symbol);

View File

@ -0,0 +1,87 @@
/*
libzint - the open source barcode library
Copyright (C) 2008-2019 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#include "testcommon.h"
static void test_koreapost(void)
{
testStart("");
int ret;
struct item {
unsigned char* data;
int ret_encode;
float w;
float h;
int ret_vector;
int expected_height;
int expected_rows;
int expected_width;
};
struct item data[] = {
/* 0*/ { "123456", 0, 100, 30, 0, 50, 1, 167 },
};
int data_size = sizeof(data) / sizeof(struct item);
for (int i = 0; i < data_size; i++) {
struct zint_symbol* symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
symbol->symbology = BARCODE_KOREAPOST;
int length = strlen(data[i].data);
ret = ZBarcode_Encode(symbol, data[i].data, length);
assert_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret_encode);
if (data[i].ret_vector != -1) {
assert_equal(symbol->height, data[i].expected_height, "i:%d symbol->height %d != %d\n", i, symbol->height, data[i].expected_height);
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
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);
}
testFinish();
}
int main()
{
test_koreapost();
testReport();
return 0;
}

View File

@ -42,25 +42,26 @@ static void test_microqr_options(void)
int ret_encode;
float w;
float h;
int ret_render;
int ret_vector;
int expected_size;
};
// Vi} :s/\/\*[ 0-9]*\*\//\=printf("\/*%2d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { "12345", 0, 0, 0, 100, 100, 1, 11 },
/* 1*/ { "12345", 1, 0, 0, 100, 100, 1, 11 },
/* 2*/ { "12345", 2, 0, 0, 100, 100, 1, 13 },
/* 3*/ { "12345", 3, 0, 0, 100, 100, 1, 17 },
/* 0*/ { "12345", 0, 0, 0, 100, 100, 0, 11 },
/* 1*/ { "12345", 1, 0, 0, 100, 100, 0, 11 },
/* 2*/ { "12345", 2, 0, 0, 100, 100, 0, 13 },
/* 3*/ { "12345", 3, 0, 0, 100, 100, 0, 17 },
/* 4*/ { "12345", 4, 0, ZINT_ERROR_INVALID_OPTION, 100, 100, -1, 0 },
/* 5*/ { "12345", 0, 1, 0, 100, 100, 1, 11 },
/* 6*/ { "12345", 0, 2, 0, 100, 100, 1, 13 },
/* 7*/ { "12345", 0, 3, 0, 100, 100, 1, 15 },
/* 8*/ { "12345", 0, 4, 0, 100, 100, 1, 17 },
/* 9*/ { "12345", 0, 5, 0, 100, 100, 1, 11 }, // Size > 4 ignored
/*10*/ { "12345", 1, 5, 0, 100, 100, 1, 11 }, // Ignored also if ECC given
/*11*/ { "12345", 1, 1, 0, 100, 100, 1, 11 },
/*12*/ { "12345", 1, 2, 0, 100, 100, 1, 13 },
/*13*/ { "12345", 1, 3, 0, 100, 100, 1, 15 },
/*14*/ { "12345", 1, 4, 0, 100, 100, 1, 17 },
/* 5*/ { "12345", 0, 1, 0, 100, 100, 0, 11 },
/* 6*/ { "12345", 0, 2, 0, 100, 100, 0, 13 },
/* 7*/ { "12345", 0, 3, 0, 100, 100, 0, 15 },
/* 8*/ { "12345", 0, 4, 0, 100, 100, 0, 17 },
/* 9*/ { "12345", 0, 5, 0, 100, 100, 0, 11 }, // Size > 4 ignored
/*10*/ { "12345", 1, 5, 0, 100, 100, 0, 11 }, // Ignored also if ECC given
/*11*/ { "12345", 1, 1, 0, 100, 100, 0, 11 },
/*12*/ { "12345", 1, 2, 0, 100, 100, 0, 13 },
/*13*/ { "12345", 1, 3, 0, 100, 100, 0, 15 },
/*14*/ { "12345", 1, 4, 0, 100, 100, 0, 17 },
/*15*/ { "12345", 2, 1, ZINT_ERROR_INVALID_OPTION, 100, 100, -1, 0 },
/*16*/ { "12345", 2, 2, 0, 100, 100, -1, 13 },
/*17*/ { "12345", 2, 3, 0, 100, 100, -1, 15 },
@ -70,29 +71,25 @@ static void test_microqr_options(void)
/*21*/ { "12345", 3, 3, ZINT_ERROR_INVALID_OPTION, 100, 100, -1, 0 },
/*22*/ { "12345", 3, 4, 0, 100, 100, -1, 17 },
/*23*/ { "12345", 4, 4, ZINT_ERROR_INVALID_OPTION, 100, 100, -1, 0 },
/*24*/ { "12345", 5, 0, 0, 100, 100, 1, 11 }, // ECC > 4 ignored
/*25*/ { "12345", 5, 1, 0, 100, 100, 1, 11 }, // Ignored also if size given
/*26*/ { "123456", 1, 0, 0, 100, 100, 1, 13 },
/*24*/ { "12345", 5, 0, 0, 100, 100, 0, 11 }, // ECC > 4 ignored
/*25*/ { "12345", 5, 1, 0, 100, 100, 0, 11 }, // Ignored also if size given
/*26*/ { "123456", 1, 0, 0, 100, 100, 0, 13 },
/*27*/ { "123456", 1, 1, ZINT_ERROR_TOO_LONG, 100, 100, -1, 0 },
/*28*/ { "123456", 1, 2, 0, 100, 100, 1, 13 },
/*29*/ { "ABCDEF", 1, 0, 0, 100, 100, 1, 13 },
/*30*/ { "ABCDEF", 1, 2, 0, 100, 100, 1, 13 },
/*28*/ { "123456", 1, 2, 0, 100, 100, 0, 13 },
/*29*/ { "ABCDEF", 1, 0, 0, 100, 100, 0, 13 },
/*30*/ { "ABCDEF", 1, 2, 0, 100, 100, 0, 13 },
/*31*/ { "ABCDEF", 2, 2, ZINT_ERROR_TOO_LONG, 100, 100, -1, 0 },
/*32*/ { "ABCDE", 2, 0, 0, 100, 100, 1, 13 },
/*33*/ { "ABCDEABCDEABCD", 1, 0, 0, 100, 100, 1, 15 }, // 14 alphanumerics
/*34*/ { "ABCDEABCDEABCD", 1, 3, 0, 100, 100, 1, 15 },
/*32*/ { "ABCDE", 2, 0, 0, 100, 100, 0, 13 },
/*33*/ { "ABCDEABCDEABCD", 1, 0, 0, 100, 100, 0, 15 }, // 14 alphanumerics
/*34*/ { "ABCDEABCDEABCD", 1, 3, 0, 100, 100, 0, 15 },
/*35*/ { "ABCDEABCDEABCD", 2, 3, ZINT_ERROR_TOO_LONG, 100, 100, -1, 0 },
/*36*/ { "ABCDEABCDEA", 2, 3, 0, 100, 100, 1, 15 }, // 11 alphanumerics
/*37*/ { "ABCDEFGHIJABCDEFGHIJA", 1, 0, 0, 100, 100, 1, 17 }, // 21 alphanumerics
/*38*/ { "ABCDEFGHIJABCDEFGHIJA", 1, 4, 0, 100, 100, 1, 17 },
/*36*/ { "ABCDEABCDEA", 2, 3, 0, 100, 100, 0, 15 }, // 11 alphanumerics
/*37*/ { "ABCDEFGHIJABCDEFGHIJA", 1, 0, 0, 100, 100, 0, 17 }, // 21 alphanumerics
/*38*/ { "ABCDEFGHIJABCDEFGHIJA", 1, 4, 0, 100, 100, 0, 17 },
/*39*/ { "ABCDEFGHIJABCDEFGHIJA", 2, 4, ZINT_ERROR_TOO_LONG, 100, 100, -1, 0 },
/*40*/ { "ABCDEFGHIJABCDEFGH", 2, 4, 0, 100, 100, 1, 17 }, // 18 alphanumerics
/*40*/ { "ABCDEFGHIJABCDEFGH", 2, 4, 0, 100, 100, 0, 17 }, // 18 alphanumerics
/*41*/ { "ABCDEFGHIJABCDEFGH", 3, 4, ZINT_ERROR_TOO_LONG, 100, 100, -1, 0 },
/*42*/ { "ABCDEFGHIJABC", 3, 4, 0, 100, 100, 1, 17 }, // 13 alphanumerics
/*42*/ { "ABCDEFGHIJABC", 3, 4, 0, 100, 100, 0, 17 }, // 13 alphanumerics
};
int data_size = sizeof(data) / sizeof(struct item);
@ -109,9 +106,9 @@ static void test_microqr_options(void)
ret = ZBarcode_Encode(symbol, data[i].data, length);
assert_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret_encode);
if (data[i].ret_render != -1) {
ret = ZBarcode_Render( symbol, data[i].w, data[i].h );
assert_equal(ret, data[i].ret_render, "i:%d ZBarcode_Render ret %d != %d\n", i, ret, data[i].ret_render);
if (data[i].ret_vector != -1) {
ret = ZBarcode_Buffer_Vector(symbol, 0);
assert_equal(ret, data[i].ret_vector, "i:%d ZBarcode_Buffer_Vector ret %d != %d\n", i, ret, data[i].ret_vector);
assert_equal(symbol->width, data[i].expected_size, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_size);
assert_equal(symbol->rows, data[i].expected_size, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_size);
}

View File

@ -30,10 +30,11 @@
#include "testcommon.h"
//#define TEST_RSS_LINEAR_GENERATE_EXPECTED 1
//#define TEST_RSS_COMPOSITE_GENERATE_EXPECTED 1
extern int general_rules(char type[]);
static void test_linear(void)
//#define TEST_RSS_BINARY_DIV_MODULO_DIVISOR_GENERATE_EXPECTED 1
static void test_binary_div_modulo_divisor(void)
{
testStart("");
@ -44,24 +45,24 @@ static void test_linear(void)
int ret_encode;
float w;
float h;
int ret_render;
int ret_vector;
int expected_rows;
int expected_width;
unsigned char* expected;
};
struct item data[] = {
/* 0*/ { BARCODE_RSS14, "1234567890123", 0, 100, 30, 1, 1, 96, "010111010010000001001110000000010100001011111010110100011001100101111111110001011011000111000101" },
/* 1*/ { BARCODE_RSS14, "0000004537076", 0, 100, 30, 1, 1, 96, "010101001000000001000100000000010111111100101010111101111101010101111111110111010100100000000101" },
/* 2*/ { BARCODE_RSS14, "0000004537077", 0, 100, 30, 1, 1, 96, "010101001000000001000111000000010111111101001010101010110000000101111100000111011111111011010101" },
/* 3*/ { BARCODE_RSS14, "0000004537078", 0, 100, 30, 1, 1, 96, "010101001000000001000111000000010111111101001010101011010000000101111000000011011111111011010101" },
/* 4*/ { BARCODE_RSS14, "0000000001596", 0, 100, 30, 1, 1, 96, "010101001000000001001111100000010111111100101010111101111101010101111100000111011111111011010101" },
/* 5*/ { BARCODE_RSS14, "0000000001597", 0, 100, 30, 1, 1, 96, "010101001000000001011111000000010111111100101010101010110000000101111100000111011111110111010101" },
/* 6*/ { BARCODE_RSS14, "0000000001598", 0, 100, 30, 1, 1, 96, "010101001000000001011111000000010111111100101010101011010000000101111000000011011111110111010101" },
/* 7*/ { BARCODE_RSS_LTD, "1234567890123", 0, 100, 30, 1, 1, 74, "01001100111100101000100111010110101011001001010010101001010000011100011101" },
/* 8*/ { BARCODE_RSS_LTD, "0000002013570", 0, 100, 30, 1, 1, 74, "01010101010100000010000001110100101101011001010111111110111111010101010101" },
/* 9*/ { BARCODE_RSS_LTD, "0000002013571", 0, 100, 30, 1, 1, 74, "01010101010100000011000000110101011010100011010101010101000000100000011101" },
/*10*/ { BARCODE_RSS_LTD, "0000002013572", 0, 100, 30, 1, 1, 74, "01010101010100000011000000110101010010111001010101010101000000110000001101" },
/* 0*/ { BARCODE_RSS14, "1234567890123", 0, 100, 30, 0, 1, 96, "010111010010000001001110000000010100001011111010110100011001100101111111110001011011000111000101" },
/* 1*/ { BARCODE_RSS14, "0000004537076", 0, 100, 30, 0, 1, 96, "010101001000000001000100000000010111111100101010111101111101010101111111110111010100100000000101" },
/* 2*/ { BARCODE_RSS14, "0000004537077", 0, 100, 30, 0, 1, 96, "010101001000000001000111000000010111111101001010101010110000000101111100000111011111111011010101" },
/* 3*/ { BARCODE_RSS14, "0000004537078", 0, 100, 30, 0, 1, 96, "010101001000000001000111000000010111111101001010101011010000000101111000000011011111111011010101" },
/* 4*/ { BARCODE_RSS14, "0000000001596", 0, 100, 30, 0, 1, 96, "010101001000000001001111100000010111111100101010111101111101010101111100000111011111111011010101" },
/* 5*/ { BARCODE_RSS14, "0000000001597", 0, 100, 30, 0, 1, 96, "010101001000000001011111000000010111111100101010101010110000000101111100000111011111110111010101" },
/* 6*/ { BARCODE_RSS14, "0000000001598", 0, 100, 30, 0, 1, 96, "010101001000000001011111000000010111111100101010101011010000000101111000000011011111110111010101" },
/* 7*/ { BARCODE_RSS_LTD, "1234567890123", 0, 100, 30, 0, 1, 74, "01001100111100101000100111010110101011001001010010101001010000011100011101" },
/* 8*/ { BARCODE_RSS_LTD, "0000002013570", 0, 100, 30, 0, 1, 74, "01010101010100000010000001110100101101011001010111111110111111010101010101" },
/* 9*/ { BARCODE_RSS_LTD, "0000002013571", 0, 100, 30, 0, 1, 74, "01010101010100000011000000110101011010100011010101010101000000100000011101" },
/*10*/ { BARCODE_RSS_LTD, "0000002013572", 0, 100, 30, 0, 1, 74, "01010101010100000011000000110101010010111001010101010101000000110000001101" },
};
int data_size = sizeof(data) / sizeof(struct item);
@ -76,12 +77,10 @@ static void test_linear(void)
ret = ZBarcode_Encode(symbol, 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);
ret = ZBarcode_Render( symbol, data[i].w, data[i].h );
assert_equal(ret, data[i].ret_render, "i:%d ZBarcode_Render ret %d != %d\n", i, ret, data[i].ret_render);
#ifdef TEST_RSS_LINEAR_GENERATE_EXPECTED
printf("symbology %d, data %s, length %d, rows %d, height %d\n", symbol->symbology, data[i].data, length, symbol->rows, symbol->height);
testUtilModulesDump(symbol);
#ifdef TEST_RSS_BINARY_DIV_MODULO_DIVISOR_GENERATE_EXPECTED
printf(" /*%2d*/ { %s, \"%s\", %d, %.0f, %.0f, %d, %d, %d, ",
i, testUtilBarcodeName(data[i].symbology), data[i].data, ret, data[i].w, data[i].h, data[i].ret_vector, symbol->rows, symbol->width);
testUtilModulesDump(symbol, "", " },\n");
#else
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
@ -90,72 +89,9 @@ static void test_linear(void)
int width, row;
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d\n", i, ret, width, row);
#endif
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_composite(void)
{
testStart("");
int ret;
struct item {
int symbology;
unsigned char* data;
unsigned char* composite;
int ret_encode;
float w;
float h;
int ret_render;
int expected_rows;
int expected_width;
unsigned char* expected;
};
struct item data[] = {
/* 0*/ { BARCODE_RSS14_CC, "0361234567890", "[11]990102", 0, 100, 30, 1, 5, 100, // TODO: verify expected
"1101101110111010001001110001100110010100000010011101001110100110011110011101110010010000110110001010"
"1101101100111000010011010001000010111110011010011001001011111001000111011111010001101110110010001010"
"1101101000110111110010010001011110100100000010011001101001111000110011011000010111111010111010001010"
"0000000000010110001110100000000101001011010111111011001101010000011010000000010100101000110011110000"
"0000010011101001110001001111111000010100101000000100110010101111100101111111100011010111001100001101"
},
};
int data_size = sizeof(data) / sizeof(struct item);
for (int i = 0; i < data_size; i++) {
struct zint_symbol* symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
symbol->symbology = data[i].symbology;
int length = strlen(data[i].data);
assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length);
strcpy(symbol->primary, data[i].data);
int composite_length = strlen(data[i].composite);
ret = ZBarcode_Encode(symbol, data[i].composite, composite_length);
assert_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret_encode);
ret = ZBarcode_Render( symbol, data[i].w, data[i].h );
assert_equal(ret, data[i].ret_render, "i:%d ZBarcode_Render ret %d != %d\n", i, ret, data[i].ret_render);
#ifdef TEST_RSS_COMPOSITE_GENERATE_EXPECTED
printf("symbology %d, data %s, length %d, rows %d, height %d\n", symbol->symbology, data[i].data, length, symbol->rows, symbol->height);
testUtilModulesDump(symbol);
#else
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
int width, row;
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d\n", i, ret, width, row);
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);
#endif
ZBarcode_Delete(symbol);
@ -166,8 +102,7 @@ static void test_composite(void)
int main()
{
test_linear();
test_composite();
test_binary_div_modulo_divisor();
testReport();

View File

@ -40,6 +40,7 @@ static void test_upce_length(void)
unsigned char* data;
int ret;
};
// Vi} :s/\/\*[ 0-9]*\*\//\=printf("\/*%2d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_UPCE, "12345", 0 },
/* 1*/ { BARCODE_UPCE_CHK, "12345", ZINT_ERROR_INVALID_CHECK },
@ -55,7 +56,6 @@ static void test_upce_length(void)
/*11*/ { BARCODE_UPCE_CHK, "12345670", 0 }, // 0 is correct check digit
/*12*/ { BARCODE_UPCE, "123456789", ZINT_ERROR_TOO_LONG },
/*13*/ { BARCODE_UPCE_CHK, "123456789", ZINT_ERROR_TOO_LONG },
/*14*/ { BARCODE_UPCE, "123406", ZINT_ERROR_INVALID_DATA }, // If last digit (emode) 6, 2nd last can't be zero
};
int data_size = sizeof(data) / sizeof(struct item);
@ -87,31 +87,32 @@ static void test_isbn(void)
int ret_encode;
float w;
float h;
int ret_render;
int ret_vector;
};
// Vi} :s/\/\*[ 0-9]*\*\//\=printf("\/*%2d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { "0", 0, 100, 30, 1 }, // Left zero-padded if < 10 chars
/* 0*/ { "0", 0, 100, 30, 0 }, // Left zero-padded if < 10 chars
/* 1*/ { "12345678", ZINT_ERROR_INVALID_CHECK, 100, 30, -1 },
/* 2*/ { "12345679", 0, 100, 30, 1 }, // 9 is correct check digit
/* 3*/ { "123456789", 0, 100, 30, 1 },
/* 4*/ { "0123456789", 0, 100, 30, 1 },
/* 2*/ { "12345679", 0, 100, 30, 0 }, // 9 is correct check digit
/* 3*/ { "123456789", 0, 100, 30, 0 },
/* 4*/ { "0123456789", 0, 100, 30, 0 },
/* 5*/ { "1234567890", ZINT_ERROR_INVALID_CHECK, 100, 30, -1 },
/* 6*/ { "123456789X", 0, 100, 30, 1 }, // X is correct check digit
/* 7*/ { "8175257660", 0, 100, 30, 1 }, // 0 is correct check digit
/* 8*/ { "0590764845", 0, 100, 30, 1 }, // 5 is correct check digit
/* 9*/ { "0906495741", 0, 100, 30, 1 }, // 1 is correct check digit
/*10*/ { "0140430016", 0, 100, 30, 1 }, // 6 is correct check digit
/*11*/ { "0571086187", 0, 100, 30, 1 }, // 7 is correct check digit
/*12*/ { "0486600882", 0, 100, 30, 1 }, // 2 is correct check digit
/* 6*/ { "123456789X", 0, 100, 30, 0 }, // X is correct check digit
/* 7*/ { "8175257660", 0, 100, 30, 0 }, // 0 is correct check digit
/* 8*/ { "0590764845", 0, 100, 30, 0 }, // 5 is correct check digit
/* 9*/ { "0906495741", 0, 100, 30, 0 }, // 1 is correct check digit
/*10*/ { "0140430016", 0, 100, 30, 0 }, // 6 is correct check digit
/*11*/ { "0571086187", 0, 100, 30, 0 }, // 7 is correct check digit
/*12*/ { "0486600882", 0, 100, 30, 0 }, // 2 is correct check digit
/*13*/ { "12345678901", ZINT_ERROR_TOO_LONG, 100, 30, -1 },
/*14*/ { "123456789012", ZINT_ERROR_TOO_LONG, 100, 30, -1 },
/*15*/ { "1234567890123", ZINT_ERROR_INVALID_DATA, 100, 30, -1 },
/*16*/ { "9784567890120", 0, 100, 30, 1 }, // 0 is correct check digit
/*17*/ { "9783161484100", 0, 100, 30, 1 }, // 0 is correct check digit
/*18*/ { "9781846688225", 0, 100, 30, 1 }, // 5 is correct check digit
/*19*/ { "9781847657954", 0, 100, 30, 1 }, // 4 is correct check digit
/*20*/ { "9781846688188", 0, 100, 30, 1 }, // 8 is correct check digit
/*21*/ { "9781847659293", 0, 100, 30, 1 }, // 3 is correct check digit
/*16*/ { "9784567890120", 0, 100, 30, 0 }, // 0 is correct check digit
/*17*/ { "9783161484100", 0, 100, 30, 0 }, // 0 is correct check digit
/*18*/ { "9781846688225", 0, 100, 30, 0 }, // 5 is correct check digit
/*19*/ { "9781847657954", 0, 100, 30, 0 }, // 4 is correct check digit
/*20*/ { "9781846688188", 0, 100, 30, 0 }, // 8 is correct check digit
/*21*/ { "9781847659293", 0, 100, 30, 0 }, // 3 is correct check digit
/*22*/ { "97845678901201", ZINT_ERROR_TOO_LONG, 100, 30, -1 },
};
int data_size = sizeof(data) / sizeof(struct item);
@ -127,9 +128,9 @@ static void test_isbn(void)
ret = ZBarcode_Encode(symbol, data[i].data, length);
assert_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d, errtxt %s\n", i, ret, data[i].ret_encode, symbol->errtxt);
if (data[i].ret_render != -1) {
ret = ZBarcode_Render( symbol, data[i].w, data[i].h );
assert_equal(ret, data[i].ret_render, "i:%d ZBarcode_Render ret %d != %d\n", i, ret, data[i].ret_render);
if (data[i].ret_vector != -1) {
ret = ZBarcode_Buffer_Vector(symbol, 0);
assert_equal(ret, data[i].ret_vector, "i:%d ZBarcode_Buffer_Vector ret %d != %d\n", i, ret, data[i].ret_vector);
}
ZBarcode_Delete(symbol);
@ -138,7 +139,7 @@ static void test_isbn(void)
testFinish();
}
static void test_render_same(void)
static void test_vector_same(void)
{
testStart("");
@ -149,21 +150,21 @@ static void test_render_same(void)
int ret_encode;
float w;
float h;
int ret_render;
int ret_vector;
};
struct item data[] = {
/* 0*/ { BARCODE_UPCE, "123456", 0, 100, 30, 1 },
/* 1*/ { BARCODE_UPCE_CHK, "1234565", 0, 100, 30, 1 }, // 5 is correct check digit
/* 1*/ { BARCODE_ISBNX, "0195049969", 0, 100, 30, 1 }, // 9 is correct check digit
/* 0*/ { BARCODE_UPCE, "123456", 0, 100, 30, 0 },
/* 1*/ { BARCODE_UPCE_CHK, "1234565", 0, 100, 30, 0 }, // 5 is correct check digit
/* 2*/ { BARCODE_ISBNX, "0195049969", 0, 100, 30, 0 }, // 9 is correct check digit
};
int data_size = sizeof(data) / sizeof(struct item);
for (int i = 0; i < data_size; i++) {
struct zint_render* renders[4];
int renders_size = sizeof(renders) / sizeof(struct zint_render*);
struct zint_vector* vectors[4];
int vectors_size = sizeof(vectors) / sizeof(struct zint_vector*);
for (int j = 0; j < renders_size; j++) {
for (int j = 0; j < vectors_size; j++) {
struct zint_symbol* symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
@ -173,24 +174,24 @@ static void test_render_same(void)
ret = ZBarcode_Encode(symbol, 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);
ret = ZBarcode_Render(symbol, data[i].w, data[i].h);
assert_equal(ret, data[i].ret_render, "i:%d ZBarcode_Render ret %d != %d\n", i, ret, data[i].ret_render);
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_nonnull(symbol->rendered, "i:%d symbol->rendered NULL\n", i);
renders[j] = testUtilRenderCpy(symbol->rendered);
assert_nonnull(symbol->vector, "i:%d symbol->vector NULL\n", i);
vectors[j] = testUtilVectorCpy(symbol->vector);
ZBarcode_Delete(symbol);
}
for (int j = 1; j < renders_size; j++) {
ret = testUtilRenderCmp(renders[j - 1], renders[j]);
assert_zero(ret, "i:%d testUtilRenderCmp ret %d != 0\n", i, ret);
for (int j = 1; j < vectors_size; j++) {
ret = testUtilVectorCmp(vectors[j - 1], vectors[j]);
assert_zero(ret, "i:%d testUtilVectorCmp ret %d != 0\n", i, ret);
}
for (int j = 0; j < renders_size; j++) {
struct zint_symbol symbol_render;
symbol_render.rendered = renders[j];
render_free(&symbol_render);
for (int j = 0; j < vectors_size; j++) {
struct zint_symbol symbol_vector;
symbol_vector.vector = vectors[j];
vector_free(&symbol_vector);
}
}
@ -201,7 +202,7 @@ int main()
{
test_upce_length();
test_isbn();
test_render_same();
test_vector_same();
testReport();

View File

@ -35,6 +35,11 @@
#include <stdio.h>
#include <string.h>
#include "testcommon.h"
#ifndef NO_PNG
#include <png.h>
#include <zlib.h>
#include <setjmp.h>
#endif
extern int module_is_set(const struct zint_symbol *symbol, const int y_coord, const int x_coord);
@ -95,6 +100,172 @@ void testReport()
}
}
char* testUtilBarcodeName(int symbology) {
struct item {
int define;
char* name;
int val;
};
struct item data[] = {
{ -1, "", 0 },
{ BARCODE_CODE11, "BARCODE_CODE11", 1 },
{ BARCODE_C25MATRIX, "BARCODE_C25MATRIX", 2 },
{ BARCODE_C25INTER, "BARCODE_C25INTER", 3 },
{ BARCODE_C25IATA, "BARCODE_C25IATA", 4 },
{ -1, "", 5 },
{ BARCODE_C25LOGIC, "BARCODE_C25LOGIC", 6 },
{ BARCODE_C25IND, "BARCODE_C25IND", 7 },
{ BARCODE_CODE39, "BARCODE_CODE39", 8 },
{ BARCODE_EXCODE39, "BARCODE_EXCODE39", 9 },
{ -1, "", 10 },
{ -1, "", 11 },
{ -1, "", 12 },
{ BARCODE_EANX, "BARCODE_EANX", 13 },
{ BARCODE_EANX_CHK, "BARCODE_EANX_CHK", 14 },
{ -1, "", 15 },
{ BARCODE_EAN128, "BARCODE_EAN128", 16 },
{ -1, "", 17 },
{ BARCODE_CODABAR, "BARCODE_CODABAR", 18 },
{ -1, "", 19 },
{ BARCODE_CODE128, "BARCODE_CODE128", 20 },
{ BARCODE_DPLEIT, "BARCODE_DPLEIT", 21 },
{ BARCODE_DPIDENT, "BARCODE_DPIDENT", 22 },
{ BARCODE_CODE16K, "BARCODE_CODE16K", 23 },
{ BARCODE_CODE49, "BARCODE_CODE49", 24 },
{ BARCODE_CODE93, "BARCODE_CODE93", 25 },
{ -1, "", 26 },
{ -1, "", 27 },
{ BARCODE_FLAT, "BARCODE_FLAT", 28 },
{ BARCODE_RSS14, "BARCODE_RSS14", 29 },
{ BARCODE_RSS_LTD, "BARCODE_RSS_LTD", 30 },
{ BARCODE_RSS_EXP, "BARCODE_RSS_EXP", 31 },
{ BARCODE_TELEPEN, "BARCODE_TELEPEN", 32 },
{ -1, "", 33 },
{ BARCODE_UPCA, "BARCODE_UPCA", 34 },
{ BARCODE_UPCA_CHK, "BARCODE_UPCA_CHK", 35 },
{ -1, "", 36 },
{ BARCODE_UPCE, "BARCODE_UPCE", 37 },
{ BARCODE_UPCE_CHK, "BARCODE_UPCE_CHK", 38 },
{ -1, "", 39 },
{ BARCODE_POSTNET, "BARCODE_POSTNET", 40 },
{ -1, "", 41 },
{ -1, "", 42 },
{ -1, "", 43 },
{ -1, "", 44 },
{ -1, "", 45 },
{ -1, "", 46 },
{ BARCODE_MSI_PLESSEY, "BARCODE_MSI_PLESSEY", 47 },
{ -1, "", 48 },
{ BARCODE_FIM, "BARCODE_FIM", 49 },
{ BARCODE_LOGMARS, "BARCODE_LOGMARS", 50 },
{ BARCODE_PHARMA, "BARCODE_PHARMA", 51 },
{ BARCODE_PZN, "BARCODE_PZN", 52 },
{ BARCODE_PHARMA_TWO, "BARCODE_PHARMA_TWO", 53 },
{ -1, "", 54 },
{ BARCODE_PDF417, "BARCODE_PDF417", 55 },
{ BARCODE_PDF417TRUNC, "BARCODE_PDF417TRUNC", 56 },
{ BARCODE_MAXICODE, "BARCODE_MAXICODE", 57 },
{ BARCODE_QRCODE, "BARCODE_QRCODE", 58 },
{ -1, "", 59 },
{ BARCODE_CODE128B, "BARCODE_CODE128B", 60 },
{ -1, "", 61 },
{ -1, "", 62 },
{ BARCODE_AUSPOST, "BARCODE_AUSPOST", 63 },
{ -1, "", 64 },
{ -1, "", 65 },
{ BARCODE_AUSREPLY, "BARCODE_AUSREPLY", 66 },
{ BARCODE_AUSROUTE, "BARCODE_AUSROUTE", 67 },
{ BARCODE_AUSREDIRECT, "BARCODE_AUSREDIRECT", 68 },
{ BARCODE_ISBNX, "BARCODE_ISBNX", 69 },
{ BARCODE_RM4SCC, "BARCODE_RM4SCC", 70 },
{ BARCODE_DATAMATRIX, "BARCODE_DATAMATRIX", 71 },
{ BARCODE_EAN14, "BARCODE_EAN14", 72 },
{ BARCODE_VIN, "BARCODE_VIN", 73 },
{ BARCODE_CODABLOCKF, "BARCODE_CODABLOCKF", 74 },
{ BARCODE_NVE18, "BARCODE_NVE18", 75 },
{ BARCODE_JAPANPOST, "BARCODE_JAPANPOST", 76 },
{ BARCODE_KOREAPOST, "BARCODE_KOREAPOST", 77 },
{ -1, "", 78 },
{ BARCODE_RSS14STACK, "BARCODE_RSS14STACK", 79 },
{ BARCODE_RSS14STACK_OMNI, "BARCODE_RSS14STACK_OMNI", 80 },
{ BARCODE_RSS_EXPSTACK, "BARCODE_RSS_EXPSTACK", 81 },
{ BARCODE_PLANET, "BARCODE_PLANET", 82 },
{ -1, "", 83 },
{ BARCODE_MICROPDF417, "BARCODE_MICROPDF417", 84 },
{ BARCODE_ONECODE, "BARCODE_ONECODE", 85 },
{ BARCODE_PLESSEY, "BARCODE_PLESSEY", 86 },
{ BARCODE_TELEPEN_NUM, "BARCODE_TELEPEN_NUM", 87 },
{ -1, "", 88 },
{ BARCODE_ITF14, "BARCODE_ITF14", 89 },
{ BARCODE_KIX, "BARCODE_KIX", 90 },
{ -1, "", 91 },
{ BARCODE_AZTEC, "BARCODE_AZTEC", 92 },
{ BARCODE_DAFT, "BARCODE_DAFT", 93 },
{ -1, "", 94 },
{ -1, "", 95 },
{ -1, "", 96 },
{ BARCODE_MICROQR, "BARCODE_MICROQR", 97 },
{ BARCODE_HIBC_128, "BARCODE_HIBC_128", 98 },
{ BARCODE_HIBC_39, "BARCODE_HIBC_39", 99 },
{ -1, "", 100 },
{ -1, "", 101 },
{ BARCODE_HIBC_DM, "BARCODE_HIBC_DM", 102 },
{ -1, "", 103 },
{ BARCODE_HIBC_QR, "BARCODE_HIBC_QR", 104 },
{ -1, "", 105 },
{ BARCODE_HIBC_PDF, "BARCODE_HIBC_PDF", 106 },
{ -1, "", 107 },
{ BARCODE_HIBC_MICPDF, "BARCODE_HIBC_MICPDF", 108 },
{ -1, "", 109 },
{ BARCODE_HIBC_BLOCKF, "BARCODE_HIBC_BLOCKF", 110 },
{ -1, "", 111 },
{ BARCODE_HIBC_AZTEC, "BARCODE_HIBC_AZTEC", 112 },
{ -1, "", 113 },
{ -1, "", 114 },
{ BARCODE_DOTCODE, "BARCODE_DOTCODE", 115 },
{ BARCODE_HANXIN, "BARCODE_HANXIN", 116 },
{ -1, "", 117 },
{ -1, "", 118 },
{ -1, "", 119 },
{ -1, "", 120 },
{ BARCODE_MAILMARK, "BARCODE_MAILMARK", 121 },
{ -1, "", 122 },
{ -1, "", 123 },
{ -1, "", 124 },
{ -1, "", 125 },
{ -1, "", 126 },
{ -1, "", 127 },
{ BARCODE_AZRUNE, "BARCODE_AZRUNE", 128 },
{ BARCODE_CODE32, "BARCODE_CODE32", 129 },
{ BARCODE_EANX_CC, "BARCODE_EANX_CC", 130 },
{ BARCODE_EAN128_CC, "BARCODE_EAN128_CC", 131 },
{ BARCODE_RSS14_CC, "BARCODE_RSS14_CC", 132 },
{ BARCODE_RSS_LTD_CC, "BARCODE_RSS_LTD_CC", 133 },
{ BARCODE_RSS_EXP_CC, "BARCODE_RSS_EXP_CC", 134 },
{ BARCODE_UPCA_CC, "BARCODE_UPCA_CC", 135 },
{ BARCODE_UPCE_CC, "BARCODE_UPCE_CC", 136 },
{ BARCODE_RSS14STACK_CC, "BARCODE_RSS14STACK_CC", 137 },
{ BARCODE_RSS14_OMNI_CC, "BARCODE_RSS14_OMNI_CC", 138 },
{ BARCODE_RSS_EXPSTACK_CC, "BARCODE_RSS_EXPSTACK_CC", 139 },
{ BARCODE_CHANNEL, "BARCODE_CHANNEL", 140 },
{ BARCODE_CODEONE, "BARCODE_CODEONE", 141 },
{ BARCODE_GRIDMATRIX, "BARCODE_GRIDMATRIX", 142 },
{ BARCODE_UPNQR, "BARCODE_UPNQR", 143 },
{ BARCODE_ULTRA, "BARCODE_ULTRA", 144 },
{ -1, "", 145 },
};
int data_size = sizeof(data) / sizeof(struct item);
if (symbology < 0 || symbology > data_size) {
return "";
}
if (data[symbology].val != symbology || (data[symbology].define != -1 && data[symbology].define != symbology)) { // Self-check
fprintf(stderr, "testUtilBarcodeName data table out of sync (%d)\n", symbology);
abort();
}
return data[symbology].name;
}
int testUtilDAFTConvert(const struct zint_symbol* symbol, char* buffer, int buffer_size)
{
buffer[0] = '\0';
@ -117,6 +288,27 @@ int testUtilDAFTConvert(const struct zint_symbol* symbol, char* buffer, int buff
return TRUE;
}
char* testUtilEscape(char* buffer, char* escaped, int escaped_size)
{
int i;
char* b = buffer;
for (i = 0; i < escaped_size && *b; b++) {
if (*b > '\0' && *b < ' ') {
if (i < escaped_size - 4) {
sprintf(escaped + i, "\\%.3o", *b);
}
i += 4;
} else {
escaped[i++] = *b;
}
}
if (i >= escaped_size) {
return NULL;
}
escaped[i] = '\0';
return escaped;
}
char* testUtilReadCSVField(char* buffer, char* field, int field_size)
{
int i;
@ -168,67 +360,67 @@ int testUtilSymbolCmp(const struct zint_symbol* a, const struct zint_symbol* b)
return 0;
}
struct zint_render* testUtilRenderCpy(const struct zint_render* in)
struct zint_vector* testUtilVectorCpy(const struct zint_vector* in)
{
struct zint_render* out = (struct zint_render*)malloc(sizeof(struct zint_render));
struct zint_vector* out = (struct zint_vector*)malloc(sizeof(struct zint_vector));
out->width = in->width;
out->height = in->height;
out->lines = NULL;
out->rectangles = NULL;
out->strings = NULL;
out->rings = NULL;
out->circles = NULL;
out->hexagons = NULL;
struct zint_render_line* line;
struct zint_render_string* string;
struct zint_render_ring* ring;
struct zint_render_hexagon* hexagon;
struct zint_vector_rect* rect;
struct zint_vector_string* string;
struct zint_vector_circle* circle;
struct zint_vector_hexagon* hexagon;
struct zint_render_line** outline;
struct zint_render_string** outstring;
struct zint_render_ring** outring;
struct zint_render_hexagon** outhexagon;
struct zint_vector_rect** outrect;
struct zint_vector_string** outstring;
struct zint_vector_circle** outcircle;
struct zint_vector_hexagon** outhexagon;
// Copy lines
line = in->lines;
outline = &(out->lines);
while (line) {
*outline = (struct zint_render_line*) malloc(sizeof(struct zint_render_line));
memcpy(*outline, line, sizeof(struct zint_render_line));
outline = &((*outline)->next);
line = line->next;
// Copy rectangles
rect = in->rectangles;
outrect = &(out->rectangles);
while (rect) {
*outrect = (struct zint_vector_rect*) malloc(sizeof(struct zint_vector_rect));
memcpy(*outrect, rect, sizeof(struct zint_vector_rect));
outrect = &((*outrect)->next);
rect = rect->next;
}
*outline = NULL;
*outrect = NULL;
// Copy Strings
string = in->strings;
outstring = &(out->strings);
while (string) {
*outstring = (struct zint_render_string*) malloc(sizeof(struct zint_render_string));
memcpy(*outstring, string, sizeof(struct zint_render_string));
(*outstring)->text = (unsigned char*) malloc(sizeof(unsigned char) * (strlen(string->text) + 1));
strcpy((*outstring)->text, string->text);
*outstring = (struct zint_vector_string*) malloc(sizeof(struct zint_vector_string));
memcpy(*outstring, string, sizeof(struct zint_vector_string));
(*outstring)->text = (unsigned char*) malloc(sizeof(unsigned char) * (ustrlen(string->text) + 1));
ustrcpy((*outstring)->text, string->text);
outstring = &((*outstring)->next);
string = string->next;
}
*outstring = NULL;
// Copy Rings
ring = in->rings;
outring = &(out->rings);
while (ring) {
*outring = (struct zint_render_ring*) malloc(sizeof(struct zint_render_ring));
memcpy(*outring, ring, sizeof(struct zint_render_ring));
outring = &((*outring)->next);
ring = ring->next;
// Copy Circles
circle = in->circles;
outcircle = &(out->circles);
while (circle) {
*outcircle = (struct zint_vector_circle*) malloc(sizeof(struct zint_vector_circle));
memcpy(*outcircle, circle, sizeof(struct zint_vector_circle));
outcircle = &((*outcircle)->next);
circle = circle->next;
}
*outstring = NULL;
*outcircle = NULL;
// Copy Hexagons
hexagon = in->hexagons;
outhexagon = &(out->hexagons);
while (hexagon) {
*outhexagon = (struct zint_render_hexagon*) malloc(sizeof(struct zint_render_hexagon));
memcpy(*outhexagon, hexagon, sizeof(struct zint_render_hexagon));
*outhexagon = (struct zint_vector_hexagon*) malloc(sizeof(struct zint_vector_hexagon));
memcpy(*outhexagon, hexagon, sizeof(struct zint_vector_hexagon));
outhexagon = &((*outhexagon)->next);
hexagon = hexagon->next;
}
@ -237,17 +429,17 @@ struct zint_render* testUtilRenderCpy(const struct zint_render* in)
return out;
}
int testUtilRenderCmp(const struct zint_render* a, const struct zint_render* b)
int testUtilVectorCmp(const struct zint_vector* a, const struct zint_vector* b)
{
struct zint_render_line* aline;
struct zint_render_string* astring;
struct zint_render_ring* aring;
struct zint_render_hexagon* ahexagon;
struct zint_vector_rect* arect;
struct zint_vector_string* astring;
struct zint_vector_circle* acircle;
struct zint_vector_hexagon* ahexagon;
struct zint_render_line* bline;
struct zint_render_string* bstring;
struct zint_render_ring* bring;
struct zint_render_hexagon* bhexagon;
struct zint_vector_rect* brect;
struct zint_vector_string* bstring;
struct zint_vector_circle* bcircle;
struct zint_vector_hexagon* bhexagon;
if (a->width != b->width) {
return 1;
@ -256,29 +448,32 @@ int testUtilRenderCmp(const struct zint_render* a, const struct zint_render* b)
return 2;
}
// Compare lines
aline = a->lines;
bline = b->lines;
while (aline) {
if (!bline) {
// Compare rectangles
arect = a->rectangles;
brect = b->rectangles;
while (arect) {
if (!brect) {
return 11;
}
if (aline->x != bline->x) {
if (arect->x != brect->x) {
return 12;
}
if (aline->y != bline->y) {
if (arect->y != brect->y) {
return 13;
}
if (aline->length != bline->length) {
if (arect->height != brect->height) {
return 14;
}
if (aline->width != bline->width) {
if (arect->width != brect->width) {
return 15;
}
aline = aline->next;
bline = bline->next;
if (arect->colour != brect->colour) {
return 16;
}
arect = arect->next;
brect = brect->next;
}
if (bline) {
if (brect) {
return 10;
}
@ -304,10 +499,10 @@ int testUtilRenderCmp(const struct zint_render* a, const struct zint_render* b)
if (astring->length != bstring->length) {
return 26;
}
if (strlen(astring->text) != strlen(bstring->text)) {
if (ustrlen(astring->text) != ustrlen(bstring->text)) {
return 27;
}
if (strcmp(astring->text, bstring->text) != 0) {
if (strcmp((const char*)astring->text, (const char*)bstring->text) != 0) {
return 28;
}
astring = astring->next;
@ -317,29 +512,29 @@ int testUtilRenderCmp(const struct zint_render* a, const struct zint_render* b)
return 20;
}
// Compare rings
aring = a->rings;
bring = b->rings;
while (aring) {
if (!bring) {
// Compare circles
acircle = a->circles;
bcircle = b->circles;
while (acircle) {
if (!bcircle) {
return 31;
}
if (aring->x != bring->x) {
if (acircle->x != bcircle->x) {
return 32;
}
if (aring->y != bring->y) {
if (acircle->y != bcircle->y) {
return 33;
}
if (aring->radius != bring->radius) {
if (acircle->diameter != bcircle->diameter) {
return 34;
}
if (aring->line_width != bring->line_width) {
if (acircle->colour != bcircle->colour) {
return 35;
}
aring = aring->next;
bring = bring->next;
acircle = acircle->next;
bcircle = bcircle->next;
}
if (bring) {
if (bcircle) {
return 30;
}
@ -356,7 +551,7 @@ int testUtilRenderCmp(const struct zint_render* a, const struct zint_render* b)
if (ahexagon->y != bhexagon->y) {
return 43;
}
if (ahexagon->height != bhexagon->height) {
if (ahexagon->diameter != bhexagon->diameter) {
return 44;
}
ahexagon = ahexagon->next;
@ -385,24 +580,29 @@ void testUtilLargeDump(const char* name, const short int reg[])
printf("%4x 0x%08x%08x%08x %s", words[3], words[2], words[1], words[0], name);
}
void testUtilModulesDump(const struct zint_symbol* symbol)
void testUtilModulesDump(const struct zint_symbol* symbol, char* prefix, char* postfix)
{
int r, w;
for (r = 0; r < symbol->rows; r++) {
if (*prefix) {
fputs(prefix, stdout);
}
putchar('"');
for (w = 0; w < symbol->width; w++) {
putchar(module_is_set(symbol, r, w) ? '1' : '0');
}
puts("\"");
putchar('"');
if (*postfix) {
fputs(postfix, stdout);
}
}
putchar('\n');
}
int testUtilModulesCmp(const struct zint_symbol* symbol, const char* expected, int* row, int* width)
{
const char* e = expected;
const char* ep = expected + strlen(expected);
int r, w;
int r, w = 0;
for (r = 0; r < symbol->rows && e < ep; r++) {
for (w = 0; w < symbol->width && e < ep; w++) {
if (module_is_set(symbol, r, w) != (*e == '1')) {
@ -417,3 +617,427 @@ int testUtilModulesCmp(const struct zint_symbol* symbol, const char* expected, i
*width = w;
return e != ep || r != symbol->rows || w != symbol->width ? 1 /*fail*/ : 0 /*success*/;
}
int testUtilModulesDumpHex(const struct zint_symbol* symbol, char dump[], int dump_size)
{
int i, r;
char hex[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8',
'9', 'A', 'B', 'C', 'D', 'E', 'F'};
int space = 0;
char* d = dump;
char* de = dump + dump_size;
for (r = 0; r < symbol->rows && d < de; r++) {
int byt = 0;
for (i = 0; i < symbol->width && d < de; i++) {
if (space == 2) {
*d++ = ' ';
space = 0;
}
byt = byt << 1;
if (module_is_set(symbol, r, i)) {
byt += 1;
}
if (d < de && ((i + 1) % 4) == 0) {
*d++ = hex[byt];
space++;
byt = 0;
}
}
if (d < de && (symbol->width % 4) != 0) {
byt = byt << (4 - (symbol->width % 4));
*d++ = hex[byt];
space++;
}
}
if (d == de) {
return -1;
}
*d = '\0';
return d - dump;
}
int testUtilExists(char* filename)
{
FILE* fp = fopen(filename, "r");
if (fp == NULL) {
return 0;
}
fclose(fp);
return 1;
}
int testUtilCmpPngs(char* png1, char* png2)
{
int ret = -1;
#ifndef NO_PNG
FILE* fp1;
FILE* fp2;
png_structp png_ptr1, png_ptr2;
png_infop info_ptr1, info_ptr2;
int width1, height1, width2, height2;
png_byte color_type1, color_type2;
png_byte bit_depth1, bit_depth2;
png_bytep row1 = NULL, row2 = NULL;
size_t rowbytes1, rowbytes2;
int r;
fp1 = fopen(png1, "rb");
if (!fp1) {
return 2;
}
fp2 = fopen(png2, "rb");
if (!fp2) {
fclose(fp1);
return 3;
}
png_ptr1 = png_create_read_struct(PNG_LIBPNG_VER_STRING, (png_voidp)NULL, NULL, NULL);
if (!png_ptr1) {
fclose(fp1);
fclose(fp2);
return 4;
}
info_ptr1 = png_create_info_struct(png_ptr1);
if (!info_ptr1) {
png_destroy_read_struct(&png_ptr1, (png_infopp)NULL, (png_infopp)NULL);
fclose(fp1);
fclose(fp2);
return 5;
}
png_ptr2 = png_create_read_struct(PNG_LIBPNG_VER_STRING, (png_voidp)NULL, NULL, NULL);
if (!png_ptr2) {
png_destroy_read_struct(&png_ptr1, &info_ptr1, (png_infopp)NULL);
fclose(fp1);
fclose(fp2);
return 6;
}
info_ptr2 = png_create_info_struct(png_ptr2);
if (!info_ptr2) {
png_destroy_read_struct(&png_ptr1, &info_ptr1, (png_infopp)NULL);
png_destroy_read_struct(&png_ptr2, (png_infopp)NULL, (png_infopp)NULL);
fclose(fp1);
fclose(fp2);
return 7;
}
if (setjmp(png_jmpbuf(png_ptr1))) {
if (row1) {
free(row1);
}
if (row2) {
free(row2);
}
png_destroy_read_struct(&png_ptr1, &info_ptr1, (png_infopp)NULL);
png_destroy_read_struct(&png_ptr2, &info_ptr2, (png_infopp)NULL);
fclose(fp1);
fclose(fp2);
return 8;
}
if (setjmp(png_jmpbuf(png_ptr2))) {
if (row1) {
free(row1);
}
if (row2) {
free(row2);
}
png_destroy_read_struct(&png_ptr1, &info_ptr1, (png_infopp)NULL);
png_destroy_read_struct(&png_ptr2, &info_ptr2, (png_infopp)NULL);
fclose(fp1);
fclose(fp2);
return 9;
}
png_init_io(png_ptr1, fp1);
png_init_io(png_ptr2, fp2);
png_read_info(png_ptr1, info_ptr1);
png_read_info(png_ptr2, info_ptr2);
width1 = png_get_image_width(png_ptr1, info_ptr1);
height1 = png_get_image_height(png_ptr1, info_ptr1);
width2 = png_get_image_width(png_ptr2, info_ptr2);
height2 = png_get_image_height(png_ptr2, info_ptr2);
if (width1 != width2 || height1 != height2) {
printf("width1 %d, width2 %d, height1 %d, height2 %d\n", width1, width2, height1, height2);
png_destroy_read_struct(&png_ptr1, &info_ptr1, (png_infopp)NULL);
png_destroy_read_struct(&png_ptr2, &info_ptr2, (png_infopp)NULL);
fclose(fp1);
fclose(fp2);
return 10;
}
color_type1 = png_get_color_type(png_ptr1, info_ptr1);
bit_depth1 = png_get_bit_depth(png_ptr1, info_ptr1);
if (bit_depth1 == 16) {
png_set_scale_16(png_ptr1);
}
if (color_type1 == PNG_COLOR_TYPE_PALETTE) {
png_set_palette_to_rgb(png_ptr1);
}
if (color_type1 == PNG_COLOR_TYPE_GRAY && bit_depth1 < 8) {
png_set_expand_gray_1_2_4_to_8(png_ptr1);
}
if (png_get_valid(png_ptr1, info_ptr1, PNG_INFO_tRNS)) {
png_set_tRNS_to_alpha(png_ptr1);
}
if (color_type1 == PNG_COLOR_TYPE_RGB || color_type1 == PNG_COLOR_TYPE_GRAY || color_type1 == PNG_COLOR_TYPE_PALETTE) {
png_set_filler(png_ptr1, 0xFF, PNG_FILLER_AFTER);
}
if (color_type1 == PNG_COLOR_TYPE_GRAY || color_type1 == PNG_COLOR_TYPE_GRAY_ALPHA) {
png_set_gray_to_rgb(png_ptr1);
}
color_type2 = png_get_color_type(png_ptr2, info_ptr2);
bit_depth2 = png_get_bit_depth(png_ptr2, info_ptr2);
if (bit_depth2 == 16) {
png_set_scale_16(png_ptr2);
}
if (color_type2 == PNG_COLOR_TYPE_PALETTE) {
png_set_palette_to_rgb(png_ptr2);
}
if (color_type2 == PNG_COLOR_TYPE_GRAY && bit_depth2 < 8) {
png_set_expand_gray_1_2_4_to_8(png_ptr2);
}
if (png_get_valid(png_ptr2, info_ptr2, PNG_INFO_tRNS)) {
png_set_tRNS_to_alpha(png_ptr2);
}
if (color_type2 == PNG_COLOR_TYPE_RGB || color_type2 == PNG_COLOR_TYPE_GRAY || color_type2 == PNG_COLOR_TYPE_PALETTE) {
png_set_filler(png_ptr2, 0xFF, PNG_FILLER_AFTER);
}
if (color_type2 == PNG_COLOR_TYPE_GRAY || color_type2 == PNG_COLOR_TYPE_GRAY_ALPHA) {
png_set_gray_to_rgb(png_ptr2);
}
png_read_update_info(png_ptr1, info_ptr1);
png_read_update_info(png_ptr2, info_ptr2);
rowbytes1 = png_get_rowbytes(png_ptr1, info_ptr1);
rowbytes2 = png_get_rowbytes(png_ptr2, info_ptr2);
if (rowbytes1 != rowbytes2) {
png_destroy_read_struct(&png_ptr1, &info_ptr1, (png_infopp)NULL);
png_destroy_read_struct(&png_ptr2, &info_ptr2, (png_infopp)NULL);
fclose(fp1);
fclose(fp2);
return 11;
}
row1 = (png_byte*)malloc(rowbytes1);
if (!row1) {
png_destroy_read_struct(&png_ptr1, &info_ptr1, (png_infopp)NULL);
png_destroy_read_struct(&png_ptr2, &info_ptr2, (png_infopp)NULL);
fclose(fp1);
fclose(fp2);
return 12;
}
row2 = (png_byte*)malloc(rowbytes2);
if (!row2) {
free(row1);
png_destroy_read_struct(&png_ptr1, &info_ptr1, (png_infopp)NULL);
png_destroy_read_struct(&png_ptr2, &info_ptr2, (png_infopp)NULL);
fclose(fp1);
fclose(fp2);
return 13;
}
for (r = 0; r < height1; r++) {
png_read_row(png_ptr1, row1, NULL);
png_read_row(png_ptr2, row2, NULL);
if (memcmp(row1, row2, rowbytes1) != 0) {
break;
}
}
ret = r == height1 ? 0 : 20;
free(row1);
free(row2);
png_destroy_read_struct(&png_ptr1, &info_ptr1, (png_infopp)NULL);
png_destroy_read_struct(&png_ptr2, &info_ptr2, (png_infopp)NULL);
fclose(fp1);
fclose(fp2);
#endif
return ret;
}
static int testUtilCmpTxts(char* txt1, char* txt2)
{
int ret = -1;
FILE* fp1;
FILE* fp2;
char buf1[1024];
char buf2[1024];
size_t len1 = 0, len2 = 0;
fp1 = fopen(txt1, "r");
if (!fp1) {
return 2;
}
fp2 = fopen(txt2, "r");
if (!fp2) {
fclose(fp1);
return 3;
}
while (1) {
if (fgets(buf1, sizeof(buf1), fp1) == NULL) {
if (fgets(buf2, sizeof(buf2), fp2) != NULL) {
ret = 4;
break;
}
break;
}
if (fgets(buf2, sizeof(buf2), fp2) == NULL) {
ret = 5;
break;
}
len1 = strlen(buf1);
len2 = strlen(buf2);
if (len1 != len2) {
ret = 6;
break;
}
if (strcmp(buf1, buf2) != 0) {
ret = 7;
break;
}
}
if (ret == -1) {
ret = feof(fp1) && feof(fp2) ? 0 : 20;
}
fclose(fp1);
fclose(fp2);
return ret;
}
static int testUtilCmpBins(char* bin1, char* bin2)
{
int ret = -1;
FILE* fp1;
FILE* fp2;
char buf1[1024];
char buf2[1024];
size_t len1 = 0, len2 = 0;
fp1 = fopen(bin1, "rb");
if (!fp1) {
return 2;
}
fp2 = fopen(bin2, "rb");
if (!fp2) {
fclose(fp1);
return 3;
}
do {
len1 = fread(buf1, 1, sizeof(buf1), fp1);
len2 = fread(buf2, 1, sizeof(buf2), fp2);
if (len1 != len2) {
ret = 6;
break;
}
if (memcmp(buf1, buf2, len1) != 0) {
ret = 7;
break;
}
} while (!feof(fp1) && !feof(fp2));
if (ret == -1) {
ret = feof(fp1) && feof(fp2) ? 0 : 20;
}
fclose(fp1);
fclose(fp2);
return ret;
}
int testUtilCmpSvgs(char* svg1, char* svg2)
{
return testUtilCmpTxts(svg1, svg2);
}
int testUtilCmpEpss(char* eps1, char* eps2)
{
int ret = -1;
FILE* fp1;
FILE* fp2;
char buf1[1024];
char buf2[1024];
size_t len1 = 0, len2 = 0;
char first_line[] = "%!PS-Adobe-3.0 EPSF-3.0\n";
char second_line_start[] = "%%Creator: Zint ";
fp1 = fopen(eps1, "r");
if (!fp1) {
return 2;
}
fp2 = fopen(eps2, "r");
if (!fp2) {
fclose(fp1);
return 3;
}
// Preprocess the 1st 2 lines to avoid comparing changeable Zint version in 2nd line
if (fgets(buf1, sizeof(buf1), fp1) == NULL || strcmp(buf1, first_line) != 0
|| fgets(buf2, sizeof(buf2), fp2) == NULL || strcmp(buf2, first_line) != 0) {
ret = 10;
} else if (fgets(buf1, sizeof(buf1), fp1) == NULL || strncmp(buf1, second_line_start, sizeof(second_line_start) - 1) != 0
|| fgets(buf2, sizeof(buf2), fp2) == NULL || strncmp(buf2, second_line_start, sizeof(second_line_start) - 1) != 0) {
ret = 11;
}
if (ret == -1) {
while (1) {
if (fgets(buf1, sizeof(buf1), fp1) == NULL) {
if (fgets(buf2, sizeof(buf2), fp2) != NULL) {
ret = 4;
break;
}
break;
}
if (fgets(buf2, sizeof(buf2), fp2) == NULL) {
ret = 5;
break;
}
len1 = strlen(buf1);
len2 = strlen(buf2);
if (len1 != len2) {
ret = 6;
break;
}
if (strcmp(buf1, buf2) != 0) {
ret = 7;
break;
}
}
if (ret == -1) {
ret = feof(fp1) && feof(fp2) ? 0 : 20;
}
}
fclose(fp1);
fclose(fp2);
return ret;
}
int testUtilCmpEmfs(char* emf1, char* emf2)
{
return testUtilCmpBins(emf1, emf2);
}
int testUtilCmpGifs(char* gif1, char* gif2)
{
return testUtilCmpBins(gif1, gif2);
}
int testUtilCmpBmps(char* bmp1, char* bmp2)
{
return testUtilCmpBins(bmp1, bmp2);
}
int testUtilCmpPcxs(char* pcx1, char* pcx2)
{
return testUtilCmpBins(pcx1, pcx2);
}

View File

@ -60,17 +60,29 @@ void testReport();
#define assert_nonnull(__ptr__, ...) assert_exp((__ptr__) != NULL, __VA_ARGS__)
#define assert_equal(__e1__, __e2__, ...) assert_exp((__e1__) == (__e2__), __VA_ARGS__)
#define assert_notequal(__e1__, __e2__, ...) assert_exp((__e1__) != (__e2__), __VA_ARGS__)
#define assert_fail(...) assert_exp(0, __VA_ARGS__)
#define assert_nothing(__exp__, ...) {printf(__VA_ARGS__); __exp__;}
extern void render_free(struct zint_symbol *symbol); /* Free render structures */
extern void vector_free(struct zint_symbol *symbol); /* Free vector structures */
char* testUtilBarcodeName(int symbology);
int testUtilDAFTConvert(const struct zint_symbol* symbol, char* buffer, int buffer_size);
char* testUtilEscape(char* buffer, char* escaped, int escaped_size);
char* testUtilReadCSVField(char* buffer, char* field, int field_size);
int testUtilSymbolCmp(const struct zint_symbol* a, const struct zint_symbol* b);
struct zint_render* testUtilRenderCpy(const struct zint_render* in);
int testUtilRenderCmp(const struct zint_render* a, const struct zint_render* b);
struct zint_vector* testUtilVectorCpy(const struct zint_vector* in);
int testUtilVectorCmp(const struct zint_vector* a, const struct zint_vector* b);
void testUtilLargeDump(const char* name, const short reg[]);
void testUtilModulesDump(const struct zint_symbol* symbol);
void testUtilModulesDump(const struct zint_symbol* symbol, char* prefix, char* postfix);
int testUtilModulesCmp(const struct zint_symbol* symbol, const char* expected, int* row, int* width);
int testUtilModulesDumpHex(const struct zint_symbol* symbol, char dump[], int dump_size);
int testUtilExists(char* filename);
int testUtilCmpPngs(char* file1, char* file2);
int testUtilCmpSvgs(char* svg1, char* svg2);
int testUtilCmpEpss(char* eps1, char* eps2);
int testUtilCmpEmfs(char* emf1, char* emf2);
int testUtilCmpGifs(char* gif1, char* gif2);
int testUtilCmpBmps(char* bmp1, char* bmp2);
int testUtilCmpPcxs(char* pcx1, char* pcx2);
#endif /* TESTCOMMON_H */