@@ -753,30 +753,41 @@ function test_urlparse(){
753753}
754754
755755function test_xlsx2csv(){
756- bin/xlsx2csv demos/xlsx2csv/MyWorkbook.xlsx " My worksheet 1" > demos/xlsx2csv/sheet1.csv
757- cmp demos/xlsx2csv/sheet1.csv demos/xlsx2csv/expected1.csv
758- if [ " $? " != " 0" ]; then
759- exit 1
760- fi
761-
762- echo -n " Count the sheets in MyWorkbook.xlsx: "
763- bin/xlsx2csv -nl -count demos/xlsx2csv/MyWorkbook.xlsx
764- echo ' '
756+ if [ -f temp.txt ]; then rm temp.txt; fi
757+ bin/xlsx2csv demos/xlsx2csv/MyWorkbook.xlsx " My worksheet 1" > temp.txt
758+ assert_exists " test_xlsx2csv (1)" temp.txt
759+ R=$( cmp demos/xlsx2csv/expected1.csv temp.txt)
760+ assert_empty " test_xlsx2csv (1)" " $R "
765761
766- echo -n " List the sheets in MyWorkbook.xlsx: "
767- bin/xlsx2csv -sheets demos/xlsx2csv/MyWorkbook.xlsx
768- echo ' '
762+ EXPECTED= " 2 "
763+ RESULT= $( bin/xlsx2csv -count demos/xlsx2csv/MyWorkbook.xlsx)
764+ assert_equal " test_xlsx2csv (2) " " $EXPECTED " " $RESULT "
769765
770- # bin/xlsx2csv -N demos/xlsx2csv/MyWorkbook.xlsx | while read SHEET_NAME; do
771- # CSV_NAME="${SHEET_NAME// /-}.csv"
772- # bin/xlsx2csv -o "${CSV_NAME}" demos/xlsx2csv/MyWorkbook.xlsx "${SHEET_NAME}"
773- # done
766+ EXPECTED=$( cat demos/xlsx2csv/expected3.txt)
767+ RESULT=$( bin/xlsx2csv -nl -sheets demos/xlsx2csv/MyWorkbook.xlsx | sort)
768+ assert_equal " test_xlsx2csv (3)" " $EXPECTED " " $RESULT "
774769
770+ if [ -f temp.txt ]; then rm temp.txt; fi
775771 echo " test_xlsx2csv OK" ;
776772}
777773
778774function test_xlsx2json(){
779- echo " test_xlsx2json skipping, not implemented" ;
775+ if [ -f temp.txt ]; then rm temp.txt; fi
776+ bin/xlsx2json -nl demos/xlsx2json/MyWorkbook.xlsx " My worksheet 1" > temp.txt
777+ echo ' [["Number","Value"],["one","1"],["two","2"],["three","3"]]' > expected1.json
778+ R=$( cmp demos/xlsx2json/expected1.json temp.txt)
779+ assert_empty " test_xlsx2csv (1)" " $R "
780+
781+ EXPECTED=" 2"
782+ RESULT=$( bin/xlsx2json -count demos/xlsx2json/MyWorkbook.xlsx)
783+ assert_equal " test_xlsx2json (2)" " $EXPECTED " " $RESULT "
784+
785+ EXPECTED=$( cat demos/xlsx2json/expected3.txt)
786+ RESULT=$( bin/xlsx2json -nl -sheets demos/xlsx2json/MyWorkbook.xlsx | sort)
787+ assert_equal " test_xlsx2json (3)" " $EXPECTED " " $RESULT "
788+
789+ if [ -f temp.txt ]; then rm temp.txt; fi
790+ echo " test_xlsx2json OK" ;
780791}
781792
782793#
0 commit comments