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
--- a/test/Makefile.am	Wed Oct 18 14:23:57 2017 +0200
+++ b/test/Makefile.am	Wed Oct 18 19:10:29 2017 +0200
@@ -1,5 +1,6 @@
 TESTS = ucxtest
 check_PROGRAMS = ucxtest
+ucxtest_CFLAGS = -I$(top_srcdir)/src
 ucxtest_SOURCES = main.c
 ucxtest_SOURCES += allocator_tests.c
 ucxtest_SOURCES += list_tests.c
@@ -13,4 +14,3 @@
 ucxtest_SOURCES += buffer_tests.c
 ucxtest_SOURCES += utils_tests.c
 ucxtest_LDADD = ../src/libucx.la
-
--- a/test/main.c	Wed Oct 18 14:23:57 2017 +0200
+++ b/test/main.c	Wed Oct 18 19:10:29 2017 +0200
@@ -45,61 +45,65 @@
 #include "utils_tests.h"
 #include "avl_tests.h"
 
+#ifdef __cplusplus
 extern "C" {
-    UCX_TEST(testTestSuitePositive) {
-        UCX_TEST_BEGIN
-        UCX_TEST_ASSERT(2*2 == 4, "the test framework fails");
-        UCX_TEST_END
-    }
-
-    UCX_TEST(testTestSuiteNegative) {
-        UCX_TEST_BEGIN
-        UCX_TEST_ASSERT(2*(-2) == 4, "the test framework works");
-        UCX_TEST_END
-    }
+#endif
+UCX_TEST(testTestSuitePositive) {
+    UCX_TEST_BEGIN
+    UCX_TEST_ASSERT(2*2 == 4, "the test framework fails");
+    UCX_TEST_END
+}
 
-    UCX_TEST_SUBROUTINE(testTestSuiteRoutineRoutine, float f) {
-        UCX_TEST_ASSERT(f == 3.14f, "calling routine in a routine fails");
-    }
+UCX_TEST(testTestSuiteNegative) {
+    UCX_TEST_BEGIN
+    UCX_TEST_ASSERT(2*(-2) == 4, "the test framework works");
+    UCX_TEST_END
+}
+
+UCX_TEST_SUBROUTINE(testTestSuiteRoutineRoutine, float f) {
+    UCX_TEST_ASSERT(f == 3.14f, "calling routine in a routine fails");
+}
 
-    UCX_TEST_SUBROUTINE(testTestSuiteRoutine2Param, int i, float f) {
-        UCX_TEST_ASSERT(i == 42, "two parameter routine fails");
-        UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutineRoutine, f);
-    }
+UCX_TEST_SUBROUTINE(testTestSuiteRoutine2Param, int i, float f) {
+    UCX_TEST_ASSERT(i == 42, "two parameter routine fails");
+    UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutineRoutine, f);
+}
 
-    UCX_TEST_SUBROUTINE(testTestSuiteRoutineSuccess, int* i) {
-        *i += 2;
-        UCX_TEST_ASSERT(*i==4, "the test framework fails");
-    }
+UCX_TEST_SUBROUTINE(testTestSuiteRoutineSuccess, int* i) {
+    *i += 2;
+    UCX_TEST_ASSERT(*i==4, "the test framework fails");
+}
 
-    UCX_TEST_SUBROUTINE(testTestSuiteRoutineFailure, int* i) {
-        *i += 2;
-        // Next test shall fail!
-        UCX_TEST_ASSERT(*i==4, "the test framework works");
-    }
+UCX_TEST_SUBROUTINE(testTestSuiteRoutineFailure, int* i) {
+    *i += 2;
+    // Next test shall fail!
+    UCX_TEST_ASSERT(*i==4, "the test framework works");
+}
 
-    UCX_TEST(testTestSuiteRoutinePositive) {
-        int i = 2;
-        UCX_TEST_BEGIN
-        UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutineSuccess, &i);
-        UCX_TEST_ASSERT(i==4, "the test framework fails");
-        UCX_TEST_END
-    }
+UCX_TEST(testTestSuiteRoutinePositive) {
+    int i = 2;
+    UCX_TEST_BEGIN
+    UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutineSuccess, &i);
+    UCX_TEST_ASSERT(i==4, "the test framework fails");
+    UCX_TEST_END
+}
 
-    UCX_TEST(testTestSuiteRoutineNegative) {
-        int i = 0;
-        UCX_TEST_BEGIN
-        UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutineFailure, &i);
-        UCX_TEST_ASSERT(1, "the test framework fails");
-        UCX_TEST_END
-    }
+UCX_TEST(testTestSuiteRoutineNegative) {
+    int i = 0;
+    UCX_TEST_BEGIN
+    UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutineFailure, &i);
+    UCX_TEST_ASSERT(1, "the test framework fails");
+    UCX_TEST_END
+}
 
-    UCX_TEST(testTestSuiteRoutineMultiparam) {
-        UCX_TEST_BEGIN
-        UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutine2Param, 42, 3.14f);
-        UCX_TEST_END
-    }   
+UCX_TEST(testTestSuiteRoutineMultiparam) {
+    UCX_TEST_BEGIN
+    UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutine2Param, 42, 3.14f);
+    UCX_TEST_END
 }
+#ifdef __cplusplus
+}
+#endif
 
 int main(int argc, char **argv) {
     printf("UCX Tests\n---------\n");

mercurial