mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
testcommon: add testUtilDataPath() (uses getcwd()) so generate works for data files, remove copy
This commit is contained in:
parent
8ff15d805a
commit
32af280254
@ -10,11 +10,6 @@ enable_testing()
|
|||||||
|
|
||||||
include(${zint-package_SOURCE_DIR}/cmake/zint_add_test.cmake)
|
include(${zint-package_SOURCE_DIR}/cmake/zint_add_test.cmake)
|
||||||
|
|
||||||
file(GLOB_RECURSE zint_backend_tests_data LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "data/*")
|
|
||||||
foreach(data_file IN LISTS zint_backend_tests_data)
|
|
||||||
configure_file(${data_file} ${data_file} COPYONLY)
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
set(BWIPP_TAR ${CMAKE_CURRENT_SOURCE_DIR}/tools/bwipp_dump.ps.tar.xz)
|
set(BWIPP_TAR ${CMAKE_CURRENT_SOURCE_DIR}/tools/bwipp_dump.ps.tar.xz)
|
||||||
set(BWIPP_PS ${CMAKE_CURRENT_SOURCE_DIR}/tools/bwipp_dump.ps)
|
set(BWIPP_PS ${CMAKE_CURRENT_SOURCE_DIR}/tools/bwipp_dump.ps)
|
||||||
|
|
||||||
|
@ -129,14 +129,15 @@ static void test_print(int index, int generate, int debug) {
|
|||||||
char *expected_file;
|
char *expected_file;
|
||||||
};
|
};
|
||||||
struct item data[] = {
|
struct item data[] = {
|
||||||
/* 0*/ { BARCODE_PDF417, 5, -1, -1, -1, "147AD0", "FC9630", "123", "data/bmp/pdf417_fg_bg.bmp" },
|
/* 0*/ { BARCODE_PDF417, 5, -1, -1, -1, "147AD0", "FC9630", "123", "pdf417_fg_bg.bmp" },
|
||||||
/* 1*/ { BARCODE_ULTRA, 5, -1, -1, -1, "147AD0", "FC9630", "123", "data/bmp/ultracode_fg_bg.bmp" },
|
/* 1*/ { BARCODE_ULTRA, 5, -1, -1, -1, "147AD0", "FC9630", "123", "ultracode_fg_bg.bmp" },
|
||||||
/* 2*/ { BARCODE_PDF417COMP, 2, 2, -1, -1, "", "", "123", "data/bmp/pdf417comp_hvwsp2.bmp" },
|
/* 2*/ { BARCODE_PDF417COMP, 2, 2, -1, -1, "", "", "123", "pdf417comp_hvwsp2.bmp" },
|
||||||
};
|
};
|
||||||
int data_size = ARRAY_SIZE(data);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
char* data_dir = "data/bmp";
|
const char *data_dir = "/backend/tests/data/bmp";
|
||||||
char* bmp = "out.bmp";
|
const char *bmp = "out.bmp";
|
||||||
|
char expected_file[4096];
|
||||||
char escaped[1024];
|
char escaped[1024];
|
||||||
int escaped_size = 1024;
|
int escaped_size = 1024;
|
||||||
|
|
||||||
@ -175,23 +176,25 @@ static void test_print(int index, int generate, int debug) {
|
|||||||
ret = ZBarcode_Print(symbol, 0);
|
ret = ZBarcode_Print(symbol, 0);
|
||||||
assert_zero(ret, "i:%d %s ZBarcode_Print %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, ret);
|
assert_zero(ret, "i:%d %s ZBarcode_Print %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, ret);
|
||||||
|
|
||||||
|
assert_nonzero(testUtilDataPath(expected_file, sizeof(expected_file), data_dir, data[i].expected_file), "i:%d testUtilDataPath == 0\n", i);
|
||||||
|
|
||||||
if (generate) {
|
if (generate) {
|
||||||
printf(" /*%3d*/ { %s, %d, %d, %d, %d, \"%s\", \"%s\", \"%s\", \"%s\"},\n",
|
printf(" /*%3d*/ { %s, %d, %d, %d, %d, \"%s\", \"%s\", \"%s\", \"%s\"},\n",
|
||||||
i, testUtilBarcodeName(data[i].symbology), data[i].whitespace_width, data[i].whitespace_height,
|
i, testUtilBarcodeName(data[i].symbology), data[i].whitespace_width, data[i].whitespace_height,
|
||||||
data[i].option_1, data[i].option_2, data[i].fgcolour, data[i].bgcolour,
|
data[i].option_1, data[i].option_2, data[i].fgcolour, data[i].bgcolour,
|
||||||
testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].expected_file);
|
testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].expected_file);
|
||||||
ret = rename(symbol->outfile, data[i].expected_file);
|
ret = rename(symbol->outfile, expected_file);
|
||||||
assert_zero(ret, "i:%d rename(%s, %s) ret %d != 0\n", i, symbol->outfile, data[i].expected_file, ret);
|
assert_zero(ret, "i:%d rename(%s, %s) ret %d != 0\n", i, symbol->outfile, expected_file, ret);
|
||||||
if (have_identify) {
|
if (have_identify) {
|
||||||
ret = testUtilVerifyIdentify(data[i].expected_file, debug);
|
ret = testUtilVerifyIdentify(expected_file, debug);
|
||||||
assert_zero(ret, "i:%d %s identify %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), data[i].expected_file, ret);
|
assert_zero(ret, "i:%d %s identify %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), expected_file, ret);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
assert_nonzero(testUtilExists(symbol->outfile), "i:%d testUtilExists(%s) == 0\n", i, symbol->outfile);
|
assert_nonzero(testUtilExists(symbol->outfile), "i:%d testUtilExists(%s) == 0\n", i, symbol->outfile);
|
||||||
assert_nonzero(testUtilExists(data[i].expected_file), "i:%d testUtilExists(%s) == 0\n", i, data[i].expected_file);
|
assert_nonzero(testUtilExists(expected_file), "i:%d testUtilExists(%s) == 0\n", i, expected_file);
|
||||||
|
|
||||||
ret = testUtilCmpBins(symbol->outfile, data[i].expected_file);
|
ret = testUtilCmpBins(symbol->outfile, expected_file);
|
||||||
assert_zero(ret, "i:%d %s testUtilCmpBins(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, data[i].expected_file, ret);
|
assert_zero(ret, "i:%d %s testUtilCmpBins(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, expected_file, ret);
|
||||||
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
|
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,24 +57,25 @@ static void test_print(int index, int generate, int debug) {
|
|||||||
char *comment;
|
char *comment;
|
||||||
};
|
};
|
||||||
struct item data[] = {
|
struct item data[] = {
|
||||||
/* 0*/ { BARCODE_CODE128, UNICODE_MODE, BOLD_TEXT, -1, -1, -1, "", "", 0, "Égjpqy", "data/emf/code128_egrave_bold.emf", "" },
|
/* 0*/ { BARCODE_CODE128, UNICODE_MODE, BOLD_TEXT, -1, -1, -1, "", "", 0, "Égjpqy", "code128_egrave_bold.emf", "" },
|
||||||
/* 1*/ { BARCODE_TELEPEN, -1, -1, -1, -1, -1, "147AD0", "FC9630", 0, "123", "data/emf/telenum_fg_bg.emf", "" },
|
/* 1*/ { BARCODE_TELEPEN, -1, -1, -1, -1, -1, "147AD0", "FC9630", 0, "123", "telenum_fg_bg.emf", "" },
|
||||||
/* 2*/ { BARCODE_ULTRA, -1, -1, 5, -1, -1, "147AD0", "FC9630", 0, "123", "data/emf/ultracode_fg_bg.emf", "" },
|
/* 2*/ { BARCODE_ULTRA, -1, -1, 5, -1, -1, "147AD0", "FC9630", 0, "123", "ultracode_fg_bg.emf", "" },
|
||||||
/* 3*/ { BARCODE_EANX, -1, -1, -1, -1, -1, "", "", 0, "9780877799306+54321", "data/emf/ean13_5addon_ggs_5.2.2.5.2-2.emf", "" },
|
/* 3*/ { BARCODE_EANX, -1, -1, -1, -1, -1, "", "", 0, "9780877799306+54321", "ean13_5addon_ggs_5.2.2.5.2-2.emf", "" },
|
||||||
/* 4*/ { BARCODE_EANX, -1, -1, -1, -1, -1, "", "", 0, "210987654321+54321", "data/emf/ean13_5addon_#185.emf", "#185 Byte count, font data, HeaderExtension1/2" },
|
/* 4*/ { BARCODE_EANX, -1, -1, -1, -1, -1, "", "", 0, "210987654321+54321", "ean13_5addon_#185.emf", "#185 Byte count, font data, HeaderExtension1/2" },
|
||||||
/* 5*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, "", "", 0, "012345678905+24", "data/emf/upca_2addon_ggs_5.2.6.6-5.emf", "" },
|
/* 5*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, "", "", 0, "012345678905+24", "upca_2addon_ggs_5.2.6.6-5.emf", "" },
|
||||||
/* 6*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, "", "", 0, "0123456+12", "data/emf/upce_2addon.emf", "" },
|
/* 6*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, "", "", 0, "0123456+12", "upce_2addon.emf", "" },
|
||||||
/* 7*/ { BARCODE_UPCE, -1, SMALL_TEXT | BOLD_TEXT, -1, -1, -1, "", "", 0, "0123456+12", "data/emf/upce_2addon_small_bold.emf", "" },
|
/* 7*/ { BARCODE_UPCE, -1, SMALL_TEXT | BOLD_TEXT, -1, -1, -1, "", "", 0, "0123456+12", "upce_2addon_small_bold.emf", "" },
|
||||||
/* 8*/ { BARCODE_ITF14, -1, BOLD_TEXT, -1, -1, -1, "", "", 0, "123", "data/emf/itf14_bold.emf", "" },
|
/* 8*/ { BARCODE_ITF14, -1, BOLD_TEXT, -1, -1, -1, "", "", 0, "123", "itf14_bold.emf", "" },
|
||||||
/* 9*/ { BARCODE_CODE39, -1, -1, -1, -1, -1, "", "", 90, "123", "data/emf/code39_rotate_90.emf", "" },
|
/* 9*/ { BARCODE_CODE39, -1, -1, -1, -1, -1, "", "", 90, "123", "code39_rotate_90.emf", "" },
|
||||||
/* 10*/ { BARCODE_CODE39, -1, -1, -1, -1, -1, "", "", 180, "123", "data/emf/code39_rotate_180.emf", "" },
|
/* 10*/ { BARCODE_CODE39, -1, -1, -1, -1, -1, "", "", 180, "123", "code39_rotate_180.emf", "" },
|
||||||
/* 11*/ { BARCODE_CODE39, -1, -1, -1, -1, -1, "", "", 270, "123", "data/emf/code39_rotate_270.emf", "" },
|
/* 11*/ { BARCODE_CODE39, -1, -1, -1, -1, -1, "", "", 270, "123", "code39_rotate_270.emf", "" },
|
||||||
/* 12*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, "E0E0E0", "700070", 0, "THIS IS A 93 CHARACTER CODE SET A MESSAGE THAT FILLS A MODE 4, UNAPPENDED, MAXICODE SYMBOL...", "data/emf/maxicode_#185.emf", "#185 Maxicode scaling" },
|
/* 12*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, "E0E0E0", "700070", 0, "THIS IS A 93 CHARACTER CODE SET A MESSAGE THAT FILLS A MODE 4, UNAPPENDED, MAXICODE SYMBOL...", "maxicode_#185.emf", "#185 Maxicode scaling" },
|
||||||
};
|
};
|
||||||
int data_size = ARRAY_SIZE(data);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
char *data_dir = "data/emf";
|
const char *data_dir = "/backend/tests/data/emf";
|
||||||
char *emf = "out.emf";
|
const char *emf = "out.emf";
|
||||||
|
char expected_file[1024];
|
||||||
char escaped[1024];
|
char escaped[1024];
|
||||||
int escaped_size = 1024;
|
int escaped_size = 1024;
|
||||||
|
|
||||||
@ -110,26 +111,28 @@ static void test_print(int index, int generate, int debug) {
|
|||||||
ret = ZBarcode_Print(symbol, data[i].rotate_angle);
|
ret = ZBarcode_Print(symbol, data[i].rotate_angle);
|
||||||
assert_zero(ret, "i:%d %s ZBarcode_Print %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, ret);
|
assert_zero(ret, "i:%d %s ZBarcode_Print %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, ret);
|
||||||
|
|
||||||
|
assert_nonzero(testUtilDataPath(expected_file, sizeof(expected_file), data_dir, data[i].expected_file), "i:%d testUtilDataPath == 0\n", i);
|
||||||
|
|
||||||
if (generate) {
|
if (generate) {
|
||||||
printf(" /*%3d*/ { %s, %s, %s, %d, %d, %d, \"%s\", \"%s\", %d, \"%s\", \"%s\" \"%s\" },\n",
|
printf(" /*%3d*/ { %s, %s, %s, %d, %d, %d, \"%s\", \"%s\", %d, \"%s\", \"%s\" \"%s\" },\n",
|
||||||
i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode),
|
i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode),
|
||||||
testUtilOutputOptionsName(data[i].output_options), data[i].whitespace_width,
|
testUtilOutputOptionsName(data[i].output_options), data[i].whitespace_width,
|
||||||
data[i].option_1, data[i].option_2, data[i].fgcolour, data[i].bgcolour, data[i].rotate_angle,
|
data[i].option_1, data[i].option_2, data[i].fgcolour, data[i].bgcolour, data[i].rotate_angle,
|
||||||
testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].expected_file, data[i].comment);
|
testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].expected_file, data[i].comment);
|
||||||
ret = rename(symbol->outfile, data[i].expected_file);
|
ret = rename(symbol->outfile, expected_file);
|
||||||
assert_zero(ret, "i:%d rename(%s, %s) ret %d != 0\n", i, symbol->outfile, data[i].expected_file, ret);
|
assert_zero(ret, "i:%d rename(%s, %s) ret %d != 0\n", i, symbol->outfile, expected_file, ret);
|
||||||
if (have_libreoffice) {
|
if (have_libreoffice) {
|
||||||
// Note this will fail (on Ubuntu anyway) if LibreOffice Base/Calc/Impress/Writer running (i.e. anything but LibreOffice Draw)
|
// Note this will fail (on Ubuntu anyway) if LibreOffice Base/Calc/Impress/Writer running (i.e. anything but LibreOffice Draw)
|
||||||
// Doesn't seem to be a way to force Draw invocation through the command line
|
// Doesn't seem to be a way to force Draw invocation through the command line
|
||||||
ret = testUtilVerifyLibreOffice(data[i].expected_file, debug);
|
ret = testUtilVerifyLibreOffice(expected_file, debug);
|
||||||
assert_zero(ret, "i:%d %s libreoffice %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), data[i].expected_file, ret);
|
assert_zero(ret, "i:%d %s libreoffice %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), expected_file, ret);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
assert_nonzero(testUtilExists(symbol->outfile), "i:%d testUtilExists(%s) == 0\n", i, symbol->outfile);
|
assert_nonzero(testUtilExists(symbol->outfile), "i:%d testUtilExists(%s) == 0\n", i, symbol->outfile);
|
||||||
assert_nonzero(testUtilExists(data[i].expected_file), "i:%d testUtilExists(%s) == 0\n", i, data[i].expected_file);
|
assert_nonzero(testUtilExists(expected_file), "i:%d testUtilExists(%s) == 0\n", i, expected_file);
|
||||||
|
|
||||||
ret = testUtilCmpBins(symbol->outfile, data[i].expected_file);
|
ret = testUtilCmpBins(symbol->outfile, expected_file);
|
||||||
assert_zero(ret, "i:%d %s testUtilCmpBins(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, data[i].expected_file, ret);
|
assert_zero(ret, "i:%d %s testUtilCmpBins(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, expected_file, ret);
|
||||||
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
|
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,11 +39,8 @@
|
|||||||
|
|
||||||
static void test_csv(int index, int debug) {
|
static void test_csv(int index, int debug) {
|
||||||
|
|
||||||
testStart("");
|
char csvfile[1024];
|
||||||
|
FILE *fd;
|
||||||
FILE *fd = fopen("data/imail/usps/uspsIMbEncoderTestCases.csv", "r");
|
|
||||||
assert_nonnull(fd, "open data/imail/usps/uspsIMbEncoderTestCases.csv");
|
|
||||||
|
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
char id[10];
|
char id[10];
|
||||||
char tracking_code[50];
|
char tracking_code[50];
|
||||||
@ -55,6 +52,15 @@ static void test_csv(int index, int debug) {
|
|||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
int lc = 0;
|
int lc = 0;
|
||||||
|
|
||||||
|
testStart("");
|
||||||
|
|
||||||
|
assert_nonzero(testUtilDataPath(csvfile, sizeof(csvfile),
|
||||||
|
"/backend/tests/data/imail/usps/", "uspsIMbEncoderTestCases.csv"), "testUtilDataPath == 0\n");
|
||||||
|
|
||||||
|
fd = fopen(csvfile, "r");
|
||||||
|
assert_nonnull(fd, "fopen(%s) == NULL", csvfile);
|
||||||
|
|
||||||
while (fgets(buffer, sizeof(buffer), fd) != NULL) {
|
while (fgets(buffer, sizeof(buffer), fd) != NULL) {
|
||||||
|
|
||||||
lc++;
|
lc++;
|
||||||
@ -119,7 +125,7 @@ static void test_csv(int index, int debug) {
|
|||||||
ZBarcode_Delete(symbol);
|
ZBarcode_Delete(symbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fd);
|
assert_zero(fclose(fd), "fclose != 0\n");
|
||||||
|
|
||||||
testFinish();
|
testFinish();
|
||||||
}
|
}
|
||||||
|
@ -134,62 +134,63 @@ static void test_print(int index, int generate, int debug) {
|
|||||||
char *comment;
|
char *comment;
|
||||||
};
|
};
|
||||||
struct item data[] = {
|
struct item data[] = {
|
||||||
/* 0*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, -1, 0, 0, "", "", "Égjpqy", "", "data/png/code128_egrave_bold.png", "" },
|
/* 0*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, -1, 0, 0, "", "", "Égjpqy", "", "code128_egrave_bold.png", "" },
|
||||||
/* 1*/ { BARCODE_CODE128, UNICODE_MODE, 3, BOLD_TEXT | BARCODE_BOX, -1, -1, -1, -1, -1, 0, 0, "", "", "Égjpqy", "", "data/png/code128_egrave_bold_box3.png", "" },
|
/* 1*/ { BARCODE_CODE128, UNICODE_MODE, 3, BOLD_TEXT | BARCODE_BOX, -1, -1, -1, -1, -1, 0, 0, "", "", "Égjpqy", "", "code128_egrave_bold_box3.png", "" },
|
||||||
/* 2*/ { BARCODE_CODE128, UNICODE_MODE, 2, BOLD_TEXT | BARCODE_BOX, 2, 2, -1, -1, -1, 0, 0, "", "", "Égjpqy", "", "data/png/code128_egrave_bold_hvwsp2_box2.png", "" },
|
/* 2*/ { BARCODE_CODE128, UNICODE_MODE, 2, BOLD_TEXT | BARCODE_BOX, 2, 2, -1, -1, -1, 0, 0, "", "", "Égjpqy", "", "code128_egrave_bold_hvwsp2_box2.png", "" },
|
||||||
/* 3*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, -1, -1, 3, -1, 0, 0, "", "", "[00]030123456789012340", "[02]13012345678909[37]24[10]1234567ABCDEFG", "data/png/gs1_128_cc_fig12.png", "" },
|
/* 3*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, -1, -1, 3, -1, 0, 0, "", "", "[00]030123456789012340", "[02]13012345678909[37]24[10]1234567ABCDEFG", "gs1_128_cc_fig12.png", "" },
|
||||||
/* 4*/ { BARCODE_CODABLOCKF, -1, 3, -1, -1, -1, -1, 3, -1, 0, 0, "", "", "AAAAAAAAA", "", "data/png/codablockf_3rows.png", "" },
|
/* 4*/ { BARCODE_CODABLOCKF, -1, 3, -1, -1, -1, -1, 3, -1, 0, 0, "", "", "AAAAAAAAA", "", "codablockf_3rows.png", "" },
|
||||||
/* 5*/ { BARCODE_CODABLOCKF, -1, -1, -1, 2, 2, -1, -1, -1, 0, 0, "", "", "AAAAAAAAA", "", "data/png/codablockf_hvwsp2.png", "" },
|
/* 5*/ { BARCODE_CODABLOCKF, -1, -1, -1, 2, 2, -1, -1, -1, 0, 0, "", "", "AAAAAAAAA", "", "codablockf_hvwsp2.png", "" },
|
||||||
/* 6*/ { BARCODE_CODABLOCKF, -1, 2, BARCODE_BOX, 2, 2, -1, -1, -1, 0, 0, "", "", "AAAAAAAAA", "", "data/png/codablockf_hvwsp2_box2.png", "" },
|
/* 6*/ { BARCODE_CODABLOCKF, -1, 2, BARCODE_BOX, 2, 2, -1, -1, -1, 0, 0, "", "", "AAAAAAAAA", "", "codablockf_hvwsp2_box2.png", "" },
|
||||||
/* 7*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "9771384524017+12", "", "data/png/ean13_2addon_ggs_5.2.2.5.1-2.png", "" },
|
/* 7*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "9771384524017+12", "", "ean13_2addon_ggs_5.2.2.5.1-2.png", "" },
|
||||||
/* 8*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "9780877799306+54321", "", "data/png/ean13_5addon_ggs_5.2.2.5.2-2.png", "" },
|
/* 8*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "9780877799306+54321", "", "ean13_5addon_ggs_5.2.2.5.2-2.png", "" },
|
||||||
/* 9*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, 1, -1, 0, 0, "", "", "123456789012+12", "[91]123456789012345678901", "data/png/ean13_cc_2addon_cca_4x4.png", "" },
|
/* 9*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, 1, -1, 0, 0, "", "", "123456789012+12", "[91]123456789012345678901", "ean13_cc_2addon_cca_4x4.png", "" },
|
||||||
/* 10*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, 2, -1, 0, 0, "", "", "123456789012+54321", "[91]1234567890", "data/png/ean13_cc_5addon_ccb_3x4.png", "" },
|
/* 10*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, 2, -1, 0, 0, "", "", "123456789012+54321", "[91]1234567890", "ean13_cc_5addon_ccb_3x4.png", "" },
|
||||||
/* 11*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, 0, 2, -1, 0, 0, "", "", "123456789012+54321", "[91]1234567890", "data/png/ean13_cc_5addon_ccb_3x4_notext.png", "" },
|
/* 11*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, 0, 2, -1, 0, 0, "", "", "123456789012+54321", "[91]1234567890", "ean13_cc_5addon_ccb_3x4_notext.png", "" },
|
||||||
/* 12*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "012345678905+24", "", "data/png/upca_2addon_ggs_5.2.6.6-5.png", "" },
|
/* 12*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "012345678905+24", "", "upca_2addon_ggs_5.2.6.6-5.png", "" },
|
||||||
/* 13*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "614141234417+12345", "", "data/png/upca_5addon.png", "" },
|
/* 13*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "614141234417+12345", "", "upca_5addon.png", "" },
|
||||||
/* 14*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, 0, -1, -1, 0, 0, "", "", "614141234417+12345", "", "data/png/upca_5addon_notext.png", "" },
|
/* 14*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, 0, -1, -1, 0, 0, "", "", "614141234417+12345", "", "upca_5addon_notext.png", "" },
|
||||||
/* 15*/ { BARCODE_UPCA, -1, 3, BARCODE_BIND, -1, -1, -1, -1, -1, 0, 0, "", "", "614141234417+12345", "", "data/png/upca_5addon_bind3.png", "" },
|
/* 15*/ { BARCODE_UPCA, -1, 3, BARCODE_BIND, -1, -1, -1, -1, -1, 0, 0, "", "", "614141234417+12345", "", "upca_5addon_bind3.png", "" },
|
||||||
/* 16*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, -1, -1, 1, -1, 0, 0, "", "", "12345678901+12", "[91]123456789", "data/png/upca_cc_2addon_cca_3x4.png", "" },
|
/* 16*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, -1, -1, 1, -1, 0, 0, "", "", "12345678901+12", "[91]123456789", "upca_cc_2addon_cca_3x4.png", "" },
|
||||||
/* 17*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, -1, -1, 2, -1, 0, 0, "", "", "12345678901+12121", "[91]1234567890123", "data/png/upca_cc_5addon_ccb_4x4.png", "" },
|
/* 17*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, -1, -1, 2, -1, 0, 0, "", "", "12345678901+12121", "[91]1234567890123", "upca_cc_5addon_ccb_4x4.png", "" },
|
||||||
/* 18*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, -1, 0, 2, -1, 0, 0, "", "", "12345678901+12121", "[91]1234567890123", "data/png/upca_cc_5addon_ccb_4x4_notext.png", "" },
|
/* 18*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, -1, 0, 2, -1, 0, 0, "", "", "12345678901+12121", "[91]1234567890123", "upca_cc_5addon_ccb_4x4_notext.png", "" },
|
||||||
/* 19*/ { BARCODE_UPCA_CC, -1, 3, BARCODE_BIND, -1, -1, -1, 2, -1, 0, 0, "", "", "12345678901+12121", "[91]1234567890123", "data/png/upca_cc_5addon_ccb_4x4_bind3.png", "" },
|
/* 19*/ { BARCODE_UPCA_CC, -1, 3, BARCODE_BIND, -1, -1, -1, 2, -1, 0, 0, "", "", "12345678901+12121", "[91]1234567890123", "upca_cc_5addon_ccb_4x4_bind3.png", "" },
|
||||||
/* 20*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "1234567+12", "", "data/png/upce_2addon.png", "" },
|
/* 20*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "1234567+12", "", "upce_2addon.png", "" },
|
||||||
/* 21*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "1234567+12345", "", "data/png/upce_5addon.png", "" },
|
/* 21*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "1234567+12345", "", "upce_5addon.png", "" },
|
||||||
/* 22*/ { BARCODE_UPCE, -1, -1, SMALL_TEXT, -1, -1, -1, -1, -1, 0, 0, "", "", "1234567+12345", "", "data/png/upce_5addon_small.png", "" },
|
/* 22*/ { BARCODE_UPCE, -1, -1, SMALL_TEXT, -1, -1, -1, -1, -1, 0, 0, "", "", "1234567+12345", "", "upce_5addon_small.png", "" },
|
||||||
/* 23*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, -1, 1, -1, 0, 0, "", "", "0654321+89", "[91]1", "data/png/upce_cc_2addon_cca_5x2.png", "" },
|
/* 23*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, -1, 1, -1, 0, 0, "", "", "0654321+89", "[91]1", "upce_cc_2addon_cca_5x2.png", "" },
|
||||||
/* 24*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, -1, 2, -1, 0, 0, "", "", "1876543+56789", "[91]12345", "data/png/upce_cc_5addon_ccb_8x2.png", "" },
|
/* 24*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, -1, 2, -1, 0, 0, "", "", "1876543+56789", "[91]12345", "upce_cc_5addon_ccb_8x2.png", "" },
|
||||||
/* 25*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, 0, 2, -1, 0, 0, "", "", "1876543+56789", "[91]12345", "data/png/upce_cc_5addon_ccb_8x2_notext.png", "" },
|
/* 25*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, 0, 2, -1, 0, 0, "", "", "1876543+56789", "[91]12345", "upce_cc_5addon_ccb_8x2_notext.png", "" },
|
||||||
/* 26*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "1234567+12", "", "data/png/ean8_2addon.png", "" },
|
/* 26*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "1234567+12", "", "ean8_2addon.png", "" },
|
||||||
/* 27*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "1234567+12345", "", "data/png/ean8_5addon.png", "" },
|
/* 27*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "1234567+12345", "", "ean8_5addon.png", "" },
|
||||||
/* 28*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "9876543+65", "[91]1234567", "data/png/ean8_cc_2addon_cca_4x3.png", "" },
|
/* 28*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "9876543+65", "[91]1234567", "ean8_cc_2addon_cca_4x3.png", "" },
|
||||||
/* 29*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "9876543+74083", "[91]123456789012345678", "data/png/ean8_cc_5addon_ccb_8x3.png", "" },
|
/* 29*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "9876543+74083", "[91]123456789012345678", "ean8_cc_5addon_ccb_8x3.png", "" },
|
||||||
/* 30*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "12345", "", "data/png/ean5.png", "" },
|
/* 30*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "12345", "", "ean5.png", "" },
|
||||||
/* 31*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "12", "", "data/png/ean2.png", "" },
|
/* 31*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "12", "", "ean2.png", "" },
|
||||||
/* 32*/ { BARCODE_CODE39, -1, -1, SMALL_TEXT, -1, -1, -1, -1, -1, 0, 0, "", "", "123", "", "data/png/code39_small.png", "" },
|
/* 32*/ { BARCODE_CODE39, -1, -1, SMALL_TEXT, -1, -1, -1, -1, -1, 0, 0, "", "", "123", "", "code39_small.png", "" },
|
||||||
/* 33*/ { BARCODE_POSTNET, -1, -1, -1, -1, -1, -1, -1, -1, 0, 3.5, "", "", "12345", "", "data/png/postnet_zip.png", "300 dpi, using 1/43in X, 300 / 43 / 2 = ~3.5 scale" },
|
/* 33*/ { BARCODE_POSTNET, -1, -1, -1, -1, -1, -1, -1, -1, 0, 3.5, "", "", "12345", "", "postnet_zip.png", "300 dpi, using 1/43in X, 300 / 43 / 2 = ~3.5 scale" },
|
||||||
/* 34*/ { BARCODE_PDF417, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "CFCECDCC", "12345", "", "data/png/pdf417_bgalpha.png", "" },
|
/* 34*/ { BARCODE_PDF417, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "CFCECDCC", "12345", "", "pdf417_bgalpha.png", "" },
|
||||||
/* 35*/ { BARCODE_PDF417, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "30313233", "", "12345", "", "data/png/pdf417_fgalpha.png", "" },
|
/* 35*/ { BARCODE_PDF417, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "30313233", "", "12345", "", "pdf417_fgalpha.png", "" },
|
||||||
/* 36*/ { BARCODE_PDF417, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "20212244", "CFCECDCC", "12345", "", "data/png/pdf417_bgfgalpha.png", "" },
|
/* 36*/ { BARCODE_PDF417, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "20212244", "CFCECDCC", "12345", "", "pdf417_bgfgalpha.png", "" },
|
||||||
/* 37*/ { BARCODE_ULTRA, -1, -1, -1, 2, -1, -1, -1, -1, 0, 0, "0000007F", "FF000033", "12345", "", "data/png/ultra_bgfgalpha.png", "" },
|
/* 37*/ { BARCODE_ULTRA, -1, -1, -1, 2, -1, -1, -1, -1, 0, 0, "0000007F", "FF000033", "12345", "", "ultra_bgfgalpha.png", "" },
|
||||||
/* 38*/ { BARCODE_ULTRA, -1, -1, -1, 2, -1, -1, -1, -1, 0, 0, "", "FF000033", "12345", "", "data/png/ultra_bgalpha.png", "" },
|
/* 38*/ { BARCODE_ULTRA, -1, -1, -1, 2, -1, -1, -1, -1, 0, 0, "", "FF000033", "12345", "", "ultra_bgalpha.png", "" },
|
||||||
/* 39*/ { BARCODE_ULTRA, -1, -1, -1, 2, -1, -1, -1, -1, 0, 0, "0000007F", "FF0000", "12345", "", "data/png/ultra_fgalpha.png", "" },
|
/* 39*/ { BARCODE_ULTRA, -1, -1, -1, 2, -1, -1, -1, -1, 0, 0, "0000007F", "FF0000", "12345", "", "ultra_fgalpha.png", "" },
|
||||||
/* 40*/ { BARCODE_ULTRA, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "0000007F", "", "12345", "", "data/png/ultra_fgalpha_nobg.png", "" },
|
/* 40*/ { BARCODE_ULTRA, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "0000007F", "", "12345", "", "ultra_fgalpha_nobg.png", "" },
|
||||||
/* 41*/ { BARCODE_ULTRA, -1, 1, BARCODE_BOX, 1, 1, -1, -1, -1, 0, 0, "00FF007F", "BABDB6", "12345", "", "data/png/ultra_fgalpha_hvwsp1_box1.png", "" },
|
/* 41*/ { BARCODE_ULTRA, -1, 1, BARCODE_BOX, 1, 1, -1, -1, -1, 0, 0, "00FF007F", "BABDB6", "12345", "", "ultra_fgalpha_hvwsp1_box1.png", "" },
|
||||||
/* 42*/ { BARCODE_ULTRA, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0.5f, "", "", "1", "", "data/png/ultra_odd.png", "" },
|
/* 42*/ { BARCODE_ULTRA, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0.5f, "", "", "1", "", "ultra_odd.png", "" },
|
||||||
/* 43*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0.5f, "", "", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "data/png/maxicode_0.5.png", "6 dpmm, 150 dpi" },
|
/* 43*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0.5f, "", "", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "maxicode_0.5.png", "6 dpmm, 150 dpi" },
|
||||||
/* 44*/ { BARCODE_MAXICODE, -1, 1, BARCODE_BOX, 3, -1, -1, -1, -1, 0, 0.7f, "", "", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "data/png/maxicode_0.7_wsp3_box1.png", "8 dpmm, 200 dpi" },
|
/* 44*/ { BARCODE_MAXICODE, -1, 1, BARCODE_BOX, 3, -1, -1, -1, -1, 0, 0.7f, "", "", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "maxicode_0.7_wsp3_box1.png", "8 dpmm, 200 dpi" },
|
||||||
/* 45*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1.4f, "1111117F", "EEEEEEEE", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "data/png/maxicode_1.4_bgfgalpha.png", "16 dpmm, 400 dpi" },
|
/* 45*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1.4f, "1111117F", "EEEEEEEE", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "maxicode_1.4_bgfgalpha.png", "16 dpmm, 400 dpi" },
|
||||||
/* 46*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, -1, 0, 2.1f, "", "", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "data/png/maxicode_2.1.png", "24 dpmm, 600 dpi" },
|
/* 46*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, -1, 0, 2.1f, "", "", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "maxicode_2.1.png", "24 dpmm, 600 dpi" },
|
||||||
/* 47*/ { BARCODE_MAXICODE, -1, 2, BARCODE_BOX, 1, 1, -1, -1, -1, 0, 0, "", "", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "data/png/maxicode_hvwsp1_box2.png", "" },
|
/* 47*/ { BARCODE_MAXICODE, -1, 2, BARCODE_BOX, 1, 1, -1, -1, -1, 0, 0, "", "", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "maxicode_hvwsp1_box2.png", "" },
|
||||||
/* 48*/ { BARCODE_MAXICODE, -1, 1, BARCODE_BIND, -1, 1, -1, -1, -1, 0, 0, "", "", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "data/png/maxicode_vwsp1_bind1.png", "" },
|
/* 48*/ { BARCODE_MAXICODE, -1, 1, BARCODE_BIND, -1, 1, -1, -1, -1, 0, 0, "", "", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "maxicode_vwsp1_bind1.png", "" },
|
||||||
/* 49*/ { BARCODE_DATAMATRIX, -1, 1, BARCODE_BIND | BARCODE_DOTTY_MODE, -1, -1, -1, -1, -1, 0, 2.0f, "", "", "1234", "", "data/png/datamatrix_2.0_bind1_dotty.png", "" },
|
/* 49*/ { BARCODE_DATAMATRIX, -1, 1, BARCODE_BIND | BARCODE_DOTTY_MODE, -1, -1, -1, -1, -1, 0, 2.0f, "", "", "1234", "", "datamatrix_2.0_bind1_dotty.png", "" },
|
||||||
/* 50*/ { BARCODE_DATAMATRIX, -1, 1, BARCODE_BIND | BARCODE_DOTTY_MODE, 1, 1, -1, -1, -1, 0, 2.0f, "", "", "1234", "", "data/png/datamatrix_2.0_hvwsp1_bind1_dotty.png", "" },
|
/* 50*/ { BARCODE_DATAMATRIX, -1, 1, BARCODE_BIND | BARCODE_DOTTY_MODE, 1, 1, -1, -1, -1, 0, 2.0f, "", "", "1234", "", "datamatrix_2.0_hvwsp1_bind1_dotty.png", "" },
|
||||||
};
|
};
|
||||||
int data_size = ARRAY_SIZE(data);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
char *data_dir = "data/png";
|
const char *data_dir = "/backend/tests/data/png";
|
||||||
char *png = "out.png";
|
const char *png = "out.png";
|
||||||
|
char expected_file[1024];
|
||||||
char escaped[1024];
|
char escaped[1024];
|
||||||
int escaped_size = 1024;
|
int escaped_size = 1024;
|
||||||
char *text;
|
char *text;
|
||||||
@ -248,25 +249,27 @@ static void test_print(int index, int generate, int debug) {
|
|||||||
ret = ZBarcode_Print(symbol, 0);
|
ret = ZBarcode_Print(symbol, 0);
|
||||||
assert_zero(ret, "i:%d %s ZBarcode_Print %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, ret);
|
assert_zero(ret, "i:%d %s ZBarcode_Print %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, ret);
|
||||||
|
|
||||||
|
assert_nonzero(testUtilDataPath(expected_file, sizeof(expected_file), data_dir, data[i].expected_file), "i:%d testUtilDataPath == 0\n", i);
|
||||||
|
|
||||||
if (generate) {
|
if (generate) {
|
||||||
printf(" /*%3d*/ { %s, %s, %d, %s, %d, %d, %d, %d, %d, %d, %.5g, \"%s\",\"%s\", \"%s\", \"%s\", \"%s\", \"%s\" },\n",
|
printf(" /*%3d*/ { %s, %s, %d, %s, %d, %d, %d, %d, %d, %d, %.5g, \"%s\",\"%s\", \"%s\", \"%s\", \"%s\", \"%s\" },\n",
|
||||||
i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), data[i].border_width, testUtilOutputOptionsName(data[i].output_options),
|
i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), data[i].border_width, testUtilOutputOptionsName(data[i].output_options),
|
||||||
data[i].whitespace_width, data[i].whitespace_height, data[i].show_hrt, data[i].option_1, data[i].option_2, data[i].height, data[i].scale, data[i].fgcolour, data[i].bgcolour,
|
data[i].whitespace_width, data[i].whitespace_height, data[i].show_hrt, data[i].option_1, data[i].option_2, data[i].height, data[i].scale, data[i].fgcolour, data[i].bgcolour,
|
||||||
testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].composite, data[i].expected_file, data[i].comment);
|
testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].composite, data[i].expected_file, data[i].comment);
|
||||||
ret = rename(symbol->outfile, data[i].expected_file);
|
ret = rename(symbol->outfile, expected_file);
|
||||||
assert_zero(ret, "i:%d rename(%s, %s) ret %d != 0\n", i, symbol->outfile, data[i].expected_file, ret);
|
assert_zero(ret, "i:%d rename(%s, %s) ret %d != 0\n", i, symbol->outfile, expected_file, ret);
|
||||||
if (have_identify) {
|
if (have_identify) {
|
||||||
ret = testUtilVerifyIdentify(data[i].expected_file, debug);
|
ret = testUtilVerifyIdentify(expected_file, debug);
|
||||||
assert_zero(ret, "i:%d %s identify %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), data[i].expected_file, ret);
|
assert_zero(ret, "i:%d %s identify %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), expected_file, ret);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
assert_nonzero(testUtilExists(symbol->outfile), "i:%d testUtilExists(%s) == 0\n", i, symbol->outfile);
|
assert_nonzero(testUtilExists(symbol->outfile), "i:%d testUtilExists(%s) == 0\n", i, symbol->outfile);
|
||||||
assert_nonzero(testUtilExists(data[i].expected_file), "i:%d testUtilExists(%s) == 0\n", i, data[i].expected_file);
|
assert_nonzero(testUtilExists(expected_file), "i:%d testUtilExists(%s) == 0\n", i, expected_file);
|
||||||
|
|
||||||
ret = testUtilCmpPngs(symbol->outfile, data[i].expected_file);
|
ret = testUtilCmpPngs(symbol->outfile, expected_file);
|
||||||
assert_zero(ret, "i:%d %s testUtilCmpPngs(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, data[i].expected_file, ret);
|
assert_zero(ret, "i:%d %s testUtilCmpPngs(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, expected_file, ret);
|
||||||
ret = testUtilCmpBins(symbol->outfile, data[i].expected_file);
|
ret = testUtilCmpBins(symbol->outfile, expected_file);
|
||||||
assert_zero(ret, "i:%d %s testUtilCmpBins(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, data[i].expected_file, ret);
|
assert_zero(ret, "i:%d %s testUtilCmpBins(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, expected_file, ret);
|
||||||
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
|
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,41 +67,51 @@ static void test_print(int index, int generate, int debug) {
|
|||||||
/* 3*/ { BARCODE_ULTRA, -1, -1, -1, "A", "ultracode_a" },
|
/* 3*/ { BARCODE_ULTRA, -1, -1, -1, "A", "ultracode_a" },
|
||||||
/* 4*/ { BARCODE_MAXICODE, -1, -1, -1, "THIS IS A 93 CHARACTER CODE SET A MESSAGE THAT FILLS A MODE 4, UNAPPENDED, MAXICODE SYMBOL...", "maxicode_fig_2" },
|
/* 4*/ { BARCODE_MAXICODE, -1, -1, -1, "THIS IS A 93 CHARACTER CODE SET A MESSAGE THAT FILLS A MODE 4, UNAPPENDED, MAXICODE SYMBOL...", "maxicode_fig_2" },
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
char *exts[] = { "bmp", "emf", "eps", "gif", "pcx", "png", "svg", "tif", "txt" };
|
char *exts[] = { "bmp", "emf", "eps", "gif", "pcx", "png", "svg", "tif", "txt" };
|
||||||
int exts_len = sizeof(exts) / sizeof(char*);
|
int exts_size = ARRAY_SIZE(exts);
|
||||||
|
|
||||||
char data_dir[1024];
|
char data_dir[1024];
|
||||||
|
char data_subdir[1024];
|
||||||
char expected_file[1024];
|
char expected_file[1024];
|
||||||
|
|
||||||
char escaped[1024];
|
char escaped[1024];
|
||||||
int escaped_size = 1024;
|
int escaped_size = 1024;
|
||||||
|
|
||||||
|
assert_nonzero(testUtilDataPath(data_dir, sizeof(data_dir), "/backend/tests/data", NULL), "testUtilDataPath == 0\n");
|
||||||
|
|
||||||
if (generate) {
|
if (generate) {
|
||||||
strcpy(data_dir, "data");
|
|
||||||
if (!testUtilExists(data_dir)) {
|
if (!testUtilExists(data_dir)) {
|
||||||
ret = testutil_mkdir(data_dir, 0755);
|
ret = testutil_mkdir(data_dir, 0755);
|
||||||
assert_zero(ret, "testutil_mkdir(%s) ret %d != 0 (%d: %s)\n", data_dir, ret, errno, strerror(errno));
|
assert_zero(ret, "testutil_mkdir(%s) ret %d != 0 (%d: %s)\n", data_dir, ret, errno, strerror(errno));
|
||||||
}
|
}
|
||||||
|
assert_nonzero(sizeof(data_dir) > strlen(data_dir) + 6, "sizeof(data_dir) %d <= strlen (%d) + 6\n", (int) sizeof(data_dir), (int) strlen(data_dir));
|
||||||
strcat(data_dir, "/print");
|
strcat(data_dir, "/print");
|
||||||
if (!testUtilExists(data_dir)) {
|
if (!testUtilExists(data_dir)) {
|
||||||
ret = testutil_mkdir(data_dir, 0755);
|
ret = testutil_mkdir(data_dir, 0755);
|
||||||
assert_zero(ret, "testutil_mkdir(%s) ret %d != 0 (%d: %s)\n", data_dir, ret, errno, strerror(errno));
|
assert_zero(ret, "testutil_mkdir(%s) ret %d != 0 (%d: %s)\n", data_dir, ret, errno, strerror(errno));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
assert_nonzero(sizeof(data_dir) > strlen(data_dir) + 6, "sizeof(data_dir) %d <= strlen (%d) + 6\n", (int) sizeof(data_dir), (int) strlen(data_dir));
|
||||||
|
strcat(data_dir, "/print");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j = 0; j < exts_len; j++) {
|
for (int j = 0; j < exts_size; j++) {
|
||||||
#ifdef NO_PNG
|
#ifdef NO_PNG
|
||||||
if (strcmp(exts[j], "png") == 0) continue;
|
if (strcmp(exts[j], "png") == 0) continue;
|
||||||
#endif
|
#endif
|
||||||
strcpy(data_dir, "data/print/");
|
assert_nonzero(sizeof(data_subdir) > strlen(data_dir) + 1 + strlen(exts[j]),
|
||||||
strcat(data_dir, exts[j]);
|
"sizeof(data_subdir) (%d) <= strlen(data_dir) (%d) + 1 + strlen(%s) (%d)\n",
|
||||||
|
(int) sizeof(data_subdir), (int) strlen(data_dir), exts[j], (int) strlen(exts[j]));
|
||||||
|
strcpy(data_subdir, data_dir);
|
||||||
|
strcat(data_subdir, "/");
|
||||||
|
strcat(data_subdir, exts[j]);
|
||||||
|
|
||||||
if (generate) {
|
if (generate) {
|
||||||
if (!testUtilExists(data_dir)) {
|
if (!testUtilExists(data_subdir)) {
|
||||||
ret = testutil_mkdir(data_dir, 0755);
|
ret = testutil_mkdir(data_subdir, 0755);
|
||||||
assert_zero(ret, "testutil_mkdir(%s) ret %d != 0 (%d: %s)\n", data_dir, ret, errno, strerror(errno));
|
assert_zero(ret, "testutil_mkdir(%s) ret %d != 0 (%d: %s)\n", data_subdir, ret, errno, strerror(errno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,7 +133,10 @@ static void test_print(int index, int generate, int debug) {
|
|||||||
strcpy(symbol->outfile, "out.");
|
strcpy(symbol->outfile, "out.");
|
||||||
strcat(symbol->outfile, exts[j]);
|
strcat(symbol->outfile, exts[j]);
|
||||||
|
|
||||||
strcpy(expected_file, data_dir);
|
assert_nonzero(sizeof(expected_file) > strlen(data_subdir) + 1 + strlen(data[i].expected_file) + 1 + strlen(exts[j]),
|
||||||
|
"i:%d sizeof(expected_file) (%d) > strlen(data_subdir) (%d) + 1 + strlen(%s) (%d) + 1 + strlen(%s) (%d),\n",
|
||||||
|
i, (int) sizeof(expected_file), (int) strlen(data_subdir), data[i].expected_file, (int) strlen(data[i].expected_file), exts[j], (int) strlen(exts[j]));
|
||||||
|
strcpy(expected_file, data_subdir);
|
||||||
strcat(expected_file, "/");
|
strcat(expected_file, "/");
|
||||||
strcat(expected_file, data[i].expected_file);
|
strcat(expected_file, data[i].expected_file);
|
||||||
strcat(expected_file, ".");
|
strcat(expected_file, ".");
|
||||||
|
@ -52,20 +52,21 @@ static void test_print(int index, int generate, int debug) {
|
|||||||
char *expected_file;
|
char *expected_file;
|
||||||
};
|
};
|
||||||
struct item data[] = {
|
struct item data[] = {
|
||||||
/* 0*/ { BARCODE_CODE128, UNICODE_MODE, BOLD_TEXT, -1, -1, -1, "", "", "Égjpqy", "data/eps/code128_egrave_bold.eps" },
|
/* 0*/ { BARCODE_CODE128, UNICODE_MODE, BOLD_TEXT, -1, -1, -1, "", "", "Égjpqy", "code128_egrave_bold.eps" },
|
||||||
/* 1*/ { BARCODE_CODE39, -1, -1, -1, -1, -1, "147AD0", "FC9630", "123", "data/eps/code39_fg_bg.eps" },
|
/* 1*/ { BARCODE_CODE39, -1, -1, -1, -1, -1, "147AD0", "FC9630", "123", "code39_fg_bg.eps" },
|
||||||
/* 2*/ { BARCODE_ULTRA, -1, 1, -1, -1, -1, "147AD0", "FC9630", "123", "data/eps/ultra_fg_bg.eps" },
|
/* 2*/ { BARCODE_ULTRA, -1, 1, -1, -1, -1, "147AD0", "FC9630", "123", "ultra_fg_bg.eps" },
|
||||||
/* 3*/ { BARCODE_EANX, -1, -1, -1, -1, -1, "", "", "9771384524017+12", "data/eps/ean13_2addon_ggs_5.2.2.5.1-2.eps" },
|
/* 3*/ { BARCODE_EANX, -1, -1, -1, -1, -1, "", "", "9771384524017+12", "ean13_2addon_ggs_5.2.2.5.1-2.eps" },
|
||||||
/* 4*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, "", "", "012345678905+24", "data/eps/upca_2addon_ggs_5.2.6.6-5.eps" },
|
/* 4*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, "", "", "012345678905+24", "upca_2addon_ggs_5.2.6.6-5.eps" },
|
||||||
/* 5*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, "", "", "0123456+12345", "data/eps/upce_5addon.eps" },
|
/* 5*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, "", "", "0123456+12345", "upce_5addon.eps" },
|
||||||
/* 6*/ { BARCODE_UPCE, -1, SMALL_TEXT | BOLD_TEXT, -1, -1, -1, "", "", "0123456+12345", "data/eps/upce_5addon_small_bold.eps" },
|
/* 6*/ { BARCODE_UPCE, -1, SMALL_TEXT | BOLD_TEXT, -1, -1, -1, "", "", "0123456+12345", "upce_5addon_small_bold.eps" },
|
||||||
/* 7*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, -1, -1, "", "", "A\\B)ç(D", "data/eps/code128_escape_latin1.eps" },
|
/* 7*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, -1, -1, "", "", "A\\B)ç(D", "code128_escape_latin1.eps" },
|
||||||
/* 8*/ { BARCODE_DBAR_LTD, -1, BOLD_TEXT, -1, -1, -1, "", "", "1501234567890", "data/eps/dbar_ltd_24724_fig7_bold.eps" },
|
/* 8*/ { BARCODE_DBAR_LTD, -1, BOLD_TEXT, -1, -1, -1, "", "", "1501234567890", "dbar_ltd_24724_fig7_bold.eps" },
|
||||||
};
|
};
|
||||||
int data_size = ARRAY_SIZE(data);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
char *data_dir = "data/eps";
|
const char *data_dir = "/backend/tests/data/eps";
|
||||||
char *eps = "out.eps";
|
const char *eps = "out.eps";
|
||||||
|
char expected_file[1024];
|
||||||
char escaped[1024];
|
char escaped[1024];
|
||||||
int escaped_size = 1024;
|
int escaped_size = 1024;
|
||||||
|
|
||||||
@ -101,22 +102,24 @@ static void test_print(int index, int generate, int debug) {
|
|||||||
ret = ZBarcode_Print(symbol, 0);
|
ret = ZBarcode_Print(symbol, 0);
|
||||||
assert_zero(ret, "i:%d %s ZBarcode_Print %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, ret);
|
assert_zero(ret, "i:%d %s ZBarcode_Print %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, ret);
|
||||||
|
|
||||||
|
assert_nonzero(testUtilDataPath(expected_file, sizeof(expected_file), data_dir, data[i].expected_file), "i:%d testUtilDataPath == 0\n", i);
|
||||||
|
|
||||||
if (generate) {
|
if (generate) {
|
||||||
printf(" /*%3d*/ { %s, %s, %s, %d, %d, %d, \"%s\", \"%s\", \"%s\", \"%s\"},\n",
|
printf(" /*%3d*/ { %s, %s, %s, %d, %d, %d, \"%s\", \"%s\", \"%s\", \"%s\"},\n",
|
||||||
i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), testUtilOutputOptionsName(data[i].output_options), data[i].whitespace_width,
|
i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), testUtilOutputOptionsName(data[i].output_options), data[i].whitespace_width,
|
||||||
data[i].option_1, data[i].option_2, data[i].fgcolour, data[i].bgcolour, testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].expected_file);
|
data[i].option_1, data[i].option_2, data[i].fgcolour, data[i].bgcolour, testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].expected_file);
|
||||||
ret = rename(symbol->outfile, data[i].expected_file);
|
ret = rename(symbol->outfile, expected_file);
|
||||||
assert_zero(ret, "i:%d rename(%s, %s) ret %d != 0\n", i, symbol->outfile, data[i].expected_file, ret);
|
assert_zero(ret, "i:%d rename(%s, %s) ret %d != 0\n", i, symbol->outfile, expected_file, ret);
|
||||||
if (have_ghostscript) {
|
if (have_ghostscript) {
|
||||||
ret = testUtilVerifyGhostscript(data[i].expected_file, debug);
|
ret = testUtilVerifyGhostscript(expected_file, debug);
|
||||||
assert_zero(ret, "i:%d %s ghostscript %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), data[i].expected_file, ret);
|
assert_zero(ret, "i:%d %s ghostscript %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), expected_file, ret);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
assert_nonzero(testUtilExists(symbol->outfile), "i:%d testUtilExists(%s) == 0\n", i, symbol->outfile);
|
assert_nonzero(testUtilExists(symbol->outfile), "i:%d testUtilExists(%s) == 0\n", i, symbol->outfile);
|
||||||
assert_nonzero(testUtilExists(data[i].expected_file), "i:%d testUtilExists(%s) == 0\n", i, data[i].expected_file);
|
assert_nonzero(testUtilExists(expected_file), "i:%d testUtilExists(%s) == 0\n", i, expected_file);
|
||||||
|
|
||||||
ret = testUtilCmpEpss(symbol->outfile, data[i].expected_file);
|
ret = testUtilCmpEpss(symbol->outfile, expected_file);
|
||||||
assert_zero(ret, "i:%d %s testUtilCmpEpss(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, data[i].expected_file, ret);
|
assert_zero(ret, "i:%d %s testUtilCmpEpss(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, expected_file, ret);
|
||||||
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
|
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,52 +59,53 @@ static void test_print(int index, int generate, int debug) {
|
|||||||
char *expected_file;
|
char *expected_file;
|
||||||
};
|
};
|
||||||
struct item data[] = {
|
struct item data[] = {
|
||||||
/* 0*/ { BARCODE_CODE128, -1, -1, -1, -1, -1, -1, -1, -1, "<>\"&'", "", "data/svg/code128_amperands.svg" },
|
/* 0*/ { BARCODE_CODE128, -1, -1, -1, -1, -1, -1, -1, -1, "<>\"&'", "", "code128_amperands.svg" },
|
||||||
/* 1*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, -1, "Égjpqy", "", "data/svg/code128_egrave_bold.svg" },
|
/* 1*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, -1, "Égjpqy", "", "code128_egrave_bold.svg" },
|
||||||
/* 2*/ { BARCODE_CODE128, UNICODE_MODE, 3, BOLD_TEXT | BARCODE_BOX, -1, -1, -1, -1, -1, "Égjpqy", "", "data/svg/code128_egrave_bold_box3.svg" },
|
/* 2*/ { BARCODE_CODE128, UNICODE_MODE, 3, BOLD_TEXT | BARCODE_BOX, -1, -1, -1, -1, -1, "Égjpqy", "", "code128_egrave_bold_box3.svg" },
|
||||||
/* 3*/ { BARCODE_CODE128, UNICODE_MODE, 2, BOLD_TEXT | BARCODE_BOX, 2, 2, -1, -1, -1, "Égjpqy", "", "data/svg/code128_egrave_bold_hvwsp2_box2.svg" },
|
/* 3*/ { BARCODE_CODE128, UNICODE_MODE, 2, BOLD_TEXT | BARCODE_BOX, 2, 2, -1, -1, -1, "Égjpqy", "", "code128_egrave_bold_hvwsp2_box2.svg" },
|
||||||
/* 4*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, 3, 3, -1, -1, -1, "Égjpqy", "", "data/svg/code128_egrave_bold_hvwsp3.svg" },
|
/* 4*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, 3, 3, -1, -1, -1, "Égjpqy", "", "code128_egrave_bold_hvwsp3.svg" },
|
||||||
/* 5*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, -1, -1, 3, -1, "[00]030123456789012340", "[02]13012345678909[37]24[10]1234567ABCDEFG", "data/svg/gs1_128_cc_fig12.svg" },
|
/* 5*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, -1, -1, 3, -1, "[00]030123456789012340", "[02]13012345678909[37]24[10]1234567ABCDEFG", "gs1_128_cc_fig12.svg" },
|
||||||
/* 6*/ { BARCODE_CODABLOCKF, -1, -1, -1, -1, -1, -1, 3, -1, "AAAAAAAAA", "", "data/svg/codablockf_3rows.svg" },
|
/* 6*/ { BARCODE_CODABLOCKF, -1, -1, -1, -1, -1, -1, 3, -1, "AAAAAAAAA", "", "codablockf_3rows.svg" },
|
||||||
/* 7*/ { BARCODE_CODABLOCKF, -1, -1, -1, 2, 2, -1, 3, -1, "AAAAAAAAA", "", "data/svg/codablockf_hvwsp2.svg" },
|
/* 7*/ { BARCODE_CODABLOCKF, -1, -1, -1, 2, 2, -1, 3, -1, "AAAAAAAAA", "", "codablockf_hvwsp2.svg" },
|
||||||
/* 8*/ { BARCODE_CODABLOCKF, -1, 2, BARCODE_BOX, 2, 2, -1, -1, -1, "AAAAAAAAA", "", "data/svg/codablockf_hvwsp2_box2.svg" },
|
/* 8*/ { BARCODE_CODABLOCKF, -1, 2, BARCODE_BOX, 2, 2, -1, -1, -1, "AAAAAAAAA", "", "codablockf_hvwsp2_box2.svg" },
|
||||||
/* 9*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, "9771384524017+12", "", "data/svg/ean13_2addon_ggs_5.2.2.5.1-2.svg" },
|
/* 9*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, "9771384524017+12", "", "ean13_2addon_ggs_5.2.2.5.1-2.svg" },
|
||||||
/* 10*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, "9780877799306+54321", "", "data/svg/ean13_5addon_ggs_5.2.2.5.2-2.svg" },
|
/* 10*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, "9780877799306+54321", "", "ean13_5addon_ggs_5.2.2.5.2-2.svg" },
|
||||||
/* 11*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, 1, -1, "123456789012+12", "[91]123456789012345678901", "data/svg/ean13_cc_2addon_cca_4x4.svg" },
|
/* 11*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, 1, -1, "123456789012+12", "[91]123456789012345678901", "ean13_cc_2addon_cca_4x4.svg" },
|
||||||
/* 12*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, 2, -1, "123456789012+54321", "[91]1234567890", "data/svg/ean13_cc_5addon_ccb_3x4.svg" },
|
/* 12*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, 2, -1, "123456789012+54321", "[91]1234567890", "ean13_cc_5addon_ccb_3x4.svg" },
|
||||||
/* 13*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, 0, 2, -1, "123456789012+54321", "[91]1234567890", "data/svg/ean13_cc_5addon_ccb_3x4_notext.svg" },
|
/* 13*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, 0, 2, -1, "123456789012+54321", "[91]1234567890", "ean13_cc_5addon_ccb_3x4_notext.svg" },
|
||||||
/* 14*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, -1, -1, -1, "012345678905+24", "", "data/svg/upca_2addon_ggs_5.2.6.6-5.svg" },
|
/* 14*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, -1, -1, -1, "012345678905+24", "", "upca_2addon_ggs_5.2.6.6-5.svg" },
|
||||||
/* 15*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, -1, -1, -1, "614141234417+12345", "", "data/svg/upca_5addon.svg" },
|
/* 15*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, -1, -1, -1, "614141234417+12345", "", "upca_5addon.svg" },
|
||||||
/* 16*/ { BARCODE_UPCA, -1, 3, BARCODE_BIND, -1, -1, -1, -1, -1, "614141234417+12345", "", "data/svg/upca_5addon_bind3.svg" },
|
/* 16*/ { BARCODE_UPCA, -1, 3, BARCODE_BIND, -1, -1, -1, -1, -1, "614141234417+12345", "", "upca_5addon_bind3.svg" },
|
||||||
/* 17*/ { BARCODE_UPCA, -1, -1, SMALL_TEXT | BOLD_TEXT, -1, -1, -1, -1, -1, "614141234417+12345", "", "data/svg/upca_5addon_small_bold.svg" },
|
/* 17*/ { BARCODE_UPCA, -1, -1, SMALL_TEXT | BOLD_TEXT, -1, -1, -1, -1, -1, "614141234417+12345", "", "upca_5addon_small_bold.svg" },
|
||||||
/* 18*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, -1, -1, 1, -1, "12345678901+12", "[91]123456789", "data/svg/upca_cc_2addon_cca_3x4.svg" },
|
/* 18*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, -1, -1, 1, -1, "12345678901+12", "[91]123456789", "upca_cc_2addon_cca_3x4.svg" },
|
||||||
/* 19*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, -1, -1, 2, -1, "12345678901+12121", "[91]1234567890123", "data/svg/upca_cc_5addon_ccb_4x4.svg" },
|
/* 19*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, -1, -1, 2, -1, "12345678901+12121", "[91]1234567890123", "upca_cc_5addon_ccb_4x4.svg" },
|
||||||
/* 20*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, -1, 0, 2, -1, "12345678901+12121", "[91]1234567890123", "data/svg/upca_cc_5addon_ccb_4x4_notext.svg" },
|
/* 20*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, -1, 0, 2, -1, "12345678901+12121", "[91]1234567890123", "upca_cc_5addon_ccb_4x4_notext.svg" },
|
||||||
/* 21*/ { BARCODE_UPCA_CC, -1, 3, BARCODE_BIND, -1, -1, -1, 2, -1, "12345678901+12121", "[91]1234567890123", "data/svg/upca_cc_5addon_ccb_4x4_bind3.svg" },
|
/* 21*/ { BARCODE_UPCA_CC, -1, 3, BARCODE_BIND, -1, -1, -1, 2, -1, "12345678901+12121", "[91]1234567890123", "upca_cc_5addon_ccb_4x4_bind3.svg" },
|
||||||
/* 22*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, -1, -1, -1, "1234567+12", "", "data/svg/upce_2addon.svg" },
|
/* 22*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, -1, -1, -1, "1234567+12", "", "upce_2addon.svg" },
|
||||||
/* 23*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, -1, -1, -1, "1234567+12345", "", "data/svg/upce_5addon.svg" },
|
/* 23*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, -1, -1, -1, "1234567+12345", "", "upce_5addon.svg" },
|
||||||
/* 24*/ { BARCODE_UPCE, -1, -1, SMALL_TEXT, -1, -1, -1, -1, -1, "1234567+12345", "", "data/svg/upce_5addon_small.svg" },
|
/* 24*/ { BARCODE_UPCE, -1, -1, SMALL_TEXT, -1, -1, -1, -1, -1, "1234567+12345", "", "upce_5addon_small.svg" },
|
||||||
/* 25*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, 0, -1, -1, "1234567+12345", "", "data/svg/upce_5addon_notext.svg" },
|
/* 25*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, 0, -1, -1, "1234567+12345", "", "upce_5addon_notext.svg" },
|
||||||
/* 26*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, -1, 1, -1, "0654321+89", "[91]1", "data/svg/upce_cc_2addon_cca_5x2.svg" },
|
/* 26*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, -1, 1, -1, "0654321+89", "[91]1", "upce_cc_2addon_cca_5x2.svg" },
|
||||||
/* 27*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, -1, 2, -1, "1876543+56789", "[91]12345", "data/svg/upce_cc_5addon_ccb_8x2.svg" },
|
/* 27*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, -1, 2, -1, "1876543+56789", "[91]12345", "upce_cc_5addon_ccb_8x2.svg" },
|
||||||
/* 28*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, 0, 2, -1, "1876543+56789", "[91]12345", "data/svg/upce_cc_5addon_ccb_8x2_notext.svg" },
|
/* 28*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, 0, 2, -1, "1876543+56789", "[91]12345", "upce_cc_5addon_ccb_8x2_notext.svg" },
|
||||||
/* 29*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, "1234567+12", "", "data/svg/ean8_2addon.svg" },
|
/* 29*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, "1234567+12", "", "ean8_2addon.svg" },
|
||||||
/* 30*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, "1234567+12345", "", "data/svg/ean8_5addon.svg" },
|
/* 30*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, "1234567+12345", "", "ean8_5addon.svg" },
|
||||||
/* 31*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, 1, -1, "9876543+65", "[91]1234567", "data/svg/ean8_cc_2addon_cca_4x3.svg" },
|
/* 31*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, 1, -1, "9876543+65", "[91]1234567", "ean8_cc_2addon_cca_4x3.svg" },
|
||||||
/* 32*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, 2, -1, "9876543+74083", "[91]123456789012345678", "data/svg/ean8_cc_5addon_ccb_8x3.svg" },
|
/* 32*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, 2, -1, "9876543+74083", "[91]123456789012345678", "ean8_cc_5addon_ccb_8x3.svg" },
|
||||||
/* 33*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, "12345", "", "data/svg/ean5.svg" },
|
/* 33*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, "12345", "", "ean5.svg" },
|
||||||
/* 34*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, "12", "", "data/svg/ean2.svg" },
|
/* 34*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, "12", "", "ean2.svg" },
|
||||||
/* 35*/ { BARCODE_CODE39, -1, -1, SMALL_TEXT, -1, -1, -1, -1, -1, "123", "", "data/svg/code39_small.svg" },
|
/* 35*/ { BARCODE_CODE39, -1, -1, SMALL_TEXT, -1, -1, -1, -1, -1, "123", "", "code39_small.svg" },
|
||||||
/* 36*/ { BARCODE_POSTNET, -1, -1, -1, -1, -1, -1, -1, -1, "12345", "", "data/svg/postnet_zip.svg" },
|
/* 36*/ { BARCODE_POSTNET, -1, -1, -1, -1, -1, -1, -1, -1, "12345", "", "postnet_zip.svg" },
|
||||||
/* 37*/ { BARCODE_MAXICODE, -1, 2, BARCODE_BOX, -1, -1, -1, -1, -1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "data/svg/maxicode_box2.svg" },
|
/* 37*/ { BARCODE_MAXICODE, -1, 2, BARCODE_BOX, -1, -1, -1, -1, -1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "maxicode_box2.svg" },
|
||||||
/* 38*/ { BARCODE_MAXICODE, -1, 1, BARCODE_BIND, -1, 1, -1, -1, -1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "data/svg/maxicode_vwsp1_bind1.svg" },
|
/* 38*/ { BARCODE_MAXICODE, -1, 1, BARCODE_BIND, -1, 1, -1, -1, -1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "maxicode_vwsp1_bind1.svg" },
|
||||||
/* 39*/ { BARCODE_DATAMATRIX, -1, 1, BARCODE_BIND | BARCODE_DOTTY_MODE, -1, 1, -1, -1, -1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "data/svg/datamatrix_vwsp1_bind1_dotty.svg" },
|
/* 39*/ { BARCODE_DATAMATRIX, -1, 1, BARCODE_BIND | BARCODE_DOTTY_MODE, -1, 1, -1, -1, -1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "datamatrix_vwsp1_bind1_dotty.svg" },
|
||||||
/* 40*/ { BARCODE_DATAMATRIX, -1, 1, BARCODE_BIND | BARCODE_DOTTY_MODE, 1, 1, -1, -1, -1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "data/svg/datamatrix_hvwsp1_bind1_dotty.svg" },
|
/* 40*/ { BARCODE_DATAMATRIX, -1, 1, BARCODE_BIND | BARCODE_DOTTY_MODE, 1, 1, -1, -1, -1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "datamatrix_hvwsp1_bind1_dotty.svg" },
|
||||||
};
|
};
|
||||||
int data_size = ARRAY_SIZE(data);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
char *data_dir = "data/svg";
|
const char *data_dir = "/backend/tests/data/svg";
|
||||||
char *svg = "out.svg";
|
const char *svg = "out.svg";
|
||||||
|
char expected_file[1024];
|
||||||
char escaped[1024];
|
char escaped[1024];
|
||||||
int escaped_size = 1024;
|
int escaped_size = 1024;
|
||||||
char *text;
|
char *text;
|
||||||
@ -151,27 +152,29 @@ static void test_print(int index, int generate, int debug) {
|
|||||||
ret = ZBarcode_Print(symbol, 0);
|
ret = ZBarcode_Print(symbol, 0);
|
||||||
assert_zero(ret, "i:%d %s ZBarcode_Print %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, ret);
|
assert_zero(ret, "i:%d %s ZBarcode_Print %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, ret);
|
||||||
|
|
||||||
|
assert_nonzero(testUtilDataPath(expected_file, sizeof(expected_file), data_dir, data[i].expected_file), "i:%d testUtilDataPath == 0\n", i);
|
||||||
|
|
||||||
if (generate) {
|
if (generate) {
|
||||||
printf(" /*%3d*/ { %s, %s, %d, %s, %d, %d, %d, %d, %d, \"%s\", \"%s\", \"%s\" },\n",
|
printf(" /*%3d*/ { %s, %s, %d, %s, %d, %d, %d, %d, %d, \"%s\", \"%s\", \"%s\" },\n",
|
||||||
i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), data[i].border_width, testUtilOutputOptionsName(data[i].output_options),
|
i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), data[i].border_width, testUtilOutputOptionsName(data[i].output_options),
|
||||||
data[i].whitespace_width, data[i].whitespace_height, data[i].show_hrt, data[i].option_1, data[i].option_2,
|
data[i].whitespace_width, data[i].whitespace_height, data[i].show_hrt, data[i].option_1, data[i].option_2,
|
||||||
testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].composite, data[i].expected_file);
|
testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].composite, data[i].expected_file);
|
||||||
ret = rename(symbol->outfile, data[i].expected_file);
|
ret = rename(symbol->outfile, expected_file);
|
||||||
assert_zero(ret, "i:%d rename(%s, %s) ret %d != 0\n", i, symbol->outfile, data[i].expected_file, ret);
|
assert_zero(ret, "i:%d rename(%s, %s) ret %d != 0\n", i, symbol->outfile, expected_file, ret);
|
||||||
if (have_libreoffice) {
|
if (have_libreoffice) {
|
||||||
ret = testUtilVerifyLibreOffice(data[i].expected_file, debug);
|
ret = testUtilVerifyLibreOffice(expected_file, debug);
|
||||||
assert_zero(ret, "i:%d %s libreoffice %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), data[i].expected_file, ret);
|
assert_zero(ret, "i:%d %s libreoffice %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), expected_file, ret);
|
||||||
}
|
}
|
||||||
if (have_vnu) {
|
if (have_vnu) {
|
||||||
ret = testUtilVerifyVnu(data[i].expected_file, debug); // Very slow
|
ret = testUtilVerifyVnu(expected_file, debug); // Very slow
|
||||||
assert_zero(ret, "i:%d %s vnu libreoffice %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), data[i].expected_file, ret);
|
assert_zero(ret, "i:%d %s vnu libreoffice %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), expected_file, ret);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
assert_nonzero(testUtilExists(symbol->outfile), "i:%d testUtilExists(%s) == 0\n", i, symbol->outfile);
|
assert_nonzero(testUtilExists(symbol->outfile), "i:%d testUtilExists(%s) == 0\n", i, symbol->outfile);
|
||||||
assert_nonzero(testUtilExists(data[i].expected_file), "i:%d testUtilExists(%s) == 0\n", i, data[i].expected_file);
|
assert_nonzero(testUtilExists(expected_file), "i:%d testUtilExists(%s) == 0\n", i, expected_file);
|
||||||
|
|
||||||
ret = testUtilCmpSvgs(symbol->outfile, data[i].expected_file);
|
ret = testUtilCmpSvgs(symbol->outfile, expected_file);
|
||||||
assert_zero(ret, "i:%d %s testUtilCmpSvgs(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, data[i].expected_file, ret);
|
assert_zero(ret, "i:%d %s testUtilCmpSvgs(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, expected_file, ret);
|
||||||
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
|
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,26 +164,27 @@ static void test_print(int index, int generate, int debug) {
|
|||||||
char *comment;
|
char *comment;
|
||||||
};
|
};
|
||||||
struct item data[] = {
|
struct item data[] = {
|
||||||
/* 0*/ { BARCODE_CODE128, -1, -1, -1, 1, -1, -1, -1, 0, 0, "112233", "EEDDCC", "A", "", "data/tif/code128_fgbg.tif", "" },
|
/* 0*/ { BARCODE_CODE128, -1, -1, -1, 1, -1, -1, -1, 0, 0, "112233", "EEDDCC", "A", "", "code128_fgbg.tif", "" },
|
||||||
/* 1*/ { BARCODE_CODE128, -1, -1, -1, 1, -1, -1, -1, 0, 0, "C00000", "FEDCBACC", "A", "", "data/tif/code128_bgalpha.tif", "" },
|
/* 1*/ { BARCODE_CODE128, -1, -1, -1, 1, -1, -1, -1, 0, 0, "C00000", "FEDCBACC", "A", "", "code128_bgalpha.tif", "" },
|
||||||
/* 2*/ { BARCODE_CODE128, -1, -1, -1, 1, -1, -1, -1, 0, 0, "00000099", "FEDCBA", "A", "", "data/tif/code128_fgalpha.tif", "" },
|
/* 2*/ { BARCODE_CODE128, -1, -1, -1, 1, -1, -1, -1, 0, 0, "00000099", "FEDCBA", "A", "", "code128_fgalpha.tif", "" },
|
||||||
/* 3*/ { BARCODE_CODE128, -1, -1, -1, 1, -1, -1, -1, 0, 0, "00000099", "FEDCBACC", "A", "", "data/tif/code128_fgbgalpha.tif", "" },
|
/* 3*/ { BARCODE_CODE128, -1, -1, -1, 1, -1, -1, -1, 0, 0, "00000099", "FEDCBACC", "A", "", "code128_fgbgalpha.tif", "" },
|
||||||
/* 4*/ { BARCODE_CODE128, -1, -1, CMYK_COLOUR, 1, -1, -1, -1, 0, 0, "C00000", "FEDCBA", "A", "", "data/tif/code128_cmyk.tif", "" },
|
/* 4*/ { BARCODE_CODE128, -1, -1, CMYK_COLOUR, 1, -1, -1, -1, 0, 0, "C00000", "FEDCBA", "A", "", "code128_cmyk.tif", "" },
|
||||||
/* 5*/ { BARCODE_CODE128, -1, -1, CMYK_COLOUR, 1, -1, -1, -1, 0, 0, "C0000099", "FEDCBACC", "A", "", "data/tif/code128_cmyk_fgbgalpha.tif", "" },
|
/* 5*/ { BARCODE_CODE128, -1, -1, CMYK_COLOUR, 1, -1, -1, -1, 0, 0, "C0000099", "FEDCBACC", "A", "", "code128_cmyk_fgbgalpha.tif", "" },
|
||||||
/* 6*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, 0, 0, "C00000", "FEDCBACC", "1234", "", "data/tif/ultra_bgalpha.tif", "" },
|
/* 6*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, 0, 0, "C00000", "FEDCBACC", "1234", "", "ultra_bgalpha.tif", "" },
|
||||||
/* 7*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, 0, 0, "000000BB", "FEDCBA", "1234", "", "data/tif/ultra_fgalpha.tif", "" },
|
/* 7*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, 0, 0, "000000BB", "FEDCBA", "1234", "", "ultra_fgalpha.tif", "" },
|
||||||
/* 8*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, 0, 0, "000000BB", "FEDCBACC", "1234", "", "data/tif/ultra_fgbgalpha.tif", "" },
|
/* 8*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, 0, 0, "000000BB", "FEDCBACC", "1234", "", "ultra_fgbgalpha.tif", "" },
|
||||||
/* 9*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, 0, 0, "000000BB", "", "1234", "", "data/tif/ultra_fgalpha_nobg.tif", "" },
|
/* 9*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, 0, 0, "000000BB", "", "1234", "", "ultra_fgalpha_nobg.tif", "" },
|
||||||
/* 10*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, 0, 0, "", "FEDCBACC", "1234", "", "data/tif/ultra_bgalpha_nofg.tif", "" },
|
/* 10*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, 0, 0, "", "FEDCBACC", "1234", "", "ultra_bgalpha_nofg.tif", "" },
|
||||||
/* 11*/ { BARCODE_ULTRA, -1, -1, -1, -1, -1, -1, -1, 0, 0.5f, "", "", "1", "", "data/tif/ultra_odd.tif", "" },
|
/* 11*/ { BARCODE_ULTRA, -1, -1, -1, -1, -1, -1, -1, 0, 0.5f, "", "", "1", "", "ultra_odd.tif", "" },
|
||||||
/* 12*/ { BARCODE_HANXIN, UNICODE_MODE, -1, -1, -1, -1, 4, 84, 0, 2, "", "", "1", "", "data/tif/hanxin_v84_l4_scale2.tif", "" },
|
/* 12*/ { BARCODE_HANXIN, UNICODE_MODE, -1, -1, -1, -1, 4, 84, 0, 2, "", "", "1", "", "hanxin_v84_l4_scale2.tif", "" },
|
||||||
/* 13*/ { BARCODE_AZTEC, -1, -1, -1, -1, -1, -1, 32, 0, 0, "4BE055", "", "1", "", "data/tif/aztec_v32_fg.tif", "" },
|
/* 13*/ { BARCODE_AZTEC, -1, -1, -1, -1, -1, -1, 32, 0, 0, "4BE055", "", "1", "", "aztec_v32_fg.tif", "" },
|
||||||
/* 14*/ { BARCODE_DAFT, -1, -1, -1, -1, -1, -1, -1, 1, 0.5f, "", "", "F", "", "data/tif/daft_scale0.5.tif", "" },
|
/* 14*/ { BARCODE_DAFT, -1, -1, -1, -1, -1, -1, -1, 1, 0.5f, "", "", "F", "", "daft_scale0.5.tif", "" },
|
||||||
};
|
};
|
||||||
int data_size = ARRAY_SIZE(data);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
char *data_dir = "data/tif";
|
const char *data_dir = "/backend/tests/data/tif";
|
||||||
char *tif = "out.tif";
|
const char *tif = "out.tif";
|
||||||
|
char expected_file[1024];
|
||||||
char escaped[1024];
|
char escaped[1024];
|
||||||
int escaped_size = 1024;
|
int escaped_size = 1024;
|
||||||
char *text;
|
char *text;
|
||||||
@ -239,26 +240,28 @@ static void test_print(int index, int generate, int debug) {
|
|||||||
ret = ZBarcode_Print(symbol, 0);
|
ret = ZBarcode_Print(symbol, 0);
|
||||||
assert_zero(ret, "i:%d %s ZBarcode_Print %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, ret);
|
assert_zero(ret, "i:%d %s ZBarcode_Print %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, ret);
|
||||||
|
|
||||||
|
assert_nonzero(testUtilDataPath(expected_file, sizeof(expected_file), data_dir, data[i].expected_file), "i:%d testUtilDataPath == 0\n", i);
|
||||||
|
|
||||||
if (generate) {
|
if (generate) {
|
||||||
printf(" /*%3d*/ { %s, %s, %d, %s, %d, %d, %d, %d, %d, %.5g, \"%s\",\"%s\", \"%s\", \"%s\", \"%s\", \"%s\" },\n",
|
printf(" /*%3d*/ { %s, %s, %d, %s, %d, %d, %d, %d, %d, %.5g, \"%s\",\"%s\", \"%s\", \"%s\", \"%s\", \"%s\" },\n",
|
||||||
i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), data[i].border_width, testUtilOutputOptionsName(data[i].output_options),
|
i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), data[i].border_width, testUtilOutputOptionsName(data[i].output_options),
|
||||||
data[i].whitespace_width, data[i].show_hrt, data[i].option_1, data[i].option_2, data[i].height, data[i].scale, data[i].fgcolour, data[i].bgcolour,
|
data[i].whitespace_width, data[i].show_hrt, data[i].option_1, data[i].option_2, data[i].height, data[i].scale, data[i].fgcolour, data[i].bgcolour,
|
||||||
testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].composite, data[i].expected_file, data[i].comment);
|
testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].composite, data[i].expected_file, data[i].comment);
|
||||||
ret = rename(symbol->outfile, data[i].expected_file);
|
ret = rename(symbol->outfile, expected_file);
|
||||||
assert_zero(ret, "i:%d rename(%s, %s) ret %d != 0\n", i, symbol->outfile, data[i].expected_file, ret);
|
assert_zero(ret, "i:%d rename(%s, %s) ret %d != 0\n", i, symbol->outfile, expected_file, ret);
|
||||||
if (have_tiffinfo) {
|
if (have_tiffinfo) {
|
||||||
ret = testUtilVerifyTiffInfo(data[i].expected_file, debug);
|
ret = testUtilVerifyTiffInfo(expected_file, debug);
|
||||||
assert_zero(ret, "i:%d %s tiffinfo %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), data[i].expected_file, ret);
|
assert_zero(ret, "i:%d %s tiffinfo %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), expected_file, ret);
|
||||||
} else if (have_identify) {
|
} else if (have_identify) {
|
||||||
ret = testUtilVerifyIdentify(data[i].expected_file, debug);
|
ret = testUtilVerifyIdentify(expected_file, debug);
|
||||||
assert_zero(ret, "i:%d %s identify %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), data[i].expected_file, ret);
|
assert_zero(ret, "i:%d %s identify %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), expected_file, ret);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
assert_nonzero(testUtilExists(symbol->outfile), "i:%d testUtilExists(%s) == 0\n", i, symbol->outfile);
|
assert_nonzero(testUtilExists(symbol->outfile), "i:%d testUtilExists(%s) == 0\n", i, symbol->outfile);
|
||||||
assert_nonzero(testUtilExists(data[i].expected_file), "i:%d testUtilExists(%s) == 0\n", i, data[i].expected_file);
|
assert_nonzero(testUtilExists(expected_file), "i:%d testUtilExists(%s) == 0\n", i, expected_file);
|
||||||
|
|
||||||
ret = testUtilCmpBins(symbol->outfile, data[i].expected_file);
|
ret = testUtilCmpBins(symbol->outfile, expected_file);
|
||||||
assert_zero(ret, "i:%d %s testUtilCmpBins(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, data[i].expected_file, ret);
|
assert_zero(ret, "i:%d %s testUtilCmpBins(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, expected_file, ret);
|
||||||
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
|
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1130,8 +1130,92 @@ char *testUtilUCharArrayDump(unsigned char *array, int size, char *dump, int dum
|
|||||||
return dump;
|
return dump;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int testUtilDataPath(char *buffer, int buffer_size, const char *subdir, const char *filename) {
|
||||||
|
int subdir_len = subdir ? (int) strlen(subdir) : 0;
|
||||||
|
int filename_len = filename ? (int) strlen(filename) : 0;
|
||||||
|
int len;
|
||||||
|
#ifdef _WIN32
|
||||||
|
int i;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (getcwd(buffer, buffer_size) == NULL) {
|
||||||
|
fprintf(stderr, "testUtilDataPath: getcwd NULL buffer_size %d\n", buffer_size);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
len = (int) strlen(buffer);
|
||||||
|
if (len <= 0) {
|
||||||
|
fprintf(stderr, "testUtilDataPath: strlen <= 0\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#ifdef _WIN32
|
||||||
|
for (i = 0; i < len; i++) {
|
||||||
|
if (buffer[i] == '\\') {
|
||||||
|
buffer[i] = '/';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (buffer[len - 1] == '/') {
|
||||||
|
buffer[len--] = '\0';
|
||||||
|
}
|
||||||
|
if (len == 0) {
|
||||||
|
fprintf(stderr, "testUtilDataPath: len == 0\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (len > 6 && strcmp(buffer + len - 6, "/build") == 0) {
|
||||||
|
buffer[len - 6] = '\0';
|
||||||
|
len -= 6;
|
||||||
|
} else if (len > 14 && strcmp(buffer + len - 14, "/build/backend") == 0) {
|
||||||
|
buffer[len - 14] = '\0';
|
||||||
|
len -= 14;
|
||||||
|
} else if (len > 20 && strcmp(buffer + len - 20, "/build/backend/tests") == 0) {
|
||||||
|
buffer[len - 20] = '\0';
|
||||||
|
len -= 20;
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "testUtilDataPath: unrecognized dir '%s'\n", buffer);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (subdir_len) {
|
||||||
|
if (*subdir != '/' && buffer[len - 1] != '/') {
|
||||||
|
if (len + 1 >= buffer_size) {
|
||||||
|
fprintf(stderr, "testUtilDataPath: subdir len (%d) + 1 >= buffer_size (%d)\n", len, buffer_size);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
buffer[len++] = '/';
|
||||||
|
buffer[len] = '\0';
|
||||||
|
}
|
||||||
|
if (len + subdir_len >= buffer_size) {
|
||||||
|
fprintf(stderr, "testUtilDataPath: len (%d) + subdir_len (%d) >= buffer_size (%d)\n",
|
||||||
|
len, subdir_len, buffer_size);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
strcpy(buffer + len, subdir);
|
||||||
|
len += subdir_len;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filename_len) {
|
||||||
|
if (*filename != '/' && buffer[len - 1] != '/') {
|
||||||
|
if (len + 1 >= buffer_size) {
|
||||||
|
fprintf(stderr, "testUtilDataPath: filename len (%d) + 1 >= buffer_size (%d)\n", len, buffer_size);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
buffer[len++] = '/';
|
||||||
|
buffer[len] = '\0';
|
||||||
|
}
|
||||||
|
if (len + filename_len >= buffer_size) {
|
||||||
|
fprintf(stderr, "testUtilDataPath: len (%d) + filename_len (%d) >= buffer_size (%d)\n",
|
||||||
|
len, filename_len, buffer_size);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
strcpy(buffer + len, filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
void testUtilBitmapPrint(const struct zint_symbol *symbol, const char *prefix, const char *postfix) {
|
void testUtilBitmapPrint(const struct zint_symbol *symbol, const char *prefix, const char *postfix) {
|
||||||
static char colour[] = { '0', 'C', 'M', 'B', 'Y', 'G', 'R', '1' };
|
static const char colour[] = { '0', 'C', 'M', 'B', 'Y', 'G', 'R', '1' };
|
||||||
int row, column, i, j;
|
int row, column, i, j;
|
||||||
|
|
||||||
if (!prefix) {
|
if (!prefix) {
|
||||||
@ -1185,7 +1269,7 @@ void testUtilBitmapPrint(const struct zint_symbol *symbol, const char *prefix, c
|
|||||||
}
|
}
|
||||||
|
|
||||||
int testUtilBitmapCmp(const struct zint_symbol *symbol, const char *expected, int *row, int *column) {
|
int testUtilBitmapCmp(const struct zint_symbol *symbol, const char *expected, int *row, int *column) {
|
||||||
static char colour[] = { '0', 'C', 'M', 'B', 'Y', 'G', 'R', '1' };
|
static const char colour[] = { '0', 'C', 'M', 'B', 'Y', 'G', 'R', '1' };
|
||||||
int r, c = -1, i, j;
|
int r, c = -1, i, j;
|
||||||
const char *e = expected;
|
const char *e = expected;
|
||||||
const char *ep = expected + strlen(expected);
|
const char *ep = expected + strlen(expected);
|
||||||
@ -1229,7 +1313,7 @@ int testUtilBitmapCmp(const struct zint_symbol *symbol, const char *expected, in
|
|||||||
return e != ep || r != symbol->bitmap_height || c != symbol->bitmap_width ? 1 /*fail*/ : 0 /*success*/;
|
return e != ep || r != symbol->bitmap_height || c != symbol->bitmap_width ? 1 /*fail*/ : 0 /*success*/;
|
||||||
}
|
}
|
||||||
|
|
||||||
int testUtilExists(char *filename) {
|
int testUtilExists(const char *filename) {
|
||||||
FILE *fp = fopen(filename, "r");
|
FILE *fp = fopen(filename, "r");
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -1238,7 +1322,7 @@ int testUtilExists(char *filename) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int testUtilCmpPngs(char *png1, char *png2) {
|
int testUtilCmpPngs(const char *png1, const char *png2) {
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
#ifdef NO_PNG
|
#ifdef NO_PNG
|
||||||
(void)png1; (void)png2;
|
(void)png1; (void)png2;
|
||||||
@ -1433,7 +1517,7 @@ int testUtilCmpPngs(char *png1, char *png2) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int testUtilCmpTxts(char *txt1, char *txt2) {
|
int testUtilCmpTxts(const char *txt1, const char *txt2) {
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
FILE *fp1;
|
FILE *fp1;
|
||||||
FILE *fp2;
|
FILE *fp2;
|
||||||
@ -1483,7 +1567,7 @@ int testUtilCmpTxts(char *txt1, char *txt2) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int testUtilCmpBins(char *bin1, char *bin2) {
|
int testUtilCmpBins(const char *bin1, const char *bin2) {
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
FILE *fp1;
|
FILE *fp1;
|
||||||
FILE *fp2;
|
FILE *fp2;
|
||||||
@ -1523,11 +1607,11 @@ int testUtilCmpBins(char *bin1, char *bin2) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int testUtilCmpSvgs(char *svg1, char *svg2) {
|
int testUtilCmpSvgs(const char *svg1, const char *svg2) {
|
||||||
return testUtilCmpTxts(svg1, svg2);
|
return testUtilCmpTxts(svg1, svg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
int testUtilCmpEpss(char *eps1, char *eps2) {
|
int testUtilCmpEpss(const char *eps1, const char *eps2) {
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
FILE *fp1;
|
FILE *fp1;
|
||||||
FILE *fp2;
|
FILE *fp2;
|
||||||
@ -1594,7 +1678,7 @@ int testUtilHaveIdentify() {
|
|||||||
return system("identify --version > /dev/null") == 0;
|
return system("identify --version > /dev/null") == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int testUtilVerifyIdentify(char *filename, int debug) {
|
int testUtilVerifyIdentify(const char *filename, int debug) {
|
||||||
char cmd[512 + 128];
|
char cmd[512 + 128];
|
||||||
|
|
||||||
if (strlen(filename) > 512) {
|
if (strlen(filename) > 512) {
|
||||||
@ -1619,7 +1703,7 @@ int testUtilHaveLibreOffice() {
|
|||||||
return system("libreoffice --version > /dev/null") == 0;
|
return system("libreoffice --version > /dev/null") == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int testUtilVerifyLibreOffice(char *filename, int debug) {
|
int testUtilVerifyLibreOffice(const char *filename, int debug) {
|
||||||
char cmd[512 + 128];
|
char cmd[512 + 128];
|
||||||
char svg[512];
|
char svg[512];
|
||||||
char *slash, *dot;
|
char *slash, *dot;
|
||||||
@ -1694,7 +1778,7 @@ int testUtilHaveGhostscript() {
|
|||||||
return system("gs -v > /dev/null") == 0;
|
return system("gs -v > /dev/null") == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int testUtilVerifyGhostscript(char *filename, int debug) {
|
int testUtilVerifyGhostscript(const char *filename, int debug) {
|
||||||
char cmd[512 + 128];
|
char cmd[512 + 128];
|
||||||
|
|
||||||
if (strlen(filename) > 512) {
|
if (strlen(filename) > 512) {
|
||||||
@ -1716,7 +1800,7 @@ int testUtilHaveVnu() {
|
|||||||
return system("vnu --version > /dev/null 2>&1") == 0;
|
return system("vnu --version > /dev/null 2>&1") == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int testUtilVerifyVnu(char *filename, int debug) {
|
int testUtilVerifyVnu(const char *filename, int debug) {
|
||||||
char buf[512 + 128];
|
char buf[512 + 128];
|
||||||
|
|
||||||
if (strlen(filename) > 512) {
|
if (strlen(filename) > 512) {
|
||||||
@ -1737,7 +1821,7 @@ int testUtilHaveTiffInfo() {
|
|||||||
return system("tiffinfo -h > /dev/null") == 0;
|
return system("tiffinfo -h > /dev/null") == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int testUtilVerifyTiffInfo(char *filename, int debug) {
|
int testUtilVerifyTiffInfo(const char *filename, int debug) {
|
||||||
char cmd[512 + 128];
|
char cmd[512 + 128];
|
||||||
|
|
||||||
if (strlen(filename) > 512) {
|
if (strlen(filename) > 512) {
|
||||||
|
@ -135,24 +135,25 @@ int testUtilModulesCmpRow(const struct zint_symbol *symbol, int row, const char
|
|||||||
int testUtilModulesDumpHex(const struct zint_symbol *symbol, char dump[], int dump_size);
|
int testUtilModulesDumpHex(const struct zint_symbol *symbol, char dump[], int dump_size);
|
||||||
char *testUtilUIntArrayDump(unsigned int *array, int size, char *dump, int dump_size);
|
char *testUtilUIntArrayDump(unsigned int *array, int size, char *dump, int dump_size);
|
||||||
char *testUtilUCharArrayDump(unsigned char *array, int size, char *dump, int dump_size);
|
char *testUtilUCharArrayDump(unsigned char *array, int size, char *dump, int dump_size);
|
||||||
|
int testUtilDataPath(char *buffer, int buffer_size, const char *subdir, const char *filename);
|
||||||
void testUtilBitmapPrint(const struct zint_symbol *symbol, const char *prefix, const char *postfix);
|
void testUtilBitmapPrint(const struct zint_symbol *symbol, const char *prefix, const char *postfix);
|
||||||
int testUtilBitmapCmp(const struct zint_symbol *symbol, const char *expected, int *row, int *column);
|
int testUtilBitmapCmp(const struct zint_symbol *symbol, const char *expected, int *row, int *column);
|
||||||
int testUtilExists(char *filename);
|
int testUtilExists(const char *filename);
|
||||||
int testUtilCmpPngs(char *file1, char *file2);
|
int testUtilCmpPngs(const char *file1, const char *file2);
|
||||||
int testUtilCmpTxts(char *txt1, char *txt2);
|
int testUtilCmpTxts(const char *txt1, const char *txt2);
|
||||||
int testUtilCmpBins(char *bin1, char *bin2);
|
int testUtilCmpBins(const char *bin1, const char *bin2);
|
||||||
int testUtilCmpSvgs(char *svg1, char *svg2);
|
int testUtilCmpSvgs(const char *svg1, const char *svg2);
|
||||||
int testUtilCmpEpss(char *eps1, char *eps2);
|
int testUtilCmpEpss(const char *eps1, const char *eps2);
|
||||||
int testUtilHaveIdentify();
|
int testUtilHaveIdentify();
|
||||||
int testUtilVerifyIdentify(char *filename, int debug);
|
int testUtilVerifyIdentify(const char *filename, int debug);
|
||||||
int testUtilHaveLibreOffice();
|
int testUtilHaveLibreOffice();
|
||||||
int testUtilVerifyLibreOffice(char *filename, int debug);
|
int testUtilVerifyLibreOffice(const char *filename, int debug);
|
||||||
int testUtilHaveGhostscript();
|
int testUtilHaveGhostscript();
|
||||||
int testUtilVerifyGhostscript(char *filename, int debug);
|
int testUtilVerifyGhostscript(const char *filename, int debug);
|
||||||
int testUtilHaveVnu();
|
int testUtilHaveVnu();
|
||||||
int testUtilVerifyVnu(char *filename, int debug);
|
int testUtilVerifyVnu(const char *filename, int debug);
|
||||||
int testUtilHaveTiffInfo();
|
int testUtilHaveTiffInfo();
|
||||||
int testUtilVerifyTiffInfo(char *filename, int debug);
|
int testUtilVerifyTiffInfo(const char *filename, int debug);
|
||||||
int testUtilCanBwipp(int index, const struct zint_symbol *symbol, int option_1, int option_2, int option_3,
|
int testUtilCanBwipp(int index, const struct zint_symbol *symbol, int option_1, int option_2, int option_3,
|
||||||
int debug);
|
int debug);
|
||||||
int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int option_2, int option_3,
|
int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int option_2, int option_3,
|
||||||
|
@ -18,8 +18,8 @@ Make sure git and cmake are in your PATH, e.g. (your paths may differ)
|
|||||||
Download zint, zlib and libpng by going to the directory you want to clone them
|
Download zint, zlib and libpng by going to the directory you want to clone them
|
||||||
into:
|
into:
|
||||||
|
|
||||||
set "PROJECT_DIR=<project-directory>"
|
cd <project-directory>
|
||||||
cd %PROJECT_DIR%
|
set "PROJECT_DIR=%cd%"
|
||||||
|
|
||||||
and cloning each:
|
and cloning each:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user