mirror of
https://git.code.sf.net/p/zint/code
synced 2025-05-31 15:18:29 -04:00
- API: add new zint_symbol dpmm
field for output resolution (BMP/
EMF/PCX/PNG/TIF only, i.e. excluding EPS, GIF & SVG) - Add support for specifying scale by X-dimension and resolution with new option `--scalexdimdp` for CLI/Tcl & new API function `ZBarcode_Scale_From_XdimDp()` (+ `ZBarcode_XdimDp_From_Scale()` & `ZBarcode_Default_Xdim()`) and new GUI popup; manual: document - BMP/EMF/PCX/PNG/TIF: use new `dpmm` resolution field (for EMF following Inkscape) - backend_qt: add `dpmm()`, `vectorWidth()`, `vectorHeight()`, `noPng()`, `getVersion()`, `takesGS1AIData()`, & `XdimDp` stuff incl. new `QZintXdimDp` struct for passing around scale vars & use in `getAsCLI()`; add comments - Raise `scale` limit to 200 (from 100) to allow for large dpmm - output: create directories & subdirectories as necessary for output path using new function `out_fopen()` and use in BMP/EMF/ EPS/GIF/PCX/PNG/SVG/TIF - DPLEIT/DPIDENT: format HRT according to (incomplete) documentation, and set default height to 72X (from 50X) - CODE128B renamed to CODE128AB as can use subsets A and/or B - CODABAR: fix minimum height calc - EMF: fix indexing of handles (zero-based not 1-based) - GUI: fix symbology zap (previous technique of clearing and re-loading settings without doing a sync no longer works); fix UPCEAN guard descent enable - MAILMARK: better error message if input < 14 characters - GUI: add "Default" button for DAFT tracker ratio & enable/disable various default buttons; use new `takesGS1AIData()` to enable/disable GS1-specific checkboxes - CLI: use new `validate_float()` to parse float options (7 significant digits allowed only, no scientific notation) - DATAMATRIX/GRIDMATRIX/PDF417/QR/ULTRA: micro-optimize structapp ID parse - library/CLI: fiddle with static asserts (make CHAR_BIT sensitive, supposedly) - win32/README: update building libpng (assembly removed) - README.linux: document incompatibility of Qt6 >= 6.3 - manual: expand Barcode Studio waffle - test suite: change range separator to hyphen and allow multiple excludes
This commit is contained in:
parent
6393813cff
commit
c8033695d9
127 changed files with 4032 additions and 1248 deletions
|
@ -62,21 +62,25 @@ To run a single dataset item in a single test function, use '-i <index>':
|
|||
|
||||
backend/tests/test_dotcode -f input -i 2
|
||||
|
||||
To run a range of dataset items in a single test function, use '-i <start>,<end>':
|
||||
To run a range of dataset items in a single test function, use '-i <start>-<end>':
|
||||
|
||||
backend/tests/test_dotcode -f input -i 2,5
|
||||
backend/tests/test_dotcode -f input -i 2-5
|
||||
|
||||
To exclude a single dataset item in a single test function, use '-x <index>':
|
||||
|
||||
backend/tests/test_dotcode -f input -x 4
|
||||
|
||||
This can also take a range, '-x <start>,<end>':
|
||||
This can also take a range, '-x <start>-<end>':
|
||||
|
||||
backend/tests/test_dotcode -f input -x 4,6
|
||||
|
||||
Exclude can be used multiple times (unlike '-i'):
|
||||
|
||||
backend/tests/test_dotcode -f input -x 4 -x 6-8
|
||||
|
||||
The include and exclude options can be used together:
|
||||
|
||||
backend/tests/test_dotcode -f input -i 2,7 -x 4
|
||||
backend/tests/test_dotcode -f input -i 2-7 -x 4 -x 6
|
||||
|
||||
To show debug info (if any), use '-d <flag>':
|
||||
|
||||
|
|
Binary file not shown.
BIN
backend/tests/data/emf/code128_egrave_bold_100dpi.emf
Normal file
BIN
backend/tests/data/emf/code128_egrave_bold_100dpi.emf
Normal file
Binary file not shown.
BIN
backend/tests/data/emf/code128_egrave_bold_1200dpi.emf
Normal file
BIN
backend/tests/data/emf/code128_egrave_bold_1200dpi.emf
Normal file
Binary file not shown.
BIN
backend/tests/data/emf/code128_egrave_bold_150dpi.emf
Normal file
BIN
backend/tests/data/emf/code128_egrave_bold_150dpi.emf
Normal file
Binary file not shown.
BIN
backend/tests/data/emf/code128_egrave_bold_300dpi.emf
Normal file
BIN
backend/tests/data/emf/code128_egrave_bold_300dpi.emf
Normal file
Binary file not shown.
BIN
backend/tests/data/emf/code128_egrave_bold_400dpi.emf
Normal file
BIN
backend/tests/data/emf/code128_egrave_bold_400dpi.emf
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
backend/tests/data/emf/code39_rotate_90_300dpi.emf
Normal file
BIN
backend/tests/data/emf/code39_rotate_90_300dpi.emf
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
backend/tests/data/emf/itf14_bold_600dpi.emf
Normal file
BIN
backend/tests/data/emf/itf14_bold_600dpi.emf
Normal file
Binary file not shown.
Binary file not shown.
BIN
backend/tests/data/emf/maxicode_#185_150dpi.emf
Normal file
BIN
backend/tests/data/emf/maxicode_#185_150dpi.emf
Normal file
Binary file not shown.
BIN
backend/tests/data/emf/maxicode_#185_600dpi.emf
Normal file
BIN
backend/tests/data/emf/maxicode_#185_600dpi.emf
Normal file
Binary file not shown.
Binary file not shown.
BIN
backend/tests/data/emf/maxicode_rotate_90_nobg_300dpi.emf
Normal file
BIN
backend/tests/data/emf/maxicode_rotate_90_nobg_300dpi.emf
Normal file
Binary file not shown.
Binary file not shown.
BIN
backend/tests/data/emf/telenum_fg_bg_150dpi.emf
Normal file
BIN
backend/tests/data/emf/telenum_fg_bg_150dpi.emf
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
backend/tests/data/emf/ultracode_fg_bg_box2_600dpi.emf
Normal file
BIN
backend/tests/data/emf/ultracode_fg_bg_box2_600dpi.emf
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
backend/tests/data/emf/upce_2addon_150dpi.emf
Normal file
BIN
backend/tests/data/emf/upce_2addon_150dpi.emf
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -135,10 +135,10 @@ static void test_hrt(const testCtx *const p_ctx) {
|
|||
/* 15*/ { BARCODE_C25IND, -1, "123456789", "123456789" },
|
||||
/* 16*/ { BARCODE_C25IND, 1, "123456789", "1234567895" },
|
||||
/* 17*/ { BARCODE_C25IND, 2, "123456789", "123456789" },
|
||||
/* 18*/ { BARCODE_DPLEIT, -1, "123456789", "00001234567890" }, /* Leading zeroes added to make 13 + appended checksum */
|
||||
/* 19*/ { BARCODE_DPLEIT, -1, "1234567890123", "12345678901236" },
|
||||
/* 20*/ { BARCODE_DPIDENT, -1, "123456789", "001234567890" }, /* Leading zeroes added to make 11 + appended checksum */
|
||||
/* 21*/ { BARCODE_DPIDENT, -1, "12345678901", "123456789016" },
|
||||
/* 18*/ { BARCODE_DPLEIT, -1, "123456789", "00001.234.567.890" }, /* Leading zeroes added to make 13 + appended checksum */
|
||||
/* 19*/ { BARCODE_DPLEIT, -1, "1234567890123", "12345.678.901.236" },
|
||||
/* 20*/ { BARCODE_DPIDENT, -1, "123456789", "00.12 3.456.789 0" }, /* Leading zeroes added to make 11 + appended checksum */
|
||||
/* 21*/ { BARCODE_DPIDENT, -1, "12345678901", "12.34 5.678.901 6" },
|
||||
/* 22*/ { BARCODE_ITF14, -1, "123456789", "00001234567895" }, /* Leading zeroes added to make 13 + appended checksum */
|
||||
/* 23*/ { BARCODE_ITF14, -1, "1234567890123", "12345678901231" },
|
||||
};
|
||||
|
@ -282,25 +282,31 @@ static void test_encode(const testCtx *const p_ctx) {
|
|||
/* 15*/ { BARCODE_DPLEIT, -1, "0000087654321", 0, 1, 135, "Deutsche Post Leitcode; verified manually against tec-it",
|
||||
"101010101110001110001010101110001110001010001011101110001010100010001110111011101011100010100011101110001010100011101000100010111011101"
|
||||
},
|
||||
/* 16*/ { BARCODE_DPLEIT, -1, "5082300702800", 0, 1, 135, "Deutsche Post Leitcode https://de.wikipedia.org/wiki/Leitcode example",
|
||||
/* 16*/ { BARCODE_DPLEIT, -1, "2045703000360", 0, 1, 135, "Deutsche Post DIALOGPOST SCHWER brochure 3.1 example",
|
||||
"101010111010001000111010001011100010111010101000111000111011101110100010001010101110001110001011101110001000101010001011100011101011101"
|
||||
},
|
||||
/* 17*/ { BARCODE_DPLEIT, -1, "5082300702800", 0, 1, 135, "Deutsche Post Leitcode https://de.wikipedia.org/wiki/Leitcode example",
|
||||
"101011101011100010001011101000101110100011101110100010001010101110111000100010100011101110100011101010001110001010001011100011101011101"
|
||||
},
|
||||
/* 17*/ { BARCODE_DPIDENT, -1, "00087654321", 0, 1, 117, "Deutsche Post Identcode; verified manually against tec-it",
|
||||
/* 18*/ { BARCODE_DPIDENT, -1, "00087654321", 0, 1, 117, "Deutsche Post Identcode; verified manually against tec-it (HRT differently formatted)",
|
||||
"101010101110001110001010001011101110001010100010001110111011101011100010100011101110001010100011101000100010111011101"
|
||||
},
|
||||
/* 18*/ { BARCODE_DPIDENT, -1, "39601313414", 0, 1, 117, "Deutsche Post Identcode https://de.wikipedia.org/wiki/Leitcode example",
|
||||
/* 19*/ { BARCODE_DPIDENT, -1, "80420000001", 0, 1, 117, "Deutsche Post DIALOGPOST SCHWER brochure 3.1 example",
|
||||
"101011101010001110001010100011101011100010101110001110001010101110001110001010101110001110001011101010001000111011101"
|
||||
},
|
||||
/* 20*/ { BARCODE_DPIDENT, -1, "39601313414", 0, 1, 117, "Deutsche Post Identcode https://de.wikipedia.org/wiki/Leitcode example",
|
||||
"101011101110001010001010111011100010001011100010001010111011100010001010111010001011101011100010101110001000111011101"
|
||||
},
|
||||
/* 19*/ { BARCODE_ITF14, -1, "0000087654321", 0, 1, 135, "ITF-14; verified manually against tec-it",
|
||||
/* 21*/ { BARCODE_ITF14, -1, "0000087654321", 0, 1, 135, "ITF-14; verified manually against tec-it",
|
||||
"101010101110001110001010101110001110001010001011101110001010100010001110111011101011100010100011101110001010100011101000101011100011101"
|
||||
},
|
||||
/* 20*/ { BARCODE_ITF14, -1, "0950110153000", 0, 1, 135, "GS1 General Specifications Figure 5.1-2",
|
||||
/* 22*/ { BARCODE_ITF14, -1, "0950110153000", 0, 1, 135, "GS1 General Specifications Figure 5.1-2",
|
||||
"101010100011101110001011101011100010001011100010101011100010001011101110100011100010001110101010101110001110001010001000111011101011101"
|
||||
},
|
||||
/* 21*/ { BARCODE_ITF14, -1, "1540014128876", 0, 1, 135, "GS1 General Specifications Figure 5.3.2.4-1",
|
||||
/* 23*/ { BARCODE_ITF14, -1, "1540014128876", 0, 1, 135, "GS1 General Specifications Figure 5.3.2.4-1",
|
||||
"101011100010100010111010101110001000111010001011101110100010001011101011100010001110101000111011101010111000100010001110001110101011101"
|
||||
},
|
||||
/* 22*/ { BARCODE_ITF14, -1, "0950110153001", 0, 1, 135, "GS1 General Specifications Figure 5.3.6-1",
|
||||
/* 24*/ { BARCODE_ITF14, -1, "0950110153001", 0, 1, 135, "GS1 General Specifications Figure 5.3.6-1",
|
||||
"101010100011101110001011101011100010001011100010101011100010001011101110100011100010001110101010101110001110001011101010001000111011101"
|
||||
},
|
||||
};
|
||||
|
|
|
@ -65,7 +65,7 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
|
|||
|
||||
char data_buf[8 * 2 + 1];
|
||||
|
||||
int have_identify = testUtilHaveIdentify();
|
||||
const char *const have_identify = testUtilHaveIdentify();
|
||||
|
||||
testStart("test_pixel_plot");
|
||||
|
||||
|
@ -104,7 +104,7 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
|
|||
|
||||
if (ret < ZINT_ERROR) {
|
||||
if (have_identify) {
|
||||
ret = testUtilVerifyIdentify(symbol->outfile, debug);
|
||||
ret = testUtilVerifyIdentify(have_identify, symbol->outfile, debug);
|
||||
assert_zero(ret, "i:%d identify %s ret %d != 0\n", i, symbol->outfile, ret);
|
||||
}
|
||||
if (!(debug & ZINT_DEBUG_TEST_KEEP_OUTFILE)) {
|
||||
|
@ -156,7 +156,7 @@ static void test_print(const testCtx *const p_ctx) {
|
|||
char escaped[1024];
|
||||
int escaped_size = 1024;
|
||||
|
||||
int have_identify = testUtilHaveIdentify();
|
||||
const char *const have_identify = testUtilHaveIdentify();
|
||||
|
||||
testStart("test_print");
|
||||
|
||||
|
@ -211,7 +211,7 @@ static void test_print(const testCtx *const p_ctx) {
|
|||
ret = testUtilRename(symbol->outfile, expected_file);
|
||||
assert_zero(ret, "i:%d testUtilRename(%s, %s) ret %d != 0 (%d: %s)\n", i, symbol->outfile, expected_file, ret, errno, strerror(errno));
|
||||
if (have_identify) {
|
||||
ret = testUtilVerifyIdentify(expected_file, debug);
|
||||
ret = testUtilVerifyIdentify(have_identify, expected_file, debug);
|
||||
assert_zero(ret, "i:%d %s identify %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), expected_file, ret);
|
||||
}
|
||||
} else {
|
||||
|
@ -242,10 +242,13 @@ static void test_outfile(const testCtx *const p_ctx) {
|
|||
symbol.bitmap = data;
|
||||
symbol.bitmap_width = symbol.bitmap_height = 1;
|
||||
|
||||
strcpy(symbol.outfile, "nosuch_dir/out.bmp");
|
||||
strcpy(symbol.outfile, "test_bmp_out.bmp");
|
||||
(void) testUtilRmROFile(symbol.outfile); /* In case lying around from previous fail */
|
||||
assert_nonzero(testUtilCreateROFile(symbol.outfile), "bmp_pixel_plot testUtilCreateROFile(%s) fail (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
ret = bmp_pixel_plot(&symbol, data);
|
||||
assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "bmp_pixel_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt);
|
||||
assert_zero(testUtilRmROFile(symbol.outfile), "bmp_pixel_plot testUtilRmROFile(%s) != 0 (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
symbol.output_options |= BARCODE_STDOUT;
|
||||
|
||||
|
|
|
@ -55,10 +55,10 @@ static void test_large(const testCtx *const p_ctx) {
|
|||
/* 4*/ { BARCODE_CODE128, "\351A", 41, ZINT_ERROR_TOO_LONG, -1 }, /* 41 chars (+ 20 shifts) */
|
||||
/* 5*/ { BARCODE_CODE128, "0", 120, 0, 695 },
|
||||
/* 6*/ { BARCODE_CODE128, "0", 121, ZINT_ERROR_TOO_LONG, -1 },
|
||||
/* 7*/ { BARCODE_CODE128B, "A", 60, 0, 695 },
|
||||
/* 8*/ { BARCODE_CODE128B, "A", 61, ZINT_ERROR_TOO_LONG, -1 },
|
||||
/* 9*/ { BARCODE_CODE128B, "0", 60, 0, 695 },
|
||||
/* 10*/ { BARCODE_CODE128B, "0", 61, ZINT_ERROR_TOO_LONG, -1 },
|
||||
/* 7*/ { BARCODE_CODE128AB, "A", 60, 0, 695 },
|
||||
/* 8*/ { BARCODE_CODE128AB, "A", 61, ZINT_ERROR_TOO_LONG, -1 },
|
||||
/* 9*/ { BARCODE_CODE128AB, "0", 60, 0, 695 },
|
||||
/* 10*/ { BARCODE_CODE128AB, "0", 61, ZINT_ERROR_TOO_LONG, -1 },
|
||||
/* 11*/ { BARCODE_GS1_128, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]1234567890", -1, 0, 706 }, /* 116 nos + 3 FNC1s */
|
||||
/* 12*/ { BARCODE_GS1_128, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]1234[93]1234", -1, ZINT_ERROR_TOO_LONG, -1 }, /* 116 nos + 4 FNC1s */
|
||||
/* 13*/ { BARCODE_GS1_128, "A", 161, ZINT_ERROR_TOO_LONG, -1 },
|
||||
|
@ -198,13 +198,13 @@ static void test_hrt(const testCtx *const p_ctx) {
|
|||
struct item data[] = {
|
||||
/* 0*/ { BARCODE_CODE128, UNICODE_MODE, -1, "1234567890", -1, "1234567890" },
|
||||
/* 1*/ { BARCODE_CODE128, UNICODE_MODE, -1, "\000ABC\000DEF\000", 9, " ABC DEF " },
|
||||
/* 2*/ { BARCODE_CODE128B, UNICODE_MODE, -1, "12345\00067890", 11, "12345 67890" },
|
||||
/* 2*/ { BARCODE_CODE128AB, UNICODE_MODE, -1, "12345\00067890", 11, "12345 67890" },
|
||||
/* 3*/ { BARCODE_CODE128, UNICODE_MODE, -1, "12345\01167890\037\177", -1, "12345 67890 " },
|
||||
/* 4*/ { BARCODE_CODE128, UNICODE_MODE, -1, "abcdé", -1, "abcdé" },
|
||||
/* 5*/ { BARCODE_CODE128, DATA_MODE, -1, "abcd\351", -1, "abcdé" },
|
||||
/* 6*/ { BARCODE_CODE128, DATA_MODE, -1, "ab\240cd\351", -1, "ab\302\240cdé" }, /* NBSP */
|
||||
/* 7*/ { BARCODE_CODE128B, UNICODE_MODE, -1, "abcdé", -1, "abcdé" },
|
||||
/* 8*/ { BARCODE_CODE128B, DATA_MODE, -1, "abcd\351", -1, "abcdé" },
|
||||
/* 7*/ { BARCODE_CODE128AB, UNICODE_MODE, -1, "abcdé", -1, "abcdé" },
|
||||
/* 8*/ { BARCODE_CODE128AB, DATA_MODE, -1, "abcd\351", -1, "abcdé" },
|
||||
/* 9*/ { BARCODE_HIBC_128, UNICODE_MODE, -1, "1234567890", -1, "*+12345678900*" },
|
||||
/* 10*/ { BARCODE_HIBC_128, UNICODE_MODE, -1, "a99912345", -1, "*+A999123457*" }, /* Converts to upper */
|
||||
/* 11*/ { BARCODE_DPD, UNICODE_MODE, -1, "000393206219912345678101040", -1, "0003 932 0621 9912 3456 78 101 040 9" }, /* DPDAPPD 4.0.2 - Illustration 7 */
|
||||
|
@ -281,7 +281,7 @@ static void test_reader_init(const testCtx *const p_ctx) {
|
|||
struct item data[] = {
|
||||
/* 0*/ { BARCODE_CODE128, UNICODE_MODE, READER_INIT, "A", 0, 1, 57, "(5) 104 96 33 60 106", "StartA FNC3 A" },
|
||||
/* 1*/ { BARCODE_CODE128, UNICODE_MODE, READER_INIT, "12", 0, 1, 68, "(6) 104 96 99 12 22 106", "StartB FNC3 CodeC 12" },
|
||||
/* 2*/ { BARCODE_CODE128B, UNICODE_MODE, READER_INIT, "\0371234", 0, 1, 101, "(9) 103 96 95 17 18 19 20 6 106", "StartA FNC3 US 1 2 3 4" },
|
||||
/* 2*/ { BARCODE_CODE128AB, UNICODE_MODE, READER_INIT, "\0371234", 0, 1, 101, "(9) 103 96 95 17 18 19 20 6 106", "StartA FNC3 US 1 2 3 4" },
|
||||
/* 3*/ { BARCODE_GS1_128, GS1_MODE, READER_INIT, "[90]12", 0, 1, 68, "(6) 105 102 90 12 11 106", "StartC FNC1 90 12 (Reader Initialise not supported by GS1 barcodes (use CODE128))" },
|
||||
/* 4*/ { BARCODE_EAN14, GS1_MODE, READER_INIT, "12", 0, 1, 134, "(12) 105 102 1 0 0 0 0 0 1 23 12 106", "StartC FNC1 01 00 (5) 01 23 (Reader Initialise not supported by GS1 barcodes (use CODE128))" },
|
||||
/* 5*/ { BARCODE_NVE18, GS1_MODE, READER_INIT, "12", 0, 1, 156, "(14) 105 102 0 0 0 0 0 0 0 0 1 23 58 106", "StartC FNC1 00 (8) 01 23 (Reader Initialise not supported by GS1 barcodes (use CODE128))" },
|
||||
|
@ -766,13 +766,13 @@ static void test_encode(const testCtx *const p_ctx) {
|
|||
/* 0*/ { BARCODE_CODE128, UNICODE_MODE, -1, "AIM", 0, 1, 68, 1, "ISO/IEC 15417:2007 Figure 1",
|
||||
"11010010000101000110001100010001010111011000101110110001100011101011"
|
||||
},
|
||||
/* 1*/ { BARCODE_CODE128B, UNICODE_MODE, -1, "AIM", 0, 1, 68, 1, "128B same",
|
||||
/* 1*/ { BARCODE_CODE128AB, UNICODE_MODE, -1, "AIM", 0, 1, 68, 1, "128B same",
|
||||
"11010010000101000110001100010001010111011000101110110001100011101011"
|
||||
},
|
||||
/* 2*/ { BARCODE_CODE128, UNICODE_MODE, -1, "1234567890", 0, 1, 90, 1, "",
|
||||
"110100111001011001110010001011000111000101101100001010011011110110100111100101100011101011"
|
||||
},
|
||||
/* 3*/ { BARCODE_CODE128B, UNICODE_MODE, -1, "1234567890", 0, 1, 145, 1, "",
|
||||
/* 3*/ { BARCODE_CODE128AB, UNICODE_MODE, -1, "1234567890", 0, 1, 145, 1, "",
|
||||
"1101001000010011100110110011100101100101110011001001110110111001001100111010011101101110111010011001110010110010011101100101000110001100011101011"
|
||||
},
|
||||
/* 4*/ { BARCODE_CODE128, DATA_MODE, -1, "\101\102\103\104\105\106\200\200\200\200\200", 0, 1, 178, 1, "",
|
||||
|
|
|
@ -266,9 +266,9 @@ static void test_reduced_charset_input(const testCtx *const p_ctx) {
|
|||
/*121*/ { BARCODE_MAXICODE, UNICODE_MODE, 29, "齄齄", 0, 29, "U+9F44 in GB2312 but not in Big5" },
|
||||
/*122*/ { BARCODE_MAXICODE, UNICODE_MODE, 30, "가", 0, 30, "U+AC00 in EUC-KR" },
|
||||
/*123*/ { BARCODE_MAXICODE, UNICODE_MODE, 30, "가가", 0, 30, "U+AC00 in EUC-KR" },
|
||||
/*124*/ { BARCODE_CODE128B, UNICODE_MODE, 0, "é", 0, 0, "" },
|
||||
/*125*/ { BARCODE_CODE128B, UNICODE_MODE, 3, "é", ZINT_ERROR_INVALID_OPTION, -1, "Does not support ECI" },
|
||||
/*126*/ { BARCODE_CODE128B, UNICODE_MODE, 0, "β", ZINT_ERROR_INVALID_DATA, -1, "β not in ISO 8859-1" },
|
||||
/*124*/ { BARCODE_CODE128AB, UNICODE_MODE, 0, "é", 0, 0, "" },
|
||||
/*125*/ { BARCODE_CODE128AB, UNICODE_MODE, 3, "é", ZINT_ERROR_INVALID_OPTION, -1, "Does not support ECI" },
|
||||
/*126*/ { BARCODE_CODE128AB, UNICODE_MODE, 0, "β", ZINT_ERROR_INVALID_DATA, -1, "β not in ISO 8859-1" },
|
||||
/*127*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 0, "é", 0, 0, "" },
|
||||
/*128*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 3, "é", 0, 3, "Supports ECI" },
|
||||
/*129*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 0, "β", ZINT_WARN_USES_ECI, 9, "" },
|
||||
|
|
|
@ -44,6 +44,7 @@ static void test_print(const testCtx *const p_ctx) {
|
|||
int whitespace_height;
|
||||
int option_1;
|
||||
int option_2;
|
||||
float dpmm;
|
||||
char *fgcolour;
|
||||
char *bgcolour;
|
||||
int rotate_angle;
|
||||
|
@ -52,21 +53,34 @@ static void test_print(const testCtx *const p_ctx) {
|
|||
char *comment;
|
||||
};
|
||||
struct item data[] = {
|
||||
/* 0*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, "", "", 0, "Égjpqy", "code128_egrave_bold.emf", "" },
|
||||
/* 1*/ { BARCODE_TELEPEN, -1, -1, -1, -1, -1, -1, -1, "147AD0", "FC9630", 0, "123", "telenum_fg_bg.emf", "" },
|
||||
/* 2*/ { BARCODE_ULTRA, -1, -1, -1, 5, -1, -1, -1, "147AD0", "FC9630", 0, "123", "ultracode_fg_bg.emf", "" },
|
||||
/* 3*/ { BARCODE_ULTRA, -1, 2, BARCODE_BOX, 2, 2, -1, -1, "FF0000", "0000FF", 0, "123", "ultracode_fg_bg_box2.emf", "" },
|
||||
/* 4*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, "", "", 0, "9780877799306+54321", "ean13_5addon_ggs_5.2.2.5.2-2.emf", "" },
|
||||
/* 5*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, "", "", 0, "210987654321+54321", "ean13_5addon_#185.emf", "#185 Byte count, font data, HeaderExtension1/2" },
|
||||
/* 6*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, -1, -1, "", "", 0, "012345678905+24", "upca_2addon_ggs_5.2.6.6-5.emf", "" },
|
||||
/* 7*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, -1, -1, "", "", 0, "0123456+12", "upce_2addon.emf", "" },
|
||||
/* 8*/ { BARCODE_UPCE, -1, -1, SMALL_TEXT | BOLD_TEXT, -1, -1, -1, -1, "", "", 0, "0123456+12", "upce_2addon_small_bold.emf", "" },
|
||||
/* 9*/ { BARCODE_ITF14, -1, -1, BOLD_TEXT, -1, -1, -1, -1, "", "", 0, "123", "itf14_bold.emf", "" },
|
||||
/* 10*/ { BARCODE_CODE39, -1, -1, -1, -1, -1, -1, -1, "", "", 90, "123", "code39_rotate_90.emf", "" },
|
||||
/* 11*/ { BARCODE_CODE39, -1, -1, -1, -1, -1, -1, -1, "", "", 180, "123", "code39_rotate_180.emf", "" },
|
||||
/* 12*/ { BARCODE_CODE39, -1, -1, -1, -1, -1, -1, -1, "", "", 270, "123", "code39_rotate_270.emf", "" },
|
||||
/* 13*/ { BARCODE_MAXICODE, -1, -1, -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" },
|
||||
/* 14*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, "", "FFFFFF00", 90, "THIS IS A 93 CHARACTER CODE SET A MESSAGE THAT FILLS A MODE 4, UNAPPENDED, MAXICODE SYMBOL...", "maxicode_rotate_90_nobg.emf", "" },
|
||||
/* 0*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, 0, "", "", 0, "Égjpqy", "code128_egrave_bold.emf", "" },
|
||||
/* 1*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, 100.0f / 25.4f, "", "", 0, "Égjpqy", "code128_egrave_bold_100dpi.emf", "" },
|
||||
/* 2*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, 150.0f / 25.4f, "", "", 0, "Égjpqy", "code128_egrave_bold_150dpi.emf", "" },
|
||||
/* 3*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, 300.0f / 25.4f, "", "", 0, "Égjpqy", "code128_egrave_bold_300dpi.emf", "" },
|
||||
/* 4*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, 400.0f / 25.4f, "", "", 0, "Égjpqy", "code128_egrave_bold_400dpi.emf", "" },
|
||||
/* 5*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, 1200.0f / 25.4f, "", "", 0, "Égjpqy", "code128_egrave_bold_1200dpi.emf", "" },
|
||||
/* 6*/ { BARCODE_TELEPEN, -1, -1, -1, -1, -1, -1, -1, 0, "147AD0", "FC9630", 0, "123", "telenum_fg_bg.emf", "" },
|
||||
/* 7*/ { BARCODE_TELEPEN, -1, -1, -1, -1, -1, -1, -1, 150.0f / 25.4f, "147AD0", "FC9630", 0, "123", "telenum_fg_bg_150dpi.emf", "" },
|
||||
/* 8*/ { BARCODE_ULTRA, -1, -1, -1, 5, -1, -1, -1, 0, "147AD0", "FC9630", 0, "123", "ultracode_fg_bg.emf", "" },
|
||||
/* 9*/ { BARCODE_ULTRA, -1, 2, BARCODE_BOX, 2, 2, -1, -1, 0, "FF0000", "0000FF", 0, "123", "ultracode_fg_bg_box2.emf", "" },
|
||||
/* 10*/ { BARCODE_ULTRA, -1, 2, BARCODE_BOX, 2, 2, -1, -1, 600.0f / 25.4f, "FF0000", "0000FF", 0, "123", "ultracode_fg_bg_box2_600dpi.emf", "" },
|
||||
/* 11*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, 0, "", "", 0, "9780877799306+54321", "ean13_5addon_ggs_5.2.2.5.2-2.emf", "" },
|
||||
/* 12*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, 0, "", "", 0, "210987654321+54321", "ean13_5addon_#185.emf", "#185 Byte count, font data, HeaderExtension1/2" },
|
||||
/* 13*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, -1, -1, 0, "", "", 0, "012345678905+24", "upca_2addon_ggs_5.2.6.6-5.emf", "" },
|
||||
/* 14*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, -1, -1, 0, "", "", 0, "0123456+12", "upce_2addon.emf", "" },
|
||||
/* 15*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, -1, -1, 150.f / 25.4f, "", "", 0, "0123456+12", "upce_2addon_150dpi.emf", "" },
|
||||
/* 16*/ { BARCODE_UPCE, -1, -1, SMALL_TEXT | BOLD_TEXT, -1, -1, -1, -1, 0, "", "", 0, "0123456+12", "upce_2addon_small_bold.emf", "" },
|
||||
/* 17*/ { BARCODE_ITF14, -1, -1, BOLD_TEXT, -1, -1, -1, -1, 0, "", "", 0, "123", "itf14_bold.emf", "" },
|
||||
/* 18*/ { BARCODE_ITF14, -1, -1, BOLD_TEXT, -1, -1, -1, -1, 600.f / 25.4f, "", "", 0, "123", "itf14_bold_600dpi.emf", "" },
|
||||
/* 19*/ { BARCODE_CODE39, -1, -1, -1, -1, -1, -1, -1, 0, "", "", 90, "123", "code39_rotate_90.emf", "" },
|
||||
/* 20*/ { BARCODE_CODE39, -1, -1, -1, -1, -1, -1, -1, 300.f / 25.4f, "", "", 90, "123", "code39_rotate_90_300dpi.emf", "" },
|
||||
/* 21*/ { BARCODE_CODE39, -1, -1, -1, -1, -1, -1, -1, 0, "", "", 180, "123", "code39_rotate_180.emf", "" },
|
||||
/* 22*/ { BARCODE_CODE39, -1, -1, -1, -1, -1, -1, -1, 0, "", "", 270, "123", "code39_rotate_270.emf", "" },
|
||||
/* 23*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, 0, "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" },
|
||||
/* 24*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, 150.f / 25.4f, "E0E0E0", "700070", 0, "THIS IS A 93 CHARACTER CODE SET A MESSAGE THAT FILLS A MODE 4, UNAPPENDED, MAXICODE SYMBOL...", "maxicode_#185_150dpi.emf", "#185 Maxicode scaling" },
|
||||
/* 25*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, 600.f / 25.4f, "E0E0E0", "700070", 0, "THIS IS A 93 CHARACTER CODE SET A MESSAGE THAT FILLS A MODE 4, UNAPPENDED, MAXICODE SYMBOL...", "maxicode_#185_600dpi.emf", "#185 Maxicode scaling" },
|
||||
/* 26*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, 0, "", "FFFFFF00", 90, "THIS IS A 93 CHARACTER CODE SET A MESSAGE THAT FILLS A MODE 4, UNAPPENDED, MAXICODE SYMBOL...", "maxicode_rotate_90_nobg.emf", "" },
|
||||
/* 27*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, 300.0f, "", "FFFFFF00", 90, "THIS IS A 93 CHARACTER CODE SET A MESSAGE THAT FILLS A MODE 4, UNAPPENDED, MAXICODE SYMBOL...", "maxicode_rotate_90_nobg_300dpi.emf", "" },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
|
@ -111,6 +125,10 @@ static void test_print(const testCtx *const p_ctx) {
|
|||
if (data[i].whitespace_height != -1) {
|
||||
symbol->whitespace_height = data[i].whitespace_height;
|
||||
}
|
||||
if (data[i].dpmm) {
|
||||
symbol->dpmm = data[i].dpmm;
|
||||
symbol->scale = ZBarcode_Scale_From_XdimDp(symbol->symbology, ZBarcode_Default_Xdim(symbol->symbology), symbol->dpmm, "EMF");
|
||||
}
|
||||
if (*data[i].fgcolour) {
|
||||
strcpy(symbol->fgcolour, data[i].fgcolour);
|
||||
}
|
||||
|
@ -128,10 +146,10 @@ static void test_print(const testCtx *const p_ctx) {
|
|||
assert_nonzero(testUtilDataPath(expected_file, sizeof(expected_file), data_dir, data[i].expected_file), "i:%d testUtilDataPath == 0\n", i);
|
||||
|
||||
if (p_ctx->generate) {
|
||||
printf(" /*%3d*/ { %s, %s, %d, %s, %d, %d, %d, %d, \"%s\", \"%s\", %d, \"%s\", \"%s\", \"%s\" },\n",
|
||||
printf(" /*%3d*/ { %s, %s, %d, %s, %d, %d, %d, %d, %g, \"%s\", \"%s\", %d, \"%s\", \"%s\", \"%s\" },\n",
|
||||
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].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].dpmm, 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);
|
||||
ret = testUtilRename(symbol->outfile, expected_file);
|
||||
assert_zero(ret, "i:%d testUtilRename(%s, %s) ret %d != 0\n", i, symbol->outfile, expected_file, ret);
|
||||
|
@ -170,10 +188,13 @@ static void test_outfile(const testCtx *const p_ctx) {
|
|||
symbol.symbology = BARCODE_CODE128;
|
||||
symbol.vector = &vector;
|
||||
|
||||
strcpy(symbol.outfile, "nosuch_dir/out.emf");
|
||||
strcpy(symbol.outfile, "test_emf_out.emf");
|
||||
(void) testUtilRmROFile(symbol.outfile); /* In case lying around from previous fail */
|
||||
assert_nonzero(testUtilCreateROFile(symbol.outfile), "emf_plot testUtilCreateROFile(%s) fail (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
ret = emf_plot(&symbol, 0);
|
||||
assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "emf_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt);
|
||||
assert_zero(testUtilRmROFile(symbol.outfile), "emf_plot testUtilRmROFile(%s) != 0 (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
symbol.output_options |= BARCODE_STDOUT;
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
|
|||
|
||||
char data_buf[19 * 32 + 1]; /* 19 * 32 == 608 */
|
||||
|
||||
int have_identify = testUtilHaveIdentify();
|
||||
const char *const have_identify = testUtilHaveIdentify();
|
||||
|
||||
testStart("test_pixel_plot");
|
||||
|
||||
|
@ -100,7 +100,7 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
|
|||
|
||||
if (ret < ZINT_ERROR) {
|
||||
if (have_identify) {
|
||||
ret = testUtilVerifyIdentify(symbol->outfile, debug);
|
||||
ret = testUtilVerifyIdentify(have_identify, symbol->outfile, debug);
|
||||
assert_zero(ret, "i:%d identify %s ret %d != 0\n", i, symbol->outfile, ret);
|
||||
}
|
||||
if (!(debug & ZINT_DEBUG_TEST_KEEP_OUTFILE)) {
|
||||
|
@ -184,7 +184,7 @@ static void test_print(const testCtx *const p_ctx) {
|
|||
char escaped[1024];
|
||||
int escaped_size = 1024;
|
||||
|
||||
int have_identify = testUtilHaveIdentify();
|
||||
const char *const have_identify = testUtilHaveIdentify();
|
||||
|
||||
testStart("test_print");
|
||||
|
||||
|
@ -251,7 +251,7 @@ static void test_print(const testCtx *const p_ctx) {
|
|||
ret = testUtilRename(symbol->outfile, expected_file);
|
||||
assert_zero(ret, "i:%d testUtilRename(%s, %s) ret %d != 0\n", i, symbol->outfile, expected_file, ret);
|
||||
if (have_identify) {
|
||||
ret = testUtilVerifyIdentify(expected_file, debug);
|
||||
ret = testUtilVerifyIdentify(have_identify, expected_file, debug);
|
||||
assert_zero(ret, "i:%d %s identify %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), expected_file, ret);
|
||||
}
|
||||
} else {
|
||||
|
@ -282,10 +282,13 @@ static void test_outfile(const testCtx *const p_ctx) {
|
|||
symbol.bitmap = data;
|
||||
symbol.bitmap_width = symbol.bitmap_height = 1;
|
||||
|
||||
strcpy(symbol.outfile, "nosuch_dir/out.gif");
|
||||
strcpy(symbol.outfile, "test_gif_out.gif");
|
||||
(void) testUtilRmROFile(symbol.outfile); /* In case lying around from previous fail */
|
||||
assert_nonzero(testUtilCreateROFile(symbol.outfile), "gif_pixel_plot testUtilCreateROFile(%s) fail (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
ret = gif_pixel_plot(&symbol, data);
|
||||
assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "gif_pixel_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt);
|
||||
assert_zero(testUtilRmROFile(symbol.outfile), "gif_pixel_plot testUtilRmROFile(%s) != 0 (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
symbol.output_options |= BARCODE_STDOUT;
|
||||
|
||||
|
|
|
@ -29,10 +29,12 @@
|
|||
*/
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
|
||||
#include "testcommon.h"
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <math.h>
|
||||
#include <sys/stat.h>
|
||||
#include "testcommon.h"
|
||||
#include "../common.h"
|
||||
|
||||
static void test_checks(const testCtx *const p_ctx) {
|
||||
int debug = p_ctx->debug;
|
||||
|
@ -63,8 +65,8 @@ static void test_checks(const testCtx *const p_ctx) {
|
|||
/* 1*/ { BARCODE_CODE128, -1, "1234", -1, -1, 0, 0, 0, 0, 0, -1, -1, -1, -1, 0, "", -1 },
|
||||
/* 2*/ { BARCODE_QRCODE, -1, "1234", -1, -1, 3, 0, 0, 0, 0, -1, -1, -1, -1, 0, "", -1 },
|
||||
/* 3*/ { BARCODE_QRCODE, -1, "1234", -1, -1, 999999 + 1, 0, 0, 0, 0, -1, -1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 218: Invalid ECI code 1000000", -1 },
|
||||
/* 4*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, 0, 0, 0, 0, 0.009, -1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 227: Scale out of range (0.01 to 100)", -1 },
|
||||
/* 5*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, 0, 0, 0, 0, 100.01, -1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 227: Scale out of range (0.01 to 100)", -1 },
|
||||
/* 4*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, 0, 0, 0, 0, 0.009, -1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 227: Scale out of range (0.01 to 200)", -1 },
|
||||
/* 5*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, 0, 0, 0, 0, 200.01, -1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 227: Scale out of range (0.01 to 200)", -1 },
|
||||
/* 6*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, 0, 0, 0, 0, -1, 20.1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 221: Dot size out of range (0.01 to 20)", -1 },
|
||||
/* 7*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, 0, 0, 0, 0, 0.01, 0.009, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 221: Dot size out of range (0.01 to 20)", -1 },
|
||||
/* 8*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, -0.1, 0, 0, 0, -1, -1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 765: Height out of range (0 to 2000)", -1 },
|
||||
|
@ -1381,6 +1383,204 @@ static void test_clear(const testCtx *const p_ctx) {
|
|||
testFinish();
|
||||
}
|
||||
|
||||
static void test_scale_from_xdimdp(const testCtx *const p_ctx) {
|
||||
|
||||
struct item {
|
||||
int symbology;
|
||||
float x_dim;
|
||||
float dpmm;
|
||||
int dpi;
|
||||
char *filetype;
|
||||
float expected;
|
||||
};
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
struct item data[] = {
|
||||
/* 0*/ { BARCODE_EANX, 0.33f, 2, 50, "gif", 0.5f },
|
||||
/* 1*/ { BARCODE_EANX, 0.33f, 2, 50, "emf", 0.33000001f },
|
||||
/* 2*/ { BARCODE_EANX, 0.33f, 2, 50, "svg", 0.33000001f },
|
||||
/* 3*/ { BARCODE_EANX, 0.33f, 3, 76, "gif", 0.5f },
|
||||
/* 4*/ { BARCODE_EANX, 0.33f, 3, 76, "svg", 0.495f },
|
||||
/* 5*/ { BARCODE_EANX, 0.33f, 4, 100, "gif", 0.5f },
|
||||
/* 6*/ { BARCODE_EANX, 0.33f, 4, 100, "svg", 0.66000003f },
|
||||
/* 7*/ { BARCODE_EANX, 0.33f, 6, 150, "gif", 1 },
|
||||
/* 8*/ { BARCODE_EANX, 0.33f, 6, 150, "svg", 0.99f },
|
||||
/* 9*/ { BARCODE_EANX, 0.33f, 8, 200, "gif", 1.5f },
|
||||
/* 10*/ { BARCODE_EANX, 0.33f, 8, 200, "svg", 1.32f },
|
||||
/* 11*/ { BARCODE_EANX, 0.33f, 12, 300, "gif", 2 },
|
||||
/* 12*/ { BARCODE_EANX, 0.33f, 12, 300, "svg", 1.98f },
|
||||
/* 13*/ { BARCODE_EANX, 0.33f, 16, 400, "gif", 2.5f }, /* NOTE: scale previously documented as 3.0f */
|
||||
/* 14*/ { BARCODE_EANX, 0.33f, 16, 400, "svg", 2.64f },
|
||||
/* 15*/ { BARCODE_EANX, 0.33f, 24, 600, "gif", 4 },
|
||||
/* 16*/ { BARCODE_EANX, 0.33f, 24, 600, "svg", 3.96f },
|
||||
/* 17*/ { BARCODE_EANX, 0.33f, 47, 1200, "gif", 8 },
|
||||
/* 18*/ { BARCODE_EANX, 0.33f, 47, 1200, "emf", 7.755f },
|
||||
/* 19*/ { BARCODE_EANX, 0.33f, 47, 1200, "svg", 7.755f },
|
||||
/* 20*/ { BARCODE_EANX, 0.33f, 94, 2400, "gif", 15.5f }, /* NOTE dpmm previously documented as 95 */
|
||||
/* 21*/ { BARCODE_EANX, 0.33f, 94, 2400, "svg", 15.51f },
|
||||
/* 22*/ { BARCODE_EANX, 0.33f, 189, 4800, "gif", 31 },
|
||||
/* 23*/ { BARCODE_EANX, 0.33f, 189, 4800, "svg", 31.185001f },
|
||||
/* 24*/ { BARCODE_EANX, 0.33f, 378, 9600, "gif", 62.5f },
|
||||
/* 25*/ { BARCODE_EANX, 0.33f, 378, 9600, "svg", 62.370003f },
|
||||
/* 26*/ { BARCODE_MAXICODE, 0.88f, 4, 100, "gif", 0.352f },
|
||||
/* 27*/ { BARCODE_MAXICODE, 0.88f, 4, 100, "emf", 0.1f }, /* NOTE scale rounded up to min 0.1 so doesn't round trip */
|
||||
/* 28*/ { BARCODE_MAXICODE, 0.88f, 4, 100, "svg", 1.76f },
|
||||
/* 29*/ { BARCODE_MAXICODE, 0.88f, 6, 150, "gif", 0.528f }, /* NOTE scale previously documented as 0.5f */
|
||||
/* 30*/ { BARCODE_MAXICODE, 0.88f, 6, 150, "emf", 0.132f },
|
||||
/* 31*/ { BARCODE_MAXICODE, 0.88f, 6, 150, "svg", 2.6399999 },
|
||||
/* 32*/ { BARCODE_MAXICODE, 0.88f, 8, 200, "gif", 0.704f }, /* NOTE scale previously documented as 0.7f */
|
||||
/* 33*/ { BARCODE_MAXICODE, 0.88f, 8, 200, "emf", 0.176f },
|
||||
/* 34*/ { BARCODE_MAXICODE, 0.88f, 8, 200, "svg", 3.52f },
|
||||
/* 35*/ { BARCODE_MAXICODE, 0.88f, 12, 300, "gif", 1.056f }, /* NOTE scale previously documented as 1.0f */
|
||||
/* 36*/ { BARCODE_MAXICODE, 0.88f, 12, 300, "emf", 0.264f },
|
||||
/* 37*/ { BARCODE_MAXICODE, 0.88f, 12, 300, "svg", 5.2799997f },
|
||||
/* 38*/ { BARCODE_MAXICODE, 0.88f, 16, 400, "gif", 1.408f }, /* NOTE scale previously documented as 1.4f */
|
||||
/* 39*/ { BARCODE_MAXICODE, 0.88f, 16, 400, "emf", 0.352f },
|
||||
/* 40*/ { BARCODE_MAXICODE, 0.88f, 16, 400, "gif", 1.408f },
|
||||
/* 41*/ { BARCODE_MAXICODE, 0.88f, 24, 600, "gif", 2.112f }, /* NOTE scale previously documented as 2.1f */
|
||||
/* 42*/ { BARCODE_MAXICODE, 0.88f, 24, 600, "emf", 0.528f },
|
||||
/* 43*/ { BARCODE_MAXICODE, 0.88f, 24, 600, "svg", 10.559999f },
|
||||
/* 44*/ { BARCODE_MAXICODE, 0.88f, 47, 1200, "gif", 4.136f }, /* NOTE scale previously documented as 4.1f */
|
||||
/* 45*/ { BARCODE_MAXICODE, 0.88f, 47, 1200, "emf", 1.034f },
|
||||
/* 46*/ { BARCODE_MAXICODE, 0.88f, 47, 1200, "svg", 20.68f },
|
||||
/* 47*/ { BARCODE_MAXICODE, 0.88f, 94, 2400, "gif", 8.272f }, /* NOTE dpmm previously documented as 95, scale as 8.2f */
|
||||
/* 48*/ { BARCODE_MAXICODE, 0.88f, 94, 2400, "emf", 2.0680001f },
|
||||
/* 49*/ { BARCODE_MAXICODE, 0.88f, 94, 2400, "svg", 41.360001f },
|
||||
/* 50*/ { BARCODE_MAXICODE, 0.88f, 189, 4800, "gif", 16.632f }, /* NOTE scale previously documented as 16.4f */
|
||||
/* 51*/ { BARCODE_MAXICODE, 0.88f, 189, 4800, "emf", 4.158f },
|
||||
/* 52*/ { BARCODE_MAXICODE, 0.88f, 189, 4800, "svg", 83.159996f },
|
||||
/* 53*/ { BARCODE_MAXICODE, 0.88f, 378, 9600, "gif", 33.264f },
|
||||
/* 54*/ { BARCODE_MAXICODE, 0.88f, 378, 9600, "emf", 8.316f },
|
||||
/* 55*/ { BARCODE_MAXICODE, 0.88f, 378, 9600, "svg", 166.31999f },
|
||||
/* 56*/ { BARCODE_PDF417, 0.27f, 2, 50, "gif", 0.5f },
|
||||
/* 57*/ { BARCODE_PDF417, 0.27f, 2, 50, "svg", 0.27000001f },
|
||||
/* 58*/ { BARCODE_PDF417, 0.27f, 6, 150, "gif", 1 },
|
||||
/* 59*/ { BARCODE_PDF417, 0.27f, 6, 150, "svg", 0.81000006f },
|
||||
/* 60*/ { BARCODE_PDF417, 0.27f, 12, 300, "gif", 1.5 },
|
||||
/* 61*/ { BARCODE_PDF417, 0.27f, 12, 300, "svg", 1.6200001f },
|
||||
/* 62*/ { BARCODE_PDF417, 0.27f, 24, 600, "gif", 3 },
|
||||
/* 63*/ { BARCODE_PDF417, 0.27f, 24, 600, "emf", 3.2400002f },
|
||||
/* 64*/ { BARCODE_PDF417, 0.27f, 24, 600, "svg", 3.2400002f },
|
||||
/* 65*/ { BARCODE_PHARMA_TWO, 1, 2, 50, "gif", 1 },
|
||||
/* 66*/ { BARCODE_PHARMA_TWO, 1, 2, 50, "svg", 1 },
|
||||
/* 67*/ { BARCODE_PHARMA_TWO, 1, 6, 150, "gif", 3 },
|
||||
/* 68*/ { BARCODE_PHARMA_TWO, 1, 6, 150, "svg", 3 },
|
||||
/* 69*/ { BARCODE_PHARMA_TWO, 1, 8, 200, "gif", 4 },
|
||||
/* 70*/ { BARCODE_PHARMA_TWO, 1, 8, 200, "svg", 4 },
|
||||
/* 71*/ { BARCODE_PHARMA_TWO, 1, 189, 4800, "gif", 94.5f },
|
||||
/* 72*/ { BARCODE_PHARMA_TWO, 1, 189, 4800, "svg", 94.5f },
|
||||
/* 73*/ { BARCODE_PHARMA_TWO, 1, 378, 9600, "gif", 189 },
|
||||
/* 74*/ { BARCODE_PHARMA_TWO, 1, 378, 9600, "svg", 189 },
|
||||
/* 75*/ { BARCODE_PHARMA_TWO, 1, 401, 10200, "gif", 200 }, /* NOTE scale capped to 200 so doesn't round trip */
|
||||
/* 76*/ { BARCODE_PHARMA_TWO, 1, 401, 10200, "svg", 200 },
|
||||
/* 77*/ { BARCODE_CODE128, 0.5, 12, 300, "gif", 3 },
|
||||
/* 78*/ { BARCODE_CODE128, 0, 12, -1, "gif", 0 }, /* x_dim zero */
|
||||
/* 79*/ { BARCODE_CODE128, 200.1f, 12, -1, "gif", 0 }, /* x_dim > 200 */
|
||||
/* 80*/ { BARCODE_CODE128, 0.5f, -0.1f, -1, "gif", 0 }, /* dpmm neg */
|
||||
/* 81*/ { BARCODE_CODE128, 0.5f, 1000.1, -1, "gif", 0 }, /* dpmm > 1000 */
|
||||
/* 82*/ { BARCODE_CODE128, 0.5f, 300, -1, "abcd", 0 }, /* filetype unknown */
|
||||
/* 83*/ { BARCODE_QRCODE, 10, 31, 800, "gif", 155 },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i;
|
||||
float ret;
|
||||
float x_dim_from_scale;
|
||||
float dpmm_from_dpi;
|
||||
|
||||
testStart("test_scale_from_xdimdp");
|
||||
|
||||
for (i = 0; i < data_size; i++) {
|
||||
|
||||
if (testContinue(p_ctx, i)) continue;
|
||||
|
||||
ret = ZBarcode_Scale_From_XdimDp(data[i].symbology, data[i].x_dim, data[i].dpmm, data[i].filetype);
|
||||
assert_equal(ret, data[i].expected, "i:%d ZBarcode_Scale_From_XdimDp(%s, %g, %g, %s) %.8g != %.8g\n",
|
||||
i, testUtilBarcodeName(data[i].symbology), data[i].dpmm, data[i].x_dim, data[i].filetype, ret, data[i].expected);
|
||||
|
||||
if (ret) {
|
||||
dpmm_from_dpi = roundf(data[i].dpi / 25.4f);
|
||||
ret = ZBarcode_Scale_From_XdimDp(data[i].symbology, data[i].x_dim, dpmm_from_dpi, data[i].filetype);
|
||||
assert_equal(ret, data[i].expected, "i:%d ZBarcode_Scale_From_XdimDp(%s, %g (dpi %d), %g, %s) %.8g != %.8g\n",
|
||||
i, testUtilBarcodeName(data[i].symbology), dpmm_from_dpi, data[i].dpi, data[i].x_dim, data[i].filetype, ret, data[i].expected);
|
||||
|
||||
if (data[i].expected > 0.1f && data[i].expected < 200.0f /* Can't round trip scales <= 0.1 or >= 200.0f */
|
||||
&& (data[i].symbology == BARCODE_MAXICODE || strcmp(data[i].filetype, "gif") != 0)) { /* Non-MAXICODE raster rounds to half-increments */
|
||||
x_dim_from_scale = ZBarcode_XdimDp_From_Scale(data[i].symbology, ret, data[i].dpmm, data[i].filetype);
|
||||
x_dim_from_scale = roundf(x_dim_from_scale * 100.0f) / 100.0f;
|
||||
assert_equal(x_dim_from_scale, data[i].x_dim, "i:%d ZBarcode_XdimDp_From_Scale(%s, %g, %g, %s) %.8g != x_dim %.8g\n",
|
||||
i, testUtilBarcodeName(data[i].symbology), ret, data[i].x_dim, data[i].filetype, x_dim_from_scale, data[i].x_dim);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
testFinish();
|
||||
}
|
||||
|
||||
static void test_xdimdp_from_scale(const testCtx *const p_ctx) {
|
||||
|
||||
struct item {
|
||||
int symbology;
|
||||
float scale;
|
||||
float dpmm; /* Note testing "normal" case that want X-dim, not dpmm */
|
||||
int dpi;
|
||||
char *filetype;
|
||||
float expected;
|
||||
};
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
struct item data[] = {
|
||||
/* 0*/ { BARCODE_EANX, 1, 6, 150, "gif", 0.33333334f },
|
||||
/* 1*/ { BARCODE_EANX, 1.32f, 8, 200, "gif", 0.33000001f },
|
||||
/* 2*/ { BARCODE_EANX, 1.5f, 8, 200, "gif", 0.375f },
|
||||
/* 3*/ { BARCODE_EANX, 1.98f, 12, 300, "gif", 0.33f },
|
||||
/* 4*/ { BARCODE_EANX, 2, 12, 300, "gif", 0.33333334f },
|
||||
/* 5*/ { BARCODE_EANX, 2, 12, 300, "svg", 0.33333334f },
|
||||
/* 6*/ { BARCODE_EANX, 2.64f, 16, 400, "gif", 0.33f },
|
||||
/* 7*/ { BARCODE_EANX, 2.5f, 16, 400, "gif", 0.3125f },
|
||||
/* 8*/ { BARCODE_EANX, 3.96f, 24, 600, "gif", 0.33f },
|
||||
/* 9*/ { BARCODE_EANX, 3.96f, 24, 600, "svg", 0.33f },
|
||||
/* 10*/ { BARCODE_EANX, 4, 24, 600, "gif", 0.33333334f },
|
||||
/* 11*/ { BARCODE_EANX, 7.755f, 47, 1200, "gif", 0.33f },
|
||||
/* 12*/ { BARCODE_EANX, 8, 47, 1200, "gif", 0.34042552f },
|
||||
/* 13*/ { BARCODE_EANX, 15.51f, 94, 2400, "gif", 0.33f },
|
||||
/* 14*/ { BARCODE_EANX, 15.5f, 94, 2400, "gif", 0.32978722f },
|
||||
/* 15*/ { BARCODE_EANX, 31.185001f, 189, 4800, "gif", 0.33f },
|
||||
/* 16*/ { BARCODE_EANX, 31, 189, 4800, "gif", 0.32804233f },
|
||||
/* 17*/ { BARCODE_MAXICODE, 1, 12, 300, "gif", 0.83333331f },
|
||||
/* 18*/ { BARCODE_MAXICODE, 0.264f, 12, 300, "emf", 0.87999994f },
|
||||
/* 19*/ { BARCODE_MAXICODE, 5.2799997f, 12, 300, "svg", 0.87999994f },
|
||||
/* 20*/ { BARCODE_MAXICODE, 2, 24, 600, "gif", 0.83333331f },
|
||||
/* 21*/ { BARCODE_MAXICODE, 0.528f, 24, 600, "emf", 0.87999994f },
|
||||
/* 22*/ { BARCODE_MAXICODE, 10.559999f, 24, 600, "svg", 0.87999994f },
|
||||
/* 23*/ { BARCODE_CODE128, 0, 12, -1, "gif", 0 }, /* scale zero */
|
||||
/* 24*/ { BARCODE_CODE128, 200.01f, 12, -1, "gif", 0 }, /* scale > 200 */
|
||||
/* 25*/ { BARCODE_CODE128, 0.5f, 0, -1, "gif", 0 }, /* xdim_mm_or_dpmm zero */
|
||||
/* 26*/ { BARCODE_CODE128, 0.5f, 1000.1f, -1, "gif", 0 }, /* xdim_mm_or_dpmm > 1000 */
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i;
|
||||
float ret;
|
||||
float dpmm_from_dpi;
|
||||
|
||||
testStart("test_xdimdp_from_scale");
|
||||
|
||||
for (i = 0; i < data_size; i++) {
|
||||
|
||||
if (testContinue(p_ctx, i)) continue;
|
||||
|
||||
ret = ZBarcode_XdimDp_From_Scale(data[i].symbology, data[i].scale, data[i].dpmm, data[i].filetype);
|
||||
assert_equal(ret, data[i].expected, "i:%d ZBarcode_XdimDp_From_Scale(%s, %g, %g, %s) %.8g != %.8g\n",
|
||||
i, testUtilBarcodeName(data[i].symbology), data[i].dpmm, data[i].scale, data[i].filetype, ret, data[i].expected);
|
||||
|
||||
if (ret) {
|
||||
dpmm_from_dpi = roundf(data[i].dpi / 25.4f);
|
||||
ret = ZBarcode_XdimDp_From_Scale(data[i].symbology, data[i].scale, dpmm_from_dpi, data[i].filetype);
|
||||
assert_equal(ret, data[i].expected, "i:%d ZBarcode_XdimDp_From_Scale(%s, %g (dpi %d), %g, %s) %.8g != %.8g\n",
|
||||
i, testUtilBarcodeName(data[i].symbology), dpmm_from_dpi, data[i].dpi, data[i].scale, data[i].filetype, ret, data[i].expected);
|
||||
}
|
||||
}
|
||||
|
||||
testFinish();
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
testFunction funcs[] = { /* name, func */
|
||||
|
@ -1404,6 +1604,8 @@ int main(int argc, char *argv[]) {
|
|||
{ "test_strip_bom", test_strip_bom },
|
||||
{ "test_zero_outfile", test_zero_outfile },
|
||||
{ "test_clear", test_clear },
|
||||
{ "test_scale_from_xdimdp", test_scale_from_xdimdp },
|
||||
{ "test_xdimdp_from_scale", test_xdimdp_from_scale },
|
||||
};
|
||||
|
||||
testRun(argc, argv, funcs, ARRAY_SIZE(funcs));
|
||||
|
|
|
@ -44,59 +44,61 @@ static void test_input(const testCtx *const p_ctx) {
|
|||
struct item data[] = {
|
||||
/* 0*/ { "41038422416563762XY11 ", 0, 3, 155 },
|
||||
/* 1*/ { "41038422416563762XY11 ", ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 2*/ { "41038422416563762xy11 ", 0, 3, 155 }, /* Case insensitive */
|
||||
/* 3*/ { "41038422416563762xy11 .", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
||||
/* 4*/ { "0100000000000AA000AA0A", 0, 3, 131, }, /* Length 22, Mailmark C (2 digit chain id) */
|
||||
/* 5*/ { "5100000000000AA000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* 1st char format 0-4 only */
|
||||
/* 6*/ { "0000000000000AA000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* 2nd char version id 1-4 only */
|
||||
/* 7*/ { "01F0000000000AA000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* 3rd char class 0-9A-E only */
|
||||
/* 8*/ { "0100A00000000AA000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* 4-5th chars chain id 2 digits */
|
||||
/* 9*/ { "010000000000AAA000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* 6-13th chars item id 8 digits */
|
||||
/* 10*/ { "0100000000000 A000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* Remaining chars post code */
|
||||
/* 11*/ { "0100000000000C1I2JQ3N ", 0, 3, 131, }, /* F N F N L L N L S */
|
||||
/* 12*/ { "010000000000091I2JQ3N ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N F N L L N L S bad 1st F */
|
||||
/* 13*/ { "0100000000000CAI2JQ3N ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N F N L L N L S bad 1st N */
|
||||
/* 14*/ { "0100000000000C1I2IQ3N ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N F N L L N L S bad 1st L */
|
||||
/* 15*/ { "0100000000000C1I2IQ3NA", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N F N L L N L S bad S */
|
||||
/* 16*/ { "0100000000000KM12JQ3N ", 0, 3, 131, }, /* F F N N L L N L S */
|
||||
/* 17*/ { "0100000000000K 12JQ3N ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N L L N L S bad 2nd F (non-numeric otherwise matches last pattern) */
|
||||
/* 18*/ { "0100000000000KM1AJQ3N ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N L L N L S bad 2nd N */
|
||||
/* 19*/ { "0100000000000KM12JO3N ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N L L N L S bad 2nd L */
|
||||
/* 20*/ { "0100000000000KM12JQ3NA", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N L L N L S bad S */
|
||||
/* 21*/ { "0100000000000OV123JQ4U", 0, 3, 131, }, /* F F N N N L L N L */
|
||||
/* 22*/ { "01000000000009V123JQ4U", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N N L L N L bad 1st F */
|
||||
/* 23*/ { "0100000000000OV12AJQ4U", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N N L L N L bad 3rd N */
|
||||
/* 24*/ { "0100000000000OV123JQ4V", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N N L L N L bad 3rd L */
|
||||
/* 25*/ { "0100000000000CI1K3JQ4U", 0, 3, 131, }, /* F F N F N L L N L */
|
||||
/* 26*/ { "0100000000000CI1 3JQ4U", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N F N L L N L bad 3rd F (non-numeric otherwise matches pattern above) */
|
||||
/* 27*/ { "0100000000000CIAK3JQ4U", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N F N L L N L bad 1st N */
|
||||
/* 28*/ { "0100000000000CI1K3CQ4U", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N F N L L N L bad 1st L */
|
||||
/* 29*/ { "0100000000000C12JQ3U ", 0, 3, 131, }, /* F N N L L N L S S */
|
||||
/* 30*/ { "0100000000000912JQ3U ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N L L N L S S bad F */
|
||||
/* 31*/ { "0100000000000C1AJQ3U ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N L L N L S S bad 2nd N */
|
||||
/* 32*/ { "0100000000000C12JO3U ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N L L N L S S bad 2nd L */
|
||||
/* 33*/ { "0100000000000C12JQ3UA ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N L L N L S S bad 1st S */
|
||||
/* 34*/ { "0100000000000C123JQ4U ", 0, 3, 131, }, /* F N N N L L N L S */
|
||||
/* 35*/ { "01000000000009123JQ4U ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N N L L N L S bad F */
|
||||
/* 36*/ { "0100000000000C12AJQ4U ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N N L L N L S bad 3rd N */
|
||||
/* 37*/ { "0100000000000C123JQ4V ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N N L L N L S bad 3rd L */
|
||||
/* 38*/ { "0100000000000C123JQ4U1", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N N L L N L S bad S */
|
||||
/* 39*/ { "01000000000000000AA000AA0A", 0, 3, 155, }, /* Length 26, Mailmark L (6 digit chain id) */
|
||||
/* 40*/ { "010A0000000000000AA000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* 4-9th chars chain id 6 digits */
|
||||
/* 41*/ { "010A0000000000000 A000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* Post code */
|
||||
/* 42*/ { "01000000000000000C1I2JQ3N ", 0, 3, 155, }, /* F N F N L L N L S */
|
||||
/* 43*/ { "01000000000000000C1 2JQ3N ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N F N L L N L S bad 2nd F */
|
||||
/* 44*/ { "01000000000000000KM12JQ3N ", 0, 3, 155, }, /* F F N N L L N L S */
|
||||
/* 45*/ { "01000000000000000KM12JQAN ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N L L N L S bad 3rd N */
|
||||
/* 46*/ { "01000000000000000OV123JQ4U", 0, 3, 155, }, /* F F N N N L L N L */
|
||||
/* 47*/ { "01000000000000000OV123IQ4U", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N N L L N L bad 1st L */
|
||||
/* 48*/ { "01000000000000000CI1K3JQ4U", 0, 3, 155, }, /* F F N F N L L N L */
|
||||
/* 49*/ { "010000000000000009I1K3JQ4U", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N F N L L N L bad 1st F */
|
||||
/* 50*/ { "01000000000000000C12JQ3U ", 0, 3, 155, }, /* F N N L L N L S S */
|
||||
/* 51*/ { "01000000000000000C12JQ3U A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N L L N L S S bad 2nd S */
|
||||
/* 52*/ { "01000000000000000C123JQ4U ", 0, 3, 155, }, /* F N N N L L N L S */
|
||||
/* 53*/ { "01000000000000000C 23JQ4U ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N N L L N L S bad 1st N (non-alpha otherwise matches 2nd pattern) */
|
||||
/* 54*/ { "41038422416563762XY1", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
||||
/* 2*/ { "4103842241656", ZINT_ERROR_TOO_LONG, -1, -1 }, /* Too short (< 14) */
|
||||
/* 3*/ { "41038422416563", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
||||
/* 4*/ { "41038422416563762xy11 ", 0, 3, 155 }, /* Case insensitive */
|
||||
/* 5*/ { "41038422416563762xy11 .", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
||||
/* 6*/ { "0100000000000AA000AA0A", 0, 3, 131, }, /* Length 22, Mailmark C (2 digit chain id) */
|
||||
/* 7*/ { "5100000000000AA000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* 1st char format 0-4 only */
|
||||
/* 8*/ { "0000000000000AA000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* 2nd char version id 1-4 only */
|
||||
/* 9*/ { "01F0000000000AA000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* 3rd char class 0-9A-E only */
|
||||
/* 10*/ { "0100A00000000AA000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* 4-5th chars chain id 2 digits */
|
||||
/* 11*/ { "010000000000AAA000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* 6-13th chars item id 8 digits */
|
||||
/* 12*/ { "0100000000000 A000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* Remaining chars post code */
|
||||
/* 13*/ { "0100000000000C1I2JQ3N ", 0, 3, 131, }, /* F N F N L L N L S */
|
||||
/* 14*/ { "010000000000091I2JQ3N ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N F N L L N L S bad 1st F */
|
||||
/* 15*/ { "0100000000000CAI2JQ3N ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N F N L L N L S bad 1st N */
|
||||
/* 16*/ { "0100000000000C1I2IQ3N ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N F N L L N L S bad 1st L */
|
||||
/* 17*/ { "0100000000000C1I2IQ3NA", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N F N L L N L S bad S */
|
||||
/* 18*/ { "0100000000000KM12JQ3N ", 0, 3, 131, }, /* F F N N L L N L S */
|
||||
/* 19*/ { "0100000000000K 12JQ3N ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N L L N L S bad 2nd F (non-numeric otherwise matches last pattern) */
|
||||
/* 20*/ { "0100000000000KM1AJQ3N ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N L L N L S bad 2nd N */
|
||||
/* 21*/ { "0100000000000KM12JO3N ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N L L N L S bad 2nd L */
|
||||
/* 22*/ { "0100000000000KM12JQ3NA", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N L L N L S bad S */
|
||||
/* 23*/ { "0100000000000OV123JQ4U", 0, 3, 131, }, /* F F N N N L L N L */
|
||||
/* 24*/ { "01000000000009V123JQ4U", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N N L L N L bad 1st F */
|
||||
/* 25*/ { "0100000000000OV12AJQ4U", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N N L L N L bad 3rd N */
|
||||
/* 26*/ { "0100000000000OV123JQ4V", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N N L L N L bad 3rd L */
|
||||
/* 27*/ { "0100000000000CI1K3JQ4U", 0, 3, 131, }, /* F F N F N L L N L */
|
||||
/* 28*/ { "0100000000000CI1 3JQ4U", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N F N L L N L bad 3rd F (non-numeric otherwise matches pattern above) */
|
||||
/* 29*/ { "0100000000000CIAK3JQ4U", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N F N L L N L bad 1st N */
|
||||
/* 30*/ { "0100000000000CI1K3CQ4U", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N F N L L N L bad 1st L */
|
||||
/* 31*/ { "0100000000000C12JQ3U ", 0, 3, 131, }, /* F N N L L N L S S */
|
||||
/* 32*/ { "0100000000000912JQ3U ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N L L N L S S bad F */
|
||||
/* 33*/ { "0100000000000C1AJQ3U ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N L L N L S S bad 2nd N */
|
||||
/* 34*/ { "0100000000000C12JO3U ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N L L N L S S bad 2nd L */
|
||||
/* 35*/ { "0100000000000C12JQ3UA ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N L L N L S S bad 1st S */
|
||||
/* 36*/ { "0100000000000C123JQ4U ", 0, 3, 131, }, /* F N N N L L N L S */
|
||||
/* 37*/ { "01000000000009123JQ4U ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N N L L N L S bad F */
|
||||
/* 38*/ { "0100000000000C12AJQ4U ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N N L L N L S bad 3rd N */
|
||||
/* 39*/ { "0100000000000C123JQ4V ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N N L L N L S bad 3rd L */
|
||||
/* 40*/ { "0100000000000C123JQ4U1", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N N L L N L S bad S */
|
||||
/* 41*/ { "01000000000000000AA000AA0A", 0, 3, 155, }, /* Length 26, Mailmark L (6 digit chain id) */
|
||||
/* 42*/ { "010A0000000000000AA000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* 4-9th chars chain id 6 digits */
|
||||
/* 43*/ { "010A0000000000000 A000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* Post code */
|
||||
/* 44*/ { "01000000000000000C1I2JQ3N ", 0, 3, 155, }, /* F N F N L L N L S */
|
||||
/* 45*/ { "01000000000000000C1 2JQ3N ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N F N L L N L S bad 2nd F */
|
||||
/* 46*/ { "01000000000000000KM12JQ3N ", 0, 3, 155, }, /* F F N N L L N L S */
|
||||
/* 47*/ { "01000000000000000KM12JQAN ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N L L N L S bad 3rd N */
|
||||
/* 48*/ { "01000000000000000OV123JQ4U", 0, 3, 155, }, /* F F N N N L L N L */
|
||||
/* 49*/ { "01000000000000000OV123IQ4U", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N N L L N L bad 1st L */
|
||||
/* 50*/ { "01000000000000000CI1K3JQ4U", 0, 3, 155, }, /* F F N F N L L N L */
|
||||
/* 51*/ { "010000000000000009I1K3JQ4U", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N F N L L N L bad 1st F */
|
||||
/* 52*/ { "01000000000000000C12JQ3U ", 0, 3, 155, }, /* F N N L L N L S S */
|
||||
/* 53*/ { "01000000000000000C12JQ3U A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N L L N L S S bad 2nd S */
|
||||
/* 54*/ { "01000000000000000C123JQ4U ", 0, 3, 155, }, /* F N N N L L N L S */
|
||||
/* 55*/ { "01000000000000000C 23JQ4U ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N N L L N L S bad 1st N (non-alpha otherwise matches 2nd pattern) */
|
||||
/* 56*/ { "41038422416563762XY1", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
|
|
|
@ -30,6 +30,11 @@
|
|||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
|
||||
#include "testcommon.h"
|
||||
#include "../output.h"
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <direct.h>
|
||||
#endif
|
||||
|
||||
INTERNAL int out_quiet_zones_test(const struct zint_symbol *symbol, const int hide_text,
|
||||
float *left, float *right, float *top, float *bottom);
|
||||
|
@ -57,10 +62,107 @@ static void test_quiet_zones(const testCtx *const p_ctx) {
|
|||
testFinish();
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#define TEST_OUT_SEP '\\'
|
||||
#define TEST_OUT_SEP_STR "\\"
|
||||
#else
|
||||
#define TEST_OUT_SEP '/'
|
||||
#define TEST_OUT_SEP_STR "/"
|
||||
#endif
|
||||
|
||||
static void test_fopen(const testCtx *const p_ctx) {
|
||||
struct item {
|
||||
char dir[32];
|
||||
char subdir[32];
|
||||
char *filename;
|
||||
int succeed;
|
||||
};
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
struct item data[] = {
|
||||
/* 0*/ { "", "", "out.png", 1 },
|
||||
/* 1*/ { "out_test", "", "out.png", 1 },
|
||||
/* 2*/ { "out_test_with_subdir", "out_test_subdir", "out.png", 1 },
|
||||
/* 3*/ { "out_test_with_subdir", "out_test_subdir", "out.bmp", 1 },
|
||||
/* 4*/ { "out_test_with_subdir", "out_test_subdir", "out.emf", 1 },
|
||||
/* 5*/ { "out_test_with_subdir", "out_test_subdir", "out.eps", 1 },
|
||||
/* 6*/ { "out_test_with_subdir", "out_test_subdir", "out.gif", 1 },
|
||||
/* 7*/ { "out_test_with_subdir", "out_test_subdir", "out.pcx", 1 },
|
||||
/* 8*/ { "out_test_with_subdir", "out_test_subdir", "out.svg", 1 },
|
||||
/* 9*/ { "out_test_with_subdir", "out_test_subdir", "out.tif", 1 },
|
||||
/* 10*/ { "out_test/", "", "out.png", 1 },
|
||||
/* 11*/ { "out_test//", "", "out.png", 1 },
|
||||
/* 12*/ { "out_test/", "/out_test_subdir/", "out.png", 1 },
|
||||
/* 13*/ { "out_test\\", "\\out_test_subdir\\", "out.png", 1 },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, len;
|
||||
|
||||
FILE *ret;
|
||||
char cwdbuf[1024];
|
||||
char outfile[1024 + 256];
|
||||
char dirname[1024 + 256];
|
||||
char subdirname[1024 + 256];
|
||||
int dir_exists, subdir_exists;
|
||||
|
||||
testStart("test_fopen");
|
||||
|
||||
assert_nonnull(getcwd(cwdbuf, sizeof(cwdbuf)), "getcwd NULL (%d, %s)\n", errno, strerror(errno));
|
||||
|
||||
for (i = 0; i < data_size; i++) {
|
||||
|
||||
if (testContinue(p_ctx, i)) continue;
|
||||
|
||||
strcpy(outfile, cwdbuf);
|
||||
len = strlen(outfile);
|
||||
if (len && outfile[len - 1] != TEST_OUT_SEP) { outfile[len++] = TEST_OUT_SEP; outfile[len] = '\0'; }
|
||||
dir_exists = subdir_exists = 0;
|
||||
|
||||
if (data[i].dir[0]) {
|
||||
strcat(outfile, data[i].dir);
|
||||
strcat(outfile, TEST_OUT_SEP_STR);
|
||||
strcpy(dirname, outfile);
|
||||
dir_exists = testUtilDirExists(dirname);
|
||||
if (data[i].subdir[0]) {
|
||||
strcat(outfile, data[i].subdir);
|
||||
strcat(outfile, TEST_OUT_SEP_STR);
|
||||
strcpy(subdirname, outfile);
|
||||
subdir_exists = testUtilDirExists(subdirname);
|
||||
}
|
||||
}
|
||||
strcat(outfile, data[i].filename);
|
||||
|
||||
ret = out_fopen(outfile, "w");
|
||||
if (data[i].succeed) {
|
||||
assert_nonnull(ret, "i:%d out_fopen(%s) == NULL (%d: %s)\n", i, outfile, errno, strerror(errno));
|
||||
assert_zero(fclose(ret), "i:%d fclose(%s) != 0 (%d: %s)\n", i, outfile, errno, strerror(errno));
|
||||
assert_nonzero(testUtilExists(outfile), "i:%d testUtilExists(%s) != 0 (%d: %s)\n", i, outfile, errno, strerror(errno));
|
||||
if (data[i].dir[0]) {
|
||||
assert_nonzero(testUtilDirExists(dirname), "i:%d testUtilDirExists(%s) != 0 (%d: %s)\n", i, dirname, errno, strerror(errno));
|
||||
}
|
||||
assert_zero(remove(outfile), "i:%d remove(%s) != 0 (%d: %s)\n", i, outfile, errno, strerror(errno));
|
||||
if (data[i].dir[0]) {
|
||||
if (data[i].subdir[0] && !subdir_exists) {
|
||||
assert_zero(testUtilRmDir(subdirname), "i:%d rmdir(%s) != 0 (%d: %s)\n", i, subdirname, errno, strerror(errno));
|
||||
}
|
||||
if (!dir_exists && strcmp(dirname, "/") != 0 && strcmp(dirname, "\\") != 0) {
|
||||
assert_zero(testUtilRmDir(dirname), "i:%d rmdir(%s) != 0 (%d: %s)\n", i, dirname, errno, strerror(errno));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
assert_null(ret, "i:%d out_fopen(%s) == NULL (%d: %s)\n", i, outfile, errno, strerror(errno));
|
||||
/* TODO: may have left junk around */
|
||||
}
|
||||
}
|
||||
|
||||
testFinish();
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
testFunction funcs[] = { /* name, func */
|
||||
{ "test_quiet_zones", test_quiet_zones },
|
||||
{ "test_fopen", test_fopen },
|
||||
};
|
||||
|
||||
testRun(argc, argv, funcs, ARRAY_SIZE(funcs));
|
||||
|
|
|
@ -65,7 +65,7 @@ static void test_print(const testCtx *const p_ctx) {
|
|||
char escaped[1024];
|
||||
int escaped_size = 1024;
|
||||
|
||||
int have_identify = testUtilHaveIdentify();
|
||||
const char *const have_identify = testUtilHaveIdentify();
|
||||
|
||||
testStart("test_pcx");
|
||||
|
||||
|
@ -124,7 +124,7 @@ static void test_print(const testCtx *const p_ctx) {
|
|||
ret = testUtilRename(symbol->outfile, expected_file);
|
||||
assert_zero(ret, "i:%d testUtilRename(%s, %s) ret %d != 0 (%d: %s)\n", i, symbol->outfile, expected_file, ret, errno, strerror(errno));
|
||||
if (have_identify) {
|
||||
ret = testUtilVerifyIdentify(expected_file, debug);
|
||||
ret = testUtilVerifyIdentify(have_identify, expected_file, debug);
|
||||
assert_zero(ret, "i:%d %s identify %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), expected_file, ret);
|
||||
}
|
||||
} else {
|
||||
|
@ -157,10 +157,13 @@ static void test_outfile(const testCtx *const p_ctx) {
|
|||
symbol.bitmap = data;
|
||||
symbol.bitmap_width = symbol.bitmap_height = 1;
|
||||
|
||||
strcpy(symbol.outfile, "nosuch_dir/out.pcx");
|
||||
strcpy(symbol.outfile, "test_pcx_out.pcx");
|
||||
(void) testUtilRmROFile(symbol.outfile); /* In case lying around from previous fail */
|
||||
assert_nonzero(testUtilCreateROFile(symbol.outfile), "pcx_pixel_plot testUtilCreateROFile(%s) fail (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
ret = pcx_pixel_plot(&symbol, data);
|
||||
assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "pcx_pixel_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt);
|
||||
assert_zero(testUtilRmROFile(symbol.outfile), "pcx_pixel_plot testUtilRmROFile(%s) != 0 (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
symbol.output_options |= BARCODE_STDOUT;
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
|
|||
|
||||
char data_buf[8 * 2 + 1];
|
||||
|
||||
int have_identify = testUtilHaveIdentify();
|
||||
const char *const have_identify = testUtilHaveIdentify();
|
||||
|
||||
testStart("test_pixel_plot");
|
||||
|
||||
|
@ -98,7 +98,7 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
|
|||
|
||||
if (ret < ZINT_ERROR) {
|
||||
if (have_identify) {
|
||||
ret = testUtilVerifyIdentify(symbol->outfile, debug);
|
||||
ret = testUtilVerifyIdentify(have_identify, symbol->outfile, debug);
|
||||
assert_zero(ret, "i:%d identify %s ret %d != 0\n", i, symbol->outfile, ret);
|
||||
}
|
||||
if (!(debug & ZINT_DEBUG_TEST_KEEP_OUTFILE)) {
|
||||
|
@ -214,7 +214,7 @@ static void test_print(const testCtx *const p_ctx) {
|
|||
int escaped_size = 1024;
|
||||
char *text;
|
||||
|
||||
int have_identify = testUtilHaveIdentify();
|
||||
const char *const have_identify = testUtilHaveIdentify();
|
||||
|
||||
testStart("test_print");
|
||||
|
||||
|
@ -288,7 +288,7 @@ static void test_print(const testCtx *const p_ctx) {
|
|||
ret = testUtilRename(symbol->outfile, expected_file);
|
||||
assert_zero(ret, "i:%d testUtilRename(%s, %s) ret %d != 0\n", i, symbol->outfile, expected_file, ret);
|
||||
if (have_identify) {
|
||||
ret = testUtilVerifyIdentify(expected_file, debug);
|
||||
ret = testUtilVerifyIdentify(have_identify, expected_file, debug);
|
||||
assert_zero(ret, "i:%d %s identify %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), expected_file, ret);
|
||||
}
|
||||
} else {
|
||||
|
@ -321,10 +321,13 @@ static void test_outfile(const testCtx *const p_ctx) {
|
|||
symbol.bitmap = data;
|
||||
symbol.bitmap_width = symbol.bitmap_height = 1;
|
||||
|
||||
strcpy(symbol.outfile, "nosuch_dir/out.png");
|
||||
strcpy(symbol.outfile, "test_png_out.png");
|
||||
(void) testUtilRmROFile(symbol.outfile); /* In case lying around from previous fail */
|
||||
assert_nonzero(testUtilCreateROFile(symbol.outfile), "png_pixel_plot testUtilCreateROFile(%s) fail (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
ret = png_pixel_plot(&symbol, data);
|
||||
assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "png_pixel_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt);
|
||||
assert_zero(testUtilRmROFile(symbol.outfile), "png_pixel_plot testUtilRmROFile(%s) != 0 (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
symbol.output_options |= BARCODE_STDOUT;
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ static void test_print(const testCtx *const p_ctx) {
|
|||
char escaped[1024];
|
||||
int escaped_size = 1024;
|
||||
|
||||
int have_identify = 0;
|
||||
const char *have_identify = NULL;
|
||||
int have_libreoffice = 0;
|
||||
int have_ghostscript = 0;
|
||||
int have_vnu = 0;
|
||||
|
@ -177,7 +177,7 @@ static void test_print(const testCtx *const p_ctx) {
|
|||
assert_zero(ret, "i:%d %s tiffinfo %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), expected_file, ret);
|
||||
} else if (strcmp(exts[j], "txt") != 0) { /* I.e. rasters */
|
||||
if (have_identify) {
|
||||
ret = testUtilVerifyIdentify(expected_file, debug);
|
||||
ret = testUtilVerifyIdentify(have_identify, expected_file, debug);
|
||||
assert_zero(ret, "i:%d %s identify %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), expected_file, ret);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -224,10 +224,13 @@ static void test_outfile(const testCtx *const p_ctx) {
|
|||
symbol.symbology = BARCODE_CODE128;
|
||||
symbol.vector = &vector;
|
||||
|
||||
strcpy(symbol.outfile, "nosuch_dir/out.eps");
|
||||
strcpy(symbol.outfile, "test_ps_out.eps");
|
||||
(void) testUtilRmROFile(symbol.outfile); /* In case lying around from previous fail */
|
||||
assert_nonzero(testUtilCreateROFile(symbol.outfile), "ps_plot testUtilCreateROFile(%s) fail (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
ret = ps_plot(&symbol, 0);
|
||||
assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "ps_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt);
|
||||
assert_zero(testUtilRmROFile(symbol.outfile), "ps_plot testUtilRmROFile(%s) != 0 (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
symbol.output_options |= BARCODE_STDOUT;
|
||||
|
||||
|
|
|
@ -91,10 +91,12 @@ static void test_qr_options(const testCtx *const p_ctx) {
|
|||
/* 38*/ { -1, -1, 4, 1, { 3, 16, "123" }, "12345678901", 0, 0, 21, -1, "" },
|
||||
/* 39*/ { -1, -1, 4, 1, { 3, 17, "123" }, "12345678901", ZINT_ERROR_INVALID_OPTION, -1, 0, -1, "Error 750: Structured Append count out of range (2-16)" },
|
||||
/* 40*/ { -1, -1, 4, 1, { 3, 2, "123" }, "12345678901", ZINT_ERROR_INVALID_OPTION, -1, 0, -1, "Error 751: Structured Append index out of range (1-2)" },
|
||||
/* 41*/ { -1, -1, 4, 1, { 1, 2, "256" }, "12345678901", ZINT_ERROR_INVALID_OPTION, -1, 0, -1, "Error 754: Structured Append ID '256' out of range (0-255)" },
|
||||
/* 42*/ { GS1_MODE, 3, -1, -1, { 0, 0, "" }, "[20]12", ZINT_WARN_NONCOMPLIANT, 0, 21, -1, "Warning 755: Using ECI in GS1 mode not supported by GS1 standards" },
|
||||
/* 43*/ { GS1_MODE, -1, -1, -1, { 1, 2, "" }, "[20]12", ZINT_WARN_NONCOMPLIANT, 0, 21, -1, "Warning 756: Using Structured Append in GS1 mode not supported by GS1 standards" },
|
||||
/* 44*/ { GS1_MODE, 3, -1, -1, { 1, 2, "" }, "[20]12", ZINT_WARN_NONCOMPLIANT, 0, 21, -1, "Warning 755: Using ECI in GS1 mode not supported by GS1 standards" }, /* ECI trumps Structured Append */
|
||||
/* 41*/ { -1, -1, 4, 1, { 1, 2, "1234" }, "12345678901", ZINT_ERROR_INVALID_OPTION, -1, 0, -1, "Error 752: Structured Append ID too long (3 digit maximum)" },
|
||||
/* 42*/ { -1, -1, 4, 1, { 1, 2, "12A" }, "12345678901", ZINT_ERROR_INVALID_OPTION, -1, 0, -1, "Error 753: Invalid Structured Append ID (digits only)" },
|
||||
/* 43*/ { -1, -1, 4, 1, { 1, 2, "256" }, "12345678901", ZINT_ERROR_INVALID_OPTION, -1, 0, -1, "Error 754: Structured Append ID '256' out of range (0-255)" },
|
||||
/* 44*/ { GS1_MODE, 3, -1, -1, { 0, 0, "" }, "[20]12", ZINT_WARN_NONCOMPLIANT, 0, 21, -1, "Warning 755: Using ECI in GS1 mode not supported by GS1 standards" },
|
||||
/* 45*/ { GS1_MODE, -1, -1, -1, { 1, 2, "" }, "[20]12", ZINT_WARN_NONCOMPLIANT, 0, 21, -1, "Warning 756: Using Structured Append in GS1 mode not supported by GS1 standards" },
|
||||
/* 46*/ { GS1_MODE, 3, -1, -1, { 1, 2, "" }, "[20]12", ZINT_WARN_NONCOMPLIANT, 0, 21, -1, "Warning 755: Using ECI in GS1 mode not supported by GS1 standards" }, /* ECI trumps Structured Append */
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
|
|
|
@ -176,10 +176,10 @@ static void test_buffer(const testCtx *const p_ctx) {
|
|||
/* 51*/ { BARCODE_CODABAR, COMPLIANT_HEIGHT, "A00000000B", "", 50, 1, 102, 204, 116 },
|
||||
/* 52*/ { BARCODE_CODE128, -1, "1234567890", "", 50, 1, 90, 180, 116 },
|
||||
/* 53*/ { BARCODE_CODE128, COMPLIANT_HEIGHT, "1234567890", "", 50, 1, 90, 180, 116 },
|
||||
/* 54*/ { BARCODE_DPLEIT, -1, "1234567890123", "", 50, 1, 135, 270, 116 },
|
||||
/* 55*/ { BARCODE_DPLEIT, COMPLIANT_HEIGHT, "1234567890123", "", 50, 1, 135, 270, 116 },
|
||||
/* 56*/ { BARCODE_DPIDENT, -1, "12345678901", "", 50, 1, 117, 234, 116 },
|
||||
/* 57*/ { BARCODE_DPIDENT, COMPLIANT_HEIGHT, "12345678901", "", 50, 1, 117, 234, 116 },
|
||||
/* 54*/ { BARCODE_DPLEIT, -1, "1234567890123", "", 72, 1, 135, 270, 160 },
|
||||
/* 55*/ { BARCODE_DPLEIT, COMPLIANT_HEIGHT, "1234567890123", "", 72, 1, 135, 270, 160 },
|
||||
/* 56*/ { BARCODE_DPIDENT, -1, "12345678901", "", 72, 1, 117, 234, 160 },
|
||||
/* 57*/ { BARCODE_DPIDENT, COMPLIANT_HEIGHT, "12345678901", "", 72, 1, 117, 234, 160 },
|
||||
/* 58*/ { BARCODE_CODE16K, -1, "1234567890", "", 20, 2, 70, 162, 44 },
|
||||
/* 59*/ { BARCODE_CODE16K, COMPLIANT_HEIGHT, "1234567890", "", 21, 2, 70, 162, 46 },
|
||||
/* 60*/ { BARCODE_CODE49, -1, "1234567890", "", 20, 2, 70, 162, 44 },
|
||||
|
@ -244,8 +244,8 @@ static void test_buffer(const testCtx *const p_ctx) {
|
|||
/*119*/ { BARCODE_MAXICODE, COMPLIANT_HEIGHT, "1234567890", "", 165, 33, 30, 299, 298 },
|
||||
/*120*/ { BARCODE_QRCODE, -1, "1234567890AB", "", 21, 21, 21, 42, 42 },
|
||||
/*121*/ { BARCODE_QRCODE, COMPLIANT_HEIGHT, "1234567890AB", "", 21, 21, 21, 42, 42 },
|
||||
/*122*/ { BARCODE_CODE128B, -1, "1234567890", "", 50, 1, 145, 290, 116 },
|
||||
/*123*/ { BARCODE_CODE128B, COMPLIANT_HEIGHT, "1234567890", "", 50, 1, 145, 290, 116 },
|
||||
/*122*/ { BARCODE_CODE128AB, -1, "1234567890", "", 50, 1, 145, 290, 116 },
|
||||
/*123*/ { BARCODE_CODE128AB, COMPLIANT_HEIGHT, "1234567890", "", 50, 1, 145, 290, 116 },
|
||||
/*124*/ { BARCODE_AUSPOST, -1, "12345678901234567890123", "", 8, 3, 133, 266, 16 },
|
||||
/*125*/ { BARCODE_AUSPOST, COMPLIANT_HEIGHT, "12345678901234567890123", "", 9.5, 3, 133, 266, 19 },
|
||||
/*126*/ { BARCODE_AUSREPLY, -1, "12345678", "", 8, 3, 73, 146, 16 },
|
||||
|
@ -1477,10 +1477,10 @@ static void test_quiet_zones(const testCtx *const p_ctx) {
|
|||
/* 44*/ { BARCODE_CODABAR, BARCODE_QUIET_ZONES, -1, -1, "A0B", 0, 50, 1, 32, 104, 116, 0 /*set*/, 0, 100, 0, 20 },
|
||||
/* 45*/ { BARCODE_CODE128, -1, -1, -1, "1234", 0, 50, 1, 57, 114, 116, 1 /*set*/, 0, 100, 0, 4 },
|
||||
/* 46*/ { BARCODE_CODE128, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 50, 1, 57, 154, 116, 0 /*set*/, 0, 100, 0, 20 },
|
||||
/* 47*/ { BARCODE_DPLEIT, -1, -1, -1, "1234", 0, 50, 1, 135, 270, 116, 1 /*set*/, 0, 100, 0, 2 },
|
||||
/* 48*/ { BARCODE_DPLEIT, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 50, 1, 135, 310, 116, 0 /*set*/, 0, 100, 0, 20 },
|
||||
/* 49*/ { BARCODE_DPIDENT, -1, -1, -1, "1234", 0, 50, 1, 117, 234, 116, 1 /*set*/, 0, 100, 0, 2 },
|
||||
/* 50*/ { BARCODE_DPIDENT, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 50, 1, 117, 274, 116, 0 /*set*/, 0, 100, 0, 20 },
|
||||
/* 47*/ { BARCODE_DPLEIT, -1, -1, -1, "1234", 0, 72, 1, 135, 270, 160, 1 /*set*/, 0, 100, 0, 2 },
|
||||
/* 48*/ { BARCODE_DPLEIT, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 72, 1, 135, 310, 160, 0 /*set*/, 0, 100, 0, 20 },
|
||||
/* 49*/ { BARCODE_DPIDENT, -1, -1, -1, "1234", 0, 72, 1, 117, 234, 160, 1 /*set*/, 0, 100, 0, 2 },
|
||||
/* 50*/ { BARCODE_DPIDENT, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 72, 1, 117, 274, 160, 0 /*set*/, 0, 100, 0, 20 },
|
||||
/* 51*/ { BARCODE_CODE16K, -1, -1, -1, "1234", 0, 20, 2, 70, 162, 44, 0 /*set*/, 2, 20, 0, 20 },
|
||||
/* 52*/ { BARCODE_CODE16K, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 20, 2, 70, 162, 44, 0 /*set*/, 2, 20, 0, 20 },
|
||||
/* 53*/ { BARCODE_CODE16K, BARCODE_NO_QUIET_ZONES, -1, -1, "1234", 0, 20, 2, 70, 140, 44, 1 /*set*/, 2, 20, 0, 6 },
|
||||
|
@ -1564,8 +1564,8 @@ static void test_quiet_zones(const testCtx *const p_ctx) {
|
|||
/*131*/ { BARCODE_MAXICODE, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 165, 33, 30, 319, 318, 0 /*set*/, 0, 9, 0, 319 },
|
||||
/*132*/ { BARCODE_QRCODE, -1, -1, -1, "1234", 0, 21, 21, 21, 42, 42, 1 /*set*/, 0, 2, 0, 14 },
|
||||
/*133*/ { BARCODE_QRCODE, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 21, 21, 21, 58, 58, 0 /*set*/, 0, 8, 0, 58 },
|
||||
/*134*/ { BARCODE_CODE128B, -1, -1, -1, "1234", 0, 50, 1, 79, 158, 116, 1 /*set*/, 0, 100, 0, 4 },
|
||||
/*135*/ { BARCODE_CODE128B, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 50, 1, 79, 198, 116, 0 /*set*/, 0, 100, 0, 20 },
|
||||
/*134*/ { BARCODE_CODE128AB, -1, -1, -1, "1234", 0, 50, 1, 79, 158, 116, 1 /*set*/, 0, 100, 0, 4 },
|
||||
/*135*/ { BARCODE_CODE128AB, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 50, 1, 79, 198, 116, 0 /*set*/, 0, 100, 0, 20 },
|
||||
/*136*/ { BARCODE_AUSPOST, -1, -1, -1, "12345678", 0, 8, 3, 73, 146, 16, 1 /*set*/, 0, 10, 0, 2 },
|
||||
/*137*/ { BARCODE_AUSPOST, BARCODE_QUIET_ZONES, -1, -1, "12345678", 0, 8, 3, 73, 186, 28, 0 /*set*/, 0, 28, 0, 20 },
|
||||
/*138*/ { BARCODE_AUSREPLY, -1, -1, -1, "1234", 0, 8, 3, 73, 146, 16, 1 /*set*/, 0, 10, 0, 2 },
|
||||
|
@ -2045,8 +2045,8 @@ static void test_height(const testCtx *const p_ctx) {
|
|||
/* 50*/ { BARCODE_CODABAR, -1, 1, "A0B", "", 0, 1, 1, 32, 64, 2, "" },
|
||||
/* 51*/ { BARCODE_CODABAR, -1, 4, "A0B", "", 0, 4, 1, 32, 64, 8, "" },
|
||||
/* 52*/ { BARCODE_CODABAR, -1, 26, "A0B", "", 0, 26, 1, 32, 64, 52, "" },
|
||||
/* 53*/ { BARCODE_CODABAR, COMPLIANT_HEIGHT, 26, "A0B", "", ZINT_WARN_NONCOMPLIANT, 26, 1, 32, 64, 52, "" },
|
||||
/* 54*/ { BARCODE_CODABAR, COMPLIANT_HEIGHT, 27, "A0B", "", 0, 27, 1, 32, 64, 54, "" },
|
||||
/* 53*/ { BARCODE_CODABAR, COMPLIANT_HEIGHT, 11, "A0B", "", ZINT_WARN_NONCOMPLIANT, 11, 1, 32, 64, 22, "" },
|
||||
/* 54*/ { BARCODE_CODABAR, COMPLIANT_HEIGHT, 12, "A0B", "", 0, 12, 1, 32, 64, 24, "" },
|
||||
/* 55*/ { BARCODE_CODE128, -1, 1, "1234567890", "", 0, 1, 1, 90, 180, 2, "" },
|
||||
/* 56*/ { BARCODE_CODE128, COMPLIANT_HEIGHT, 1, "1234567890", "", 0, 1, 1, 90, 180, 2, "" },
|
||||
/* 57*/ { BARCODE_CODE128, -1, 4, "1234567890", "", 0, 4, 1, 90, 180, 8, "" },
|
||||
|
@ -2188,9 +2188,9 @@ static void test_height(const testCtx *const p_ctx) {
|
|||
/*193*/ { BARCODE_PDF417COMP, -1, 24, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJ", "", ZINT_WARN_NONCOMPLIANT, 22.5, 9, 86, 172, 45, "" },
|
||||
/*194*/ { BARCODE_MAXICODE, -1, 1, "1234567890", "", 0, 16.5, 33, 30, 299, 298, "Fixed size, symbol->height ignored" },
|
||||
/*195*/ { BARCODE_QRCODE, -1, 1, "ABCD", "", 0, 21, 21, 21, 42, 42, "Fixed width-to-height ratio, symbol->height ignored" },
|
||||
/*196*/ { BARCODE_CODE128B, -1, 1, "1234567890", "", 0, 1, 1, 145, 290, 2, "" },
|
||||
/*197*/ { BARCODE_CODE128B, COMPLIANT_HEIGHT, 1, "1234567890", "", 0, 1, 1, 145, 290, 2, "" },
|
||||
/*198*/ { BARCODE_CODE128B, -1, 4, "1234567890", "", 0, 4, 1, 145, 290, 8, "" },
|
||||
/*196*/ { BARCODE_CODE128AB, -1, 1, "1234567890", "", 0, 1, 1, 145, 290, 2, "" },
|
||||
/*197*/ { BARCODE_CODE128AB, COMPLIANT_HEIGHT, 1, "1234567890", "", 0, 1, 1, 145, 290, 2, "" },
|
||||
/*198*/ { BARCODE_CODE128AB, -1, 4, "1234567890", "", 0, 4, 1, 145, 290, 8, "" },
|
||||
/*199*/ { BARCODE_AUSPOST, -1, -1, "12345678901234567890123", "", 0, 8, 3, 133, 266, 16, "" },
|
||||
/*200*/ { BARCODE_AUSPOST, -1, 1, "12345678901234567890123", "", 0, 2.5, 3, 133, 266, 5, "" },
|
||||
/*201*/ { BARCODE_AUSPOST, COMPLIANT_HEIGHT, 1, "12345678901234567890123", "", ZINT_WARN_NONCOMPLIANT, 1.5, 3, 133, 266, 3, "" },
|
||||
|
|
|
@ -232,10 +232,13 @@ static void test_outfile(const testCtx *const p_ctx) {
|
|||
symbol.symbology = BARCODE_CODE128;
|
||||
symbol.vector = &vector;
|
||||
|
||||
strcpy(symbol.outfile, "nosuch_dir/out.svg");
|
||||
strcpy(symbol.outfile, "test_svg_out.svg");
|
||||
(void) testUtilRmROFile(symbol.outfile); /* In case lying around from previous fail */
|
||||
assert_nonzero(testUtilCreateROFile(symbol.outfile), "svg_plot testUtilCreateROFile(%s) fail (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
ret = svg_plot(&symbol, 0);
|
||||
assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "svg_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt);
|
||||
assert_zero(testUtilRmROFile(symbol.outfile), "svg_plot testUtilRmROFile(%s) != 0 (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
symbol.output_options |= BARCODE_STDOUT;
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
|
|||
char data_buf[ZINT_MAX_DATA_LEN * 2 + 1];
|
||||
|
||||
int have_tiffinfo = testUtilHaveTiffInfo();
|
||||
int have_identify = testUtilHaveIdentify();
|
||||
const char *const have_identify = testUtilHaveIdentify();
|
||||
|
||||
testStart("test_pixel_plot");
|
||||
|
||||
|
@ -136,7 +136,7 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
|
|||
ret = testUtilVerifyTiffInfo(symbol->outfile, debug);
|
||||
assert_zero(ret, "i:%d tiffinfo %s ret %d != 0\n", i, symbol->outfile, ret);
|
||||
} else if (have_identify && !data[i].no_identify) {
|
||||
ret = testUtilVerifyIdentify(symbol->outfile, debug);
|
||||
ret = testUtilVerifyIdentify(have_identify, symbol->outfile, debug);
|
||||
assert_zero(ret, "i:%d identify %s ret %d != 0\n", i, symbol->outfile, ret);
|
||||
}
|
||||
|
||||
|
@ -214,7 +214,7 @@ static void test_print(const testCtx *const p_ctx) {
|
|||
char *text;
|
||||
|
||||
int have_tiffinfo = testUtilHaveTiffInfo();
|
||||
int have_identify = testUtilHaveIdentify();
|
||||
const char *const have_identify = testUtilHaveIdentify();
|
||||
|
||||
testStart("test_print");
|
||||
|
||||
|
@ -289,7 +289,7 @@ static void test_print(const testCtx *const p_ctx) {
|
|||
ret = testUtilVerifyTiffInfo(expected_file, debug);
|
||||
assert_zero(ret, "i:%d %s tiffinfo %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), expected_file, ret);
|
||||
} else if (have_identify) {
|
||||
ret = testUtilVerifyIdentify(expected_file, debug);
|
||||
ret = testUtilVerifyIdentify(have_identify, expected_file, debug);
|
||||
assert_zero(ret, "i:%d %s identify %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), expected_file, ret);
|
||||
}
|
||||
} else {
|
||||
|
@ -320,10 +320,13 @@ static void test_outfile(const testCtx *const p_ctx) {
|
|||
symbol.bitmap = data;
|
||||
symbol.bitmap_width = symbol.bitmap_height = 1;
|
||||
|
||||
strcpy(symbol.outfile, "nosuch_dir/out.tif");
|
||||
strcpy(symbol.outfile, "test_tif_out.tif");
|
||||
(void) testUtilRmROFile(symbol.outfile); /* In case lying around from previous fail */
|
||||
assert_nonzero(testUtilCreateROFile(symbol.outfile), "tif_pixel_plot testUtilCreateROFile(%s) fail (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
ret = tif_pixel_plot(&symbol, data);
|
||||
assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "tif_pixel_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt);
|
||||
assert_zero(testUtilRmROFile(symbol.outfile), "tif_pixel_plot testUtilRmROFile(%s) != 0 (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
symbol.output_options |= BARCODE_STDOUT;
|
||||
|
||||
|
|
|
@ -188,8 +188,8 @@ static void test_buffer_vector(const testCtx *const p_ctx) {
|
|||
/* 24*/ { BARCODE_GS1_128, "[01]12345678901231", "", 50, 1, 134, 268, 118.900002 },
|
||||
/* 25*/ { BARCODE_CODABAR, "A00000000B", "", 50, 1, 102, 204, 118.900002 },
|
||||
/* 26*/ { BARCODE_CODE128, "1234567890", "", 50, 1, 90, 180, 118.900002 },
|
||||
/* 27*/ { BARCODE_DPLEIT, "1234567890123", "", 50, 1, 135, 270, 118.900002 },
|
||||
/* 28*/ { BARCODE_DPIDENT, "12345678901", "", 50, 1, 117, 234, 118.900002 },
|
||||
/* 27*/ { BARCODE_DPLEIT, "1234567890123", "", 72, 1, 135, 270, 162.89999 },
|
||||
/* 28*/ { BARCODE_DPIDENT, "12345678901", "", 72, 1, 117, 234, 162.89999 },
|
||||
/* 29*/ { BARCODE_CODE16K, "1234567890", "", 20, 2, 70, 162, 44 },
|
||||
/* 30*/ { BARCODE_CODE49, "1234567890", "", 20, 2, 70, 162, 44 },
|
||||
/* 31*/ { BARCODE_CODE93, "1234567890", "", 50, 1, 127, 254, 118.900002 },
|
||||
|
@ -222,7 +222,7 @@ static void test_buffer_vector(const testCtx *const p_ctx) {
|
|||
/* 58*/ { BARCODE_PDF417COMP, "1234567890", "", 21, 7, 69, 138, 42 },
|
||||
/* 59*/ { BARCODE_MAXICODE, "1234567890", "", 165, 33, 30, 60, 57.7333984 },
|
||||
/* 60*/ { BARCODE_QRCODE, "1234567890AB", "", 21, 21, 21, 42, 42 },
|
||||
/* 61*/ { BARCODE_CODE128B, "1234567890", "", 50, 1, 145, 290, 118.900002 },
|
||||
/* 61*/ { BARCODE_CODE128AB, "1234567890", "", 50, 1, 145, 290, 118.900002 },
|
||||
/* 62*/ { BARCODE_AUSPOST, "12345678901234567890123", "", 8, 3, 133, 266, 16 },
|
||||
/* 63*/ { BARCODE_AUSREPLY, "12345678", "", 8, 3, 73, 146, 16 },
|
||||
/* 64*/ { BARCODE_AUSROUTE, "12345678", "", 8, 3, 73, 146, 16 },
|
||||
|
@ -1175,10 +1175,10 @@ static void test_quiet_zones(const testCtx *const p_ctx) {
|
|||
/* 44*/ { BARCODE_CODABAR, BARCODE_QUIET_ZONES, -1, -1, "A0B", 0, 50, 1, 32, 104, 118.9, 20, 0, 2, 100 },
|
||||
/* 45*/ { BARCODE_CODE128, -1, -1, -1, "1234", 0, 50, 1, 57, 114, 118.9, 0, 0, 4, 100 },
|
||||
/* 46*/ { BARCODE_CODE128, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 50, 1, 57, 154, 118.9, 20, 0, 4, 100 },
|
||||
/* 47*/ { BARCODE_DPLEIT, -1, -1, -1, "1234", 0, 50, 1, 135, 270, 118.9, 0, 0, 2, 100 },
|
||||
/* 48*/ { BARCODE_DPLEIT, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 50, 1, 135, 310, 118.9, 20, 0, 2, 100 },
|
||||
/* 49*/ { BARCODE_DPIDENT, -1, -1, -1, "1234", 0, 50, 1, 117, 234, 118.9, 0, 0, 2, 100 },
|
||||
/* 50*/ { BARCODE_DPIDENT, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 50, 1, 117, 274, 118.9, 20, 0, 2, 100 },
|
||||
/* 47*/ { BARCODE_DPLEIT, -1, -1, -1, "1234", 0, 72, 1, 135, 270, 162.89999, 0, 0, 2, 144 },
|
||||
/* 48*/ { BARCODE_DPLEIT, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 72, 1, 135, 310, 162.89999, 20, 0, 2, 144 },
|
||||
/* 49*/ { BARCODE_DPIDENT, -1, -1, -1, "1234", 0, 72, 1, 117, 234, 162.89999, 0, 0, 2, 144 },
|
||||
/* 50*/ { BARCODE_DPIDENT, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 72, 1, 117, 274, 162.89999, 20, 0, 2, 144 },
|
||||
/* 51*/ { BARCODE_CODE16K, -1, -1, -1, "1234", 0, 20, 2, 70, 162, 44, 20, 2, 6, 19 },
|
||||
/* 52*/ { BARCODE_CODE16K, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 20, 2, 70, 162, 44, 20, 2, 6, 19 },
|
||||
/* 53*/ { BARCODE_CODE16K, BARCODE_NO_QUIET_ZONES, -1, -1, "1234", 0, 20, 2, 70, 140, 44, 0, 2, 6, 19 },
|
||||
|
@ -1261,8 +1261,8 @@ static void test_quiet_zones(const testCtx *const p_ctx) {
|
|||
/*130*/ { BARCODE_MAXICODE, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 165, 33, 30, 64, 61.733398, 31, 30.866699, 16.430941, 0 },
|
||||
/*131*/ { BARCODE_QRCODE, -1, -1, -1, "1234", 0, 21, 21, 21, 42, 42, 0, 0, 14, 2 },
|
||||
/*132*/ { BARCODE_QRCODE, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 21, 21, 21, 58, 58, 8, 8, 14, 2 },
|
||||
/*133*/ { BARCODE_CODE128B, -1, -1, -1, "1234", 0, 50, 1, 79, 158, 118.9, 0, 0, 4, 100 },
|
||||
/*134*/ { BARCODE_CODE128B, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 50, 1, 79, 198, 118.9, 20, 0, 4, 100 },
|
||||
/*133*/ { BARCODE_CODE128AB, -1, -1, -1, "1234", 0, 50, 1, 79, 158, 118.9, 0, 0, 4, 100 },
|
||||
/*134*/ { BARCODE_CODE128AB, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 50, 1, 79, 198, 118.9, 20, 0, 4, 100 },
|
||||
/*135*/ { BARCODE_AUSPOST, -1, -1, -1, "12345678", 0, 8, 3, 73, 146, 16, 0, 0, 2, 10 },
|
||||
/*136*/ { BARCODE_AUSPOST, BARCODE_QUIET_ZONES, -1, -1, "12345678", 0, 8, 3, 73, 186, 29.333332, 20, 6.6666665, 2, 10 },
|
||||
/*137*/ { BARCODE_AUSREPLY, -1, -1, -1, "1234", 0, 8, 3, 73, 146, 16, 0, 0, 2, 10 },
|
||||
|
@ -1550,8 +1550,8 @@ static void test_height(const testCtx *const p_ctx) {
|
|||
/* 50*/ { BARCODE_CODABAR, -1, 1, "A0B", "", 0, 1, 1, 32, 64, 2, "" },
|
||||
/* 51*/ { BARCODE_CODABAR, -1, 4, "A0B", "", 0, 4, 1, 32, 64, 8, "" },
|
||||
/* 52*/ { BARCODE_CODABAR, -1, 26, "A0B", "", 0, 26, 1, 32, 64, 52, "" },
|
||||
/* 53*/ { BARCODE_CODABAR, COMPLIANT_HEIGHT, 26, "A0B", "", ZINT_WARN_NONCOMPLIANT, 26, 1, 32, 64, 52, "" },
|
||||
/* 54*/ { BARCODE_CODABAR, COMPLIANT_HEIGHT, 27, "A0B", "", 0, 27, 1, 32, 64, 54, "" },
|
||||
/* 53*/ { BARCODE_CODABAR, COMPLIANT_HEIGHT, 11, "A0B", "", ZINT_WARN_NONCOMPLIANT, 11, 1, 32, 64, 22, "" },
|
||||
/* 54*/ { BARCODE_CODABAR, COMPLIANT_HEIGHT, 12, "A0B", "", 0, 12, 1, 32, 64, 24, "" },
|
||||
/* 55*/ { BARCODE_CODE128, -1, 1, "1234567890", "", 0, 1, 1, 90, 180, 2, "" },
|
||||
/* 56*/ { BARCODE_CODE128, COMPLIANT_HEIGHT, 1, "1234567890", "", 0, 1, 1, 90, 180, 2, "" },
|
||||
/* 57*/ { BARCODE_CODE128, -1, 4, "1234567890", "", 0, 4, 1, 90, 180, 8, "" },
|
||||
|
@ -1693,9 +1693,9 @@ static void test_height(const testCtx *const p_ctx) {
|
|||
/*193*/ { BARCODE_PDF417COMP, -1, 24, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJ", "", ZINT_WARN_NONCOMPLIANT, 24, 9, 86, 172, 48, "" },
|
||||
/*194*/ { BARCODE_MAXICODE, -1, 1, "1234567890", "", 0, 16.5, 33, 30, 60, 57.733398, "Fixed size, symbol->height ignored" },
|
||||
/*195*/ { BARCODE_QRCODE, -1, 1, "ABCD", "", 0, 21, 21, 21, 42, 42, "Fixed width-to-height ratio, symbol->height ignored" },
|
||||
/*196*/ { BARCODE_CODE128B, -1, 1, "1234567890", "", 0, 1, 1, 145, 290, 2, "" },
|
||||
/*197*/ { BARCODE_CODE128B, COMPLIANT_HEIGHT, 1, "1234567890", "", 0, 1, 1, 145, 290, 2, "" },
|
||||
/*198*/ { BARCODE_CODE128B, -1, 4, "1234567890", "", 0, 4, 1, 145, 290, 8, "" },
|
||||
/*196*/ { BARCODE_CODE128AB, -1, 1, "1234567890", "", 0, 1, 1, 145, 290, 2, "" },
|
||||
/*197*/ { BARCODE_CODE128AB, COMPLIANT_HEIGHT, 1, "1234567890", "", 0, 1, 1, 145, 290, 2, "" },
|
||||
/*198*/ { BARCODE_CODE128AB, -1, 4, "1234567890", "", 0, 4, 1, 145, 290, 8, "" },
|
||||
/*199*/ { BARCODE_AUSPOST, -1, -1, "12345678901234567890123", "", 0, 8, 3, 133, 266, 16, "" },
|
||||
/*200*/ { BARCODE_AUSPOST, -1, 1, "12345678901234567890123", "", 0, 2, 3, 133, 266, 4, "" },
|
||||
/*201*/ { BARCODE_AUSPOST, COMPLIANT_HEIGHT, 1, "12345678901234567890123", "", ZINT_WARN_NONCOMPLIANT, 1.9230771, 3, 133, 266, 3.8461542, "" },
|
||||
|
|
|
@ -202,7 +202,7 @@ static int validate_int_range(const char src[], int *p_val, int *p_val_end) {
|
|||
|
||||
for (i = 0; i < length; i++) {
|
||||
if (src[i] < '0' || src[i] > '9') {
|
||||
if (src[i] != ',') {
|
||||
if (src[i] != '-') {
|
||||
return 0;
|
||||
}
|
||||
val_end = 0;
|
||||
|
@ -236,9 +236,13 @@ void testRun(int argc, char *argv[], testFunction funcs[], int funcs_size) {
|
|||
char *optarg;
|
||||
char *func = NULL;
|
||||
char func_buf[256 + 5];
|
||||
int exclude_idx = 0;
|
||||
testCtx ctx;
|
||||
|
||||
ctx.index = ctx.index_end = ctx.exclude = ctx.exclude_end = -1;
|
||||
ctx.index = ctx.index_end = -1;
|
||||
for (i = 0; i < ZINT_TEST_CTX_EXC_MAX; i++) {
|
||||
ctx.exclude[i] = ctx.exclude_end[i] = -1;
|
||||
}
|
||||
ctx.generate = ctx.debug = 0;
|
||||
|
||||
if (argc) {
|
||||
|
@ -303,9 +307,13 @@ void testRun(int argc, char *argv[], testFunction funcs[], int funcs_size) {
|
|||
fprintf(stderr, "testRun: -x exclude value missing, ignored\n");
|
||||
} else {
|
||||
optarg = argv[++i];
|
||||
if (!validate_int_range(optarg, &ctx.exclude, &ctx.exclude_end)) {
|
||||
if (exclude_idx + 1 == ZINT_TEST_CTX_EXC_MAX) {
|
||||
fprintf(stderr, "testRun: too many -x exclude values, ignored\n");
|
||||
} else if (!validate_int_range(optarg, &ctx.exclude[exclude_idx], &ctx.exclude_end[exclude_idx])) {
|
||||
fprintf(stderr, "testRun: -x exclude value invalid, ignored\n");
|
||||
ctx.exclude = ctx.exclude_end = -1;
|
||||
ctx.exclude[exclude_idx] = ctx.exclude_end[exclude_idx] = -1;
|
||||
} else {
|
||||
exclude_idx++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -329,6 +337,7 @@ void testRun(int argc, char *argv[], testFunction funcs[], int funcs_size) {
|
|||
|
||||
/* Call in a dataset loop to determine if a datum should be tested according to -i & -x args */
|
||||
int testContinue(const testCtx *const p_ctx, const int i) {
|
||||
int j;
|
||||
if (p_ctx->index != -1) {
|
||||
if (p_ctx->index_end != -1) {
|
||||
if (i < p_ctx->index || (p_ctx->index_end && i > p_ctx->index_end)) {
|
||||
|
@ -338,12 +347,12 @@ int testContinue(const testCtx *const p_ctx, const int i) {
|
|||
return 1;
|
||||
}
|
||||
}
|
||||
if (p_ctx->exclude != -1) {
|
||||
if (p_ctx->exclude_end != -1) {
|
||||
if (i >= p_ctx->exclude && (p_ctx->exclude_end == 0 || i <= p_ctx->exclude_end)) {
|
||||
for (j = 0; j < ZINT_TEST_CTX_EXC_MAX && p_ctx->exclude[j] != -1; j++) {
|
||||
if (p_ctx->exclude_end[j] != -1) {
|
||||
if (i >= p_ctx->exclude[j] && (p_ctx->exclude_end[j] == 0 || i <= p_ctx->exclude_end[j])) {
|
||||
return 1;
|
||||
}
|
||||
} else if (i == p_ctx->exclude) {
|
||||
} else if (i == p_ctx->exclude[j]) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -1351,7 +1360,7 @@ int testUtilRmDir(const char *dirname) {
|
|||
#endif
|
||||
}
|
||||
|
||||
/* Rename a file (Windows compatibility). */
|
||||
/* Rename a file (Windows compatibility) */
|
||||
int testUtilRename(const char *oldpath, const char *newpath) {
|
||||
#ifdef _MSVC
|
||||
int ret = remove(newpath);
|
||||
|
@ -1360,6 +1369,37 @@ int testUtilRename(const char *oldpath, const char *newpath) {
|
|||
return rename(oldpath, newpath);
|
||||
}
|
||||
|
||||
/* Create read-only file */
|
||||
int testUtilCreateROFile(const char *filename) {
|
||||
FILE *fp = fopen(filename, "w+");
|
||||
if (fp == NULL) {
|
||||
return 0;
|
||||
}
|
||||
if (fclose(fp) != 0) {
|
||||
return 0;
|
||||
}
|
||||
#ifdef _WIN32
|
||||
if (SetFileAttributesA(filename, GetFileAttributesA(filename) | FILE_ATTRIBUTE_READONLY) == 0) {
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
if (chmod(filename, S_IRUSR | S_IRGRP | S_IROTH) != 0) {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Remove read-only file (Windows compatibility) */
|
||||
int testUtilRmROFile(const char *filename) {
|
||||
#ifdef _WIN32
|
||||
if (SetFileAttributesA(filename, GetFileAttributesA(filename) & ~FILE_ATTRIBUTE_READONLY) == 0) {
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
return remove(filename);
|
||||
}
|
||||
|
||||
/* Compare 2 PNG files */
|
||||
int testUtilCmpPngs(const char *png1, const char *png2) {
|
||||
int ret = -1;
|
||||
|
@ -1730,12 +1770,19 @@ int testUtilCmpEpss(const char *eps1, const char *eps2) {
|
|||
#endif
|
||||
|
||||
/* Whether ImageMagick's identify utility available on system */
|
||||
int testUtilHaveIdentify(void) {
|
||||
return system("magick -version " DEV_NULL) == 0;
|
||||
const char *testUtilHaveIdentify(void) {
|
||||
static const char *progs[2] = { "magick identify", "identify" };
|
||||
if (system("magick -version " DEV_NULL_STDERR) == 0) {
|
||||
return progs[0];
|
||||
}
|
||||
if (system("identify -version " DEV_NULL_STDERR) == 0) {
|
||||
return progs[1];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Check raster files */
|
||||
int testUtilVerifyIdentify(const char *filename, int debug) {
|
||||
int testUtilVerifyIdentify(const char *const prog, const char *filename, int debug) {
|
||||
char cmd[512 + 128];
|
||||
|
||||
if (strlen(filename) > 512) {
|
||||
|
@ -1745,12 +1792,12 @@ int testUtilVerifyIdentify(const char *filename, int debug) {
|
|||
if (debug & ZINT_DEBUG_TEST_PRINT) {
|
||||
/* Verbose very noisy though so for quick check just return default output */
|
||||
if (debug & ZINT_DEBUG_TEST_LESS_NOISY) {
|
||||
sprintf(cmd, "magick identify %s", filename);
|
||||
sprintf(cmd, "%s %s", prog, filename);
|
||||
} else {
|
||||
sprintf(cmd, "magick identify -verbose %s", filename);
|
||||
sprintf(cmd, "%s -verbose %s", prog, filename);
|
||||
}
|
||||
} else {
|
||||
sprintf(cmd, "magick identify -verbose %s " DEV_NULL, filename);
|
||||
sprintf(cmd, "%s -verbose %s " DEV_NULL, prog, filename);
|
||||
}
|
||||
|
||||
return system(cmd);
|
||||
|
@ -1981,7 +2028,7 @@ static const char *testUtilBwippName(int index, const struct zint_symbol *symbol
|
|||
{ "maxicode", BARCODE_MAXICODE, 57, 1, 1, 0, 0, 0, },
|
||||
{ "qrcode", BARCODE_QRCODE, 58, 1, 1, 1, 0, 0, },
|
||||
{ "", -1, 59, 0, 0, 0, 0, 0, },
|
||||
{ "", BARCODE_CODE128B, 60, 0, 0, 0, 0, 0, },
|
||||
{ "", BARCODE_CODE128AB, 60, 0, 0, 0, 0, 0, },
|
||||
{ "", -1, 61, 0, 0, 0, 0, 0, },
|
||||
{ "", -1, 62, 0, 0, 0, 0, 0, },
|
||||
{ "auspost", BARCODE_AUSPOST, 63, 0, 0, 0, 0, 0, },
|
||||
|
@ -3324,7 +3371,7 @@ static const char *testUtilZXingCPPName(int index, const struct zint_symbol *sym
|
|||
{ "MaxiCode", BARCODE_MAXICODE, 57, },
|
||||
{ "QRCode", BARCODE_QRCODE, 58, },
|
||||
{ "", -1, 59, },
|
||||
{ "Code128", BARCODE_CODE128B, 60, },
|
||||
{ "Code128", BARCODE_CODE128AB, 60, },
|
||||
{ "", -1, 61, },
|
||||
{ "", -1, 62, },
|
||||
{ "", BARCODE_AUSPOST, 63, },
|
||||
|
|
|
@ -86,11 +86,12 @@ void testFinish(void);
|
|||
void testSkip(const char *msg);
|
||||
void testReport(void);
|
||||
|
||||
#define ZINT_TEST_CTX_EXC_MAX 32
|
||||
typedef struct s_testCtx {
|
||||
int index;
|
||||
int index_end;
|
||||
int exclude;
|
||||
int exclude_end;
|
||||
int exclude[ZINT_TEST_CTX_EXC_MAX];
|
||||
int exclude_end[ZINT_TEST_CTX_EXC_MAX];
|
||||
int generate;
|
||||
int debug;
|
||||
} testCtx;
|
||||
|
@ -163,6 +164,8 @@ int testUtilDirExists(const char *dirname);
|
|||
int testUtilMkDir(const char *dirname);
|
||||
int testUtilRmDir(const char *dirname);
|
||||
int testUtilRename(const char *oldpath, const char *newpath);
|
||||
int testUtilCreateROFile(const char *filename);
|
||||
int testUtilRmROFile(const char *filename);
|
||||
|
||||
int testUtilCmpPngs(const char *file1, const char *file2);
|
||||
int testUtilCmpTxts(const char *txt1, const char *txt2);
|
||||
|
@ -170,8 +173,8 @@ int testUtilCmpBins(const char *bin1, const char *bin2);
|
|||
int testUtilCmpSvgs(const char *svg1, const char *svg2);
|
||||
int testUtilCmpEpss(const char *eps1, const char *eps2);
|
||||
|
||||
int testUtilHaveIdentify(void);
|
||||
int testUtilVerifyIdentify(const char *filename, int debug);
|
||||
const char *testUtilHaveIdentify(void);
|
||||
int testUtilVerifyIdentify(const char *const prog, const char *filename, int debug);
|
||||
int testUtilHaveLibreOffice(void);
|
||||
int testUtilVerifyLibreOffice(const char *filename, int debug);
|
||||
int testUtilHaveGhostscript(void);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue