test/main.c

changeset 253
e19825a1430a
parent 252
6342cbbd1922
child 254
c45c385ac578
equal deleted inserted replaced
252:6342cbbd1922 253:e19825a1430a
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 UCX_EXTERN UCX_TEST(testTestSuitePositive) { 48 extern "C" {
49 UCX_TEST_BEGIN 49 UCX_TEST(testTestSuitePositive) {
50 UCX_TEST_ASSERT(2*2 == 4, "the test framework fails"); 50 UCX_TEST_BEGIN
51 UCX_TEST_END 51 UCX_TEST_ASSERT(2*2 == 4, "the test framework fails");
52 } 52 UCX_TEST_END
53 53 }
54 UCX_EXTERN UCX_TEST(testTestSuiteNegative) { 54
55 UCX_TEST_BEGIN 55 UCX_TEST(testTestSuiteNegative) {
56 UCX_TEST_ASSERT(2*(-2) == 4, "the test framework works"); 56 UCX_TEST_BEGIN
57 UCX_TEST_END 57 UCX_TEST_ASSERT(2*(-2) == 4, "the test framework works");
58 } 58 UCX_TEST_END
59 59 }
60 UCX_EXTERN UCX_TEST_SUBROUTINE(testTestSuiteRoutineRoutine, float f) { 60
61 UCX_TEST_ASSERT(f == 3.14f, "calling routine in a routine fails"); 61 UCX_TEST_SUBROUTINE(testTestSuiteRoutineRoutine, float f) {
62 } 62 UCX_TEST_ASSERT(f == 3.14f, "calling routine in a routine fails");
63 63 }
64 UCX_EXTERN UCX_TEST_SUBROUTINE(testTestSuiteRoutine2Param, int i, float f) { 64
65 UCX_TEST_ASSERT(i == 42, "two parameter routine fails"); 65 UCX_TEST_SUBROUTINE(testTestSuiteRoutine2Param, int i, float f) {
66 UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutineRoutine, f); 66 UCX_TEST_ASSERT(i == 42, "two parameter routine fails");
67 } 67 UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutineRoutine, f);
68 68 }
69 UCX_EXTERN UCX_TEST_SUBROUTINE(testTestSuiteRoutineSuccess, int* i) { 69
70 *i += 2; 70 UCX_TEST_SUBROUTINE(testTestSuiteRoutineSuccess, int* i) {
71 UCX_TEST_ASSERT(*i==4, "the test framework fails"); 71 *i += 2;
72 } 72 UCX_TEST_ASSERT(*i==4, "the test framework fails");
73 73 }
74 UCX_EXTERN UCX_TEST_SUBROUTINE(testTestSuiteRoutineFailure, int* i) { 74
75 *i += 2; 75 UCX_TEST_SUBROUTINE(testTestSuiteRoutineFailure, int* i) {
76 // Next test shall fail! 76 *i += 2;
77 UCX_TEST_ASSERT(*i==4, "the test framework works"); 77 // Next test shall fail!
78 } 78 UCX_TEST_ASSERT(*i==4, "the test framework works");
79 79 }
80 UCX_EXTERN UCX_TEST(testTestSuiteRoutinePositive) { 80
81 int i = 2; 81 UCX_TEST(testTestSuiteRoutinePositive) {
82 UCX_TEST_BEGIN 82 int i = 2;
83 UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutineSuccess, &i); 83 UCX_TEST_BEGIN
84 UCX_TEST_ASSERT(i==4, "the test framework fails"); 84 UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutineSuccess, &i);
85 UCX_TEST_END 85 UCX_TEST_ASSERT(i==4, "the test framework fails");
86 } 86 UCX_TEST_END
87 87 }
88 UCX_EXTERN UCX_TEST(testTestSuiteRoutineNegative) { 88
89 int i = 0; 89 UCX_TEST(testTestSuiteRoutineNegative) {
90 UCX_TEST_BEGIN 90 int i = 0;
91 UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutineFailure, &i); 91 UCX_TEST_BEGIN
92 UCX_TEST_ASSERT(1, "the test framework fails"); 92 UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutineFailure, &i);
93 UCX_TEST_END 93 UCX_TEST_ASSERT(1, "the test framework fails");
94 } 94 UCX_TEST_END
95 95 }
96 UCX_EXTERN UCX_TEST(testTestSuiteRoutineMultiparam) { 96
97 UCX_TEST_BEGIN 97 UCX_TEST(testTestSuiteRoutineMultiparam) {
98 UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutine2Param, 42, 3.14f); 98 UCX_TEST_BEGIN
99 UCX_TEST_END 99 UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutine2Param, 42, 3.14f);
100 UCX_TEST_END
101 }
100 } 102 }
101 103
102 int main(int argc, char **argv) { 104 int main(int argc, char **argv) {
103 printf("UCX Tests\n---------\n"); 105 printf("UCX Tests\n---------\n");
104 106

mercurial