fixes include path and non-cpp build for test program

Wed, 18 Oct 2017 19:10:29 +0200

author
Mike Becker <universe@uap-core.de>
date
Wed, 18 Oct 2017 19:10:29 +0200
changeset 254
c45c385ac578
parent 253
e19825a1430a
child 255
92c22c0fa8e8

fixes include path and non-cpp build for test program

test/Makefile.am file | annotate | diff | comparison | revisions
test/main.c file | annotate | diff | comparison | revisions
     1.1 --- a/test/Makefile.am	Wed Oct 18 14:23:57 2017 +0200
     1.2 +++ b/test/Makefile.am	Wed Oct 18 19:10:29 2017 +0200
     1.3 @@ -1,5 +1,6 @@
     1.4  TESTS = ucxtest
     1.5  check_PROGRAMS = ucxtest
     1.6 +ucxtest_CFLAGS = -I$(top_srcdir)/src
     1.7  ucxtest_SOURCES = main.c
     1.8  ucxtest_SOURCES += allocator_tests.c
     1.9  ucxtest_SOURCES += list_tests.c
    1.10 @@ -13,4 +14,3 @@
    1.11  ucxtest_SOURCES += buffer_tests.c
    1.12  ucxtest_SOURCES += utils_tests.c
    1.13  ucxtest_LDADD = ../src/libucx.la
    1.14 -
     2.1 --- a/test/main.c	Wed Oct 18 14:23:57 2017 +0200
     2.2 +++ b/test/main.c	Wed Oct 18 19:10:29 2017 +0200
     2.3 @@ -45,61 +45,65 @@
     2.4  #include "utils_tests.h"
     2.5  #include "avl_tests.h"
     2.6  
     2.7 +#ifdef __cplusplus
     2.8  extern "C" {
     2.9 -    UCX_TEST(testTestSuitePositive) {
    2.10 -        UCX_TEST_BEGIN
    2.11 -        UCX_TEST_ASSERT(2*2 == 4, "the test framework fails");
    2.12 -        UCX_TEST_END
    2.13 -    }
    2.14 +#endif
    2.15 +UCX_TEST(testTestSuitePositive) {
    2.16 +    UCX_TEST_BEGIN
    2.17 +    UCX_TEST_ASSERT(2*2 == 4, "the test framework fails");
    2.18 +    UCX_TEST_END
    2.19 +}
    2.20  
    2.21 -    UCX_TEST(testTestSuiteNegative) {
    2.22 -        UCX_TEST_BEGIN
    2.23 -        UCX_TEST_ASSERT(2*(-2) == 4, "the test framework works");
    2.24 -        UCX_TEST_END
    2.25 -    }
    2.26 +UCX_TEST(testTestSuiteNegative) {
    2.27 +    UCX_TEST_BEGIN
    2.28 +    UCX_TEST_ASSERT(2*(-2) == 4, "the test framework works");
    2.29 +    UCX_TEST_END
    2.30 +}
    2.31  
    2.32 -    UCX_TEST_SUBROUTINE(testTestSuiteRoutineRoutine, float f) {
    2.33 -        UCX_TEST_ASSERT(f == 3.14f, "calling routine in a routine fails");
    2.34 -    }
    2.35 +UCX_TEST_SUBROUTINE(testTestSuiteRoutineRoutine, float f) {
    2.36 +    UCX_TEST_ASSERT(f == 3.14f, "calling routine in a routine fails");
    2.37 +}
    2.38  
    2.39 -    UCX_TEST_SUBROUTINE(testTestSuiteRoutine2Param, int i, float f) {
    2.40 -        UCX_TEST_ASSERT(i == 42, "two parameter routine fails");
    2.41 -        UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutineRoutine, f);
    2.42 -    }
    2.43 +UCX_TEST_SUBROUTINE(testTestSuiteRoutine2Param, int i, float f) {
    2.44 +    UCX_TEST_ASSERT(i == 42, "two parameter routine fails");
    2.45 +    UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutineRoutine, f);
    2.46 +}
    2.47  
    2.48 -    UCX_TEST_SUBROUTINE(testTestSuiteRoutineSuccess, int* i) {
    2.49 -        *i += 2;
    2.50 -        UCX_TEST_ASSERT(*i==4, "the test framework fails");
    2.51 -    }
    2.52 +UCX_TEST_SUBROUTINE(testTestSuiteRoutineSuccess, int* i) {
    2.53 +    *i += 2;
    2.54 +    UCX_TEST_ASSERT(*i==4, "the test framework fails");
    2.55 +}
    2.56  
    2.57 -    UCX_TEST_SUBROUTINE(testTestSuiteRoutineFailure, int* i) {
    2.58 -        *i += 2;
    2.59 -        // Next test shall fail!
    2.60 -        UCX_TEST_ASSERT(*i==4, "the test framework works");
    2.61 -    }
    2.62 +UCX_TEST_SUBROUTINE(testTestSuiteRoutineFailure, int* i) {
    2.63 +    *i += 2;
    2.64 +    // Next test shall fail!
    2.65 +    UCX_TEST_ASSERT(*i==4, "the test framework works");
    2.66 +}
    2.67  
    2.68 -    UCX_TEST(testTestSuiteRoutinePositive) {
    2.69 -        int i = 2;
    2.70 -        UCX_TEST_BEGIN
    2.71 -        UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutineSuccess, &i);
    2.72 -        UCX_TEST_ASSERT(i==4, "the test framework fails");
    2.73 -        UCX_TEST_END
    2.74 -    }
    2.75 +UCX_TEST(testTestSuiteRoutinePositive) {
    2.76 +    int i = 2;
    2.77 +    UCX_TEST_BEGIN
    2.78 +    UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutineSuccess, &i);
    2.79 +    UCX_TEST_ASSERT(i==4, "the test framework fails");
    2.80 +    UCX_TEST_END
    2.81 +}
    2.82  
    2.83 -    UCX_TEST(testTestSuiteRoutineNegative) {
    2.84 -        int i = 0;
    2.85 -        UCX_TEST_BEGIN
    2.86 -        UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutineFailure, &i);
    2.87 -        UCX_TEST_ASSERT(1, "the test framework fails");
    2.88 -        UCX_TEST_END
    2.89 -    }
    2.90 +UCX_TEST(testTestSuiteRoutineNegative) {
    2.91 +    int i = 0;
    2.92 +    UCX_TEST_BEGIN
    2.93 +    UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutineFailure, &i);
    2.94 +    UCX_TEST_ASSERT(1, "the test framework fails");
    2.95 +    UCX_TEST_END
    2.96 +}
    2.97  
    2.98 -    UCX_TEST(testTestSuiteRoutineMultiparam) {
    2.99 -        UCX_TEST_BEGIN
   2.100 -        UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutine2Param, 42, 3.14f);
   2.101 -        UCX_TEST_END
   2.102 -    }   
   2.103 +UCX_TEST(testTestSuiteRoutineMultiparam) {
   2.104 +    UCX_TEST_BEGIN
   2.105 +    UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutine2Param, 42, 3.14f);
   2.106 +    UCX_TEST_END
   2.107  }
   2.108 +#ifdef __cplusplus
   2.109 +}
   2.110 +#endif
   2.111  
   2.112  int main(int argc, char **argv) {
   2.113      printf("UCX Tests\n---------\n");

mercurial