1
0
mirror of https://gitlab.com/80486DX2-66/gists synced 2025-01-09 23:17:48 +05:30

asprintf.c: test: fix function usage and asserts

This commit is contained in:
パチュリー・ノーレッジ 2024-03-13 22:33:45 +03:00
parent ad2babeb25
commit 4bbb0b6c5e
Signed by: 80486DX2-66
GPG Key ID: 83631EF27054609B

View File

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