aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKatharina Fey <kookie@spacekookie.de>2016-08-30 22:10:54 +0200
committerKatharina Fey <kookie@spacekookie.de>2019-06-04 20:21:03 +0200
commitecc9349e6ea6b2b779c30ef41f8f2354d1ad8566 (patch)
treec2abb9aba0e13ba5271608a5e1a185d52c3e6497
parent60441671a612552d47b23841b44135593806468a (diff)
Updating the examples a little
-rw-r--r--lib/dyn_utils.c3
-rw-r--r--test/main.c65
2 files changed, 12 insertions, 56 deletions
diff --git a/lib/dyn_utils.c b/lib/dyn_utils.c
index b614634..6912dd2 100644
--- a/lib/dyn_utils.c
+++ b/lib/dyn_utils.c
@@ -153,8 +153,7 @@ dt_err dtree_decode_json(dtree *(*data), const char *jd)
dtree_malloc(&new_root);
if(ctr < 0) {
- parents[0] = new_root;
- ctr = 0;
+ parents[ctr = 0] = new_root;
} else {
dtree_addlist(parents[ctr], &new_root);
parents[++ctr] = new_root;
diff --git a/test/main.c b/test/main.c
index e551d4f..02e871b 100644
--- a/test/main.c
+++ b/test/main.c
@@ -25,40 +25,21 @@ dt_err test_shortcut_functions();
int main(void)
{
- dt_err err;
+ dt_err err = SUCCESS;
printf("=== libdyntree test suite ===\n");
-// /* Search inside trees */
-// TEST(search_for_payload())
-//
-// /* Split and merge trees */
-// TEST(split_and_merge())
-//
-// /* Test shortcut functions */
-// TEST(test_shortcut_functions())
-//
-// /* Try to encode a structure into json */
-// char json[512]; // Provide a buffer that is big enough
-// TEST(json_encode(json))
-//
-// printf("\n\nJson string: %s\n", json);
-//
-// dtree *data;
-// dtree_decode_json(&data, json);
-// dtree_free(data);
-
- dtree *root, *child, *key, *val;
- dtree_malloc(&root);
- dtree_addlist(root, &child);
- dtree_addpair(child, &key, &val);
- dtree_addliteral(key, "server");
- dtree_addliteral(val, "github.com");
-
- dtree *copy;
- dtree_copy_deep(root, &copy);
+ TEST(split_and_merge())
+
+ TEST(search_for_payload())
+
+ char json[1024];
+ TEST(json_encode(json))
+
+ dtree *recover;
+ dtree_decode_json(&recover, json);
+ dtree_free(recover);
end:
- exit:
printf("==== done ====\n");
return err;
}
@@ -213,27 +194,3 @@ dt_err json_encode(char *json) {
dtree_free(root);
return err;
}
-
-dt_err test_shortcut_functions()
-{
- dtree *key, *val;
- dtree *root = dtree_allocpair_new(&key, &val);
-
- dtree_addliteral(key, "Address");
- dtree_addliteral(val, "Berlin 10555");
-
-// dtree *list_root;
-// dtree **list = dtree_alloc_listlist(&list_root, 4); // Allocate 4 nodes
-//
-// int i;
-// for(i = 0; i < 4; i++){
-// char message[32];
-// sprintf(message, "Message no.%d", i);
-// dtree_addliteral(list[i], message);
-// }
-//
-// dtree_merge_trees(val, list_root);
-
- dtree_free(root);
- return SUCCESS; // We think
-} \ No newline at end of file