From 7e6da28761032b2b3cb9c7669cda37105cd0febe Mon Sep 17 00:00:00 2001 From: gitlost Date: Sun, 27 Oct 2024 22:19:43 +0000 Subject: [PATCH] tests: test_library: fix snafus from previous commit [5e2044] (Windows) --- backend/common.c | 12 ++++++------ backend/tests/test_library.c | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/backend/common.c b/backend/common.c index 4d42a493..fad2191b 100644 --- a/backend/common.c +++ b/backend/common.c @@ -385,12 +385,12 @@ INTERNAL int errtxtf(const int error_number, struct zint_symbol *symbol, const i if (arg == -1) { if (!(symbol->debug & ZINT_DEBUG_TEST)) assert(0); return errtxt(ZINT_ERROR_ENCODING_PROBLEM, symbol, 0, - "Internal error: invalid numbered format specifer"); + "Internal error: invalid numbered format specifer"); } if (i >= 9) { if (!(symbol->debug & ZINT_DEBUG_TEST)) assert(0); return errtxt(ZINT_ERROR_ENCODING_PROBLEM, symbol, 0, - "Internal error: too many format specifiers (9 maximum)"); + "Internal error: too many format specifiers (9 maximum)"); } f += inc; have_num_arg = 1; @@ -399,7 +399,7 @@ INTERNAL int errtxtf(const int error_number, struct zint_symbol *symbol, const i if (i >= 9) { if (!(symbol->debug & ZINT_DEBUG_TEST)) assert(0); return errtxt(ZINT_ERROR_ENCODING_PROBLEM, symbol, 0, - "Internal error: too many format specifiers (9 maximum)"); + "Internal error: too many format specifiers (9 maximum)"); } have_unnum_arg = 1; idxs[i] = i; @@ -421,7 +421,7 @@ INTERNAL int errtxtf(const int error_number, struct zint_symbol *symbol, const i if (*f != 'c' && *f != 'd' && *f != 'f' && *f != 'g' && *f != 's') { if (!(symbol->debug & ZINT_DEBUG_TEST)) assert(0); return errtxt(ZINT_ERROR_ENCODING_PROBLEM, symbol, 0, - "Internal error: unknown format specifier ('%c','%d','%f','%g','%s' only)"); + "Internal error: unknown format specifier ('%c','%d','%f','%g','%s' only)"); } specs[idxs[i++]] = *f; arg_cnt++; @@ -430,7 +430,7 @@ INTERNAL int errtxtf(const int error_number, struct zint_symbol *symbol, const i if (have_num_arg && have_unnum_arg) { if (!(symbol->debug & ZINT_DEBUG_TEST)) assert(0); return errtxt(ZINT_ERROR_ENCODING_PROBLEM, symbol, 0, - "Internal error: mixed numbered and unnumbered format specifiers"); + "Internal error: mixed numbered and unnumbered format specifiers"); } /* Get arguments */ @@ -440,7 +440,7 @@ INTERNAL int errtxtf(const int error_number, struct zint_symbol *symbol, const i cs[i] = va_arg(ap, int); } else if (specs[i] == 'd') { if (dpads[i][0]) { - char dpad_fmt[30]; /* Make 30 to suppress GNU c "-Wformat-overflow=" false positive */ + char dpad_fmt[30]; /* Make 30 to suppress gcc 14 "-Wformat-overflow=" false positive */ sprintf(dpad_fmt, "%%0%sd", dpads[i]); /* TODO: keep `dpads` separate else last mentioned trumps */ sprintf(dfgs[i], dpad_fmt, va_arg(ap, int)); } else { diff --git a/backend/tests/test_library.c b/backend/tests/test_library.c index 7573b060..937f5150 100644 --- a/backend/tests/test_library.c +++ b/backend/tests/test_library.c @@ -1041,12 +1041,12 @@ static void test_encode_file_too_large(const testCtx *const p_ctx) { static void test_encode_file_unreadable(const testCtx *const p_ctx) { #ifndef _WIN32 int ret; - struct zint_symbol *symbol = NULL; char filename[] = "in.bin"; char buf[ZINT_MAX_DATA_LEN + 1] = {0}; int fd; #endif + struct zint_symbol *symbol = NULL; (void)p_ctx; @@ -1227,7 +1227,7 @@ static void test_bad_args(const testCtx *const p_ctx) { "Error 200: Input segments NULL", "Error 239: Filename NULL", "Error 778: No input data", - "Error 229: Unable to read input file (2: No such file or directory)", + "Error 229: Unable to read input file (", /* Excluding OS-dependent `errno` stuff */ "Error 771: Too many input segments (maximum 256)", "Error 205: No input data", "Error 777: Input too long", @@ -1331,16 +1331,16 @@ static void test_bad_args(const testCtx *const p_ctx) { 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); symbol->errtxt[0] = '\0'; assert_equal(ZBarcode_Encode_File(symbol, empty), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_File(symbol, empty) != ZINT_ERROR_INVALID_DATA\n"); - assert_zero(strcmp(expected[4], symbol->errtxt), "ZBarcode_Encode_File(symbol, empty) strcmp(%s, %s) != 0\n", expected[4], symbol->errtxt); + assert_zero(strncmp(expected[4], symbol->errtxt, strlen(expected[4])), "ZBarcode_Encode_File(symbol, empty) strncmp(%s, %s, %d) != 0\n", expected[4], symbol->errtxt, (int) strlen(expected[4])); symbol->errtxt[0] = '\0'; assert_equal(ZBarcode_Encode_File_and_Print(symbol, empty, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_File_and_Print(symbol, empty, 0) != ZINT_ERROR_INVALID_DATA\n"); - assert_zero(strcmp(expected[4], symbol->errtxt), "ZBarcode_Encode_File_and_Print(symbol, empty, 0) strcmp(%s, %s) != 0\n", expected[4], symbol->errtxt); + assert_zero(strncmp(expected[4], symbol->errtxt, strlen(expected[4])), "ZBarcode_Encode_File(symbol, empty) strncmp(%s, %s, %d) != 0\n", expected[4], symbol->errtxt, (int) strlen(expected[4])); symbol->errtxt[0] = '\0'; assert_equal(ZBarcode_Encode_File_and_Buffer(symbol, empty, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_File_and_Buffer(symbol, empty, 0) != ZINT_ERROR_INVALID_DATA\n"); - assert_zero(strcmp(expected[4], symbol->errtxt), "ZBarcode_Encode_File_and_Buffer(symbol, empty, 0) strcmp(%s, %s) != 0\n", expected[4], symbol->errtxt); + assert_zero(strncmp(expected[4], symbol->errtxt, strlen(expected[4])), "ZBarcode_Encode_File(symbol, empty) strncmp(%s, %s, %d) != 0\n", expected[4], symbol->errtxt, (int) strlen(expected[4])); symbol->errtxt[0] = '\0'; assert_equal(ZBarcode_Encode_File_and_Buffer_Vector(symbol, empty, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_File_and_Buffer_Vector(symbol, empty, 0) != ZINT_ERROR_INVALID_DATA\n"); - assert_zero(strcmp(expected[4], symbol->errtxt), "ZBarcode_Encode_File_and_Buffer_Vector(symbol, empty, 0) strcmp(%s, %s) != 0\n", expected[4], symbol->errtxt); + assert_zero(strncmp(expected[4], symbol->errtxt, strlen(expected[4])), "ZBarcode_Encode_File(symbol, empty) strncmp(%s, %s, %d) != 0\n", expected[4], symbol->errtxt, (int) strlen(expected[4])); /* Bad seg_count */ symbol->errtxt[0] = '\0';