aboutsummaryrefslogtreecommitdiff
path: root/tests/mem
diff options
context:
space:
mode:
authorMosder <xmosder12@gmail.com>2026-08-21 11:50:51 +0200
committerMosder <xmosder12@gmail.com>2026-08-21 11:50:51 +0200
commitb6b7a01987dca604a161c8c73a240ec4430baed0 (patch)
treeb9fdeb674ad767ccb16d1a3cdc2c6c975ea11737 /tests/mem
parent890a52b9af6e24015048eb2754552b9613484b3f (diff)
refactor: renamed mem/alloc.h to safe.h and made it be a collection of "safe" wrappers for "unsafe" functions
Diffstat (limited to 'tests/mem')
-rw-r--r--tests/mem/alloc_tests.c43
-rw-r--r--tests/mem/alloc_tests.h3
2 files changed, 0 insertions, 46 deletions
diff --git a/tests/mem/alloc_tests.c b/tests/mem/alloc_tests.c
deleted file mode 100644
index 5b71887..0000000
--- a/tests/mem/alloc_tests.c
+++ /dev/null
@@ -1,43 +0,0 @@
-#include "alloc_tests.h"
-#define MOS_MAX_ALLOC_ATTEMPTS 1
-#include "moslib/mem/alloc.h"
-
-#include <limits.h>
-#include <stdlib.h>
-
-Test malloc_exit() {
- safe_malloc(ULLONG_MAX);
-}
-
-Test test_safe_malloc() {
- void *p = safe_malloc(1024);
- test_assert(p != NULL, "Failed to malloc 1KiB");
-
- suppress_output(&stderr);
- test_assert_exit(malloc_exit, EXIT_FAILURE);
- unsuppress_outputs();
-}
-
-Test realloc_exit() {
- void *p = NULL;
- safe_realloc(p, ULLONG_MAX);
-}
-
-Test test_safe_realloc() {
- void *p = NULL;
- p = safe_realloc(p, 1024);
- test_assert(p != NULL, "Failed to realloc NULL to 1KiB");
-
- p = safe_realloc(p, 4096);
- test_assert(p != NULL, "Failed to realloc 1KiB to 4KiB");
-
- suppress_output(&stderr);
- test_assert_exit(realloc_exit, EXIT_FAILURE);
- unsuppress_outputs();
-}
-
-void mem_alloc_tests(Tester *tester) {
- TestGroup *group = add_test_group(tester, "moslib/mem/alloc.h");
- add_test(group, test_safe_malloc);
- add_test(group, test_safe_realloc);
-}
diff --git a/tests/mem/alloc_tests.h b/tests/mem/alloc_tests.h
deleted file mode 100644
index aaf70a4..0000000
--- a/tests/mem/alloc_tests.h
+++ /dev/null
@@ -1,3 +0,0 @@
-#include <moslib/tester.h>
-
-extern void mem_alloc_tests(Tester *tester);