diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2024-03-30 18:31:01 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2024-03-30 18:31:01 +0000 |
commit | 81c59f730dacf62c927eb57dcadeecffe8b8daea (patch) | |
tree | a67cc5906891e0965c3a9d8cea80deacbc7f1930 /test/pamcut.test | |
parent | 19387d1be30e80e8c4e865bfe053aed1094ca8af (diff) | |
download | netpbm-mirror-81c59f730dacf62c927eb57dcadeecffe8b8daea.tar.gz netpbm-mirror-81c59f730dacf62c927eb57dcadeecffe8b8daea.tar.xz netpbm-mirror-81c59f730dacf62c927eb57dcadeecffe8b8daea.zip |
promote Development to Advanced
git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@4897 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'test/pamcut.test')
-rwxr-xr-x | test/pamcut.test | 302 |
1 files changed, 197 insertions, 105 deletions
diff --git a/test/pamcut.test b/test/pamcut.test index 7cda5bce..7d60e1cd 100755 --- a/test/pamcut.test +++ b/test/pamcut.test @@ -1,134 +1,226 @@ #! /bin/sh -# This script tests: pamcut pbmmake -# Also requires: pamfile +# This script tests: pamcut +# Also requires: pbmmake pgmmake pamfile pnmpad pamflip -echo "Test 1. Should print 2958909756 124815" +tmpdir=${tmpdir:-/tmp} + +echo "Test 1a. Should print 0 259 0 159 227 149 260 160 twice" + +pamcut -left 0 -right 259 -top 0 -bottom 159 \ + -pad -reportonly testimg.ppm +pamcut -left 0 -top 0 -width 260 -height 160 \ + -pad -reportonly testimg.ppm + +echo "Test 1b. Should print 2958909756 124815" + +pamcut -left 0 -top 0 -width 260 -height 160 \ + -pad testimg.ppm | cksum + +echo "Test 2a. Should print 120 159 120 159 227 149 40 40 three times" + +pamcut -left 120 -right 159 -top 120 -bottom 159 \ + -pad -reportonly testimg.ppm +pamcut -right 159 -bottom 159 -width 40 -height 40 \ + -pad -reportonly testimg.ppm +pamcut -left 120 -top 120 -width 40 -height 40 \ + -pad -reportonly testimg.ppm -pamcut -top 0 -left 0 -width 260 -height 160 \ - -pad testimg.ppm | cksum +echo "Test 2b. Should print 3876978825 4813 twice" -echo "Test 2. Should print 1550940962 10933" +pamcut -left 120 -right 159 -top 120 -bottom 159 \ + -pad testimg.ppm | cksum +pamcut -left 120 -top 120 -width 40 \ + -pad testimg.ppm | pnmpad -black -bottom 11 | cksum -pamcut -top 200 -left 120 -width 40 -height 40 \ - -pad testimg.ppm | cksum +echo "Test 3a. Should print 5 5 5 5 227 149 1 1 three times" -echo "Test 3. Should print 708474423 14 twice" +pamcut -top 5 -left 5 -bottom 5 -right 5 -reportonly testimg.ppm +pamcut -width 1 -height 1 -bottom 5 -right 5 -reportonly testimg.ppm +pamcut -cropleft 5 -croptop 5 -width 1 -height 1 -reportonly testimg.ppm + +echo "Test 3b. Should print 708474423 14" pamcut -top 5 -left 5 -bottom 5 -right 5 testimg.ppm | cksum -pamcut -width 1 -height 1 -bottom 5 -right 5 testimg.ppm | cksum -echo "Test 4. Should print 659346598 80124 four times" +echo "Test 4a. Should print 10 216 10 138 227 149 207 129 five times" + +pamcut -croptop 10 -cropleft 10 -cropbottom 10 -cropright 10 \ + -reportonly testimg.ppm +pamcut -cropbottom 10 -cropright 10 -width 207 -height 129 \ + -reportonly testimg.ppm +pamcut -top 10 -left 10 -bottom 138 -right 216 -reportonly testimg.ppm +pamcut -top 10 -left 10 -bottom -11 -right -11 -reportonly testimg.ppm +pamcut -top 10 -left 10 -width 207 -height 129 -reportonly testimg.ppm + +echo "Test 4b. Should print 659346598 80124" -pamcut -croptop 10 -cropleft 10 -cropbottom 10 -cropright 10 testimg.ppm | \ - cksum -pamcut -top 10 -left 10 -bottom 138 -right 216 testimg.ppm | cksum -pamcut -top 10 -left 10 -bottom -11 -right -11 testimg.ppm | cksum pamcut -top 10 -left 10 -width 207 -height 129 testimg.ppm | cksum -echo "Test 5. Should print 281226646 481 five times" +echo "Test 5a. Should print 0 56 0 58 57 59 57 59 five times" mazesize=$(pamfile -size maze.pbm) width=$(echo ${mazesize} | cut -d " " -f 1) height=$(echo ${mazesize} | cut -d " " -f 2) - + +pamcut -croptop 0 -cropleft 0 -cropbottom 0 -cropright 0 \ + -reportonly maze.pbm +pamcut -top 0 -left 0 \ + -bottom $((${height} -1)) -right $((${width} -1)) \ + -reportonly maze.pbm +pamcut -top 0 -left 0 -bottom -1 -right -1 -reportonly maze.pbm +pamcut -top 0 -left 0 -width ${width} -height ${height} \ + -reportonly maze.pbm +pamcut -reportonly maze.pbm + +echo "Test 5b. Should print 281226646 481 twice" + pamcut -croptop 0 -cropleft 0 -cropbottom 0 -cropright 0 maze.pbm | \ - cksum -pamcut -top 0 -left 0 -bottom $((${height} -1)) -right $((${width} -1)) \ - maze.pbm | cksum -pamcut -top 0 -left 0 -bottom -1 -right -1 maze.pbm | cksum -pamcut -top 0 -left 0 -width ${width} -height ${height} maze.pbm | cksum + cksum pamcut maze.pbm | cksum - -echo "Test 6. Should print 3412257956 129" -pbmmake -g 50 50 | pamcut 5 5 30 30 | cksum +test50_pbm=${tmpdir}/test50.pbm +echo "Test 6a. Should print 5 34 5 34 50 50 30 30" -echo "Test Invalid" +pbmmake -g 50 50 | tee ${test50_pbm} | pamcut -reportonly 5 5 30 30 -tmpdir=${tmpdir:-/tmp} -test_out=${tmpdir}/test_out +echo "Test 6b. Should print 3412257956 129" + +pamcut 5 5 30 30 ${test50_pbm} | cksum + +rm ${test50_pbm} + +echo "Test 7. Should print 284857390 12 sixteen times" + +test1_pbm=${tmpdir}/test1.pbm + +pbmmake -b 1 1 > ${test1_pbm} + +# pbmmake -b 5 5 | cksum + +pamcut -pad -cropleft=6 -croptop=6 -width=5 -height=5 ${test1_pbm} | cksum +pamcut -pad -cropright=6 -croptop=6 -width=5 -height=5 ${test1_pbm} | cksum +pamcut -pad -cropleft=6 -cropbottom=6 -width=5 -height=5 ${test1_pbm} | cksum +pamcut -pad -cropright=6 -cropbottom=6 -width=5 -height=5 ${test1_pbm} | cksum + +pamcut -pad -cropleft=6 -width=5 -height=5 ${test1_pbm} | cksum +pamcut -pad -croptop=6 -width=5 -height=5 ${test1_pbm} | cksum +pamcut -pad -cropbottom=6 -width=5 -height=5 ${test1_pbm} | cksum +pamcut -pad -cropright=6 -width=5 -height=5 ${test1_pbm} | cksum + +pamcut -pad -cropleft=7 -croptop=7 -width=5 -height=5 ${test1_pbm} | cksum +pamcut -pad -cropright=7 -croptop=7 -width=5 -height=5 ${test1_pbm} | cksum +pamcut -pad -cropleft=7 -cropbottom=7 -width=5 -height=5 ${test1_pbm} | cksum +pamcut -pad -cropright=7 -cropbottom=7 -width=5 -height=5 ${test1_pbm} | cksum + +pamcut -pad -cropleft=17 -width=5 -height=5 ${test1_pbm} | cksum +pamcut -pad -croptop=17 -width=5 -height=5 ${test1_pbm} | cksum +pamcut -pad -cropbottom=17 -width=5 -height=5 ${test1_pbm} | cksum +pamcut -pad -cropright=17 -width=5 -height=5 ${test1_pbm} | cksum + + +echo "Test 8. Should print 3125257619 29 four times" -echo 1>&2 -echo "Invalid command-line argument combinations." 1>&2 -echo "Error messages should appear below the line." 1>&2 -echo "-----------------------------------------------------------" 1>&2 +test3_pbm=${tmpdir}/test3.pbm + +pbmmake -g 3 3 > ${test3_pbm} + +pamcut -pad -cropleft=10 -croptop=10 -width=10 -height=10 ${test3_pbm} | cksum +pamcut -pad -cropright=10 -croptop=10 -width=10 -height=10 ${test3_pbm} |\ + pamflip -lr | cksum +pamcut -pad -cropleft=10 -cropbottom=10 -width=10 -height=10 ${test3_pbm} |\ + pamflip -tb | cksum +pamcut -pad -cropright=10 -cropbottom=10 -width=10 -height=10 ${test3_pbm} |\ + pamflip -r180 | cksum + +rm ${test3_pbm} + +echo "Test 9. Should print 3338453023 36 sixteen times" + +testb_pgm=${tmpdir}/testb.pgm + +pgmmake 0.0 1 1 > ${testb_pgm} + +# pgmmake 0.0 5 5 | cksum + +pamcut -pad -cropleft=6 -croptop=6 -width=5 -height=5 ${testb_pgm} | cksum +pamcut -pad -cropright=6 -croptop=6 -width=5 -height=5 ${testb_pgm} | cksum +pamcut -pad -cropleft=6 -cropbottom=6 -width=5 -height=5 ${testb_pgm} | cksum +pamcut -pad -cropright=6 -cropbottom=6 -width=5 -height=5 ${testb_pgm} | cksum + +pamcut -pad -cropleft=6 -width=5 -height=5 ${testb_pgm} | cksum +pamcut -pad -croptop=6 -width=5 -height=5 ${testb_pgm} | cksum +pamcut -pad -cropbottom=6 -width=5 -height=5 ${testb_pgm} | cksum +pamcut -pad -cropright=6 -width=5 -height=5 ${testb_pgm} | cksum + +pamcut -pad -cropleft=7 -croptop=7 -width=5 -height=5 ${testb_pgm} | cksum +pamcut -pad -cropright=7 -croptop=7 -width=5 -height=5 ${testb_pgm} | cksum +pamcut -pad -cropleft=7 -cropbottom=7 -width=5 -height=5 ${testb_pgm} | cksum +pamcut -pad -cropright=7 -cropbottom=7 -width=5 -height=5 ${testb_pgm} | cksum + +pamcut -pad -cropleft=17 -width=5 -height=5 ${testb_pgm} | cksum +pamcut -pad -croptop=17 -width=5 -height=5 ${testb_pgm} | cksum +pamcut -pad -cropbottom=17 -width=5 -height=5 ${testb_pgm} | cksum +pamcut -pad -cropright=17 -width=5 -height=5 ${testb_pgm} | cksum + +rm ${testb_pgm} + +echo "Test 10. Should print 3957742883 302 four times" + +testg_pgm=${tmpdir}/testg.pgm + +pgmmake 0.5 2 2 > ${testg_pgm} + +# pgmmake 0.0 17 17 | cksum + +pamcut -pad -cropleft=17 -croptop=17 -width=17 -height=17 ${testg_pgm} | cksum +pamcut -pad -cropright=17 -croptop=17 -width=17 -height=17 ${testg_pgm} | \ + pamflip -lr | cksum +pamcut -pad -cropleft=17 -cropbottom=17 -width=17 -height=17 ${testg_pgm} | \ + pamflip -tb | cksum +pamcut -pad -cropright=17 -cropbottom=17 -width=17 -height=17 ${testg_pgm} |\ + pamflip -r180 | cksum + +rm ${testg_pgm} + +echo "Test 11. Should print 1576602925 8 four times" + +test5_pbm=${tmpdir}/test5.pbm + +pbmmake -g 5 5 > ${test5_pbm} + +cat ${test1_pbm} | cksum +pamcut -pad -left=6 -right=6 -top=6 -bottom 6 ${test5_pbm} | cksum +pamcut -pad -left=-6 -right=-6 -top=-6 -bottom -6 ${test5_pbm} | cksum +pamcut -pad -left=101 -right=101 -top=1001 -bottom 1001 ${test5_pbm} | cksum + +rm ${test1_pbm} ${test5_pbm} + +echo "Test Invalid" + +. ${srcdir}/test-invalid.inc # overspecification -pamcut -left=1 -right=1 -width=14 testgrid.pbm > ${test_out} || \ - printf "Expected failure 1 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamcut -top=1 -bottom=1 -height=16 testgrid.pbm > ${test_out} || \ - printf "Expected failure 2 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamcut -right=1 -cropright=1 testgrid.pbm > ${test_out} || \ - printf "Expected failure 3 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamcut -top=1 -croptop=1 testgrid.pbm > ${test_out} || \ - printf "Expected failure 4 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamcut -bottom=1 -cropbottom=1 testgrid.pbm > ${test_out} || \ - printf "Expected failure 5 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamcut -left=1 -cropleft=1 testgrid.pbm > ${test_out} || \ - printf "Expected failure 6 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -# excessive cropping -pamcut -cropleft=7 -cropright=8 testgrid.pbm > ${test_out} || \ - printf "Expected failure 7 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamcut -left=7 -right=6 testgrid.pbm > ${test_out} || \ - printf "Expected failure 8 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamcut -croptop=8 -cropbottom=8 testgrid.pbm > ${test_out} || \ - printf "Expected failure 9 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamcut -top=10 -bottom=9 testgrid.pbm > ${test_out} || \ - printf "Expected failure 6 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pamcut -left=1 -right=1 -width=14 testgrid.pbm" +invCmd "pamcut -top=1 -bottom=1 -height=16 testgrid.pbm" +invCmd "pamcut -right=1 -cropright=1 testgrid.pbm" +invCmd "pamcut -top=1 -croptop=1 testgrid.pbm" +invCmd "pamcut -bottom=1 -cropbottom=1 testgrid.pbm" +invCmd "pamcut -left=1 -cropleft=1 testgrid.pbm" + +# excessive amounts +invCmd "pamcut -cropleft=14 testgrid.pbm" +invCmd "pamcut -cropleft=7 -cropright=8 testgrid.pbm" +invCmd "pamcut -left=7 -right=6 testgrid.pbm" +invCmd "pamcut -croptop=16 testgrid.pbm" +invCmd "pamcut -croptop=8 -cropbottom=8 testgrid.pbm" +invCmd "pamcut -top=10 -bottom=9 testgrid.pbm" # pad absent -pamcut -cropleft=1 -width=14 testgrid.pbm > ${test_out} || \ - printf "Expected failure 10 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamcut -croptop=1 -height=16 testgrid.pbm > ${test_out} || \ - printf "Expected failure 11 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pamcut -cropleft=1 -width=14 testgrid.pbm" +invCmd "pamcut -croptop=1 -height=16 testgrid.pbm" # legacy style: insufficient number of positional parameters -pamcut 5 testimg.ppm > ${test_out} || \ - printf "Expected failure 12 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamcut 5 4 testimg.ppm > ${test_out} || \ - printf "Expected failure 13 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamcut 5 5 30 testimg.ppm > ${test_out} || \ - printf "Expected failure 14 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pamcut 5 testimg.ppm" +invCmd "pamcut 5 4 testimg.ppm" +invCmd "pamcut 5 5 30 testimg.ppm" |