diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/schema/definitions.json | 32 | ||||
-rw-r--r-- | tests/schema/ref.json | 16 | ||||
-rw-r--r-- | tests/schema/refRemote.json | 76 | ||||
-rw-r--r-- | tests/test_speed.c | 2 | ||||
-rw-r--r-- | tests/test_streamline.c | 43 |
5 files changed, 42 insertions, 127 deletions
diff --git a/tests/schema/definitions.json b/tests/schema/definitions.json deleted file mode 100644 index 1ab9b2163c44..000000000000 --- a/tests/schema/definitions.json +++ /dev/null @@ -1,32 +0,0 @@ -[ - { - "description": "valid definition", - "schema": {"$ref": "http://highsecure.ru/ucl-schema/schema#"}, - "tests": [ - { - "description": "valid definition schema", - "data": { - "definitions": { - "foo": {"type": "integer"} - } - }, - "valid": true - } - ] - }, - { - "description": "invalid definition", - "schema": {"$ref": "http://highsecure.ru/ucl-schema/schema#"}, - "tests": [ - { - "description": "invalid definition schema", - "data": { - "definitions": { - "foo": {"type": 1} - } - }, - "valid": false - } - ] - } -] diff --git a/tests/schema/ref.json b/tests/schema/ref.json index 1767769cd845..d8214bc2b30c 100644 --- a/tests/schema/ref.json +++ b/tests/schema/ref.json @@ -124,21 +124,5 @@ "valid": false } ] - }, - { - "description": "remote ref, containing refs itself", - "schema": {"$ref": "http://highsecure.ru/ucl-schema/schema#"}, - "tests": [ - { - "description": "remote ref valid", - "data": {"minLength": 1}, - "valid": true - }, - { - "description": "remote ref invalid", - "data": {"minLength": -1}, - "valid": false - } - ] } ] diff --git a/tests/schema/refRemote.json b/tests/schema/refRemote.json deleted file mode 100644 index 067c666b0ec8..000000000000 --- a/tests/schema/refRemote.json +++ /dev/null @@ -1,76 +0,0 @@ -[ - { - "description": "remote ref", - "schema": {"$ref": "http://highsecure.ru/ucl-schema/remotes/integer.json"}, - "tests": [ - { - "description": "remote ref valid", - "data": 1, - "valid": true - }, - { - "description": "remote ref invalid", - "data": "a", - "valid": false - } - ] - }, - { - "description": "fragment within remote ref", - "schema": {"$ref": "http://highsecure.ru/ucl-schema/remotes/subSchemas.json#/integer"}, - "tests": [ - { - "description": "remote fragment valid", - "data": 1, - "valid": true - }, - { - "description": "remote fragment invalid", - "data": "a", - "valid": false - } - ] - }, - { - "description": "ref within remote ref", - "schema": { - "$ref": "http://highsecure.ru/ucl-schema/remotes/subSchemas.json#/refToInteger" - }, - "tests": [ - { - "description": "ref within ref valid", - "data": 1, - "valid": true - }, - { - "description": "ref within ref invalid", - "data": "a", - "valid": false - } - ] - } -/* - { - "description": "change resolution scope", - "schema": { - "id": "http://highsecure.ru/ucl-schema/remotes/", - "items": { - "id": "folder/", - "items": {"$ref": "folderInteger.json"} - } - }, - "tests": [ - { - "description": "changed scope ref valid", - "data": [[1]], - "valid": true - }, - { - "description": "changed scope ref invalid", - "data": [["a"]], - "valid": false - } - ] - } -*/ -] diff --git a/tests/test_speed.c b/tests/test_speed.c index 56f2e5abc6c7..51476c94940b 100644 --- a/tests/test_speed.c +++ b/tests/test_speed.c @@ -44,7 +44,7 @@ get_ticks (void) { double res; -#ifdef __APPLE__ +#if defined(__APPLE__) && defined(HAVE_MACH_MACH_TIME_H) res = mach_absolute_time () / 1000000000.; #else struct timespec ts; diff --git a/tests/test_streamline.c b/tests/test_streamline.c index 4c56c4cdcffd..37fe14f9fb97 100644 --- a/tests/test_streamline.c +++ b/tests/test_streamline.c @@ -26,6 +26,10 @@ #include <assert.h> #include "ucl.h" +#include <sys/types.h> +#include <fcntl.h> +#include <unistd.h> + int main (int argc, char **argv) { @@ -34,7 +38,28 @@ main (int argc, char **argv) const char *fname_out = NULL; struct ucl_emitter_context *ctx; struct ucl_emitter_functions *f; - int ret = 0; + int ret = 0, opt, json = 0, compact = 0, yaml = 0; + + while ((opt = getopt(argc, argv, "jcy")) != -1) { + switch (opt) { + case 'j': + json = 1; + break; + case 'c': + compact = 1; + break; + case 'y': + yaml = 1; + break; + default: /* '?' */ + fprintf (stderr, "Usage: %s [-jcy] [out]\n", + argv[0]); + exit (EXIT_FAILURE); + } + } + + argc -= optind; + argv += optind; switch (argc) { case 2: @@ -63,7 +88,21 @@ main (int argc, char **argv) ucl_object_insert_key (obj, cur, "key3", 0, false); f = ucl_object_emit_file_funcs (out); - ctx = ucl_object_emit_streamline_new (obj, UCL_EMIT_CONFIG, f); + + if (yaml) { + ctx = ucl_object_emit_streamline_new (obj, UCL_EMIT_YAML, f); + } + else if (json) { + if (compact) { + ctx = ucl_object_emit_streamline_new (obj, UCL_EMIT_JSON_COMPACT, f); + } + else { + ctx = ucl_object_emit_streamline_new (obj, UCL_EMIT_JSON, f); + } + } + else { + ctx = ucl_object_emit_streamline_new (obj, UCL_EMIT_CONFIG, f); + } assert (ctx != NULL); |