diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2020-09-19 17:45:23 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2020-09-19 17:45:23 +0000 |
commit | 6f5eb59711bbff9101aefcbb803f3c63afc7c548 (patch) | |
tree | 5b75ba0e6062ab88a72482621afaef6a183743ff /test | |
parent | d683501e89c17b4c6613b5268dc5e3111bd8a20d (diff) | |
download | netpbm-mirror-6f5eb59711bbff9101aefcbb803f3c63afc7c548.tar.gz netpbm-mirror-6f5eb59711bbff9101aefcbb803f3c63afc7c548.tar.xz netpbm-mirror-6f5eb59711bbff9101aefcbb803f3c63afc7c548.zip |
Add Pamarith, Pamfunc tests for PBM
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@3963 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'test')
-rw-r--r-- | test/pamarith.ok | 83 | ||||
-rwxr-xr-x | test/pamarith.test | 123 | ||||
-rw-r--r-- | test/pamfunc.ok | 94 | ||||
-rwxr-xr-x | test/pamfunc.test | 130 |
4 files changed, 296 insertions, 134 deletions
diff --git a/test/pamarith.ok b/test/pamarith.ok index a86b0260..782637d3 100644 --- a/test/pamarith.ok +++ b/test/pamarith.ok @@ -84,7 +84,44 @@ P2 16 1 15 0 0 0 0 1 1 1 1 2 2 2 2 3 3 3 3 2898922266 59 2898922266 59 2898922266 59 -Test 2 (input = output) +Test 2 PBM +P1 +8 2 +01010101 +00001111 +-add +P1 8 1 00000101 +-subtract +P1 8 1 11110101 +-multiply +P1 8 1 01011111 +-divide +P1 8 1 01010000 +-difference +P1 8 1 10100101 +-minimum +P1 8 1 01011111 +-maximum +P1 8 1 00000101 +-mean +P1 8 1 00000101 +-compare +P2 8 1 2 1 0 1 0 2 1 2 1 +-and +P1 8 1 01011111 +-or +P1 8 1 00000101 +-nand +P1 8 1 10100000 +-nor +P1 8 1 11111010 +-xor +P1 8 1 10100101 +-shiftleft +P1 8 1 11110101 +-shiftright +P1 8 1 11110101 +Test 3 (input = output) cksum is 2425386270 41 or 2921940274 59 input image 2425386270 41 @@ -110,7 +147,7 @@ input image 2921940274 59 -or 2921940274 59 -Test 3 (blank output) +Test 4 (blank output) cksum is 2817549367 41 or 320101399 59 -subtract 2817549367 41 @@ -124,26 +161,22 @@ cksum is 2817549367 41 or 320101399 59 320101399 59 -xor 320101399 59 -Test Error: Should print 1 twenty-two times -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 +Test Invalid +Expected failure 1 1 +Expected failure 2 1 +Expected failure 3 1 +Expected failure 4 1 +Expected failure 5 1 +Expected failure 6 1 +Expected failure 7 1 +Expected failure 8 1 +Expected failure 9 1 +Expected failure 10 1 +Expected failure 11 1 +Expected failure 12 1 +Expected failure 13 1 +Expected failure 14 1 +Expected failure 15 1 +Expected failure 16 1 +Expected failure 17 1 +Expected failure 18 1 diff --git a/test/pamarith.test b/test/pamarith.test index 72d3d503..d8055385 100755 --- a/test/pamarith.test +++ b/test/pamarith.test @@ -1,6 +1,8 @@ + #! /bin/bash # This script tests: pamarith # Also requires: pamchannel pamseq pamtopnm pgmmake pnmcat rgb3toppm +# Also requires: pbmmake pamenlarge tmpdir=${tmpdir:-/tmp} input1_pgm=${tmpdir}/input1.pgm @@ -34,7 +36,30 @@ for fn in "-add" "-subtract" "-multiply" "-divide" "-difference" \ rm ${input1_pgm} ${input2_pgm} ${output_pgm} ${input2_ppm} -echo "Test 2 (input = output)" + +input1_pbm=${tmpdir}/input1.pbm +input2_pbm=${tmpdir}/input2.pbm + +echo "Test 2 PBM" + +pbmmake -g 8 1 > ${input1_pbm} +pbmmake -g 2 1 | pamenlarge -xscale=4 > ${input2_pbm} + +pnmcat -tb -plain ${input1_pbm} ${input2_pbm} + +for fn in "-add" "-subtract" "-multiply" "-divide" "-difference" \ + "-minimum" "-maximum" "-mean" "-compare" \ + "-and" "-or" "-nand" "-nor" "-xor" \ + "-shiftleft" "-shiftright" + do + echo ${fn} + pamarith ${fn} -plain ${input1_pbm} ${input2_pbm} | tr '\n' ' '; echo + done + +rm ${input1_pbm} ${input2_pbm} + + +echo "Test 3 (input = output)" echo "cksum is 2425386270 41 or 2921940274 59" for image in testgrid.pbm ${input1_ppm} @@ -49,7 +74,7 @@ for image in testgrid.pbm ${input1_ppm} done -echo "Test 3 (blank output)" +echo "Test 4 (blank output)" echo "cksum is 2817549367 41 or 320101399 59" for image in testgrid.pbm ${input1_ppm} @@ -68,37 +93,73 @@ echo "Invalid command-line argument combinations." 1>&2 echo "Error messages should appear below the line." 1>&2 echo "-----------------------------------------------------------" 1>&2 -echo "Test Error: Should print 1 twenty-two times" +echo "Test Invalid" output_ppm=${tmpdir}/output.ppm -for option in "-add -subtract" \ - "-multiply -divide" \ - "-difference -minimum" \ - "-maximum -mean" \ - "-compare -and" \ - "-or -nand" \ - "-nor -xor" \ - "-shiftleft -shiftright" - do - pamarith ${option} testimg.ppm testimg.ppm > ${output_ppm} - echo $? - test -s ${output_ppm} - echo $? - done - - pamarith -add testimg.ppm testimg.ppm testimg.ppm > ${output_ppm} - echo $? - test -s ${output_ppm} - echo $? - pamarith -add testimg.ppm testgrid.pbm > ${output_ppm} - echo $? - test -s ${output_ppm} - echo $? - pamchannel -infile testimg.ppm 0 1 | \ - pamarith -add testimg.ppm - > ${output_ppm} - echo $? - test -s ${output_ppm} - echo $? +pamarith -add -subtract testimg.ppm testimg.ppm > ${output_ppm} || \ + echo -n "Expected failure 1" + test -s ${output_ppm}; echo " "$? +pamarith -multiply -divide testimg.ppm testimg.ppm > ${output_ppm} || \ + echo -n "Expected failure 2" + test -s ${output_ppm}; echo " "$? +pamarith -difference -minimum testimg.ppm testimg.ppm > ${output_ppm} || \ + echo -n "Expected failure 3" + test -s ${output_ppm}; echo " "$? +pamarith -maximum -mean testimg.ppm testimg.ppm > ${output_ppm} || \ + echo -n "Expected failure 4" + test -s ${output_ppm}; echo " "$? +pamarith -compare -and testimg.ppm testimg.ppm > ${output_ppm} || \ + echo -n "Expected failure 5" + test -s ${output_ppm}; echo " "$? +pamarith -or -nand testimg.ppm testimg.ppm > ${output_ppm} || \ + echo -n "Expected failure 6" + test -s ${output_ppm}; echo " "$? +pamarith -nor -xor testimg.ppm testimg.ppm > ${output_ppm} || \ + echo -n "Expected failure 7" + test -s ${output_ppm}; echo " "$? +pamarith -shiftleft -shiftright testimg.ppm testimg.ppm > ${output_ppm} || \ + echo -n "Expected failure 8" + test -s ${output_ppm}; echo " "$? +pamarith -add=1 testimg.ppm testimg.ppm > ${output_ppm} || \ + echo -n "Expected failure 9" + test -s ${output_ppm}; echo " "$? + +pamarith -plain testimg.ppm testimg.ppm > ${output_ppm} || \ + echo -n "Expected failure 10" + test -s ${output_ppm}; echo " "$? + +pamarith testimg.ppm testimg.ppm > ${output_ppm} || \ + echo -n "Expected failure 11" + test -s ${output_ppm}; echo " "$? + +pamarith -add testimg.ppm testimg.ppm testimg.ppm > ${output_ppm} + echo -n "Expected failure 12" + test -s ${output_ppm}; echo " "$? +pamarith -add testimg.ppm > ${output_ppm} + echo -n "Expected failure 13" + test -s ${output_ppm}; echo " "$? +pamarith -add > ${output_ppm} + echo -n "Expected failure 14" + test -s ${output_ppm}; echo " "$? + +pamarith -add testimg.ppm testgrid.pbm > ${output_ppm} + echo -n "Expected failure 15" + test -s ${output_ppm}; echo " "$? + +pamchannel -infile testimg.ppm 0 1 | \ + pamarith -add testimg.ppm - > ${output_ppm} + echo -n "Expected failure 16" + test -s ${output_ppm}; echo " "$? + +pamenlarge -xscale=2 testgrid.pbm | \ + pamarith -add testgrid.pbm - > ${output_ppm} + echo -n "Expected failure 17" + test -s ${output_ppm}; echo " "$? + +pamenlarge -yscale=3 testgrid.pbm | \ + pamarith -add testgrid.pbm - > ${output_ppm} + echo -n "Expected failure 18" + test -s ${output_ppm}; echo " "$? rm ${output_ppm} \ No newline at end of file diff --git a/test/pamfunc.ok b/test/pamfunc.ok index 50336866..4a531577 100644 --- a/test/pamfunc.ok +++ b/test/pamfunc.ok @@ -10,10 +10,24 @@ P2 16 1 15 0 2 4 6 8 10 12 14 0 2 4 6 8 10 12 14 P2 16 1 15 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 P2 16 1 15 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 P2 16 1 15 0 0 2 2 4 4 6 6 8 8 10 10 12 12 14 14 -Test 2 (-changemaxval) +Test 2 +P1 8 1 01010101 +P1 8 1 00000000 +P1 8 1 11111111 +P1 8 1 01010101 +P1 8 1 01010101 +P1 8 1 01010101 +P1 8 1 00000000 +P1 8 1 11111111 +P1 8 1 11111111 +P1 8 1 11111111 +P1 8 1 11111111 +Test 3 (-changemaxval) P2 16 1 30 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 P2 16 1 60 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 -Test 3: Should print 1926073387 101484 eight times +P1 8 1 01010101 +P1 8 1 11111111 +Test 4: Should print 1926073387 101484 eight times 1926073387 101484 1926073387 101484 1926073387 101484 @@ -22,59 +36,35 @@ Test 3: Should print 1926073387 101484 eight times 1926073387 101484 1926073387 101484 1926073387 101484 -Test 4: Should print 2425386270 41 six times +Test 5: Should print 2425386270 41 six times 2425386270 41 2425386270 41 2425386270 41 2425386270 41 2425386270 41 2425386270 41 -Test Error: Should print 0 then 1 twenty-four times -0 -1 -0 -1 -0 -1 -0 -1 -0 -1 -0 -1 -0 -1 -0 -1 -0 -1 -0 -1 -0 -1 -0 -1 -0 -1 -0 -1 -0 -1 -0 -1 -0 -1 -0 -1 -0 -1 -0 -1 -0 -1 -0 -1 -0 -1 -0 -1 +Test Invalid +Expected failure 1 1 +Expected failure 2 1 +Expected failure 3 1 +Expected failure 4 1 +Expected failure 5 1 +Expected failure 6 1 +Expected failure 7 1 +Expected failure 8 1 +Expected failure 9 1 +Expected failure 10 1 +Expected failure 11 1 +Expected failure 12 1 +Expected failure 13 1 +Expected failure 14 1 +Expected failure 15 1 +Expected failure 16 1 +Expected failure 17 1 +Expected failure 18 1 +Expected failure 19 1 +Expected failure 20 1 +Expected failure 21 1 +Expected failure 22 1 +Expected failure 23 1 +Expected failure 24 1 diff --git a/test/pamfunc.test b/test/pamfunc.test index 2271974e..f9a8a33e 100755 --- a/test/pamfunc.test +++ b/test/pamfunc.test @@ -1,6 +1,6 @@ #! /bin/bash # This script tests: pamfunc -# Also requires: pamseq pamtopnm +# Also requires: pamseq pamtopnm pbmmake tmpdir=${tmpdir:-/tmp} input_pgm=${tmpdir}/input.pgm @@ -25,16 +25,42 @@ pamfunc -shiftright 1 ${input_pgm} | pamfunc -shiftleft 1 -plain | \ tr '\n' ' '; echo -echo "Test 2 (-changemaxval)" +input_pbm=${tmpdir}/input.pbm + +echo "Test 2" + +pbmmake -g 8 1 > ${input_pbm} +pamtopnm -plain ${input_pbm} | tr '\n' ' '; echo + +pamfunc -adder=1 -plain ${input_pbm} | tr '\n' ' '; echo +pamfunc -subtractor=1 -plain ${input_pbm} | tr '\n' ' '; echo +pamfunc -multiplier=1 -plain ${input_pbm} | tr '\n' ' '; echo +pamfunc -divisor=1 -plain ${input_pbm} | tr '\n' ' '; echo +pamfunc -max=1 -plain ${input_pbm} | tr '\n' ' '; echo +pamfunc -min=1 -plain ${input_pbm} | tr '\n' ' '; echo + +pamfunc -shiftleft 1 -plain ${input_pbm} | tr '\n' ' '; echo +pamfunc -shiftright 1 -plain ${input_pbm} | tr '\n' ' '; echo +pamfunc -shiftleft 1 ${input_pbm} | pamfunc -shiftright 1 -plain | \ + tr '\n' ' '; echo +pamfunc -shiftright 1 ${input_pbm} | pamfunc -shiftleft 1 -plain | \ + tr '\n' ' '; echo + + +echo "Test 3 (-changemaxval)" pamfunc -divisor 2 -changemaxval ${input_pgm} -plain | \ tr '\n' ' '; echo pamfunc -multiplier 0.25 -changemaxval ${input_pgm} -plain | \ tr '\n' ' '; echo +pamfunc -divisor 2 -changemaxval ${input_pbm} -plain | \ + tr '\n' ' '; echo +pamfunc -multiplier 0.25 -changemaxval ${input_pbm} -plain | \ + tr '\n' ' '; echo -rm ${input_pgm} +rm ${input_pgm} ${input_pbm} -echo "Test 3: Should print 1926073387 101484 eight times" +echo "Test 4: Should print 1926073387 101484 eight times" cat testimg.ppm | cksum @@ -47,7 +73,7 @@ pamfunc -shiftleft 0 testimg.ppm | cksum pamfunc -shiftright 0 testimg.ppm | cksum -echo "Test 4: Should print 2425386270 41 six times" +echo "Test 5: Should print 2425386270 41 six times" cat testgrid.pbm | cksum @@ -62,27 +88,79 @@ echo "Invalid command-line argument combinations." 1>&2 echo "Error messages should appear below the line." 1>&2 echo "-----------------------------------------------------------" 1>&2 -echo "Test Error: Should print 0 then 1 twenty-four times" +echo "Test Invalid" output_ppm=${tmpdir}/output.ppm -for fn in "-multiplier" "-multiplier=-1" \ - "-divisor" "-divisor=-20" \ - "-adder" "-adder 0.5" "-subtractor" "-subtractor 0.1" \ - "-multiplier=1 -divisor=2" "-adder=2 -subtractor=3" \ - "-min" "-max" "-andmask" "-ormask" "-xormask" "-not 1" \ - "-min=1 -max=2" "-andmask=1 -ormask=0" "-andmask=0xffff" \ - "-shiftleft" "-shiftright" "-changemaxval" \ - "-shiftleft=1 -shiftright=1" \ - "-multiplier=0.5 -changemaxval=65535" - do - - # uncomment to debug - # echo ${fn} - - pamfunc ${fn} testimg.ppm > ${output_ppm} - test $? -eq 1 -o $? -eq 99 - echo $? - test -s ${output_ppm} - echo $? - done \ No newline at end of file +pamfunc -multiplier testimg.ppm > ${output_ppm} || \ + echo -n "Expected failure 1" + test -s ${output_ppm}; echo " "$? +pamfunc -multiplier=-1 testimg.ppm > ${output_ppm} || \ + echo -n "Expected failure 2" + test -s ${output_ppm}; echo " "$? +pamfunc -divisor testimg.ppm > ${output_ppm} || \ + echo -n "Expected failure 3" + test -s ${output_ppm}; echo " "$? +pamfunc -divisor=-20 testimg.ppm > ${output_ppm} || \ + echo -n "Expected failure 4" + test -s ${output_ppm}; echo " "$? +pamfunc -adder testimg.ppm > ${output_ppm} || \ + echo -n "Expected failure 5" + test -s ${output_ppm}; echo " "$? +pamfunc -adder 0.5 testimg.ppm > ${output_ppm} || \ + echo -n "Expected failure 6" + test -s ${output_ppm}; echo " "$? +pamfunc -subtractor testimg.ppm > ${output_ppm} || \ + echo -n "Expected failure 7" + test -s ${output_ppm}; echo " "$? +pamfunc -subtractor 0.1 testimg.ppm > ${output_ppm} || \ + echo -n "Expected failure 8" + test -s ${output_ppm}; echo " "$? +pamfunc -multiplier=1 -divisor=2 testimg.ppm > ${output_ppm} || \ + echo -n "Expected failure 9" + test -s ${output_ppm}; echo " "$? +pamfunc -adder=2 -subtractor=3 testimg.ppm > ${output_ppm} || \ + echo -n "Expected failure 10" + test -s ${output_ppm}; echo " "$? +pamfunc -min testimg.ppm > ${output_ppm} || \ + echo -n "Expected failure 11" + test -s ${output_ppm}; echo " "$? +pamfunc -max testimg.ppm > ${output_ppm} || \ + echo -n "Expected failure 12" + test -s ${output_ppm}; echo " "$? +pamfunc -andmask testimg.ppm > ${output_ppm} || \ + echo -n "Expected failure 13" + test -s ${output_ppm}; echo " "$? +pamfunc -ormask testimg.ppm > ${output_ppm} || \ + echo -n "Expected failure 14" + test -s ${output_ppm}; echo " "$? +pamfunc -xormask testimg.ppm > ${output_ppm} || \ + echo -n "Expected failure 15" + test -s ${output_ppm}; echo " "$? +pamfunc -not 1 testimg.ppm > ${output_ppm} || \ + echo -n "Expected failure 16" + test -s ${output_ppm}; echo " "$? +pamfunc -min=1 -max=2 testimg.ppm > ${output_ppm} || \ + echo -n "Expected failure 17" + test -s ${output_ppm}; echo " "$? +pamfunc -andmask=1 -ormask=0 testimg.ppm > ${output_ppm} || \ + echo -n "Expected failure 18" + test -s ${output_ppm}; echo " "$? +pamfunc -andmask=0xffff testimg.ppm > ${output_ppm} || \ + echo -n "Expected failure 19" + test -s ${output_ppm}; echo " "$? +pamfunc -shiftleft testimg.ppm > ${output_ppm} || \ + echo -n "Expected failure 20" + test -s ${output_ppm}; echo " "$? +pamfunc -shiftright testimg.ppm > ${output_ppm} || \ + echo -n "Expected failure 21" + test -s ${output_ppm}; echo " "$? +pamfunc -changemaxval testimg.ppm > ${output_ppm} || \ + echo -n "Expected failure 22" + test -s ${output_ppm}; echo " "$? +pamfunc -shiftleft=1 -shiftright=1 testimg.ppm > ${output_ppm} || \ + echo -n "Expected failure 23" + test -s ${output_ppm}; echo " "$? +pamfunc -multiplier=0.5 -changemaxval=65535 testimg.ppm > ${output_ppm} || \ + echo -n "Expected failure 24" + test -s ${output_ppm}; echo " "$? |