celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject [40/50] celix git commit: CELIX-237: add test for serializing char*
Date Thu, 29 Oct 2015 15:29:31 GMT
CELIX-237: add test for serializing char*


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

Branch: refs/heads/feature/CELIX-269_depman
Commit: e5dfdf5366575846a86b6cec65b137cf85e90b72
Parents: 5463a35
Author: Bjoern Petri <bpetri@apache.org>
Authored: Tue Oct 27 14:29:52 2015 +0100
Committer: Bjoern Petri <bpetri@apache.org>
Committed: Tue Oct 27 14:29:52 2015 +0100

----------------------------------------------------------------------
 .../json_serializer_tests.cpp                   | 33 +++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/e5dfdf53/remote_services/remote_service_admin_dfi/dynamic_function_interface_tst/json_serializer_tests.cpp
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_dfi/dynamic_function_interface_tst/json_serializer_tests.cpp
b/remote_services/remote_service_admin_dfi/dynamic_function_interface_tst/json_serializer_tests.cpp
index 1d64ad1..e20cea4 100644
--- a/remote_services/remote_service_admin_dfi/dynamic_function_interface_tst/json_serializer_tests.cpp
+++ b/remote_services/remote_service_admin_dfi/dynamic_function_interface_tst/json_serializer_tests.cpp
@@ -142,7 +142,7 @@ static void check_example4(void *data) {
 }
 
 
-/*********** example 4 ************************/
+/*********** example 5 ************************/
 /** structs within a struct (by reference)*******/
 const char *example5_descriptor = "Tleaf={ts name age};Tnode={Lnode;Lnode;Lleaf; left right
value};{Lnode; head}";
 
@@ -224,6 +224,22 @@ static void check_example6(struct ex6_sequence seq) {
 }
 
 
+/*********** example 7 ************************/
+const char *example7_descriptor = "{t a}";
+
+const char *example7_input = "{ \
+    \"a\" : \"apache celix\" \
+}";
+
+struct example7 {
+    char* a;   //0
+};
+
+static void check_example7(void *data) {
+    struct example7 *ex = (struct example7 *)data;
+    STRCMP_EQUAL("apache celix", ex->a);
+}
+
 static void parseTests(void) {
     dyn_type *type;
     void *inst;
@@ -288,6 +304,17 @@ static void parseTests(void) {
     check_example6((*seq));
     dynType_free(type, seq);
     dynType_destroy(type);
+
+
+    type = NULL;
+    inst = NULL;
+    rc = dynType_parseWithStr(example7_descriptor, NULL, NULL, &type);
+    CHECK_EQUAL(0, rc);
+    rc = jsonSerializer_deserialize(type, example7_input, &inst);
+    CHECK_EQUAL(0, rc);
+    check_example7(inst);
+    dynType_free(type, inst);
+    dynType_destroy(type);
 }
 
 const char *write_example1_descriptor = "{BSIJsijFDN a b c d e f g h i j}";
@@ -433,6 +460,8 @@ void writeTest3(void) {
     free(result);
 }
 
+
+
 }
 
 TEST_GROUP(JsonSerializerTests) {
@@ -460,3 +489,5 @@ TEST(JsonSerializerTests, WriteTest2) {
 TEST(JsonSerializerTests, WriteTest3) {
     writeTest3();
 }
+
+


Mime
View raw message