63 UCX_TEST_BEGIN |
63 UCX_TEST_BEGIN |
64 UCX_TEST_ASSERT(2*(-2) == 4, "the test framework works"); |
64 UCX_TEST_ASSERT(2*(-2) == 4, "the test framework works"); |
65 UCX_TEST_END |
65 UCX_TEST_END |
66 } |
66 } |
67 |
67 |
68 UCX_TEST_SUBROUTINE(testTestSuiteRoutineSuccess,field) { |
68 UCX_TEST_SUBROUTINE(testTestSuiteRoutineRoutine, float f) { |
69 int* i = (int*) field; |
69 UCX_TEST_ASSERT(f == 3.14f, "calling routine in a routine fails"); |
|
70 } |
|
71 |
|
72 UCX_TEST_SUBROUTINE(testTestSuiteRoutine2Param, int i, float f) { |
|
73 UCX_TEST_ASSERT(i == 42, "two parameter routine fails"); |
|
74 UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutineRoutine, f); |
|
75 } |
|
76 |
|
77 UCX_TEST_SUBROUTINE(testTestSuiteRoutineSuccess, int* i) { |
70 *i += 2; |
78 *i += 2; |
71 UCX_TEST_ASSERT(*i==4, "the test framework fails"); |
79 UCX_TEST_ASSERT(*i==4, "the test framework fails"); |
72 } |
80 } |
73 |
81 |
74 UCX_TEST_SUBROUTINE(testTestSuiteRoutineFailure,field) { |
82 UCX_TEST_SUBROUTINE(testTestSuiteRoutineFailure, int* i) { |
75 int* i = (int*) field; |
|
76 *i += 2; |
83 *i += 2; |
|
84 // Next test shall fail! |
77 UCX_TEST_ASSERT(*i==4, "the test framework works"); |
85 UCX_TEST_ASSERT(*i==4, "the test framework works"); |
78 } |
86 } |
79 |
87 |
80 UCX_TEST_IMPLEMENT(testTestSuiteRoutinePositive) { |
88 UCX_TEST_IMPLEMENT(testTestSuiteRoutinePositive) { |
81 int i = 2; |
89 int i = 2; |
88 UCX_TEST_IMPLEMENT(testTestSuiteRoutineNegative) { |
96 UCX_TEST_IMPLEMENT(testTestSuiteRoutineNegative) { |
89 int i = 0; |
97 int i = 0; |
90 UCX_TEST_BEGIN |
98 UCX_TEST_BEGIN |
91 UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutineFailure, &i); |
99 UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutineFailure, &i); |
92 UCX_TEST_ASSERT(1, "the test framework fails"); |
100 UCX_TEST_ASSERT(1, "the test framework fails"); |
|
101 UCX_TEST_END |
|
102 } |
|
103 |
|
104 UCX_TEST_IMPLEMENT(testTestSuiteRoutineMultiparam) { |
|
105 UCX_TEST_BEGIN |
|
106 UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutine2Param, 42, 3.14f); |
93 UCX_TEST_END |
107 UCX_TEST_END |
94 } |
108 } |
95 |
109 |
96 int main(int argc, char **argv) { |
110 int main(int argc, char **argv) { |
97 printf("UCX Tests\n---------\n"); |
111 printf("UCX Tests\n---------\n"); |
100 UcxTestSuite* suite = ucx_test_suite_new(); |
114 UcxTestSuite* suite = ucx_test_suite_new(); |
101 ucx_test_register(suite, testTestSuitePositive); |
115 ucx_test_register(suite, testTestSuitePositive); |
102 ucx_test_register(suite, testTestSuiteNegative); |
116 ucx_test_register(suite, testTestSuiteNegative); |
103 ucx_test_register(suite, testTestSuiteRoutinePositive); |
117 ucx_test_register(suite, testTestSuiteRoutinePositive); |
104 ucx_test_register(suite, testTestSuiteRoutineNegative); |
118 ucx_test_register(suite, testTestSuiteRoutineNegative); |
|
119 ucx_test_register(suite, testTestSuiteRoutineMultiparam); |
105 ucx_test_run(suite, stdout); |
120 ucx_test_run(suite, stdout); |
106 if (suite->failure == 2 && suite->success == 2) { |
121 if (suite->failure == 2 && suite->success == 3) { |
107 ucx_test_suite_free(suite); |
122 ucx_test_suite_free(suite); |
108 |
123 |
109 printf("\nLibrary function tests\n"); |
124 printf("\nLibrary function tests\n"); |
110 suite = ucx_test_suite_new(); |
125 suite = ucx_test_suite_new(); |
111 /* UcxLogger Tests */ |
126 /* UcxLogger Tests */ |