From 4bbb0b6c5e1c0484a421bfa7972ce1b03137ff15 Mon Sep 17 00:00:00 2001 From: Intel A80486DX2-66 Date: Wed, 13 Mar 2024 22:33:45 +0300 Subject: [PATCH] asprintf.c: test: fix function usage and asserts --- c-programming/strings/asprintf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/c-programming/strings/asprintf.c b/c-programming/strings/asprintf.c index 16059ce..45ed617 100644 --- a/c-programming/strings/asprintf.c +++ b/c-programming/strings/asprintf.c @@ -50,13 +50,13 @@ int main(void) { const char* world = " world"; char* output; - size_t result = asprintf(&output, "Hello%s! -- Unsigned 32-bit type is " + ssize_t result = asprintf(&output, "Hello%s! -- Unsigned 32-bit type is " "constrained to lie\nwithin the range of integer values from " "%" PRIu32 " to %" PRIu32 " inclusive.", world, 0, (uint32_t) (powf(2.0f, 32.0f) - 1.0f)); - PRINT_ASSERT("segmentation fault", true); - PRINT_ASSERT("no errors", errno == 0); + PRINT_ASSERT("no segmentation fault", true); + PRINT_ASSERT("no errors occurred", result != -1); PRINT_ASSERT("zero termination test", output[result] == '\0'); printf("[asprintf (%zu)] '%s'\n", result, output);