diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/Test-Order | 10 | ||||
-rw-r--r-- | test/pnmindex.test | 39 | ||||
-rw-r--r-- | test/pnmpad-color.ok | 222 | ||||
-rwxr-xr-x | test/pnmpad-color.test | 446 | ||||
-rw-r--r-- | test/pnmpad-extend-enlarge.ok | 163 | ||||
-rwxr-xr-x | test/pnmpad-extend-enlarge.test | 177 | ||||
-rw-r--r-- | test/pnmpad-flip.ok | 64 | ||||
-rwxr-xr-x | test/pnmpad-flip.test | 62 | ||||
-rw-r--r-- | test/pnmpad-format.ok | 135 | ||||
-rwxr-xr-x | test/pnmpad-format.test | 245 | ||||
-rw-r--r-- | test/pnmpad-pnmmargin.ok | 15 | ||||
-rwxr-xr-x | test/pnmpad-pnmmargin.test | 79 | ||||
-rw-r--r-- | test/pnmpad-reportonly.ok | 8 | ||||
-rwxr-xr-x | test/pnmpad-reportonly.test | 31 | ||||
-rwxr-xr-x | test/stdin-pnm1.test | 2 |
15 files changed, 1695 insertions, 3 deletions
diff --git a/test/Test-Order b/test/Test-Order index 05742ac0..6c21c759 100644 --- a/test/Test-Order +++ b/test/Test-Order @@ -89,8 +89,13 @@ pnminvert.test pamchannel.test ppmchange.test pambackground.test + pnmpad-reportonly.test -pnmpaste-pbm.test +pnmpad-flip.test +pnmpad-extend-enlarge.test +pnmpad-pnmmargin.test +pnmpad-format.test +pnmpad-color.test pamrestack.test pamshuffle.test @@ -113,6 +118,8 @@ ppmdim.test pnmshear.test pgmbentley.test +pnmindex.test + pamfunc.test pamarith.test pamarith-compare-equal.test @@ -275,3 +282,4 @@ jpeg-roundtrip.test lps-roundtrip.test tiffcmyk-roundtrip.test yuv-roundtrip.test + diff --git a/test/pnmindex.test b/test/pnmindex.test new file mode 100644 index 00000000..5dc85b70 --- /dev/null +++ b/test/pnmindex.test @@ -0,0 +1,39 @@ +#! /bin/sh +# This script tests: pnmindex +# Also requires: + +pnmindex maze.pbm maze.pbm maze.pbm maze.pbm maze.pbm maze.pbm | cksum + +pnmindex -white -noquant maze.pbm maze.pbm maze.pbm maze.pbm maze.pbm maze.pbm | cksum + +pnmindex -black maze.pbm maze.pbm maze.pbm maze.pbm maze.pbm maze.pbm | cksum + +pnmindex -size 20 -accross=3 testgrid.pbm testgrid.pbm testgrid.pbm \ + testgrid.pbm testgrid.pbm testgrid.pbm | cksum + +echo "Test Invalid" + +test_out=${tmpdir}/test_out +n=1 + +# define function +invcmd $1 > ${test_out} || \ + printf "Expected failure $n " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + n=$(($n +1)); } + +echo 1>&2 +echo "Invalid command-line arguments." 1>&2 +echo "Error messages should appear below the line." 1>&2 +echo "-----------------------------------------------------------" 1>&2 + +invcmd "pnmindex -size -1 testgrid.pbm" +invcmd "pnmindex -size 0 testgrid.pbm" +invcmd "pnmindex -size testgrid.pbm" +invcmd "pnmindex -across -1 testgrid.pbm" +invcmd "pnmindex -across 0 testgrid.pbm" +invcmd "pnmindex -across testgrid.pbm" +invcmd "pnmindex -quant -1 testgrid.pbm" +invcmd "pnmindex -quant 0 testgrid.pbm" +invcmd "pnmindex testgrid.pbm /dev/null" diff --git a/test/pnmpad-color.ok b/test/pnmpad-color.ok new file mode 100644 index 00000000..91e3b264 --- /dev/null +++ b/test/pnmpad-color.ok @@ -0,0 +1,222 @@ +Test 1. PBM white infile +Should print match seven times +match +match +match +match +match +match +match +Should print match seven times +match +match +match +match +match +match +match +Should print match once +match +Should print match once +match +Should print match twice +match +match +Should print match twice +match +match +Should print match once +match +Should print match twice +match +match + +Test 2. PBM black infile +Should print match nine times +match +match +match +match +match +match +match +match +match +Should print match five times +match +match +match +match +match + +Test 3. PGM maxval 127 infile +Should print match five times +match +match +match +match +match +Should print match four times +match +match +match +match +Should print match twice +match +match +Should print match twice +match +match +Should print match twice +match +match +Should print match once +match +Should print match twice +match +match +Should print match twice +match +match +Should print match once +match +Should print match twice +match +match + +Test 4. PGM maxval 255 infile +Should print match five times +match +match +match +match +match +Should print match four times +match +match +match +match +Should print match twice +match +match +Should print match twice +match +match +Should print match twice +match +match +Should print match once +match +Should print match four times +match +match +match +match +Should print match four times +match +match +match +match +Should print match three times +match +match +match + +Test 5. PGM maxval 511 infile +Should print match five times +match +match +match +match +match +Should print match four times +match +match +match +match +Should print match twice +match +match +Should print match twice +match +match +Should print match twice +match +match +Should print match once +match +Should print match twice +match +match +Should print match twice +match +match +Should print match three times +match +match +match + +Test 6. PPM maxval 127 infile +Should print match five times +match +match +match +match +match +Should print match four times +match +match +match +match +Should print match twice +match +match +Should print match twice +match +match +Should print match twice +match +match +Should print match once +match +Should print match twice +match +match +Should print match twice +match +match +Should print match twice +match +match + +Test 7. PPM maxval 511 infile +Should print match five times +match +match +match +match +match +Should print match four times +match +match +match +match +Should print match six times +match +match +match +match +match +match +Should print match twice +match +match +Should print match twice +match +match +Should print match twice +match +match +Should print match twice +match +match diff --git a/test/pnmpad-color.test b/test/pnmpad-color.test new file mode 100755 index 00000000..05e8acca --- /dev/null +++ b/test/pnmpad-color.test @@ -0,0 +1,446 @@ +#! /bin/sh +# This script tests: pnmpad +# Also requires: pbmmake pgmmake ppmmake pamcut ppmtopgm + +tmpdir=${tmpdir:-/tmp} + +white_pbm=${tmpdir}/white.pbm +black_pbm=${tmpdir}/black.pbm +test127_pgm=${tmpdir}/testimg1.pgm +test255_pgm=${tmpdir}/testimg2.pgm +test511_pgm=${tmpdir}/testimg3.pgm +test127_ppm=${tmpdir}/testimg1.ppm +test255_ppm=${tmpdir}/testimg2.ppm +test511_ppm=${tmpdir}/testimg3.ppm +target_pnm=${tmpdir}/target.pnm + +BLACK="rgbi:0.0/0.0/0.0" +WHITE="rgbi:1.0/1.0/1.0" +LIGHTGRAY="rgbi:0.6/0.6/0.6" +LIGHTGRAYv=0.6 +DARKGRAY="rgbi:0.01/0.01/0.01" +DARKGRAYv=0.01 +PURPLE="rgb:A0/20/F0" +YELLOW="rgb:F0/F0/00" + +pbmmake -w 1 1 > ${white_pbm} +pbmmake -b 1 1 > ${black_pbm} +pgmmake 0.25 1 1 -maxval 127 > ${test127_pgm} +pgmmake 0.25 1 1 -maxval 255 > ${test255_pgm} +pgmmake 0.25 1 1 -maxval 511 > ${test511_pgm} +ppmmake ${YELLOW} 1 1 -maxval 127 > ${test127_ppm} +ppmmake ${YELLOW} 1 1 -maxval 255 > ${test255_ppm} +ppmmake ${YELLOW} 1 1 -maxval 511 > ${test511_ppm} + +ptop="-top 1" + +# define function +cmptarget () { pamcut -top 0 -left 0 -height 1 -width 1 $@ |\ + cmp -s ${target_ppm} - && echo "match" || echo "failure"; } + +echo "Test 1. PBM white infile" + +infile=${white_pbm} + +echo "Should print match seven times" + +pbmmake -w 1 1 > ${target_pnm} +pnmpad ${ptop} -white ${infile} | cmptarget +pnmpad ${ptop} -extend-edge ${infile} | cmptarget +pnmpad ${ptop} -detect-background ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} -promote format ${infile} | cmptarget +pnmpad ${ptop} -color ${LIGHTGRAY} -promote none ${infile} | cmptarget + +echo "Should print match seven times" + +pbmmake -b 1 1 > ${target_pnm} +pnmpad ${ptop} ${infile} | cmptarget +pnmpad ${ptop} -black ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} -promote format ${infile} | cmptarget +pnmpad ${ptop} -color ${DARKGRAY} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${PURPLE} -promote none ${infile} | cmptarget + +echo "Should print match once" + +pgmmake -maxval 1 ${LIGHTGRAYv} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${LIGHTGRAY} -promote format ${infile} | cmptarget + +echo "Should print match once" + +pgmmake -maxval 1 ${DARKGRAYv} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${DARKGRAY} -promote format ${infile} | cmptarget + +echo "Should print match twice" + +pgmmake -maxval 255 ${LIGHTGRAYv} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${LIGHTGRAY} ${infile} | cmptarget +pnmpad ${ptop} -color ${LIGHTGRAY} -promote all ${infile} | cmptarget + +echo "Should print match twice" + +pgmmake -maxval 255 ${DARKGRAYv} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${DARKGRAY} ${infile} | cmptarget +pnmpad ${ptop} -color ${DARKGRAY} -promote all ${infile} | cmptarget + +echo "Should print match once" + +ppmmake -maxval 1 ${PURPLE} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${PURPLE} -promote format ${infile} | cmptarget + +echo "Should print match twice" + +ppmmake -maxval 255 ${PURPLE} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${PURPLE} ${infile} | cmptarget +pnmpad ${ptop} -color ${PURPLE} -promote all ${infile} | cmptarget + +echo +echo "Test 2. PBM black infile" + +infile=${black_pbm} + +echo "Should print match nine times" + +pbmmake -b 1 1 > ${target_pnm} +pnmpad ${ptop} ${infile} | cmptarget +pnmpad ${ptop} -black ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} -promote format ${infile} | cmptarget +pnmpad ${ptop} -color ${DARKGRAY} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${PURPLE} -promote none ${infile} | cmptarget +pnmpad ${ptop} -extend-edge ${infile} | cmptarget +pnmpad ${ptop} -detect-background ${infile} | cmptarget + +echo "Should print match five times" + +pbmmake -w 1 1 > ${target_pnm} +pnmpad ${ptop} -white ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} -promote format ${infile} | cmptarget +pnmpad ${ptop} -color ${LIGHTGRAY} -promote none ${infile} | cmptarget + +echo +echo "Test 3. PGM maxval 127 infile" + +infile=${test127_pgm} + +echo "Should print match five times" + +pgmmake -maxval 127 0.0 1 1 > ${target_pnm} +pnmpad ${ptop} ${infile} | cmptarget +pnmpad ${ptop} -black ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} -promote format ${infile} | cmptarget + +echo "Should print match four times" + +pgmmake -maxval 127 1.0 1 1 > ${target_pnm} +pnmpad ${ptop} -white ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} -promote format ${infile} | cmptarget + +echo "Should print match twice" + +pamcut -t 0 -h 1 -w 1 ${infile} > ${target_pnm} +pnmpad ${ptop} -extend-edge ${infile} | cmptarget +pnmpad ${ptop} -detect-background ${infile} | cmptarget + +echo "Should print match twice" + +pgmmake -maxval 127 ${LIGHTGRAYv} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${LIGHTGRAY} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${LIGHTGRAY} -promote format ${infile} | cmptarget + +echo "Should print match twice" + +pgmmake -maxval 127 ${DARKGRAYv} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${DARKGRAY} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${DARKGRAY} -promote format ${infile} | cmptarget + +echo "Should print match once" + +ppmmake -maxval 127 ${PURPLE} 1 1 | ppmtopgm > ${target_pnm} +pnmpad ${ptop} -color ${PURPLE} -promote none ${infile} | cmptarget + +echo "Should print match twice" + +pgmmake -maxval 255 ${LIGHTGRAYv} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${LIGHTGRAY} ${infile} | cmptarget +pnmpad ${ptop} -color ${LIGHTGRAY} -promote all ${infile} | cmptarget + +echo "Should print match twice" + +pgmmake -maxval 255 ${DARKGRAYv} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${DARKGRAY} ${infile} | cmptarget +pnmpad ${ptop} -color ${DARKGRAY} -promote all ${infile} | cmptarget + +echo "Should print match once" + +ppmmake -maxval 127 ${PURPLE} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${PURPLE} -promote format ${infile} | cmptarget + +echo "Should print match twice" + +ppmmake -maxval 255 ${PURPLE} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${PURPLE} ${infile} | cmptarget +pnmpad ${ptop} -color ${PURPLE} -promote all ${infile} | cmptarget + + +echo +echo "Test 4. PGM maxval 255 infile" + +infile=${test255_pgm} + +echo "Should print match five times" + +pgmmake -maxval 255 0.0 1 1 > ${target_pnm} +pnmpad ${ptop} ${infile} | cmptarget +pnmpad ${ptop} -black ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} -promote format ${infile} | cmptarget + +echo "Should print match four times" + +pgmmake -maxval 255 1.0 1 1 > ${target_pnm} +pnmpad ${ptop} -white ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} -promote format ${infile} | cmptarget + +echo "Should print match twice" + +pamcut -t 0 -h 1 -w 1 ${infile} > ${target_pnm} +pnmpad ${ptop} -extend-edge ${infile} | cmptarget +pnmpad ${ptop} -detect-background ${infile} | cmptarget + +echo "Should print match twice" + +pgmmake -maxval 255 ${LIGHTGRAYv} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${LIGHTGRAY} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${LIGHTGRAY} -promote format ${infile} | cmptarget + +echo "Should print match twice" + +pgmmake -maxval 255 ${DARKGRAYv} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${DARKGRAY} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${DARKGRAY} -promote format ${infile} | cmptarget + +echo "Should print match once" + +ppmmake -maxval 255 ${PURPLE} 1 1 | ppmtopgm > ${target_pnm} +pnmpad ${ptop} -color ${PURPLE} -promote none ${infile} | cmptarget + +echo "Should print match four times" + +pgmmake -maxval 255 ${LIGHTGRAYv} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${LIGHTGRAY} ${infile} | cmptarget +pnmpad ${ptop} -color ${LIGHTGRAY} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${LIGHTGRAY} -promote format ${infile} | cmptarget +pnmpad ${ptop} -color ${LIGHTGRAY} -promote all ${infile} | cmptarget + +echo "Should print match four times" + +pgmmake -maxval 255 ${DARKGRAYv} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${DARKGRAY} ${infile} | cmptarget +pnmpad ${ptop} -color ${DARKGRAY} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${DARKGRAY} -promote format ${infile} | cmptarget +pnmpad ${ptop} -color ${DARKGRAY} -promote all ${infile} | cmptarget + +echo "Should print match three times" + +ppmmake -maxval 255 ${PURPLE} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${PURPLE} ${infile} | cmptarget +pnmpad ${ptop} -color ${PURPLE} -promote format ${infile} | cmptarget +pnmpad ${ptop} -color ${PURPLE} -promote all ${infile} | cmptarget + +echo +echo "Test 5. PGM maxval 511 infile" + +infile=${test511_pgm} + +echo "Should print match five times" + +pgmmake -maxval 511 0.0 1 1 > ${target_pnm} +pnmpad ${ptop} ${infile} | cmptarget +pnmpad ${ptop} -black ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} -promote format ${infile} | cmptarget + +echo "Should print match four times" + +pgmmake -maxval 511 1.0 1 1 > ${target_pnm} +pnmpad ${ptop} -white ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} -promote format ${infile} | cmptarget + +echo "Should print match twice" + +pamcut -t 0 -h 1 -w 1 ${infile} > ${target_pnm} +pnmpad ${ptop} -extend-edge ${infile} | cmptarget +pnmpad ${ptop} -detect-background ${infile} | cmptarget + +echo "Should print match twice" + +pgmmake -maxval 511 ${LIGHTGRAYv} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${LIGHTGRAY} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${LIGHTGRAY} -promote format ${infile} | cmptarget + +echo "Should print match twice" + +pgmmake -maxval 511 ${DARKGRAYv} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${DARKGRAY} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${DARKGRAY} -promote format ${infile} | cmptarget + +echo "Should print match once" + +ppmmake -maxval 511 ${PURPLE} 1 1 | ppmtopgm > ${target_pnm} +pnmpad ${ptop} -color ${PURPLE} -promote none ${infile} | cmptarget + +echo "Should print match twice" + +pgmmake -maxval 511 ${LIGHTGRAYv} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${LIGHTGRAY} ${infile} | cmptarget +pnmpad ${ptop} -color ${LIGHTGRAY} -promote all ${infile} | cmptarget + +echo "Should print match twice" + +pgmmake -maxval 511 ${DARKGRAYv} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${DARKGRAY} ${infile} | cmptarget +pnmpad ${ptop} -color ${DARKGRAY} -promote all ${infile} | cmptarget + +echo "Should print match three times" + +ppmmake -maxval 511 ${PURPLE} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${PURPLE} ${infile} | cmptarget +pnmpad ${ptop} -color ${PURPLE} -promote format ${infile} | cmptarget +pnmpad ${ptop} -color ${PURPLE} -promote all ${infile} | cmptarget + + +echo +echo "Test 6. PPM maxval 127 infile" + +infile=${test127_ppm} + +echo "Should print match five times" + +ppmmake -maxval 127 ${BLACK} 1 1 > ${target_pnm} +pnmpad ${ptop} ${infile} | cmptarget +pnmpad ${ptop} -black ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} -promote format ${infile} | cmptarget + +echo "Should print match four times" + +ppmmake -maxval 127 ${WHITE} 1 1 > ${target_pnm} +pnmpad ${ptop} -white ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} -promote format ${infile} | cmptarget + +echo "Should print match twice" + +ppmmake -maxval 127 ${PURPLE} 1 1 > ${target_pnm} +ppmmake -maxval 127 ${PURPLE} 1 2 | pnmpad ${ptop} -extend-edge | cmptarget +ppmmake -maxval 127 ${PURPLE} 1 2 | pnmpad ${ptop} -detect-background | cmptarget + +echo "Should print match twice" + +ppmmake -maxval 127 ${LIGHTGRAY} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${LIGHTGRAY} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${LIGHTGRAY} -promote format ${infile} | cmptarget + +echo "Should print match twice" + +ppmmake -maxval 127 ${DARKGRAY} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${DARKGRAY} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${DARKGRAY} -promote format ${infile} | cmptarget + +echo "Should print match once" + +ppmmake -maxval 127 ${PURPLE} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${PURPLE} -promote none ${infile} | cmptarget + +echo "Should print match twice" + +ppmmake -maxval 255 ${LIGHTGRAY} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${LIGHTGRAY} ${infile} | cmptarget +pnmpad ${ptop} -color ${LIGHTGRAY} -promote all ${infile} | cmptarget + +echo "Should print match twice" + +ppmmake -maxval 255 ${DARKGRAY} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${DARKGRAY} ${infile} | cmptarget +pnmpad ${ptop} -color ${DARKGRAY} -promote all ${infile} | cmptarget + +echo "Should print match twice" + +ppmmake -maxval 255 ${PURPLE} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${PURPLE} ${infile} | cmptarget +pnmpad ${ptop} -color ${PURPLE} -promote all ${infile} | cmptarget + +echo +echo "Test 7. PPM maxval 511 infile" + +infile=${test511_ppm} + +echo "Should print match five times" + +ppmmake -maxval 511 ${BLACK} 1 1 > ${target_pnm} +pnmpad ${ptop} ${infile} | cmptarget +pnmpad ${ptop} -black ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} -promote format ${infile} | cmptarget + +echo "Should print match four times" + +ppmmake -maxval 511 ${WHITE} 1 1 > ${target_pnm} +pnmpad ${ptop} -white ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} -promote format ${infile} | cmptarget + +echo "Should print match six times" + +ppmmake -maxval 511 ${PURPLE} 1 1 > ${target_pnm} +ppmmake -maxval 511 ${PURPLE} 1 5 | pnmpad ${ptop} -extend-edge | cmptarget +ppmmake -maxval 511 ${PURPLE} 1 5 | pnmpad ${ptop} -detect-background | cmptarget +pnmpad ${ptop} -color ${PURPLE} ${infile} | cmptarget +pnmpad ${ptop} -color ${PURPLE} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${PURPLE} -promote format ${infile} | cmptarget +pnmpad ${ptop} -color ${PURPLE} -promote all ${infile} | cmptarget + +echo "Should print match twice" + +ppmmake -maxval 511 ${LIGHTGRAY} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${LIGHTGRAY} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${LIGHTGRAY} -promote format ${infile} | cmptarget + +echo "Should print match twice" + +ppmmake -maxval 511 ${DARKGRAY} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${DARKGRAY} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${DARKGRAY} -promote format ${infile} | cmptarget + +echo "Should print match twice" + +ppmmake -maxval 511 ${LIGHTGRAY} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${LIGHTGRAY} ${infile} | cmptarget +pnmpad ${ptop} -color ${LIGHTGRAY} -promote all ${infile} | cmptarget + +echo "Should print match twice" + +ppmmake -maxval 511 ${DARKGRAY} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${DARKGRAY} ${infile} | cmptarget +pnmpad ${ptop} -color ${DARKGRAY} -promote all ${infile} | cmptarget diff --git a/test/pnmpad-extend-enlarge.ok b/test/pnmpad-extend-enlarge.ok new file mode 100644 index 00000000..d1539022 --- /dev/null +++ b/test/pnmpad-extend-enlarge.ok @@ -0,0 +1,163 @@ +Test 1. Should print match forty-eight (24x2) times +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +Test 2. Should print match thirty-six (18x2) times +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +Test 3. Should print match twenty-four (4x6) times +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +Test 4. Should print match eighteen (3x6) times +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +Test 5. Should print match thirty-two (8x4) times +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match diff --git a/test/pnmpad-extend-enlarge.test b/test/pnmpad-extend-enlarge.test new file mode 100755 index 00000000..fde609a6 --- /dev/null +++ b/test/pnmpad-extend-enlarge.test @@ -0,0 +1,177 @@ +#! /bin/sh +# This script tests: pnmpad pamenlarge +# Also requires: pamcat pamcut pamenlarge pbmmake pbmnoise pgmmake pgmnoise +# Also requires: ppmmake ppmpat + +# If the padding function for -extend-edge is altered, make sure to run this +# test in a more thorough form. Replace "for leftpad in 0 1 7 9 16" +# with "for leftpad in `seq 0 16`". + +tmpdir=${tmpdir:-/tmp} +test_pnm=${tmpdir}/test.pnm + +padded_pnm=${tmpdir}/padded.pnm +#middle_pnm=${tmpdir}/middle.pnm +left_pnm=${tmpdir}/left.pnm +right_pnm=${tmpdir}/right.pnm +top_pnm=${tmpdir}/top.pnm +bottom_pnm=${tmpdir}/bottom.pnm + +echo "Test 1. Should print match forty-eight (24x2) times" + +for generator in "pbmnoise -randomseed=100 17 17" \ + "ppmpat -tartan -randomseed=100 11 11" + do + ${generator} > ${test_pnm} + for leftpad in 0 1 7 9 16 + do + for rightpad in 0 1 8 + do + pnmpad -extend-edge -l=${leftpad} -r=${rightpad} ${test_pnm} > ${padded_pnm} + pamcut -left=0 -width=1 ${test_pnm} |\ + pamenlarge -xscale=$(( ${leftpad} + 1 )) > ${left_pnm} + pamcut -right=-1 -width=1 ${test_pnm} |\ + pamenlarge -xscale=$(( ${rightpad} + 1 )) > ${right_pnm} + pamcut -cropleft=1 -cropright=1 ${test_pnm} |\ + pamcat -lr ${left_pnm} - ${right_pnm} |\ + cmp -s - ${padded_pnm} && echo "match" ||\ + echo "no match: lr ${generator} ${leftpad} ${rightpad}"; + rm ${left_pnm} ${right_pnm} ${padded_pnm} + done + done + + for toppad in 0 2 5 + do + for bottompad in 0 1 10 + do + pnmpad -extend-edge -t=${toppad} -b=${bottompad} ${test_pnm} > ${padded_pnm} + pamcut -top=0 -height=1 ${test_pnm} |\ + pamenlarge -yscale=$(( ${toppad} + 1 )) > ${top_pnm} + pamcut -bottom=-1 -height=1 ${test_pnm} |\ + pamenlarge -yscale=$(( ${bottompad} + 1 )) > ${bottom_pnm} + pamcut -croptop=1 -cropbottom=1 ${test_pnm} |\ + pamcat -tb ${top_pnm} - ${bottom_pnm} |\ + cmp -s - ${padded_pnm} && echo "match" ||\ + echo "no match: tb ${generator} ${toppad} ${bottompad}"; + rm ${top_pnm} ${bottom_pnm} ${padded_pnm} + done + done + rm ${test_pnm} +done + + +echo "Test 2. Should print match thirty-six (18x2) times" + +for generator in "pbmnoise -randomseed=100 17 17" \ + "ppmpat -tartan -randomseed=100 11 11" + do + ${generator} > ${test_pnm} + for leftpad in 0 1 2 + do + for rightpad in 0 1 3 + do + pnmpad -extend-edge -l=${leftpad} -r=${rightpad} ${test_pnm} > ${padded_pnm} + pamcut -left=0 -width=1 ${test_pnm} |\ + pamenlarge -xscale=$(( ${leftpad} + 1 )) > ${left_pnm} + pamcut -right=-1 -width=1 ${test_pnm} |\ + pamenlarge -xscale=$(( ${rightpad} + 1 )) > ${right_pnm} + pamcut -cropleft=1 -cropright=1 ${test_pnm} |\ + pamcat -lr ${left_pnm} - ${right_pnm} |\ + cmp -s - ${padded_pnm} && echo "match" ||\ + echo "no match: lr ${generator} ${leftpad} ${rightpad}"; + rm ${left_pnm} ${right_pnm} ${padded_pnm} + done + done + + for toppad in 0 1 12 + do + for bottompad in 0 1 5 + do + pnmpad -extend-edge -t=${toppad} -b=${bottompad} ${test_pnm} > ${padded_pnm} + pamcut -top=0 -height=1 ${test_pnm} |\ + pamenlarge -yscale=$(( ${toppad} + 1 )) > ${top_pnm} + pamcut -bottom=-1 -height=1 ${test_pnm} |\ + pamenlarge -yscale=$(( ${bottompad} + 1 )) > ${bottom_pnm} + pamcut -croptop=1 -cropbottom=1 ${test_pnm} |\ + pamcat -tb ${top_pnm} - ${bottom_pnm} |\ + cmp -s - ${padded_pnm} && echo "match" ||\ + echo "no match: tb ${generator} ${toppad} ${bottompad}"; + rm ${top_pnm} ${bottom_pnm} ${padded_pnm} + done + done + rm ${test_pnm} +done + + +echo "Test 3. Should print match twenty-four (4x6) times" + +stretch_pnm=${tmpdir}/stretch.pnm + +for generator in "pbmmake -b 1 1" \ + "pbmmake -b 1 11" \ + "pbmmake -w 1 1" \ + "pbmmake -w 1 8" \ + "pbmnoise -randomseed=100 1 17" \ + "pgmnoise -randomseed=100 1 12" + do + ${generator} > ${test_pnm} + pamenlarge -xscale=17 ${test_pnm} > ${stretch_pnm} + + for leftpad in 0 1 7 16 + do + pnmpad -extend-edge -l=${leftpad} -r=$((16 - ${leftpad})) ${test_pnm} |\ + cmp -s - ${stretch_pnm} && echo "match" ||\ + echo "no match: ${generator} ${leftpad}"; + done + rm ${stretch_pnm} ${test_pnm} +done + + +echo "Test 4. Should print match eighteen (3x6) times" + +stretch_pnm=${tmpdir}/stretch.pnm + +for generator in "pbmmake -b 1 1" \ + "pbmmake -b 8 1" \ + "pbmmake -w 1 1" \ + "pbmmake -w 3 1" \ + "pbmnoise -randomseed=100 17 1" \ + "pgmnoise -randomseed=100 8 1" + do + ${generator} > ${test_pnm} + pamenlarge -yscale=15 ${test_pnm} > ${stretch_pnm} + + for toppad in 0 1 14 + do + pnmpad -extend-edge -t=${toppad} -b=$((14 - ${toppad})) ${test_pnm} |\ + cmp -s - ${stretch_pnm} && echo "match" ||\ + echo "no match: ${generator} ${toppad}"; + done + rm ${stretch_pnm} ${test_pnm} +done + + +echo "Test 5. Should print match thirty-two (8x4) times" + +stretch_pnm=${tmpdir}/stretch.pnm + +for generator in "pbmmake -b 1 1" \ + "pbmmake -w 1 1" \ + "pgmmake 0.3 1 1" \ + "ppmmake rgbi:0.5/0.3/0.8 1 1" + do + ${generator} > ${test_pnm} + pamenlarge -xscale=66 -yscale=10 ${test_pnm} > ${stretch_pnm} + + for toppad in 0 8 + do + for leftpad in 0 1 15 64 + do + pnmpad -extend-edge -t=${toppad} -b=$((9 - ${toppad})) \ + -l=${leftpad} -r=$((65 - ${leftpad})) ${test_pnm} |\ + cmp -s - ${stretch_pnm} && echo "match" ||\ + echo "no match: ${generator} ${toppad} ${leftpad}" + done + done + rm ${stretch_pnm} ${test_pnm} +done diff --git a/test/pnmpad-flip.ok b/test/pnmpad-flip.ok new file mode 100644 index 00000000..af596ad3 --- /dev/null +++ b/test/pnmpad-flip.ok @@ -0,0 +1,64 @@ +Test 1. Should print match sixteen (8x2) times +(pbmnoise -randomseed=100 11 16) +match +match +match +match +match +match +match +match +(pgmnoise -randomseed=100 31 41) +match +match +match +match +match +match +match +match +Test 2. Should print match forty (10x4) times +(pbmmake -b 1 1) +match +match +match +match +match +match +match +match +match +match +(pbmmake -w 1 1) +match +match +match +match +match +match +match +match +match +match +(pbmmake -g 17 11) +match +match +match +match +match +match +match +match +match +match +(ppmpat -argyle1 -randomseed=100 7 8) +match +match +match +match +match +match +match +match +match +match diff --git a/test/pnmpad-flip.test b/test/pnmpad-flip.test new file mode 100755 index 00000000..2013874c --- /dev/null +++ b/test/pnmpad-flip.test @@ -0,0 +1,62 @@ +#! /bin/sh +# This script tests: pnmpad +# Also requires: pamflip pbmmake pbmnoise pgmnoise ppmpat + +# If any of the padding functions is altered, make sure to run this +# test in a more thorough form. Try more input images and more +# values of d0, d1, d2, d3. + +tmpdir=${tmpdir:-/tmp} +test_pnm=${tmpdir}/test.pnm +padded_pnm=${tmpdir}/padded.pnm + +echo "Test 1. Should print match sixteen (8x2) times" + +d0=1; d1=11; d2=10; d3=5; + +for generator in "pbmnoise -randomseed=100 11 16" \ + "pgmnoise -randomseed=100 31 41" + do + ${generator} > ${test_pnm} + echo "("${generator}")" + for method in "-black" "-white" "-color rgb:20/30/e0" "-extend-edge" + do + pnmpad ${method} -t ${d0} -r ${d1} -b ${d2} -l ${d3} ${test_pnm} > ${padded_pnm} + + pamflip -lr ${test_pnm} |\ + pnmpad ${method} -t ${d0} -l ${d1} -b ${d2} -r ${d3} | pamflip -lr |\ + cmp -s ${padded_pnm} - && echo "match" || echo "no match" + + pamflip -r90 ${test_pnm} |\ + pnmpad ${method} -l ${d0} -t ${d1} -r ${d2} -b ${d3} | pamflip -r270 |\ + cmp -s ${padded_pnm} - && echo "match" || echo "no match" + + done +done + +echo "Test 2. Should print match forty (10x4) times" + +# Test images with all corners with the same colors + +for generator in "pbmmake -b 1 1" \ + "pbmmake -w 1 1" \ + "pbmmake -g 17 11" \ + "ppmpat -argyle1 -randomseed=100 7 8" + do + ${generator} > ${test_pnm} + echo "("${generator}")" + for method in "-black" "-white" "-color rgb:20/30/e0 -promote none" \ + "-detect-background" "-extend-edge" + do + pnmpad ${method} -t ${d0} -r ${d1} -b ${d2} -l ${d3} ${test_pnm} > ${padded_pnm} + + pamflip -lr ${test_pnm} |\ + pnmpad ${method} -t ${d0} -l ${d1} -b ${d2} -r ${d3} | pamflip -lr |\ + cmp -s ${padded_pnm} - && echo "match" || echo "no match" + + pamflip -r90 ${test_pnm} |\ + pnmpad ${method} -l ${d0} -t ${d1} -r ${d2} -b ${d3} | pamflip -r270 |\ + cmp -s ${padded_pnm} - && echo "match" || echo "no match" + + done +done diff --git a/test/pnmpad-format.ok b/test/pnmpad-format.ok new file mode 100644 index 00000000..9938a170 --- /dev/null +++ b/test/pnmpad-format.ok @@ -0,0 +1,135 @@ +Test 1. PBM infile +Should print: PBM raw, 8 by 1 fourteen times +stdin: PBM raw, 8 by 1 +stdin: PBM raw, 8 by 1 +stdin: PBM raw, 8 by 1 +stdin: PBM raw, 8 by 1 +stdin: PBM raw, 8 by 1 +stdin: PBM raw, 8 by 1 +stdin: PBM raw, 8 by 1 +stdin: PBM raw, 8 by 1 +stdin: PBM raw, 8 by 1 +stdin: PBM raw, 8 by 1 +stdin: PBM raw, 8 by 1 +stdin: PBM raw, 8 by 1 +stdin: PBM raw, 8 by 1 +stdin: PBM raw, 8 by 1 +Should print: PGM raw, 8 by 1 maxval 1 twice +stdin: PGM raw, 8 by 1 maxval 1 +stdin: PGM raw, 8 by 1 maxval 1 +Should print: PGM raw, 8 by 1 maxval 255 twice +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +Should print: PPM raw, 8 by 1 maxval 1 once +stdin: PPM raw, 8 by 1 maxval 1 +Should print: PPM raw, 8 by 1 maxval 255 twice +stdin: PPM raw, 8 by 1 maxval 255 +stdin: PPM raw, 8 by 1 maxval 255 + +Test 2. PGM maxval 127 infile +Should print: PGM raw, 8 by 1 maxval 127 sixteen times +stdin: PGM raw, 8 by 1 maxval 127 +stdin: PGM raw, 8 by 1 maxval 127 +stdin: PGM raw, 8 by 1 maxval 127 +stdin: PGM raw, 8 by 1 maxval 127 +stdin: PGM raw, 8 by 1 maxval 127 +stdin: PGM raw, 8 by 1 maxval 127 +stdin: PGM raw, 8 by 1 maxval 127 +stdin: PGM raw, 8 by 1 maxval 127 +stdin: PGM raw, 8 by 1 maxval 127 +stdin: PGM raw, 8 by 1 maxval 127 +stdin: PGM raw, 8 by 1 maxval 127 +stdin: PGM raw, 8 by 1 maxval 127 +stdin: PGM raw, 8 by 1 maxval 127 +stdin: PGM raw, 8 by 1 maxval 127 +stdin: PGM raw, 8 by 1 maxval 127 +stdin: PGM raw, 8 by 1 maxval 127 +Should print: PGM raw, 8 by 1 maxval 255 four times +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +Should print: PPM raw, 8 by 1 maxval 127 once +stdin: PPM raw, 8 by 1 maxval 127 +Should print: PPM raw, 8 by 1 maxval 255 twice +stdin: PPM raw, 8 by 1 maxval 255 +stdin: PPM raw, 8 by 1 maxval 255 + +Test 3. PGM maxval 255 infile +Should print: PGM raw, 8 by 1 maxval 255 eighteen times +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +Should print: PPM raw, 8 by 1 maxval 255 three times +stdin: PPM raw, 8 by 1 maxval 255 +stdin: PPM raw, 8 by 1 maxval 255 +stdin: PPM raw, 8 by 1 maxval 255 + +Test 4. PPM maxval 127 infile +Should print: PPM raw, 8 by 1 maxval 127 seventeen times +stdin: PPM raw, 8 by 1 maxval 127 +stdin: PPM raw, 8 by 1 maxval 127 +stdin: PPM raw, 8 by 1 maxval 127 +stdin: PPM raw, 8 by 1 maxval 127 +stdin: PPM raw, 8 by 1 maxval 127 +stdin: PPM raw, 8 by 1 maxval 127 +stdin: PPM raw, 8 by 1 maxval 127 +stdin: PPM raw, 8 by 1 maxval 127 +stdin: PPM raw, 8 by 1 maxval 127 +stdin: PPM raw, 8 by 1 maxval 127 +stdin: PPM raw, 8 by 1 maxval 127 +stdin: PPM raw, 8 by 1 maxval 127 +stdin: PPM raw, 8 by 1 maxval 127 +stdin: PPM raw, 8 by 1 maxval 127 +stdin: PPM raw, 8 by 1 maxval 127 +stdin: PPM raw, 8 by 1 maxval 127 +stdin: PPM raw, 8 by 1 maxval 127 +Should print: PPM raw, 8 by 1 maxval 255 five times +stdin: PPM raw, 8 by 1 maxval 255 +stdin: PPM raw, 8 by 1 maxval 255 +stdin: PPM raw, 8 by 1 maxval 255 +stdin: PPM raw, 8 by 1 maxval 255 +stdin: PPM raw, 8 by 1 maxval 255 + +Test 5. PPM maxval 511 infile +Should print: PPM raw, 8 by 1 maxval 511 twenty-five times +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 diff --git a/test/pnmpad-format.test b/test/pnmpad-format.test new file mode 100755 index 00000000..73ea6d2b --- /dev/null +++ b/test/pnmpad-format.test @@ -0,0 +1,245 @@ +#! /bin/sh +# This script tests: pnmpad +# Also requires: pbmmake pgmmake ppmmake pamfile + +tmpdir=${tmpdir:-/tmp} + +white_pbm=${tmpdir}/white.pbm +#black_pbm=${tmpdir}/black.pbm +test127_pgm=${tmpdir}/testimg1.pgm +test255_pgm=${tmpdir}/testimg2.pgm +test511_pgm=${tmpdir}/testimg3.pgm +test127_ppm=${tmpdir}/testimg1.ppm +test255_ppm=${tmpdir}/testimg2.ppm +test511_ppm=${tmpdir}/testimg3.ppm + +BLACK="rgbi:0.0/0.0/0.0" +WHITE="rgbi:1.0/1.0/1.0" +LIGHTGRAY="rgbi:0.6/0.6/0.6" +LIGHTGRAYv=0.6 +DARKGRAY="rgbi:0.01/0.01/0.01" +DARKGRAYv=0.01 +PURPLE="rgb:A0/20/F0" +YELLOW="rgb:FF/FF/00" + +pbmmake -w 3 1 > ${white_pbm} +#pbmmake -b 3 1 > ${black_pbm} +pgmmake 0.2 3 1 -maxval 127 > ${test127_pgm} +pgmmake 0.2 3 1 -maxval 255 > ${test255_pgm} +ppmmake ${YELLOW} 3 1 -maxval 127 > ${test127_ppm} +ppmmake ${YELLOW} 3 1 -maxval 511 > ${test511_ppm} + +# define function +ckfmt() { pamfile || echo "failure"; } + +size="-width 8" + +echo "Test 1. PBM infile" + +infile=${white_pbm} + +echo "Should print: PBM raw, 8 by 1 fourteen times" + +pnmpad ${size} ${infile} | ckfmt +pnmpad ${size} -black ${infile} | ckfmt +pnmpad ${size} -white ${infile} | ckfmt +pnmpad ${size} -extend-edge ${infile} | ckfmt +pnmpad ${size} -detect-background ${infile} | ckfmt + +pnmpad ${size} -color ${BLACK} ${infile} | ckfmt +pnmpad ${size} -color ${BLACK} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${BLACK} -promote format ${infile} | ckfmt + +pnmpad ${size} -color ${WHITE} ${infile} | ckfmt +pnmpad ${size} -color ${WHITE} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${WHITE} -promote format ${infile} | ckfmt + +pnmpad ${size} -color ${LIGHTGRAY} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${DARKGRAY} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${PURPLE} -promote none ${infile} | ckfmt + +echo "Should print: PGM raw, 8 by 1 maxval 1 twice" + +pnmpad ${size} -color ${LIGHTGRAY} -promote format ${infile} | ckfmt +pnmpad ${size} -color ${DARKGRAY} -promote format ${infile} | ckfmt + +echo "Should print: PGM raw, 8 by 1 maxval 255 twice" + +pnmpad ${size} -color ${LIGHTGRAY} ${infile} | ckfmt +pnmpad ${size} -color ${DARKGRAY} ${infile} | ckfmt + +echo "Should print: PPM raw, 8 by 1 maxval 1 once" + +pnmpad ${size} -color ${PURPLE} -promote format ${infile} | ckfmt + +echo "Should print: PPM raw, 8 by 1 maxval 255 twice" + +pnmpad ${size} -color ${PURPLE} ${infile} | ckfmt +pnmpad ${size} -color ${PURPLE} -promote all ${infile} | ckfmt + +rm ${infile} + +echo +echo "Test 2. PGM maxval 127 infile" + +infile=${test127_pgm} + +echo "Should print: PGM raw, 8 by 1 maxval 127 sixteen times" + +pnmpad ${size} ${infile} | ckfmt +pnmpad ${size} -black ${infile} | ckfmt +pnmpad ${size} -white ${infile} | ckfmt +pnmpad ${size} -extend-edge ${infile} | ckfmt +pnmpad ${size} -detect-background ${infile} | ckfmt + +pnmpad ${size} -color ${BLACK} ${infile} | ckfmt +pnmpad ${size} -color ${BLACK} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${BLACK} -promote format ${infile} | ckfmt + +pnmpad ${size} -color ${WHITE} ${infile} | ckfmt +pnmpad ${size} -color ${WHITE} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${WHITE} -promote format ${infile} | ckfmt + +pnmpad ${size} -color ${LIGHTGRAY} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${LIGHTGRAY} -promote format ${infile} | ckfmt + +pnmpad ${size} -color ${DARKGRAY} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${DARKGRAY} -promote format ${infile} | ckfmt + +pnmpad ${size} -color ${PURPLE} -promote none ${infile} | ckfmt + +echo "Should print: PGM raw, 8 by 1 maxval 255 four times" + +pnmpad ${size} -color ${LIGHTGRAY} ${infile} | ckfmt +pnmpad ${size} -color ${LIGHTGRAY} -promote all ${infile} | ckfmt +pnmpad ${size} -color ${DARKGRAY} ${infile} | ckfmt +pnmpad ${size} -color ${DARKGRAY} -promote all ${infile} | ckfmt + +echo "Should print: PPM raw, 8 by 1 maxval 127 once" + +pnmpad ${size} -color ${PURPLE} -promote format ${infile} | ckfmt + +echo "Should print: PPM raw, 8 by 1 maxval 255 twice" + +pnmpad ${size} -color ${PURPLE} ${infile} | ckfmt +pnmpad ${size} -color ${PURPLE} -promote all ${infile} | ckfmt + +rm ${infile} + +echo +echo "Test 3. PGM maxval 255 infile" + +infile=${test255_pgm} + +echo "Should print: PGM raw, 8 by 1 maxval 255 eighteen times" + +pnmpad ${size} ${infile} | ckfmt +pnmpad ${size} -black ${infile} | ckfmt +pnmpad ${size} -white ${infile} | ckfmt +pnmpad ${size} -extend-edge ${infile} | ckfmt +pnmpad ${size} -detect-background ${infile} | ckfmt + +pnmpad ${size} -color ${BLACK} ${infile} | ckfmt +pnmpad ${size} -color ${BLACK} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${BLACK} -promote format ${infile} | ckfmt +pnmpad ${size} -color ${BLACK} -promote all ${infile} | ckfmt + +pnmpad ${size} -color ${LIGHTGRAY} ${infile} | ckfmt +pnmpad ${size} -color ${LIGHTGRAY} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${LIGHTGRAY} -promote format ${infile} | ckfmt +pnmpad ${size} -color ${LIGHTGRAY} -promote all ${infile} | ckfmt + + +pnmpad ${size} -color ${DARKGRAY} ${infile} | ckfmt +pnmpad ${size} -color ${DARKGRAY} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${DARKGRAY} -promote format ${infile} | ckfmt +pnmpad ${size} -color ${DARKGRAY} -promote all ${infile} | ckfmt + +pnmpad ${size} -color ${PURPLE} -promote none ${infile} | ckfmt + +echo "Should print: PPM raw, 8 by 1 maxval 255 three times" + +pnmpad ${size} -color ${PURPLE} ${infile} | ckfmt + +pnmpad ${size} -color ${PURPLE} -promote format ${infile} | ckfmt +pnmpad ${size} -color ${PURPLE} -promote all ${infile} | ckfmt + +rm ${infile} + +echo +echo "Test 4. PPM maxval 127 infile" + +infile=${test127_ppm} + +echo "Should print: PPM raw, 8 by 1 maxval 127 seventeen times" + +pnmpad ${size} ${infile} | ckfmt +pnmpad ${size} -black ${infile} | ckfmt +pnmpad ${size} -white ${infile} | ckfmt +pnmpad ${size} -extend-edge ${infile} | ckfmt +pnmpad ${size} -detect-background ${infile} | ckfmt + +pnmpad ${size} -color ${BLACK} ${infile} | ckfmt +pnmpad ${size} -color ${BLACK} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${BLACK} -promote format ${infile} | ckfmt +pnmpad ${size} -color ${WHITE} ${infile} | ckfmt +pnmpad ${size} -color ${WHITE} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${WHITE} -promote format ${infile} | ckfmt + +pnmpad ${size} -color ${LIGHTGRAY} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${LIGHTGRAY} -promote format ${infile} | ckfmt +pnmpad ${size} -color ${DARKGRAY} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${DARKGRAY} -promote format ${infile} | ckfmt + +pnmpad ${size} -color ${PURPLE} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${PURPLE} -promote format ${infile} | ckfmt + +echo "Should print: PPM raw, 8 by 1 maxval 255 five times" + +pnmpad ${size} -color ${LIGHTGRAY} ${infile} | ckfmt +pnmpad ${size} -color ${DARKGRAY} ${infile} | ckfmt +pnmpad ${size} -color ${PURPLE} ${infile} | ckfmt +pnmpad ${size} -color ${LIGHTGRAY} -promote all ${infile} | ckfmt +pnmpad ${size} -color ${PURPLE} -promote all ${infile} | ckfmt + +rm ${infile} + +echo +echo "Test 5. PPM maxval 511 infile" + +infile=${test511_ppm} + +echo "Should print: PPM raw, 8 by 1 maxval 511 twenty-five times" + +pnmpad ${size} ${infile} | ckfmt +pnmpad ${size} -black ${infile} | ckfmt +pnmpad ${size} -white ${infile} | ckfmt +pnmpad ${size} -extend-edge ${infile} | ckfmt +pnmpad ${size} -detect-background ${infile} | ckfmt + +pnmpad ${size} -color ${BLACK} ${infile} | ckfmt +pnmpad ${size} -color ${BLACK} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${BLACK} -promote format ${infile} | ckfmt +pnmpad ${size} -color ${BLACK} -promote all ${infile} | ckfmt + +pnmpad ${size} -color ${WHITE} ${infile} | ckfmt +pnmpad ${size} -color ${WHITE} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${WHITE} -promote format ${infile} | ckfmt +pnmpad ${size} -color ${WHITE} -promote all ${infile} | ckfmt + +pnmpad ${size} -color ${LIGHTGRAY} ${infile} | ckfmt +pnmpad ${size} -color ${LIGHTGRAY} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${LIGHTGRAY} -promote format ${infile} | ckfmt +pnmpad ${size} -color ${LIGHTGRAY} -promote all ${infile} | ckfmt + +pnmpad ${size} -color ${DARKGRAY} ${infile} | ckfmt +pnmpad ${size} -color ${DARKGRAY} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${DARKGRAY} -promote format ${infile} | ckfmt +pnmpad ${size} -color ${DARKGRAY} -promote all ${infile} | ckfmt + +pnmpad ${size} -color ${PURPLE} ${infile} | ckfmt +pnmpad ${size} -color ${PURPLE} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${PURPLE} -promote format ${infile} | ckfmt +pnmpad ${size} -color ${PURPLE} -promote all ${infile} | ckfmt + +rm ${infile} diff --git a/test/pnmpad-pnmmargin.ok b/test/pnmpad-pnmmargin.ok new file mode 100644 index 00000000..552c530f --- /dev/null +++ b/test/pnmpad-pnmmargin.ok @@ -0,0 +1,15 @@ +Test 1. Should print match three times +match +match +match +Test 2. Should print match four times +match +match +match +match +Test 3. Should print match five times +match +match +match +match +match diff --git a/test/pnmpad-pnmmargin.test b/test/pnmpad-pnmmargin.test new file mode 100755 index 00000000..8b23be35 --- /dev/null +++ b/test/pnmpad-pnmmargin.test @@ -0,0 +1,79 @@ +#! /bin/sh +# This script tests: pnmpad pnmmargin +# Also requires: pamcat pamcut pamenlarge pbmmake pnmmargin ppmmake ppmpat + +tmpdir=${tmpdir:-/tmp} +padded_pbm=${tmpdir}/padded.pbm +argyle_ppm=${tmpdir}/argyle.ppm +padded_ppm=${tmpdir}/padded.ppm + +spacer_pnm=${tmpdir}/spacer.pnm + +# define function +addmargin () { + +# This function takes 3 positional parameters: +# $1: color black white or gofigure +# $2: color string (ignore if black white or gofigure) +# $3: margin +# $4: filename + + case $1 in + -color) ppmmake $2 $3 $3 > ${spacer_pnm}; infile=$4 ;; + -black) pbmmake -black $2 $2 > ${spacer_pnm}; infile=$3 ;; + -white) pbmmake -white $2 $2 > ${spacer_pnm}; infile=$3 ;; + *) pamcut -t 0 -l 0 -w 1 -h 1 $2 | pamenlarge $1 > ${spacer_pnm}; infile=$2 ;; + esac + pamcat -lr ${spacer_pnm} ${infile} ${spacer_pnm} |\ + pamcat -tb ${spacer_pnm} - ${spacer_pnm} + rm ${spacer_pnm} +} + +echo "Test 1. Should print match three times" + +pnmmargin -black 5 maze.pbm > ${padded_pbm} +pnmmargin -black 1 maze.pbm | pnmpad -black -t 4 -b 4 -l 4 -r 4 |\ + cmp -s ${padded_pbm} - && echo "match" || echo "no match" +pnmmargin 1 maze.pbm | pnmpad -black -t 4 -b 4 -l 4 -r 4 |\ + cmp -s ${padded_pbm} - && echo "match" || echo "no match" +pnmmargin -black 1 maze.pbm | pnmpad -extend-edge -t 4 -b 4 -l 4 -r 4 |\ + cmp -s ${padded_pbm} - && echo "match" || echo "no match" + + +echo "Test 2. Should print match four times" + +addmargin -black 5 maze.pbm |\ + cmp -s ${padded_pbm} - && echo "match" || echo "no match" +addmargin -black 1 maze.pbm | pnmpad -black -t 4 -b 4 -l 4 -r 4 |\ + cmp -s ${padded_pbm} - && echo "match" || echo "no match" +addmargin 1 maze.pbm | pnmpad -black -t 4 -b 4 -l 4 -r 4 |\ + cmp -s ${padded_pbm} - && echo "match" || echo "no match" +addmargin -black 1 maze.pbm | pnmpad -extend-edge -t 4 -b 4 -l 4 -r 4 |\ + cmp -s ${padded_pbm} - && echo "match" || echo "no match" + +rm ${padded_pbm} + +echo "Test 3. Should print match five times" + +ppmpat -argyle1 -color=rgb:20/30/ff,rgb:70/80/ff 30 20 > ${argyle_ppm} + +addmargin 3 ${argyle_ppm} > ${padded_ppm} + +addmargin -color rgb:20/30/ff 1 ${argyle_ppm} |\ + pnmpad -color=rgb:20/30/ff -t 2 -b 2 -r 2 -l 2 |\ + cmp -s ${padded_ppm} - && echo "match" || echo "no match" +addmargin -color rgb:20/30/ff 1 ${argyle_ppm} |\ + pnmpad -color=rgb:20/30/ff -t 2 -b 2 -r 2 -l 2 |\ + cmp -s ${padded_ppm} - && echo "match" || echo "no match" +addmargin 1 ${argyle_ppm} |\ + pnmpad -extend-edge -t 2 -b 2 -r 2 -l 2 |\ + cmp -s ${padded_ppm} - && echo "match" || echo "no match" + +pnmpad -color rgb:20/30/ff -t 3 -b 3 -r 3 -l 3 ${argyle_ppm} |\ + cmp -s ${padded_ppm} - && echo "match" || echo "no match" + +pnmpad -detect-background -t 3 -b 3 -r 3 -l 3 ${argyle_ppm} |\ + cmp -s ${padded_ppm} - && echo "match" || echo "no match" + + +rm ${argyle_ppm} ${padded_ppm} diff --git a/test/pnmpad-reportonly.ok b/test/pnmpad-reportonly.ok index e7d0a0d1..2cf58f39 100644 --- a/test/pnmpad-reportonly.ok +++ b/test/pnmpad-reportonly.ok @@ -65,3 +65,11 @@ Test 9. Should print 0 0 4 8 19 112 seven times 0 0 4 8 19 112 0 0 4 8 19 112 0 0 4 8 19 112 +Test Invalid +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) +Expected failure 5 (no output) +Expected failure 6 (no output) +Expected failure 7 (no output) diff --git a/test/pnmpad-reportonly.test b/test/pnmpad-reportonly.test index ccd79e69..412cb8a2 100755 --- a/test/pnmpad-reportonly.test +++ b/test/pnmpad-reportonly.test @@ -125,5 +125,34 @@ for pad in "-t 4 -b 8 -h 112" \ pnmpad -reportonly ${pad} ${test_ppm} || echo "failure" done - +echo "Test Invalid" + +test_out=${tmpdir}/test_out +n=1 + +# define function +invcmd () { $1 > ${test_out} || \ + printf "Expected failure $n " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + n=$(($n +1)); } + +echo 1>&2 +echo "Invalid command-line arguments." 1>&2 +echo "Error messages should appear below the line." 1>&2 +echo "-----------------------------------------------------------" 1>&2 + +invcmd "pnmpad -reportonly -l 1 -r 1 -w 100 testgrid.pbm" +invcmd "pnmpad -reportonly -t 1 -b 1 -h 100 testgrid.pbm" +invcmd "pnmpad -reportonly -black -white -l 1 testgrid.pbm" +invcmd "pnmpad -reportonly -color -l 1 testgrid.pbm" +invcmd "pnmpad -reportonly -color rgbi:0/0/0 -white -l 1 testgrid.pbm" +invcmd "pnmpad -reportonly -color rgbi:0/0/0 -extend-edge -l 1 testgrid.pbm" +invcmd "pnmpad -reportonly -color rgbi:0/0/0 -detect-background -l 1 testgrid.pbm" + +# echo "Test Invalid. Should print failure twice" +# +# pnmpad -reportonly -l 1 -r 1 -w 100 testgrid.pbm && echo "unexpected success" || echo "failure" +# pnmpad -reportonly -t 1 -b 1 -h 100 testgrid.pbm && echo "unexpected success" || echo "failure" +# rm ${test1_pbm} ${test2_pbm} ${test_pgm} ${test_ppm} diff --git a/test/stdin-pnm1.test b/test/stdin-pnm1.test index ae848752..20902d41 100755 --- a/test/stdin-pnm1.test +++ b/test/stdin-pnm1.test @@ -4,7 +4,7 @@ # This script tests: pnmmontage pnmnlfilt pnmnorm pnmpad pnmquant pnmrotate # This script tests: pnmscalefixed pnmshear pnmsmooth pnmtile pnmtoddif # This script tests: pnmtopclxl -# Also requires: ppmpat pamflip +# Also requires: ppmpat tmpdir=${tmpdir:-/tmp} small_ppm=${tmpdir}/test.ppm |