celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject [12/50] [abbrv] celix git commit: CELIX-237: Added extra dyn function test for a output parameter
Date Tue, 13 Oct 2015 10:21:40 GMT
CELIX-237: Added extra dyn function test for a output parameter


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/fa527209
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/fa527209
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/fa527209

Branch: refs/heads/develop
Commit: fa527209f1e74b61d2d844a8d2b7f38f2b28659a
Parents: 30f7e84
Author: Pepijn Noltes <pepijnnoltes@gmail.com>
Authored: Tue Aug 11 19:01:44 2015 +0200
Committer: Pepijn Noltes <pepijnnoltes@gmail.com>
Committed: Tue Aug 11 19:01:44 2015 +0200

----------------------------------------------------------------------
 .../tst/dyn_function_tests.cpp                  | 41 ++++++++++++++++++++
 1 file changed, 41 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/fa527209/remote_services/remote_service_admin_dfi/dynamic_function_interface/tst/dyn_function_tests.cpp
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_dfi/dynamic_function_interface/tst/dyn_function_tests.cpp
b/remote_services/remote_service_admin_dfi/dynamic_function_interface/tst/dyn_function_tests.cpp
index 9b681de..868073b 100644
--- a/remote_services/remote_service_admin_dfi/dynamic_function_interface/tst/dyn_function_tests.cpp
+++ b/remote_services/remote_service_admin_dfi/dynamic_function_interface/tst/dyn_function_tests.cpp
@@ -120,6 +120,42 @@ extern "C" {
         dynFunction_destroy(dynFunc);
     }
 
+    //example with gen pointer and output
+    #define EXAMPLE3_DESCRIPTOR "example(PD*D)N"
+
+    static int testExample3(void *ptr, double a, double *out) {
+        double *b = (double *)ptr;
+        CHECK_EQUAL(2.0, *b)
+        CHECK_EQUAL(a, 2.0);
+        *out = *b * a;
+        printf("out is %p and *out is %f\n", out, *out);
+        return 0;
+    }
+
+    static void test_example3(void) {
+        dyn_function_type *dynFunc = NULL;
+        int rc;
+
+        rc = dynFunction_parseWithStr(EXAMPLE3_DESCRIPTOR, NULL, &dynFunc);
+        CHECK_EQUAL(0, rc);
+        double result = -1.0;
+        double *input = &result;
+        printf("\n");
+        printf("input is %p, &input is %p and *input is %d\n", input, &input, *input);
+        double a = 2.0;
+        void *ptr = &a;
+        void *args[3];
+        args[0] = &ptr;
+        args[1] = &a;
+        args[2] = &input;
+        void (*fp)(void) = (void(*)(void)) testExample3;
+
+        rc = dynFunction_call(dynFunc, fp, &result, args);
+        printf("input is %p, &input is %p and *input is %d\n", input, &input, *input);
+
+        CHECK_EQUAL(0, rc);
+        CHECK_EQUAL(4.0, result);
+    }
 
 }
 
@@ -141,4 +177,9 @@ TEST(DynFunctionTests, DynFuncTest2) {
 
 TEST(DynFunctionTests, DynFuncAccTest) {
     test_access_functions();
+}
+
+
+TEST(DynFunctionTests, DynFuncTest3) {
+    test_example3();
 }
\ No newline at end of file


Mime
View raw message