mirror of
https://git.code.sf.net/p/zint/code
synced 2025-12-23 12:57:07 +00:00
library: use "filemem" for TXT dump_plot() -> txt_hex_plot()
filemem: remove NOLINTS (clang-tidy-20 bug fixed) QRCODE: eliminate NOLINTs using some more asserts (clang-tidy-20); some "de-branching" of loops general: various code fiddlings, in particular lessen no. of redundant parenthesized expressions, especially in conditionals, which reduce rather than aid readibility IMNSHO manual: mention "--dump" option
This commit is contained in:
@@ -39,7 +39,7 @@
|
||||
#include "../common.h"
|
||||
#include "../filemem.h"
|
||||
|
||||
static void test_svg(const testCtx *const p_ctx) {
|
||||
static void test_file(const testCtx *const p_ctx) {
|
||||
int debug = p_ctx->debug;
|
||||
|
||||
struct item {
|
||||
@@ -68,6 +68,9 @@ static void test_svg(const testCtx *const p_ctx) {
|
||||
" </g>\n"
|
||||
"</svg>\n"
|
||||
},
|
||||
/* 1*/ { BARCODE_TELEPEN, BARCODE_MEMORY_FILE, "out.txt", "ABCD", -1, 0,
|
||||
"AA B8 BB B8 E3 B8 AE EA EB B8 AE AA E2 AA\n"
|
||||
},
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
@@ -96,10 +99,12 @@ static void test_svg(const testCtx *const p_ctx) {
|
||||
|
||||
assert_nonnull(symbol->memfile, "i:%d memfile NULL (%s)\n", i, symbol->errtxt);
|
||||
|
||||
assert_equal(symbol->memfile_size, expected_size, "i:%d memfile_size %d != %d (%s)\n",
|
||||
i, symbol->memfile_size, expected_size, symbol->errtxt);
|
||||
assert_equal(symbol->memfile_size, expected_size, "i:%d memfile_size %d != %d (\"%.*s\", \"%s\") (%s)\n",
|
||||
i, symbol->memfile_size, expected_size, symbol->memfile_size, symbol->memfile,
|
||||
data[i].expected, symbol->errtxt);
|
||||
ret = memcmp(symbol->memfile, data[i].expected, expected_size);
|
||||
assert_zero(ret, "i:%d memcmp() %d != 0\n", i, ret);
|
||||
assert_zero(ret, "i:%d memcmp(\"%.*s\", \"%s\") %d != 0 (%s)\n",
|
||||
i, symbol->memfile_size, symbol->memfile, data[i].expected, ret, symbol->errtxt);
|
||||
} else {
|
||||
assert_null(symbol->memfile, "i:%d memfile != NULL (%s)\n", i, symbol->errtxt);
|
||||
assert_zero(symbol->memfile_size, "i:%d memfile_size != 0 (%s)\n", i, symbol->errtxt);
|
||||
@@ -467,7 +472,7 @@ static void test_large(const testCtx *const p_ctx) {
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
testFunction funcs[] = { /* name, func */
|
||||
{ "test_svg", test_svg },
|
||||
{ "test_file", test_file },
|
||||
{ "test_putsf", test_putsf },
|
||||
{ "test_printf", test_printf },
|
||||
{ "test_seek", test_seek },
|
||||
|
||||
@@ -1577,7 +1577,7 @@ static void test_encode_print_outfile_directory(const testCtx *const p_ctx) {
|
||||
int ret;
|
||||
struct zint_symbol *symbol = NULL;
|
||||
char dirname[] = "outdir.txt";
|
||||
char expected[] = "Error 201: Could not open output file";
|
||||
char expected[] = "Error 201: Could not open TXT output file"; /* Excluding OS-dependent `errno` stuff */
|
||||
|
||||
(void)p_ctx;
|
||||
|
||||
@@ -1593,7 +1593,8 @@ static void test_encode_print_outfile_directory(const testCtx *const p_ctx) {
|
||||
strcpy(symbol->outfile, dirname);
|
||||
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);
|
||||
assert_zero(strncmp(symbol->errtxt, expected, sizeof(expected) - 1), "strncmp(%s, %s) != 0\n",
|
||||
symbol->errtxt, expected);
|
||||
|
||||
ret = testUtilRmDir(dirname);
|
||||
assert_zero(ret, "testUtilRmDir(%s) %d != 0 (%d: %s)\n", dirname, ret, errno, strerror(errno));
|
||||
|
||||
Reference in New Issue
Block a user