43 #include "prop_tests.h" |
43 #include "prop_tests.h" |
44 #include "buffer_tests.h" |
44 #include "buffer_tests.h" |
45 #include "utils_tests.h" |
45 #include "utils_tests.h" |
46 #include "avl_tests.h" |
46 #include "avl_tests.h" |
47 |
47 |
|
48 #ifdef __cplusplus |
48 extern "C" { |
49 extern "C" { |
49 UCX_TEST(testTestSuitePositive) { |
50 #endif |
50 UCX_TEST_BEGIN |
51 UCX_TEST(testTestSuitePositive) { |
51 UCX_TEST_ASSERT(2*2 == 4, "the test framework fails"); |
52 UCX_TEST_BEGIN |
52 UCX_TEST_END |
53 UCX_TEST_ASSERT(2*2 == 4, "the test framework fails"); |
53 } |
54 UCX_TEST_END |
54 |
55 } |
55 UCX_TEST(testTestSuiteNegative) { |
56 |
56 UCX_TEST_BEGIN |
57 UCX_TEST(testTestSuiteNegative) { |
57 UCX_TEST_ASSERT(2*(-2) == 4, "the test framework works"); |
58 UCX_TEST_BEGIN |
58 UCX_TEST_END |
59 UCX_TEST_ASSERT(2*(-2) == 4, "the test framework works"); |
59 } |
60 UCX_TEST_END |
60 |
61 } |
61 UCX_TEST_SUBROUTINE(testTestSuiteRoutineRoutine, float f) { |
62 |
62 UCX_TEST_ASSERT(f == 3.14f, "calling routine in a routine fails"); |
63 UCX_TEST_SUBROUTINE(testTestSuiteRoutineRoutine, float f) { |
63 } |
64 UCX_TEST_ASSERT(f == 3.14f, "calling routine in a routine fails"); |
64 |
65 } |
65 UCX_TEST_SUBROUTINE(testTestSuiteRoutine2Param, int i, float f) { |
66 |
66 UCX_TEST_ASSERT(i == 42, "two parameter routine fails"); |
67 UCX_TEST_SUBROUTINE(testTestSuiteRoutine2Param, int i, float f) { |
67 UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutineRoutine, f); |
68 UCX_TEST_ASSERT(i == 42, "two parameter routine fails"); |
68 } |
69 UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutineRoutine, f); |
69 |
70 } |
70 UCX_TEST_SUBROUTINE(testTestSuiteRoutineSuccess, int* i) { |
71 |
71 *i += 2; |
72 UCX_TEST_SUBROUTINE(testTestSuiteRoutineSuccess, int* i) { |
72 UCX_TEST_ASSERT(*i==4, "the test framework fails"); |
73 *i += 2; |
73 } |
74 UCX_TEST_ASSERT(*i==4, "the test framework fails"); |
74 |
75 } |
75 UCX_TEST_SUBROUTINE(testTestSuiteRoutineFailure, int* i) { |
76 |
76 *i += 2; |
77 UCX_TEST_SUBROUTINE(testTestSuiteRoutineFailure, int* i) { |
77 // Next test shall fail! |
78 *i += 2; |
78 UCX_TEST_ASSERT(*i==4, "the test framework works"); |
79 // Next test shall fail! |
79 } |
80 UCX_TEST_ASSERT(*i==4, "the test framework works"); |
80 |
81 } |
81 UCX_TEST(testTestSuiteRoutinePositive) { |
82 |
82 int i = 2; |
83 UCX_TEST(testTestSuiteRoutinePositive) { |
83 UCX_TEST_BEGIN |
84 int i = 2; |
84 UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutineSuccess, &i); |
85 UCX_TEST_BEGIN |
85 UCX_TEST_ASSERT(i==4, "the test framework fails"); |
86 UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutineSuccess, &i); |
86 UCX_TEST_END |
87 UCX_TEST_ASSERT(i==4, "the test framework fails"); |
87 } |
88 UCX_TEST_END |
88 |
89 } |
89 UCX_TEST(testTestSuiteRoutineNegative) { |
90 |
90 int i = 0; |
91 UCX_TEST(testTestSuiteRoutineNegative) { |
91 UCX_TEST_BEGIN |
92 int i = 0; |
92 UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutineFailure, &i); |
93 UCX_TEST_BEGIN |
93 UCX_TEST_ASSERT(1, "the test framework fails"); |
94 UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutineFailure, &i); |
94 UCX_TEST_END |
95 UCX_TEST_ASSERT(1, "the test framework fails"); |
95 } |
96 UCX_TEST_END |
96 |
97 } |
97 UCX_TEST(testTestSuiteRoutineMultiparam) { |
98 |
98 UCX_TEST_BEGIN |
99 UCX_TEST(testTestSuiteRoutineMultiparam) { |
99 UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutine2Param, 42, 3.14f); |
100 UCX_TEST_BEGIN |
100 UCX_TEST_END |
101 UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutine2Param, 42, 3.14f); |
101 } |
102 UCX_TEST_END |
102 } |
103 } |
|
104 #ifdef __cplusplus |
|
105 } |
|
106 #endif |
103 |
107 |
104 int main(int argc, char **argv) { |
108 int main(int argc, char **argv) { |
105 printf("UCX Tests\n---------\n"); |
109 printf("UCX Tests\n---------\n"); |
106 |
110 |
107 printf("\nUcxTestSuite tests (2 failures are intended!)\n"); |
111 printf("\nUcxTestSuite tests (2 failures are intended!)\n"); |