mirror of
https://git.code.sf.net/p/zint/code
synced 2025-05-16 16:14:36 -04:00
general: reenable -Wpedantic for gcc by using __extension__
(ZEXT)
to suppress warnings about `errtxtf` operand number "%<n>$" args; enable some further warnings test suite: enable -Wpedantic and fix/suppress any warnings
This commit is contained in:
parent
a4b557786f
commit
b377b14360
93 changed files with 1397 additions and 1370 deletions
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2019-2024 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2019-2025 Robin Stuart <rstuart114@gmail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
|
@ -46,10 +46,10 @@ static void test_options(const testCtx *const p_ctx) {
|
|||
|
||||
struct item {
|
||||
int symbology;
|
||||
char *fgcolour;
|
||||
char *bgcolour;
|
||||
const char *fgcolour;
|
||||
const char *bgcolour;
|
||||
int rotate_angle;
|
||||
char *data;
|
||||
const char *data;
|
||||
int ret;
|
||||
int expected_rows;
|
||||
int expected_width;
|
||||
|
@ -112,8 +112,8 @@ static void test_buffer(const testCtx *const p_ctx) {
|
|||
struct item {
|
||||
int symbology;
|
||||
int output_options;
|
||||
char *data;
|
||||
char *composite;
|
||||
const char *data;
|
||||
const char *composite;
|
||||
|
||||
float expected_height;
|
||||
int expected_rows;
|
||||
|
@ -391,7 +391,7 @@ static void test_buffer(const testCtx *const p_ctx) {
|
|||
int i, length, ret;
|
||||
struct zint_symbol *symbol = NULL;
|
||||
|
||||
char *text;
|
||||
const char *text;
|
||||
|
||||
testStartSymbol("test_buffer", &symbol);
|
||||
|
||||
|
@ -410,7 +410,7 @@ static void test_buffer(const testCtx *const p_ctx) {
|
|||
}
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, UNICODE_MODE, -1 /*eci*/, -1 /*option_1*/, -1, -1, data[i].output_options, text, -1, debug);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) text, length);
|
||||
ret = ZBarcode_Encode(symbol, TCU(text), length);
|
||||
assert_zero(ret, "i:%d ZBarcode_Encode(%s) ret %d != 0 (%s)\n", i, testUtilBarcodeName(data[i].symbology), ret, symbol->errtxt);
|
||||
|
||||
ret = ZBarcode_Buffer(symbol, 0);
|
||||
|
@ -447,7 +447,7 @@ static void test_upcean_hrt(const testCtx *const p_ctx) {
|
|||
int symbology;
|
||||
int show_hrt; /* Using -1 in data as show_hrt, 1 in data as show_hrt but empty space */
|
||||
int output_options;
|
||||
char *data;
|
||||
const char *data;
|
||||
int ret;
|
||||
|
||||
float expected_height;
|
||||
|
@ -626,7 +626,7 @@ static void test_row_separator(const testCtx *const p_ctx) {
|
|||
int border_width;
|
||||
int option_1;
|
||||
int option_3;
|
||||
char *data;
|
||||
const char *data;
|
||||
int ret;
|
||||
|
||||
float expected_height;
|
||||
|
@ -713,8 +713,8 @@ static void test_stacking(const testCtx *const p_ctx) {
|
|||
int output_options;
|
||||
int option_1;
|
||||
int option_3;
|
||||
char *data;
|
||||
char *data2;
|
||||
const char *data;
|
||||
const char *data2;
|
||||
|
||||
float expected_height;
|
||||
int expected_rows;
|
||||
|
@ -748,11 +748,11 @@ static void test_stacking(const testCtx *const p_ctx) {
|
|||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, data[i].option_1, -1, data[i].option_3, data[i].output_options, data[i].data, -1, debug);
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
||||
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
|
||||
assert_zero(ret, "i:%d ret %d != zero\n", i, ret);
|
||||
|
||||
length2 = (int) strlen(data[i].data2);
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data2, length2);
|
||||
ret = ZBarcode_Encode(symbol, TCU(data[i].data2), length2);
|
||||
assert_zero(ret, "i:%d ret %d != zero\n", i, ret);
|
||||
|
||||
ret = ZBarcode_Buffer(symbol, 0);
|
||||
|
@ -806,13 +806,13 @@ static void test_stacking_too_many(const testCtx *const p_ctx) {
|
|||
|
||||
for (i = 0; i < 200; i++) {
|
||||
length = testUtilSetSymbol(symbol, BARCODE_CODE128, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1, data, -1, debug);
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data, length);
|
||||
ret = ZBarcode_Encode(symbol, TCU(data), length);
|
||||
assert_zero(ret, "i:%d ret %d != zero\n", i, ret);
|
||||
}
|
||||
assert_equal(symbol->rows, 200, "symbol->rows %d != 200\n", symbol->rows);
|
||||
|
||||
length = testUtilSetSymbol(symbol, BARCODE_CODE128, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1, data, -1, debug);
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data, length);
|
||||
ret = ZBarcode_Encode(symbol, TCU(data), length);
|
||||
assert_equal(ret, ZINT_ERROR_TOO_LONG, "ret %d != ZINT_ERROR_TOO_LONG\n", ret);
|
||||
assert_zero(strcmp(symbol->errtxt, expected_errtxt), "symbol->errtxt(%s) != expected_errtxt(%s)\n", symbol->errtxt, expected_errtxt);
|
||||
|
||||
|
@ -832,7 +832,7 @@ static void test_output_options(const testCtx *const p_ctx) {
|
|||
int output_options;
|
||||
int rotate_angle;
|
||||
float scale;
|
||||
char *data;
|
||||
const char *data;
|
||||
int ret;
|
||||
|
||||
float expected_height;
|
||||
|
@ -970,7 +970,7 @@ static void test_output_options(const testCtx *const p_ctx) {
|
|||
symbol->scale = data[i].scale;
|
||||
}
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
||||
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
|
||||
assert_zero(ret, "i:%d ZBarcode_Encode(%s) ret %d != 0 (%s)\n", i, testUtilBarcodeName(data[i].symbology), ret, symbol->errtxt);
|
||||
|
||||
ret = ZBarcode_Buffer(symbol, data[i].rotate_angle);
|
||||
|
@ -1013,8 +1013,8 @@ static void test_draw_string_wrap(const testCtx *const p_ctx) {
|
|||
struct item {
|
||||
int symbology;
|
||||
int output_options;
|
||||
char *data;
|
||||
char *text;
|
||||
const char *data;
|
||||
const char *text;
|
||||
|
||||
float expected_height;
|
||||
int expected_rows;
|
||||
|
@ -1046,7 +1046,7 @@ static void test_draw_string_wrap(const testCtx *const p_ctx) {
|
|||
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, data[i].output_options, data[i].data, -1, debug);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
||||
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
|
||||
assert_zero(ret, "i:%d ZBarcode_Encode(%d) ret %d != 0 (%s)\n", i, data[i].symbology, ret, symbol->errtxt);
|
||||
|
||||
/* Cheat by overwriting text */
|
||||
|
@ -1088,7 +1088,7 @@ static void test_code128_utf8(const testCtx *const p_ctx) {
|
|||
int debug = p_ctx->debug;
|
||||
|
||||
struct item {
|
||||
char *data;
|
||||
const char *data;
|
||||
|
||||
float expected_height;
|
||||
int expected_rows;
|
||||
|
@ -1119,7 +1119,7 @@ static void test_code128_utf8(const testCtx *const p_ctx) {
|
|||
|
||||
length = testUtilSetSymbol(symbol, BARCODE_CODE128, UNICODE_MODE, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
||||
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
|
||||
assert_zero(ret, "i:%d ZBarcode_Encode(%d) ret %d != 0 %s\n", i, BARCODE_CODE128, ret, symbol->errtxt);
|
||||
|
||||
ret = ZBarcode_Buffer(symbol, 0);
|
||||
|
@ -1163,8 +1163,8 @@ static void test_scale(const testCtx *const p_ctx) {
|
|||
int output_options;
|
||||
float height;
|
||||
float scale;
|
||||
char *data;
|
||||
char *composite;
|
||||
const char *data;
|
||||
const char *composite;
|
||||
|
||||
int ret_raster;
|
||||
float expected_height;
|
||||
|
@ -1271,7 +1271,7 @@ static void test_scale(const testCtx *const p_ctx) {
|
|||
int i, length, ret;
|
||||
struct zint_symbol *symbol = NULL;
|
||||
|
||||
char *text;
|
||||
const char *text;
|
||||
|
||||
testStartSymbol("test_scale", &symbol);
|
||||
|
||||
|
@ -1300,7 +1300,7 @@ static void test_scale(const testCtx *const p_ctx) {
|
|||
}
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, UNICODE_MODE, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, data[i].output_options, text, -1, debug);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) text, length);
|
||||
ret = ZBarcode_Encode(symbol, TCU(text), length);
|
||||
assert_nonzero(ret < ZINT_ERROR, "i:%d ZBarcode_Encode(%s) ret %d >= ZINT_ERROR (%s)\n",
|
||||
i, testUtilBarcodeName(data[i].symbology), ret, symbol->errtxt);
|
||||
|
||||
|
@ -1353,7 +1353,7 @@ static void test_guard_descent(const testCtx *const p_ctx) {
|
|||
struct item {
|
||||
int symbology;
|
||||
float guard_descent;
|
||||
char *data;
|
||||
const char *data;
|
||||
|
||||
int ret_raster;
|
||||
float expected_height;
|
||||
|
@ -1423,7 +1423,7 @@ static void test_guard_descent(const testCtx *const p_ctx) {
|
|||
symbol->guard_descent = data[i].guard_descent;
|
||||
}
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
||||
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
|
||||
assert_zero(ret, "i:%d ZBarcode_Encode(%d) ret %d != 0 (%s)\n", i, data[i].symbology, ret, symbol->errtxt);
|
||||
|
||||
ret = ZBarcode_Buffer(symbol, 0);
|
||||
|
@ -1474,8 +1474,8 @@ static void test_quiet_zones(const testCtx *const p_ctx) {
|
|||
int option_1;
|
||||
int option_2;
|
||||
int show_hrt;
|
||||
char *data;
|
||||
char *composite;
|
||||
const char *data;
|
||||
const char *composite;
|
||||
|
||||
int ret_raster;
|
||||
float expected_height;
|
||||
|
@ -1830,7 +1830,7 @@ static void test_quiet_zones(const testCtx *const p_ctx) {
|
|||
text = data[i].data;
|
||||
}
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) text, length);
|
||||
ret = ZBarcode_Encode(symbol, TCU(text), length);
|
||||
assert_zero(ret, "i:%d ZBarcode_Encode(%d) ret %d != 0 (%s)\n", i, data[i].symbology, ret, symbol->errtxt);
|
||||
|
||||
ret = ZBarcode_Buffer(symbol, 0);
|
||||
|
@ -1893,8 +1893,8 @@ static void test_text_gap(const testCtx *const p_ctx) {
|
|||
int show_hrt;
|
||||
float text_gap;
|
||||
float scale;
|
||||
char *data;
|
||||
char *composite;
|
||||
const char *data;
|
||||
const char *composite;
|
||||
|
||||
int ret;
|
||||
float expected_height;
|
||||
|
@ -2002,7 +2002,7 @@ static void test_text_gap(const testCtx *const p_ctx) {
|
|||
}
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, UNICODE_MODE, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, data[i].output_options, text, -1, debug);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) text, length);
|
||||
ret = ZBarcode_Encode(symbol, TCU(text), length);
|
||||
assert_zero(ret, "i:%d ZBarcode_Encode(%d) ret %d != 0 (%s)\n", i, data[i].symbology, ret, symbol->errtxt);
|
||||
|
||||
ret = ZBarcode_Buffer(symbol, 0);
|
||||
|
@ -2058,9 +2058,9 @@ static void test_buffer_plot(const testCtx *const p_ctx) {
|
|||
int whitespace_width;
|
||||
int output_options;
|
||||
float height;
|
||||
char *fgcolour;
|
||||
char *bgcolour;
|
||||
char *data;
|
||||
const char *fgcolour;
|
||||
const char *bgcolour;
|
||||
const char *data;
|
||||
int ret;
|
||||
|
||||
float expected_height;
|
||||
|
@ -2068,7 +2068,7 @@ static void test_buffer_plot(const testCtx *const p_ctx) {
|
|||
int expected_width;
|
||||
int expected_bitmap_width;
|
||||
int expected_bitmap_height;
|
||||
char *expected_bitmap;
|
||||
const char *expected_bitmap;
|
||||
};
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { BARCODE_PDF417, 0, 1, -1, -1, 15, "", "", "1", 0, 16, 4, 86, 86, 16,
|
||||
|
@ -2196,7 +2196,7 @@ static void test_buffer_plot(const testCtx *const p_ctx) {
|
|||
symbol->show_hrt = 0;
|
||||
symbol->scale = 0.5f;
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
||||
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode(%s) ret %d != %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), ret, data[i].ret, symbol->errtxt);
|
||||
|
||||
ret = ZBarcode_Buffer(symbol, 0);
|
||||
|
@ -2247,8 +2247,8 @@ static void test_height(const testCtx *const p_ctx) {
|
|||
int symbology;
|
||||
int output_options;
|
||||
float height;
|
||||
char *data;
|
||||
char *composite;
|
||||
const char *data;
|
||||
const char *composite;
|
||||
int ret;
|
||||
|
||||
float expected_height;
|
||||
|
@ -2256,7 +2256,7 @@ static void test_height(const testCtx *const p_ctx) {
|
|||
int expected_width;
|
||||
int expected_bitmap_width;
|
||||
int expected_bitmap_height;
|
||||
char *expected_errtxt;
|
||||
const char *expected_errtxt;
|
||||
|
||||
const char *comment;
|
||||
};
|
||||
|
@ -2882,7 +2882,7 @@ static void test_height(const testCtx *const p_ctx) {
|
|||
int i, length, ret;
|
||||
struct zint_symbol *symbol = NULL;
|
||||
|
||||
char *text;
|
||||
const char *text;
|
||||
|
||||
testStartSymbol("test_height", &symbol);
|
||||
|
||||
|
@ -2912,7 +2912,7 @@ static void test_height(const testCtx *const p_ctx) {
|
|||
}
|
||||
length = (int) strlen(text);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) text, length);
|
||||
ret = ZBarcode_Encode(symbol, TCU(text), length);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode(%s) ret %d != %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), ret, data[i].ret, symbol->errtxt);
|
||||
|
||||
ret = ZBarcode_Buffer(symbol, 0);
|
||||
|
@ -2954,8 +2954,8 @@ static void test_height_per_row(const testCtx *const p_ctx) {
|
|||
int option_3;
|
||||
float height;
|
||||
float scale;
|
||||
char *data;
|
||||
char *composite;
|
||||
const char *data;
|
||||
const char *composite;
|
||||
int ret;
|
||||
|
||||
float expected_height;
|
||||
|
@ -3048,7 +3048,7 @@ static void test_height_per_row(const testCtx *const p_ctx) {
|
|||
int i, length, ret;
|
||||
struct zint_symbol *symbol = NULL;
|
||||
|
||||
char *text;
|
||||
const char *text;
|
||||
|
||||
testStartSymbol("test_height_per_row", &symbol);
|
||||
|
||||
|
@ -3075,7 +3075,7 @@ static void test_height_per_row(const testCtx *const p_ctx) {
|
|||
}
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, data[i].option_1, data[i].option_2, data[i].option_3, -1 /*output_options*/, text, -1, debug);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) text, length);
|
||||
ret = ZBarcode_Encode(symbol, TCU(text), length);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode(%s) ret %d != %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), ret, data[i].ret, symbol->errtxt);
|
||||
|
||||
ret = ZBarcode_Buffer(symbol, 0);
|
||||
|
@ -3125,12 +3125,12 @@ static void test_perf_scale(const testCtx *const p_ctx) {
|
|||
int option_2;
|
||||
float height;
|
||||
float scale;
|
||||
char *data;
|
||||
const char *data;
|
||||
int ret;
|
||||
|
||||
int expected_rows;
|
||||
int expected_width;
|
||||
char *comment;
|
||||
const char *comment;
|
||||
};
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { BARCODE_PDF417, -1, -1, -1, -1, -1, 0, 1.3,
|
||||
|
@ -3183,7 +3183,7 @@ static void test_perf_scale(const testCtx *const p_ctx) {
|
|||
}
|
||||
|
||||
start = clock();
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
||||
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
|
||||
diff_encode += clock() - start;
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue