lib

morphux C utility library
Log | Files | Refs | Submodules | README | LICENSE | git clone https://git.ne02ptzero.me/git/lib

commit d731bdf931d6eadcc9662f93ed250aff7ca818ea
parent 8b814e46549166f719af9ffcf1757d2af4ec5224
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Mon, 27 Feb 2017 13:52:41 +0100

Fix(Test): Fix macro to not execute implicit conditions

Diffstat:
Minc/m_test.h | 2+-
Mtests/test_list.c | 3+--
2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/inc/m_test.h b/inc/m_test.h @@ -45,7 +45,7 @@ typedef struct s_test_results { # define TEST(name) char *test_##name(void) # define reg_test(group, name) register_test(group, &test_##name, #name); # define TEST_ASSERT(condition, error_name) {\ - if (!condition) {\ + if (!(condition)) {\ char *ret = NULL; \ asprintf(&ret, "\t%s: Test: '%s', File %s:%d", error_name, #condition, __FILE__, __LINE__);\ return ret;\ diff --git a/tests/test_list.c b/tests/test_list.c @@ -185,7 +185,7 @@ TEST(list_size) { list_add(ptr, test, sizeof(test)); list_add(ptr, test2, sizeof(test2)); list_add(ptr, test3, sizeof(test3)); - TEST_ASSERT(list_size(ptr) == 3, "Size is wrong."); + TEST_ASSERT((list_size(ptr) == 3), "Size is wrong."); list_free(ptr, NULL); ptr = NULL; TEST_ASSERT(list_size(ptr) == 0, "Size is wrong."); @@ -219,7 +219,6 @@ TEST(list_free) { int callback_list_free_2(void *ptr) { free(ptr); - printf("Sup ?!\n"); return 1; }