diff options
Diffstat (limited to 'test/pnmquantall.test')
-rwxr-xr-x | test/pnmquantall.test | 66 |
1 files changed, 45 insertions, 21 deletions
diff --git a/test/pnmquantall.test b/test/pnmquantall.test index 4c1bb77f..7910d0fc 100755 --- a/test/pnmquantall.test +++ b/test/pnmquantall.test @@ -1,47 +1,71 @@ -#! /bin/bash +#! /bin/sh # This script tests: pnmquantall -# Also requires: ppmtorgb3 pgmhist pnmcat +# Also requires: ppmtorgb3 pgmhist pamcat tmpdir=${tmpdir:-/tmp} -test_ppm=${tmpdir}/testimg.ppm +rose_ppm=${tmpdir}/rose.ppm -cp testimg.ppm ${tmpdir} && -ppmtorgb3 ${test_ppm} +cp testimg.ppm ${rose_ppm} && +ppmtorgb3 ${rose_ppm} -test_red=${tmpdir}/testimg.red -test_grn=${tmpdir}/testimg.grn -test_blu=${tmpdir}/testimg.blu +rose_red=${tmpdir}/rose.red +rose_grn=${tmpdir}/rose.grn +rose_blu=${tmpdir}/rose.blu -pnmquantall 20 ${test_red} ${test_grn} ${test_blu} +cp ${rose_red} ${rose_red}.1 +cp ${rose_grn} ${rose_grn}.1 +cp ${rose_blu} ${rose_blu}.1 -for i in ${test_red} ${test_grn} ${test_blu} +echo "Test 1." + +pnmquantall 20 ${rose_red}.1 ${rose_grn}.1 ${rose_blu}.1 + +for i in ${rose_red}.1 ${rose_grn}.1 ${rose_blu}.1 do cat $i | cksum done -# Should print 1 +pamcat ${rose_red}.1 ${rose_grn}.1 ${rose_blu}.1 -tb | \ + pgmhist -m |\ + awk '$2>0 {s++}; + END { printf("color count %u: %s\n", s, + (s==20) ? "success" : "failure") }' -pnmcat ${test_red} ${test_grn} ${test_blu} -tb | \ - pgmhist -m | awk '$2>0 {s++}; END { print (s<=20) }' +rm ${rose_red}.1 ${rose_grn}.1 ${rose_blu}.1 +echo "Test 2." -tmpdir=${tmpdir:-/tmp} -test_out=${tmpdir}/test_out +pnmquantall -ext .2 1 ${rose_red} ${rose_grn} ${rose_blu} + +for i in ${rose_red}.2 ${rose_grn}.2 ${rose_blu}.2 +do +cat $i | cksum +done + +pamcat ${rose_red}.2 ${rose_grn}.2 ${rose_blu}.2 -tb | \ + pgmhist -m |\ + awk '$2>0 {s++}; + END { printf("color count %u: %s\n", s, + (s==1) ? "success" : "failure") }' + +rm ${rose_red}.2 ${rose_grn}.2 ${rose_blu}.2 + +echo "Test Invalid" echo 1>&2 echo "Invalid command-line argument combinations." 1>&2 echo "Error messages should appear below the line." 1>&2 echo "-----------------------------------------------------------" 1>&2 -pnmquantall -ext xx 0 ${test_red} ${test_grn} ${test_blu} || \ +pnmquantall -ext xx 0 ${rose_red} ${rose_grn} ${rose_blu} || \ echo "Expected failure 1" -rm ${test_red}xx ${test_grn}xx ${test_blu}xx || \ +rm ${rose_red}xx ${rose_grn}xx ${rose_blu}xx || \ echo "Expected failure 1.rm" -pnmquantall -ext xx 1 ${test_red} ${test_grn} ${test_blu} || \ +pnmquantall -ext yy ${rose_red} ${rose_grn} ${rose_blu} || \ echo "Expected failure 2" -rm ${test_red}xx ${test_grn}xx ${test_blu}xx || \ +rm ${rose_red}yy ${rose_grn}yy ${rose_blu}yy || \ echo "Expected failure 2.rm" -pnmquantall -ext xx 2 || \ +pnmquantall -ext zz 2 || \ echo "Expected failure 3" -rm ${test_red} ${test_grn} ${test_blu} ${test_ppm} \ No newline at end of file +rm ${rose_red} ${rose_grn} ${rose_blu} ${rose_ppm} |