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:
gitlost 2025-01-27 11:03:33 +00:00
parent a4b557786f
commit b377b14360
93 changed files with 1397 additions and 1370 deletions

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020-2024 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-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
@ -37,12 +37,12 @@ static void test_large(const testCtx *const p_ctx) {
struct item {
int symbology;
int option_2;
char *pattern;
const char *pattern;
int length;
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -93,7 +93,7 @@ static void test_large(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data_buf, data[i].length, debug);
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
ret = ZBarcode_Encode(symbol, TCU(data_buf), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
@ -115,8 +115,8 @@ static void test_hrt(const testCtx *const p_ctx) {
struct item {
int symbology;
int option_2;
char *data;
char *expected;
const char *data;
const char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -160,7 +160,7 @@ static void test_hrt(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -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 ret %d != 0 %s\n", i, ret, symbol->errtxt);
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
@ -177,11 +177,11 @@ static void test_input(const testCtx *const p_ctx) {
struct item {
int symbology;
int input_mode;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -212,7 +212,7 @@ static void test_input(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1 /*option_2*/, -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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
@ -234,13 +234,13 @@ static void test_encode(const testCtx *const p_ctx) {
struct item {
int symbology;
int option_2;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
/* BARCODE_ITF14 examples verified manually against GS1 General Specifications 21.0.1 */
static const struct item data[] = {
@ -351,7 +351,7 @@ static void test_encode(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -411,12 +411,12 @@ static void test_perf(const testCtx *const p_ctx) {
struct item {
int symbology;
int option_2;
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_C25INTER, -1, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", 0, 1, 819, "C25INTER 90" },
@ -457,7 +457,7 @@ static void test_perf(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, DATA_MODE, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug);
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);

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020-2024 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-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
@ -36,7 +36,7 @@ static void test_large(const testCtx *const p_ctx) {
struct item {
int symbology;
char *pattern;
const char *pattern;
int length;
int ret;
int expected_rows;
@ -81,7 +81,7 @@ static void test_large(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data_buf, data[i].length, debug);
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
ret = ZBarcode_Encode(symbol, TCU(data_buf), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < ZINT_ERROR) {
@ -100,9 +100,9 @@ static void test_hrt(const testCtx *const p_ctx) {
struct item {
int symbology;
char *data;
const char *data;
char *expected;
const char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -123,7 +123,7 @@ static void test_hrt(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_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 ret %d != 0 %s\n", i, ret, symbol->errtxt);
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
@ -139,11 +139,11 @@ static void test_input(const testCtx *const p_ctx) {
struct item {
int symbology;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -189,7 +189,7 @@ static void test_input(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
@ -226,13 +226,13 @@ static void test_encode(const testCtx *const p_ctx) {
struct item {
int symbology;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
static const struct item data[] = {
/* 0*/ { BARCODE_AUSPOST, "96184209", 0, 3, 73, "AusPost Tech Specs Diagram 1; verified manually against TEC-IT",
@ -332,7 +332,7 @@ static void test_encode(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -374,7 +374,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
struct item {
int symbology;
char *data;
const char *data;
int length;
int ret;
};
@ -402,7 +402,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
ZBarcode_Delete(symbol);

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020-2024 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-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
@ -41,7 +41,7 @@ static void test_large(const testCtx *const p_ctx) {
int option_2;
int output_options;
struct zint_structapp structapp;
char *pattern;
const char *pattern;
int length;
int ret;
int expected_rows;
@ -202,7 +202,7 @@ static void test_large(const testCtx *const p_ctx) {
symbol->structapp = data[i].structapp;
}
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
ret = ZBarcode_Encode(symbol, TCU(data_buf), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
@ -248,7 +248,7 @@ static void test_options(const testCtx *const p_ctx) {
int option_1;
int option_2;
struct zint_structapp structapp;
char *data;
const char *data;
int ret;
int expected_rows;
@ -304,7 +304,7 @@ static void test_options(const testCtx *const p_ctx) {
symbol->structapp = data[i].structapp;
}
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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < ZINT_ERROR) {
@ -329,15 +329,15 @@ static void test_encode(const testCtx *const p_ctx) {
int output_options;
int option_1;
int option_2;
char *data;
const char *data;
int length;
int ret;
int expected_rows;
int expected_width;
int bwipp_cmp;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
static const struct item data[] = {
/* 0*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, -1, 1, "123456789012", -1, 0, 15, 15, 1, "ISO/IEC 24778:2008 Figure 1 (left)",
@ -2622,7 +2622,7 @@ static void test_encode(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, data[i].eci, data[i].option_1, data[i].option_2, -1, data[i].output_options, data[i].data, data[i].length, debug);
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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -2688,8 +2688,8 @@ static void test_encode_segs(const testCtx *const p_ctx) {
int expected_rows;
int expected_width;
int bwipp_cmp;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, -1, 1, { { TU(""), -1, 0 }, { TU("Ж"), -1, 7 }, { TU(""), 0, 0 } }, 0, 15, 15, 1, "ISO/IEC 24778:2008 16.5 example",
@ -2968,10 +2968,10 @@ static void test_fuzz(const testCtx *const p_ctx) {
int input_mode;
int option_1;
int option_2;
char *data;
const char *data;
int length;
int ret;
char *expected_errtxt;
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -3727,7 +3727,7 @@ static void test_fuzz(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, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d symbol->errtxt %s != %s\n", i, symbol->errtxt, data[i].expected_errtxt);
@ -3766,12 +3766,12 @@ static void test_perf(const testCtx *const p_ctx) {
int input_mode;
int option_1;
int option_2;
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_AZTEC, -1, -1, -1,
@ -3837,7 +3837,7 @@ static void test_perf(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, -1, -1 /*output_options*/, data[i].data, -1, debug);
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);

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2022-2024 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2022-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
@ -38,13 +38,13 @@ static void test_input(const testCtx *const p_ctx) {
int input_mode;
int option_1;
int option_2;
char *data;
const char *data;
int length;
int ret;
int expected_rows;
int expected_width;
char *expected;
char *comment;
const char *expected;
const char *comment;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -91,7 +91,7 @@ static void test_input(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_BC412, data[i].input_mode, -1 /*eci*/, data[i].option_1, data[i].option_2, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < ZINT_ERROR) {
@ -126,14 +126,14 @@ static void test_encode(const testCtx *const p_ctx) {
int input_mode;
int option_1;
int option_2;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
int bwipp_cmp;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, -1, "AQ45670", 0, 1, 102, 1, "SEMI T1-95 Figure 2, same",
@ -164,7 +164,7 @@ static void test_encode(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_BC412, data[i].input_mode, -1 /*eci*/, data[i].option_1, data[i].option_2, -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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2021-2022 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2021-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
@ -175,12 +175,12 @@ static int big5_utf8(struct zint_symbol *symbol, const unsigned char source[], i
static void test_big5_utf8(const testCtx *const p_ctx) {
struct item {
char *data;
const char *data;
int length;
int ret;
int ret_length;
unsigned int expected_b5data[20];
char *comment;
const char *comment;
};
/*
_ U+FF3F fullwidth low line, not in ISO/Win, in Big5 0xA1C4, UTF-8 EFBCBF
@ -207,7 +207,7 @@ static void test_big5_utf8(const testCtx *const p_ctx) {
length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length;
ret_length = length;
ret = big5_utf8(&symbol, (unsigned char *) data[i].data, &ret_length, b5data);
ret = big5_utf8(&symbol, TCU(data[i].data), &ret_length, b5data);
assert_equal(ret, data[i].ret, "i:%d ret %d != %d (%s)\n", i, ret, data[i].ret, symbol.errtxt);
if (ret == 0) {
int j;

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020-2024 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-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
@ -32,7 +32,7 @@
#include "testcommon.h"
#include <sys/stat.h>
INTERNAL int bmp_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf);
INTERNAL int bmp_pixel_plot(struct zint_symbol *symbol, const unsigned char *pixelbuf);
static void test_pixel_plot(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
@ -40,7 +40,7 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
struct item {
int width;
int height;
char *pattern;
const char *pattern;
int repeat;
int ret;
};
@ -61,7 +61,7 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
int i, ret;
struct zint_symbol *symbol;
char *bmp = "out.bmp";
const char *bmp = "out.bmp";
char data_buf[8 * 2 + 1];
@ -99,7 +99,7 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
symbol->bitmap = (unsigned char *) data_buf;
ret = bmp_pixel_plot(symbol, (unsigned char *) data_buf);
ret = bmp_pixel_plot(symbol, TCU(data_buf));
assert_equal(ret, data[i].ret, "i:%d bmp_pixel_plot ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < ZINT_ERROR) {
@ -135,10 +135,10 @@ static void test_print(const testCtx *const p_ctx) {
int whitespace_height;
int option_1;
int option_2;
char *fgcolour;
char *bgcolour;
char *data;
char *expected_file;
const char *fgcolour;
const char *bgcolour;
const char *data;
const char *expected_file;
};
static const struct item data[] = {
/* 0*/ { BARCODE_PDF417, -1, -1, 5, -1, -1, -1, "147AD0", "FC9630", "123", "pdf417_fg_bg.bmp" },
@ -195,7 +195,7 @@ static void test_print(const testCtx *const p_ctx) {
strcpy(symbol->bgcolour, data[i].bgcolour);
}
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_zero(ret, "i:%d %s ZBarcode_Encode ret %d != 0 %s\n", i, testUtilBarcodeName(data[i].symbology), ret, symbol->errtxt);
strcpy(symbol->outfile, bmp);

View file

@ -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
@ -36,10 +36,10 @@ static void test_hrt(const testCtx *const p_ctx) {
struct item {
int option_2;
char *data;
const char *data;
int length;
char *expected;
const char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -80,7 +80,7 @@ static void test_hrt(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_CHANNEL, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, data[i].length, 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 ret %d != 0 %s\n", i, ret, symbol->errtxt);
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
@ -96,11 +96,11 @@ static void test_input(const testCtx *const p_ctx) {
struct item {
int option_2;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -174,7 +174,7 @@ static void test_input(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_CHANNEL, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
@ -197,13 +197,13 @@ static void test_encode(const testCtx *const p_ctx) {
struct item {
int option_2;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
static const struct item data[] = {
/* 0*/ { -1, "1234", 0, 1, 27, "ANSI/AIM BC12-1998 Figure 1",
@ -436,7 +436,7 @@ static void test_encode(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_CHANNEL, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -476,7 +476,7 @@ static void test_encode(const testCtx *const p_ctx) {
static void test_generate(const testCtx *const p_ctx) {
struct item {
char *data;
const char *data;
};
static const struct item data[] = { { "576688" }, { "7742862" } };
const int data_size = ARRAY_SIZE(data);
@ -493,7 +493,7 @@ static void test_generate(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_CHANNEL, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, 0);
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 ret %d != 0 (%s)\n", i, ret, symbol->errtxt);
ZBarcode_Delete(symbol);

View file

@ -39,7 +39,7 @@ static void test_large(const testCtx *const p_ctx) {
struct item {
int symbology;
int option_2;
char *pattern;
const char *pattern;
int length;
int ret;
int expected_rows;
@ -72,7 +72,7 @@ static void test_large(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data_buf, data[i].length, debug);
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
ret = ZBarcode_Encode(symbol, TCU(data_buf), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < ZINT_ERROR) {
@ -92,9 +92,9 @@ static void test_hrt(const testCtx *const p_ctx) {
struct item {
int symbology;
int option_2;
char *data;
const char *data;
char *expected;
const char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -120,7 +120,7 @@ static void test_hrt(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -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 ret %d != 0 %s\n", i, ret, symbol->errtxt);
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
@ -136,7 +136,7 @@ static void test_input(const testCtx *const p_ctx) {
struct item {
int symbology;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
@ -177,7 +177,7 @@ static void test_input(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d symbol->errtxt %s != %s\n", i, symbol->errtxt, data[i].expected_errtxt);
@ -213,13 +213,13 @@ static void test_encode(const testCtx *const p_ctx) {
struct item {
int symbology;
int option_2;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
static const struct item data[] = {
/* 0*/ { BARCODE_CODABAR, -1, "A37859B", 0, 1, 72, "BS EN 798:1995 Figure 1",
@ -260,7 +260,7 @@ static void test_encode(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {

View file

@ -37,12 +37,12 @@ static void test_large(const testCtx *const p_ctx) {
struct item {
int option_1;
int option_2;
char *pattern;
const char *pattern;
int length;
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
const char *expected_errtxt;
};
/*
é U+00E9 (\351, 233), UTF-8 C3A9, CodeB-only extended ASCII
@ -106,7 +106,7 @@ static void test_large(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_CODABLOCKF, -1 /*input_mode*/, -1 /*eci*/, data[i].option_1, data[i].option_2, -1, -1 /*output_options*/, data_buf, data[i].length, debug);
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
ret = ZBarcode_Encode(symbol, TCU(data_buf), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
@ -129,12 +129,12 @@ static void test_options(const testCtx *const p_ctx) {
int input_mode;
int option_1;
int option_2;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
char *comment;
const char *expected_errtxt;
const char *comment;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -178,7 +178,7 @@ static void test_options(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_CODABLOCKF, data[i].input_mode, -1 /*eci*/, data[i].option_1, data[i].option_2, -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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
@ -201,12 +201,12 @@ static void test_reader_init(const testCtx *const p_ctx) {
int symbology;
int input_mode;
int output_options;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
char *expected;
char *comment;
const char *expected;
const char *comment;
};
static const struct item data[] = {
/* 0*/ { BARCODE_CODABLOCKF, UNICODE_MODE, READER_INIT, "1234", 0, 2, 101, "67 64 40 60 63 0C 22 2B 6A 67 64 0B 63 64 3A 1C 29 6A", "CodeB FNC3 CodeC 12 34 / CodeB Pads" },
@ -232,7 +232,7 @@ static void test_reader_init(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1 /*option_2*/, -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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -262,14 +262,14 @@ static void test_input(const testCtx *const p_ctx) {
int input_mode;
int option_1;
int option_2;
char *data;
const char *data;
int length;
int ret;
int expected_rows;
int expected_width;
int bwipp_cmp;
char *expected;
char *comment;
const char *expected;
const char *comment;
};
/*
NUL U+0000, CodeA-only
@ -365,7 +365,7 @@ static void test_input(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, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -420,14 +420,14 @@ static void test_encode(const testCtx *const p_ctx) {
int symbology;
int option_1;
int option_2;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
int bwipp_cmp;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
static const struct item data[] = {
/* 0*/ { BARCODE_CODABLOCKF, 1, -1, "AIM", 0, 1, 68, 1, "Same as CODE128 (not supported by BWIPP or ZXing-C++)",
@ -539,7 +539,7 @@ static void test_encode(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, UNICODE_MODE, -1 /*eci*/, data[i].option_1, data[i].option_2, -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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -597,11 +597,11 @@ static void test_fuzz(const testCtx *const p_ctx) {
struct item {
int option_1;
int option_2;
char *data;
const char *data;
int length;
int ret;
int bwipp_cmp;
char *comment;
const char *comment;
};
static const struct item data[] = {
/* 0*/ { -1, -1, "\034\034I", 3, 0, 1, "" },
@ -637,7 +637,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_CODABLOCKF, -1 /*input_mode*/, -1 /*eci*/, data[i].option_1, data[i].option_2, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < ZINT_ERROR) {

View file

@ -37,12 +37,12 @@ static void test_large(const testCtx *const p_ctx) {
struct item {
int symbology;
int option_2;
char *pattern;
const char *pattern;
int length;
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -89,7 +89,7 @@ static void test_large(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data_buf, data[i].length, debug);
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
ret = ZBarcode_Encode(symbol, TCU(data_buf), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
@ -111,10 +111,10 @@ static void test_hrt(const testCtx *const p_ctx) {
struct item {
int symbology;
int option_2;
char *data;
const char *data;
int length;
char *expected;
const char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -164,7 +164,7 @@ static void test_hrt(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, data[i].length, 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 ret %d != 0 %s\n", i, ret, symbol->errtxt);
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
@ -182,12 +182,12 @@ static void test_input(const testCtx *const p_ctx) {
int symbology;
int input_mode;
int option_2;
char *data;
const char *data;
int length;
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -260,7 +260,7 @@ static void test_input(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
@ -282,14 +282,14 @@ static void test_encode(const testCtx *const p_ctx) {
struct item {
int symbology;
int option_2;
char *data;
const char *data;
int length;
int ret;
int expected_rows;
int expected_width;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
static const struct item data[] = {
/* 0*/ { BARCODE_CODE39, -1, "1A", -1, 0, 1, 51, "ISO/IEC 16388:2007 Figure 1",
@ -417,7 +417,7 @@ static void test_encode(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -477,12 +477,12 @@ static void test_perf(const testCtx *const p_ctx) {
struct item {
int symbology;
int option_2;
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_CODE39, -1, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+", 0, 1, 1130, "CODE39 85" },
@ -525,7 +525,7 @@ static void test_perf(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, DATA_MODE, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug);
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);

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020-2024 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-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
@ -38,12 +38,12 @@ static void test_large(const testCtx *const p_ctx) {
int eci;
int option_2;
struct zint_structapp structapp;
char *pattern;
const char *pattern;
int length;
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
const char *expected_errtxt;
};
/* Reference AIM USS Code One Table 2 */
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
@ -217,7 +217,7 @@ static void test_large(const testCtx *const p_ctx) {
symbol->structapp = data[i].structapp;
}
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
ret = ZBarcode_Encode(symbol, TCU(data_buf), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
@ -241,7 +241,7 @@ static void test_input(const testCtx *const p_ctx) {
int eci;
int option_2;
struct zint_structapp structapp;
char *data;
const char *data;
int length;
int ret;
int expected_rows;
@ -307,7 +307,7 @@ static void test_input(const testCtx *const p_ctx) {
symbol->structapp = data[i].structapp;
}
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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < ZINT_ERROR) {
@ -330,15 +330,15 @@ static void test_encode(const testCtx *const p_ctx) {
int eci;
int option_2;
struct zint_structapp structapp;
char *data;
const char *data;
int length;
int ret;
int expected_rows;
int expected_width;
int bwipp_cmp;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
/* Figure examples AIM USS Code One (USSCO) Revision March 3, 2000 */
static const struct item data[] = {
@ -2910,7 +2910,7 @@ static void test_encode(const testCtx *const p_ctx) {
symbol->structapp = data[i].structapp;
}
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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -2972,8 +2972,8 @@ static void test_encode_segs(const testCtx *const p_ctx) {
int expected_rows;
int expected_width;
int bwipp_cmp;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
/* Figure examples AIM USS Code One (USSCO) Revision March 3, 2000 */
static const struct item data[] = {
@ -3363,11 +3363,11 @@ static void test_fuzz(const testCtx *const p_ctx) {
struct item {
int option_2;
char *data;
const char *data;
int length;
int ret;
int bwipp_cmp;
char *comment;
const char *comment;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -3398,7 +3398,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_CODEONE, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < ZINT_ERROR) {

View file

@ -39,12 +39,12 @@ static void test_large(const testCtx *const p_ctx) {
struct item {
int symbology;
int option_2;
char *pattern;
const char *pattern;
int length;
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -71,7 +71,7 @@ static void test_large(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data_buf, data[i].length, debug);
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
ret = ZBarcode_Encode(symbol, TCU(data_buf), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
@ -93,10 +93,10 @@ static void test_hrt(const testCtx *const p_ctx) {
struct item {
int symbology;
int option_2;
char *data;
const char *data;
int length;
char *expected;
const char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -120,7 +120,7 @@ static void test_hrt(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, data[i].length, 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 ret %d != 0 %s\n", i, ret, symbol->errtxt);
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
@ -138,12 +138,12 @@ static void test_input(const testCtx *const p_ctx) {
int symbology;
int input_mode;
int option_2;
char *data;
const char *data;
int length;
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -172,7 +172,7 @@ static void test_input(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
@ -194,14 +194,14 @@ static void test_encode(const testCtx *const p_ctx) {
struct item {
int symbology;
int option_2;
char *data;
const char *data;
int length;
int ret;
int expected_rows;
int expected_width;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
static const struct item data[] = {
/* 0*/ { BARCODE_CODE11, -1, "123-45", -1, 0, 1, 78, "2 check digits (52); verified manually against TEC-IT",
@ -245,7 +245,7 @@ static void test_encode(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -305,12 +305,12 @@ static void test_perf(const testCtx *const p_ctx) {
struct item {
int symbology;
int option_2;
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_CODE11, -1, "1234567890-1234567890-1234567890-1234567890-1234567890-1234567890-1234567890-1234567890-1234567890-1234567890-1234567890-", 0, 1, 966, "CODE11 121" },
@ -349,7 +349,7 @@ static void test_perf(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, DATA_MODE, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug);
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);

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020-2024 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-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
@ -40,11 +40,11 @@ static void test_large(const testCtx *const p_ctx) {
int symbology;
int input_mode;
int output_options;
char *pattern;
const char *pattern;
int length;
int ret;
int expected_width;
char *expected_errtxt;
const char *expected_errtxt;
};
/*
é U+00E9 (\351, 233), UTF-8 C3A9, CodeB-only extended ASCII
@ -126,7 +126,7 @@ static void test_large(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, data[i].output_options, data_buf, data[i].length, debug);
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
ret = ZBarcode_Encode(symbol, TCU(data_buf), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
@ -176,10 +176,10 @@ static void test_hrt(const testCtx *const p_ctx) {
int symbology;
int input_mode;
int option_2;
char *data;
const char *data;
int length;
char *expected;
const char *expected;
};
/*
é U+00E9 (\351, 233), UTF-8 C3A9, CodeB-only extended ASCII
@ -256,7 +256,7 @@ static void test_hrt(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, data[i].length, 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 ret %d != 0 %s\n", i, ret, symbol->errtxt);
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
@ -305,12 +305,12 @@ static void test_reader_init(const testCtx *const p_ctx) {
int symbology;
int input_mode;
int output_options;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
char *expected;
char *comment;
const char *expected;
const char *comment;
};
static const struct item data[] = {
/* 0*/ { BARCODE_CODE128, UNICODE_MODE, READER_INIT, "A", 0, 1, 57, "(5) 104 96 33 60 106", "StartB FNC3 A" },
@ -347,7 +347,7 @@ static void test_reader_init(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1 /*option_2*/, -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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -388,13 +388,13 @@ static void test_input(const testCtx *const p_ctx) {
struct item {
int input_mode;
char *data;
const char *data;
int length;
int ret;
int expected_width;
int bwipp_cmp;
char *expected;
char *comment;
const char *expected;
const char *comment;
};
/*
NUL U+0000, CodeA-only
@ -559,7 +559,7 @@ static void test_input(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_CODE128, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
if (p_ctx->generate) {
printf(" /*%3d*/ { %s, \"%s\", %d, %s, %d, %d, \"%s\", \"%s\" },\n",
@ -614,12 +614,12 @@ static void test_gs1_128_input(const testCtx *const p_ctx) {
struct item {
int input_mode;
char *data;
const char *data;
int ret;
int expected_width;
int bwipp_cmp;
char *expected;
char *comment;
const char *expected;
const char *comment;
};
static const struct item data[] = {
/* 0*/ { GS1_MODE, "[90]1[90]1", 0, 123, 0, "(11) 105 102 90 100 17 102 25 99 1 56 106", "StartC FNC1 9 0 1 FNC1 9 0 1; BWIPP different encodation (same width)" },
@ -680,7 +680,7 @@ static void test_gs1_128_input(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_GS1_128, data[i].input_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);
if (p_ctx->generate) {
printf(" /*%3d*/ { %s, \"%s\", %s, %d, %d, \"%s\", \"%s\" },\n",
@ -739,12 +739,12 @@ static void test_hibc_input(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
char *data;
const char *data;
int ret;
int expected_width;
int bwipp_cmp;
char *expected;
char *comment;
const char *expected;
const char *comment;
};
static const struct item data[] = {
/* 0*/ { ",", ZINT_ERROR_INVALID_DATA, -1, 0, "Error 203: Invalid character at position 1 in input (alphanumerics, space and \"-.$/+%\" only)", "" },
@ -782,7 +782,7 @@ static void test_hibc_input(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_HIBC_128, 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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -835,11 +835,11 @@ static void test_nve18_input(const testCtx *const p_ctx) {
struct item {
int input_mode;
char *data;
const char *data;
int ret;
int expected_width;
char *expected;
char *comment;
const char *expected;
const char *comment;
};
static const struct item data[] = {
/* 0*/ { -1, "123456789012345678", ZINT_ERROR_TOO_LONG, -1, "Error 345: Input length 18 too long (maximum 17)", "" },
@ -865,7 +865,7 @@ static void test_nve18_input(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_NVE18, data[i].input_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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
@ -890,11 +890,11 @@ static void test_ean14_input(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
char *data;
const char *data;
int ret;
int expected_width;
char *expected;
char *comment;
const char *expected;
const char *comment;
};
static const struct item data[] = {
/* 0*/ { "12345678901234", ZINT_ERROR_TOO_LONG, -1, "Error 345: Input length 14 too long (maximum 13)", "" },
@ -919,7 +919,7 @@ static void test_ean14_input(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_EAN14, 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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -945,13 +945,13 @@ static void test_dpd_input(const testCtx *const p_ctx) {
struct item {
int option_2;
int output_options;
char *data;
const char *data;
int ret;
int expected_width;
float expected_height;
int bwipp_cmp;
char *expected;
char *comment;
const char *expected;
const char *comment;
};
static const struct item data[] = {
/* 0*/ { -1, -1, "12345678901234567890123456", ZINT_ERROR_TOO_LONG, -1, 0, 1, "Error 349: DPD input length 26 wrong (27 or 28 only)", "" },
@ -1012,7 +1012,7 @@ static void test_dpd_input(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_DPD, UNICODE_MODE, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -1066,11 +1066,11 @@ static void test_upu_s10_input(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
char *data;
const char *data;
int ret;
int expected_width;
char *expected;
char *comment;
const char *expected;
const char *comment;
};
static const struct item data[] = {
/* 0*/ { "AB123456789ABC", ZINT_ERROR_TOO_LONG, 0, "Error 834: Input length 14 wrong (12 or 13 only)", "" },
@ -1117,7 +1117,7 @@ static void test_upu_s10_input(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_UPU_S10, 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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -1159,14 +1159,14 @@ static void test_encode(const testCtx *const p_ctx) {
int symbology;
int input_mode;
int option_2;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
int bwipp_cmp;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
/* BARCODE_GS1_128 examples verified manually against GS1 General Specifications 21.0.1 (GGS) */
/* BARCODE_DPD examples Specification DPD and primetime Parcel Despatch (DPDAPPD) Version 4.0.2, also
@ -1356,7 +1356,7 @@ static void test_encode(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -1422,12 +1422,12 @@ static void test_perf(const testCtx *const p_ctx) {
struct item {
int symbology;
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_CODE128, "123456ABCD123456ABCD123456ABCD123456ABCD123456ABCD123456ABCD", 0, 1, 618, "CODE128 60" },
@ -1467,7 +1467,7 @@ static void test_perf(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, DATA_MODE, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
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);

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020-2024 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-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
@ -35,12 +35,12 @@ static void test_large(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
char *pattern;
const char *pattern;
int length;
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -76,7 +76,7 @@ static void test_large(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_CODE16K, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data_buf, data[i].length, debug);
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
ret = ZBarcode_Encode(symbol, TCU(data_buf), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
@ -98,12 +98,12 @@ static void test_reader_init(const testCtx *const p_ctx) {
struct item {
int input_mode;
int output_options;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
char *expected;
char *comment;
const char *expected;
const char *comment;
};
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, READER_INIT, "A", 0, 2, 70, "(10) 1 96 33 103 103 103 103 103 68 35", "ModeB FNC3 A Pad (5)" },
@ -130,7 +130,7 @@ static void test_reader_init(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_CODE16K, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1 /*option_2*/, -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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -158,14 +158,14 @@ static void test_input(const testCtx *const p_ctx) {
struct item {
int input_mode;
int option_1;
char *data;
const char *data;
int length;
int ret;
int expected_rows;
int expected_width;
int bwipp_cmp;
char *expected;
char *comment;
const char *expected;
const char *comment;
};
/*
NUL U+0000, CodeA-only
@ -246,7 +246,7 @@ static void test_input(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_CODE16K, data[i].input_mode, -1 /*eci*/, data[i].option_1, -1, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -300,13 +300,13 @@ static void test_encode(const testCtx *const p_ctx) {
struct item {
int input_mode;
int option_1;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, "ab0123456789", 0, 2, 70, "BS EN 12323:2005 Figure 3",
@ -373,7 +373,7 @@ static void test_encode(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_CODE16K, data[i].input_mode, -1 /*eci*/, data[i].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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020-2024 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-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
@ -35,12 +35,12 @@ static void test_large(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
char *pattern;
const char *pattern;
int length;
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -69,7 +69,7 @@ static void test_large(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_CODE49, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data_buf, data[i].length, debug);
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
ret = ZBarcode_Encode(symbol, TCU(data_buf), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
@ -91,13 +91,13 @@ static void test_input(const testCtx *const p_ctx) {
struct item {
int input_mode;
int option_1;
char *data;
const char *data;
int length;
int ret;
int expected_rows;
int expected_width;
char *expected;
char *comment;
const char *expected;
const char *comment;
};
/*
NUL U+0000, S1 SP (39)
@ -155,7 +155,7 @@ static void test_input(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_CODE49, data[i].input_mode, -1 /*eci*/, data[i].option_1, -1, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -194,13 +194,13 @@ static void test_encode(const testCtx *const p_ctx) {
struct item {
int input_mode;
int option_1;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, "MULTIPLE ROWS IN CODE 49", 0, 5, 70, "ANSI/AIM BC6-2000 Figure 1",
@ -251,7 +251,7 @@ static void test_encode(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_CODE49, data[i].input_mode, -1 /*eci*/, data[i].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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {

View file

@ -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
@ -54,7 +54,7 @@ static int is_sane_orig(const char test_string[], const unsigned char source[],
static void test_to_int(const testCtx *const p_ctx) {
struct item {
char *data;
const char *data;
int length;
int ret;
};
@ -88,9 +88,9 @@ static void test_to_int(const testCtx *const p_ctx) {
static void test_to_upper(const testCtx *const p_ctx) {
struct item {
char *data;
const char *data;
int length;
char *expected;
const char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -126,7 +126,7 @@ static void test_to_upper(const testCtx *const p_ctx) {
static void test_chr_cnt(const testCtx *const p_ctx) {
struct item {
char *data;
const char *data;
int length;
char c;
int ret;
@ -159,11 +159,11 @@ static void test_not_sane(const testCtx *const p_ctx) {
struct item {
unsigned int flg;
char *data;
const char *data;
int length;
int ret;
char *orig_test;
const char *orig_test;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -292,9 +292,9 @@ static void test_not_sane(const testCtx *const p_ctx) {
static void test_not_sane_lookup(const testCtx *const p_ctx) {
struct item {
char *test_string;
const char *test_string;
int test_length;
char *data;
const char *data;
int length;
int ret;
@ -339,8 +339,8 @@ static void test_errtxt(const testCtx *const p_ctx) {
int debug_test;
int error_number;
int err_id;
char *msg;
char *expected;
const char *msg;
const char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -385,13 +385,13 @@ static void test_errtxtf(const testCtx *const p_ctx) {
int debug_test;
int error_number;
int err_id;
char *fmt;
const char *fmt;
int num_args;
int i_arg;
const char *s_arg;
double f_arg;
int ret;
char *expected;
const char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -536,7 +536,7 @@ static void test_errtxtf(const testCtx *const p_ctx) {
static void test_cnt_digits(const testCtx *const p_ctx) {
struct item {
char *data;
const char *data;
int length;
int position;
int max;
@ -572,10 +572,10 @@ static void test_cnt_digits(const testCtx *const p_ctx) {
static void test_is_valid_utf8(const testCtx *const p_ctx) {
struct item {
char *data;
const char *data;
int length;
int ret;
char *comment;
const char *comment;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -612,13 +612,13 @@ static void test_utf8_to_unicode(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
char *data;
const char *data;
int length;
int disallow_4byte;
int ret;
int ret_length;
unsigned int expected_vals[20];
char *comment;
const char *comment;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -666,11 +666,11 @@ static void test_hrt_cpy_iso8859_1(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
char *data;
const char *data;
int length;
int ret;
char *expected;
char *comment;
const char *expected;
const char *comment;
};
/*
NBSP U+00A0 (\240, 160), UTF-8 C2A0 (\302\240)
@ -748,8 +748,8 @@ static void test_set_height(const testCtx *const p_ctx) {
int ret;
float expected_height;
char *expected_errtxt;
char *comment;
const char *expected_errtxt;
const char *comment;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -803,7 +803,7 @@ static void test_debug_test_codeword_dump_int(const testCtx *const p_ctx) {
struct item {
int codewords[50];
int length;
char *expected;
const char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {

View file

@ -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
@ -36,8 +36,8 @@ static void test_eanx_leading_zeroes(const testCtx *const p_ctx) {
struct item {
int symbology;
char *data;
char *composite;
const char *data;
const char *composite;
int ret;
int expected_rows;
@ -92,7 +92,7 @@ static void test_eanx_leading_zeroes(const testCtx *const p_ctx) {
composite_length = (int) strlen(data[i].composite);
ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].composite, composite_length);
ret = ZBarcode_Encode(symbol, TCU(data[i].composite), composite_length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
@ -104,7 +104,8 @@ static void test_eanx_leading_zeroes(const testCtx *const p_ctx) {
testFinish();
}
static void test_helper_generate(const struct zint_symbol *symbol, int ret, int i, char *data, char *composite, int option_1, char *comment, int bwipp_cmp) {
static void test_helper_generate(const struct zint_symbol *symbol, int ret, int i, const char *data,
const char *composite, int option_1, const char *comment, int bwipp_cmp) {
char esc_data[1024];
char esc_composite[4096];
@ -140,15 +141,15 @@ static void test_examples(const testCtx *const p_ctx) {
int symbology;
int input_mode;
int option_1;
char *data;
char *composite;
const char *data;
const char *composite;
int ret;
int expected_rows;
int expected_width;
int bwipp_cmp;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
/* Verified manually against GS1 General Specifications 21.0.1 (GGS) and ISO/IEC 24723:2010, with noted exceptions, and verified via bwipp_dump.ps against BWIPP */
static const struct item data[] = {
@ -1553,7 +1554,7 @@ static void test_examples(const testCtx *const p_ctx) {
composite_length = (int) strlen(data[i].composite);
ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].composite, composite_length);
ret = ZBarcode_Encode(symbol, TCU(data[i].composite), composite_length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -1598,14 +1599,14 @@ static void test_odd_numbered_numeric(const testCtx *const p_ctx) {
struct item {
int symbology;
int option_1;
char *data;
char *composite;
const char *data;
const char *composite;
int ret;
int expected_rows;
int expected_width;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
/* Verified via bwipp_dump.ps against BWIPP, and manually against tec-it.com */
static const struct item data[] = {
@ -1726,7 +1727,7 @@ static void test_odd_numbered_numeric(const testCtx *const p_ctx) {
composite_length = (int) strlen(data[i].composite);
ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].composite, composite_length);
ret = ZBarcode_Encode(symbol, TCU(data[i].composite), composite_length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -1762,15 +1763,15 @@ static void test_ean128_cc_shift(const testCtx *const p_ctx) {
struct item {
int symbology;
int option_1;
char *data;
char *composite;
const char *data;
const char *composite;
int ret;
int expected_rows;
int expected_width;
int bwipp_cmp;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
/* Verified via bwipp_dump.ps against BWIPP except where noted, when shift verified manually (tec-it.com seems to be off by 2 for top shifts > 1) */
static const struct item data[] = {
@ -1855,7 +1856,7 @@ static void test_ean128_cc_shift(const testCtx *const p_ctx) {
composite_length = (int) strlen(data[i].composite);
ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].composite, composite_length);
ret = ZBarcode_Encode(symbol, TCU(data[i].composite), composite_length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -1893,13 +1894,13 @@ static void test_ean128_cc_width(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
char *data;
char *composite;
const char *data;
const char *composite;
int ret;
int expected_rows;
int expected_width;
char *comment;
const char *comment;
};
/* Verified manually with BWIPP (except very large tests) */
static const struct item data[] = {
@ -1936,7 +1937,7 @@ static void test_ean128_cc_width(const testCtx *const p_ctx) {
composite_length = (int) strlen(data[i].composite);
ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].composite, composite_length);
ret = ZBarcode_Encode(symbol, TCU(data[i].composite), composite_length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -1960,14 +1961,14 @@ static void test_encodation_0(const testCtx *const p_ctx) {
struct item {
int symbology;
int option_1;
char *data;
char *composite;
const char *data;
const char *composite;
int ret;
int expected_rows;
int expected_width;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
/* Verified via bwipp_dump.ps against BWIPP and manually against tec-it.com (with noted exception) */
static const struct item data[] = {
@ -2403,7 +2404,7 @@ static void test_encodation_0(const testCtx *const p_ctx) {
composite_length = (int) strlen(data[i].composite);
ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].composite, composite_length);
ret = ZBarcode_Encode(symbol, TCU(data[i].composite), composite_length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -2439,14 +2440,14 @@ static void test_encodation_10(const testCtx *const p_ctx) {
struct item {
int symbology;
int option_1;
char *data;
char *composite;
const char *data;
const char *composite;
int ret;
int expected_rows;
int expected_width;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
/* Verified via bwipp_dump.ps against BWIPP, and manually, with noted exceptions, against tec-it.com */
static const struct item data[] = {
@ -2541,7 +2542,7 @@ static void test_encodation_10(const testCtx *const p_ctx) {
composite_length = (int) strlen(data[i].composite);
ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].composite, composite_length);
ret = ZBarcode_Encode(symbol, TCU(data[i].composite), composite_length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -2577,14 +2578,14 @@ static void test_encodation_11(const testCtx *const p_ctx) {
struct item {
int symbology;
int option_1;
char *data;
char *composite;
const char *data;
const char *composite;
int ret;
int expected_rows;
int expected_width;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
/* Verified via bwipp_dump.ps against BWIPP, and manually against tec-it.com (with noted exception) */
static const struct item data[] = {
@ -2957,7 +2958,7 @@ static void test_encodation_11(const testCtx *const p_ctx) {
composite_length = (int) strlen(data[i].composite);
ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].composite, composite_length);
ret = ZBarcode_Encode(symbol, TCU(data[i].composite), composite_length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -2995,13 +2996,13 @@ static void test_addongap(const testCtx *const p_ctx) {
int symbology;
int option_1;
int option_2;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
/* Verified via bwipp_dump.ps against BWIPP */
static const struct item data[] = {
@ -3091,7 +3092,7 @@ static void test_addongap(const testCtx *const p_ctx) {
char bwipp_buf[8192];
char bwipp_msg[1024];
char *composite = "[91]12";
const char *composite = "[91]12";
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
@ -3110,7 +3111,7 @@ static void test_addongap(const testCtx *const p_ctx) {
composite_length = (int) strlen(composite);
ret = ZBarcode_Encode(symbol, (const unsigned char *) composite, composite_length);
ret = ZBarcode_Encode(symbol, TCU(composite), composite_length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -3150,8 +3151,8 @@ static void test_gs1parens(const testCtx *const p_ctx) {
struct item {
int symbology;
int input_mode;
char *data;
char *composite;
const char *data;
const char *composite;
int ret;
int expected_rows;
@ -3201,7 +3202,7 @@ static void test_gs1parens(const testCtx *const p_ctx) {
composite_length = (int) strlen(data[i].composite);
ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].composite, composite_length);
ret = ZBarcode_Encode(symbol, TCU(data[i].composite), composite_length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
@ -3219,11 +3220,11 @@ static void test_hrt(const testCtx *const p_ctx) {
struct item {
int symbology;
int input_mode;
char *data;
char *composite;
const char *data;
const char *composite;
int ret;
char *expected;
const char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -3282,7 +3283,7 @@ static void test_hrt(const testCtx *const p_ctx) {
composite_length = (int) strlen(data[i].composite);
ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].composite, composite_length);
ret = ZBarcode_Encode(symbol, TCU(data[i].composite), composite_length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, data[i].ret, ret, symbol->errtxt);
assert_zero(strcmp((const char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
@ -3303,13 +3304,13 @@ static void test_input(const testCtx *const p_ctx) {
int option_1;
int option_2;
int option_3;
char *data;
char *composite;
const char *data;
const char *composite;
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -3446,7 +3447,7 @@ static void test_input(const testCtx *const p_ctx) {
composite_length = (int) strlen(data[i].composite);
ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].composite, composite_length);
ret = ZBarcode_Encode(symbol, TCU(data[i].composite), composite_length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, data[i].ret, ret, symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
@ -3470,13 +3471,13 @@ static void test_fuzz(const testCtx *const p_ctx) {
int symbology;
int input_mode;
int option_1;
char *data;
const char *data;
int length;
char *composite;
const char *composite;
int ret;
int bwipp_cmp;
char *expected_errtxt;
char *comment;
const char *expected_errtxt;
const char *comment;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -3516,7 +3517,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
composite_length = (int) strlen(data[i].composite);
ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].composite, composite_length);
ret = ZBarcode_Encode(symbol, TCU(data[i].composite), composite_length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n",
i, symbol->errtxt, data[i].expected_errtxt);
@ -3555,13 +3556,13 @@ static void test_perf(const testCtx *const p_ctx) {
struct item {
int symbology;
int option_1;
char *data;
char *composite;
const char *data;
const char *composite;
int ret;
int expected_rows;
int expected_width;
char *comment;
const char *comment;
};
static const struct item data[] = {
/* 0*/ { BARCODE_EANX_CC, 1, "123456789012",
@ -3609,7 +3610,7 @@ static void test_perf(const testCtx *const p_ctx) {
composite_length = (int) strlen(data[i].composite);
start = clock();
ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].composite, composite_length);
ret = ZBarcode_Encode(symbol, TCU(data[i].composite), composite_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);

View file

@ -39,14 +39,14 @@ static void test_large(const testCtx *const p_ctx) {
int symbology;
int option_2;
struct zint_structapp structapp;
char *pattern;
const char *pattern;
int length;
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
char *expected_errtxt2;
char *comment;
const char *expected_errtxt;
const char *expected_errtxt2;
const char *comment;
};
/* ISO/IEC 16022:2006 Table 7 and ISO/IEC 21471:2020 (DMRE) Table 7 */
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
@ -382,7 +382,7 @@ static void test_large(const testCtx *const p_ctx) {
symbol->structapp = data[i].structapp;
}
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
ret = ZBarcode_Encode(symbol, TCU(data_buf), length);
if (p_ctx->generate) {
char errtxt[sizeof(symbol->errtxt)];
@ -394,7 +394,7 @@ static void test_large(const testCtx *const p_ctx) {
testUtilErrorName(ret), symbol->rows, symbol->width, errtxt);
ZBarcode_Clear(symbol);
symbol->input_mode |= FAST_MODE;
(void) ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
(void) ZBarcode_Encode(symbol, TCU(data_buf), length);
printf(" \"%s\", \"%s\" },\n", strcmp(errtxt, symbol->errtxt) != 0 ? symbol->errtxt : "", data[i].comment);
} else {
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
@ -419,7 +419,7 @@ static void test_large(const testCtx *const p_ctx) {
ZBarcode_Clear(symbol);
symbol->input_mode |= FAST_MODE;
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
ret = ZBarcode_Encode(symbol, TCU(data_buf), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
@ -460,10 +460,10 @@ static void test_buffer(const testCtx *const p_ctx) {
int eci;
int input_mode;
int output_options;
char *data;
const char *data;
int ret;
int bwipp_cmp;
char *comment;
const char *comment;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -492,7 +492,7 @@ static void test_buffer(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_DATAMATRIX, data[i].input_mode, data[i].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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret);
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, -1, -1, debug)) {
if (!data[i].bwipp_cmp) {
@ -537,7 +537,7 @@ static void test_options(const testCtx *const p_ctx) {
int option_3;
int output_options;
struct zint_structapp structapp;
char *data;
const char *data;
int ret;
int expected_rows;
@ -675,7 +675,7 @@ static void test_options(const testCtx *const p_ctx) {
symbol->structapp = data[i].structapp;
}
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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < ZINT_ERROR) {
@ -712,7 +712,7 @@ static void test_options(const testCtx *const p_ctx) {
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d symbol->errtxt %s != %s\n", i, symbol->errtxt, data[i].expected_errtxt);
symbol->input_mode |= FAST_MODE;
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 FAST_MODE ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < ZINT_ERROR) {
@ -734,12 +734,12 @@ static void test_reader_init(const testCtx *const p_ctx) {
int symbology;
int input_mode;
int output_options;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
char *expected;
char *comment;
const char *expected;
const char *comment;
};
static const struct item data[] = {
/* 0*/ { BARCODE_DATAMATRIX, UNICODE_MODE, READER_INIT, "A", 0, 10, 10, "EA 42 81 19 A4 53 21 DF", "" },
@ -769,7 +769,7 @@ static void test_reader_init(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1 /*option_2*/, -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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -827,15 +827,15 @@ static void test_input(const testCtx *const p_ctx) {
int option_2;
int option_3;
int output_options;
char *data;
const char *data;
int ret;
int expected_eci;
int expected_rows;
int expected_width;
int bwipp_cmp;
char *expected;
char *comment;
const char *expected;
const char *comment;
int expected_diff; /* Difference between default minimal encodation and ISO encodation (FAST_MODE) */
};
@ -1110,7 +1110,7 @@ static void test_input(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_DATAMATRIX, data[i].input_mode, data[i].eci, -1 /*option_1*/, data[i].option_2, 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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -1224,16 +1224,16 @@ static void test_encode(const testCtx *const p_ctx) {
int output_options;
int option_2;
int option_3;
char *data;
const char *data;
int length;
int ret;
int expected_rows;
int expected_width;
int bwipp_cmp;
char *comment;
const char *comment;
int expected_diff; /* Difference between default minimal encodation and ISO encodation (FAST_MODE) */
char *expected;
const char *expected;
};
/* Verified manually against ISO/IEC 16022:2006, ISO/IEC 21471:2020, GS1 General Specifications 21.0.1 (GGS), ANSI/HIBC LIC 2.6-2016 (HIBC/LIC),
ANSI/HIBC PAS 1.3-2010 (HIBC/PAS) and AIM ITS/04-023:2022 (ECI Part 3: Register), with noted exceptions
@ -5680,7 +5680,7 @@ static void test_encode(const testCtx *const p_ctx) {
-1 /*option_1*/, data[i].option_2, data[i].option_3, data[i].output_options,
data[i].data, data[i].length, debug);
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 ret %d != %d\n", i, ret, data[i].ret);
if (p_ctx->generate) {
@ -5791,8 +5791,8 @@ static void test_encode_segs(const testCtx *const p_ctx) {
int expected_rows;
int expected_width;
int bwipp_cmp;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
static const struct item data[] = {
/* 0*/ { BARCODE_DATAMATRIX, UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, { { TU(""), -1, 0 }, { TU("Ж"), -1, 7 }, { TU(""), 0, 0 } }, 0, 14, 14, 1, "ISO 16022:2006 11.6 example",
@ -6212,12 +6212,12 @@ static void test_minimalenc(const testCtx *const p_ctx) {
int input_mode;
int output_options;
int option_2;
char *data;
const char *data;
int length;
int ret;
int expected_diff; /* Difference between default minimal encodation and ISO encodation (FAST_MODE) */
char *comment;
const char *comment;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -7316,12 +7316,12 @@ static void test_perf(const testCtx *const p_ctx) {
int input_mode;
int option_2;
int option_3;
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_DATAMATRIX, FAST_MODE, -1, -1,
@ -7428,7 +7428,7 @@ static void test_perf(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, data[i].option_3, -1 /*output_options*/, data[i].data, -1, debug);
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);

View file

@ -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
@ -39,7 +39,7 @@ static void test_large(const testCtx *const p_ctx) {
char datum;
int length;
int ret;
char *expected_errtxt;
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -69,7 +69,7 @@ static void test_large(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_DOTCODE, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data_buf, data[i].length, debug);
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
ret = ZBarcode_Encode(symbol, TCU(data_buf), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
@ -89,7 +89,7 @@ static void test_options(const testCtx *const p_ctx) {
int option_2;
int option_3;
struct zint_structapp structapp;
char *data;
const char *data;
int ret;
int expected_rows;
@ -137,7 +137,7 @@ static void test_options(const testCtx *const p_ctx) {
symbol->structapp = data[i].structapp;
}
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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < ZINT_ERROR) {
@ -161,12 +161,12 @@ static void test_input(const testCtx *const p_ctx) {
int option_2;
int option_3;
struct zint_structapp structapp;
char *data;
const char *data;
int length;
int ret;
char *expected;
const char *expected;
int bwipp_cmp;
char *comment;
const char *comment;
};
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, 13, -1, { 0, 0, "" }, "A", -1, 0, "66 21 6A", 1, "" },
@ -241,7 +241,7 @@ static void test_input(const testCtx *const p_ctx) {
symbol->structapp = data[i].structapp;
}
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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -296,7 +296,7 @@ static void test_encode(const testCtx *const p_ctx) {
int option_2;
int option_3;
struct zint_structapp structapp;
char *data;
const char *data;
int length;
int ret;
@ -304,8 +304,8 @@ static void test_encode(const testCtx *const p_ctx) {
int expected_width;
int bwipp_cmp;
int zxingcpp_cmp;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
/* ISS DotCode, Rev 4.0, DRAFT 0.15, TSC Pre-PR #5, MAY 28, 2019 */
static const struct item data[] = {
@ -1104,7 +1104,7 @@ static void test_encode(const testCtx *const p_ctx) {
symbol->structapp = data[i].structapp;
}
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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -1177,8 +1177,8 @@ static void test_encode_segs(const testCtx *const p_ctx) {
int expected_width;
int bwipp_cmp;
int zxingcpp_cmp;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
/* ISS DotCode, Rev 4.0, DRAFT 0.15, TSC Pre-PR #5, MAY 28, 2019 */
static const struct item data[] = {
@ -1564,7 +1564,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
struct item {
int input_mode;
char *data;
const char *data;
int length;
int ret;
};
@ -1608,7 +1608,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_DOTCODE, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
ZBarcode_Delete(symbol);
@ -1687,12 +1687,12 @@ static void test_perf(const testCtx *const p_ctx) {
int input_mode;
int option_1;
int option_2;
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_DOTCODE, -1, -1, -1,
@ -1727,7 +1727,7 @@ static void test_perf(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, -1, -1 /*output_options*/, data[i].data, -1, debug);
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);

View file

@ -37,13 +37,13 @@ static void test_encode(const testCtx *const p_ctx) {
struct item {
int symbology;
int option_2;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
static const struct item data[] = {
/* 0*/ { BARCODE_DXFILMEDGE, -1, "79-7", 0, 2, 23, "DX code 1: 79, DX code 2: 7. DX Extract = 1271. DX Full: X1271X (X is any digit)",
@ -167,7 +167,7 @@ static void test_encode(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -212,11 +212,11 @@ static void test_input(const testCtx *const p_ctx) {
struct item {
int symbology;
int input_mode;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -260,7 +260,7 @@ static void test_input(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1 /*option_2*/, -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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);

View file

@ -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
@ -79,7 +79,7 @@ static void test_bom(const testCtx *const p_ctx) {
length = (int) strlen(data);
ret = ZBarcode_Encode(symbol, (unsigned char *) data, length);
ret = ZBarcode_Encode(symbol, TCU(data), length);
assert_equal(ret, ZINT_WARN_USES_ECI, "ZBarcode_Encode ret %d != ZINT_WARN_USES_ECI\n", ret);
assert_equal(symbol->eci, 21, "eci %d != 21\n", symbol->eci); /* ECI 21 == Windows-1250 */
@ -109,7 +109,7 @@ static void test_iso_8859_16(const testCtx *const p_ctx) {
length = (int) strlen(data);
ret = ZBarcode_Encode(symbol, (unsigned char *) data, length);
ret = ZBarcode_Encode(symbol, TCU(data), length);
assert_equal(ret, ZINT_WARN_USES_ECI, "ZBarcode_Encode ret %d != ZINT_WARN_USES_ECI\n", ret);
assert_equal(symbol->eci, 18, "eci %d != 18\n", symbol->eci); /* ECI 18 == ISO 8859-16 */
@ -126,10 +126,10 @@ static void test_reduced_charset_input(const testCtx *const p_ctx) {
int symbology;
int input_mode;
int eci;
char *data;
const char *data;
int ret;
int expected_eci;
char *comment;
const char *comment;
};
/*
é U+00E9 in ISO 8859-1 plus other ISO 8859 (but not in ISO 8859-7 or ISO 8859-11), Win 1250 plus other Win, not in Shift JIS
@ -396,7 +396,7 @@ static void test_reduced_charset_input(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, data[i].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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (data[i].expected_eci != -1) {
@ -724,7 +724,7 @@ static void test_utf8_to_eci_ascii(const testCtx *const p_ctx) {
struct item {
int eci;
char *data;
const char *data;
int length;
int ret;
};
@ -783,11 +783,11 @@ static void test_utf8_to_eci_ascii(const testCtx *const p_ctx) {
static void test_utf8_to_eci_utf16be(const testCtx *const p_ctx) {
struct item {
char *data;
const char *data;
int length;
int ret;
int expected_length;
char *expected;
const char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
@ -848,11 +848,11 @@ static void test_utf8_to_eci_utf16be(const testCtx *const p_ctx) {
static void test_utf8_to_eci_utf16le(const testCtx *const p_ctx) {
struct item {
char *data;
const char *data;
int length;
int ret;
int expected_length;
char *expected;
const char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
@ -913,11 +913,11 @@ static void test_utf8_to_eci_utf16le(const testCtx *const p_ctx) {
static void test_utf8_to_eci_utf32be(const testCtx *const p_ctx) {
struct item {
char *data;
const char *data;
int length;
int ret;
int expected_length;
char *expected;
const char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
@ -977,11 +977,11 @@ static void test_utf8_to_eci_utf32be(const testCtx *const p_ctx) {
static void test_utf8_to_eci_utf32le(const testCtx *const p_ctx) {
struct item {
char *data;
const char *data;
int length;
int ret;
int expected_length;
char *expected;
const char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
@ -1041,7 +1041,7 @@ static void test_utf8_to_eci_utf32le(const testCtx *const p_ctx) {
static void test_utf8_to_eci_sjis(const testCtx *const p_ctx) {
struct item {
char *data;
const char *data;
int length;
int ret;
int expected_length;
@ -1097,7 +1097,7 @@ static void test_utf8_to_eci_sjis(const testCtx *const p_ctx) {
static void test_utf8_to_eci_big5(const testCtx *const p_ctx) {
struct item {
char *data;
const char *data;
int length;
int ret;
int expected_length;
@ -1143,7 +1143,7 @@ static void test_utf8_to_eci_big5(const testCtx *const p_ctx) {
static void test_utf8_to_eci_gb2312(const testCtx *const p_ctx) {
struct item {
char *data;
const char *data;
int length;
int ret;
int expected_length;
@ -1189,7 +1189,7 @@ static void test_utf8_to_eci_gb2312(const testCtx *const p_ctx) {
static void test_utf8_to_eci_euc_kr(const testCtx *const p_ctx) {
struct item {
char *data;
const char *data;
int length;
int ret;
int expected_length;
@ -1235,7 +1235,7 @@ static void test_utf8_to_eci_euc_kr(const testCtx *const p_ctx) {
static void test_utf8_to_eci_gbk(const testCtx *const p_ctx) {
struct item {
char *data;
const char *data;
int length;
int ret;
int expected_length;
@ -1281,7 +1281,7 @@ static void test_utf8_to_eci_gbk(const testCtx *const p_ctx) {
static void test_utf8_to_eci_gb18030(const testCtx *const p_ctx) {
struct item {
char *data;
const char *data;
int length;
int ret;
int expected_length;

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020-2024 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-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,12 +46,12 @@ static void test_print(const testCtx *const p_ctx) {
int option_2;
float scale;
float dpmm;
char *fgcolour;
char *bgcolour;
const char *fgcolour;
const char *bgcolour;
int rotate_angle;
char *data;
char *expected_file;
char *comment;
const char *data;
const char *expected_file;
const char *comment;
};
static const struct item data[] = {
/* 0*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, 0.0f, 0, "", "", 0, "Égjpqy", "code128_egrave_bold.emf", "" },
@ -154,7 +154,7 @@ static void test_print(const testCtx *const p_ctx) {
strcpy(symbol->bgcolour, data[i].bgcolour);
}
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_zero(ret, "i:%d %s ZBarcode_Encode ret %d != 0 %s\n", i, testUtilBarcodeName(data[i].symbology), ret, symbol->errtxt);
strcpy(symbol->outfile, emf);

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2023-2024 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2023-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
@ -45,12 +45,12 @@ static void test_svg(const testCtx *const p_ctx) {
struct item {
int symbology;
int output_options;
char *outfile;
char *data;
const char *outfile;
const char *data;
int length;
int ret;
char *expected;
const char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
@ -85,7 +85,7 @@ static void test_svg(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, data[i].length, debug);
strcpy(symbol->outfile, data[i].outfile);
ret = ZBarcode_Encode_and_Print(symbol, TU(data[i].data), length, 0);
ret = ZBarcode_Encode_and_Print(symbol, TCU(data[i].data), length, 0);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode_and_Print(%d) ret %d != %d (%s)\n",
i, data[i].symbology, ret, data[i].ret, symbol->errtxt);
@ -445,7 +445,7 @@ static void test_large(const testCtx *const p_ctx) {
symbol->option_2 = 84;
symbol->scale = 10.0f; /* Could go up to 86.5 (pixel buffer 0x3FB913B1, file size 8868579) but very very slow */
ret = ZBarcode_Encode_and_Print(symbol, TU(data), -1, 0);
ret = ZBarcode_Encode_and_Print(symbol, TCU(data), -1, 0);
assert_zero(ret, "ZBarcode_Encode_and_Print ret %d != 0 (%s)\n", ret, symbol->errtxt);
assert_nonnull(symbol->memfile, "memfile NULL (%s)\n", symbol->errtxt);
assert_equal(symbol->memfile_size, expected_size, "memfile_size %d != expected %d\n",

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2019-2023 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
@ -246,12 +246,12 @@ static void test_u_gb18030_int(const testCtx *const p_ctx) {
static void test_gb18030_utf8(const testCtx *const p_ctx) {
struct item {
char *data;
const char *data;
int length;
int ret;
int ret_length;
unsigned int expected_gbdata[30];
char *comment;
const char *comment;
};
/*
é U+00E9 in ISO 8859-1 plus other ISO 8859 (but not in ISO 8859-7 or ISO 8859-11), Win 1250 plus other Win, in GB 18030 0xA8A6, UTF-8 C3A9
@ -313,12 +313,12 @@ static void test_gb18030_utf8_to_eci(const testCtx *const p_ctx) {
struct item {
int eci;
int full_multibyte;
char *data;
const char *data;
int length;
int ret;
int ret_length;
unsigned int expected_gbdata[30];
char *comment;
const char *comment;
};
/*
é U+00E9 in ISO 8859-1 0xE9, Win 1250 plus other Win, in HANXIN Chinese mode first byte range 0x81..FE
@ -432,12 +432,12 @@ static void test_gb18030_cpy(const testCtx *const p_ctx) {
struct item {
int full_multibyte;
char *data;
const char *data;
int length;
int ret;
int ret_length;
unsigned int expected_gbdata[30];
char *comment;
const char *comment;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
@ -536,10 +536,10 @@ static void test_perf(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
char *data;
const char *data;
int ret;
char *comment;
const char *comment;
};
struct item data[] = {
/* 0*/ { "1234567890", 0, "10 numerics" },

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2019-2023 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
@ -153,12 +153,12 @@ static void test_u_gb2312_int(const testCtx *const p_ctx) {
static void test_gb2312_utf8(const testCtx *const p_ctx) {
struct item {
char *data;
const char *data;
int length;
int ret;
int ret_length;
unsigned int expected_gbdata[20];
char *comment;
const char *comment;
};
/*
é U+00E9 in ISO 8859-1 plus other ISO 8859 (but not in ISO 8859-7 or ISO 8859-11), Win 1250 plus other Win, in GB 2312 0xA8A6, UTF-8 C3A9
@ -219,12 +219,12 @@ static void test_gb2312_utf8_to_eci(const testCtx *const p_ctx) {
struct item {
int eci;
int full_multibyte;
char *data;
const char *data;
int length;
int ret;
int ret_length;
unsigned int expected_gbdata[20];
char *comment;
const char *comment;
};
/*
é U+00E9 in ISO 8859-1 0xE9, Win 1250 plus other Win, in GRIDMATRIX Chinese mode first byte range 0xA1..A9, 0xB0..F7
@ -323,12 +323,12 @@ static void test_gb2312_cpy(const testCtx *const p_ctx) {
struct item {
int full_multibyte;
char *data;
const char *data;
int length;
int ret;
int ret_length;
unsigned int expected_gbdata[20];
char *comment;
const char *comment;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
@ -377,10 +377,10 @@ static void test_perf(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
char *data;
const char *data;
int ret;
char *comment;
const char *comment;
};
struct item data[] = {
/* 0*/ { "1234567890", 0, "10 numerics" },

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020-2024 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-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
@ -40,7 +40,7 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
int symbology;
int width;
int height;
char *pattern;
const char *pattern;
int repeat;
int ret;
};
@ -62,7 +62,7 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
int i, ret;
struct zint_symbol *symbol = NULL;
char *gif = "out.gif";
const char *gif = "out.gif";
char data_buf[19 * 32 + 1]; /* 19 * 32 == 608 */
@ -137,11 +137,11 @@ static void test_print(const testCtx *const p_ctx) {
float scale;
float dot_size;
struct zint_structapp structapp;
char *fgcolour;
char *bgcolour;
char *data;
char *expected_file;
char *comment;
const char *fgcolour;
const char *bgcolour;
const char *data;
const char *expected_file;
const char *comment;
};
static const struct item data[] = {
/* 0*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, 0, 0, 0, { 0, 0, "" }, "", "", "12", "dotcode_1.0.gif", "" },
@ -243,7 +243,7 @@ static void test_print(const testCtx *const p_ctx) {
strcpy(symbol->bgcolour, data[i].bgcolour);
}
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_zero(ret, "i:%d %s ZBarcode_Encode ret %d != 0 %s\n", i, testUtilBarcodeName(data[i].symbology), ret, symbol->errtxt);
strcpy(symbol->outfile, gif);

View file

@ -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
@ -37,12 +37,12 @@ static void test_large(const testCtx *const p_ctx) {
struct item {
int option_2;
int option_3;
char *pattern;
const char *pattern;
int length;
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -109,7 +109,7 @@ static void test_large(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_GRIDMATRIX, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, data[i].option_3, -1 /*output_options*/, data_buf, data[i].length, debug);
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
ret = ZBarcode_Encode(symbol, TCU(data_buf), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
@ -132,7 +132,7 @@ static void test_options(const testCtx *const p_ctx) {
int option_1;
int option_2;
struct zint_structapp structapp;
char *data;
const char *data;
int ret_encode;
int ret_vector;
int expected_size;
@ -182,7 +182,7 @@ static void test_options(const testCtx *const p_ctx) {
symbol->structapp = data[i].structapp;
}
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_encode, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret_encode, symbol->errtxt);
if (ret < ZINT_ERROR) {
assert_equal(symbol->width, data[i].expected_size, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_size);
@ -210,11 +210,11 @@ static void test_input(const testCtx *const p_ctx) {
int output_options;
int option_3;
struct zint_structapp structapp;
char *data;
const char *data;
int ret;
int expected_eci;
char *expected;
char *comment;
const char *expected;
const char *comment;
};
/*
é U+00E9 in ISO 8859-1 plus other ISO 8859 (but not in ISO 8859-7 or ISO 8859-11), Win 1250 plus other Win, in GB 2312 0xA8A6, UTF-8 C3A9
@ -363,7 +363,7 @@ static void test_input(const testCtx *const p_ctx) {
symbol->structapp = data[i].structapp;
}
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 ret %d != %d\n", i, ret, data[i].ret);
if (p_ctx->generate) {
@ -390,7 +390,7 @@ static void test_encode(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
char *data;
const char *data;
int input_mode;
int option_1;
int option_2;
@ -398,8 +398,8 @@ static void test_encode(const testCtx *const p_ctx) {
int expected_rows;
int expected_width;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
static const struct item data[] = {
/* 0*/ { "1234", UNICODE_MODE, -1, -1, 0, 18, 18, "",
@ -514,7 +514,7 @@ static void test_encode(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_GRIDMATRIX, data[i].input_mode, -1 /*eci*/, data[i].option_1, data[i].option_2, -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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -553,8 +553,8 @@ static void test_encode_segs(const testCtx *const p_ctx) {
int expected_rows;
int expected_width;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
/*
not in GB 2312 (in ISO/IEC 8869-1)
@ -903,12 +903,12 @@ static void test_perf(const testCtx *const p_ctx) {
int input_mode;
int option_1;
int option_2;
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_GRIDMATRIX, UNICODE_MODE, -1, -1,
@ -951,7 +951,7 @@ static void test_perf(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, -1, -1 /*output_options*/, data[i].data, -1, debug);
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);

View file

@ -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
@ -40,12 +40,12 @@ static void test_gs1_reduce(const testCtx *const p_ctx) {
struct item {
int symbology;
int input_mode;
char *data;
char *composite;
const char *data;
const char *composite;
int ret;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
static const struct item data[] = {
/* 0*/ { BARCODE_GS1_128, -1, "12345678901234", "", ZINT_ERROR_INVALID_DATA, "GS1 data required", "" },
@ -194,7 +194,7 @@ static void test_gs1_reduce(const testCtx *const p_ctx) {
int i, length, ret;
struct zint_symbol *symbol = NULL;
char *text;
const char *text;
char bwipp_buf[8196];
char bwipp_msg[1024];
@ -218,7 +218,7 @@ static void test_gs1_reduce(const testCtx *const p_ctx) {
}
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, text, -1, debug);
ret = ZBarcode_Encode(symbol, (unsigned char *) text, length);
ret = ZBarcode_Encode(symbol, TCU(text), length);
if (p_ctx->generate) {
if (data[i].ret == 0) {
@ -265,11 +265,11 @@ static void test_hrt(const testCtx *const p_ctx) {
struct item {
int symbology;
int input_mode;
char *data;
char *composite;
const char *data;
const char *composite;
int ret;
char *expected;
const char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -332,7 +332,7 @@ static void test_hrt(const testCtx *const p_ctx) {
int i, length, ret;
struct zint_symbol *symbol = NULL;
char *text;
const char *text;
testStartSymbol("test_hrt", &symbol);
@ -351,7 +351,7 @@ static void test_hrt(const testCtx *const p_ctx) {
}
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, -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 ret %d != %d (%s)\n", i, data[i].ret, ret, symbol->errtxt);
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
@ -367,10 +367,10 @@ static void test_hrt(const testCtx *const p_ctx) {
static void test_gs1_verify(const testCtx *const p_ctx) {
struct item {
char *data;
const char *data;
int ret;
char *expected;
char *expected_errtxt;
const char *expected;
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -1448,10 +1448,10 @@ static void test_gs1_verify(const testCtx *const p_ctx) {
static void test_gs1_lint(const testCtx *const p_ctx) {
struct item {
char *data;
const char *data;
int ret;
char *expected;
char *expected_errtxt;
const char *expected;
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -2144,7 +2144,7 @@ static void test_input_mode(const testCtx *const p_ctx) {
struct item {
int symbology;
char *data;
const char *data;
int input_mode;
int output_options;
int ret;
@ -2289,7 +2289,7 @@ static void test_input_mode(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->index == -1 && data[i].compare_previous) {
ret = testUtilSymbolCmp(symbol, &previous_symbol);
@ -2312,10 +2312,10 @@ static void test_gs1nocheck_mode(const testCtx *const p_ctx) {
struct item {
int symbology;
int input_mode;
char *data;
char *composite;
const char *data;
const char *composite;
int ret;
char *expected_errtxt;
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -2506,7 +2506,7 @@ static void test_gs1nocheck_mode(const testCtx *const p_ctx) {
int i, length, ret;
struct zint_symbol *symbol = NULL;
char *text;
const char *text;
testStartSymbol("test_gs1nocheck_mode", &symbol);
@ -2525,7 +2525,7 @@ static void test_gs1nocheck_mode(const testCtx *const p_ctx) {
}
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, -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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);

View file

@ -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
@ -38,12 +38,12 @@ static void test_large(const testCtx *const p_ctx) {
int option_1;
int option_2;
int option_3;
char *pattern;
const char *pattern;
int length;
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -96,7 +96,7 @@ static void test_large(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_HANXIN, -1 /*input_mode*/, -1 /*eci*/, data[i].option_1, data[i].option_2, data[i].option_3, -1 /*output_options*/, data_buf, data[i].length, debug);
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
ret = ZBarcode_Encode(symbol, TCU(data_buf), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
@ -129,7 +129,7 @@ static void test_options(const testCtx *const p_ctx) {
struct item {
int option_1;
int option_2;
char *data;
const char *data;
int ret_encode;
int ret_vector;
int expected_size;
@ -170,7 +170,7 @@ static void test_options(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_HANXIN, -1 /*input_mode*/, -1 /*eci*/, data[i].option_1, data[i].option_2, -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_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret_encode, symbol->errtxt);
if (data[i].ret_vector != -1) {
@ -206,13 +206,13 @@ static void test_input(const testCtx *const p_ctx) {
int input_mode;
int eci;
int option_3;
char *data;
const char *data;
int length;
int ret;
int expected_eci;
char *expected;
const char *expected;
int zxingcpp_cmp;
char *comment;
const char *comment;
};
/*
é U+00E9 in ISO 8859-1 plus other ISO 8859 (but not in ISO 8859-7 or ISO 8859-11), Win 1250 plus other Win, in GB 18030 0xA8A6, UTF-8 C3A9
@ -338,7 +338,7 @@ static void test_input(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_HANXIN, data[i].input_mode, data[i].eci, -1 /*option_1*/, -1, data[i].option_3, -1 /*output_options*/, data[i].data, data[i].length, debug);
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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -387,14 +387,14 @@ static void test_encode(const testCtx *const p_ctx) {
int option_1;
int option_2;
int option_3;
char *data;
const char *data;
int length;
int ret;
int expected_rows;
int expected_width;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, -1, -1, -1, "1234", -1, 0, 23, 23, "Mode nnnn, mask 10",
@ -3187,7 +3187,7 @@ static void test_encode(const testCtx *const p_ctx) {
data[i].option_1, data[i].option_2, data[i].option_3, -1 /*output_options*/,
data[i].data, data[i].length, debug);
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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -3240,8 +3240,8 @@ static void test_encode_segs(const testCtx *const p_ctx) {
int expected_rows;
int expected_width;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, -1, -1, { { TU(""), -1, 0 }, { TU("Ж"), -1, 7 }, { TU(""), 0, 0 } }, 0, 23, 23, "Standard example",
@ -3542,11 +3542,11 @@ static void test_fuzz(const testCtx *const p_ctx) {
int option_1;
int option_2;
int option_3;
char *data;
const char *data;
int length;
int ret;
int bwipp_cmp;
char *comment;
const char *comment;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -3567,7 +3567,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, data[i].eci, data[i].option_1, data[i].option_2, data[i].option_3, -1 /*output_options*/, data[i].data, data[i].length, debug);
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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
ZBarcode_Delete(symbol);
@ -3589,12 +3589,12 @@ static void test_perf(const testCtx *const p_ctx) {
int input_mode;
int option_1;
int option_2;
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_HANXIN, UNICODE_MODE, -1, -1,
@ -3653,7 +3653,7 @@ static void test_perf(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, -1, -1 /*output_options*/, data[i].data, -1, debug);
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);

View file

@ -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
@ -133,7 +133,7 @@ static void test_csv(const testCtx *const p_ctx) {
if (test_performance) {
start = clock();
}
ret = ZBarcode_Encode(symbol, (unsigned char *) data, (int) strlen(data));
ret = ZBarcode_Encode(symbol, TCU(data), (int) strlen(data));
if (test_performance) {
total += clock() - start;
}
@ -167,8 +167,8 @@ static void test_hrt(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
char *data;
char *expected;
const char *data;
const char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -189,7 +189,7 @@ static void test_hrt(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_USPS_IMAIL, -1 /*input_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 ret %d != 0 %s\n", i, ret, symbol->errtxt);
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
@ -204,11 +204,11 @@ static void test_input(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -246,7 +246,7 @@ static void test_input(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_USPS_IMAIL, -1 /*input_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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
@ -276,13 +276,13 @@ static void test_encode(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
static const struct item data[] = {
/* 0*/ { "01234567094987654321-01234567891", 0, 3, 129, "USPS-B-3200 Rev. H (2015) Figure 5",
@ -312,7 +312,7 @@ static void test_encode(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_USPS_IMAIL, -1 /*input_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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {

View file

@ -816,7 +816,7 @@ static void test_dump(const testCtx *const p_ctx) {
struct item {
large_uint t;
char *expected;
const char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {

View file

@ -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
@ -41,7 +41,7 @@ static void test_checks(const testCtx *const p_ctx) {
struct item {
int symbology;
int option_1;
char *data;
const char *data;
int length;
int input_mode;
int eci;
@ -56,7 +56,7 @@ static void test_checks(const testCtx *const p_ctx) {
int warn_level;
int ret;
char *expected;
const char *expected;
int expected_symbology;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
@ -258,7 +258,7 @@ static void test_checks(const testCtx *const p_ctx) {
symbol->warn_level = data[i].warn_level;
}
ret = ZBarcode_Encode(symbol, TU(data[i].data), length);
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode(%d) ret %d != %d (%s)\n", i, data[i].symbology, ret, data[i].ret, symbol->errtxt);
ret = strcmp(symbol->errtxt, data[i].expected);
@ -289,7 +289,7 @@ static void test_checks_segs(const testCtx *const p_ctx) {
int warn_level;
int ret;
char *expected;
const char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -345,12 +345,12 @@ static void test_input_data(const testCtx *const p_ctx) {
struct item {
int symbology;
int input_mode;
char *data;
const char *data;
int length;
char *composite;
const char *composite;
int ret;
char *expected;
const char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -366,7 +366,7 @@ static void test_input_data(const testCtx *const p_ctx) {
int i, length, ret;
struct zint_symbol *symbol = NULL;
char *text;
const char *text;
testStartSymbol("test_input_data", &symbol);
@ -385,7 +385,7 @@ static void test_input_data(const testCtx *const p_ctx) {
}
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, -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(%d) ret %d != %d (%s)\n", i, data[i].symbology, ret, data[i].ret, symbol->errtxt);
ret = strcmp(symbol->errtxt, data[i].expected);
@ -397,7 +397,7 @@ static void test_input_data(const testCtx *const p_ctx) {
if (p_ctx->index == -1 && p_ctx->exclude[0] == -1) {
char data_buf[ZINT_MAX_DATA_LEN + 10];
int expected_ret = ZINT_ERROR_TOO_LONG;
char *expected_errtxt[] = { "Error 797: Input too long", "Error 340: Input length 17399 too long (maximum 256)" };
const char *expected_errtxt[] = { "Error 797: Input too long", "Error 340: Input length 17399 too long (maximum 256)" };
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
@ -527,7 +527,7 @@ static void test_symbologies(const testCtx *const p_ctx) {
if (testContinue(p_ctx, i)) continue;
symbol->symbology = i;
ret = ZBarcode_Encode(symbol, TU(""), 0);
ret = ZBarcode_Encode(symbol, TCU(""), 0);
assert_notequal(ret, ZINT_ERROR_ENCODING_PROBLEM, "i:%d Encoding problem (%s)\n", i, symbol->errtxt);
if (!ZBarcode_ValidID(i)) {
@ -551,12 +551,12 @@ static void test_input_mode(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
char *data;
const char *data;
int input_mode;
int ret;
int expected_input_mode;
char *expected_errtxt;
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -587,7 +587,7 @@ static void test_input_mode(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_CODE49 /*Supports GS1*/, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
ret = ZBarcode_Encode(symbol, TU(data[i].data), length);
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->input_mode, data[i].expected_input_mode, "i:%d symbol->input_mode %d != %d\n", i, symbol->input_mode, data[i].expected_input_mode);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d ZBarcode_Encode strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
@ -605,13 +605,13 @@ static void test_escape_char_process(const testCtx *const p_ctx) {
int symbology;
int input_mode;
int eci;
char *data;
char *composite;
const char *data;
const char *composite;
int ret;
int expected_width;
char *expected;
const char *expected;
int compare_previous;
char *comment;
const char *comment;
};
static const struct item data[] = {
/* 0*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\e\\G\\R\\x81\\\\", "", 0, 26, "01 05 08 09 0A 0B 0C 0D 0E 1C 1E 1F EB 02 5D 81 21 0D 92 2E 3D FD B6 9A 37 2A CD 61 FB 95", 0, "" },
@ -707,9 +707,9 @@ static void test_escape_char_process(const testCtx *const p_ctx) {
char escaped[1024];
char escaped_composite[1024];
struct zint_symbol previous_symbol;
char *input_filename = "test_escape.txt";
const char *input_filename = "test_escape.txt";
char *text;
const char *text;
testStartSymbol("test_escape_char_process", &symbol);
@ -731,7 +731,7 @@ static void test_escape_char_process(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode | ESCAPE_MODE, data[i].eci, -1 /*option_1*/, -1, -1, -1 /*output_options*/, text, -1, debug);
ret = ZBarcode_Encode(symbol, TU(text), length);
ret = ZBarcode_Encode(symbol, TCU(text), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -796,9 +796,9 @@ static void test_escape_char_process_test(const testCtx *const p_ctx) {
struct item {
int symbology;
int input_mode;
char *data;
const char *data;
int ret;
char *expected;
const char *expected;
int expected_len;
};
static const struct item data[] = {
@ -1126,9 +1126,9 @@ static void test_encode_file_directory(const testCtx *const p_ctx) {
static void test_encode_file(const testCtx *const p_ctx) {
int ret;
struct zint_symbol *symbol = NULL;
char *data = "1";
char *filename = "test_encode_file_in.txt";
char *outfile = "test_encode_file_out.gif";
const char *data = "1";
const char *filename = "test_encode_file_in.txt";
const char *outfile = "test_encode_file_out.gif";
FILE *fp;
(void)p_ctx;
@ -1206,7 +1206,7 @@ static void test_encode_print_outfile_directory(const testCtx *const p_ctx) {
assert_zero(ret, "testUtilMkDir(%s) %d != 0 (%d: %s)\n", dirname, ret, errno, strerror(errno));
strcpy(symbol->outfile, dirname);
ret = ZBarcode_Encode_and_Print(symbol, TU("1"), 0, 0);
ret = ZBarcode_Encode_and_Print(symbol, TCU("1"), 0, 0);
assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "ret %d != ZINT_ERROR_FILE_ACCESS (%s)\n", ret, symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, expected), "strcmp(%s, %s) != 0\n", symbol->errtxt, expected);
@ -1222,9 +1222,9 @@ static void test_bad_args(const testCtx *const p_ctx) {
int ret;
unsigned int uret;
struct zint_symbol *symbol = NULL;
char *data = "1";
char *filename = "1.png";
char *empty = "";
const char *data = "1";
const char *filename = "1.png";
const char *empty = "";
struct zint_seg seg = { TU("1"), -1, 4 };
struct zint_seg seg_empty = { TU(""), -1, 4 };
struct zint_seg seg_too_long = { TU("1"), ZINT_MAX_DATA_LEN + 1, 4 };
@ -1260,16 +1260,16 @@ static void test_bad_args(const testCtx *const p_ctx) {
assert_zero(uret, "ZBarcode_Cap(10, ~0) uret 0x%X != 0\n", uret);
/* NULL symbol */
assert_equal(ZBarcode_Encode(NULL, TU(data), 1), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode(NULL, data, 1) != ZINT_ERROR_INVALID_DATA\n");
assert_equal(ZBarcode_Encode(NULL, TCU(data), 1), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode(NULL, data, 1) != ZINT_ERROR_INVALID_DATA\n");
assert_equal(ZBarcode_Encode_Segs(NULL, &seg, 1), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_Segs(NULL, &seg, 1) != ZINT_ERROR_INVALID_DATA\n");
assert_equal(ZBarcode_Print(NULL, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Print(NULL, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_equal(ZBarcode_Buffer(NULL, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Buffer(NULL, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_equal(ZBarcode_Buffer_Vector(NULL, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Buffer_Vector(NULL, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_equal(ZBarcode_Encode_and_Print(NULL, TU(data), 1, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_and_Print(NULL, data, 1, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_equal(ZBarcode_Encode_and_Print(NULL, TCU(data), 1, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_and_Print(NULL, data, 1, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_equal(ZBarcode_Encode_Segs_and_Print(NULL, &seg, 1, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_Seg_and_Print(NULL, &seg, 1, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_equal(ZBarcode_Encode_and_Buffer(NULL, TU(data), 1, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_and_Buffer(NULL, data, 1, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_equal(ZBarcode_Encode_and_Buffer(NULL, TCU(data), 1, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_and_Buffer(NULL, data, 1, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_equal(ZBarcode_Encode_Segs_and_Buffer(NULL, &seg, 1, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_Segs_and_Buffer(NULL, &seg, 1, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_equal(ZBarcode_Encode_and_Buffer_Vector(NULL, TU(data), 1, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_and_Buffer_Vector(NULL, data, 1, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_equal(ZBarcode_Encode_and_Buffer_Vector(NULL, TCU(data), 1, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_and_Buffer_Vector(NULL, data, 1, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_equal(ZBarcode_Encode_Segs_and_Buffer_Vector(NULL, &seg, 1, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_Segs_and_Buffer_Vector(NULL, &seg, 1, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_equal(ZBarcode_Encode_File(NULL, filename), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_File(NULL, filename) != ZINT_ERROR_INVALID_DATA\n");
assert_equal(ZBarcode_Encode_File_and_Print(NULL, filename, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_File_and_Print(NULL, filename, 0) != ZINT_ERROR_INVALID_DATA\n");
@ -1315,23 +1315,23 @@ static void test_bad_args(const testCtx *const p_ctx) {
/* Empty data/segs/filename */
symbol->errtxt[0] = '\0';
assert_equal(ZBarcode_Encode(symbol, TU(empty), 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode(symbol, empty, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_zero(strcmp(expected[3], symbol->errtxt), "ZBarcode_Encode(symbol, TU(empty), 0) strcmp(%s, %s) != 0\n", expected[3], symbol->errtxt);
assert_equal(ZBarcode_Encode(symbol, TCU(empty), 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode(symbol, empty, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_zero(strcmp(expected[3], symbol->errtxt), "ZBarcode_Encode(symbol, TCU(empty), 0) strcmp(%s, %s) != 0\n", expected[3], symbol->errtxt);
symbol->errtxt[0] = '\0';
assert_equal(ZBarcode_Encode_Segs(symbol, &seg_empty, 1), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_Segs(symbol, &seg_empty, 1) != ZINT_ERROR_INVALID_DATA\n");
assert_zero(strcmp(expected[3], symbol->errtxt), "ZBarcode_Encode_Segs(symbol, &seg_empty, 1) strcmp(%s, %s) != 0\n", expected[3], symbol->errtxt);
symbol->errtxt[0] = '\0';
assert_equal(ZBarcode_Encode_and_Print(symbol, TU(empty), 0, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_and_Print(symbol, empty, 0, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_zero(strcmp(expected[3], symbol->errtxt), "ZBarcode_Encode_and_Print(symbol, TU(empty), 0, 0) strcmp(%s, %s) != 0\n", expected[3], symbol->errtxt);
assert_equal(ZBarcode_Encode_and_Print(symbol, TCU(empty), 0, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_and_Print(symbol, empty, 0, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_zero(strcmp(expected[3], symbol->errtxt), "ZBarcode_Encode_and_Print(symbol, TCU(empty), 0, 0) strcmp(%s, %s) != 0\n", expected[3], symbol->errtxt);
symbol->errtxt[0] = '\0';
assert_equal(ZBarcode_Encode_and_Buffer(symbol, TU(empty), 0, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_and_Buffer(symbol, empty, 0, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_zero(strcmp(expected[3], symbol->errtxt), "ZBarcode_Encode_and_Buffer(symbol, TU(empty), 0, 0) strcmp(%s, %s) != 0\n", expected[3], symbol->errtxt);
assert_equal(ZBarcode_Encode_and_Buffer(symbol, TCU(empty), 0, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_and_Buffer(symbol, empty, 0, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_zero(strcmp(expected[3], symbol->errtxt), "ZBarcode_Encode_and_Buffer(symbol, TCU(empty), 0, 0) strcmp(%s, %s) != 0\n", expected[3], symbol->errtxt);
symbol->errtxt[0] = '\0';
assert_equal(ZBarcode_Encode_Segs_and_Buffer(symbol, &seg_empty, 1, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_Segs_and_Buffer(symbol, &seg_empty, 1, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_zero(strcmp(expected[3], symbol->errtxt), "ZBarcode_Encode_Segs_and_Buffer(symbol, &seg_empty, 1, 0) strcmp(%s, %s) != 0\n", expected[3], symbol->errtxt);
symbol->errtxt[0] = '\0';
assert_equal(ZBarcode_Encode_and_Buffer_Vector(symbol, TU(empty), 0, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_and_Buffer_Vector(symbol, empty, 0, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_zero(strcmp(expected[3], symbol->errtxt), "ZBarcode_Encode_and_Buffer_Vector(symbol, TU(empty), 0, 0) strcmp(%s, %s) != 0\n", expected[3], symbol->errtxt);
assert_equal(ZBarcode_Encode_and_Buffer_Vector(symbol, TCU(empty), 0, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_and_Buffer_Vector(symbol, empty, 0, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_zero(strcmp(expected[3], symbol->errtxt), "ZBarcode_Encode_and_Buffer_Vector(symbol, TCU(empty), 0, 0) strcmp(%s, %s) != 0\n", expected[3], symbol->errtxt);
symbol->errtxt[0] = '\0';
assert_equal(ZBarcode_Encode_Segs_and_Buffer_Vector(symbol, &seg_empty, 1, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_Segs_and_Buffer_Vector(symbol, &seg_empty, 1, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_zero(strcmp(expected[3], symbol->errtxt), "ZBarcode_Encode_Segs_and_Buffer_Vector(symbol, &seg_empty, 1, 0) strcmp(%s, %s) != 0\n", expected[3], symbol->errtxt);
@ -1361,8 +1361,8 @@ static void test_bad_args(const testCtx *const p_ctx) {
/* Data/seg too big */
symbol->errtxt[0] = '\0';
assert_equal(ZBarcode_Encode(symbol, TU(empty), ZINT_MAX_DATA_LEN + 1), ZINT_ERROR_TOO_LONG, "ZBarcode_Encode(symbol, empty, ZINT_MAX_DATA_LEN + 1) != ZINT_ERROR_TOO_LONG\n");
assert_zero(strcmp(expected[7], symbol->errtxt), "ZBarcode_Encode(symbol, TU(empty), ZINT_MAX_DATA_LEN + 1) strcmp(%s, %s) != 0\n", expected[7], symbol->errtxt);
assert_equal(ZBarcode_Encode(symbol, TCU(empty), ZINT_MAX_DATA_LEN + 1), ZINT_ERROR_TOO_LONG, "ZBarcode_Encode(symbol, empty, ZINT_MAX_DATA_LEN + 1) != ZINT_ERROR_TOO_LONG\n");
assert_zero(strcmp(expected[7], symbol->errtxt), "ZBarcode_Encode(symbol, TCU(empty), ZINT_MAX_DATA_LEN + 1) strcmp(%s, %s) != 0\n", expected[7], symbol->errtxt);
symbol->errtxt[0] = '\0';
assert_equal(ZBarcode_Encode_Segs(symbol, &seg_too_long, 1), ZINT_ERROR_TOO_LONG, "ZBarcode_Encode_Segs(symbol, &seg_too_long, 1) != ZINT_ERROR_TOO_LONG\n");
assert_zero(strcmp(expected[7], symbol->errtxt), "ZBarcode_Encode_Segs(symbol, &seg_too_long, 1) strcmp(%s, %s) != 0\n", expected[7], symbol->errtxt);
@ -1611,9 +1611,9 @@ static void test_error_tag(const testCtx *const p_ctx) {
int debug_test;
int error_number;
int warn_level;
char *data;
const char *data;
int ret;
char *expected;
const char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
@ -1702,7 +1702,7 @@ static void test_zero_outfile(const testCtx *const p_ctx) {
int ret;
struct zint_symbol *symbol = NULL;
char *data = "1234";
const char *data = "1234";
(void)p_ctx;
@ -1714,7 +1714,7 @@ static void test_zero_outfile(const testCtx *const p_ctx) {
assert_nonzero(symbol->outfile[0], "ZBarcode_Create() outfile zero\n");
symbol->outfile[0] = '\0';
ret = ZBarcode_Encode(symbol, TU(data), 0);
ret = ZBarcode_Encode(symbol, TCU(data), 0);
assert_zero(ret, "ZBarcode_Encode(%s) ret %d != 0 (%s)\n", data, ret, symbol->errtxt);
assert_zero(symbol->outfile[0], "ZBarcode_Encode() outfile non-zero\n");
@ -1735,7 +1735,7 @@ static void test_clear(const testCtx *const p_ctx) {
int ret;
struct zint_symbol *symbol = NULL;
char *data = "1234";
const char *data = "1234";
(void)p_ctx;
@ -1754,7 +1754,7 @@ static void test_clear(const testCtx *const p_ctx) {
/* Raster */
ret = ZBarcode_Encode(symbol, TU(data), 0);
ret = ZBarcode_Encode(symbol, TCU(data), 0);
assert_zero(ret, "ZBarcode_Encode() ret %d != 0 (%s)\n", ret, symbol->errtxt);
assert_nonzero(symbol->rows, "ZBarcode_Encode() rows 0\n");
@ -1785,7 +1785,7 @@ static void test_clear(const testCtx *const p_ctx) {
/* Vector */
ret = ZBarcode_Encode(symbol, TU(data), 0);
ret = ZBarcode_Encode(symbol, TCU(data), 0);
assert_zero(ret, "ZBarcode_Encode() ret %d != 0 (%s)\n", ret, symbol->errtxt);
assert_nonzero(symbol->rows, "ZBarcode_Encode() rows 0\n");
@ -1855,7 +1855,7 @@ static void test_reset(const testCtx *const p_ctx) {
int ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol_def;
char *data = "1234";
const char *data = "1234";
(void)p_ctx;
@ -1871,7 +1871,7 @@ static void test_reset(const testCtx *const p_ctx) {
/* Raster */
ret = ZBarcode_Encode(symbol, TU(data), 0);
ret = ZBarcode_Encode(symbol, TCU(data), 0);
assert_zero(ret, "ZBarcode_Encode() ret %d != 0 (%s)\n", ret, symbol->errtxt);
assert_nonzero(symbol->rows, "ZBarcode_Encode() rows 0\n");
@ -1922,7 +1922,7 @@ static void test_reset(const testCtx *const p_ctx) {
set_symbol_fields(symbol);
ret = ZBarcode_Encode(symbol, TU(data), 0);
ret = ZBarcode_Encode(symbol, TCU(data), 0);
assert_zero(ret, "ZBarcode_Encode() ret %d != 0 (%s)\n", ret, symbol->errtxt);
assert_nonzero(symbol->rows, "ZBarcode_Encode() rows 0\n");
@ -1984,7 +1984,7 @@ static void test_scale_from_xdimdp(const testCtx *const p_ctx) {
float x_dim;
float dpmm;
int dpi;
char *filetype;
const char *filetype;
float expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
@ -2116,7 +2116,7 @@ static void test_xdimdp_from_scale(const testCtx *const p_ctx) {
float scale;
float dpmm; /* Note testing "normal" case that want X-dim, not dpmm */
int dpi;
char *filetype;
const char *filetype;
float expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */

View file

@ -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
@ -35,7 +35,7 @@ static void test_4s_input(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
@ -115,7 +115,7 @@ static void test_4s_input(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_MAILMARK_4S, -1 /*input_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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < ZINT_ERROR) {
@ -138,12 +138,12 @@ static void test_4s_encode_vector(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
char *data;
const char *data;
int ret_encode;
float w;
float h;
int ret_vector;
char *expected_daft;
const char *expected_daft;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -185,7 +185,7 @@ static void test_4s_encode_vector(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_MAILMARK_4S, -1 /*input_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_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret_encode, symbol->errtxt);
assert_equal(symbol->rows, 3, "i:%d symbol->rows %d != 3\n", i, symbol->rows);
@ -207,13 +207,13 @@ static void test_4s_encode(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
static const struct item data[] = {
/* 0*/ { "1100000000000XY11 ", 0, 3, 131, "Verified manually against TEC-IT",
@ -239,7 +239,7 @@ static void test_4s_encode(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_MAILMARK_4S, -1 /*input_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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -271,11 +271,11 @@ static void test_2d_input(const testCtx *const p_ctx) {
struct item {
int option_2;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -329,7 +329,7 @@ static void test_2d_input(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_MAILMARK_2D, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < ZINT_ERROR) {
@ -349,14 +349,14 @@ static void test_2d_encode(const testCtx *const p_ctx) {
struct item {
int option_2;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
int bwipp_cmp;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
/* Mailmark Mailing Requirements for Letters and Large Letters 14th Nov 2019 (MMRLLL)
https://www.royalmailtechnical.com/rmt_docs/User_Guides_2020/Mailmark_Letters_and_Large_Letters_20200723.pdf */
@ -550,7 +550,7 @@ static void test_2d_encode(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_MAILMARK_2D, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {

View file

@ -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
@ -37,14 +37,14 @@ static void test_large(const testCtx *const p_ctx) {
struct item {
int option_1;
int option_2;
char *pattern;
const char *pattern;
int length;
char *primary;
const char *primary;
int ret;
int expected_rows;
int expected_width;
int bwipp_cmp;
char *comment;
const char *comment;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -112,7 +112,7 @@ static void test_large(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_MAXICODE, -1 /*input_mode*/, -1 /*eci*/, data[i].option_1, data[i].option_2, -1, -1 /*output_options*/, data_buf, data[i].length, debug);
strcpy(symbol->primary, data[i].primary);
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
ret = ZBarcode_Encode(symbol, TCU(data_buf), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
@ -166,15 +166,15 @@ static void test_input(const testCtx *const p_ctx) {
int option_1;
int option_2;
struct zint_structapp structapp;
char *data;
const char *data;
int length;
char *primary;
const char *primary;
int ret;
int expected_width;
char *expected;
const char *expected;
int bwipp_cmp;
int zxingcpp_cmp;
char *comment;
const char *comment;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -278,7 +278,7 @@ static void test_input(const testCtx *const p_ctx) {
}
strcpy(symbol->primary, data[i].primary);
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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -340,16 +340,16 @@ static void test_encode(const testCtx *const p_ctx) {
int option_1;
int option_2;
struct zint_structapp structapp;
char *data;
const char *data;
int length;
char *primary;
const char *primary;
int ret;
int expected_rows;
int expected_width;
int bwipp_cmp;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
static const struct item data[] = {
/* 0*/ { -1, -1, -1, { 0, 0, "" }, "THIS IS A 93 CHARACTER CODE SET A MESSAGE THAT FILLS A MODE 4, UNAPPENDED, MAXICODE SYMBOL...", -1, "", 0, 33, 30, 1, "ISO/IEC 16023:2000 Figure 2 (and L1), same",
@ -1184,7 +1184,7 @@ static void test_encode(const testCtx *const p_ctx) {
}
strcpy(symbol->primary, data[i].primary);
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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -1246,14 +1246,14 @@ static void test_encode_segs(const testCtx *const p_ctx) {
int option_2;
struct zint_structapp structapp;
struct zint_seg segs[3];
char *primary;
const char *primary;
int ret;
int expected_rows;
int expected_width;
int bwipp_cmp;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, -1, { 0, 0, "" }, { { TU(""), -1, 0 }, { TU("Ж"), -1, 7 }, { TU(""), 0, 0 } }, "", 0, 33, 30, 1, "ISO 16023:2000 4.15.4 example",
@ -1850,7 +1850,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
struct item {
int eci;
char *data;
const char *data;
int length;
int ret;
};
@ -1878,7 +1878,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_MAXICODE, -1 /*input_mode*/, data[i].eci, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
ZBarcode_Delete(symbol);
@ -1902,13 +1902,13 @@ static void test_perf(const testCtx *const p_ctx) {
int input_mode;
int option_1;
int option_2;
char *data;
char *primary;
const char *data;
const char *primary;
int ret;
int expected_rows;
int expected_width;
char *comment;
const char *comment;
};
static const struct item data[] = {
/* 0*/ { BARCODE_MAXICODE, UNICODE_MODE | ESCAPE_MODE, -1, -1,
@ -1959,7 +1959,7 @@ static void test_perf(const testCtx *const p_ctx) {
strcpy(symbol->primary, data[i].primary);
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);

View file

@ -37,12 +37,12 @@ static void test_large(const testCtx *const p_ctx) {
struct item {
int symbology;
int option_2;
char *pattern;
const char *pattern;
int length;
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -77,7 +77,7 @@ static void test_large(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data_buf, data[i].length, debug);
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
ret = ZBarcode_Encode(symbol, TCU(data_buf), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
@ -99,9 +99,9 @@ static void test_hrt(const testCtx *const p_ctx) {
struct item {
int symbology;
int option_2;
char *data;
const char *data;
char *expected;
const char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -133,7 +133,7 @@ static void test_hrt(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -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 ret %d != 0 %s\n", i, ret, symbol->errtxt);
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
@ -150,7 +150,7 @@ static void test_input(const testCtx *const p_ctx) {
struct item {
int symbology;
int option_2;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
@ -208,7 +208,7 @@ static void test_input(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d symbol->errtxt %s != %s\n", i, symbol->errtxt, data[i].expected_errtxt);
@ -244,13 +244,13 @@ static void test_encode(const testCtx *const p_ctx) {
struct item {
int symbology;
int option_2;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
static const struct item data[] = {
/* 0*/ { BARCODE_PHARMA, -1, "131070", 0, 1, 78, "",
@ -302,7 +302,7 @@ static void test_encode(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2021-2024 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2021-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
@ -38,10 +38,10 @@
static void test_check_colour_options(const testCtx *const p_ctx) {
struct item {
char *fgcolour;
char *bgcolour;
const char *fgcolour;
const char *bgcolour;
int ret;
char *expected;
const char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -90,13 +90,13 @@ static void test_check_colour_options(const testCtx *const p_ctx) {
static void test_colour_get_rgb(const testCtx *const p_ctx) {
struct item {
char *colour;
const char *colour;
int ret;
unsigned char red;
unsigned char green;
unsigned char blue;
unsigned char alpha;
char *expected_cmyk;
const char *expected_cmyk;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -154,14 +154,14 @@ static void test_colour_get_rgb(const testCtx *const p_ctx) {
static void test_colour_get_cmyk(const testCtx *const p_ctx) {
struct item {
char *colour;
const char *colour;
int ret;
int cyan;
int magenta;
int yellow;
int black;
unsigned char alpha;
char *expected_rgb;
const char *expected_rgb;
int ret_rgb;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
@ -323,9 +323,9 @@ static void test_set_whitespace_offsets(const testCtx *const p_ctx) {
static void test_fopen(const testCtx *const p_ctx) {
struct item {
char dir[32];
char subdir[32];
char *filename;
const char dir[32];
const char subdir[32];
const char *filename;
int succeed;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020-2024 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-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
@ -42,11 +42,11 @@ static void test_print(const testCtx *const p_ctx) {
int whitespace_height;
int option_1;
int option_2;
char *fgcolour;
char *bgcolour;
const char *fgcolour;
const char *bgcolour;
float scale;
char *data;
char *expected_file;
const char *data;
const char *expected_file;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -61,7 +61,7 @@ static void test_print(const testCtx *const p_ctx) {
struct zint_symbol *symbol;
const char *data_dir = "/backend/tests/data/pcx";
char *pcx = "out.pcx";
const char *pcx = "out.pcx";
char expected_file[4096];
char escaped[1024];
int escaped_size = 1024;
@ -109,7 +109,7 @@ static void test_print(const testCtx *const p_ctx) {
}
symbol->debug |= 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 %s ZBarcode_Encode ret %d != 0 %s\n", i, testUtilBarcodeName(data[i].symbology), ret, symbol->errtxt);
strcpy(symbol->outfile, pcx);

View file

@ -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
@ -39,12 +39,12 @@ static void test_large(const testCtx *const p_ctx) {
int option_1;
int option_2;
int option_3;
char *pattern;
const char *pattern;
int length;
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -85,7 +85,7 @@ static void test_large(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, data[i].option_1, data[i].option_2, data[i].option_3, -1 /*output_options*/, data_buf, data[i].length, debug);
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
ret = ZBarcode_Encode(symbol, TCU(data_buf), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < ZINT_ERROR) {
@ -98,7 +98,7 @@ static void test_large(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, FAST_MODE, -1 /*eci*/, data[i].option_1, data[i].option_2, data[i].option_3, -1 /*output_options*/, data_buf, data[i].length, debug);
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
ret = ZBarcode_Encode(symbol, TCU(data_buf), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < ZINT_ERROR) {
@ -123,7 +123,7 @@ static void test_options(const testCtx *const p_ctx) {
int option_3;
int warn_level;
struct zint_structapp structapp;
char *data;
const char *data;
int ret_encode;
int ret_vector;
@ -209,7 +209,7 @@ static void test_options(const testCtx *const p_ctx) {
symbol->structapp = data[i].structapp;
}
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_encode, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret_encode, symbol->errtxt);
if (data[i].option_3 != -1) {
@ -246,12 +246,12 @@ static void test_reader_init(const testCtx *const p_ctx) {
int symbology;
int input_mode;
int output_options;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
char *expected;
char *comment;
const char *expected;
const char *comment;
};
static const struct item data[] = {
/* 0*/ { BARCODE_PDF417, UNICODE_MODE, READER_INIT, "A", 0, 6, 103, "(12) 4 921 29 900 209 917 46 891 522 472 822 385", "Outputs Test Alpha flag 900" },
@ -280,7 +280,7 @@ static void test_reader_init(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1 /*option_2*/, -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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -326,14 +326,14 @@ static void test_input(const testCtx *const p_ctx) {
int option_1;
int option_2;
struct zint_structapp structapp;
char *data;
const char *data;
int ret;
int expected_eci;
int expected_rows;
int expected_width;
char *expected;
const char *expected;
int bwipp_cmp;
char *comment;
const char *comment;
};
/* é U+00E9 (\351, 233), UTF-8 C3A9 */
/* β U+03B2 in ISO 8859-7 Greek (but not other ISO 8859 or Win page) (\342, 226), UTF-8 CEB2 */
@ -451,7 +451,7 @@ static void test_input(const testCtx *const p_ctx) {
symbol->structapp = data[i].structapp;
}
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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -527,14 +527,14 @@ static void test_encode(const testCtx *const p_ctx) {
int option_1;
int option_2;
int option_3;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
int bwipp_cmp;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
static const struct item data[] = {
/* 0*/ { BARCODE_PDF417, -1, UNICODE_MODE | FAST_MODE, 1, 2, -1, "PDF417 Symbology Standard", 0, 10, 103, 0, "ISO 15438:2015 Figure 1, same, BWIPP uses different encodation, same codeword count",
@ -3949,7 +3949,7 @@ static void test_encode(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, data[i].eci, data[i].option_1, data[i].option_2, data[i].option_3, -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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -4035,8 +4035,8 @@ static void test_encode_segs(const testCtx *const p_ctx) {
int expected_rows;
int expected_width;
int bwipp_cmp;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
static const struct item data[] = {
/* 0*/ { BARCODE_PDF417, UNICODE_MODE | FAST_MODE, -1, -1, -1, { 0, 0, "" }, { { TU(""), -1, 0 }, { TU("Ж"), -1, 7 }, { TU(""), 0, 0 } }, 0, 8, 103, 1, "Standard example",
@ -4786,11 +4786,11 @@ static void test_fuzz(const testCtx *const p_ctx) {
int input_mode;
int option_1;
int option_2;
char *data;
const char *data;
int length;
int ret;
int bwipp_cmp;
char *comment;
const char *comment;
};
static const struct item data[] = {
/* 0*/ { BARCODE_PDF417, DATA_MODE | FAST_MODE, -1, -1,
@ -5591,7 +5591,7 @@ static void test_fuzz(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, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < ZINT_ERROR) {
@ -5808,12 +5808,12 @@ static void test_perf(const testCtx *const p_ctx) {
int input_mode;
int option_1;
int option_2;
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, "1234567890", 0, 7, 103, "10 numerics" },
@ -5892,7 +5892,7 @@ static void test_perf(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, input_mode, -1 /*eci*/, data[i].option_1, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug);
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);
@ -5952,7 +5952,7 @@ static void test_perf(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, -1, -1 /*output_options*/, data[i].data, -1, debug);
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);

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020-2024 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-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
@ -37,12 +37,12 @@ static void test_large(const testCtx *const p_ctx) {
struct item {
int symbology;
int option_2;
char *pattern;
const char *pattern;
int length;
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -87,7 +87,7 @@ static void test_large(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data_buf, data[i].length, debug);
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
ret = ZBarcode_Encode(symbol, TCU(data_buf), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
@ -109,9 +109,9 @@ static void test_hrt(const testCtx *const p_ctx) {
struct item {
int symbology;
int option_2;
char *data;
const char *data;
char *expected;
const char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -160,7 +160,7 @@ static void test_hrt(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -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 ret %d != 0 %s\n", i, ret, symbol->errtxt);
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
@ -177,11 +177,11 @@ static void test_input(const testCtx *const p_ctx) {
struct item {
int symbology;
int option_2;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -207,7 +207,7 @@ static void test_input(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
@ -229,13 +229,13 @@ static void test_encode(const testCtx *const p_ctx) {
struct item {
int symbology;
int option_2;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
static const struct item data[] = {
/* 0*/ { BARCODE_MSI_PLESSEY, -1, "1234567890", 0, 1, 127, "Verified manually against tec-it",
@ -293,7 +293,7 @@ static void test_encode(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -342,12 +342,12 @@ static void test_perf(const testCtx *const p_ctx) {
struct item {
int symbology;
int option_2;
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_PLESSEY, -1, "1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1", 0, 1, 1107, "PLESSEY 65" },
@ -388,7 +388,7 @@ static void test_perf(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, DATA_MODE, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug);
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);

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020-2024 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-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
@ -42,7 +42,7 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
struct item {
int width;
int height;
char *pattern;
const char *pattern;
int repeat;
int ret;
};
@ -60,7 +60,7 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
int i, ret;
struct zint_symbol *symbol = NULL;
char *png = "out.png";
const char *png = "out.png";
char data_buf[8 * 2 + 1];
@ -135,14 +135,14 @@ static void test_print(const testCtx *const p_ctx) {
float height;
float scale;
struct zint_structapp structapp;
char *fgcolour;
char *bgcolour;
const char *fgcolour;
const char *bgcolour;
float text_gap;
char *data;
char *composite;
const char *data;
const char *composite;
int ret;
char *expected_file;
char *comment;
const char *expected_file;
const char *comment;
};
static const struct item data[] = {
/* 0*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, -1, -1, -1, -1, -1, 10.0, 0, { 0, 0, "" }, "", "", 1, "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~", "", 0, "code128_latin1_1.png", "" },
@ -249,7 +249,7 @@ static void test_print(const testCtx *const p_ctx) {
int escaped_size = 1024;
unsigned char filebuf[32768];
int filebuf_size;
char *text;
const char *text;
const char *const have_identify = testUtilHaveIdentify();
@ -310,7 +310,7 @@ static void test_print(const testCtx *const p_ctx) {
}
text_length = (int) strlen(text);
ret = ZBarcode_Encode(symbol, (unsigned char *) text, text_length);
ret = ZBarcode_Encode(symbol, TCU(text), text_length);
assert_equal(ret, data[i].ret, "i:%d %s ZBarcode_Encode ret %d != %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), ret, data[i].ret, symbol->errtxt);
strcpy(symbol->outfile, png);

View file

@ -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
@ -40,12 +40,12 @@ static void test_large(const testCtx *const p_ctx) {
struct item {
int symbology;
char *pattern;
const char *pattern;
int length;
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -98,7 +98,7 @@ static void test_large(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data_buf, data[i].length, debug);
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
ret = ZBarcode_Encode(symbol, TCU(data_buf), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
@ -117,7 +117,7 @@ static void test_koreapost(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
char *data;
const char *data;
int ret_encode;
int ret_vector;
@ -143,7 +143,7 @@ static void test_koreapost(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_KOREAPOST, -1 /*input_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_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret_encode);
if (ret < ZINT_ERROR) {
@ -165,14 +165,14 @@ static void test_japanpost(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
char *data;
const char *data;
int ret_encode;
int ret_vector;
float expected_height;
int expected_rows;
int expected_width;
char *comment;
const char *comment;
};
static const struct item data[] = {
/* 0*/ { "123", 0, 0, 8, 3, 133, "Check 3" },
@ -196,7 +196,7 @@ static void test_japanpost(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_JAPANPOST, -1 /*input_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_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret_encode);
if (ret < ZINT_ERROR) {
@ -221,14 +221,14 @@ static void test_input(const testCtx *const p_ctx) {
int symbology;
int option_2;
float height;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
float expected_height;
char *expected_errtxt;
const char *expected_errtxt;
int bwipp_cmp;
char *comment;
const char *comment;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -303,7 +303,7 @@ static void test_input(const testCtx *const p_ctx) {
symbol->height = data[i].height;
}
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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
@ -339,13 +339,13 @@ static void test_encode(const testCtx *const p_ctx) {
struct item {
int symbology;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
static const struct item data[] = {
/* 0*/ { BARCODE_FLAT, "1304056", 0, 1, 63, "Verified manually against tec-it",
@ -498,7 +498,7 @@ static void test_encode(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -547,12 +547,12 @@ static void test_perf(const testCtx *const p_ctx) {
struct item {
int symbology;
int option_2;
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_POSTNET, -1, "12345678901", 0, 2, 123, "POSTNET 11" },
@ -592,7 +592,7 @@ static void test_perf(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, DATA_MODE, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug);
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);

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020-2024 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-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
@ -45,8 +45,8 @@ static void test_print(const testCtx *const p_ctx) {
int option_1;
int option_2;
float scale;
char *data;
char *expected_file;
const char *data;
const char *expected_file;
};
struct item data[] = {
/* 0*/ { BARCODE_CODE128, -1, -1, -1, "AIM", "code128_aim" },
@ -60,7 +60,7 @@ static void test_print(const testCtx *const p_ctx) {
struct zint_symbol *symbol = NULL;
int j;
char *exts[] = { "bmp", "emf", "eps", "gif", "pcx", "png", "svg", "tif", "txt" };
const char *exts[] = { "bmp", "emf", "eps", "gif", "pcx", "png", "svg", "tif", "txt" };
int exts_size = ARRAY_SIZE(exts);
char data_dir[1024];
@ -134,7 +134,7 @@ static void test_print(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 %s ZBarcode_Encode ret %d != 0 %s\n", i, testUtilBarcodeName(data[i].symbology), ret, symbol->errtxt);
strcpy(symbol->outfile, "out.");

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020-2024 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-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,11 +46,11 @@ static void test_print(const testCtx *const p_ctx) {
int option_2;
float scale;
float dot_size;
char *fgcolour;
char *bgcolour;
const char *fgcolour;
const char *bgcolour;
int rotate_angle;
char *data;
char *expected_file;
const char *data;
const char *expected_file;
};
static const struct item data[] = {
/* 0*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, 0, 0, "", "", 0, "Égjpqy", "code128_egrave_bold.eps" },
@ -167,7 +167,7 @@ static void test_print(const testCtx *const p_ctx) {
strcpy(symbol->bgcolour, data[i].bgcolour);
}
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_zero(ret, "i:%d %s ZBarcode_Encode ret %d != 0 %s\n", i, testUtilBarcodeName(data[i].symbology), ret, symbol->errtxt);
strcpy(symbol->outfile, eps);
@ -226,8 +226,8 @@ INTERNAL void ps_convert_test(const unsigned char *string, unsigned char *ps_str
static void test_ps_convert(const testCtx *const p_ctx) {
struct item {
char *data;
char *expected;
const char *data;
const char *expected;
};
static const struct item data[] = {
/* 0*/ { "1\\(é)2€3¿", "1\\\\\\(\351\\)23\277" },

View file

@ -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
@ -38,12 +38,12 @@ static void test_qr_large(const testCtx *const p_ctx) {
int option_1;
int option_2;
int option_3;
char *pattern;
const char *pattern;
int length;
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -93,7 +93,7 @@ static void test_qr_large(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_QRCODE, -1 /*input_mode*/, -1 /*eci*/, data[i].option_1, data[i].option_2, data[i].option_3 | FAST_MODE, -1 /*output_options*/, data_buf, data[i].length, debug);
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
ret = ZBarcode_Encode(symbol, TCU(data_buf), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
@ -104,7 +104,7 @@ static void test_qr_large(const testCtx *const p_ctx) {
}
symbol->input_mode |= FAST_MODE;
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
ret = ZBarcode_Encode(symbol, TCU(data_buf), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
@ -151,12 +151,12 @@ static void test_qr_options(const testCtx *const p_ctx) {
int option_1;
int option_2;
struct zint_structapp structapp;
char *data;
const char *data;
int ret_encode;
int ret_vector;
int expected_size;
int compare_previous;
char *expected;
const char *expected;
};
/* 貫 U+8CAB kanji, in Shift JIS 0x8AD1 (\212\321), UTF-8 E8B2AB */
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
@ -229,7 +229,7 @@ static void test_qr_options(const testCtx *const p_ctx) {
symbol->structapp = data[i].structapp;
}
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_encode, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret_encode, symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
if (p_ctx->index == -1 && data[i].compare_previous != -1) {
@ -259,13 +259,13 @@ static void test_qr_input(const testCtx *const p_ctx) {
int eci;
int option_1;
int option_3;
char *data;
const char *data;
int ret;
int expected_eci;
char *expected;
const char *expected;
int bwipp_cmp;
int zxingcpp_cmp;
char *comment;
const char *comment;
};
/* é U+00E9 in ISO 8859-1 plus other ISO 8859 (but not in ISO 8859-7 or ISO 8859-11), Win 1250 plus other Win, not in Shift JIS, UTF-8 C3A9 */
/* β U+03B2 in ISO 8859-7 Greek (but not other ISO 8859 or Win page), in Shift JIS 0x83C0, UTF-8 CEB2 */
@ -452,7 +452,7 @@ static void test_qr_input(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_QRCODE, data[i].input_mode, data[i].eci, data[i].option_1, -1, data[i].option_3, -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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -514,11 +514,11 @@ static void test_qr_gs1(const testCtx *const p_ctx) {
int input_mode;
int option_1;
int option_3;
char *data;
const char *data;
int ret;
char *expected;
const char *expected;
int bwipp_cmp;
char *comment;
const char *comment;
};
static const struct item data[] = {
/* 0*/ { GS1_MODE, 4, 7 << 8, "[01]12345678901231", 0, "51 04 00 B3 AA 37 DE 87 B1", 1, "N16" },
@ -664,7 +664,7 @@ static void test_qr_gs1(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_QRCODE, data[i].input_mode, -1 /*eci*/, data[i].option_1, -1, data[i].option_3, -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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -720,11 +720,11 @@ static void test_qr_optimize(const testCtx *const p_ctx) {
int input_mode;
int option_1;
int option_3; /* OR-ed with ZINT_FULL_MULTIBYTE */
char *data;
const char *data;
int ret;
char *expected;
const char *expected;
int bwipp_cmp;
char *comment;
const char *comment;
};
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, 4, -1, "1", 0, "10 04 40 EC 11 EC 11 EC 11", 1, "N1" },
@ -782,7 +782,7 @@ static void test_qr_optimize(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_QRCODE, data[i].input_mode, -1 /*eci*/, data[i].option_1, -1, data[i].option_3 | ZINT_FULL_MULTIBYTE, -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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -836,15 +836,15 @@ static void test_qr_encode(const testCtx *const p_ctx) {
int option_2;
int option_3;
struct zint_structapp structapp;
char *data;
const char *data;
int length;
int ret;
int expected_rows;
int expected_width;
int bwipp_cmp;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
/* や U+3084 kanji, in Shift JIS 0x82E2 (\202\342), UTF-8 E38284; its 2nd byte 0xE2 + 0x40-FC also form Shift JIS */
static const struct item data[] = {
@ -4307,7 +4307,7 @@ static void test_qr_encode(const testCtx *const p_ctx) {
symbol->structapp = data[i].structapp;
}
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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -4376,8 +4376,8 @@ static void test_qr_encode_segs(const testCtx *const p_ctx) {
int expected_rows;
int expected_width;
int bwipp_cmp;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
static const struct item data[] = {
/* 0*/ { BARCODE_QRCODE, UNICODE_MODE, 4, -1, 8 << 8, { 0, 0, "" }, { { TU(""), -1, 0 }, { TU("Ж"), -1, 7 }, { TU(""), 0, 0 } }, 0, 21, 21, 1, "Standard example",
@ -4716,12 +4716,12 @@ static void test_qr_perf(const testCtx *const p_ctx) {
int input_mode;
int option_1;
int option_2;
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_QRCODE, UNICODE_MODE, -1, -1, "12345678901234", 0, 21, 21, "14 chars, Numeric mode" },
@ -4803,7 +4803,7 @@ static void test_qr_perf(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, input_mode, -1 /*eci*/, data[i].option_1, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug);
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);
@ -4849,7 +4849,7 @@ static void test_qr_perf(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, -1, -1 /*output_options*/, data[i].data, -1, debug);
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);
@ -4883,11 +4883,11 @@ static void test_microqr_options(const testCtx *const p_ctx) {
struct item {
int option_1;
int option_2;
char *data;
const char *data;
int ret_encode;
int ret_vector;
int expected_size;
char *expected_errtxt;
const int expected_size;
const char *expected_errtxt;
int compare_previous;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
@ -4973,7 +4973,7 @@ static void test_microqr_options(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_MICROQR, -1 /*input_mode*/, -1 /*eci*/, data[i].option_1, data[i].option_2, -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_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret_encode, symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
if (p_ctx->index == -1 && data[i].compare_previous != -1) {
@ -5001,12 +5001,12 @@ static void test_microqr_input(const testCtx *const p_ctx) {
struct item {
int input_mode;
int option_3;
char *data;
const char *data;
int ret;
char *expected;
const char *expected;
int bwipp_cmp;
int zxingcpp_cmp;
char *comment;
const char *comment;
};
/* é U+00E9 in ISO 8859-1 plus other ISO 8859 (but not in ISO 8859-7 or ISO 8859-11), Win 1250 plus other Win, not in Shift JIS, UTF-8 C3A9 */
/* β U+03B2 in ISO 8859-7 Greek (but not other ISO 8859 or Win page), in Shift JIS 0x83C0, UTF-8 CEB2 */
@ -5088,7 +5088,7 @@ static void test_microqr_input(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_MICROQR, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, data[i].option_3, -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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -5145,10 +5145,10 @@ static void test_microqr_padding(const testCtx *const p_ctx) {
struct item {
int option_1;
char *data;
const char *data;
int ret;
char *expected;
char *comment;
const char *expected;
const char *comment;
};
static const struct item data[] = {
/* 0*/ { -1, "1", 0, "22 00 00 (20)", "M1, bits left 13" },
@ -5217,7 +5217,7 @@ static void test_microqr_padding(const testCtx *const p_ctx) {
length = (int) strlen(data[i].data);
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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -5263,12 +5263,12 @@ static void test_microqr_optimize(const testCtx *const p_ctx) {
int option_1;
int option_2;
int option_3;
char *data;
const char *data;
int ret;
char *expected;
const char *expected;
int bwipp_cmp;
int zxingcpp_cmp;
char *comment;
const char *comment;
};
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, -1, -1, "1", 0, "22 00 00 (20)", 1, 1, "N1" },
@ -5309,7 +5309,7 @@ static void test_microqr_optimize(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_MICROQR, data[i].input_mode, -1 /*eci*/, data[i].option_1, data[i].option_2, data[i].option_3, -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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -5366,14 +5366,14 @@ static void test_microqr_encode(const testCtx *const p_ctx) {
int option_1;
int option_2;
int option_3;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
int bwipp_cmp;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, 1, -1, -1, "01234567", 0, 13, 13, 1, "ISO 18004 Figure 2 (and I.2) (mask 01)",
@ -6359,7 +6359,7 @@ static void test_microqr_encode(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_MICROQR, data[i].input_mode, -1 /*eci*/, data[i].option_1, data[i].option_2, data[i].option_3, -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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -6420,12 +6420,12 @@ static void test_microqr_perf(const testCtx *const p_ctx) {
int input_mode;
int option_1;
int option_2;
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_MICROQR, UNICODE_MODE, 1, 1, "12345", 0, 11, 11, "Max 5 numbers, M1" },
@ -6456,7 +6456,7 @@ static void test_microqr_perf(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, -1, -1 /*output_options*/, data[i].data, -1, debug);
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);
@ -6486,10 +6486,10 @@ static void test_upnqr_input(const testCtx *const p_ctx) {
struct item {
int input_mode;
char *data;
const char *data;
int ret;
char *expected;
char *comment;
const char *expected;
const char *comment;
};
/* Ą U+0104 in ISO 8859-2 0xA1, in other ISO 8859 and Win 1250, UTF-8 C484 */
/* Ŕ U+0154 in ISO 8859-2 0xC0, in Win 1250 but not other ISO 8859 or Win page, UTF-8 C594 */
@ -6532,7 +6532,7 @@ static void test_upnqr_input(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_UPNQR, data[i].input_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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < ZINT_ERROR) {
assert_equal(symbol->eci, 4, "i:%d ZBarcode_Encode symbol->eci %d != 4\n", i, symbol->eci);
@ -6574,13 +6574,13 @@ static void test_upnqr_encode(const testCtx *const p_ctx) {
int option_1;
int option_2;
int option_3;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
/* https://www.upn-qr.si/uploads/files/Tehnicni standard UPN QR.pdf */
@ -7084,7 +7084,7 @@ static void test_upnqr_encode(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_UPNQR, data[i].input_mode, -1 /*eci*/, data[i].option_1, data[i].option_2, data[i].option_3, -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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -7146,7 +7146,7 @@ static void test_rmqr_large(const testCtx *const p_ctx) {
struct item {
int option_1;
int option_2;
char *pattern;
const char *pattern;
int length;
int ret;
int expected_rows;
@ -7696,7 +7696,7 @@ static void test_rmqr_large(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_RMQR, -1 /*input_mode*/, -1 /*eci*/, data[i].option_1, data[i].option_2, ZINT_FULL_MULTIBYTE, -1 /*output_options*/, data_buf, data[i].length, debug);
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
ret = ZBarcode_Encode(symbol, TCU(data_buf), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
@ -7713,7 +7713,7 @@ static void test_rmqr_large(const testCtx *const p_ctx) {
}
symbol->input_mode |= FAST_MODE;
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
ret = ZBarcode_Encode(symbol, TCU(data_buf), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < ZINT_ERROR) {
@ -7748,14 +7748,14 @@ static void test_rmqr_options(const testCtx *const p_ctx) {
int eci;
int option_1;
int option_2;
char *data;
const char *data;
int ret_encode;
int ret_vector;
int expected_rows;
int expected_width;
char *expected_errtxt;
const char *expected_errtxt;
int zxingcpp_cmp;
char *comment;
const char *comment;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -7853,7 +7853,7 @@ static void test_rmqr_options(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_RMQR, data[i].input_mode, data[i].eci, data[i].option_1, data[i].option_2, -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_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret_encode, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
@ -7897,13 +7897,13 @@ static void test_rmqr_input(const testCtx *const p_ctx) {
int option_1;
int option_2;
int option_3;
char *data;
const char *data;
int ret;
int expected_eci;
char *expected;
const char *expected;
int bwipp_cmp;
int zxingcpp_cmp;
char *comment;
const char *comment;
};
/* See test_qr_input() for details about test characters */
static const struct item data[] = {
@ -8049,7 +8049,7 @@ static void test_rmqr_input(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_RMQR, data[i].input_mode, data[i].eci, data[i].option_1, data[i].option_2, data[i].option_3, -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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -8109,10 +8109,10 @@ static void test_rmqr_gs1(const testCtx *const p_ctx) {
struct item {
int input_mode;
char *data;
const char *data;
int ret;
char *expected;
char *comment;
const char *expected;
const char *comment;
};
static const struct item data[] = {
/* 0*/ { GS1_MODE, "[01]12345678901231", 0, "A6 00 59 D5 1B EF 43 D8 80 EC 11 EC", "N16" },
@ -8152,7 +8152,7 @@ static void test_rmqr_gs1(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_RMQR, data[i].input_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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -8189,11 +8189,11 @@ static void test_rmqr_optimize(const testCtx *const p_ctx) {
int input_mode;
int option_1;
int option_2;
char *data;
const char *data;
int ret;
char *expected;
const char *expected;
int bwipp_cmp;
char *comment;
const char *comment;
};
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, 4, 11, "1", 0, "22 20 EC 11 EC", 1, "N1" },
@ -8243,7 +8243,7 @@ static void test_rmqr_optimize(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_RMQR, data[i].input_mode, -1 /*eci*/, data[i].option_1, data[i].option_2, ZINT_FULL_MULTIBYTE, -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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -8296,14 +8296,14 @@ static void test_rmqr_encode(const testCtx *const p_ctx) {
int option_1;
int option_2;
int option_3;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
int bwipp_cmp;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
/* ISO/IEC 23941:2022 */
static const struct item data[] = {
@ -8709,7 +8709,7 @@ static void test_rmqr_encode(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_RMQR, data[i].input_mode, data[i].eci, data[i].option_1, data[i].option_2, data[i].option_3, -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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -8775,8 +8775,8 @@ static void test_rmqr_encode_segs(const testCtx *const p_ctx) {
int expected_rows;
int expected_width;
int bwipp_cmp;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, 2, 11, -1, { { TU(""), -1, 0 }, { TU("Ж"), -1, 7 }, { TU(""), 0, 0 } }, 0, 11, 27, 1, "Standard example",
@ -8973,11 +8973,11 @@ static void test_fuzz(const testCtx *const p_ctx) {
int option_1;
int option_2;
int option_3;
char *data;
const char *data;
int length;
int ret;
int bwipp_cmp;
char *comment;
const char *comment;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -9000,7 +9000,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, data[i].eci, data[i].option_1, data[i].option_2, data[i].option_3, -1 /*output_options*/, data[i].data, data[i].length, debug);
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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
ZBarcode_Delete(symbol);

View file

@ -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);

View file

@ -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
@ -36,13 +36,13 @@ static void test_binary_div_modulo_divisor(const testCtx *const p_ctx) {
struct item {
int symbology;
char *data;
const char *data;
float w;
float h;
int expected_rows;
int expected_width;
char *expected;
const char *expected;
};
static const struct item data[] = {
/* 0*/ { BARCODE_DBAR_OMN, "1234567890123", 100, 30, 1, 96, "010111010010000001001110000000010100001011111010110100011001100101111111110001011011000111000101" },
@ -121,7 +121,7 @@ static void test_binary_div_modulo_divisor(const testCtx *const p_ctx) {
int i, length, ret;
struct zint_symbol *symbol = NULL;
char *text;
const char *text;
char escaped[1024];
char cmp_buf[1024];
@ -147,7 +147,7 @@ static void test_binary_div_modulo_divisor(const testCtx *const p_ctx) {
}
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, text, -1, debug);
ret = ZBarcode_Encode(symbol, (const unsigned char *) text, length);
ret = ZBarcode_Encode(symbol, TCU(text), length);
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 (%s)\n", i, ret, symbol->errtxt);
if (p_ctx->generate) {
@ -202,14 +202,14 @@ static void test_examples(const testCtx *const p_ctx) {
int input_mode;
int option_2;
int option_3;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
int bwipp_cmp;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
/* Verified manually against GS1 General Specifications 21.0.1 (GGS) and ISO/IEC 24724:2011, and verified via bwipp_dump.ps against BWIPP */
static const struct item data[] = {
@ -883,7 +883,7 @@ static void test_examples(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, data[i].option_3, -1 /*output_options*/, data[i].data, -1, debug);
ret = ZBarcode_Encode(symbol, (const 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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -939,12 +939,12 @@ static void test_general_field(const testCtx *const p_ctx) {
struct item {
int symbology;
char *data;
const char *data;
int expected_rows;
int expected_width;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
/* Verified via bwipp_dump.ps against BWIPP and manually against tec-it.com (some separators differ from tec-it.com where noted) */
static const struct item data[] = {
@ -1210,7 +1210,7 @@ static void test_general_field(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].data, length);
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 (%s)\n", i, ret, symbol->errtxt);
if (p_ctx->generate) {
@ -1239,13 +1239,13 @@ static void test_binary_buffer_size(const testCtx *const p_ctx) {
struct item {
int input_mode;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
char *comment;
const char *expected_errtxt;
const char *comment;
};
static const struct item data[] = {
/* 0*/ { -1, "[91]1", 0, 1, 102, "", "Minimum digit" },
@ -1276,7 +1276,7 @@ static void test_binary_buffer_size(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_DBAR_EXP, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
ret = ZBarcode_Encode(symbol, (const 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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
@ -1302,10 +1302,10 @@ static void test_hrt(const testCtx *const p_ctx) {
struct item {
int symbology;
int input_mode;
char *data;
const char *data;
int ret;
char *expected;
const char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -1334,7 +1334,7 @@ static void test_hrt(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
ret = ZBarcode_Encode(symbol, (const 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 ret %d != %d (%s)\n", i, data[i].ret, ret, symbol->errtxt);
assert_zero(strcmp((const char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
@ -1353,11 +1353,11 @@ static void test_input(const testCtx *const p_ctx) {
int input_mode;
int option_2;
int option_3;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -1488,7 +1488,7 @@ static void test_input(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, data[i].option_3, -1 /*output_options*/, data[i].data, -1, debug);
ret = ZBarcode_Encode(symbol, (const 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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2019-2023 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
@ -176,12 +176,12 @@ static void test_u_sjis_int(const testCtx *const p_ctx) {
static void test_sjis_utf8(const testCtx *const p_ctx) {
struct item {
char *data;
const char *data;
int length;
int ret;
int ret_length;
unsigned int expected_jisdata[20];
char *comment;
const char *comment;
};
/*
é U+00E9 in ISO 8859-1 plus other ISO 8859 (but not in ISO 8859-7 or ISO 8859-11), Win 1250 plus other Win, not in Shift JIS, UTF-8 C3A9
@ -241,12 +241,12 @@ static void test_sjis_utf8_to_eci(const testCtx *const p_ctx) {
struct item {
int eci;
int full_multibyte;
char *data;
const char *data;
int length;
int ret;
int ret_length;
unsigned int expected_jisdata[20];
char *comment;
const char *comment;
};
/*
é U+00E9 in ISO 8859-1 0xE9, Win 1250 plus other Win, in QR Kanji mode first byte range 0x81..9F, 0xE0..EB
@ -332,12 +332,12 @@ static void test_sjis_cpy(const testCtx *const p_ctx) {
struct item {
int full_multibyte;
char *data;
const char *data;
int length;
int ret;
int ret_length;
unsigned int expected_jisdata[20];
char *comment;
const char *comment;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
@ -385,10 +385,10 @@ static void test_perf(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
char *data;
const char *data;
int ret;
char *comment;
const char *comment;
};
struct item data[] = {
/* 0*/ { "1234567890", 0, "10 numerics" },

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020-2024 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-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
@ -47,14 +47,14 @@ static void test_print(const testCtx *const p_ctx) {
int option_2;
int option_3;
float height;
char *fgcolour;
char *bgcolour;
const char *fgcolour;
const char *bgcolour;
int rotate_angle;
char *data;
char *composite;
const char *data;
const char *composite;
int ret;
char *expected_file;
char *comment;
const char *expected_file;
const char *comment;
};
static const struct item data[] = {
/* 0*/ { BARCODE_CODE128, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, "", "", 0, "<>\"&'", "", 0, "code128_amperands.svg", "" },
@ -150,7 +150,7 @@ static void test_print(const testCtx *const p_ctx) {
char expected_file[1024];
char escaped[1024];
int escaped_size = 1024;
char *text;
const char *text;
int have_libreoffice = 0;
int have_vnu = 0;
@ -209,7 +209,7 @@ static void test_print(const testCtx *const p_ctx) {
}
text_length = (int) strlen(text);
ret = ZBarcode_Encode(symbol, (unsigned char *) text, text_length);
ret = ZBarcode_Encode(symbol, TCU(text), text_length);
assert_equal(ret, data[i].ret, "i:%d %s ZBarcode_Encode ret %d != %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), ret, data[i].ret, symbol->errtxt);
strcpy(symbol->outfile, svg);

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020-2024 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-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
@ -36,12 +36,12 @@ static void test_large(const testCtx *const p_ctx) {
struct item {
int symbology;
char *pattern;
const char *pattern;
int length;
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -70,7 +70,7 @@ static void test_large(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data_buf, data[i].length, debug);
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
ret = ZBarcode_Encode(symbol, TCU(data_buf), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
@ -91,10 +91,10 @@ static void test_hrt(const testCtx *const p_ctx) {
struct item {
int symbology;
char *data;
const char *data;
int length;
char *expected;
const char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -122,7 +122,7 @@ static void test_hrt(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, data[i].length, 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 ret %d != 0 %s\n", i, ret, symbol->errtxt);
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
@ -138,12 +138,12 @@ static void test_input(const testCtx *const p_ctx) {
struct item {
int symbology;
char *data;
const char *data;
int length;
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -172,7 +172,7 @@ static void test_input(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
@ -197,14 +197,14 @@ static void test_encode(const testCtx *const p_ctx) {
struct item {
int symbology;
char *data;
const char *data;
int length;
int ret;
int expected_rows;
int expected_width;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
static const struct item data[] = {
/* 0*/ { BARCODE_TELEPEN, "1A", -1, 0, 1, 80, "Telepen BSiH Example, same",
@ -259,7 +259,7 @@ static void test_encode(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -301,7 +301,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
struct item {
int symbology;
char *data;
const char *data;
int length;
int ret;
};
@ -335,7 +335,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length;
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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
ZBarcode_Delete(symbol);

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020-2023 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-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
@ -41,7 +41,7 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
struct item {
int width;
int height;
char *pattern;
const char *pattern;
int repeat;
int no_identify; /* identify fails for some valid TIFFs (eg. RGB with LZW and large rows) */
int ret;
@ -91,7 +91,7 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
int i, ret;
struct zint_symbol *symbol = NULL;
char *tif = "out.tif";
const char *tif = "out.tif";
char data_buf[ZINT_MAX_DATA_LEN * 2 + 1];
@ -172,12 +172,12 @@ static void test_print(const testCtx *const p_ctx) {
int option_2;
int height;
float scale;
char *fgcolour;
char *bgcolour;
char *data;
char *composite;
char *expected_file;
char *comment;
const char *fgcolour;
const char *bgcolour;
const char *data;
const char *composite;
const char *expected_file;
const char *comment;
};
static const struct item data[] = {
/* 0*/ { BARCODE_CODE128, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0, "112233", "EEDDCC", "A", "", "code128_fgbg.tif", "" },
@ -216,7 +216,7 @@ static void test_print(const testCtx *const p_ctx) {
int escaped_size = 1024;
unsigned char filebuf[32768];
int filebuf_size;
char *text;
const char *text;
int have_tiffinfo = testUtilHaveTiffInfo();
const char *const have_identify = testUtilHaveIdentify();
@ -273,7 +273,7 @@ static void test_print(const testCtx *const p_ctx) {
}
text_length = (int) strlen(text);
ret = ZBarcode_Encode(symbol, (unsigned char *) text, text_length);
ret = ZBarcode_Encode(symbol, TCU(text), text_length);
assert_zero(ret, "i:%d %s ZBarcode_Encode ret %d != 0 %s\n", i, testUtilBarcodeName(data[i].symbology), ret, symbol->errtxt);
strcpy(symbol->outfile, tif);

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020-2024 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-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
@ -38,12 +38,12 @@ static void test_large(const testCtx *const p_ctx) {
int option_1;
int option_3;
struct zint_structapp structapp;
char *pattern;
const char *pattern;
int length;
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -109,7 +109,7 @@ static void test_large(const testCtx *const p_ctx) {
symbol->structapp = data[i].structapp;
}
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
ret = ZBarcode_Encode(symbol, TCU(data_buf), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
@ -132,12 +132,12 @@ static void test_reader_init(const testCtx *const p_ctx) {
int input_mode;
int output_options;
int option_3;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
char *expected;
char *comment;
const char *expected;
const char *comment;
};
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, READER_INIT, 0, "A", 0, 13, 14, "(3) 257 269 65", "8-bit FNC3 A" },
@ -162,7 +162,7 @@ static void test_reader_init(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_ULTRA, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1 /*option_2*/, 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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -195,10 +195,10 @@ static void test_input(const testCtx *const p_ctx) {
int option_2;
int option_3;
struct zint_structapp structapp;
char *data;
const char *data;
int ret;
char *expected;
char *comment;
const char *expected;
const char *comment;
};
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, 0, -1, -1, -1, { 0, 0, "" }, "A", 0, "(2) 257 65", "Default (Revision 1)" },
@ -293,7 +293,7 @@ static void test_input(const testCtx *const p_ctx) {
symbol->structapp = data[i].structapp;
}
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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -322,14 +322,14 @@ static void test_encode(const testCtx *const p_ctx) {
int option_2;
int option_3;
struct zint_structapp structapp;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
int bwipp_cmp;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
/* Based on AIMD/TSC15032-43 (v 0.99c), with values updated from BWIPP update 2021-07-14
https://github.com/bwipp/postscriptbarcode/commit/4255810845fa8d45c6192dd30aee1fdad1aaf0cc
@ -804,7 +804,7 @@ static void test_encode(const testCtx *const p_ctx) {
symbol->structapp = data[i].structapp;
}
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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -861,8 +861,8 @@ static void test_encode_segs(const testCtx *const p_ctx) {
int expected_rows;
int expected_width;
int bwipp_cmp;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
/* Based on AIMD/TSC15032-43 (v 0.99c), with values updated from BWIPP update 2021-07-14
https://github.com/bwipp/postscriptbarcode/commit/4255810845fa8d45c6192dd30aee1fdad1aaf0cc

View file

@ -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
@ -36,10 +36,10 @@ static void test_upce_input(const testCtx *const p_ctx) {
struct item {
int symbology;
char *data;
const char *data;
int ret;
char *hrt;
const char *hrt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -116,7 +116,7 @@ static void test_upce_input(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_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_equal(ret, data[i].ret, "i:%d ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < ZINT_ERROR) {
@ -155,7 +155,7 @@ static void test_upca_print(const testCtx *const p_ctx) {
struct item {
int symbology;
char *data;
const char *data;
int ret;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
@ -177,7 +177,7 @@ static void test_upca_print(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_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_equal(ret, data[i].ret, "i:%d ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
strcpy(symbol->outfile, "out.gif");
@ -197,9 +197,9 @@ static void test_upca_input(const testCtx *const p_ctx) {
struct item {
int symbology;
char *data;
const char *data;
int ret;
char *expected_errtxt;
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -297,7 +297,7 @@ static void test_upca_input(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_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_equal(ret, data[i].ret, "i:%d ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
@ -312,10 +312,10 @@ static void test_eanx_input(const testCtx *const p_ctx) {
struct item {
int symbology;
char *data;
const char *data;
int ret;
char *ret_errtxt;
char *comment;
const char *ret_errtxt;
const char *comment;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -469,7 +469,7 @@ static void test_eanx_input(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_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);
if (p_ctx->generate) {
printf(" /*%3d*/ { %s, \"%s\", %s, \"%s\", \"%s\" },\n",
@ -491,11 +491,11 @@ static void test_isbn_input(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
char *data;
const char *data;
int ret_encode;
int ret_vector;
char *ret_errtxt;
char *comment;
const char *ret_errtxt;
const char *comment;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -622,7 +622,7 @@ static void test_isbn_input(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_ISBNX, -1 /*input_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);
if (p_ctx->generate) {
printf(" /*%3d*/ { \"%s\", %s, %d, \"%s\", \"%s\" },\n",
@ -650,9 +650,9 @@ static void test_hrt(const testCtx *const p_ctx) {
struct item {
int symbology;
char *data;
const char *data;
int ret;
char *expected;
const char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -729,7 +729,7 @@ static void test_hrt(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_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_equal(ret, data[i].ret, "i:%d ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_zero(strcmp((const char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
@ -745,7 +745,7 @@ static void test_vector_same(const testCtx *const p_ctx) {
struct item {
int symbology;
char *data;
const char *data;
int ret_encode;
int ret_vector;
};
@ -773,7 +773,7 @@ static void test_vector_same(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_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_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret_encode, symbol->errtxt);
ret = ZBarcode_Buffer_Vector(symbol, 0);
@ -808,13 +808,13 @@ static void test_encode(const testCtx *const p_ctx) {
struct item {
int symbology;
int option_2;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
char *comment;
char *expected;
const char *comment;
const char *expected;
};
static const struct item data[] = {
/* 0*/ { BARCODE_UPCA, -1, "01234567890", 0, 1, 95, "GGS Figure 5.1-1 UPC-A (also Figure 5.2.2.3-1., 5.2.6.6-2., 6.4.9-1. and BS EN 797:1996 Figure 3)",
@ -948,7 +948,7 @@ static void test_encode(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -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_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (p_ctx->generate) {
@ -1000,7 +1000,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
struct item {
int symbology;
char *data;
const char *data;
int length;
int ret;
};
@ -1033,7 +1033,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
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 ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
ZBarcode_Delete(symbol);
@ -1055,12 +1055,12 @@ static void test_perf(const testCtx *const p_ctx) {
struct item {
int symbology;
int option_2;
char *data;
const char *data;
int ret;
int expected_rows;
int expected_width;
char *comment;
const char *comment;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
@ -1108,7 +1108,7 @@ static void test_perf(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, data[i].symbology, DATA_MODE, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug);
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);

View file

@ -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
@ -478,10 +478,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;
@ -541,8 +541,8 @@ static void test_buffer_vector(const testCtx *const p_ctx) {
struct item {
int symbology;
char *data;
char *composite;
const char *data;
const char *composite;
float expected_height;
int expected_rows;
@ -688,7 +688,7 @@ static void test_buffer_vector(const testCtx *const p_ctx) {
int i, length, ret;
struct zint_symbol *symbol = NULL;
char *text;
const char *text;
char errmsg[128];
testStartSymbol("test_buffer_vector", &symbol);
@ -712,7 +712,7 @@ static void test_buffer_vector(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_zero(ret, "i:%d ZBarcode_Encode(%d) ret %d != 0 %s\n", i, data[i].symbology, ret, symbol->errtxt);
ret = ZBarcode_Buffer_Vector(symbol, 0);
@ -750,8 +750,8 @@ static void test_has_hrt(const testCtx *const p_ctx) {
struct item {
int symbology;
char *data;
char *composite;
const char *data;
const char *composite;
};
struct item data[] = {
/* 0*/ { BARCODE_CODE11, "1234567890", "" },
@ -857,7 +857,7 @@ static void test_has_hrt(const testCtx *const p_ctx) {
int i, length, ret;
struct zint_symbol *symbol = NULL;
char *text;
const char *text;
char errmsg[128];
testStartSymbol("test_has_hrt", &symbol);
@ -881,7 +881,7 @@ static void test_has_hrt(const testCtx *const p_ctx) {
}
length = (int) strlen(text);
ret = ZBarcode_Encode_and_Buffer_Vector(symbol, (unsigned char *) text, length, 0);
ret = ZBarcode_Encode_and_Buffer_Vector(symbol, (const unsigned char *) text, length, 0);
assert_zero(ret, "i:%d ZBarcode_Encode_and_Buffer_Vector(%d) ret %d != 0 %s\n", i, data[i].symbology, ret, symbol->errtxt);
assert_nonnull(symbol->vector, "i:%d ZBarcode_Encode_and_Buffer_Vector(%d) vector NULL\n", i, data[i].symbology);
@ -901,7 +901,7 @@ static void test_upcean_hrt(const testCtx *const p_ctx) {
int symbology;
int show_hrt;
int output_options;
char *data;
const char *data;
int ret;
float expected_height;
@ -1005,7 +1005,7 @@ static void test_upcean_hrt(const testCtx *const p_ctx) {
length = (int) strlen(data[i].data);
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_Vector(symbol, 0);
@ -1061,7 +1061,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;
@ -1103,7 +1103,7 @@ static void test_row_separator(const testCtx *const p_ctx) {
symbol->border_width = data[i].border_width;
}
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_Vector(symbol, 0);
@ -1131,8 +1131,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;
@ -1166,11 +1166,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);
@ -1213,7 +1213,7 @@ static void test_output_options(const testCtx *const p_ctx) {
int whitespace_height;
int border_width;
int output_options;
char *data;
const char *data;
int ret;
float expected_height;
@ -1311,7 +1311,7 @@ static void test_output_options(const testCtx *const p_ctx) {
symbol->border_width = data[i].border_width;
}
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_Vector(symbol, 0);
@ -1355,7 +1355,7 @@ static void test_noncomposite_string_x(const testCtx *const p_ctx) {
struct item {
int symbology;
char *data;
const char *data;
int expected_width;
float expected_string_x;
@ -1385,7 +1385,7 @@ static void test_noncomposite_string_x(const testCtx *const p_ctx) {
length = (int) strlen(data[i].data);
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_Vector(symbol, 0);
@ -1409,7 +1409,7 @@ static void test_upcean_whitespace_width(const testCtx *const p_ctx) {
struct item {
int symbology;
char *data;
const char *data;
int whitespace_width;
int expected_width;
@ -1447,7 +1447,7 @@ static void test_upcean_whitespace_width(const testCtx *const p_ctx) {
length = (int) strlen(data[i].data);
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_Vector(symbol, 0);
@ -1486,8 +1486,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_vector;
float expected_height;
@ -1515,7 +1515,7 @@ static void test_scale(const testCtx *const p_ctx) {
int i, length, ret;
struct zint_symbol *symbol = NULL;
char *text;
const char *text;
struct zint_vector_rect *rect;
testStartSymbol("test_scale", &symbol);
@ -1545,7 +1545,7 @@ static void test_scale(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_nonzero(ret < ZINT_ERROR, "i:%d ZBarcode_Encode(%d) ret %d >= ZINT_ERROR (%s)\n", i, data[i].symbology, ret, symbol->errtxt);
ret = ZBarcode_Buffer_Vector(symbol, 0);
@ -1588,7 +1588,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;
float expected_height;
@ -1658,7 +1658,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_Vector(symbol, 0);
@ -1701,8 +1701,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;
float expected_height;
@ -2048,7 +2048,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_Vector(symbol, 0);
@ -2099,8 +2099,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;
@ -2211,7 +2211,7 @@ static void test_text_gap(const testCtx *const p_ctx) {
}
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_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_Vector(symbol, 0);
@ -2258,8 +2258,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;
@ -2892,7 +2892,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);
@ -2922,7 +2922,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_Vector(symbol, 0);
@ -2961,8 +2961,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;
@ -3055,7 +3055,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);
@ -3082,7 +3082,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_Vector(symbol, 0);

View file

@ -287,7 +287,7 @@ static int validate_int_range(const char src[], int *p_val, int *p_val_end) {
/* Begin test program, parse args */
void testRun(int argc, char *argv[], testFunction funcs[], int funcs_size) {
int i, ran;
char *optarg;
char *opt_arg;
char *func = NULL;
char func_buf[256 + 5];
char *func_not = NULL;
@ -324,8 +324,8 @@ void testRun(int argc, char *argv[], testFunction funcs[], int funcs_size) {
fprintf(stderr, "***testRun: -d debug value missing, ignoring***\n");
} else {
int d; /* Allow multiple debug flags, OR-ing */
optarg = argv[++i];
if (!validate_int(optarg, &d)) {
opt_arg = argv[++i];
if (!validate_int(opt_arg, &d)) {
fprintf(stderr, "***testRun: -d debug value invalid, ignoring***\n");
} else {
ctx.debug |= d;
@ -335,13 +335,13 @@ void testRun(int argc, char *argv[], testFunction funcs[], int funcs_size) {
if (i + 1 == argc) {
fprintf(stderr, "***testRun: -f func value missing, ignoring***\n");
} else {
optarg = argv[++i];
if (strlen(optarg) < 256) {
if (strncmp(optarg, "test_", 5) == 0) {
strcpy(func_buf, optarg);
opt_arg = argv[++i];
if (strlen(opt_arg) < 256) {
if (strncmp(opt_arg, "test_", 5) == 0) {
strcpy(func_buf, opt_arg);
} else {
strcpy(func_buf, "test_");
strcat(func_buf, optarg);
strcat(func_buf, opt_arg);
}
func = func_buf;
} else {
@ -353,13 +353,13 @@ void testRun(int argc, char *argv[], testFunction funcs[], int funcs_size) {
if (i + 1 == argc) {
fprintf(stderr, "***testRun: -n func exclude value missing, ignoring***\n");
} else {
optarg = argv[++i];
if (strlen(optarg) < 256) {
if (strncmp(optarg, "test_", 5) == 0) {
strcpy(func_not_buf, optarg);
opt_arg = argv[++i];
if (strlen(opt_arg) < 256) {
if (strncmp(opt_arg, "test_", 5) == 0) {
strcpy(func_not_buf, opt_arg);
} else {
strcpy(func_not_buf, "test_");
strcat(func_not_buf, optarg);
strcat(func_not_buf, opt_arg);
}
func_not = func_not_buf;
} else {
@ -379,8 +379,8 @@ void testRun(int argc, char *argv[], testFunction funcs[], int funcs_size) {
if (i + 1 == argc) {
fprintf(stderr, "***testRun: -i index value missing, ignoring***\n");
} else {
optarg = argv[++i];
if (!validate_int_range(optarg, &ctx.index, &ctx.index_end)) {
opt_arg = argv[++i];
if (!validate_int_range(opt_arg, &ctx.index, &ctx.index_end)) {
fprintf(stderr, "***testRun: -i index value invalid, ignoring***\n");
ctx.index = ctx.index_end = -1;
}
@ -389,10 +389,10 @@ void testRun(int argc, char *argv[], testFunction funcs[], int funcs_size) {
if (i + 1 == argc) {
fprintf(stderr, "***testRun: -x exclude value missing, ignoring***\n");
} else {
optarg = argv[++i];
opt_arg = argv[++i];
if (exclude_idx + 1 == ZINT_TEST_CTX_EXC_MAX) {
fprintf(stderr, "***testRun: too many -x exclude values, ignoring***\n");
} else if (!validate_int_range(optarg, &ctx.exclude[exclude_idx], &ctx.exclude_end[exclude_idx])) {
} else if (!validate_int_range(opt_arg, &ctx.exclude[exclude_idx], &ctx.exclude_end[exclude_idx])) {
fprintf(stderr, "***testRun: -x exclude value invalid, ignoring***\n");
ctx.exclude[exclude_idx] = ctx.exclude_end[exclude_idx] = -1;
} else {

View file

@ -66,7 +66,6 @@ extern int pclose(FILE *stream);
#endif
#if defined(__GNUC__)
# pragma GCC diagnostic ignored "-Wpedantic"
# pragma GCC diagnostic ignored "-Woverlength-strings"
#elif defined(_MSC_VER)
# pragma warning(disable: 4305) /* truncation from 'double' to 'float' */
@ -82,8 +81,8 @@ extern const char *testAssertFilename;
#define testStart(name) (testStartReal("", name, NULL))
#define testStartSymbol(name, pp_symbol) (testStartReal("", name, pp_symbol))
#else
#define testStart(name) (testStartReal(__func__, name, NULL))
#define testStartSymbol(name, pp_symbol) (testStartReal(__func__, name, pp_symbol))
#define testStart(name) (ZEXT testStartReal(__func__, name, NULL))
#define testStartSymbol(name, pp_symbol) (ZEXT testStartReal(__func__, name, pp_symbol))
#endif
void testStartReal(const char *func, const char *name, struct zint_symbol **pp_symbol);
void testFinish(void);
@ -130,6 +129,7 @@ void assert_notequal(int e1, int e2, const char *fmt, ...);
#endif
#define TU(p) ((unsigned char *) (p))
#define TCU(p) ((const unsigned char *) (p))
INTERNAL void vector_free(struct zint_symbol *symbol); /* Free vector structures */