test/main.c

changeset 26
59f147baea31
parent 21
d599fefc7620
child 27
22644e2572bc
equal deleted inserted replaced
25:3192553c0df1 26:59f147baea31
27 */ 27 */
28 28
29 #include <stdio.h> 29 #include <stdio.h>
30 #include <stdlib.h> 30 #include <stdlib.h>
31 31
32 #include "ucx/test.h"
33
32 #include "list_tests.h" 34 #include "list_tests.h"
33 #include "mpool_tests.h" 35 #include "mpool_tests.h"
34 #include "map_tests.h" 36 #include "map_tests.h"
35 37
38 UCX_TEST_BEGIN(testTestSuitePositive) {
39 UCX_TEST_ASSERT(2*2 == 4, "the test framework fails")
40 UCX_TEST_END
41 }
42
43 UCX_TEST_BEGIN(testTestSuiteNegative) {
44 UCX_TEST_ASSERT(2*(-2) == 4, "the test framework works")
45 UCX_TEST_END
46 }
47
36 int main(int argc, char **argv) { 48 int main(int argc, char **argv) {
37 printf("UCX Tests\n---------\n"); 49 printf("UCX Tests\n---------\n");
38 50
39 printf("\nUcxDlist Tests\n"); 51 printf("\nUcxTestSuite Tests\n");
40 if(dlist_tests()) { 52 UcxTestSuite* suite = ucx_test_suite_new();
41 fprintf(stderr, "dlist_tests failed\n"); 53 ucx_test_register(suite, testTestSuitePositive);
54 ucx_test_register(suite, testTestSuiteNegative);
55 ucx_test_run(suite, stdout);
56 if (suite->failure == 1 && suite->success == 1) {
57 ucx_test_suite_free(suite);
58
59 /* TODO: replace these tests with "real" tests */
60 printf("\nUcxDlist Tests\n");
61 if(dlist_tests()) {
62 fprintf(stderr, "dlist_tests failed\n");
63 }
64
65 printf("\nUcxList Tests\n Assumed to be correct\n");
66
67 printf("\nUcxMemPool Tests\n");
68 if(mpool_tests()) {
69 fprintf(stderr, "mpool_tests failed\n");
70 }
71
72 printf("\nUcxMap Tests\n");
73 if(map_tests()) {
74 fprintf(stderr, "map_tests failed\n");
75 }
76
77 return EXIT_SUCCESS;
78 } else {
79 ucx_test_suite_free(suite);
80 return EXIT_FAILURE;
42 } 81 }
43
44 printf("\nUcxList Tests\n Assumed to be correct\n");
45
46 printf("\nUcxMemPool Tests\n");
47 if(mpool_tests()) {
48 fprintf(stderr, "mpool_tests failed\n");
49 }
50
51 printf("\nUcxMap Tests\n");
52 if(map_tests()) {
53 fprintf(stderr, "map_tests failed\n");
54 }
55
56 return EXIT_SUCCESS;
57 } 82 }
58 83

mercurial