diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2021-12-27 17:33:56 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2021-12-27 17:33:56 +0000 |
commit | 6e629f983aa205c3eaa5f339f1c71bb5e7938049 (patch) | |
tree | a89f594443ac2330138f0bd0f19ee59135c2213f /test/cut-cat-roundtrip.test | |
parent | ec52f41aabc9de9aac203c2f462252e403c7374a (diff) | |
download | netpbm-mirror-6e629f983aa205c3eaa5f339f1c71bb5e7938049.tar.gz netpbm-mirror-6e629f983aa205c3eaa5f339f1c71bb5e7938049.tar.xz netpbm-mirror-6e629f983aa205c3eaa5f339f1c71bb5e7938049.zip |
Promote Development to Advanced to make Release 10.97.00
git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@4222 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'test/cut-cat-roundtrip.test')
-rwxr-xr-x | test/cut-cat-roundtrip.test | 170 |
1 files changed, 94 insertions, 76 deletions
diff --git a/test/cut-cat-roundtrip.test b/test/cut-cat-roundtrip.test index 95ee5279..970c3e17 100755 --- a/test/cut-cat-roundtrip.test +++ b/test/cut-cat-roundtrip.test @@ -1,128 +1,146 @@ #! /bin/bash # This script tests: pamcut -# Also requires: pnmcat pnmpad +# Also requires: pamfile pnmcat pnmpad pnmcrop tmpdir=${tmpdir:-/tmp} -quant_ppm=${tmpdir}/quant.ppm -right_pbm=${tmpdir}/right.pbm -left_pbm=${tmpdir}/left.pbm -right_ppm=${tmpdir}/right.ppm left_ppm=${tmpdir}/left.ppm -bottom_pbm=${tmpdir}/bottom.pbm -top_pbm=${tmpdir}/top.pbm -bottom_ppm=${tmpdir}/bottom.ppm +right_ppm=${tmpdir}/right.ppm top_ppm=${tmpdir}/top.ppm +bottom_ppm=${tmpdir}/bottom.ppm +padded_ppm=${tmpdir}/padded.ppm + +echo "Test 1. Should print 1926073387 101484 six times" +testimg_ppm_sum=`cat testimg.ppm | cksum` +echo ${testimg_ppm_sum} -# Test 1. Should print 1926073387 101484 six times -echo Test 1. + imgsize=$(pamfile -size testimg.ppm) + iw=$(echo ${imgsize} | cut -d" " -f1) + ih=$(echo ${imgsize} | cut -d" " -f2) -cat testimg.ppm | cksum for i in 0 1 128 224 225 do pamcut -left=$((i+1)) testimg.ppm > ${right_ppm} pamcut -right=$i testimg.ppm > ${left_ppm} pnmcat -lr ${left_ppm} ${right_ppm} | \ - pamcut -left=0 -width=227| cksum + pamcut -left=0 -width=${iw} | cksum rm ${left_ppm} ${right_ppm} done +echo "Test 2. Should print 3891261972 202953 1926073387 101484 six times" +# Padding added to right. -# Test 2. Should print 3891261972 202953 six times -# Not roundtrip. Padding added to right. -echo Test 2. +pnmpad -right=${iw} -black testimg.ppm | cksum | tr '\n' ' ' +echo ${testimg_ppm_sum} -pnmpad -right=227 -black testimg.ppm | cksum -for i in 0 1 128 224 225 +for border in 0 1 128 224 225 do - pamcut -left=$((i+1)) -width=227 -pad testimg.ppm > ${right_ppm} - pamcut -right=$i -width=227 -pad testimg.ppm > ${left_ppm} + pamcut -left=$((${border}+1)) -width=${iw} -pad testimg.ppm > ${right_ppm} + pamcut -right=${border} -width=${iw} -pad testimg.ppm > ${left_ppm} pnmcat -lr ${left_ppm} ${right_ppm} ${left_ppm} | \ - pamcut -left=$((227-i-1)) -width=$((227*2)) | cksum - rm ${left_ppm} ${right_ppm} + pamcut -left=$((${iw}-${border}-1)) -width=$((${iw}*2)) | \ + tee ${padded_ppm} | cksum | tr '\n' ' ' + pnmcrop -black -right ${padded_ppm} | cksum + rm ${left_ppm} ${right_ppm} ${padded_ppm} done -# Test 3. Should print 1926073387 101484 five times -echo Test 3. +echo "Test 3. Should print 1926073387 101484 five times" -cat testimg.ppm | cksum -for i in 0 1 70 147 +echo ${testimg_ppm_sum} +for border in 0 1 70 147 do - pamcut -top=$((i+1)) testimg.ppm > ${bottom_ppm} - pamcut -bottom=$i testimg.ppm > ${top_ppm} + pamcut -top=$((${border}+1)) testimg.ppm > ${bottom_ppm} + pamcut -bottom=${border} testimg.ppm > ${top_ppm} pnmcat -tb ${top_ppm} ${bottom_ppm} | \ - pamcut -top=0 -height=149 | cksum + pamcut -top=0 -height=${ih} | cksum rm ${top_ppm} ${bottom_ppm} done -# Test 4. Should print 26789469 202953 five times -# Not roundtrip. Padding added to bottom. -echo Test 4. +echo "Test 4. Should print 26789469 202953 1926073387 101484 five times" +# Padding added to bottom. -pnmpad -bottom=149 -black testimg.ppm | cksum -for i in 0 1 70 147 +pnmpad -bottom=${ih} -black testimg.ppm | cksum | tr '\n' ' ' +echo ${testimg_ppm_sum} +for border in 0 1 70 147 do - pamcut -top=$((i+1)) -height=149 -pad testimg.ppm > ${bottom_ppm} - pamcut -bottom=$i -height=149 -pad testimg.ppm > ${top_ppm} + pamcut -top=$((${border}+1)) -height=${ih} -pad testimg.ppm > ${bottom_ppm} + pamcut -bottom=${border} -height=${ih} -pad testimg.ppm > ${top_ppm} pnmcat -tb ${top_ppm} ${bottom_ppm} ${top_ppm} | \ - pamcut -top=$((149-i-1)) -height=$((149*2)) | cksum - rm ${top_ppm} ${bottom_ppm} + pamcut -top=$((${ih}-${border}-1)) -height=$((${ih}*2)) | \ + tee ${padded_ppm} | cksum | tr '\n' ' 'cksum + pnmcrop -black -bottom ${padded_ppm} | cksum + rm ${top_ppm} ${bottom_ppm} ${padded_ppm} done -# Test 5. Should print 2425386270 41 fourteen times -echo Test 5. +left_pbm=${tmpdir}/left.pbm +right_pbm=${tmpdir}/right.pbm +top_pbm=${tmpdir}/top.pbm +bottom_pbm=${tmpdir}/bottom.pbm +padded_pbm=${tmpdir}/padded.pbm + +echo "Test 5. Should print 281226646 481 six times" + +maze_pbm_sum=`cat maze.pbm | cksum` +echo ${maze_pbm_sum} + +imgsize=$(pamfile -size maze.pbm) +iw=$(echo ${imgsize} | cut -d" " -f1) +ih=$(echo ${imgsize} | cut -d" " -f2) -cat testgrid.pbm | cksum -for i in `seq 0 12` +for i in 0 1 10 30 50 do - pamcut -left=$((i+1)) testgrid.pbm > ${right_pbm} - pamcut -right=$i testgrid.pbm > ${left_pbm} - pnmcat -lr ${left_pbm} ${right_pbm} | \ - pamcut -left=0 -width=14 | cksum - rm ${left_pbm} ${right_pbm} + pamcut -left=$((i+1)) maze.pbm > ${right_ppm} + pamcut -right=$i maze.pbm > ${left_ppm} + pnmcat -lr ${left_ppm} ${right_ppm} | \ + pamcut -left=0 -width=${iw} | cksum + rm ${left_ppm} ${right_ppm} done -# Test 6. Should print 1887700557 73 fifteen times -# Not roundtrip. Padding added to right. -echo Test 6. +echo "Test 6. Should print 1748767123 895 281226646 481 six times" +# Padding added to right. + +pnmpad -right=${iw} -black maze.pbm | cksum | tr '\n' ' ' +echo ${maze_pbm_sum} -pnmpad -right=14 -black testgrid.pbm | cksum -for i in `seq 0 13` +for border in 0 1 10 30 50 do - pamcut -left=$((i+1)) -width=14 -pad testgrid.pbm > ${right_pbm} - pamcut -right=$i -width=14 -pad testgrid.pbm > ${left_pbm} - pnmcat -lr ${left_pbm} ${right_pbm} ${left_pbm} | \ - pamcut -left=$((14-i-1)) -width=28 | cksum - rm ${left_pbm} ${right_pbm} + pamcut -left=$((${border}+1)) -width=${iw} -pad maze.pbm > ${right_ppm} + pamcut -right=${border} -width=${iw} -pad maze.pbm > ${left_ppm} + pnmcat -lr ${left_ppm} ${right_ppm} ${left_ppm} | \ + pamcut -left=$((${iw}-${border}-1)) -width=$((${iw}*2)) | \ + tee ${padded_ppm} | cksum | tr '\n' ' ' + pnmcrop -black -right ${padded_ppm} | cksum + rm ${left_ppm} ${right_ppm} ${padded_ppm} done -# Test 7. Should print 2425386270 41 sixteen times -echo Test 7. -cat testgrid.pbm | cksum -for i in `seq 0 14` +echo "Test 7. Should print 281226646 481 seven times" + +echo ${maze_pbm_sum} +for border in 0 1 12 21 31 44 do - pamcut -top=$((i+1)) testgrid.pbm > ${bottom_pbm} - pamcut -bottom=$i testgrid.pbm > ${top_pbm} - pnmcat -tb ${top_pbm} ${bottom_pbm} | \ - pamcut -top=0 -height=16 | cksum - rm ${top_pbm} ${bottom_pbm} + pamcut -top=$((${border}+1)) maze.pbm > ${bottom_ppm} + pamcut -bottom=${border} maze.pbm > ${top_ppm} + pnmcat -tb ${top_ppm} ${bottom_ppm} | \ + pamcut -top=0 -height=${ih} | cksum + rm ${top_ppm} ${bottom_ppm} done -# Test 8. Should print 3221289196 73 seventeen times -# Not roundtrip. Padding added to bottom. -echo Test 8. +echo "Test 8. Should print 1346655680 954 281226646 481 five times" +# Padding added to bottom. -pnmpad -bottom=16 -black testgrid.pbm | cksum -for i in `seq 0 15` +pnmpad -bottom=${ih} -black maze.pbm | cksum | tr '\n' ' ' +echo ${maze_pbm_sum} +for border in 0 1 10 50 do - pamcut -top=$((i+1)) -height=16 -pad testgrid.pbm > ${bottom_pbm} - pamcut -bottom=$i -height=16 -pad testgrid.pbm > ${top_pbm} - pnmcat -tb ${top_pbm} ${bottom_pbm} ${top_pbm} | \ - pamcut -top=$((16-i-1)) -height=32 | cksum - rm ${top_pbm} ${bottom_pbm} + pamcut -top=$((${border}+1)) -height=${ih} -pad maze.pbm > ${bottom_ppm} + pamcut -bottom=${border} -height=${ih} -pad maze.pbm > ${top_ppm} + pnmcat -tb ${top_ppm} ${bottom_ppm} ${top_ppm} | \ + pamcut -top=$((${ih}-${border}-1)) -height=$((${ih}*2)) | \ + tee ${padded_ppm} | cksum | tr '\n' ' 'cksum + pnmcrop -black -bottom ${padded_ppm} | cksum + rm ${top_ppm} ${bottom_ppm} ${padded_ppm} done - |