From ee250e7490cbb3550fed22fdb98b7152cce20b72 Mon Sep 17 00:00:00 2001 From: giraffedata Date: Sat, 29 Dec 2018 16:32:28 +0000 Subject: Promote current Development release as Advanced git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@3468 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- test/Test-Order | 6 +- test/bmp-quant-roundtrip.ok | 6 ++ test/bmp-quant-roundtrip.test | 36 ++++++++++++ test/bmp-roundtrip.ok | 20 ++++++- test/bmp-roundtrip.test | 41 ++++++++++++- test/cut-cat-roundtrip.ok | 92 +++++++++++++++++++++++++++++ test/cut-cat-roundtrip.test | 128 +++++++++++++++++++++++++++++++++++++++++ test/g3-roundtrip.ok | 20 +++---- test/g3-roundtrip.test | 20 +++---- test/gif-quant-roundtrip.ok | 2 +- test/gif-quant-roundtrip.test | 2 +- test/gif-roundtrip.ok | 20 +++---- test/gif-roundtrip.test | 8 +-- test/palm-roundtrip.ok | 10 ++-- test/palm-roundtrip.test | 8 ++- test/pamcut.ok | 15 +++++ test/pamcut.test | 35 ++++++++++- test/pammixmulti-identity.ok | 22 +++++++ test/pammixmulti-identity.test | 77 +++++++++++++++++++++++++ test/pbmtext-utf8.ok | 4 +- test/pbmtext-utf8.test | 4 +- test/pdb-roundtrip.ok | 22 +++---- test/pdb-roundtrip.test | 6 +- test/pnmpaste-pbm.ok | 22 +++++++ test/pnmpaste-pbm.test | 47 +++++++++++++++ test/pnmtile.ok | 2 +- test/pnmtile.test | 2 +- test/rgb3-roundtrip.ok | 2 +- test/rgb3-roundtrip.test | 2 +- test/targa-roundtrip.ok | 40 +++++++++++++ test/targa-roundtrip.test | 82 ++++++++++++++++++++++---- 31 files changed, 721 insertions(+), 82 deletions(-) create mode 100644 test/bmp-quant-roundtrip.ok create mode 100755 test/bmp-quant-roundtrip.test create mode 100644 test/cut-cat-roundtrip.ok create mode 100755 test/cut-cat-roundtrip.test create mode 100644 test/pammixmulti-identity.ok create mode 100755 test/pammixmulti-identity.test create mode 100644 test/pnmpaste-pbm.ok create mode 100755 test/pnmpaste-pbm.test (limited to 'test') diff --git a/test/Test-Order b/test/Test-Order index 6abc2287..8bda73a4 100644 --- a/test/Test-Order +++ b/test/Test-Order @@ -1,4 +1,4 @@ -# General test +# General tests all-in-place.test legacy-names.test @@ -63,6 +63,7 @@ pnminvert.test pamchannel.test ppmchange.test pambackground.test +pnmpaste-pbm.test pbmpscale.test pnmremap1.test @@ -78,6 +79,7 @@ pnmshear.test pgmbentley.test ppmmix.test +pammixmulti-identity.test # Symmetry test @@ -111,6 +113,7 @@ pamdice-roundtrip.test pamslice-roundtrip.test lookup-roundtrip.test enlarge-reduce-roundtrip.test +cut-cat-roundtrip.test # Round-trip tests : lossless converters @@ -119,6 +122,7 @@ atari-roundtrip.test atk-roundtrip.test avs-roundtrip.test bmp-roundtrip.test +bmp-quant-roundtrip.test cis-roundtrip.test cmuw-roundtrip.test facesaver-roundtrip.test diff --git a/test/bmp-quant-roundtrip.ok b/test/bmp-quant-roundtrip.ok new file mode 100644 index 00000000..5262df53 --- /dev/null +++ b/test/bmp-quant-roundtrip.ok @@ -0,0 +1,6 @@ +colors=256, bpp=8 +0 0 0 : 0 +0 0 0 : 0 +colors=16, bpp=4 +0 0 0 : 0 +0 0 0 : 0 diff --git a/test/bmp-quant-roundtrip.test b/test/bmp-quant-roundtrip.test new file mode 100755 index 00000000..2c223b7c --- /dev/null +++ b/test/bmp-quant-roundtrip.test @@ -0,0 +1,36 @@ +#! /bin/bash +# This script tests: bmptopnm ppmtobmp pnmquant +# Also requires: ppmhist + +tmpdir=${tmpdir:-/tmp} +quant_ppm=${tmpdir}/quant.ppm + +colors=256 # any value between 2 - 256 works +bpp=8 +echo colors=${colors}, bpp=${bpp} + +pnmquant ${colors} testimg.ppm > ${quant_ppm} + +for mode in "-windows" "-os2" + do + ppmtobmp $mode -bpp=${bpp} ${quant_ppm} | bmptopnm | \ + cmp -s - ${quant_ppm} > /dev/null + echo ${PIPESTATUS[@]} ":" $? + done + +rm ${quant_ppm} + +colors=16 # any value between 2 - 16 works +bpp=4 +echo colors=${colors}, bpp=${bpp} + +pnmquant ${colors} testimg.ppm > ${quant_ppm} + +for mode in "-windows" "-os2" + do + ppmtobmp -bpp=${bpp} ${quant_ppm} | bmptopnm | \ + cmp -s - ${quant_ppm} > /dev/null + echo ${PIPESTATUS[@]} ":" $? + done + +rm ${quant_ppm} diff --git a/test/bmp-roundtrip.ok b/test/bmp-roundtrip.ok index 67f7a1fe..4f4f8367 100644 --- a/test/bmp-roundtrip.ok +++ b/test/bmp-roundtrip.ok @@ -1,2 +1,20 @@ -1926073387 101484 +PBM +2425386270 41 +2425386270 41 +2425386270 41 2425386270 41 +PPM +1926073387 101484 +1926073387 101484 +1926073387 101484 +1926073387 101484 +PGM +1571496937 33838 +1571496937 33838 +1571496937 33838 +1571496937 33838 +1571496937 33838 +1571496937 33838 +1571496937 33838 +1571496937 33838 +1571496937 33838 diff --git a/test/bmp-roundtrip.test b/test/bmp-roundtrip.test index be9a4548..c9ef363a 100755 --- a/test/bmp-roundtrip.test +++ b/test/bmp-roundtrip.test @@ -1,7 +1,42 @@ #! /bin/bash # This script tests: bmptopnm ppmtobmp -# Also requires: +# Also requires: pamchannel pamtopnm pamseq +tmpdir=${tmpdir:-/tmp} -ppmtobmp testimg.ppm | bmptopnm | cksum -ppmtobmp testgrid.pbm | bmptopnm | cksum +# Test 1. Should print 2425386270 41 four times + +echo PBM + +for mode in "" "-bpp=1" "-windows" "-os2" + do + ppmtobmp ${mode} testgrid.pbm | bmptopnm | cksum + done + +# Test 2. Should print 1926073387 101484 four times + +echo PPM + +for mode in "" "-bpp=24" "-windows" "-os2" + do + ppmtobmp ${mode} testimg.ppm | bmptopnm | cksum + done + +# Test 3. Should print 1571496937 33838 nine times + +echo PGM + +red_pgm=${tmpdir}/red.pgm +mapfile_pgm=${tmpdir}/mapfile.pgm +pamseq -tupletype="GRAYSCALE" 1 255 > ${mapfile_pgm} + +pamchannel -infile=testimg.ppm -tupletype="GRAYSCALE" 0 | \ + pamtopnm | tee ${red_pgm} | cksum + +for mode in "" "-bpp=8" "-windows" "-os2" + do + ppmtobmp ${mode} ${red_pgm} | bmptopnm | cksum + ppmtobmp ${mode} -mapfile=${mapfile_pgm} ${red_pgm} | bmptopnm | cksum + done + +rm ${mapfile_pgm} ${red_pgm} \ No newline at end of file diff --git a/test/cut-cat-roundtrip.ok b/test/cut-cat-roundtrip.ok new file mode 100644 index 00000000..bc9b8cb4 --- /dev/null +++ b/test/cut-cat-roundtrip.ok @@ -0,0 +1,92 @@ +Test 1. +1926073387 101484 +1926073387 101484 +1926073387 101484 +1926073387 101484 +1926073387 101484 +1926073387 101484 +Test 2. +3891261972 202953 +3891261972 202953 +3891261972 202953 +3891261972 202953 +3891261972 202953 +3891261972 202953 +Test 3. +1926073387 101484 +1926073387 101484 +1926073387 101484 +1926073387 101484 +1926073387 101484 +Test 4. +26789469 202953 +26789469 202953 +26789469 202953 +26789469 202953 +26789469 202953 +Test 5. +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +Test 6. +1887700557 73 +1887700557 73 +1887700557 73 +1887700557 73 +1887700557 73 +1887700557 73 +1887700557 73 +1887700557 73 +1887700557 73 +1887700557 73 +1887700557 73 +1887700557 73 +1887700557 73 +1887700557 73 +1887700557 73 +Test 7. +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +Test 8. +3221289196 73 +3221289196 73 +3221289196 73 +3221289196 73 +3221289196 73 +3221289196 73 +3221289196 73 +3221289196 73 +3221289196 73 +3221289196 73 +3221289196 73 +3221289196 73 +3221289196 73 +3221289196 73 +3221289196 73 +3221289196 73 +3221289196 73 diff --git a/test/cut-cat-roundtrip.test b/test/cut-cat-roundtrip.test new file mode 100755 index 00000000..95ee5279 --- /dev/null +++ b/test/cut-cat-roundtrip.test @@ -0,0 +1,128 @@ +#! /bin/bash +# This script tests: pamcut +# Also requires: pnmcat pnmpad + +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 +top_ppm=${tmpdir}/top.ppm + + +# Test 1. Should print 1926073387 101484 six times +echo Test 1. + +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 + rm ${left_ppm} ${right_ppm} + done + + +# Test 2. Should print 3891261972 202953 six times +# Not roundtrip. Padding added to right. +echo Test 2. + +pnmpad -right=227 -black testimg.ppm | cksum +for i 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} + pnmcat -lr ${left_ppm} ${right_ppm} ${left_ppm} | \ + pamcut -left=$((227-i-1)) -width=$((227*2)) | cksum + rm ${left_ppm} ${right_ppm} + done + + +# Test 3. Should print 1926073387 101484 five times +echo Test 3. + +cat testimg.ppm | cksum +for i in 0 1 70 147 + do + pamcut -top=$((i+1)) testimg.ppm > ${bottom_ppm} + pamcut -bottom=$i testimg.ppm > ${top_ppm} + pnmcat -tb ${top_ppm} ${bottom_ppm} | \ + pamcut -top=0 -height=149 | cksum + rm ${top_ppm} ${bottom_ppm} + done + +# Test 4. Should print 26789469 202953 five times +# Not roundtrip. Padding added to bottom. +echo Test 4. + +pnmpad -bottom=149 -black testimg.ppm | cksum +for i 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} + pnmcat -tb ${top_ppm} ${bottom_ppm} ${top_ppm} | \ + pamcut -top=$((149-i-1)) -height=$((149*2)) | cksum + rm ${top_ppm} ${bottom_ppm} + done + +# Test 5. Should print 2425386270 41 fourteen times +echo Test 5. + +cat testgrid.pbm | cksum +for i in `seq 0 12` + 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} + done + + +# Test 6. Should print 1887700557 73 fifteen times +# Not roundtrip. Padding added to right. +echo Test 6. + +pnmpad -right=14 -black testgrid.pbm | cksum +for i in `seq 0 13` + 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} + done + +# Test 7. Should print 2425386270 41 sixteen times +echo Test 7. + +cat testgrid.pbm | cksum +for i in `seq 0 14` + 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} + done + +# Test 8. Should print 3221289196 73 seventeen times +# Not roundtrip. Padding added to bottom. +echo Test 8. + +pnmpad -bottom=16 -black testgrid.pbm | cksum +for i in `seq 0 15` + 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} + done + diff --git a/test/g3-roundtrip.ok b/test/g3-roundtrip.ok index 853d06d2..603c9457 100644 --- a/test/g3-roundtrip.ok +++ b/test/g3-roundtrip.ok @@ -1,13 +1,13 @@ -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 +0 0 0 : 0 +0 0 0 : 0 +0 0 0 0 : 0 +0 0 0 : 0 +0 0 0 : 0 +0 0 0 0 : 0 +0 0 0 0 : 0 +0 0 0 : 0 +0 0 0 : 0 +0 0 0 : 0 1777627284 265 2985378006 3135 3651878552 3135 diff --git a/test/g3-roundtrip.test b/test/g3-roundtrip.test index 10174733..6e31c587 100755 --- a/test/g3-roundtrip.test +++ b/test/g3-roundtrip.test @@ -9,15 +9,15 @@ wideb_pbm=${tmpdir}/wideb.pbm pbmtog3 -nofixedwidth testgrid.pbm | \ g3topbm -width=14 | cmp -s - testgrid.pbm -echo $? +echo ${PIPESTATUS[@]} ":" $? pbmtog3 -nofixedwidth -reversebits testgrid.pbm | \ g3topbm -width=14 -reversebits | cmp -s - testgrid.pbm -echo $? +echo ${PIPESTATUS[@]} ":" $? pbmtog3 testgrid.pbm | \ g3topbm | pnmcrop -white -right -bottom | \ - cmp -s - testgrid.pbm ; echo $? + cmp -s - testgrid.pbm ; echo ${PIPESTATUS[@]} ":" $? # works with gawk and mawk # produce all possible 8-bit patterns @@ -28,31 +28,31 @@ LC_ALL=C awk 'BEGIN { print "P4"; # header printf("%c",i) }' > ${complete256_pbm} pbmtog3 -nofixedwidth ${complete256_pbm} | g3topbm -width=8 | \ - cmp -s - ${complete256_pbm} ; echo $? + cmp -s - ${complete256_pbm} ; echo ${PIPESTATUS[@]} ":" $? pbmtog3 -reverse -nofixedwidth ${complete256_pbm} | \ g3topbm -reversebits -width=8 | \ - cmp -s - ${complete256_pbm} ; echo $? + cmp -s - ${complete256_pbm} ; echo ${PIPESTATUS[@]} ":" $? pbmtog3 -align8 ${complete256_pbm} | \ g3topbm -width=1728 | pnmcrop -white -right | \ - cmp -s - ${complete256_pbm} ; echo $? + cmp -s - ${complete256_pbm} ; echo ${PIPESTATUS[@]} ":" $? pbmtog3 -align16 ${complete256_pbm} | \ g3topbm -width=1728 | pnmcrop -white -right | \ - cmp -s - ${complete256_pbm} ; echo $? + cmp -s - ${complete256_pbm} ; echo ${PIPESTATUS[@]} ":" $? pbmmake -w 5000 5 > ${widew_pbm} pbmtog3 -nofixedwidth ${widew_pbm} | g3topbm | \ - cmp -s - ${widew_pbm} ; echo $? + cmp -s - ${widew_pbm} ; echo ${PIPESTATUS[@]} ":" $? pbmtog3 -nofixedwidth ${widew_pbm} | \ g3topbm -width=5000 | \ - cmp -s - ${widew_pbm} ; echo $? + cmp -s - ${widew_pbm} ; echo ${PIPESTATUS[@]} ":" $? pbmmake -b 5000 5 > ${wideb_pbm} pbmtog3 -nofixedwidth ${wideb_pbm} | g3topbm | \ - cmp -s - ${wideb_pbm} ; echo $? + cmp -s - ${wideb_pbm} ; echo ${PIPESTATUS[@]} ":" $? cat ${complete256_pbm} | cksum cat ${wideb_pbm} | cksum diff --git a/test/gif-quant-roundtrip.ok b/test/gif-quant-roundtrip.ok index 573541ac..b813e8db 100644 --- a/test/gif-quant-roundtrip.ok +++ b/test/gif-quant-roundtrip.ok @@ -1 +1 @@ -0 +0 0 0 : 0 diff --git a/test/gif-quant-roundtrip.test b/test/gif-quant-roundtrip.test index 8b911740..910fa369 100755 --- a/test/gif-quant-roundtrip.test +++ b/test/gif-quant-roundtrip.test @@ -13,6 +13,6 @@ quant_ppm=${tmpdir}/quant.ppm pnmquant ${colors} testimg.ppm > ${quant_ppm} && pamtogif ${quant_ppm} | giftopnm | \ cmp -s - ${quant_ppm} > /dev/null -echo $? +echo ${PIPESTATUS[@]} ":" $? rm ${quant_ppm} diff --git a/test/gif-roundtrip.ok b/test/gif-roundtrip.ok index 1704ba03..607ebd5c 100644 --- a/test/gif-roundtrip.ok +++ b/test/gif-roundtrip.ok @@ -10,13 +10,13 @@ 2425386270 41 2425386270 41 P1 4 1 0101 -4030 0 , 4030 0 -4031 0 , 4031 0 -4097 0 , 4097 0 -238 0 , 238 0 -239 0 , 239 0 -240 0 , 240 0 -241 0 , 241 0 -255 0 , 255 0 -256 0 , 256 0 -257 0 , 257 0 +4030 : 0 0 0 0 : 0 , 4030 : 0 0 0 0 : 0 +4031 : 0 0 0 0 : 0 , 4031 : 0 0 0 0 : 0 +4097 : 0 0 0 0 : 0 , 4097 : 0 0 0 0 : 0 +238 : 0 0 0 0 : 0 , 238 : 0 0 0 0 : 0 +239 : 0 0 0 0 : 0 , 239 : 0 0 0 0 : 0 +240 : 0 0 0 0 : 0 , 240 : 0 0 0 0 : 0 +241 : 0 0 0 0 : 0 , 241 : 0 0 0 0 : 0 +255 : 0 0 0 0 : 0 , 255 : 0 0 0 0 : 0 +256 : 0 0 0 0 : 0 , 256 : 0 0 0 0 : 0 +257 : 0 0 0 0 : 0 , 257 : 0 0 0 0 : 0 diff --git a/test/gif-roundtrip.test b/test/gif-roundtrip.test index b49cc6d2..1e6c7760 100755 --- a/test/gif-roundtrip.test +++ b/test/gif-roundtrip.test @@ -124,10 +124,10 @@ for size in 4030 4031 4097 cmp - ${test_pgm} # pamdepth ${maxval} is necessary because # giftopnm output is maxval 255 - echo -n ${size} $? ", " + echo -n ${size} ":" ${PIPESTATUS[@]} ":" $? ", " pamtogif -nolzw ${test_pgm} | giftopnm | pamdepth ${maxval} | \ cmp - ${test_pgm} - echo ${size} $? + echo ${size} ":" ${PIPESTATUS[@]} ":" $? rm ${test_pgm} done @@ -153,10 +153,10 @@ for size in 238 239 240 241 255 256 257 pamcut -height=${size} ${test257_pgm} > ${test_pgm} && pamtogif -verbose ${test_pgm} | giftopnm | pamdepth ${maxval} | \ cmp - ${test_pgm} - echo -n ${size} $? ", " + echo -n ${size} ":" ${PIPESTATUS[@]} ":" $? ", " pamtogif -nolzw -verbose ${test_pgm} | giftopnm | pamdepth ${maxval} | \ cmp - ${test_pgm} - echo ${size} $? + echo ${size} ":" ${PIPESTATUS[@]} ":" $? rm ${test_pgm} done diff --git a/test/palm-roundtrip.ok b/test/palm-roundtrip.ok index 5bd3cb0a..b9ea3056 100644 --- a/test/palm-roundtrip.ok +++ b/test/palm-roundtrip.ok @@ -1,9 +1,11 @@ +Test 1 584219238 236 584219238 236 584219238 236 584219238 236 584219238 236 -0 -0 -0 -0 +Test 2 +0 0 0 : 0 +0 0 0 : 0 +0 0 0 : 0 +0 0 0 : 0 diff --git a/test/palm-roundtrip.test b/test/palm-roundtrip.test index 9c053ba9..b00454ca 100755 --- a/test/palm-roundtrip.test +++ b/test/palm-roundtrip.test @@ -8,6 +8,8 @@ test256color_ppm=${tmpdir}/test256color.ppm # Test 1. Should print 584219238 236 5 times +echo "Test 1" + pamdepth 15 testgrid.pbm | tee ${test4bit_pgm} | cksum for flags in "" \ @@ -21,7 +23,9 @@ rm ${test4bit_pgm} # Test 2. Should print 0 4 times -pnmquant 256 testimg.ppm > ${test256color_ppm} +echo "Test 2" + +pnmquant 256 testimg.ppm > ${test256color_ppm} || echo "pnmquant failed" for flags in "" \ "-scanline_compression" \ @@ -29,7 +33,7 @@ for flags in "" \ "-packbits_compression" do pnmtopalm -colormap $flags ${test256color_ppm} | palmtopnm | \ cmp -s - ${test256color_ppm} > /dev/null - echo $? + echo ${PIPESTATUS[@]} ":" $? done rm ${test256color_ppm} diff --git a/test/pamcut.ok b/test/pamcut.ok index 61ef99bc..b08bc531 100644 --- a/test/pamcut.ok +++ b/test/pamcut.ok @@ -1,4 +1,19 @@ +Test 1. 2958909756 124815 +Test 2. 1550940962 10933 +Test 3. 708474423 14 +708474423 14 +Test 4. +659346598 80124 +659346598 80124 +659346598 80124 +659346598 80124 +Test 5. +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +Test 6. 3412257956 129 diff --git a/test/pamcut.test b/test/pamcut.test index fd9185a3..9971b1a5 100755 --- a/test/pamcut.test +++ b/test/pamcut.test @@ -2,17 +2,46 @@ # This script tests: pamcut pbmmake # Also requires: - # Test 1. Should print 2958909756 124815 +echo Test 1. + pamcut -top 0 -left 0 -width 260 -height 160 \ -pad testimg.ppm | cksum # Test 2. Should print 1550940962 10933 +echo Test 2. + pamcut -top 200 -left 120 -width 40 -height 40 \ -pad testimg.ppm | cksum -# Test 3. Should print 708474423 14 +# Test 3. Should print 708474423 14 twice +echo Test 3. + 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. + +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 + + +# Test 5. Should print 2425386270 41 four times +echo Test 5. + +pamcut -croptop 0 -cropleft 0 -cropbottom 0 -cropright 0 testgrid.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 + + +# Test 6. Should print 3412257956 129 +echo Test 6. -# Test 4. Should print 3412257956 129 pbmmake -g 50 50 | pamcut 5 5 30 30 | cksum diff --git a/test/pammixmulti-identity.ok b/test/pammixmulti-identity.ok new file mode 100644 index 00000000..9e712f7f --- /dev/null +++ b/test/pammixmulti-identity.ok @@ -0,0 +1,22 @@ +Test 1. +1926073387 101484 +1926073387 101484 +1926073387 101484 +1926073387 101484 +1926073387 101484 +1926073387 101484 +Test 2. +1926073387 101484 +1926073387 101484 +1926073387 101484 +Test 3. +1926073387 101484 +1926073387 101484 +1926073387 101484 +Test 4. +127 +127 +127 +127 +127 +127 diff --git a/test/pammixmulti-identity.test b/test/pammixmulti-identity.test new file mode 100755 index 00000000..d205c359 --- /dev/null +++ b/test/pammixmulti-identity.test @@ -0,0 +1,77 @@ +#! /bin/bash +# This script tests: pammixmulti +# Also requires: pgmnoise pnminvert pamsumm + +tmpdir=${tmpdir:-/tmp} + +# Test 1. Should print 1926073387 101484 six times +echo Test 1. + +pammixmulti testimg.ppm | cksum +pammixmulti testimg.ppm testimg.ppm | cksum +pammixmulti testimg.ppm testimg.ppm testimg.ppm | cksum +pammixmulti -blend=average testimg.ppm testimg.ppm | cksum +pammixmulti -blend=average testimg.ppm testimg.ppm testimg.ppm | cksum +pammixmulti -blend=random -randomseed=1 \ + testimg.ppm testimg.ppm testimg.ppm | cksum + + +# Test 2. Should print 1926073387 101484 three times +echo Test 2. + +mask_pgm=${tmpdir}/mask.pgm +pgmnoise -maxval=2 -randomseed=1 227 149 > ${mask_pgm} + +for sd in 0.5 1.2 3.0 + do + pammixmulti -blend=mask -maskfile=${mask_pgm} -stdev=${sd} \ + testimg.ppm testimg.ppm testimg.ppm | cksum + done +rm ${mask_pgm} + +# Test 3. Should print +echo Test 3. + +noise_pgm=${tmpdir}/noise.pgm +pgmnoise --randomseed=1 227 149 > ${noise_pgm} + +pammixmulti -blend=mask -maskfile=${noise_pgm} \ + testimg.ppm testimg.ppm | cksum +pammixmulti -blend=mask -maskfile=${noise_pgm} \ + testimg.ppm testimg.ppm testimg.ppm | cksum +pammixmulti -blend=mask -maskfile=${noise_pgm} \ + testimg.ppm testimg.ppm testimg.ppm testimg.ppm | cksum +rm ${noise_pgm} + + +# Test 4. + +# Mix image with its own inverse. +# Output should be a monotone gray sheet. +# Should print 127 six times +echo Test 4. + +invert_ppm=${tmpdir}/invert.ppm +monotone_ppm=${tmpdir}/monotone.ppm + +pnminvert testimg.ppm > ${invert_ppm} + +pammixmulti -blend=average testimg.ppm ${invert_ppm} | tee ${monotone_ppm} | \ + pamsumm -brief -max && + pamsumm -brief -min ${monotone_ppm} +rm ${monotone_ppm} + +pammixmulti -blend=average \ + testimg.ppm ${invert_ppm} testimg.ppm ${invert_ppm} | \ + tee ${monotone_ppm} | \ + pamsumm -brief -max && + pamsumm -brief -min ${monotone_ppm} +rm ${monotone_ppm} + +pammixmulti -blend=average \ + testimg.ppm testimg.ppm ${invert_ppm} ${invert_ppm} | \ + tee ${monotone_ppm} | \ + pamsumm -brief -max && + pamsumm -brief -min ${monotone_ppm} + +rm ${monotone_ppm} ${invert_ppm} diff --git a/test/pbmtext-utf8.ok b/test/pbmtext-utf8.ok index 9e65dec4..588bf617 100644 --- a/test/pbmtext-utf8.ok +++ b/test/pbmtext-utf8.ok @@ -2,7 +2,7 @@ 2066913605 5110 2920616515 2301 2920616515 2301 -0 +0 0 0 0 : 0 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ -1 +0 1 : 1 diff --git a/test/pbmtext-utf8.test b/test/pbmtext-utf8.test index 010c02db..cf495b7c 100755 --- a/test/pbmtext-utf8.test +++ b/test/pbmtext-utf8.test @@ -66,7 +66,7 @@ awk 'BEGIN { for (i=32; i<=126;++i) printf("%c",i); print ""; \ LC_ALL=en_US.utf8 pbmtext -builtin bdf -wchar -text-dump | \ cmp --quiet - ${output} -echo $? +echo ${PIPESTATUS[@]} ":" $? rm ${output} @@ -92,4 +92,4 @@ echo "-----------------------------------------------------------" 1>&2 LC_ALL=C \ awk 'BEGIN { for (i=128; i<=129;++i) printf("%c",i); print ""}' | \ LC_ALL=en_US.utf8 pbmtext -builtin bdf -wchar -text-dump -echo $? +echo ${PIPESTATUS[@]} ":" $? diff --git a/test/pdb-roundtrip.ok b/test/pdb-roundtrip.ok index cb920669..b903da8d 100644 --- a/test/pdb-roundtrip.ok +++ b/test/pdb-roundtrip.ok @@ -3,16 +3,16 @@ pbm grid 2224198737 25671 2224198737 25671 pbm tiled -0 0 0 -0 0 0 -0 0 0 -0 0 0 +0 0 0 0 : 0 +0 0 0 0 : 0 +0 0 0 0 : 0 +0 0 0 0 : 0 pgm ellipse -0 0 0 -0 0 0 -0 0 0 -0 0 0 +0 0 0 0 0 : 0 +0 0 0 0 0 : 0 +0 0 0 0 0 : 0 +0 0 0 0 0 : 0 pgm ellipse -4depth -0 0 0 -0 0 0 -0 0 0 +0 0 0 0 0 : 0 +0 0 0 0 0 : 0 +0 0 0 0 0 : 0 diff --git a/test/pdb-roundtrip.test b/test/pdb-roundtrip.test index a6de93d2..6b4e152c 100755 --- a/test/pdb-roundtrip.test +++ b/test/pdb-roundtrip.test @@ -24,7 +24,7 @@ for flag in "" "-compressed" "-maybecompressed" "-uncompressed" do pamtopdbimg ${flag} ${tiled_pbm} | pdbimgtopam | pamtopnm | \ cmp -s - ${tiled_pbm} - echo ${PIPESTATUS[0]} ${PIPESTATUS[1]} $? + echo ${PIPESTATUS[@]} ":" $? done rm ${tiled_pbm} @@ -37,7 +37,7 @@ for flag in "" "-compressed" "-maybecompressed" "-uncompressed" do pamtopdbimg ${flag} ${ellipse_pgm} | pdbimgtopam | \ pamtopnm | pamdepth 3 | cmp -s - ${ellipse_pgm} - echo ${PIPESTATUS[0]} ${PIPESTATUS[1]} $? + echo ${PIPESTATUS[@]} ":" $? done rm ${ellipse_pgm} @@ -50,6 +50,6 @@ for flag in "-compressed" "-maybecompressed" "-uncompressed" do pamtopdbimg -4depth ${flag} ${ellipse_pgm} | pdbimgtopam | \ pamtopnm | pamdepth 15 | cmp -s - ${ellipse_pgm} - echo ${PIPESTATUS[0]} ${PIPESTATUS[1]} $? + echo ${PIPESTATUS[@]} ":" $? done rm ${ellipse_pgm} \ No newline at end of file diff --git a/test/pnmpaste-pbm.ok b/test/pnmpaste-pbm.ok new file mode 100644 index 00000000..d3b0a7e8 --- /dev/null +++ b/test/pnmpaste-pbm.ok @@ -0,0 +1,22 @@ +Test 1. +-replace +P1 18 1 001010101010101011 +-and +P1 18 1 001111101111101111 +-or +P1 18 1 000010000010000011 +-xor +P1 18 1 010010010010010011 +-nand +P1 18 1 010000010000010011 +-nor +P1 18 1 011101111101111111 +-nxor +P1 18 1 001101101101101111 +Test 2. +-and -nand +P1 18 1 110000000000000001 +-or -nor +P1 18 1 110000000000000001 +-xor -nxor +P1 18 1 110000000000000001 diff --git a/test/pnmpaste-pbm.test b/test/pnmpaste-pbm.test new file mode 100755 index 00000000..b75797af --- /dev/null +++ b/test/pnmpaste-pbm.test @@ -0,0 +1,47 @@ +#! /bin/bash +# This script tests: pnmpaste +# Also requires: pbmmake + +tmpdir=${tmpdir:-/tmp} +base_pbm=${tmpdir}/font.pbm +insert_pbm=${tmpdir}/insert.pbm + +cat > ${base_pbm} << EOF +P1 +18 1 +000111000111000111 +EOF + +pbmmake -g 15 1 > ${insert_pbm} + +# Test 1. +echo "Test 1." + +for operation in "-replace" "-and" "-or" "-xor" "-nand" "-nor" "-nxor" + do + echo ${operation} + pnmpaste ${operation} -plain ${insert_pbm} 1 0 ${base_pbm} | tr '\n' ' ' + echo + done + + +# Test 2. +# Perform an operation and its negative counterpart, combine the +# resulting images with "-xor". +# The untouched area of the base image should be 1; inserted area 0. + +echo "Test 2." + +positive_pbm=${tmpdir}/positive.pbm +negative_pbm=${tmpdir}/negative.pbm + +for operation in "and" "or" "xor" + do + echo "-"$operation " -n"$operation + pnmpaste "-"${operation} ${insert_pbm} 2 0 ${base_pbm} > ${positive_pbm} + pnmpaste "-n"${operation} ${insert_pbm} 2 0 ${base_pbm} > ${negative_pbm} + pnmpaste -xor -plain ${positive_pbm} 0 0 ${negative_pbm} | tr '\n ' ' ' + echo + done + +rm ${base_pbm} ${insert_pbm} ${positive_pbm} ${negative_pbm} diff --git a/test/pnmtile.ok b/test/pnmtile.ok index 559d0f65..4a29e0dc 100644 --- a/test/pnmtile.ok +++ b/test/pnmtile.ok @@ -1,2 +1,2 @@ 4228632379 259 -0 +0 0 : 0 diff --git a/test/pnmtile.test b/test/pnmtile.test index 409c0e50..e297da66 100755 --- a/test/pnmtile.test +++ b/test/pnmtile.test @@ -17,6 +17,6 @@ pnmtile 454 298 testimg.ppm > ${testimg4_ppm} && pnmcat -lr testimg.ppm testimg.ppm > ${testimg2_ppm} && pnmcat -tb ${testimg2_ppm} ${testimg2_ppm} | \ cmp -s - ${testimg4_ppm} -echo $? +echo ${PIPESTATUS[@]} ":" $? rm ${testimg2_ppm} ${testimg4_ppm} diff --git a/test/rgb3-roundtrip.ok b/test/rgb3-roundtrip.ok index 64da849d..367e5429 100644 --- a/test/rgb3-roundtrip.ok +++ b/test/rgb3-roundtrip.ok @@ -3,4 +3,4 @@ 2425386270 41 0 0 -0 +0 0 : 0 diff --git a/test/rgb3-roundtrip.test b/test/rgb3-roundtrip.test index cac52220..42fd822f 100755 --- a/test/rgb3-roundtrip.test +++ b/test/rgb3-roundtrip.test @@ -41,6 +41,6 @@ rgb3toppm ${testgrid_red} ${testgrid_grn} ${testgrid_blu} | \ cmp -s ${testgrid_red} ${testgrid_grn} ; echo $? cmp -s ${testgrid_grn} ${testgrid_blu} ; echo $? pgmtopgm < testgrid.pbm | cmp -s - ${testgrid_red} - echo $? + echo ${PIPESTATUS[@]} ":" $? rm ${testgrid_pbm} ${testgrid_red} ${testgrid_grn} ${testgrid_blu} diff --git a/test/targa-roundtrip.ok b/test/targa-roundtrip.ok index 9a428195..514f970f 100644 --- a/test/targa-roundtrip.ok +++ b/test/targa-roundtrip.ok @@ -1,3 +1,43 @@ +Test 1 2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +Test 2 +1571496937 33838 +1571496937 33838 1571496937 33838 +1571496937 33838 +1571496937 33838 +1571496937 33838 +1571496937 33838 +1571496937 33838 +1571496937 33838 +1571496937 33838 +Test 3 +1926073387 101484 +1926073387 101484 +1926073387 101484 1926073387 101484 +Test 4 +0 0 0 : 0 +0 0 0 : 0 +0 0 0 : 0 +0 0 0 : 0 +0 0 0 : 0 +0 0 0 : 0 +Test 5 +0 0 0 : 0 +0 0 0 : 0 +0 0 0 0 : 0 +0 0 0 0 : 0 +0 0 0 0 : 0 +0 0 0 0 : 0 +0 0 0 0 : 0 +0 0 0 0 : 0 diff --git a/test/targa-roundtrip.test b/test/targa-roundtrip.test index f646b8c1..79b01b61 100755 --- a/test/targa-roundtrip.test +++ b/test/targa-roundtrip.test @@ -1,18 +1,80 @@ #! /bin/bash # This script tests: pamtotga tgatoppm -# Also requires: ppmtopgm pgmtopbm pamchannel +# Also requires: ppmtopgm pgmtopbm pamchannel pnmquant pamdepth +tmpdir=${tmpdir:-/tmp} -#Test 1: Should print 2425386270 41, cksum of testgrid.pbm +#Test 1: Should print 2425386270 41, cksum of testgrid.pbm, ten times -pamtotga -mono testgrid.pbm | \ - tgatoppm | ppmtopgm | \ - pgmtopbm -threshold -val 0.5 | cksum +echo "Test 1" -#Test 2: Should produce 1571496937 33838, cksum of testimg.red -pamchannel -infile=testimg.ppm -tupletype="GRAYSCALE" 0 | \ - pamtotga -cmap | tgatoppm | ppmtopgm | cksum +for mode in "-mono" "-mono -norle" \ + "-cmap" "-cmap -norle" "-cmap16" "-cmap16 -norle" \ + "-rgb" "-rgb -norle" "" "-norle" + do + pamtotga ${mode} testgrid.pbm | \ + tgatoppm | ppmtopgm | \ + pgmtopbm -threshold -val 0.5 | cksum + done -#Test 3: Should print 1926073387 101484, cksum of testimg.ppm +#Test 2: Should produce 1571496937 33838, cksum of testimg.red, ten times -pamtotga -rgb testimg.ppm | tgatoppm | cksum +echo "Test 2" + +test_pam=${tmpdir}/testimg.pgm +pamchannel -infile=testimg.ppm -tupletype="GRAYSCALE" 0 > ${test_pam} + +for mode in "-mono" "-mono -norle" \ + "-cmap" "-cmap -norle" "-cmap16" "-cmap16 -norle" \ + "-rgb" "-rgb -norle" "" "-norle" + do + pamtotga ${mode} ${test_pam} | tgatoppm | ppmtopgm | cksum + done + +rm ${test_pam} + + +#Test 3: Should print 1926073387 101484, cksum of testimg.ppm, four times + +echo "Test 3" + +for mode in "-rgb" "-rgb -norle" "" "-norle" + do + pamtotga ${mode} testimg.ppm | tgatoppm | cksum + done + +#Test 4: Should print 0 six times + +echo "Test 4" + +test256_ppm=${tmpdir}/test256.ppm +pnmquant 256 testimg.ppm > ${test256_ppm} || echo "pnmquant failed" +# test image may have less than 256 colors + +for mode in "-rgb" "-rgb -norle" "-cmap" "-cmap -norle" "" "-norle" + do + pamtotga ${mode} ${test256_ppm} | tgatoppm | cmp -s - ${test256_ppm} + echo ${PIPESTATUS[@]} ":" $? +done + + +#Test 5: Should print 0 eight times + +echo "Test 5" + +test256_31_ppm=${tmpdir}/test256-31.ppm +pamdepth 31 ${test256_ppm} > ${test256_31_ppm} || echo "pamdepth failed" +rm ${test256_ppm} + +for mode in "-cmap16" "-cmap16 -norle" + do pamtotga ${mode} ${test256_31_ppm} | tgatoppm | cmp -s - ${test256_31_ppm} + echo ${PIPESTATUS[@]} ":" $? + done + +for mode in "-rgb" "-rgb -norle" "-cmap" "-cmap -norle" "" "-norle" + do pamtotga ${mode} ${test256_31_ppm} | tgatoppm | \ + pamdepth 31 | cmp -s - ${test256_31_ppm} + echo ${PIPESTATUS[@]} ":" $? + done + +rm ${test256_31_ppm} -- cgit 1.4.1