diff --git a/test/main.c b/test/main.c index e683267..2eee572 100644 --- a/test/main.c +++ b/test/main.c @@ -5,13 +5,12 @@ #include "../src/raw_chunk_manager.h" #include - -#define NOT_NULL (void*) 55342301 +#include void test(const void* expected_value, const void* value, const char* test_name, const char* description) { printf("%s ", test_name); - if ((expected_value == NOT_NULL && value != NULL) || (expected_value != NOT_NULL && expected_value == value)) + if (expected_value == value) printf("[OK]"); else printf("[FAILED] %s {%p != %p}", description, expected_value, value); @@ -37,13 +36,13 @@ int main(int ac, char **av) void *ptr1 = ft_malloc(10000000); void *ptr2 = ft_malloc(10000000); void *ptr3 = ft_malloc(10000000); - test(NOT_NULL, raw_get_chunk(allocs_tree[LARGE], ptr1), "alloc first", ""); - test(NOT_NULL, raw_get_chunk(allocs_tree[LARGE], ptr2), "alloc second", ""); - test(NOT_NULL, raw_get_chunk(allocs_tree[LARGE], ptr3), "alloc third", ""); + test(0, (const void*) (uintptr_t) (raw_get_chunk(allocs_tree[LARGE], ptr1) == NULL), "alloc first", ""); + test(0, (const void*) (uintptr_t) (raw_get_chunk(allocs_tree[LARGE], ptr2) == NULL), "alloc second", ""); + test(0, (const void*) (uintptr_t) (raw_get_chunk(allocs_tree[LARGE], ptr3) == NULL), "alloc third", ""); ft_free(ptr1); - test(NOT_NULL, raw_get_chunk(allocs_tree[LARGE], ptr2), "free disorder1", ""); + test(0, (const void*) (uintptr_t) (raw_get_chunk(allocs_tree[LARGE], ptr2) == NULL), "free disorder1", ""); ft_free(ptr3); - test(NOT_NULL, raw_get_chunk(allocs_tree[LARGE], ptr2), "free disorder2", ""); + test(0, (const void*) (uintptr_t) (raw_get_chunk(allocs_tree[LARGE], ptr2) == NULL), "free disorder2", ""); ft_free(ptr2); test(NULL, allocs_tree[LARGE], "free disorder3", "");