test/main.c

changeset 253
e19825a1430a
parent 252
6342cbbd1922
child 254
c45c385ac578
     1.1 --- a/test/main.c	Wed Oct 18 12:03:44 2017 +0200
     1.2 +++ b/test/main.c	Wed Oct 18 14:23:57 2017 +0200
     1.3 @@ -45,58 +45,60 @@
     1.4  #include "utils_tests.h"
     1.5  #include "avl_tests.h"
     1.6  
     1.7 -UCX_EXTERN UCX_TEST(testTestSuitePositive) {
     1.8 -    UCX_TEST_BEGIN
     1.9 -    UCX_TEST_ASSERT(2*2 == 4, "the test framework fails");
    1.10 -    UCX_TEST_END
    1.11 -}
    1.12 +extern "C" {
    1.13 +    UCX_TEST(testTestSuitePositive) {
    1.14 +        UCX_TEST_BEGIN
    1.15 +        UCX_TEST_ASSERT(2*2 == 4, "the test framework fails");
    1.16 +        UCX_TEST_END
    1.17 +    }
    1.18  
    1.19 -UCX_EXTERN UCX_TEST(testTestSuiteNegative) {
    1.20 -    UCX_TEST_BEGIN
    1.21 -    UCX_TEST_ASSERT(2*(-2) == 4, "the test framework works");
    1.22 -    UCX_TEST_END
    1.23 -}
    1.24 +    UCX_TEST(testTestSuiteNegative) {
    1.25 +        UCX_TEST_BEGIN
    1.26 +        UCX_TEST_ASSERT(2*(-2) == 4, "the test framework works");
    1.27 +        UCX_TEST_END
    1.28 +    }
    1.29  
    1.30 -UCX_EXTERN UCX_TEST_SUBROUTINE(testTestSuiteRoutineRoutine, float f) {
    1.31 -    UCX_TEST_ASSERT(f == 3.14f, "calling routine in a routine fails");
    1.32 -}
    1.33 +    UCX_TEST_SUBROUTINE(testTestSuiteRoutineRoutine, float f) {
    1.34 +        UCX_TEST_ASSERT(f == 3.14f, "calling routine in a routine fails");
    1.35 +    }
    1.36  
    1.37 -UCX_EXTERN UCX_TEST_SUBROUTINE(testTestSuiteRoutine2Param, int i, float f) {
    1.38 -    UCX_TEST_ASSERT(i == 42, "two parameter routine fails");
    1.39 -    UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutineRoutine, f);
    1.40 -}
    1.41 +    UCX_TEST_SUBROUTINE(testTestSuiteRoutine2Param, int i, float f) {
    1.42 +        UCX_TEST_ASSERT(i == 42, "two parameter routine fails");
    1.43 +        UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutineRoutine, f);
    1.44 +    }
    1.45  
    1.46 -UCX_EXTERN UCX_TEST_SUBROUTINE(testTestSuiteRoutineSuccess, int* i) {
    1.47 -    *i += 2;
    1.48 -    UCX_TEST_ASSERT(*i==4, "the test framework fails");
    1.49 -}
    1.50 +    UCX_TEST_SUBROUTINE(testTestSuiteRoutineSuccess, int* i) {
    1.51 +        *i += 2;
    1.52 +        UCX_TEST_ASSERT(*i==4, "the test framework fails");
    1.53 +    }
    1.54  
    1.55 -UCX_EXTERN UCX_TEST_SUBROUTINE(testTestSuiteRoutineFailure, int* i) {
    1.56 -    *i += 2;
    1.57 -    // Next test shall fail!
    1.58 -    UCX_TEST_ASSERT(*i==4, "the test framework works");
    1.59 -}
    1.60 +    UCX_TEST_SUBROUTINE(testTestSuiteRoutineFailure, int* i) {
    1.61 +        *i += 2;
    1.62 +        // Next test shall fail!
    1.63 +        UCX_TEST_ASSERT(*i==4, "the test framework works");
    1.64 +    }
    1.65  
    1.66 -UCX_EXTERN UCX_TEST(testTestSuiteRoutinePositive) {
    1.67 -    int i = 2;
    1.68 -    UCX_TEST_BEGIN
    1.69 -    UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutineSuccess, &i);
    1.70 -    UCX_TEST_ASSERT(i==4, "the test framework fails");
    1.71 -    UCX_TEST_END
    1.72 -}
    1.73 +    UCX_TEST(testTestSuiteRoutinePositive) {
    1.74 +        int i = 2;
    1.75 +        UCX_TEST_BEGIN
    1.76 +        UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutineSuccess, &i);
    1.77 +        UCX_TEST_ASSERT(i==4, "the test framework fails");
    1.78 +        UCX_TEST_END
    1.79 +    }
    1.80  
    1.81 -UCX_EXTERN UCX_TEST(testTestSuiteRoutineNegative) {
    1.82 -    int i = 0;
    1.83 -    UCX_TEST_BEGIN
    1.84 -    UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutineFailure, &i);
    1.85 -    UCX_TEST_ASSERT(1, "the test framework fails");
    1.86 -    UCX_TEST_END
    1.87 -}
    1.88 +    UCX_TEST(testTestSuiteRoutineNegative) {
    1.89 +        int i = 0;
    1.90 +        UCX_TEST_BEGIN
    1.91 +        UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutineFailure, &i);
    1.92 +        UCX_TEST_ASSERT(1, "the test framework fails");
    1.93 +        UCX_TEST_END
    1.94 +    }
    1.95  
    1.96 -UCX_EXTERN UCX_TEST(testTestSuiteRoutineMultiparam) {
    1.97 -    UCX_TEST_BEGIN
    1.98 -    UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutine2Param, 42, 3.14f);
    1.99 -    UCX_TEST_END
   1.100 +    UCX_TEST(testTestSuiteRoutineMultiparam) {
   1.101 +        UCX_TEST_BEGIN
   1.102 +        UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutine2Param, 42, 3.14f);
   1.103 +        UCX_TEST_END
   1.104 +    }   
   1.105  }
   1.106  
   1.107  int main(int argc, char **argv) {

mercurial