Skip to content

Commit ba163ba

Browse files
committed
Added test on returning objects and their attributes
1 parent 177b357 commit ba163ba

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

test_cmds.bash

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -548,17 +548,37 @@ function test_jsoncols(){
548548
assert_empty "test_jsoncols (result3)" "$R"
549549

550550
E="1"
551-
R=$(bin/jsoncols -i how-to/jsoncols/blob2.json '.id')
551+
R=$(bin/jsoncols -i "how-to/jsoncols/blob2.json" '.id')
552552
assert_equal "test_jsoncols (.id)" "$E" "$R"
553553
E="8"
554-
R=$(bin/jsoncols -i how-to/jsoncols/blob2.json '.counts[2]')
554+
R=$(bin/jsoncols -i "how-to/jsoncols/blob2.json" '.counts[2]')
555555
assert_equal "test_jsoncols (.counts[2])" "$E" "$R"
556+
E="1"
557+
R=$(bin/jsoncols -i "how-to/jsoncols/blob2.json" '.map.one')
558+
assert_equal "test_jsoncols (.map.two)" "$E" "$R"
556559
E="2"
557-
R=$(bin/jsoncols -i how-to/jsoncols/blob2.json '.map.two')
560+
R=$(bin/jsoncols -i "how-to/jsoncols/blob2.json" '.map.two')
558561
assert_equal "test_jsoncols (.map.two)" "$E" "$R"
562+
E="3"
563+
R=$(bin/jsoncols -i "how-to/jsoncols/blob2.json" '.map.three')
564+
assert_equal "test_jsoncols (.map.two)" "$E" "$R"
565+
559566
E='{"one":1,"two":2,"three":3}'
560-
R=$(bin/jsoncols -i how-to/jsoncols/blob2.json '.map')
561-
assert_equal "test_jsoncols (.map)" "$E" "$R"
567+
R1=$(bin/jsoncols -i "how-to/jsoncols/blob2.json" '.map')
568+
echo "${E}" | jsonrange -i - | while read K; do
569+
R2=$(echo "$R1" | bin/jsoncols -i - ".$K")
570+
case "$K" in
571+
"one")
572+
assert_equal "test_jsoncols (.$K)" "1" "$R2"
573+
;;
574+
"two")
575+
assert_equal "test_jsoncols (.$K)" "2" "$R2"
576+
;;
577+
"three")
578+
assert_equal "test_jsoncols (.$K)" "3" "$R2"
579+
;;
580+
esac
581+
done
562582

563583

564584
if [ -f temp.txt ]; then rm temp.txt; fi
@@ -801,6 +821,7 @@ function test_xlsx2json(){
801821
assert_equal "test_xlsx2json (3)" "$EXPECTED" "$RESULT"
802822

803823
if [ -f temp.txt ]; then rm temp.txt; fi
824+
if [ -f expected1.json ]; then rm expected1.json; fi
804825
echo "test_xlsx2json OK";
805826
}
806827

0 commit comments

Comments
 (0)