mirror of
https://git.code.sf.net/p/zint/code
synced 2026-01-10 21:45:58 +00:00
test suite: zxing-cpp: adjust for returnCodabarStartEnd no-op;
allow for old "libpng" (`png_set_scale_16()` not available) general: Solaris compat library: use proper function ptr instead of `void *` for function table; warning suppression "-Wpedantic" -> "-Wstrict-prototypes" GRIDMATRIX/HANXIN/QRCODE: `xx_define_mode()`: multi-dim `char_modes`
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2023 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2023-2024 Robin Stuart <rstuart114@gmail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
@@ -109,7 +109,11 @@ static void test_svg(const testCtx *const p_ctx) {
|
||||
testFinish();
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
#if defined(_WIN32) || (defined(__sun) && defined(__SVR4))
|
||||
#define ZINT_TEST_NO_FMEMOPEN
|
||||
#endif
|
||||
|
||||
#ifndef ZINT_TEST_NO_FMEMOPEN
|
||||
extern FILE *fmemopen(void *buf, size_t size, const char *mode);
|
||||
#endif
|
||||
|
||||
@@ -145,7 +149,7 @@ static void test_putsf(const testCtx *const p_ctx) {
|
||||
struct zint_symbol *const symbol = &symbol_data;
|
||||
struct filemem fm;
|
||||
struct filemem *const fmp = &fm;
|
||||
#ifndef _WIN32
|
||||
#ifndef ZINT_TEST_NO_FMEMOPEN
|
||||
FILE *fp;
|
||||
char buf[512] = {0}; /* Suppress clang-16/17 run-time exception MemorySanitizer: use-of-uninitialized-value */
|
||||
#endif
|
||||
@@ -153,8 +157,8 @@ static void test_putsf(const testCtx *const p_ctx) {
|
||||
testStart("test_putsf");
|
||||
|
||||
for (j = 0; j < 2; j++) { /* 1st `memfile`, then file */
|
||||
#ifdef _WIN32
|
||||
if (j == 1) break; /* Skip file test on Windows */
|
||||
#ifdef ZINT_TEST_NO_FMEMOPEN
|
||||
if (j == 1) break; /* Skip file test on Windows/Solaris */
|
||||
#endif
|
||||
for (i = 0; i < data_size; i++) {
|
||||
const char *locale = NULL;
|
||||
@@ -164,7 +168,7 @@ static void test_putsf(const testCtx *const p_ctx) {
|
||||
|
||||
ZBarcode_Reset(symbol);
|
||||
if (j == 1) {
|
||||
#ifndef _WIN32
|
||||
#ifndef ZINT_TEST_NO_FMEMOPEN
|
||||
buf[0] = '\0';
|
||||
fp = fmemopen(buf, sizeof(buf), "w");
|
||||
assert_nonnull(fp, "%d: fmemopen fail (%d, %s)\n", i, errno, strerror(errno));
|
||||
@@ -174,7 +178,7 @@ static void test_putsf(const testCtx *const p_ctx) {
|
||||
}
|
||||
assert_nonzero(fm_open(fmp, symbol, "w"), "i:%d: fm_open fail (%d, %s)\n", i, fmp->err, strerror(fmp->err));
|
||||
if (j == 1) {
|
||||
#ifndef _WIN32
|
||||
#ifndef ZINT_TEST_NO_FMEMOPEN
|
||||
/* Hack in `fmemopen()` fp */
|
||||
assert_zero(fclose(fmp->fp), "i:%d fclose(fmp->fp) fail (%d, %s)\n", i, errno, strerror(errno));
|
||||
fmp->fp = fp;
|
||||
@@ -200,7 +204,7 @@ static void test_putsf(const testCtx *const p_ctx) {
|
||||
}
|
||||
|
||||
if (j == 1) {
|
||||
#ifndef _WIN32
|
||||
#ifndef ZINT_TEST_NO_FMEMOPEN
|
||||
assert_zero(strcmp(buf, data[i].expected), "%d: strcmp(%s, %s) != 0\n", i, buf, data[i].expected);
|
||||
#endif
|
||||
} else {
|
||||
|
||||
@@ -1685,7 +1685,11 @@ int testUtilCmpPngs(const char *png1, const char *png2) {
|
||||
color_type1 = png_get_color_type(png_ptr1, info_ptr1);
|
||||
bit_depth1 = png_get_bit_depth(png_ptr1, info_ptr1);
|
||||
if (bit_depth1 == 16) {
|
||||
#if defined(PNG_LIBPNG_VER) && PNG_LIBPNG_VER >= 10504
|
||||
png_set_scale_16(png_ptr1);
|
||||
#else
|
||||
png_set_strip_16(png_ptr1);
|
||||
#endif
|
||||
}
|
||||
if (color_type1 == PNG_COLOR_TYPE_PALETTE) {
|
||||
png_set_palette_to_rgb(png_ptr1);
|
||||
@@ -1707,7 +1711,11 @@ int testUtilCmpPngs(const char *png1, const char *png2) {
|
||||
color_type2 = png_get_color_type(png_ptr2, info_ptr2);
|
||||
bit_depth2 = png_get_bit_depth(png_ptr2, info_ptr2);
|
||||
if (bit_depth2 == 16) {
|
||||
#if defined(PNG_LIBPNG_VER) && PNG_LIBPNG_VER >= 10504
|
||||
png_set_scale_16(png_ptr2);
|
||||
#else
|
||||
png_set_strip_16(png_ptr2);
|
||||
#endif
|
||||
}
|
||||
if (color_type2 == PNG_COLOR_TYPE_PALETTE) {
|
||||
png_set_palette_to_rgb(png_ptr2);
|
||||
@@ -4036,7 +4044,9 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in
|
||||
expected_len += maxi_len;
|
||||
}
|
||||
} else if (symbology == BARCODE_CODABAR) {
|
||||
/* Start A/B/C/D and stop A/B/C/D chars not returned by ZXing-C++ */
|
||||
/* Ignore start A/B/C/D and stop A/B/C/D chars to avoid upper/lowercase issues */
|
||||
cmp_buf++;
|
||||
cmp_len -= 2;
|
||||
expected++;
|
||||
expected_len -= 2;
|
||||
if (symbol->option_2 == 1 || symbol->option_2 == 2) {
|
||||
|
||||
Reference in New Issue
Block a user