diff options
| author | Mosder <git@mosder.eu> | 2026-09-17 15:51:23 +0200 |
|---|---|---|
| committer | Mosder <git@mosder.eu> | 2026-09-17 15:51:23 +0200 |
| commit | 5a7dcb86485f050aeeb77eef3313a6b92a2adde4 (patch) | |
| tree | 8da7de37d80b36f054bfc6d5dba284dda609c435 /tests | |
| parent | de163fe7ee64e63d36dd581db16c776831cbead0 (diff) | |
feat: changed output tests and suppression to use file descriptors for more portability
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/safe_tests.c | 12 | ||||
| -rw-r--r-- | tests/string_tests.c | 2 |
2 files changed, 7 insertions, 7 deletions
diff --git a/tests/safe_tests.c b/tests/safe_tests.c index b50b073..3c25dd5 100644 --- a/tests/safe_tests.c +++ b/tests/safe_tests.c @@ -13,7 +13,7 @@ TEST(test_safe_malloc) { void *p = safe_malloc(1024); test_assert(p != NULL, "Failed to malloc 1KiB"); - suppress_output(stderr); + suppress_output(STDERR_FILENO); test_assert_exit(malloc_exit, EXIT_FAILURE); unsuppress_outputs(); } @@ -26,7 +26,7 @@ TEST(test_safe_calloc) { void *p = safe_calloc(16, 16); test_assert(p != NULL, "Failed to calloc 16 items of 16 bytes"); - suppress_output(stderr); + suppress_output(STDERR_FILENO); test_assert_exit(calloc_exit, EXIT_FAILURE); unsuppress_outputs(); } @@ -44,7 +44,7 @@ TEST(test_safe_realloc) { p = safe_realloc(p, 4096); test_assert(p != NULL, "Failed to realloc 1KiB to 4KiB"); - suppress_output(stderr); + suppress_output(STDERR_FILENO); test_assert_exit(realloc_exit, EXIT_FAILURE); unsuppress_outputs(); } @@ -57,7 +57,7 @@ TEST(test_safe_fopen) { FILE *fp = safe_fopen(__FILE__, "r"); test_assert(fp != NULL, "Failed to fopen current file"); - suppress_output(stderr); + suppress_output(STDERR_FILENO); test_assert_exit(fopen_exit, EXIT_FAILURE); unsuppress_outputs(); } @@ -76,7 +76,7 @@ TEST(test_safe_dup) { test_assert(fd != -1, "Failed to dup STDOUT_FILENO"); close(fd); - suppress_output(stderr); + suppress_output(STDERR_FILENO); test_assert_exit(dup_exit, EXIT_FAILURE); unsuppress_outputs(); } @@ -96,7 +96,7 @@ TEST(test_safe_dup2) { test_assert(res != -1, "Failed to restore STDOUT_FILENO"); close(fd); - suppress_output(stderr); + suppress_output(STDERR_FILENO); test_assert_exit(dup2_exit, EXIT_FAILURE); unsuppress_outputs(); } diff --git a/tests/string_tests.c b/tests/string_tests.c index eaa9498..8ca0dcd 100644 --- a/tests/string_tests.c +++ b/tests/string_tests.c @@ -41,7 +41,7 @@ TEST(ss_print_helper) { } TEST(printing) { - test_assert_out(ss_print_helper, stdout, "test"); + test_assert_out(ss_print_helper, STDOUT_FILENO, "test"); StringSlice ss = ss_from_str("slice"); char buf[16]; |
