diff --git a/tests/main_test_amf.c b/tests/main_test_amf.c index 534efea..8e9fd6a 100644 --- a/tests/main_test_amf.c +++ b/tests/main_test_amf.c @@ -42,10 +42,8 @@ struct gmio_memblock gmio_memblock_for_tests() return gmio_memblock_malloc(512 * 1024); /* 512KB */ } -const char* all_tests() +void all_tests() { - UTEST_SUITE_START(); - gmio_memblock_set_default_constructor(gmio_memblock_for_tests); UTEST_RUN(test_amf_write_doc_null); @@ -54,7 +52,5 @@ const char* all_tests() UTEST_RUN(test_amf_write_doc_1_zip64); UTEST_RUN(test_amf_write_doc_1_zip64_file); UTEST_RUN(test_amf_write_doc_1_task_iface); - - return NULL; } UTEST_MAIN(all_tests) diff --git a/tests/main_test_core.c b/tests/main_test_core.c index b5165dd..86525da 100644 --- a/tests/main_test_core.c +++ b/tests/main_test_core.c @@ -34,10 +34,8 @@ #include "test_core_internal.c" #include "test_core_platform.c" -const char* all_tests() +void all_tests() { - UTEST_SUITE_START(); - UTEST_RUN(test_core__buffer); UTEST_RUN(test_core__endian); UTEST_RUN(test_core__error); @@ -61,7 +59,5 @@ const char* all_tests() UTEST_RUN(test_internal__zip_utils); UTEST_RUN(test_internal__zlib_enumvalues); UTEST_RUN(test_internal__file_utils); - - return NULL; } UTEST_MAIN(all_tests) diff --git a/tests/main_test_stl.c b/tests/main_test_stl.c index 7d07966..dc024b5 100644 --- a/tests/main_test_stl.c +++ b/tests/main_test_stl.c @@ -44,10 +44,8 @@ struct gmio_memblock gmio_memblock_for_tests() return gmio_memblock(buff, sizeof(buff), NULL); } -const char* all_tests() +void all_tests() { - UTEST_SUITE_START(); - gmio_memblock_set_default_constructor(gmio_memblock_for_tests); #if 0 @@ -73,7 +71,5 @@ const char* all_tests() UTEST_RUN(test_stlb_header_str); UTEST_RUN(test_stlb_header_to_printable_str); - - return NULL; } UTEST_MAIN(all_tests) diff --git a/tests/utest_assert.h b/tests/utest_assert.h index b6c3cbc..7620c5b 100644 --- a/tests/utest_assert.h +++ b/tests/utest_assert.h @@ -3,8 +3,7 @@ * http://c.learncodethehardway.org/book/ex30.html */ -#ifndef UTEST_ASSERT_H -#define UTEST_ASSERT_H +#pragma once #include @@ -47,5 +46,3 @@ #define UTEST_COMPARE_CSTR(expected, actual) \ UTEST_COMPARE__INTERNAL(expected, actual, UTEST_EQUALS_STRCMP__INTERNAL, "%s", "C-string") - -#endif /* UTEST_ASSERT_H */ diff --git a/tests/utest_lib.h b/tests/utest_lib.h index 10af19a..3ddc505 100644 --- a/tests/utest_lib.h +++ b/tests/utest_lib.h @@ -3,38 +3,42 @@ * http://c.learncodethehardway.org/book/ex30.html */ -#ifndef UTEST_LIB_H -#define UTEST_LIB_H +#pragma once #include "utest_assert.h" - #include -#define UTEST_SUITE_START() const char* message = NULL - -#define UTEST_RUN(test) printf("\n-----%s", " " #test); \ - message = test();\ - tests_run++;\ - if (message) return message; +#define UTEST_RUN(func_run_utest) \ + {\ + printf("\n-----%s", " " #func_run_utest); \ + ++test_count;\ + const char* str_error = func_run_utest();\ + if (str_error == NULL)\ + ++test_ok_count;\ + else\ + printf(" FAILED: %s\n", str_error);\ + } -#define UTEST_MAIN(name) \ +#define UTEST_MAIN(func_run_utests) \ int main(int argc, char *argv[]) {\ - const char *result = NULL; \ - \ - (void)argc; \ - printf("----\nRUNNING: %s\n", argv[0]);\ - result = name();\ - if (result != NULL) {\ - printf("\n\nFAILED: %s\n", result);\ + const char* prg_test_name = argv[0];\ + (void)argc;\ + test_count = test_ok_count = 0;\ + printf("----\nRUNNING: %s\n", prg_test_name);\ + func_run_utests();\ + printf("\n\nRESULT: %s\n"\ + " tested: %d | passed: %d | failed: %d\n",\ + prg_test_name,\ + test_count, test_ok_count, test_count - test_ok_count);\ + if (test_count > 0) {\ + if (test_ok_count == test_count)\ + printf(" ALL TESTS PASSED\n");\ + else\ + printf(" TEST FAILURE\n");\ }\ - else {\ - printf("\n\nALL TESTS PASSED\n");\ - }\ - printf("Tests run: %d\n", tests_run);\ - exit(result != NULL);\ + exit(test_ok_count != test_count);\ } -static int tests_run; - -#endif /* UTEST_LIB_H */ +static int test_count; +static int test_ok_count;