diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2023-06-28 17:29:32 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2023-06-28 17:29:32 +0000 |
commit | 23ce26f64c34e30951ad9ade2151552ed77e7357 (patch) | |
tree | d73b31a0c2f7c7be4a69f8a8e84e00dd39c432b5 /test/pamcut.test | |
parent | 1b6e51a266008348ad93ed8b6ac9ec91b5024fea (diff) | |
download | netpbm-mirror-23ce26f64c34e30951ad9ade2151552ed77e7357.tar.gz netpbm-mirror-23ce26f64c34e30951ad9ade2151552ed77e7357.tar.xz netpbm-mirror-23ce26f64c34e30951ad9ade2151552ed77e7357.zip |
promote Advanced to Stable
git-svn-id: http://svn.code.sf.net/p/netpbm/code/stable@4558 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'test/pamcut.test')
-rwxr-xr-x | test/pamcut.test | 129 |
1 files changed, 108 insertions, 21 deletions
diff --git a/test/pamcut.test b/test/pamcut.test index 9971b1a5..a489635a 100755 --- a/test/pamcut.test +++ b/test/pamcut.test @@ -1,28 +1,23 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamcut pbmmake -# Also requires: +# Also requires: pamfile -# Test 1. Should print 2958909756 124815 -echo Test 1. +echo "Test 1. Should print 2958909756 124815" pamcut -top 0 -left 0 -width 260 -height 160 \ -pad testimg.ppm | cksum -# Test 2. Should print 1550940962 10933 -echo Test 2. +echo "Test 2. Should print 1550940962 10933" pamcut -top 200 -left 120 -width 40 -height 40 \ -pad testimg.ppm | cksum -# Test 3. Should print 708474423 14 twice -echo Test 3. +echo "Test 3. Should print 708474423 14 twice" pamcut -top 5 -left 5 -bottom 5 -right 5 testimg.ppm | cksum pamcut -width 1 -height 1 -bottom 5 -right 5 testimg.ppm | cksum - -# Test 4. Should print 659346598 80124 four times -echo Test 4. +echo "Test 4. Should print 659346598 80124 four times" pamcut -croptop 10 -cropleft 10 -cropbottom 10 -cropright 10 testimg.ppm | \ cksum @@ -30,18 +25,110 @@ 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" -# Test 5. Should print 2425386270 41 four times -echo Test 5. - -pamcut -croptop 0 -cropleft 0 -cropbottom 0 -cropright 0 testgrid.pbm | \ +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 maze.pbm | \ cksum -pamcut -top 0 -left 0 -bottom 15 -right 13 testgrid.pbm | cksum -pamcut -top 0 -left 0 -bottom -1 -right -1 testgrid.pbm | cksum -pamcut -top 0 -left 0 -width 14 -height 16 testgrid.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 +pamcut maze.pbm | cksum + +echo "Test 6. Should print 3412257956 129" + +pbmmake -g 50 50 | pamcut 5 5 30 30 | cksum -# Test 6. Should print 3412257956 129 -echo Test 6. +echo "Test Invalid" -pbmmake -g 50 50 | pamcut 5 5 30 30 | cksum +tmpdir=${tmpdir:-/tmp} +test_out=${tmpdir}/test_out + +echo 1>&2 +echo "Invalid command-line argument combinations." 1>&2 +echo "Error messages should appear below the line." 1>&2 +echo "-----------------------------------------------------------" 1>&2 + +# overspecification +pamcut -left=1 -right=1 -width=14 testgrid.pbm > ${test_out} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamcut -top=1 -bottom=1 -height=16 testgrid.pbm > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamcut -right=1 -cropright=1 testgrid.pbm > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamcut -top=1 -croptop=1 testgrid.pbm > ${test_out} || \ + printf "Expected failure 4" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamcut -bottom=1 -cropbottom=1 testgrid.pbm > ${test_out} || \ + printf "Expected failure 5" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamcut -left=1 -cropleft=1 testgrid.pbm > ${test_out} || \ + printf "Expected failure 6" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# excessive cropping +pamcut -cropleft=7 -cropright=8 testgrid.pbm > ${test_out} || \ + printf "Expected failure 7" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamcut -left=7 -right=6 testgrid.pbm > ${test_out} || \ + printf "Expected failure 8" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamcut -croptop=8 -cropbottom=8 testgrid.pbm > ${test_out} || \ + printf "Expected failure 9" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamcut -top=10 -bottom=9 testgrid.pbm > ${test_out} || \ + printf "Expected failure 6" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# pad absent +pamcut -cropleft=1 -width=14 testgrid.pbm > ${test_out} || \ + printf "Expected failure 10" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamcut -croptop=1 -height=16 testgrid.pbm > ${test_out} || \ + printf "Expected failure 11" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# legacy style: insufficient number of positional parameters +pamcut 5 testimg.ppm > ${test_out} || \ + printf "Expected failure 12" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamcut 5 4 testimg.ppm > ${test_out} || \ + printf "Expected failure 13" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamcut 5 5 30 testimg.ppm > ${test_out} || \ + printf "Expected failure 14" + test -s ${test_out}; echo " "$? + rm -f ${test_out} |