aboutsummaryrefslogtreecommitdiff
path: root/tests/test_generate.c
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2015-03-02 21:35:31 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2015-03-02 21:35:31 +0000
commit513f8791d85bbaf75cea6a942f689a9fc128805e (patch)
treeec41d84b201fb3620a1d96fc8d2c7fd86cef6b63 /tests/test_generate.c
parent1eea90048f8f0e6360171d254c1f60f41a090814 (diff)
downloadsrc-513f8791d85bbaf75cea6a942f689a9fc128805e.tar.gz
src-513f8791d85bbaf75cea6a942f689a9fc128805e.zip
Update libucl to git version 8d3b186
Notes
Notes: svn path=/vendor/libucl/dist/; revision=279546
Diffstat (limited to 'tests/test_generate.c')
-rw-r--r--tests/test_generate.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/tests/test_generate.c b/tests/test_generate.c
index aad92b51fb0e..f09eabb839fe 100644
--- a/tests/test_generate.c
+++ b/tests/test_generate.c
@@ -30,7 +30,8 @@ int
main (int argc, char **argv)
{
ucl_object_t *obj, *cur, *ar, *ref;
- const ucl_object_t *found;
+ ucl_object_iter_t it;
+ const ucl_object_t *found, *it_obj;
FILE *out;
unsigned char *emitted;
const char *fname_out = NULL;
@@ -59,7 +60,7 @@ main (int argc, char **argv)
cur = ucl_object_fromstring_common ("value1", 0, UCL_STRING_TRIM);
ucl_object_insert_key (obj, cur, "key0", 0, false);
cur = ucl_object_fromdouble (0.1);
- ucl_object_replace_key (obj, cur, "key0", 0, false);
+ assert (ucl_object_replace_key (obj, cur, "key0", 0, false));
/* Create some strings */
cur = ucl_object_fromstring_common (" test string ", 0, UCL_STRING_TRIM);
@@ -139,6 +140,33 @@ main (int argc, char **argv)
found = ucl_lookup_path (obj, "key9..key1");
assert (found == NULL);
+ /* Test iteration */
+ it = ucl_object_iterate_new (obj);
+ it_obj = ucl_object_iterate_safe (it, true);
+ /* key0 = 0.1 */
+ assert (ucl_object_type (it_obj) == UCL_FLOAT);
+ it_obj = ucl_object_iterate_safe (it, true);
+ /* key1 = "" */
+ assert (ucl_object_type (it_obj) == UCL_STRING);
+ it_obj = ucl_object_iterate_safe (it, true);
+ /* key2 = "" */
+ assert (ucl_object_type (it_obj) == UCL_STRING);
+ it_obj = ucl_object_iterate_safe (it, true);
+ /* key3 = "" */
+ assert (ucl_object_type (it_obj) == UCL_STRING);
+ it_obj = ucl_object_iterate_safe (it, true);
+ /* key4 = ([float, int, float], boolean) */
+ ucl_object_iterate_reset (it, it_obj);
+ it_obj = ucl_object_iterate_safe (it, true);
+ assert (ucl_object_type (it_obj) == UCL_FLOAT);
+ it_obj = ucl_object_iterate_safe (it, true);
+ assert (ucl_object_type (it_obj) == UCL_INT);
+ it_obj = ucl_object_iterate_safe (it, true);
+ assert (ucl_object_type (it_obj) == UCL_FLOAT);
+ it_obj = ucl_object_iterate_safe (it, true);
+ assert (ucl_object_type (it_obj) == UCL_BOOLEAN);
+ ucl_object_iterate_free (it);
+
emitted = ucl_object_emit (obj, UCL_EMIT_CONFIG);
fprintf (out, "%s\n", emitted);