diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2019-05-30 02:11:23 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2019-05-30 02:11:23 +0000 |
commit | 5314448e55da76bf33edeebc0c17c0866ce2c879 (patch) | |
tree | 4bf04d9c9a34aaee9306cd0fa66099ae3116dea5 /test | |
parent | c95f75ad52009a53373192c6512baa89bbca5608 (diff) | |
download | netpbm-mirror-5314448e55da76bf33edeebc0c17c0866ce2c879.tar.gz netpbm-mirror-5314448e55da76bf33edeebc0c17c0866ce2c879.tar.xz netpbm-mirror-5314448e55da76bf33edeebc0c17c0866ce2c879.zip |
Various new tests and corrections
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@3621 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'test')
-rwxr-xr-x | test/Execute-Tests | 7 | ||||
-rw-r--r-- | test/Test-Order | 7 | ||||
-rwxr-xr-x | test/bmp-quant-roundtrip.test | 2 | ||||
-rwxr-xr-x | test/g3-roundtrip.test | 2 | ||||
-rw-r--r-- | test/pad-crop-roundtrip.ok | 2 | ||||
-rwxr-xr-x | test/pad-crop-roundtrip.test | 15 | ||||
-rw-r--r-- | test/pamfind.ok | 178 | ||||
-rwxr-xr-x | test/pamfind.test | 11 | ||||
-rw-r--r-- | test/pamhue-roundtrip.ok | 10 | ||||
-rwxr-xr-x | test/pamhue-roundtrip.test | 19 | ||||
-rw-r--r-- | test/pamhue.ok | 25 | ||||
-rwxr-xr-x | test/pamhue.test | 10 | ||||
-rw-r--r-- | test/pamscale-filters3.ok | 1 | ||||
-rwxr-xr-x | test/pamscale-filters3.test | 3 | ||||
-rwxr-xr-x | test/pamtable.test | 2 | ||||
-rwxr-xr-x | test/pbm-misc-converters.test | 2 | ||||
-rwxr-xr-x | test/pdb-roundtrip.test | 2 | ||||
-rw-r--r-- | test/pnmcrop-blank.ok | 130 | ||||
-rwxr-xr-x | test/pnmcrop-blank.test | 55 | ||||
-rw-r--r-- | test/pnmcrop1.ok | 109 | ||||
-rwxr-xr-x | test/pnmcrop1.test | 78 | ||||
-rw-r--r-- | test/pnmcrop2.ok | 29 | ||||
-rwxr-xr-x | test/pnmcrop2.test | 55 | ||||
-rw-r--r-- | test/pnmcrop3.ok | 90 | ||||
-rwxr-xr-x | test/pnmcrop3.test | 71 | ||||
-rwxr-xr-x | test/pnmquantall.test | 2 | ||||
-rwxr-xr-x | test/sgi-roundtrip.test | 2 |
27 files changed, 903 insertions, 16 deletions
diff --git a/test/Execute-Tests b/test/Execute-Tests index 7a65d51f..3530d978 100755 --- a/test/Execute-Tests +++ b/test/Execute-Tests @@ -179,9 +179,10 @@ elif [ $VALGRIND_TESTS = "on" ] vg_command_base="valgrind --trace-children=yes"; - for i in awk cat cksum cmp cp cut date dirname egrep fgrep file grep gs \ - head iconv mkdir mktemp perl rm sed seq sh tee testrandom tr uniq \ - Available-Testprog + for i in awk basename cat cksum cmp comm cp cut date dirname \ + egrep fgrep file grep gs head iconv mkdir mktemp perl rm \ + sed seq sh sort tee tr uniq wc \ + testrandom Available-Testprog # Tell valgrind not to probe execution of the above programs. diff --git a/test/Test-Order b/test/Test-Order index 49eaeff2..9721aa17 100644 --- a/test/Test-Order +++ b/test/Test-Order @@ -53,6 +53,7 @@ pnmtopnm-plain.test # Editor tests pamditherbw.test +pamhue.test pbmclean.test pamcut.test @@ -89,6 +90,11 @@ pamenlarge-pamscale-point.test pamstretch.test +pnmcrop1.test +pnmcrop2.test +pnmcrop3.test +pnmcrop-blank.test + ppmmix.test pammixmulti-identity.test @@ -125,6 +131,7 @@ pamslice-roundtrip.test lookup-roundtrip.test enlarge-reduce-roundtrip.test cut-cat-roundtrip.test +pamhue-roundtrip.test # Round-trip tests : lossless converters diff --git a/test/bmp-quant-roundtrip.test b/test/bmp-quant-roundtrip.test index 2c223b7c..9f1036d0 100755 --- a/test/bmp-quant-roundtrip.test +++ b/test/bmp-quant-roundtrip.test @@ -1,6 +1,6 @@ #! /bin/bash # This script tests: bmptopnm ppmtobmp pnmquant -# Also requires: ppmhist +# Also requires: tmpdir=${tmpdir:-/tmp} quant_ppm=${tmpdir}/quant.ppm diff --git a/test/g3-roundtrip.test b/test/g3-roundtrip.test index 6e31c587..d18e4466 100755 --- a/test/g3-roundtrip.test +++ b/test/g3-roundtrip.test @@ -1,6 +1,6 @@ #! /bin/bash # This script tests: g3topbm pbmtog3 -# Also requires: pnmcrop +# Also requires: pnmcrop pbmmake tmpdir=${tmpdir:-/tmp} complete256_pbm=${tmpdir}/complete256.pbm diff --git a/test/pad-crop-roundtrip.ok b/test/pad-crop-roundtrip.ok index 67f7a1fe..0e712ce7 100644 --- a/test/pad-crop-roundtrip.ok +++ b/test/pad-crop-roundtrip.ok @@ -1,2 +1,4 @@ 1926073387 101484 +1926073387 101484 +2425386270 41 2425386270 41 diff --git a/test/pad-crop-roundtrip.test b/test/pad-crop-roundtrip.test index c7780d68..75979901 100755 --- a/test/pad-crop-roundtrip.test +++ b/test/pad-crop-roundtrip.test @@ -1,9 +1,18 @@ #! /bin/bash -# This script tests: pnmcrop pnmmargin -# Also requires: pnmpad - +# This script tests: pnmcrop pnmmargin pnmpad +# Also requires: pnmmargin -white 10 testimg.ppm | \ pnmcrop | cksum + +pnmpad -white -left 10 -top 10 testimg.ppm | \ + pnmpad -white -right 10 -bottom 10 | \ + pnmcrop -right -bottom | pnmcrop -left -top | cksum + pnmmargin -white 10 testgrid.pbm | \ pnmcrop | cksum + +pnmpad -white -left 10 -top 10 testgrid.pbm | \ + pnmpad -white -right 10 -bottom 10 | \ + pnmcrop -left -right | pnmcrop -top -bottom | cksum + diff --git a/test/pamfind.ok b/test/pamfind.ok index dc0f95ed..9ddddced 100644 --- a/test/pamfind.ok +++ b/test/pamfind.ok @@ -20,6 +20,14 @@ Locations containing tuple (210/57/41)/255: (101, 77) (101, 78) (102, 72) +118 195 +137 176 +137 177 +137 178 +138 183 +139 205 +140 188 +144 199 Test 2 Locations containing tuple (1)/1: (0, 1) @@ -78,6 +86,176 @@ Locations containing tuple (1)/1: (14, 9) (14, 11) (14, 13) +00 00 +00 02 +00 04 +00 06 +00 08 +00 10 +00 12 +01 00 +01 01 +01 02 +01 03 +01 04 +01 05 +01 06 +01 07 +01 08 +01 09 +01 10 +01 11 +01 12 +01 13 +02 00 +02 02 +02 04 +02 06 +02 08 +02 10 +02 12 +03 00 +03 01 +03 02 +03 03 +03 04 +03 05 +03 06 +03 07 +03 08 +03 09 +03 10 +03 11 +03 12 +03 13 +04 00 +04 02 +04 04 +04 06 +04 08 +04 10 +04 12 +05 00 +05 01 +05 02 +05 03 +05 04 +05 05 +05 06 +05 07 +05 08 +05 09 +05 10 +05 11 +05 12 +05 13 +06 00 +06 02 +06 04 +06 06 +06 08 +06 10 +06 12 +07 00 +07 01 +07 02 +07 03 +07 04 +07 05 +07 06 +07 07 +07 08 +07 09 +07 10 +07 11 +07 12 +07 13 +08 00 +08 02 +08 04 +08 06 +08 08 +08 10 +08 12 +09 00 +09 01 +09 02 +09 03 +09 04 +09 05 +09 06 +09 07 +09 08 +09 09 +09 10 +09 11 +09 12 +09 13 +10 00 +10 02 +10 04 +10 06 +10 08 +10 10 +10 12 +11 00 +11 01 +11 02 +11 03 +11 04 +11 05 +11 06 +11 07 +11 08 +11 09 +11 10 +11 11 +11 12 +11 13 +12 00 +12 02 +12 04 +12 06 +12 08 +12 10 +12 12 +13 00 +13 01 +13 02 +13 03 +13 04 +13 05 +13 06 +13 07 +13 08 +13 09 +13 10 +13 11 +13 12 +13 13 +14 00 +14 02 +14 04 +14 06 +14 08 +14 10 +14 12 +15 00 +15 01 +15 02 +15 03 +15 04 +15 05 +15 06 +15 07 +15 08 +15 09 +15 10 +15 11 +15 12 +15 13 Test 3 okay okay +Test 4 +expected error diff --git a/test/pamfind.test b/test/pamfind.test index 39cb1437..e55f290c 100755 --- a/test/pamfind.test +++ b/test/pamfind.test @@ -10,10 +10,12 @@ sorted1_res=${tmpdir}/pamfind_sorted1.res echo Test 1 pamfind -color=grey17 testimg.ppm pamfind -target=210,57,41 testimg.ppm +pamfind -target=50,55,49 -machine testimg.ppm # Test 2 echo Test 2 pamfind -target=1 testgrid.pbm +pamfind -target=0 -machine testgrid.pbm # Test 3 # The two outputs should be disjoint @@ -29,4 +31,13 @@ comm -12 ${sorted0_res} ${sorted1_res} | rm ${sorted0_res} ${sorted1_res} +# Test 4 +echo 1>&2 +echo "Invalid command-line argument combination." 1>&2 +echo "Error messages should appear below the line." 1>&2 +echo "-----------------------------------------------------------" 1>&2 + +echo Test 4 +pamfind -color=black -target=1 testimg.ppm || \ + echo expected error diff --git a/test/pamhue-roundtrip.ok b/test/pamhue-roundtrip.ok new file mode 100644 index 00000000..b341398c --- /dev/null +++ b/test/pamhue-roundtrip.ok @@ -0,0 +1,10 @@ +input image +1926073387 101484 +360 +1926073387 101484 +180 +1926073387 101484 +120 +1926073387 101484 +60 +1926073387 101484 diff --git a/test/pamhue-roundtrip.test b/test/pamhue-roundtrip.test new file mode 100755 index 00000000..643ac99a --- /dev/null +++ b/test/pamhue-roundtrip.test @@ -0,0 +1,19 @@ +#! /bin/bash +# This script tests: pamhue +# Also requires: + +echo input image +cat testimg.ppm | cksum + +echo 360 +pamhue -huechange=360 testimg.ppm | cksum +echo 180 +pamhue -huechange=180 testimg.ppm | pamhue -huechange=180 | cksum +echo 120 +pamhue -huechange=120 testimg.ppm | pamhue -huechange=120 | \ + pamhue -huechange=120 | cksum +echo 60 +pamhue -huechange=60 testimg.ppm | pamhue -huechange=60 | \ + pamhue -huechange=60 | pamhue -huechange=60 | \ + pamhue -huechange=60 | pamhue -huechange=60 | cksum + diff --git a/test/pamhue.ok b/test/pamhue.ok new file mode 100644 index 00000000..447759ba --- /dev/null +++ b/test/pamhue.ok @@ -0,0 +1,25 @@ +1213482165 83 + Summary: 8 colors: 1 black, 1 white, 0 gray, 6 color + + r g b lum count + ----- ----- ----- ----- ------- + 0 0 0 0 1 + 0 0 255 29 1 + 255 255 0 226 1 + 255 255 255 255 1 + 0 255 0 150 1 + 0 255 255 179 1 + 255 0 0 76 1 + 255 0 255 105 1 + Summary: 8 colors: 1 black, 1 white, 0 gray, 6 color + + r g b lum count + ----- ----- ----- ----- ------- + 0 0 0 0 1 + 0 0 255 29 1 + 255 255 0 226 1 + 255 255 255 255 1 + 0 255 0 150 1 + 0 255 255 179 1 + 255 0 0 76 1 + 255 0 255 105 1 diff --git a/test/pamhue.test b/test/pamhue.test new file mode 100755 index 00000000..544b1d32 --- /dev/null +++ b/test/pamhue.test @@ -0,0 +1,10 @@ +#! /bin/bash +# This script tests: pamhue +# Also requires: pamseq ppmhist pamdepth + +pamseq -tupletype=RGB 3 1 | pamdepth 255 | pamhue -huechange=60 | cksum + +pamseq -tupletype=RGB 3 1 | pamdepth 255 | ppmhist +pamseq -tupletype=RGB 3 1 | pamdepth 255 | pamhue -huechange=60 | ppmhist + + diff --git a/test/pamscale-filters3.ok b/test/pamscale-filters3.ok index 94d4ae96..182700cd 100644 --- a/test/pamscale-filters3.ok +++ b/test/pamscale-filters3.ok @@ -1,4 +1,3 @@ -failure : 0 3.96 hermite: match match diff --git a/test/pamscale-filters3.test b/test/pamscale-filters3.test index 83198e2b..5a865508 100755 --- a/test/pamscale-filters3.test +++ b/test/pamscale-filters3.test @@ -1,7 +1,6 @@ #! /bin/bash # This script tests: pamscale pamstretch pamstretch-gen - # Also requires: pamvalidate pnmpsnr || \ - echo failure ${PIPESTATUS[@]} ":" $? +# Also requires: pamvalidate pnmpsnr tmpdir=${tmpdir:-/tmp} stretch_ppm=${tmpdir}/stretch.ppm diff --git a/test/pamtable.test b/test/pamtable.test index 5c66b7ae..335d45c4 100755 --- a/test/pamtable.test +++ b/test/pamtable.test @@ -1,6 +1,6 @@ #! /bin/bash # This script tests: pamtable -# Also requires: pamgradient pamseq pamdepth +# Also requires: pamseq pamdepth pbmmake ppmrainbow pamtable testgrid.pbm echo diff --git a/test/pbm-misc-converters.test b/test/pbm-misc-converters.test index aa71489b..ad96f13c 100755 --- a/test/pbm-misc-converters.test +++ b/test/pbm-misc-converters.test @@ -3,7 +3,7 @@ # This script tests: pbmtodjvurle pbmtoepson pbmtogo pbmtoibm23xx # This script tests: pbmtolj pbmtoln03 pbmtomatrixorbital pbmtonokia # This script tests: pbmtoplot pbmtoptx pbmtozinc -# Also requires: pbmpage +# Also requires: pbmpage pbmtoppa # Note: one-way test. # These converters do not have counterparts that work in the opposite diff --git a/test/pdb-roundtrip.test b/test/pdb-roundtrip.test index 6b4e152c..32d7aa87 100755 --- a/test/pdb-roundtrip.test +++ b/test/pdb-roundtrip.test @@ -1,6 +1,6 @@ #! /bin/bash # This script tests: pamtopdbimg pdbimgtopam -# Also requires: pnmtile pgmramp pamtopnm +# Also requires: pnmtile pgmramp pamtopnm pamdepth tmpdir=${tmpdir:-/tmp} tiled_pbm=${tmpdir}/tiled.pbm diff --git a/test/pnmcrop-blank.ok b/test/pnmcrop-blank.ok new file mode 100644 index 00000000..55103acb --- /dev/null +++ b/test/pnmcrop-blank.ok @@ -0,0 +1,130 @@ +Test 1 +-blank-image=pass +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +-blank-image=minimize +-7 -7 -7 -6 1 1 +0 0 0 0 15 14 +-7 -7 -7 -6 1 1 +-7 -7 -7 -6 1 1 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +-7 -7 -7 -6 1 1 +-blank-image=minimize -top +0 0 -13 0 15 1 +0 0 0 0 15 14 +0 0 -13 0 15 1 +0 0 -13 0 15 1 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 -13 0 15 1 +-blank-image=minimize -bottom +0 0 0 -13 15 1 +0 0 0 0 15 14 +0 0 0 -13 15 1 +0 0 0 -13 15 1 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 -13 15 1 +-blank-image=minimize -left +-14 0 0 0 1 14 +0 0 0 0 15 14 +-14 0 0 0 1 14 +-14 0 0 0 1 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +-14 0 0 0 1 14 +-blank-image=minimize -right +0 -14 0 0 1 14 +0 0 0 0 15 14 +0 -14 0 0 1 14 +0 -14 0 0 1 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 -14 0 0 1 14 +-blank-image=minimize -left -right +-7 -7 0 0 1 14 +0 0 0 0 15 14 +-7 -7 0 0 1 14 +-7 -7 0 0 1 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +-7 -7 0 0 1 14 +-blank-image=maxcrop +-15 -15 -14 -14 15 14 +0 0 0 0 15 14 +-15 -15 -14 -14 15 14 +-15 -15 -14 -14 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +-15 -15 -14 -14 15 14 +-blank-image=abort +fail1 +fail2 +0 0 0 0 15 14 +0 0 0 0 15 14 +fail3 + +fail1 +fail2 +0 0 0 0 15 14 +0 0 0 0 15 14 +fail3 +Test 2 +-blank-image=maxcrop -top +0 0 -99 0 100 99 +0 0 -99 0 100 99 +0 0 0 0 100 99 +-blank-image=minimize +-50 -49 -49 -49 1 1 +-50 -49 -49 -49 1 1 +0 0 0 0 100 99 +-blank-image=maxcrop +-100 -100 -99 -99 100 99 +-100 -100 -99 -99 100 99 +0 0 0 0 100 99 +-blank-image=maxcrop -top +0 0 -99 0 100 99 +0 0 -99 0 100 99 +0 0 0 0 100 99 +-blank-image=maxcrop -bottom +0 0 0 -99 100 99 +0 0 0 -99 100 99 +0 0 0 0 100 99 +-blank-image=maxcrop -left +-100 0 0 0 100 99 +-100 0 0 0 100 99 +0 0 0 0 100 99 +-blank-image=maxcrop -right +0 -100 0 0 100 99 +0 -100 0 0 100 99 +0 0 0 0 100 99 +-blank-image=maxcrop -top -bottom -right +0 -100 -99 -99 100 99 +0 -100 -99 -99 100 99 +0 0 0 0 100 99 + +fail4 +fail5 +0 0 0 0 100 99 diff --git a/test/pnmcrop-blank.test b/test/pnmcrop-blank.test new file mode 100755 index 00000000..087ad65e --- /dev/null +++ b/test/pnmcrop-blank.test @@ -0,0 +1,55 @@ +#! /bin/bash +# This script tests: pnmcrop +# Also requires: pbmmake ppmmake + +tmpdir=${tmpdir:-/tmp} + +test_pbm=${tmpdir}/test.pbm +test_ppm=${tmpdir}/test.ppm + +echo "Error messages should appear below the line." 1>&2 +echo "--------------------------------------------" 1>&2 + +#Test 1 +echo Test 1 + +( pbmmake -white 15 14; pbmmake -gray 15 14; pbmmake -black 15 14 ) > \ + ${test_pbm} +for type in "-blank-image=pass" \ + "-blank-image=minimize" \ + "-blank-image=minimize -top" \ + "-blank-image=minimize -bottom" \ + "-blank-image=minimize -left" \ + "-blank-image=minimize -right" \ + "-blank-image=minimize -left -right" \ + "-blank-image=maxcrop" \ + "-blank-image=abort" "" + do + echo ${type} + pnmcrop -reportsize ${type} ${test_pbm} || echo "fail1" + pnmcrop -reportsize ${type} -white ${test_pbm} || echo "fail2" + pnmcrop -reportsize ${type} -black ${test_pbm} || echo "fail3" + done + +rm ${test_pbm} + + +#Test 2 + +ppmmake rgb:ff/ff/ff 100 99 > ${test_ppm} +echo Test 2 +for type in "-blank-image=maxcrop -top" \ + "-blank-image=minimize" "-blank-image=maxcrop" \ + "-blank-image=maxcrop -top" \ + "-blank-image=maxcrop -bottom" \ + "-blank-image=maxcrop -left" \ + "-blank-image=maxcrop -right" \ + "-blank-image=maxcrop -top -bottom -right" "" + do + echo ${type} + pnmcrop -reportsize ${type} ${test_ppm} || echo "fail4" + pnmcrop -reportsize ${type} -white ${test_ppm} || echo "fail5" + pnmcrop -reportsize ${type} -black ${test_ppm} || echo "fail6" + done + +rm ${test_ppm} \ No newline at end of file diff --git a/test/pnmcrop1.ok b/test/pnmcrop1.ok new file mode 100644 index 00000000..09714bc7 --- /dev/null +++ b/test/pnmcrop1.ok @@ -0,0 +1,109 @@ +Test 1 +test.pbm + +0 0 -7 0 28 25 rgb-1:1/1/1 0.000000 +-white +0 0 -7 0 28 25 rgb-1:1/1/1 0.000000 +-black +0 0 0 -2 28 30 rgb-1:0/0/0 0.000000 +-sides +0 0 -7 0 28 25 rgb-1:1/1/1 0.000000 +-top +0 0 -7 0 28 25 rgb-1:1/1/1 0.000000 +-bottom +0 0 0 0 28 32 rgb-1:1/1/1 0.000000 +-left +0 0 0 0 28 32 rgb-1:1/1/1 0.000000 +-right +0 0 0 0 28 32 rgb-1:1/1/1 0.000000 +-top -bottom +0 0 -7 0 28 25 rgb-1:1/1/1 0.000000 +-bottom -bg-corner=bottomright +0 0 0 -2 28 30 rgb-1:0/0/0 0.000000 +-right -bg-corner=bottomright +0 0 0 0 28 32 rgb-1:0/0/0 0.000000 +-bg-color=white +0 0 0 0 28 32 rgb-1:1/1/1 0.000000 +-bg-color=black +0 0 0 -2 28 30 rgb-1:0/0/0 0.000000 +-bg-color=red +0 0 0 0 28 32 rgb-1:0/0/0 0.000000 +test.ppm + +0 0 0 0 250 161 rgb-255:127/127/127 0.000000 +-white +-6 0 0 0 244 161 rgb-255:255/255/255 0.000000 +-black +0 -11 0 0 239 161 rgb-255:0/0/0 0.000000 +-sides +-6 0 0 0 244 161 rgb-255:255/255/255 0.000000 +-top +0 0 0 0 250 161 rgb-255:127/127/127 0.000000 +-bottom +0 0 0 0 250 161 rgb-255:127/127/127 0.000000 +-left +0 0 0 0 250 161 rgb-255:127/127/127 0.000000 +-right +0 0 0 0 250 161 rgb-255:127/127/127 0.000000 +-top -bottom +0 0 0 0 250 161 rgb-255:127/127/127 0.000000 +-bottom -bg-corner=bottomright +0 0 0 0 250 161 rgb-255:0/0/0 0.000000 +-right -bg-corner=bottomright +0 -11 0 0 239 161 rgb-255:0/0/0 0.000000 +-bg-color=white +-6 0 0 0 244 161 rgb-255:255/255/255 0.000000 +-bg-color=black +0 -11 0 0 239 161 rgb-255:0/0/0 0.000000 +-bg-color=red +0 0 0 0 250 161 rgb-255:255/0/0 0.000000 +Test 2 +test.pbm + +3130931737 109 +3130931737 109 +-white +3130931737 109 +3130931737 109 +-top +3130931737 109 +3130931737 109 +test.ppm + +1435955776 120765 +1435955776 120765 +-white +638507845 117867 +638507845 117867 +-top +1435955776 120765 +1435955776 120765 +Test 3 +-reportfull -reportsize +expected failure +-reportfull -borderfile=testgrid.pbm +expected failure +-reportsize -borderfile=testgrid.pbm +expected failure +-black -white +expected failure +-black -sides +expected failure +-white -bg-color=red +expected failure +-white -bg-corner=topleft +expected failure +-white -bg-corner=top +expected failure +-bg-color=black -bg-color=white +expected failure +-bg-corner=topleft -bg-corner=bottomright +expected failure +-blank-image=maxcrop +-1 0 0 -1 13 15 rgb-1:0/0/0 0.000000 +-blank-image=past +expected failure +-bg-color=black -closeness=-1 +expected failure +-bg-color=black -closeness=101 +expected failure diff --git a/test/pnmcrop1.test b/test/pnmcrop1.test new file mode 100755 index 00000000..088ecf46 --- /dev/null +++ b/test/pnmcrop1.test @@ -0,0 +1,78 @@ +#! /bin/bash +# This script tests: pnmcrop +# Also requires: pnmpad pnmmargin pamcut + +tmpdir=${tmpdir:-/tmp} + +test_pbm=${tmpdir}/test.pbm +test_ppm=${tmpdir}/test.ppm + +pnmmargin -white 7 testgrid.pbm | pnmpad -black -bottom=2 > ${test_pbm} +pnmmargin -white 6 testimg.ppm | pnmpad -black -right=11 > ${test_ppm} + +#Test 1 +echo Test 1 + +for input_file in ${test_pbm} ${test_ppm} + do + echo `basename ${input_file}` + for option in "" "-white" "-black" "-sides" \ + "-top" "-bottom" "-left" "-right" "-top -bottom" \ + "-bottom -bg-corner=bottomright" \ + "-right -bg-corner=bottomright" \ + "-bg-color=white" "-bg-color=black" "-bg-color=red" + do + echo ${option} + pnmcrop -reportfull ${option} ${input_file} || echo fail + done + done + +#Test 2 +echo Test 2 + +for input_file in ${test_pbm} ${test_ppm} + do + echo `basename ${input_file}` + for option in "" "-white" "-top" + do + echo ${option} + # Normal crop operation + pnmcrop ${option} ${input_file} | cksum + + # Compute edge extents with pnmcrop; let pamcut do the actual cropping + pamcut ${input_file} `pnmcrop -reportsize ${option} ${input_file} | \ + awk 'NF==6 && NR==1 && \ + $1<=0 && $2<=0 && $3<=0 && $4<=0 && $5>=0 && $6>=0 \ + { printf("-cropleft=%d -cropright=%d ", -$1, -$2); + printf("-croptop=%d -cropbottom=%d", -$3, -$4) }' ` | cksum + done + done + +rm ${test_pbm} ${test_ppm} + +# Test 3 + +echo 1>&2 +echo "Invalid command-line argument combinations." 1>&2 +echo "Error messages should appear below the line." 1>&2 +echo "-----------------------------------------------------------" 1>&2 + +echo Test 3 +for option in "-reportfull -reportsize" \ + "-reportfull -borderfile=testgrid.pbm" \ + "-reportsize -borderfile=testgrid.pbm" \ + "-black -white" \ + "-black -sides" \ + "-white -bg-color=red" \ + "-white -bg-corner=topleft" \ + "-white -bg-corner=top" \ + "-bg-color=black -bg-color=white" \ + "-bg-corner=topleft -bg-corner=bottomright" \ + "-blank-image=maxcrop" \ + "-blank-image=past" \ + "-bg-color=black -closeness=-1" \ + "-bg-color=black -closeness=101" + do + echo ${option} + pnmcrop -reportfull ${option} testgrid.pbm || echo expected failure + done diff --git a/test/pnmcrop2.ok b/test/pnmcrop2.ok new file mode 100644 index 00000000..4eff830d --- /dev/null +++ b/test/pnmcrop2.ok @@ -0,0 +1,29 @@ +Test 1 + +0 0 0 0 5 5 rgb-200:2/2/2 0.000000 +-sides +0 0 0 0 5 5 rgb-200:6/6/6 0.000000 +Test 2 +topleft +0 0 0 0 5 5 rgb-200:0/0/0 0.000000 +topright +0 0 0 0 5 5 rgb-200:4/4/4 0.000000 +bottomleft +0 0 0 0 5 5 rgb-200:8/8/8 0.000000 +bottomright +0 0 0 0 5 5 rgb-200:15/15/15 0.000000 +Test 3 +0 +0 0 0 0 5 5 rgb-200:0/0/0 0.000000 +1 +0 0 0 0 5 5 rgb-200:0/0/0 1.000000 +2 +0 0 -1 0 5 4 rgb-200:0/0/0 2.000000 +3 +-1 0 -1 0 4 4 rgb-200:0/0/0 3.000000 +4 +-1 0 -1 0 4 4 rgb-200:0/0/0 4.000000 +5 +-1 -1 -1 -1 3 3 rgb-200:0/0/0 5.000000 +6 +-1 -1 -1 -1 3 3 rgb-200:0/0/0 6.000000 diff --git a/test/pnmcrop2.test b/test/pnmcrop2.test new file mode 100755 index 00000000..d6c83c73 --- /dev/null +++ b/test/pnmcrop2.test @@ -0,0 +1,55 @@ +#! /bin/bash +# This script tests: pnmcrop +# Also requires: + +tmpdir=${tmpdir:-/tmp} +test_pgm=${tmpdir}/test.pgm + +cat > ${test_pgm} << EOF +P2 +5 5 +200 +0 1 2 3 4 +5 199 199 199 9 +6 199 199 199 10 +7 199 199 199 11 +8 12 13 14 15 +EOF + +# Test 1 +# Test color detection; none of the sides are cropped + +echo Test 1 + +for option in "" "-sides" + do + echo ${option} + pnmcrop -reportfull ${option} ${test_pgm} || echo fail1 + done + +# Test 2 +# Test color detection; none of the sides are cropped +echo Test 2 + +for corner in topleft topright bottomleft bottomright + do + echo ${corner} + pnmcrop -reportfull -bg-corner=${corner} ${test_pgm} || echo fail2 + done + +# Test 3 +# Left edge is cropped at closeness 2% and above +# Top edge is cropped at closeness 3% and above +# All edges are cropped at closeness 5% and above + +echo Test 3 + +for closeness in `seq 0 6` + do + echo ${closeness} + pnmcrop -reportfull -bg-corner=topleft -closeness=${closeness} ${test_pgm} \ + || echo fail3 + done + +rm ${test_pgm} + diff --git a/test/pnmcrop3.ok b/test/pnmcrop3.ok new file mode 100644 index 00000000..6824143a --- /dev/null +++ b/test/pnmcrop3.ok @@ -0,0 +1,90 @@ +Test 1 +test.pbm +-left +-12 0 0 0 15 24 +-right +0 -2 0 0 25 24 +-top +0 0 -3 0 27 21 +-bottom +0 0 0 -6 27 18 +-left -right +-12 -2 0 0 13 24 +-left -bottom +-12 0 0 -6 15 18 +-right -bottom +0 -2 0 -6 25 18 +test.ppm +-left +-21 0 0 0 236 161 +-right +0 -9 0 0 248 161 +-top +0 0 -11 0 257 150 +-bottom +0 0 0 -1 257 160 +-left -right +-21 -9 0 0 227 161 +-left -bottom +-21 0 0 -1 236 160 +-right -bottom +0 -9 0 -1 248 160 +Test 2 +test.pbm +-12 -2 -3 -6 13 15 +-11 -1 -2 -5 15 17 +-10 0 -1 -4 17 19 +-9 +1 0 -3 19 21 +-8 +2 +1 -2 21 23 +-7 +3 +2 -1 23 25 +test.ppm +-21 -9 -11 -1 227 149 +-20 -8 -10 0 229 151 +-19 -7 -9 +1 231 153 +-18 -6 -8 +2 233 155 +-17 -5 -7 +3 235 157 +-16 -4 -6 +4 237 159 +Test 3 +13 15 +P2 +13 15 +255 +128 128 128 128 128 128 128 128 128 128 128 128 128 +128 128 128 128 128 128 128 128 128 128 128 128 128 +128 128 128 128 128 128 128 128 128 128 128 128 128 +128 128 128 128 128 128 128 128 128 128 128 128 128 +128 128 128 128 128 128 128 128 128 128 128 128 128 +128 128 128 128 128 128 128 128 128 128 128 128 128 +128 128 128 128 128 128 128 128 128 128 128 128 128 +128 128 128 128 128 128 128 128 128 128 128 128 128 +128 128 128 128 128 128 128 128 128 128 128 128 128 +128 128 128 128 128 128 128 128 128 128 128 128 128 +128 128 128 128 128 128 128 128 128 128 128 128 128 +128 128 128 128 128 128 128 128 128 128 128 128 128 +128 128 128 128 128 128 128 128 128 128 128 128 128 +128 128 128 128 128 128 128 128 128 128 128 128 128 +128 128 128 128 128 128 128 128 128 128 128 128 128 +13 15 +0 0 0 0 13 15 +13 15 +P1 +13 15 +1111111111111 +1110101010101 +1111111111111 +1110101010101 +1111111111111 +1110101010101 +1111111111111 +1110101010101 +1111111111111 +1110101010101 +1111111111111 +1110101010101 +1111111111111 +1110101010101 +1111111111111 +-3 -1 -1 -1 9 13 +544280424 101484 +4294967295 0 +4294967295 0 diff --git a/test/pnmcrop3.test b/test/pnmcrop3.test new file mode 100755 index 00000000..c46fd7ea --- /dev/null +++ b/test/pnmcrop3.test @@ -0,0 +1,71 @@ +#! /bin/bash +# This script tests: pnmcrop +# Also requires: pnmpad pamfile pgmmake + +tmpdir=${tmpdir:-/tmp} + +test_pbm=${tmpdir}/test.pbm +test_ppm=${tmpdir}/test.ppm +border_pbm=${tmpdir}/border.pbm +border_ppm=${tmpdir}/border.ppm +gray_pgm=${tmpdir}/gray.pgm + +pnmpad -top=3 -bottom=5 -left=11 -right=2 testgrid.pbm > ${test_pbm} +pnmpad -top=11 -bottom=1 -left=21 -right=9 testimg.ppm > ${test_ppm} + +pnmpad -top=4 -bottom=4 -left=8 -right=5 testgrid.pbm > ${border_pbm} +pnmpad -top=7 -bottom=5 -left=30 -right=0 testimg.ppm > ${border_ppm} + +pgmmake 0.5 `pamfile -size ${test_pbm}` > ${gray_pgm} + +# Test 1 +echo Test 1 + +for input_file in ${test_pbm} ${test_ppm} + do + echo `basename ${input_file}` + for option in "-left" "-right" "-top" "-bottom" \ + "-left -right" "-left -bottom" "-right -bottom" + do + echo ${option} + pnmcrop -reportsize ${option} ${input_file} || echo fail1 + done + done + +# Test 2 +echo Test 2 + +for input_file in ${test_pbm} ${test_ppm} + do + echo `basename ${input_file}` + for margin in `seq 0 5` + do + pnmcrop -reportsize -margin=${margin} ${input_file} || echo fail2 + done + done + +# Test 3 +echo Test 3 + +pnmcrop -borderfile=${border_pbm} ${gray_pgm} | pamfile -size +pnmcrop -borderfile=${border_pbm} ${gray_pgm} -plain + +pnmcrop -borderfile=${test_pbm} ${test_pbm} | pamfile -size +pnmcrop -borderfile=${test_pbm} ${test_pbm} | pnmcrop -black -reportsize + +pnmcrop -borderfile=${border_pbm} ${test_pbm} | pamfile -size +pnmcrop -borderfile=${border_pbm} ${test_pbm} -plain +pnmcrop -borderfile=${border_pbm} ${test_pbm} | pnmcrop -black -reportsize + +pnmcrop -borderfile=${border_ppm} ${test_ppm} | cksum + +# The following two cases are expected to fai + +echo "Error messages should appear below the line." 1>&2 +echo "--------------------------------------------" 1>&2 + +pnmcrop -borderfile=${border_ppm} ${test_pbm} | cksum +pnmcrop -borderfile=${border_pbm} ${test_ppm} | cksum + + +rm ${test_pbm} ${test_ppm} ${border_pbm} ${border_ppm} ${gray_pgm} \ No newline at end of file diff --git a/test/pnmquantall.test b/test/pnmquantall.test index cd01bb8d..b735b623 100755 --- a/test/pnmquantall.test +++ b/test/pnmquantall.test @@ -1,6 +1,6 @@ #! /bin/bash # This script tests: pnmquantall -# Also requires: ppmtorgb3 pgmhist +# Also requires: ppmtorgb3 pgmhist pnmcat tmpdir=${tmpdir:-/tmp} test_ppm=${tmpdir}/testimg.ppm diff --git a/test/sgi-roundtrip.test b/test/sgi-roundtrip.test index 88efb75e..5052bb81 100755 --- a/test/sgi-roundtrip.test +++ b/test/sgi-roundtrip.test @@ -1,6 +1,6 @@ #! /bin/bash # This script tests: pnmtosgi sgitopnm -# Also requires: rgb3toppm +# Also requires: rgb3toppm pamdepth pamtopnm a_sgi=${tmpdir}/a.sgi |