diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2013-12-06 17:58:55 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2013-12-06 17:58:55 +0000 |
commit | 4dae047849625a2acaac764d15d7a7b6549071f3 (patch) | |
tree | 02e7191ee290dd9bc5842cc2464c7b57ed687db9 | |
parent | 1fd6937fcb290fa56cb882a819294605568e3b5f (diff) | |
download | netpbm-mirror-4dae047849625a2acaac764d15d7a7b6549071f3.tar.gz netpbm-mirror-4dae047849625a2acaac764d15d7a7b6549071f3.tar.xz netpbm-mirror-4dae047849625a2acaac764d15d7a7b6549071f3.zip |
Add test for Pnmshear
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@2046 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r-- | test/Test-Order | 1 | ||||
-rw-r--r-- | test/pnmshear.ok | 1 | ||||
-rw-r--r-- | test/pnmshear.test | 19 | ||||
-rw-r--r-- | test/ps-roundtrip.ok | 14 | ||||
-rwxr-xr-x | test/ps-roundtrip.test | 76 |
5 files changed, 88 insertions, 23 deletions
diff --git a/test/Test-Order b/test/Test-Order index 698552b9..75bb5a93 100644 --- a/test/Test-Order +++ b/test/Test-Order @@ -63,6 +63,7 @@ ppmbrighten.test ppmdither.test pamedge.test ppmdim.test +pnmshear.test ppmmix.test diff --git a/test/pnmshear.ok b/test/pnmshear.ok new file mode 100644 index 00000000..d701faaf --- /dev/null +++ b/test/pnmshear.ok @@ -0,0 +1 @@ +2080980136 22 diff --git a/test/pnmshear.test b/test/pnmshear.test new file mode 100644 index 00000000..276e3e22 --- /dev/null +++ b/test/pnmshear.test @@ -0,0 +1,19 @@ +#! /bin/bash +# This script tests: pnmshear +# Also requires: pbmmake + +# Test. Should produce 2080980136 22 +${PBM_BINPREFIX}pbmmake -g 7 7 | \ + ${PBM_TESTPREFIX}pnmshear 45 -noantialias | cksum + +# Output of above, in pbm plain format +# +# P1 +# 14 7 +# 01010101111111 +# 10101011111111 +# 10101010111111 +# 11101010111111 +# 11101010101111 +# 11111010101111 +# 11111010101011 diff --git a/test/ps-roundtrip.ok b/test/ps-roundtrip.ok index a267f7eb..0ebfb94a 100644 --- a/test/ps-roundtrip.ok +++ b/test/ps-roundtrip.ok @@ -1,3 +1,15 @@ 1926073387 101484 -2425386270 41 +1926073387 101484 +1926073387 101484 +1926073387 101484 +1926073387 101484 +2918318199 62 +2918318199 62 +2918318199 62 +2918318199 62 +2918318199 62 +2918318199 62 +2918318199 62 +1386192571 507420 +1386192571 507420 1386192571 507420 diff --git a/test/ps-roundtrip.test b/test/ps-roundtrip.test index 60ecf60a..b7aa816c 100755 --- a/test/ps-roundtrip.test +++ b/test/ps-roundtrip.test @@ -1,38 +1,70 @@ #! /bin/bash # This script tests: pnmtops pstopnm -# Also requires: pnmtopnm pamtopnm gs +# Also requires: pnmtopnm pamtopnm gs pbmmake pnmshear pnmpad pnmcat -# Test 1. Should print: 1926073387 101484 -${PBM_TESTPREFIX}pnmtops -nocenter -equalpixels -dpi 72 -noturn testimg.ppm \ - > ${tmpdir}/testimg.ps -xysize1=`awk '/BoundingBox/ {print "-xsize="$4,"-ysize="$5}' \ - ${tmpdir}/testimg.ps` -${PBM_TESTPREFIX}pstopnm -xborder=0 -yborder=0 $xysize1 -stdout \ - -quiet ${tmpdir}/testimg.ps | \ - ${PBM_BINPREFIX}pnmtopnm | cksum +# Test 1. Should print: 1926073387 101484 five times +# *NOTE* Fifth iteration fails if pnmtops was compiled without zlib +# (flate compression) support. +for flag in "" "-ps" "-rle" "-ps -ascii" "-ps -flate" + do + ${PBM_TESTPREFIX}pnmtops -nocenter -equalpixels -dpi 72 -noturn \ + ${flag} testimg.ppm \ + > ${tmpdir}/testimg.ps + xysize1=`awk '/BoundingBox/ {print "-xsize="$4,"-ysize="$5}' \ + ${tmpdir}/testimg.ps` + ${PBM_TESTPREFIX}pstopnm -xborder=0 -yborder=0 $xysize1 -stdout \ + -quiet ${tmpdir}/testimg.ps | \ + ${PBM_BINPREFIX}pnmtopnm | cksum + done -# Test 2. Should print: 2425386270 41 -${PBM_TESTPREFIX}pnmtops -nocenter -equalpixels -dpi 72 -noturn \ - testgrid.pbm > ${tmpdir}/testgrid.ps && -xysize2=`awk '/BoundingBox/ {print "-xsize="$4,"-ysize="$5}' \ - ${tmpdir}/testgrid.ps` -${PBM_TESTPREFIX}pstopnm -xborder=0 -yborder=0 $xysize2 -stdout \ - -quiet ${tmpdir}/testgrid.ps -pbm | \ - ${PBM_BINPREFIX}pnmtopnm | cksum +# Test 2. Should print: 2918318199 62 seven times +# Test image designed to detect problems with run-length compression +# +${PBM_BINPREFIX}pbmmake -g 2 2 > ${tmpdir}/g.pbm +${PBM_BINPREFIX}pbmmake -g 8 4 | \ + ${PBM_BINPREFIX}pnmshear 45 -noantialias -background=black | \ + ${PBM_BINPREFIX}pnmpad -right 60 | \ + ${PBM_BINPREFIX}pnmcat -tb -jright - ${tmpdir}/g.pbm > ${tmpdir}/t.pbm && +for flag in "" "-rle" "-ps -rle -ascii" \ + "-bitspersample=2 -rle" "-ps -bitspersample=4 -rle" \ + "-bitspersample=8 -rle" "-ps -bitspersample=12 -rle -dict" + do + ${PBM_TESTPREFIX}pnmtops -nocenter -equalpixels -dpi 72 -noturn \ + ${flag} ${tmpdir}/t.pbm > ${tmpdir}/testgrid.ps && + xysize2=`awk '/BoundingBox/ {print "-xsize="$4,"-ysize="$5}' \ + ${tmpdir}/testgrid.ps` + ${PBM_TESTPREFIX}pstopnm -xborder=0 -yborder=0 $xysize2 -stdout \ + -quiet ${tmpdir}/testgrid.ps -pbm | \ + ${PBM_BINPREFIX}pnmtopnm | cksum + done -#Test 3. Should print: 1386192571 507420 +#Test 3. Should print: 1386192571 507420 three times +# *NOTE* Second iteration fails if pnmtops was compiled without zlib +# (flate compression) support. +# +# Special care is needed when conducting round-trips with multiple-image +# files as input. +# (1) pnmtops: -setpage is mandatory +# (2) awk: xy values are taken from the first "BoundingBox" encountered. +# Subsequent BoundingBox values are ignored. +# (3) pstopnm: input must be an ordinary file. Input from stdin +# (by pipe or input redirection: "< file" ) does not work. +# +for flag in "" "-ps" \ + "-ps -bitspersample=12 -flate -rle -vmreclaim" + do cat testimg.ppm testimg.ppm testimg.ppm testgrid.pbm testgrid.pbm | \ ${PBM_TESTPREFIX}pnmtops -nocenter -equalpixels -dpi 72 -noturn -setpage \ - > ${tmpdir}/testimg5.ps + ${flag} > ${tmpdir}/testimg5.ps xysize3=`awk '/BoundingBox/ {print "-xsize="$4,"-ysize="$5 ; exit}' \ ${tmpdir}/testimg5.ps` ${PBM_TESTPREFIX}pstopnm -xborder=0 -yborder=0 $xysize3 \ -stdout ${tmpdir}/testimg5.ps | \ ${PBM_BINPREFIX}pnmtopnm | cksum + done -#rm ${tmpdir}/testgrid.ps ${tmpdir}/testimg.ps ${tmpdir}/testimg5.ps -rm ${tmpdir}/testimg.ps ${tmpdir}/testimg5.ps -mv ${tmpdir}/testgrid.ps /tmp +rm ${tmpdir}/testgrid.ps ${tmpdir}/testimg.ps ${tmpdir}/testimg5.ps \ + ${tmpdir}/t.pbm |