CLI: fix batch mode fopen() -> win_fopen() (Windows)

GUI: fix `save_to_file()` `filename.toLatin1()` -> `toUtf8()`
tests: `fopen()` -> `testUtilOpen()`, `remove()` -> `testUtilRemove()`
  ticket #288, props Marcel
This commit is contained in:
gitlost 2023-05-10 21:29:09 +01:00
parent 15fdca2a03
commit dff534140a
26 changed files with 172 additions and 132 deletions

View file

@ -461,7 +461,7 @@ static void test_perf(const testCtx *const p_ctx) {
ret = ZBarcode_Print(symbol, 0 /*rotate_angle*/);
diff_print += clock() - start;
assert_zero(ret, "i:%d ZBarcode_Print ret %d != 0 (%s)\n", i, ret, symbol->errtxt);
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
assert_zero(testUtilRemove(symbol->outfile), "i:%d testUtilRemove(%s) != 0\n", i, symbol->outfile);
ZBarcode_Delete(symbol);
}

View file

@ -108,11 +108,11 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
assert_zero(ret, "i:%d identify %s ret %d != 0\n", i, symbol->outfile, ret);
}
if (!(debug & ZINT_DEBUG_TEST_KEEP_OUTFILE)) {
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
assert_zero(testUtilRemove(symbol->outfile), "i:%d testUtilRemove(%s) != 0\n", i, symbol->outfile);
}
} else {
if (!(debug & ZINT_DEBUG_TEST_KEEP_OUTFILE)) {
(void) remove(symbol->outfile);
(void) testUtilRemove(symbol->outfile);
}
}
@ -220,7 +220,7 @@ static void test_print(const testCtx *const p_ctx) {
ret = testUtilCmpBins(symbol->outfile, expected_file);
assert_zero(ret, "i:%d %s testUtilCmpBins(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, expected_file, ret);
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
assert_zero(testUtilRemove(symbol->outfile), "i:%d testUtilRemove(%s) != 0\n", i, symbol->outfile);
}
ZBarcode_Delete(symbol);

View file

@ -587,7 +587,7 @@ static void test_perf(const testCtx *const p_ctx) {
ret = ZBarcode_Print(symbol, 0 /*rotate_angle*/);
diff_print += clock() - start;
assert_zero(ret, "i:%d ZBarcode_Print ret %d != 0 (%s)\n", i, ret, symbol->errtxt);
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
assert_zero(testUtilRemove(symbol->outfile), "i:%d testUtilRemove(%s) != 0\n", i, symbol->outfile);
ZBarcode_Delete(symbol);
}

View file

@ -1178,7 +1178,7 @@ static void test_perf(const testCtx *const p_ctx) {
ret = ZBarcode_Print(symbol, 0 /*rotate_angle*/);
diff_print += clock() - start;
assert_zero(ret, "i:%d ZBarcode_Print ret %d != 0 (%s)\n", i, ret, symbol->errtxt);
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
assert_zero(testUtilRemove(symbol->outfile), "i:%d testUtilRemove(%s) != 0\n", i, symbol->outfile);
ZBarcode_Delete(symbol);
}

View file

@ -6850,7 +6850,7 @@ static void test_perf(const testCtx *const p_ctx) {
ret = ZBarcode_Print(symbol, 0 /*rotate_angle*/);
diff_print += clock() - start;
assert_zero(ret, "i:%d ZBarcode_Print ret %d != 0 (%s)\n", i, ret, symbol->errtxt);
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
assert_zero(testUtilRemove(symbol->outfile), "i:%d testUtilRemove(%s) != 0\n", i, symbol->outfile);
ZBarcode_Delete(symbol);
}

View file

@ -167,7 +167,7 @@ static void test_print(const testCtx *const p_ctx) {
ret = testUtilCmpBins(symbol->outfile, expected_file);
assert_zero(ret, "i:%d %s testUtilCmpBins(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, expected_file, ret);
if (p_ctx->index == -1) assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
if (p_ctx->index == -1) assert_zero(testUtilRemove(symbol->outfile), "i:%d testUtilRemove(%s) != 0\n", i, symbol->outfile);
}
ZBarcode_Delete(symbol);

View file

@ -104,11 +104,11 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
assert_zero(ret, "i:%d identify %s ret %d != 0\n", i, symbol->outfile, ret);
}
if (!(debug & ZINT_DEBUG_TEST_KEEP_OUTFILE)) {
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
assert_zero(testUtilRemove(symbol->outfile), "i:%d testUtilRemove(%s) != 0\n", i, symbol->outfile);
}
} else {
if (!(debug & ZINT_DEBUG_TEST_KEEP_OUTFILE)) {
(void) remove(symbol->outfile);
(void) testUtilRemove(symbol->outfile);
}
}
@ -263,7 +263,7 @@ static void test_print(const testCtx *const p_ctx) {
ret = testUtilCmpBins(symbol->outfile, expected_file);
assert_zero(ret, "i:%d %s testUtilCmpBins(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, expected_file, ret);
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
assert_zero(testUtilRemove(symbol->outfile), "i:%d testUtilRemove(%s) != 0\n", i, symbol->outfile);
}
ZBarcode_Delete(symbol);
@ -332,7 +332,7 @@ static void test_large_scale(const testCtx *const p_ctx) {
if (!(debug & ZINT_DEBUG_TEST_KEEP_OUTFILE)) { /* -d 64 */
/* 129.1 kB file manually inspected and checked (1.1 MB file for scale 70.0f also checked) */
assert_zero(remove(symbol.outfile), "remove(%s) != 0\n", symbol.outfile);
assert_zero(testUtilRemove(symbol.outfile), "testUtilRemove(%s) != 0\n", symbol.outfile);
}
ZBarcode_Clear(&symbol);

View file

@ -78,8 +78,8 @@ static void test_csv(const testCtx *const p_ctx) {
"/backend/tests/data/imail/usps/", "uspsIMbEncoderTestCases.csv"), "testUtilDataPath == 0\n");
for (j = 0; j < perf_iterations; j++) {
fd = fopen(csvfile, "r");
assert_nonnull(fd, "fopen(%s) == NULL", csvfile);
fd = testUtilOpen(csvfile, "r");
assert_nonnull(fd, "testUtilOpen(%s) == NULL", csvfile);
while (fgets(buffer, sizeof(buffer), fd) != NULL) {
const char *b;

View file

@ -616,8 +616,8 @@ static void test_escape_char_process(const testCtx *const p_ctx) {
FILE *fp;
struct zint_symbol *symbol2;
fp = fopen(input_filename, "wb");
assert_nonnull(fp, "i:%d fopen(%s) failed\n", i, input_filename);
fp = testUtilOpen(input_filename, "wb");
assert_nonnull(fp, "i:%d testUtilOpen(%s) failed\n", i, input_filename);
assert_notequal(fputs(data[i].data, fp), EOF, "i%d fputs(%s) failed == EOF (%d)\n", i, data[i].data, ferror(fp));
assert_zero(fclose(fp), "i%d fclose() failed\n", i);
@ -635,7 +635,7 @@ static void test_escape_char_process(const testCtx *const p_ctx) {
ret = testUtilSymbolCmp(symbol2, symbol);
assert_zero(ret, "i:%d testUtilSymbolCmp symbol2 ret %d != 0\n", i, ret);
assert_zero(remove(input_filename), "i:%d remove(%s) != 0 (%d: %s)\n", i, input_filename, errno, strerror(errno));
assert_zero(testUtilRemove(input_filename), "i:%d testUtilRemove(%s) != 0 (%d: %s)\n", i, input_filename, errno, strerror(errno));
ZBarcode_Delete(symbol2);
}
@ -789,18 +789,18 @@ static void test_encode_file_empty(const testCtx *const p_ctx) {
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
(void) remove(filename); /* In case junk hanging around */
(void) testUtilRemove(filename); /* In case junk hanging around */
fstream = fopen(filename, "w+");
assert_nonnull(fstream, "fopen(%s) failed (%d)\n", filename, ferror(fstream));
fstream = testUtilOpen(filename, "w+");
assert_nonnull(fstream, "testUtilOpen(%s) failed (%d)\n", filename, ferror(fstream));
ret = fclose(fstream);
assert_zero(ret, "fclose(%s) %d != 0\n", filename, ret);
ret = ZBarcode_Encode_File(symbol, filename);
assert_equal(ret, ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_File empty ret %d != ZINT_ERROR_INVALID_DATA (%s)\n", ret, symbol->errtxt);
ret = remove(filename);
assert_zero(ret, "remove(%s) != 0 (%d: %s)\n", filename, errno, strerror(errno));
ret = testUtilRemove(filename);
assert_zero(ret, "testUtilRemove(%s) != 0 (%d: %s)\n", filename, errno, strerror(errno));
ZBarcode_Delete(symbol);
@ -821,10 +821,10 @@ static void test_encode_file_too_large(const testCtx *const p_ctx) {
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
(void) remove(filename); /* In case junk hanging around */
(void) testUtilRemove(filename); /* In case junk hanging around */
fstream = fopen(filename, "w+");
assert_nonnull(fstream, "fopen(%s) failed (%d)\n", filename, ferror(fstream));
fstream = testUtilOpen(filename, "w+");
assert_nonnull(fstream, "testUtilOpen(%s) failed (%d)\n", filename, ferror(fstream));
ret = (int) fwrite(buf, 1, sizeof(buf), fstream);
assert_equal(ret, sizeof(buf), "fwrite return value: %d != %d\n", ret, (int)sizeof(buf));
ret = fclose(fstream);
@ -833,8 +833,8 @@ static void test_encode_file_too_large(const testCtx *const p_ctx) {
ret = ZBarcode_Encode_File(symbol, filename);
assert_equal(ret, ZINT_ERROR_TOO_LONG, "ZBarcode_Encode_File too large ret %d != ZINT_ERROR_TOO_LONG (%s)\n", ret, symbol->errtxt);
ret = remove(filename);
assert_zero(ret, "remove(%s) != 0 (%d: %s)\n", filename, errno, strerror(errno));
ret = testUtilRemove(filename);
assert_zero(ret, "testUtilRemove(%s) != 0 (%d: %s)\n", filename, errno, strerror(errno));
ZBarcode_Delete(symbol);
@ -878,8 +878,8 @@ static void test_encode_file_unreadable(const testCtx *const p_ctx) {
ret = ZBarcode_Encode_File(symbol, filename);
assert_equal(ret, ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_File unreadable ret %d != ZINT_ERROR_INVALID_DATA (%s)\n", ret, symbol->errtxt);
ret = remove(filename);
assert_zero(ret, "remove(%s) != 0 (%d: %s)\n", filename, errno, strerror(errno));
ret = testUtilRemove(filename);
assert_zero(ret, "testUtilRemove(%s) != 0 (%d: %s)\n", filename, errno, strerror(errno));
ZBarcode_Delete(symbol);
@ -927,11 +927,11 @@ static void test_encode_file(const testCtx *const p_ctx) {
testStart("test_encode_file");
(void) remove(filename); /* In case junk hanging around */
(void) remove(outfile); /* In case junk hanging around */
(void) testUtilRemove(filename); /* In case junk hanging around */
(void) testUtilRemove(outfile); /* In case junk hanging around */
fp = fopen(filename, "w+");
assert_nonnull(fp, "fopen(%s) failed (%d)\n", filename, ferror(fp));
fp = testUtilOpen(filename, "w+");
assert_nonnull(fp, "testUtilOpen(%s) failed (%d)\n", filename, ferror(fp));
assert_notequal(fputs(data, fp), EOF, "fputs(%s) failed == EOF (%d)\n", data, ferror(fp));
ret = fclose(fp);
assert_zero(ret, "fclose(%s) %d != 0\n", filename, ret);
@ -944,8 +944,8 @@ static void test_encode_file(const testCtx *const p_ctx) {
ret = ZBarcode_Encode_File_and_Print(symbol, filename, 0);
assert_zero(ret, "ret %d != 0 (%s)\n", ret, symbol->errtxt);
ret = remove(outfile);
assert_zero(ret, "remove(%s) != 0 (%d: %s)\n", outfile, errno, strerror(errno));
ret = testUtilRemove(outfile);
assert_zero(ret, "testUtilRemove(%s) != 0 (%d: %s)\n", outfile, errno, strerror(errno));
ZBarcode_Delete(symbol);
}
@ -974,8 +974,8 @@ static void test_encode_file(const testCtx *const p_ctx) {
ZBarcode_Delete(symbol);
}
ret = remove(filename);
assert_zero(ret, "remove(%s) != 0 (%d: %s)\n", filename, errno, strerror(errno));
ret = testUtilRemove(filename);
assert_zero(ret, "testUtilRemove(%s) != 0 (%d: %s)\n", filename, errno, strerror(errno));
testFinish();
}

View file

@ -134,7 +134,7 @@ static void test_print(const testCtx *const p_ctx) {
ret = testUtilCmpBins(symbol->outfile, expected_file);
assert_zero(ret, "i:%d %s testUtilCmpBins(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, expected_file, ret);
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
assert_zero(testUtilRemove(symbol->outfile), "i:%d testUtilRemove(%s) != 0\n", i, symbol->outfile);
}
ZBarcode_Delete(symbol);

View file

@ -5618,7 +5618,7 @@ static void test_perf(const testCtx *const p_ctx) {
ret = ZBarcode_Print(symbol, 0 /*rotate_angle*/);
diff_print += clock() - start;
assert_zero(ret, "i:%d ZBarcode_Print ret %d != 0 (%s)\n", i, ret, symbol->errtxt);
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
assert_zero(testUtilRemove(symbol->outfile), "i:%d testUtilRemove(%s) != 0\n", i, symbol->outfile);
ZBarcode_Delete(symbol);
}
@ -5678,7 +5678,7 @@ static void test_perf(const testCtx *const p_ctx) {
ret = ZBarcode_Print(symbol, 0 /*rotate_angle*/);
diff_print += clock() - start;
assert_zero(ret, "i:%d ZBarcode_Print ret %d != 0 (%s)\n", i, ret, symbol->errtxt);
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
assert_zero(testUtilRemove(symbol->outfile), "i:%d testUtilRemove(%s) != 0\n", i, symbol->outfile);
ZBarcode_Delete(symbol);
}

View file

@ -405,7 +405,7 @@ static void test_perf(const testCtx *const p_ctx) {
ret = ZBarcode_Print(symbol, 0 /*rotate_angle*/);
diff_print += clock() - start;
assert_zero(ret, "i:%d ZBarcode_Print ret %d != 0 (%s)\n", i, ret, symbol->errtxt);
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
assert_zero(testUtilRemove(symbol->outfile), "i:%d testUtilRemove(%s) != 0\n", i, symbol->outfile);
ZBarcode_Delete(symbol);
}

View file

@ -102,11 +102,11 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
assert_zero(ret, "i:%d identify %s ret %d != 0\n", i, symbol->outfile, ret);
}
if (!(debug & ZINT_DEBUG_TEST_KEEP_OUTFILE)) {
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
assert_zero(testUtilRemove(symbol->outfile), "i:%d testUtilRemove(%s) != 0\n", i, symbol->outfile);
}
} else {
if (!(debug & ZINT_DEBUG_TEST_KEEP_OUTFILE)) {
(void) remove(symbol->outfile);
(void) testUtilRemove(symbol->outfile);
}
}
@ -303,7 +303,7 @@ static void test_print(const testCtx *const p_ctx) {
assert_zero(ret, "i:%d %s testUtilCmpPngs(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, expected_file, ret);
ret = testUtilCmpBins(symbol->outfile, expected_file);
assert_zero(ret, "i:%d %s testUtilCmpBins(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, expected_file, ret);
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
assert_zero(testUtilRemove(symbol->outfile), "i:%d testUtilRemove(%s) != 0\n", i, symbol->outfile);
}
ZBarcode_Delete(symbol);
@ -374,15 +374,15 @@ static void test_wpng_error_handler(const testCtx *const p_ctx) {
wpng_error.symbol = &symbol;
/* Create empty file */
(void) remove(filename); /* In case junk hanging around */
fp = fopen(filename, "w+");
assert_nonnull(fp, "fopen(%s) failed\n", filename);
(void) testUtilRemove(filename); /* In case junk hanging around */
fp = testUtilOpen(filename, "w+");
assert_nonnull(fp, "testUtilOpen(%s) failed\n", filename);
ret = fclose(fp);
assert_zero(ret, "fclose(%s) %d != 0\n", filename, ret);
/* Re-open for read, which will cause libpng to error */
fp = fopen(filename, "r");
assert_nonnull(fp, "fopen(%s) for read failed\n", filename);
fp = testUtilOpen(filename, "r");
assert_nonnull(fp, "testUtilOpen(%s) for read failed\n", filename);
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, &wpng_error, wpng_error_handler_test, NULL);
assert_nonnull(png_ptr, "png_create_write_struct failed\n");
@ -395,7 +395,7 @@ static void test_wpng_error_handler(const testCtx *const p_ctx) {
ret = fclose(fp);
assert_zero(ret, "fclose(%s) %d != 0\n", filename, ret);
assert_nonnull(strstr(symbol.errtxt, "635: libpng error:"), "strstr(%s) NULL\n", symbol.errtxt);
assert_zero(remove(filename), "remove(%s) != 0 (%d: %s)\n", filename, errno, strerror(errno));
assert_zero(testUtilRemove(filename), "testUtilRemove(%s) != 0 (%d: %s)\n", filename, errno, strerror(errno));
} else {
png_init_io(png_ptr, fp);
@ -429,7 +429,7 @@ static void test_large_compliant_height(const testCtx *const p_ctx) {
ret = ZBarcode_Encode_and_Print(symbol, (const unsigned char *) data_buf, codablockf_max, 0);
assert_zero(ret, "ZBarcode_Encode_and_Print ret %d != 0 (%s)\n", ret, symbol->errtxt);
assert_zero(remove(symbol->outfile), "remove(%s) != 0\n", symbol->outfile);
assert_zero(testUtilRemove(symbol->outfile), "testUtilRemove(%s) != 0\n", symbol->outfile);
ZBarcode_Delete(symbol);

View file

@ -611,7 +611,7 @@ static void test_perf(const testCtx *const p_ctx) {
ret = ZBarcode_Print(symbol, 0 /*rotate_angle*/);
diff_print += clock() - start;
assert_zero(ret, "i:%d ZBarcode_Print ret %d != 0 (%s)\n", i, ret, symbol->errtxt);
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
assert_zero(testUtilRemove(symbol->outfile), "i:%d testUtilRemove(%s) != 0\n", i, symbol->outfile);
ZBarcode_Delete(symbol);
}

View file

@ -204,7 +204,7 @@ static void test_print(const testCtx *const p_ctx) {
assert_zero(ret, "i:%d %s testUtilCmpBins(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, expected_file, ret);
}
if (p_ctx->index == -1) assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
if (p_ctx->index == -1) assert_zero(testUtilRemove(symbol->outfile), "i:%d testUtilRemove(%s) != 0\n", i, symbol->outfile);
}
ZBarcode_Delete(symbol);

View file

@ -173,7 +173,7 @@ static void test_print(const testCtx *const p_ctx) {
ret = testUtilCmpEpss(symbol->outfile, expected_file);
assert_zero(ret, "i:%d %s testUtilCmpEpss(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, expected_file, ret);
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
assert_zero(testUtilRemove(symbol->outfile), "i:%d testUtilRemove(%s) != 0\n", i, symbol->outfile);
}
ZBarcode_Delete(symbol);

View file

@ -1020,7 +1020,7 @@ static void test_draw_string_wrap(const testCtx *const p_ctx) {
ret = ZBarcode_Print(symbol, 0);
assert_zero(ret, "i:%d ZBarcode_Print(%d) ret %d != 0\n", i, data[i].symbology, ret);
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
assert_zero(testUtilRemove(symbol->outfile), "i:%d testUtilRemove(%s) != 0\n", i, symbol->outfile);
text_bits_set = 0;
row = data[i].expected_no_text_row;
@ -1090,7 +1090,7 @@ static void test_code128_utf8(const testCtx *const p_ctx) {
ret = ZBarcode_Print(symbol, 0);
assert_zero(ret, "i:%d ZBarcode_Print(%d) ret %d != 0\n", i, BARCODE_CODE128, ret);
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
assert_zero(testUtilRemove(symbol->outfile), "i:%d testUtilRemove(%s) != 0\n", i, symbol->outfile);
text_bits_set = 0;
row = data[i].expected_text_row;
@ -1271,7 +1271,7 @@ static void test_scale(const testCtx *const p_ctx) {
ret = ZBarcode_Print(symbol, 0);
assert_equal(ret, data[i].ret_raster, "i:%d ZBarcode_Print(%d) ret %d != %d (%s)\n", i, data[i].symbology, ret, data[i].ret_raster, symbol->errtxt);
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
assert_zero(testUtilRemove(symbol->outfile), "i:%d testUtilRemove(%s) != 0\n", i, symbol->outfile);
assert_nonzero(symbol->bitmap_height >= data[i].expected_set_rows, "i:%d (%d) symbol->bitmap_height %d < expected_set_rows %d\n",
i, data[i].symbology, symbol->bitmap_height, data[i].expected_set_rows);
@ -1383,7 +1383,7 @@ static void test_guard_descent(const testCtx *const p_ctx) {
ret = ZBarcode_Print(symbol, 0);
assert_equal(ret, data[i].ret_raster, "i:%d ZBarcode_Print(%d) ret %d != %d (%s)\n", i, data[i].symbology, ret, data[i].ret_raster, symbol->errtxt);
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
assert_zero(testUtilRemove(symbol->outfile), "i:%d testUtilRemove(%s) != 0\n", i, symbol->outfile);
assert_nonzero(symbol->bitmap_height >= data[i].expected_set_rows, "i:%d (%d) symbol->bitmap_height %d < expected_set_rows %d\n",
i, data[i].symbology, symbol->bitmap_height, data[i].expected_set_rows);
@ -1762,7 +1762,7 @@ static void test_quiet_zones(const testCtx *const p_ctx) {
ret = ZBarcode_Print(symbol, 0);
assert_equal(ret, data[i].ret_raster, "i:%d ZBarcode_Print(%d) ret %d != %d (%s)\n", i, data[i].symbology, ret, data[i].ret_raster, symbol->errtxt);
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
assert_zero(testUtilRemove(symbol->outfile), "i:%d testUtilRemove(%s) != 0\n", i, symbol->outfile);
assert_nonzero(symbol->bitmap_height >= data[i].expected_set_rows, "i:%d (%d) symbol->bitmap_height %d < expected_set_rows %d\n",
i, data[i].symbology, symbol->bitmap_height, data[i].expected_set_rows);
@ -1917,7 +1917,7 @@ static void test_text_gap(const testCtx *const p_ctx) {
ret = ZBarcode_Print(symbol, 0);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Print(%d) ret %d != %d (%s)\n", i, data[i].symbology, ret, data[i].ret, symbol->errtxt);
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
assert_zero(testUtilRemove(symbol->outfile), "i:%d testUtilRemove(%s) != 0\n", i, symbol->outfile);
assert_nonzero(symbol->bitmap_height >= data[i].expected_set_rows, "i:%d (%d) symbol->bitmap_height %d < expected_set_rows %d\n",
i, data[i].symbology, symbol->bitmap_height, data[i].expected_set_rows);
@ -3098,7 +3098,7 @@ static void test_perf_scale(const testCtx *const p_ctx) {
ret = ZBarcode_Print(symbol, 0 /*rotate_angle*/);
diff_print += clock() - start;
assert_zero(ret, "i:%d ZBarcode_Print ret %d != 0 (%s)\n", i, ret, symbol->errtxt);
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
assert_zero(testUtilRemove(symbol->outfile), "i:%d testUtilRemove(%s) != 0\n", i, symbol->outfile);
ZBarcode_Delete(symbol);
}

View file

@ -211,7 +211,7 @@ static void test_print(const testCtx *const p_ctx) {
ret = testUtilCmpSvgs(symbol->outfile, expected_file);
assert_zero(ret, "i:%d %s testUtilCmpSvgs(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, expected_file, ret);
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
assert_zero(testUtilRemove(symbol->outfile), "i:%d testUtilRemove(%s) != 0\n", i, symbol->outfile);
}
ZBarcode_Delete(symbol);

View file

@ -141,11 +141,11 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
}
if (!(debug & ZINT_DEBUG_TEST_KEEP_OUTFILE)) {
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
assert_zero(testUtilRemove(symbol->outfile), "i:%d testUtilRemove(%s) != 0\n", i, symbol->outfile);
}
} else {
if (!(debug & ZINT_DEBUG_TEST_KEEP_OUTFILE)) {
(void) remove(symbol->outfile);
(void) testUtilRemove(symbol->outfile);
}
}
@ -299,7 +299,7 @@ static void test_print(const testCtx *const p_ctx) {
ret = testUtilCmpBins(symbol->outfile, expected_file);
assert_zero(ret, "i:%d %s testUtilCmpBins(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, expected_file, ret);
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
assert_zero(testUtilRemove(symbol->outfile), "i:%d testUtilRemove(%s) != 0\n", i, symbol->outfile);
}
ZBarcode_Delete(symbol);

View file

@ -184,7 +184,7 @@ static void test_upca_print(const testCtx *const p_ctx) {
ret = ZBarcode_Print(symbol, 0);
assert_zero(ret, "i:%d %s ZBarcode_Print %s ret %d != 0 (%s)\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, ret, symbol->errtxt);
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
assert_zero(testUtilRemove(symbol->outfile), "i:%d testUtilRemove(%s) != 0\n", i, symbol->outfile);
ZBarcode_Delete(symbol);
}
@ -1124,7 +1124,7 @@ static void test_perf(const testCtx *const p_ctx) {
ret = ZBarcode_Print(symbol, 0 /*rotate_angle*/);
diff_print += clock() - start;
assert_zero(ret, "i:%d ZBarcode_Print ret %d != 0 (%s)\n", i, ret, symbol->errtxt);
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
assert_zero(testUtilRemove(symbol->outfile), "i:%d testUtilRemove(%s) != 0\n", i, symbol->outfile);
ZBarcode_Delete(symbol);
}

View file

@ -37,6 +37,7 @@
#ifdef _WIN32
#include <windows.h>
#include <direct.h>
#include <wchar.h>
#endif
#ifndef ZINT_NO_PNG
#include <png.h>
@ -1334,13 +1335,19 @@ int testUtilDataPath(char *buffer, int buffer_size, const char *subdir, const ch
return 1;
}
/* Open a file (Windows compatibility) */
FILE *testUtilOpen(const char *filename, const char *mode) {
#ifdef _WIN32
FILE *fp = out_win_fopen(filename, mode);
#else
FILE *fp = fopen(filename, mode);
#endif
return fp;
}
/* Does file exist? */
int testUtilExists(const char *filename) {
#ifdef _WIN32
FILE *fp = out_win_fopen(filename, "r");
#else
FILE *fp = fopen(filename, "r");
#endif
FILE *fp = testUtilOpen(filename, "r");
if (fp == NULL) {
return 0;
}
@ -1396,7 +1403,7 @@ int testUtilRmDir(const char *dirname) {
/* Rename a file (Windows compatibility) */
int testUtilRename(const char *oldpath, const char *newpath) {
#ifdef _MSVC
#ifdef _WIN32
wchar_t *oldpathW, *newpathW;
int ret = testUtilRemove(newpath);
if (ret != 0) return ret;
@ -1412,10 +1419,8 @@ int testUtilRename(const char *oldpath, const char *newpath) {
int testUtilCreateROFile(const char *filename) {
#ifdef _WIN32
wchar_t *filenameW;
FILE *fp = out_win_fopen(filename, "w+");
#else
FILE *fp = fopen(filename, "w+");
#endif
FILE *fp = testUtilOpen(filename, "w+");
if (fp == NULL) {
return 0;
}
@ -1464,11 +1469,11 @@ int testUtilCmpPngs(const char *png1, const char *png2) {
size_t rowbytes1, rowbytes2;
int r;
fp1 = fopen(png1, "rb");
fp1 = testUtilOpen(png1, "rb");
if (!fp1) {
return 2;
}
fp2 = fopen(png2, "rb");
fp2 = testUtilOpen(png2, "rb");
if (!fp2) {
fclose(fp1);
return 3;
@ -1654,11 +1659,11 @@ int testUtilCmpTxts(const char *txt1, const char *txt2) {
char buf2[1024];
size_t len1 = 0, len2 = 0;
fp1 = fopen(txt1, "r");
fp1 = testUtilOpen(txt1, "r");
if (!fp1) {
return 2;
}
fp2 = fopen(txt2, "r");
fp2 = testUtilOpen(txt2, "r");
if (!fp2) {
fclose(fp1);
return 3;
@ -1705,11 +1710,11 @@ int testUtilCmpBins(const char *bin1, const char *bin2) {
char buf2[1024];
size_t len1 = 0, len2 = 0;
fp1 = fopen(bin1, "rb");
fp1 = testUtilOpen(bin1, "rb");
if (!fp1) {
return 2;
}
fp2 = fopen(bin2, "rb");
fp2 = testUtilOpen(bin2, "rb");
if (!fp2) {
fclose(fp1);
return 3;
@ -1753,11 +1758,11 @@ int testUtilCmpEpss(const char *eps1, const char *eps2) {
static char first_line[] = "%!PS-Adobe-3.0 EPSF-3.0\n";
static char second_line_start[] = "%%Creator: Zint ";
fp1 = fopen(eps1, "r");
fp1 = testUtilOpen(eps1, "r");
if (!fp1) {
return 2;
}
fp2 = fopen(eps2, "r");
fp2 = testUtilOpen(eps2, "r");
if (!fp2) {
fclose(fp1);
return 3;
@ -1896,7 +1901,7 @@ int testUtilVerifyLibreOffice(const char *filename, int debug) {
return -1;
}
fp = fopen(svg, "r");
fp = testUtilOpen(svg, "r");
if (!fp) {
fprintf(stderr, "testUtilVerifyLibreOffice: failed to open '%s' (%s)\n", svg, cmd);
return -1;
@ -1923,7 +1928,7 @@ int testUtilVerifyLibreOffice(const char *filename, int debug) {
if (strstr(buf, "x=\"-32767\"") != NULL) {
return -1;
}
remove(svg);
testUtilRemove(svg);
return 0;
}

View file

@ -159,6 +159,7 @@ void testUtilBitmapPrint(const struct zint_symbol *symbol, const char *prefix, c
int testUtilBitmapCmp(const struct zint_symbol *symbol, const char *expected, int *row, int *column);
int testUtilDataPath(char *buffer, int buffer_size, const char *subdir, const char *filename);
FILE *testUtilOpen(const char *filename, const char *mode);
int testUtilExists(const char *filename);
int testUtilRemove(const char *filename);
int testUtilDirExists(const char *dirname);