From 7cfe611b6ceafbdccb55cb4cc77f75d4b0f4d723 Mon Sep 17 00:00:00 2001 From: Gabriel Marin Date: Tue, 12 Nov 2024 17:50:00 +0200 Subject: [PATCH] shtest: Added tests for --compact-output and --indent options --- tests/shtest | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/shtest b/tests/shtest index 96b547e564..f78a9f96ca 100755 --- a/tests/shtest +++ b/tests/shtest @@ -722,4 +722,25 @@ $VALGRIND $Q $JQ . <<\NUM -10E-1000000001 NUM +# #2498 test for --indent and --compact-output +echo "[1,2]" > $d/expected +$JQ --compact-output -n "[1,2]" > /dev/null 2 > $d/out +cmp $d/out $d/expected + +echo "[\n1,\n2\n]" > $d/expected +$JQ --indent 0 -n "[1,2]" > /dev/null 2 > $d/out +cmp $d/out $d/expected + +echo "[\n 1,\n 2\n]" > $d/expected +$JQ --indent 1 -n "[1,2]" > /dev/null 2 > $d/out +cmp $d/out $d/expected + +echo "[\n{\n\"a\": 1\n}\n]" > $d/expected +$JQ --indent 0 -n "[{a:1}]" > /dev/null 2 > $d/out +cmp $d/out $d/expected + +echo "[\n {\n \"a\": 1\n }\n]" > $d/expected +$JQ --indent 1 -n "[{a:1}]" > /dev/null 2 > $d/out +cmp $d/out $d/expected + exit 0