aboutsummaryrefslogtreecommitdiff
path: root/tests/test_generate.c
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2014-05-24 23:40:39 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2014-05-24 23:40:39 +0000
commiteaa81a1805da0fde938c109a768e9c48471c3bb9 (patch)
tree11177c8667280f65b11e0c5d96830f43a8e5d860 /tests/test_generate.c
parentd4fc17b1e5ff64ea70cfb02594ae87f599f81c29 (diff)
downloadsrc-eaa81a1805da0fde938c109a768e9c48471c3bb9.tar.gz
src-eaa81a1805da0fde938c109a768e9c48471c3bb9.zip
Import libucl version 2014-05-14 (almost 0.4.1)vendor/libucl/20140514
This bring ucl_lookup_path (xpath like for ucl objects)
Notes
Notes: svn path=/vendor/libucl/dist/; revision=266634 svn path=/vendor/libucl/20140514/; revision=266635; tag=vendor/libucl/20140514
Diffstat (limited to 'tests/test_generate.c')
-rw-r--r--tests/test_generate.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/test_generate.c b/tests/test_generate.c
index 2b1bf8d73a3f..5c130e67499a 100644
--- a/tests/test_generate.c
+++ b/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);