diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2020-04-17 09:38:43 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2020-04-17 09:38:43 +0200 |
commit | 15250710c63a2c3d230304e46a03532f787759fb (patch) | |
tree | 9fda47ad94248d133b7b48c67eba20d357c6694e /tests/mknode_reg.c | |
parent | 6b3e6d299d5298a5936dbba57f67cdfc4a406789 (diff) |
tests: improve diagnostics output & make "release builds" work
This commit adds a few macros and helper functions for the unit test
programs. Those are used instead of asserts to provide more fine
grained diagnostics on the one hand and on the other hand because
they also work if NDEBUG is defined, unlike asserts that get eliminated
in that case.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'tests/mknode_reg.c')
-rw-r--r-- | tests/mknode_reg.c | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/tests/mknode_reg.c b/tests/mknode_reg.c index 40966f8..677c934 100644 --- a/tests/mknode_reg.c +++ b/tests/mknode_reg.c @@ -7,10 +7,7 @@ #include "config.h" #include "fstree.h" - -#include <stdlib.h> -#include <assert.h> -#include <string.h> +#include "test.h" int main(void) { @@ -28,16 +25,16 @@ int main(void) sb.st_size = 4096; node = fstree_mknode(NULL, "filename", 8, "input", &sb); - assert(node->uid == sb.st_uid); - assert(node->gid == sb.st_gid); - assert(node->mode == sb.st_mode); - assert(node->parent == NULL); - assert(node->link_count == 1); - assert((char *)node->name >= (char *)node->payload); - assert(node->data.file.input_file >= (char *)node->payload); - assert(node->data.file.input_file >= node->name + 8); - assert(strcmp(node->name, "filename") == 0); - assert(strcmp(node->data.file.input_file, "input") == 0); + TEST_EQUAL_UI(node->uid, sb.st_uid); + TEST_EQUAL_UI(node->gid, sb.st_gid); + TEST_EQUAL_UI(node->mode, sb.st_mode); + TEST_NULL(node->parent); + TEST_EQUAL_UI(node->link_count, 1); + TEST_ASSERT((char *)node->name >= (char *)node->payload); + TEST_ASSERT(node->data.file.input_file >= (char *)node->payload); + TEST_ASSERT(node->data.file.input_file >= node->name + 8); + TEST_STR_EQUAL(node->name, "filename"); + TEST_STR_EQUAL(node->data.file.input_file, "input"); free(node); return EXIT_SUCCESS; |