diff options
author | bapt <bapt@FreeBSD.org> | 2014-05-24 23:46:41 +0000 |
---|---|---|
committer | bapt <bapt@FreeBSD.org> | 2014-05-24 23:46:41 +0000 |
commit | d66fac1ce6945cd9678282056da4d2f4fabb4adc (patch) | |
tree | d79bb7ef653c040679a51c1bace22f0fb236ccd4 /contrib/libucl/tests | |
parent | 51a05acc08355b84ae16b193ccb7037691f8ba90 (diff) | |
download | FreeBSD-src-d66fac1ce6945cd9678282056da4d2f4fabb4adc.zip FreeBSD-src-d66fac1ce6945cd9678282056da4d2f4fabb4adc.tar.gz |
merge libucl 20140514
this version brings xpath-like interface for ucl objects
Diffstat (limited to 'contrib/libucl/tests')
-rw-r--r-- | contrib/libucl/tests/test_generate.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/contrib/libucl/tests/test_generate.c b/contrib/libucl/tests/test_generate.c index 2b1bf8d..5c130e6 100644 --- a/contrib/libucl/tests/test_generate.c +++ b/contrib/libucl/tests/test_generate.c @@ -30,6 +30,7 @@ int main (int argc, char **argv) { ucl_object_t *obj, *cur, *ar, *ref; + const ucl_object_t *found; FILE *out; unsigned char *emitted; const char *fname_out = NULL; @@ -114,6 +115,23 @@ main (int argc, char **argv) cur = ucl_object_frombool (true); ucl_object_insert_key (obj, cur, "k=3", 0, false); + /* Try to find using path */ + /* Should exist */ + found = ucl_lookup_path (obj, "key4.1"); + assert (found != NULL && ucl_object_toint (found) == 10); + /* . should be ignored */ + found = ucl_lookup_path (obj, ".key4.1"); + assert (found != NULL && ucl_object_toint (found) == 10); + /* moar dots... */ + found = ucl_lookup_path (obj, ".key4........1..."); + assert (found != NULL && ucl_object_toint (found) == 10); + /* No such index */ + found = ucl_lookup_path (obj, ".key4.3"); + assert (found == NULL); + /* No such key */ + found = ucl_lookup_path (obj, "key9..key1"); + assert (found == NULL); + emitted = ucl_object_emit (obj, UCL_EMIT_CONFIG); fprintf (out, "%s\n", emitted); |