diff options
| author | Baptiste Daroussin <bapt@FreeBSD.org> | 2014-11-29 00:33:10 +0000 |
|---|---|---|
| committer | Baptiste Daroussin <bapt@FreeBSD.org> | 2014-11-29 00:33:10 +0000 |
| commit | 1eea90048f8f0e6360171d254c1f60f41a090814 (patch) | |
| tree | 4aae5869b82bf4066989c1dce79dc9f06fa9526b /tests | |
| parent | 8f2b0cccb4a7a7fe296db2f59cb6cdbfbec9291b (diff) | |
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/Makefile.am | 2 | ||||
| -rw-r--r-- | tests/basic/12.in | 2 | ||||
| -rw-r--r-- | tests/basic/12.res | 3 | ||||
| -rw-r--r-- | tests/basic/13.in | 9 | ||||
| -rw-r--r-- | tests/basic/13.res | 8 | ||||
| -rw-r--r-- | tests/basic/4.res | 22 | ||||
| -rw-r--r-- | tests/basic/comments.in | 25 | ||||
| -rw-r--r-- | tests/basic/comments.res | 7 | ||||
| -rw-r--r-- | tests/basic/include_dir/invalid.conf | 1 | ||||
| -rw-r--r-- | tests/basic/include_dir/pri1.conf | 2 | ||||
| -rw-r--r-- | tests/basic/include_dir/pri2.conf | 2 | ||||
| -rw-r--r-- | tests/basic/include_dir/test1.conf | 1 | ||||
| -rw-r--r-- | tests/basic/include_dir/test2.conf | 1 | ||||
| -rw-r--r-- | tests/basic/include_dir/test3.conf | 1 | ||||
| -rw-r--r-- | tests/generate.res | 1 | ||||
| -rw-r--r-- | tests/test_basic.c | 4 | ||||
| -rw-r--r-- | tests/test_generate.c | 7 | ||||
| -rw-r--r-- | tests/test_schema.c | 2 |
18 files changed, 94 insertions, 6 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index a21a65c16534..5b17e1fb252e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,4 +1,4 @@ -EXTRA_DIST = $(TESTS) basic schema generate.res rcl_test.json.xz +EXTRA_DIST = $(TESTS) basic schema generate.res streamline.res rcl_test.json.xz TESTS = basic.test \ generate.test \ diff --git a/tests/basic/12.in b/tests/basic/12.in new file mode 100644 index 000000000000..b63a32fbf92d --- /dev/null +++ b/tests/basic/12.in @@ -0,0 +1,2 @@ +key1: 12 , +key2: 12 value diff --git a/tests/basic/12.res b/tests/basic/12.res new file mode 100644 index 000000000000..163af46c7f17 --- /dev/null +++ b/tests/basic/12.res @@ -0,0 +1,3 @@ +key1 = 12; +key2 = "12 value"; + diff --git a/tests/basic/13.in b/tests/basic/13.in new file mode 100644 index 000000000000..81f03a61d286 --- /dev/null +++ b/tests/basic/13.in @@ -0,0 +1,9 @@ +key = value_orig; + +# test glob +.include(glob=true) "${CURDIR}/include_dir/test*.conf" + +.include(priority=1) "${CURDIR}/include_dir/pri1.conf" +.include(priority=2) "${CURDIR}/include_dir/pri2.conf" + +.include(try=true) "${CURDIR}/include_dir/invalid.conf" diff --git a/tests/basic/13.res b/tests/basic/13.res new file mode 100644 index 000000000000..aa13a5471f2e --- /dev/null +++ b/tests/basic/13.res @@ -0,0 +1,8 @@ +key = "value_orig"; +key = "value1"; +key = "value2"; +key = "value3"; +key_pri = "priority2"; +key_trace1 = "pri1"; +key_trace2 = "pri2"; + diff --git a/tests/basic/4.res b/tests/basic/4.res index 58c3599432b8..2b862fc1410a 100644 --- a/tests/basic/4.res +++ b/tests/basic/4.res @@ -10,7 +10,14 @@ licenses [ "BSD", ] flatsize = 60523; -desc = "pkgconf is a program which helps to configure compiler and linker flags for\ndevelopment frameworks. It is similar to pkg-config, but was written from\nscratch in Summer of 2011 to replace pkg-config, which now needs itself to build\nitself.\n\nWWW: https://github.com/pkgconf/pkgconf"; +desc = <<EOD +pkgconf is a program which helps to configure compiler and linker flags for +development frameworks. It is similar to pkg-config, but was written from +scratch in Summer of 2011 to replace pkg-config, which now needs itself to build +itself. + +WWW: https://github.com/pkgconf/pkgconf +EOD; categories [ "devel", ] @@ -31,6 +38,17 @@ scripts { pre-deinstall = "cd /usr/local\nn"; post-deinstall = "cd /usr/local\nn"; } -multiline-key = "test\ntest\ntest\\n\n/* comment like */\n# Some invalid endings\n EOD\nEOD \nEOF\n# Valid ending + empty string\n"; +multiline-key = <<EOD +test +test +test\n +/* comment like */ +# Some invalid endings + EOD +EOD +EOF +# Valid ending + empty string + +EOD; normal-key = "<<EODnot"; diff --git a/tests/basic/comments.in b/tests/basic/comments.in new file mode 100644 index 000000000000..3144fa004fa2 --- /dev/null +++ b/tests/basic/comments.in @@ -0,0 +1,25 @@ +# This test is intended to check various comments in ucl + +obj { + + key = value + key = "/* value" + /* + key = value + */ +# Nested comments + key = nested + /* + adasdasdads + /* asdasdasd */asjdasjldaskd + /* asdsadasd */ + /* /* /* /* /* */ */ */ */ */ +# some + */ + key = quotes # quoted +# Quotes + /* + key = "/* value" + key = "*/value" + */ +} diff --git a/tests/basic/comments.res b/tests/basic/comments.res new file mode 100644 index 000000000000..4c3a79714170 --- /dev/null +++ b/tests/basic/comments.res @@ -0,0 +1,7 @@ +obj { + key = "value"; + key = "/* value"; + key = "nested"; + key = "quotes"; +} + diff --git a/tests/basic/include_dir/invalid.conf b/tests/basic/include_dir/invalid.conf new file mode 100644 index 000000000000..c3267cb244e9 --- /dev/null +++ b/tests/basic/include_dir/invalid.conf @@ -0,0 +1 @@ +@@@@ BAD UCL ~~~~ diff --git a/tests/basic/include_dir/pri1.conf b/tests/basic/include_dir/pri1.conf new file mode 100644 index 000000000000..d21843367319 --- /dev/null +++ b/tests/basic/include_dir/pri1.conf @@ -0,0 +1,2 @@ +key_pri = priority1; +key_trace1 = pri1; diff --git a/tests/basic/include_dir/pri2.conf b/tests/basic/include_dir/pri2.conf new file mode 100644 index 000000000000..ee734a82836f --- /dev/null +++ b/tests/basic/include_dir/pri2.conf @@ -0,0 +1,2 @@ +key_pri = priority2; +key_trace2 = pri2; diff --git a/tests/basic/include_dir/test1.conf b/tests/basic/include_dir/test1.conf new file mode 100644 index 000000000000..61f290659a2f --- /dev/null +++ b/tests/basic/include_dir/test1.conf @@ -0,0 +1 @@ +key = value1; diff --git a/tests/basic/include_dir/test2.conf b/tests/basic/include_dir/test2.conf new file mode 100644 index 000000000000..0b5542792376 --- /dev/null +++ b/tests/basic/include_dir/test2.conf @@ -0,0 +1 @@ +key = value2; diff --git a/tests/basic/include_dir/test3.conf b/tests/basic/include_dir/test3.conf new file mode 100644 index 000000000000..3ceb7dd492d2 --- /dev/null +++ b/tests/basic/include_dir/test3.conf @@ -0,0 +1 @@ +key = value3; diff --git a/tests/generate.res b/tests/generate.res index 1d39478e0239..970b3125bae6 100644 --- a/tests/generate.res +++ b/tests/generate.res @@ -1,3 +1,4 @@ +key0 = 0.100000; key1 = "test string"; key2 = "test \\nstring"; key3 = " test string \n"; diff --git a/tests/test_basic.c b/tests/test_basic.c index b4ed7788dce4..5859c0ba6eb7 100644 --- a/tests/test_basic.c +++ b/tests/test_basic.c @@ -90,7 +90,7 @@ main (int argc, char **argv) inlen = strlen (inbuf); test_in = malloc (inlen); memcpy (test_in, inbuf, inlen); - ucl_parser_add_chunk (parser, test_in, inlen); + ucl_parser_add_chunk (parser, (const unsigned char *)test_in, inlen); } fclose (in); @@ -126,7 +126,7 @@ main (int argc, char **argv) ucl_parser_free (parser); ucl_object_unref (obj); parser2 = ucl_parser_new (UCL_PARSER_KEY_LOWERCASE); - ucl_parser_add_string (parser2, emitted, 0); + ucl_parser_add_string (parser2, (const char *)emitted, 0); if (ucl_parser_get_error(parser2) != NULL) { fprintf (out, "Error occurred: %s\n", ucl_parser_get_error(parser2)); diff --git a/tests/test_generate.c b/tests/test_generate.c index 5c130e67499a..aad92b51fb0e 100644 --- a/tests/test_generate.c +++ b/tests/test_generate.c @@ -54,6 +54,13 @@ main (int argc, char **argv) } obj = ucl_object_typed_new (UCL_OBJECT); + + /* Keys replacing */ + 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); + /* Create some strings */ cur = ucl_object_fromstring_common (" test string ", 0, UCL_STRING_TRIM); ucl_object_insert_key (obj, cur, "key1", 0, false); diff --git a/tests/test_schema.c b/tests/test_schema.c index afce17816d50..7acebb84b934 100644 --- a/tests/test_schema.c +++ b/tests/test_schema.c @@ -61,7 +61,7 @@ static bool perform_test (const ucl_object_t *schema, const ucl_object_t *obj, struct ucl_schema_error *err) { - const const ucl_object_t *valid, *data, *description; + const ucl_object_t *valid, *data, *description; bool match; data = ucl_object_find_key (obj, "data"); |
