tests/ucxtest.c

changeset 770
ed710122af44
parent 768
0e1cf2cd500e
child 777
e5b29e6f0615
equal deleted inserted replaced
769:b53e0e003d7e 770:ed710122af44
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #include "cx/test.h" 29 #include "cx/test.h"
30 30
31 CxTestSuite *cx_test_suite_testing_allocator(void);
31 CxTestSuite *cx_test_suite_utils(void); 32 CxTestSuite *cx_test_suite_utils(void);
32 CxTestSuite *cx_test_suite_hash_key(void); 33 CxTestSuite *cx_test_suite_hash_key(void);
33 34
34 #define run_tests(suite) cx_test_run_stdout(suite); success += (suite)->success; failure += (suite)->failure 35 #define run_tests(suite) cx_test_run_stdout(suite); success += (suite)->success; failure += (suite)->failure
36 #define execute_test_suites(...) unsigned success = 0, failure = 0; CxTestSuite* test_suites[] = {__VA_ARGS__}; \
37 for (size_t i = 0; i < sizeof(test_suites)/sizeof(void*) ; i++) {run_tests(test_suites[i]);} (void)0
38 #define free_test_suites for (size_t i = 0 ; i < sizeof(test_suites)/sizeof(void*) ; i++) {cx_test_suite_free(test_suites[i]);} (void)0
35 39
36 int main(void) { 40 int main(void) {
37 printf("UCX Tests\n---------\n"); 41 printf("UCX Tests\n---------\n");
38 42
39 unsigned success = 0, failure = 0; 43 execute_test_suites(
40 44 cx_test_suite_testing_allocator(),
41 // create test suites 45 cx_test_suite_utils(),
42 CxTestSuite 46 cx_test_suite_hash_key()
43 *utils = cx_test_suite_utils(), 47 );
44 *hash_key = cx_test_suite_hash_key();
45
46 // run tests
47 run_tests(utils);
48 run_tests(hash_key);
49
50 // print overall result
51 printf("=== OVERALL RESULT ===\n"); 48 printf("=== OVERALL RESULT ===\n");
52 printf(" Total: %u\n Success: %u\n Failure: %u\n", 49 printf(" Total: %u\n Success: %u\n Failure: %u\n",
53 success + failure, success, failure); 50 success + failure, success, failure);
54 51 free_test_suites;
55 cx_test_suite_free(utils);
56 cx_test_suite_free(hash_key);
57 52
58 return failure > 0 ? 1 : 0; 53 return failure > 0 ? 1 : 0;
59 } 54 }
60 55

mercurial