diff options
Diffstat (limited to 'tests/test_basic.c')
-rw-r--r-- | tests/test_basic.c | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/tests/test_basic.c b/tests/test_basic.c index 5a977aa7191af..b4ed7788dce4a 100644 --- a/tests/test_basic.c +++ b/tests/test_basic.c @@ -33,15 +33,21 @@ main (int argc, char **argv) FILE *in, *out; unsigned char *emitted = NULL; const char *fname_in = NULL, *fname_out = NULL; - int ret = 0, inlen, opt, json = 0; + int ret = 0, inlen, opt, json = 0, compact = 0, yaml = 0; - while ((opt = getopt(argc, argv, "j")) != -1) { + 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 [-j] [in] [out]\n", + fprintf (stderr, "Usage: %s [-jcy] [in] [out]\n", argv[0]); exit (EXIT_FAILURE); } @@ -104,7 +110,15 @@ main (int argc, char **argv) } obj = ucl_parser_get_object (parser); if (json) { - emitted = ucl_object_emit (obj, UCL_EMIT_JSON); + if (compact) { + emitted = ucl_object_emit (obj, UCL_EMIT_JSON_COMPACT); + } + else { + emitted = ucl_object_emit (obj, UCL_EMIT_JSON); + } + } + else if (yaml) { + emitted = ucl_object_emit (obj, UCL_EMIT_YAML); } else { emitted = ucl_object_emit (obj, UCL_EMIT_CONFIG); @@ -125,7 +139,15 @@ main (int argc, char **argv) } obj = ucl_parser_get_object (parser2); if (json) { - emitted = ucl_object_emit (obj, UCL_EMIT_JSON); + if (compact) { + emitted = ucl_object_emit (obj, UCL_EMIT_JSON_COMPACT); + } + else { + emitted = ucl_object_emit (obj, UCL_EMIT_JSON); + } + } + else if (yaml) { + emitted = ucl_object_emit (obj, UCL_EMIT_YAML); } else { emitted = ucl_object_emit (obj, UCL_EMIT_CONFIG); |