diff options
Diffstat (limited to 'test')
391 files changed, 11588 insertions, 3046 deletions
diff --git a/test/411toppm.test b/test/411toppm.test index 98170c67..7a9e533c 100755 --- a/test/411toppm.test +++ b/test/411toppm.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: 411toppm # Also requires: diff --git a/test/Execute-Tests b/test/Execute-Tests index 3530d978..c86121dc 100755 --- a/test/Execute-Tests +++ b/test/Execute-Tests @@ -50,7 +50,7 @@ esac # invoke, the list of tests to run ('Test-Order'), and *.ok files that # indicate the expected results of tests. -srcdir=$(dirname $0) +export srcdir=$(dirname $0) # Set tmpdir, which is used in some of the test scripts. By default # this is created by mktemp. The user can override and specify tmpdir, @@ -103,6 +103,10 @@ if [ ! -f ./testgrid.pbm ] then cp -v ${srcdir}/testgrid.pbm ./testgrid.pbm fi +if [ ! -f ./maze.pbm ] + then cp -v ${srcdir}/maze.pbm ./maze.pbm +fi + if [ ! -f ./testimg.ppm ] then cp -v ${srcdir}/testimg.ppm ./testimg.ppm fi @@ -178,13 +182,15 @@ elif [ $VALGRIND_TESTS = "on" ] mkdir $valdir vg_command_base="valgrind --trace-children=yes"; + # You may want to add --track-origins=yes to the above. for i in awk basename cat cksum cmp comm cp cut date dirname \ - egrep fgrep file grep gs head iconv mkdir mktemp perl rm \ - sed seq sh sort tee tr uniq wc \ + egrep fgrep file grep gs head iconv ls mkdir mktemp perl \ + printf rm sed seq sh sort tail tee tr uniq wc \ testrandom Available-Testprog # Tell valgrind not to probe execution of the above programs. + # You may add programs in Netpbm to the above to speed up tests. do vg_skip=$vg_skip"/*/"$i","; done; @@ -238,13 +244,15 @@ if [ $VALGRIND_TESTS = "on" ] fi # Execute a single test and test its result. -# But first check if the .ok file exists. (Some .ok files are -# dynamically created.) Then see if target programs and requirements -# are in place. If either of these conditions are not met, do -# not execute the test and report "Not Testable". +# But first check if the .ok file exists. +# (In past versions certain .ok files were dynamically created.) +# Then see if target programs and requirements are in place. If +# either of these conditions are not met, do not execute the test and +# report "Not Testable". if [ ! -s ${srcdir}/${tname%.test}.ok ] then + echo "${tname%.test}.ok does not exist" let result=4; else ${srcdir}/Available-Testprog \ @@ -296,7 +304,7 @@ fi # (Do not erase them if we are working from the source directory.) if [ ! $PWD -ef ${srcdir} ] - then rm ./testimg.ppm ./testgrid.pbm + then rm ./testimg.ppm ./testgrid.pbm ./maze.pbm fi diff --git a/test/Makefile b/test/Makefile index c640dfff..732113f3 100644 --- a/test/Makefile +++ b/test/Makefile @@ -8,27 +8,14 @@ include $(BUILDDIR)/config.mk MERGE_OBJECTS = -PROGS = testrandom - -OKSTOGENERATE = $(patsubst %.rand-ok, %.ok, $(wildcard *.rand-ok)) - -all: $(PROGS) $(OKSTOGENERATE) - -testrandom.o: testrandom.c - $(CC_FOR_BUILD) -c -o $@ $(CFLAGS_FOR_BUILD) $< - -testrandom: testrandom.o - $(LD_FOR_BUILD) -o $@ $(LDFLAGS_FOR_BUILD) $< - -RAND_VARIETY ?= $(shell ./testrandom -x) - -$(OKSTOGENERATE): %.ok: %.rand-ok testrandom - sed -n "/^$(RAND_VARIETY)|/s/^$(RAND_VARIETY)|//p" $< > $@ +PROGS = OMIT_TEST_RULE = 1 include $(SRCDIR)/common.mk +all: + distclean clean: cleanlocal .PHONY: cleanlocal cleanlocal: - rm -f $(PROGS) $(patsubst %.rand-ok,%.ok,$(wildcard *.rand-ok)) + diff --git a/test/Test-Order b/test/Test-Order index aaf46985..6c21c759 100644 --- a/test/Test-Order +++ b/test/Test-Order @@ -2,6 +2,7 @@ all-in-place.test legacy-names.test +random-generator.test # Generator tests @@ -15,6 +16,8 @@ pbmtext.test pbmtext-bdf.test pbmtext-iso88591.test pbmtext-utf8.test +pbmtextps-dump.test +pbmtextps.test pbmupc.test pgmramp.test pamgauss.test @@ -24,13 +27,19 @@ pamcrater.test ppmpat.test ppmforge-parameters.test +pamstereogram.test + # Generators with random components +pbmnoise1.test +pbmnoise2.test +pbmnoise-parameters.test pgmnoise.test pgmnoise-parameters.test ppmpat-random.test ppmforge.test ppmrough.test +ppmrough-parameters.test # Analyzer tests @@ -45,6 +54,7 @@ pbmminkowski.test pgmminkowski.test pnmcolormap.test +pnmcolormap2.test # Basic (internal) converter tests @@ -61,10 +71,14 @@ pnmtopnm-plain.test pamdepth.test pamditherbw.test +pamditherbw-random.test pamhue.test pbmclean.test pamcut.test +pamcat1.test +pamcat2.test +pamcat3.test pnmcat.test pamdice.test pamundice.test @@ -75,9 +89,21 @@ pnminvert.test pamchannel.test ppmchange.test pambackground.test -pnmpaste-pbm.test + +pnmpad-reportonly.test +pnmpad-flip.test +pnmpad-extend-enlarge.test +pnmpad-pnmmargin.test +pnmpad-format.test +pnmpad-color.test + +pamrestack.test +pamshuffle.test +ppmshift.test +ppmspread.test pbmpscale.test +pamrecolor.test pnmremap1.test pnmremap2.test pnmquant.test @@ -92,6 +118,8 @@ ppmdim.test pnmshear.test pgmbentley.test +pnmindex.test + pamfunc.test pamarith.test pamarith-compare-equal.test @@ -116,19 +144,45 @@ pnmcrop-blank.test ppmmix.test pammixmulti-identity.test +pamaddnoise-parameters.test + +pamstack.test + # Symmetry test symmetry.test +# Standard input tests + +stdin-pbm1.test +stdin-pbm2.test +stdin-pgm1.test +stdin-pgm2.test +stdin-ppm1.test +stdin-ppm2.test +stdin-ppm3.test +stdin-pnm1.test +stdin-pnm2.test +stdin-pam1.test +stdin-pam2.test +stdin-pam3.test + +pbm-misc-converters.test + # Format converter tests pamtopdbimg.test +pamtosvg.test pbmtog3.test +ppmtoapplevol.test +ppmtomitsu.test 411toppm.test eyuvtoppm.test rawtoppm.test -pbm-misc-converters.test +gif-transparent1.test + +pnmtojpeg-scans.test # Miscellaneous utility tests @@ -136,6 +190,7 @@ ppmdfont.test pamfix.test pamvalidate.test pamexec.test +pbmlife.test # Round-trip tests : editors @@ -143,8 +198,10 @@ pnm-plain-roundtrip.test pnm-pam-roundtrip.test pnminvert-roundtrip.test pamflip-roundtrip.test +pamflip-pbm-roundtrip.test pamdepth-roundtrip.test pad-crop-roundtrip.test +pbm-ppm-roundtrip.test cut-paste-roundtrip.test rgb3-roundtrip.test ppmchange-roundtrip.test @@ -157,6 +214,7 @@ pamhue-roundtrip.test # Round-trip tests: miscellaneous utilities +pamendian-roundtrip.test pamexec-roundtrip.test channel-stack-roundtrip.test @@ -198,6 +256,7 @@ pj-roundtrip.test ps-roundtrip.test ps-flate-roundtrip.test ps-alt-roundtrip.test +qoi-roundtrip.test sgi-roundtrip.test sbig-roundtrip.test st4-roundtrip.test @@ -214,6 +273,7 @@ xbm-roundtrip.test xpm-roundtrip.test xv-roundtrip.test xwd-roundtrip.test +ybm-roundtrip.test # Round-trip tests : lossy converters @@ -222,3 +282,4 @@ jpeg-roundtrip.test lps-roundtrip.test tiffcmyk-roundtrip.test yuv-roundtrip.test + diff --git a/test/all-in-place.ok b/test/all-in-place.ok index 4d840102..31854728 100644 --- a/test/all-in-place.ok +++ b/test/all-in-place.ok @@ -41,6 +41,7 @@ pamarith: ok pambackground: ok pambayer: ok pambrighten: ok +pamcat: ok pamchannel: ok pamcomp: ok pamcrater: ok @@ -61,6 +62,7 @@ pamfunc: ok pamgauss: ok pamgetcolor: ok pamgradient: ok +pamhomography: ok pamhue: ok pamlevels: ok pamlookup: ok @@ -74,12 +76,14 @@ pamperspective: ok pampick: ok pampop9: ok pamrecolor: ok +pamrestack: ok pamrubber: ok pamscale: ok pamseq: ok pamshadedrelief: ok pamsharpmap: ok pamsharpness: ok +pamshuffle: ok pamsistoaglyph: ok pamslice: ok pamsplit: ok @@ -106,6 +110,7 @@ pamtopdbimg: ok pamtopfm: ok pamtopng: ok pamtopnm: ok +pamtoqoi: ok pamtosrf: ok pamtosvg: ok pamtotga: ok @@ -124,6 +129,7 @@ pbmlife: ok pbmmake: ok pbmmask: ok pbmminkowski: ok +pbmnoise: ok pbmpage: ok pbmpscale: ok pbmreduce: ok @@ -197,7 +203,6 @@ pjtoppm: ok pktopbm: ok pngtopam: ok pnmalias: ok -pnmcat: ok pnmcolormap: ok pnmconvol: ok pnmcrop: ok @@ -298,6 +303,7 @@ ppmtv: ok ppmwheel: ok psidtopgm: ok pstopnm: ok +qoitopam: ok qrttoppm: ok rasttopnm: ok rawtopgm: ok diff --git a/test/all-in-place.test b/test/all-in-place.test index 78a9346a..386d2872 100755 --- a/test/all-in-place.test +++ b/test/all-in-place.test @@ -83,6 +83,7 @@ ordinary_testprogs="\ pambackground \ pambayer \ pambrighten \ + pamcat \ pamchannel \ pamcomp \ pamcrater \ @@ -103,6 +104,7 @@ ordinary_testprogs="\ pamgauss \ pamgetcolor \ pamgradient \ + pamhomography \ pamhue \ pamlevels \ pamlookup \ @@ -116,12 +118,14 @@ ordinary_testprogs="\ pampick \ pampop9 \ pamrecolor \ + pamrestack \ pamrubber \ pamscale \ pamseq \ pamshadedrelief \ pamsharpmap \ pamsharpness \ + pamshuffle \ pamsistoaglyph \ pamslice \ pamsplit \ @@ -148,6 +152,7 @@ ordinary_testprogs="\ pamtopfm \ pamtopng \ pamtopnm \ + pamtoqoi \ pamtosrf \ pamtosvg \ pamtotga \ @@ -166,6 +171,7 @@ ordinary_testprogs="\ pbmmake \ pbmmask \ pbmminkowski \ + pbmnoise \ pbmpage \ pbmpscale \ pbmreduce \ @@ -239,7 +245,6 @@ ordinary_testprogs="\ pktopbm \ pngtopam \ pnmalias \ - pnmcat \ pnmcolormap \ pnmconvol \ pnmcrop \ @@ -340,6 +345,7 @@ ordinary_testprogs="\ ppmwheel \ psidtopgm \ pstopnm \ + qoitopam \ qrttoppm \ rasttopnm \ rawtopgm \ @@ -432,4 +438,4 @@ testExitStatus anytopnm 0 $? manweb --help > /dev/null testExitStatus manweb 0 $? -# We do not test vidtoppm. \ No newline at end of file +# We do not test vidtoppm. diff --git a/test/atari-roundtrip.test b/test/atari-roundtrip.test index 413438a1..809cbdb2 100755 --- a/test/atari-roundtrip.test +++ b/test/atari-roundtrip.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: ppmtopi1 pi1toppm ppmtoneo neotoppm # Also requires: pgmramp pamscale pbmmake pamenlarge rgb3toppm pamdepth diff --git a/test/atk-roundtrip.ok b/test/atk-roundtrip.ok index 845be5fb..b9437e7d 100644 --- a/test/atk-roundtrip.ok +++ b/test/atk-roundtrip.ok @@ -1 +1,7 @@ -2425386270 41 +Test 1. Should print 281226646 481 +281226646 481 +Test 2. Should print 1824220442 125013 twice, then 2146497872 1000013 twice +241513515 125013 +241513515 125013 +2146497872 1000013 +2146497872 1000013 diff --git a/test/atk-roundtrip.test b/test/atk-roundtrip.test index 6db3df6d..97ac1be7 100755 --- a/test/atk-roundtrip.test +++ b/test/atk-roundtrip.test @@ -1,7 +1,23 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmtoatk atktopbm -# Also requires: +# Also requires: pbmmake +echo "Test 1. Should print 281226646 481" +# cksum of maze.pbm -# Should print 2425386270 41, cksum of testgrid.pbm -pbmtoatk testgrid.pbm | atktopbm | cksum +pbmtoatk maze.pbm | atktopbm | cksum + +tmpdir=${tmpdir:-/tmp} +maxwidth_pbm=${tmpdir}/maxwidth.pbm +maxheight_pbm=${tmpdir}/maxheight.pbm + +echo \ + "Test 2. Should print 1824220442 125013 twice, then 2146497872 1000013 twice" + +pbmmake -g 1000000 1 | tee ${maxwidth_pbm} | cksum +pbmtoatk ${maxwidth_pbm} | atktopbm | cksum + +pbmmake -b 1 1000000 | tee ${maxheight_pbm} | cksum +pbmtoatk ${maxheight_pbm} | atktopbm | cksum + +rm ${maxwidth_pbm} ${maxheight_pbm} diff --git a/test/avs-roundtrip.test b/test/avs-roundtrip.test index 042ce91e..255226db 100755 --- a/test/avs-roundtrip.test +++ b/test/avs-roundtrip.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamtoavs avstopam # Also requires: pamtopnm diff --git a/test/bmp-roundtrip.ok b/test/bmp-roundtrip.ok index 4f4f8367..217a54aa 100644 --- a/test/bmp-roundtrip.ok +++ b/test/bmp-roundtrip.ok @@ -1,14 +1,14 @@ -PBM -2425386270 41 -2425386270 41 -2425386270 41 -2425386270 41 -PPM +Test 1 PBM. Should print 281226646 481 four times +281226646 481 +281226646 481 +281226646 481 +281226646 481 +Test 2 PPM. Should print 1926073387 101484 four times 1926073387 101484 1926073387 101484 1926073387 101484 1926073387 101484 -PGM +Test 3 PGM. Should print 1571496937 33838 nine times 1571496937 33838 1571496937 33838 1571496937 33838 diff --git a/test/bmp-roundtrip.test b/test/bmp-roundtrip.test index c9ef363a..340eee66 100755 --- a/test/bmp-roundtrip.test +++ b/test/bmp-roundtrip.test @@ -1,30 +1,24 @@ -#! /bin/bash +#! /bin/sh # This script tests: bmptopnm ppmtobmp # Also requires: pamchannel pamtopnm pamseq tmpdir=${tmpdir:-/tmp} -# Test 1. Should print 2425386270 41 four times - -echo PBM +echo "Test 1 PBM. Should print 281226646 481 four times" for mode in "" "-bpp=1" "-windows" "-os2" do - ppmtobmp ${mode} testgrid.pbm | bmptopnm | cksum + ppmtobmp ${mode} maze.pbm | bmptopnm | cksum done -# Test 2. Should print 1926073387 101484 four times - -echo PPM +echo "Test 2 PPM. Should print 1926073387 101484 four times" 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 +echo "Test 3 PGM. Should print 1571496937 33838 nine times" red_pgm=${tmpdir}/red.pgm mapfile_pgm=${tmpdir}/mapfile.pgm diff --git a/test/channel-stack-roundtrip.test b/test/channel-stack-roundtrip.test index dae64605..14ac0d2e 100755 --- a/test/channel-stack-roundtrip.test +++ b/test/channel-stack-roundtrip.test @@ -1,6 +1,6 @@ -#! /bin/bash -# This script tests: pamchanel pamstack -# Also requires: pamtopam pamstack pamtopnm +#! /bin/sh +# This script tests: pamchannel pamstack +# Also requires: pamtopam pamtopnm tmpdir=${tmpdir:-/tmp} r_pam=${tmpdir}/testimg_r.pam diff --git a/test/cis-roundtrip.ok b/test/cis-roundtrip.ok index da90078b..8cac8da6 100644 --- a/test/cis-roundtrip.ok +++ b/test/cis-roundtrip.ok @@ -1,2 +1,8 @@ +Test 1. Should print 2631579683 1546 twice 2631579683 1546 -2425386270 41 +2631579683 1546 +Test 2. Should print 281226646 481, cksum of maze.pbm four times +281226646 481 +281226646 481 +281226646 481 +281226646 481 diff --git a/test/cis-roundtrip.test b/test/cis-roundtrip.test index 62fcc3b9..3316868c 100755 --- a/test/cis-roundtrip.test +++ b/test/cis-roundtrip.test @@ -1,14 +1,23 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmtocis cistopbm -# Also requires: pbmmake pamcut +# Also requires: pbmmake pamcut pamfile pnmcrop +tmpdir=${tmpdir:-/tmp} +test_pbm=${tmpdir}/test.pbm # Output images produced by pbmtocis are of fixed size, # either 128x96 or 256x192. # Smaller input images are padded, larger ones are cropped. -# Test 1. Should print 2631579683 1546 -pbmmake -g 128 96 | pbmtocis | cistopbm | cksum +echo "Test 1. Should print 2631579683 1546 twice" +pbmmake -g 128 96 | tee ${test_pbm} | cksum +pbmtocis ${test_pbm} | cistopbm | cksum -# Test 2. Should print 2425386270 41 -pbmtocis testgrid.pbm | cistopbm | pamcut 0 0 14 16 | cksum +rm ${test_pbm} + +echo "Test 2. Should print 281226646 481, cksum of maze.pbm four times" +size=$(pamfile -size maze.pbm | awk '{print "-width="$1,"-height="$2}') +pbmtocis maze.pbm | cistopbm | pamcut -left=0 -top=0 ${size} | cksum +pbmtocis -i maze.pbm | cistopbm -i | pamcut -left=0 -top=0 ${size} | cksum +pbmtocis maze.pbm | cistopbm | pnmcrop -black -right -bottom | cksum +pbmtocis -w maze.pbm | cistopbm | pnmcrop -white -right -bottom | cksum diff --git a/test/cmuw-roundtrip.ok b/test/cmuw-roundtrip.ok index 845be5fb..4ec1a381 100644 --- a/test/cmuw-roundtrip.ok +++ b/test/cmuw-roundtrip.ok @@ -1 +1,2 @@ -2425386270 41 +Should print 281226646 481, cksum of maze.pbm +281226646 481 diff --git a/test/cmuw-roundtrip.test b/test/cmuw-roundtrip.test index e52adb70..8664a1e6 100755 --- a/test/cmuw-roundtrip.test +++ b/test/cmuw-roundtrip.test @@ -1,7 +1,6 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmtocmuwm cmuwmtopbm # Also requires: - -# Should print 2425386270 41, cksum of testgrid.pbm -pbmtocmuwm testgrid.pbm | cmuwmtopbm | cksum +echo "Should print 281226646 481, cksum of maze.pbm" +pbmtocmuwm maze.pbm | cmuwmtopbm | cksum diff --git a/test/cut-cat-roundtrip.ok b/test/cut-cat-roundtrip.ok index bc9b8cb4..edf1de67 100644 --- a/test/cut-cat-roundtrip.ok +++ b/test/cut-cat-roundtrip.ok @@ -1,92 +1,54 @@ -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 +Test 1. Should print 1926073387 101484 six times +1926073387 101484 +1926073387 101484 +1926073387 101484 +1926073387 101484 +1926073387 101484 +1926073387 101484 +Test 2. Should print 3891261972 202953 1926073387 101484 six times +3891261972 202953 1926073387 101484 +3891261972 202953 1926073387 101484 +3891261972 202953 1926073387 101484 +3891261972 202953 1926073387 101484 +3891261972 202953 1926073387 101484 +3891261972 202953 1926073387 101484 +Test 3. Should print 1926073387 101484 five times +1926073387 101484 +1926073387 101484 +1926073387 101484 +1926073387 101484 +1926073387 101484 +Test 4. Should print 26789469 202953 1926073387 101484 five times +26789469 202953 1926073387 101484 +26789469 202953 1926073387 101484 +26789469 202953 1926073387 101484 +26789469 202953 1926073387 101484 +26789469 202953 1926073387 101484 +Test 5. Should print 281226646 481 six times +281226646 481 +281226646 481 +281226646 481 +281226646 481 +281226646 481 +281226646 481 +Test 6. Should print 1748767123 895 281226646 481 six times +1748767123 895 281226646 481 +1748767123 895 281226646 481 +1748767123 895 281226646 481 +1748767123 895 281226646 481 +1748767123 895 281226646 481 +1748767123 895 281226646 481 +Test 7. Should print 281226646 481 seven times +281226646 481 +281226646 481 +281226646 481 +281226646 481 +281226646 481 +281226646 481 +281226646 481 +Test 8. Should print 1346655680 954 281226646 481 five times +1346655680 954 281226646 481 +1346655680 954 281226646 481 +1346655680 954 281226646 481 +1346655680 954 281226646 481 +1346655680 954 281226646 481 diff --git a/test/cut-cat-roundtrip.test b/test/cut-cat-roundtrip.test index 95ee5279..274cb865 100755 --- a/test/cut-cat-roundtrip.test +++ b/test/cut-cat-roundtrip.test @@ -1,128 +1,147 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamcut -# Also requires: pnmcat pnmpad +# Also requires: pamfile pamcat 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=`cksum < testimg.ppm` +echo ${testimg_ppm_sum} -# Test 1. Should print 1926073387 101484 six times -echo Test 1. +imgsize=$(pamfile -size testimg.ppm) +width=$(echo ${imgsize} | cut -d " " -f 1) +height=$(echo ${imgsize} | cut -d " " -f 2) -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 + pamcat -lr ${left_ppm} ${right_ppm} | \ + pamcut -left=0 -width=${width} | 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=${width} -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} - pnmcat -lr ${left_ppm} ${right_ppm} ${left_ppm} | \ - pamcut -left=$((227-i-1)) -width=$((227*2)) | cksum - rm ${left_ppm} ${right_ppm} + pamcut -left=$((${border}+1)) -width=${width} -pad testimg.ppm > ${right_ppm} + pamcut -right=${border} -width=${width} -pad testimg.ppm > ${left_ppm} + pamcat -lr ${left_ppm} ${right_ppm} ${left_ppm} | \ + pamcut -left=$((${width}-${border}-1)) -width=$((${width}*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} - pnmcat -tb ${top_ppm} ${bottom_ppm} | \ - pamcut -top=0 -height=149 | cksum + pamcut -top=$((${border}+1)) testimg.ppm > ${bottom_ppm} + pamcut -bottom=${border} testimg.ppm > ${top_ppm} + pamcat -tb ${top_ppm} ${bottom_ppm} | \ + pamcut -top=0 -height=${height} | 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=${height} -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} - pnmcat -tb ${top_ppm} ${bottom_ppm} ${top_ppm} | \ - pamcut -top=$((149-i-1)) -height=$((149*2)) | cksum - rm ${top_ppm} ${bottom_ppm} + pamcut -top=$((${border}+1)) -height=${height} -pad testimg.ppm \ + > ${bottom_ppm} + pamcut -bottom=${border} -height=${height} -pad testimg.ppm > ${top_ppm} + pamcat -tb ${top_ppm} ${bottom_ppm} ${top_ppm} | \ + pamcut -top=$((${height}-${border}-1)) -height=$((${height}*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=`cksum < maze.pbm` +echo ${maze_pbm_sum} + +imgsize=$(pamfile -size maze.pbm) +width=$(echo ${imgsize} | cut -d " " -f 1) +height=$(echo ${imgsize} | cut -d " " -f 2) -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} + pamcat -lr ${left_ppm} ${right_ppm} | \ + pamcut -left=0 -width=${width} | 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=${width} -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=${width} -pad maze.pbm > ${right_ppm} + pamcut -right=${border} -width=${width} -pad maze.pbm > ${left_ppm} + pamcat -lr ${left_ppm} ${right_ppm} ${left_ppm} | \ + pamcut -left=$((${width}-${border}-1)) -width=$((${width}*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} + pamcat -tb ${top_ppm} ${bottom_ppm} | \ + pamcut -top=0 -height=${height} | 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=${height} -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=${height} -pad maze.pbm > ${bottom_ppm} + pamcut -bottom=${border} -height=${height} -pad maze.pbm > ${top_ppm} + pamcat -tb ${top_ppm} ${bottom_ppm} ${top_ppm} | \ + pamcut -top=$((${height}-${border}-1)) -height=$((${height}*2)) | \ + tee ${padded_ppm} | cksum | tr '\n' ' 'cksum + pnmcrop -black -bottom ${padded_ppm} | cksum + rm ${top_ppm} ${bottom_ppm} ${padded_ppm} done - diff --git a/test/cut-paste-roundtrip.test b/test/cut-paste-roundtrip.test index 1bb3a7c2..bec8baf5 100755 --- a/test/cut-paste-roundtrip.test +++ b/test/cut-paste-roundtrip.test @@ -1,7 +1,8 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamcut pnmpaste # Also requires: pbmmake pnmpad +tmpdir=${tmpdir:-/tmp} base_ppm=${tmpdir}/base.ppm # Test 1. Should produce 2999529086 101484 diff --git a/test/enlarge-reduce-roundtrip.test b/test/enlarge-reduce-roundtrip.test index 54b52c60..5d223cf1 100755 --- a/test/enlarge-reduce-roundtrip.test +++ b/test/enlarge-reduce-roundtrip.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamenlarge pbmpscale pbmreduce # Also requires: pbmtext diff --git a/test/eyuvtoppm.test b/test/eyuvtoppm.test index b28b4539..6bbc2e7e 100755 --- a/test/eyuvtoppm.test +++ b/test/eyuvtoppm.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: eyuvtoppm # Also requires: diff --git a/test/facesaver-roundtrip.test b/test/facesaver-roundtrip.test index f4b8f069..75fcf662 100755 --- a/test/facesaver-roundtrip.test +++ b/test/facesaver-roundtrip.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pgmtofs fstopgm # Also requires: pamchannel pamtopnm diff --git a/test/fiasco-roundtrip.test b/test/fiasco-roundtrip.test index 8325a37d..8d5fdaa6 100755 --- a/test/fiasco-roundtrip.test +++ b/test/fiasco-roundtrip.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pnmtofiasco fiascotopnm # Also requires: pnmpad pnmpsnr diff --git a/test/fits-roundtrip.test b/test/fits-roundtrip.test index e793df9a..030a519e 100755 --- a/test/fits-roundtrip.test +++ b/test/fits-roundtrip.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamtofits fitstopnm # Also requires: diff --git a/test/g3-roundtrip.ok b/test/g3-roundtrip.ok index 603c9457..7140cc8b 100644 --- a/test/g3-roundtrip.ok +++ b/test/g3-roundtrip.ok @@ -1,6 +1,9 @@ +Test 1. Should print 0 0 0 : 0 or 0 0 0 0 : 0 total three times 0 0 0 : 0 0 0 0 : 0 0 0 0 0 : 0 +Test 2. Should print 0 0 0 : 0 or 0 0 0 0 : 0 total seven times +then 1777627284 265, 2985378006 3135, 3651878552 3135 0 0 0 : 0 0 0 0 : 0 0 0 0 0 : 0 @@ -11,3 +14,9 @@ 1777627284 265 2985378006 3135 3651878552 3135 +Test 3. Should print 0 0 0 : 0 twice +then 356688157 17399694 twice +0 0 0 : 0 +0 0 0 : 0 +356688157 17399694 +356688157 17399694 diff --git a/test/g3-roundtrip.test b/test/g3-roundtrip.test index d18e4466..2736c09a 100755 --- a/test/g3-roundtrip.test +++ b/test/g3-roundtrip.test @@ -1,23 +1,33 @@ #! /bin/bash # This script tests: g3topbm pbmtog3 -# Also requires: pnmcrop pbmmake +# Also requires: pamfile pnmcrop pbmmake pbmpage pnmpad pamenlarge tmpdir=${tmpdir:-/tmp} complete256_pbm=${tmpdir}/complete256.pbm widew_pbm=${tmpdir}/widew.pbm wideb_pbm=${tmpdir}/wideb.pbm +page_pbm=${tmpdir}/page.pbm +pagemax_pbm=${tmpdir}/pagemax.pbm -pbmtog3 -nofixedwidth testgrid.pbm | \ -g3topbm -width=14 | cmp -s - testgrid.pbm +echo "Test 1. Should print 0 0 0 : 0 or 0 0 0 0 : 0 total three times" + +width=$(pamfile -size maze.pbm | cut -d " " -f 1) + +pbmtog3 -nofixedwidth maze.pbm | \ +g3topbm -width=${width} | cmp -s - maze.pbm echo ${PIPESTATUS[@]} ":" $? -pbmtog3 -nofixedwidth -reversebits testgrid.pbm | \ -g3topbm -width=14 -reversebits | cmp -s - testgrid.pbm +pbmtog3 -nofixedwidth -reversebits maze.pbm | \ +g3topbm -width=${width} -reversebits | cmp -s - maze.pbm echo ${PIPESTATUS[@]} ":" $? -pbmtog3 testgrid.pbm | \ +pbmtog3 maze.pbm | \ g3topbm | pnmcrop -white -right -bottom | \ - cmp -s - testgrid.pbm ; echo ${PIPESTATUS[@]} ":" $? + cmp -s - maze.pbm ; echo ${PIPESTATUS[@]} ":" $? + + +echo "Test 2. Should print 0 0 0 : 0 or 0 0 0 0 : 0 total seven times" +echo "then 1777627284 265, 2985378006 3135, 3651878552 3135" # works with gawk and mawk # produce all possible 8-bit patterns @@ -27,7 +37,7 @@ LC_ALL=C awk 'BEGIN { print "P4"; # header for (i=0;i<256;++i) # raster printf("%c",i) }' > ${complete256_pbm} -pbmtog3 -nofixedwidth ${complete256_pbm} | g3topbm -width=8 | \ +pbmtog3 -nofixedwidth ${complete256_pbm} | g3topbm -width=8 | \ cmp -s - ${complete256_pbm} ; echo ${PIPESTATUS[@]} ":" $? pbmtog3 -reverse -nofixedwidth ${complete256_pbm} | \ @@ -59,3 +69,20 @@ cat ${wideb_pbm} | cksum cat ${widew_pbm} | cksum rm ${complete256_pbm} ${wideb_pbm} ${widew_pbm} + + +echo "Test 3. Should print 0 0 0 : 0 twice" +echo "then 356688157 17399694 twice" + +pbmpage 3 -a4 | pamenlarge 2 > ${page_pbm} +pbmtog3 -nofixedwidth ${page_pbm} | g3topbm | \ + cmp -s - ${page_pbm} ; echo ${PIPESTATUS[@]} ":" $? + +pnmpad -width=1000 -height=1400 ${page_pbm} > ${pagemax_pbm} +pbmtog3 -nofixedwidth ${pagemax_pbm} | g3topbm | \ + cmp -s - ${pagemax_pbm} ; echo ${PIPESTATUS[@]} ":" $? + +cat ${page_pbm} | cksum +cat ${pagemax_pbm} | cksum + +rm ${page_pbm} ${pagemax_pbm} \ No newline at end of file diff --git a/test/gem-roundtrip.ok b/test/gem-roundtrip.ok index 845be5fb..5168378d 100644 --- a/test/gem-roundtrip.ok +++ b/test/gem-roundtrip.ok @@ -1 +1 @@ -2425386270 41 +281226646 481 diff --git a/test/gem-roundtrip.test b/test/gem-roundtrip.test index 0fce59db..d97a5cb9 100755 --- a/test/gem-roundtrip.test +++ b/test/gem-roundtrip.test @@ -1,7 +1,7 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmtogem gemtopnm # Also requires: -# Should print 2425386270 41, cksum of testgrid.pbm -pbmtogem testgrid.pbm | gemtopnm | cksum +# Should print 281226646 481, cksum of maze.pbm +pbmtogem maze.pbm | gemtopnm | cksum diff --git a/test/gif-roundtrip.ok b/test/gif-roundtrip.ok index 607ebd5c..27d1bb47 100644 --- a/test/gif-roundtrip.ok +++ b/test/gif-roundtrip.ok @@ -1,18 +1,23 @@ +Test 1. Should print 1926073387 101484 1926073387 101484 +Test 2. Should produce 1571496937 33838 six times 1571496937 33838 1571496937 33838 1571496937 33838 1571496937 33838 1571496937 33838 -2425386270 41 -2425386270 41 -2425386270 41 -2425386270 41 -2425386270 41 +1571496937 33838 +Test 3. Should produce 281226646 481 six times +281226646 481 +281226646 481 +281226646 481 +281226646 481 +281226646 481 +281226646 481 +Test 4. Should produce P1 4 1 0101 P1 4 1 0101 -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 +Test 5. Should produce: N : 0 0 0 0 : 0 , N : 0 0 0 0 : 0 +(N=238, 239, 240, 241, 255, 256, 257, 4030, 4031, 4097) 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 @@ -20,3 +25,6 @@ P1 4 1 0101 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 +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 diff --git a/test/gif-roundtrip.test b/test/gif-roundtrip.test index 1e6c7760..13ff595e 100755 --- a/test/gif-roundtrip.test +++ b/test/gif-roundtrip.test @@ -7,7 +7,8 @@ tmpdir=${tmpdir:-/tmp} # Test 1. Break up input image into three monochrome planes, # maxval 255. Transform each plane to gif and back to pgm. # Reassemble the planes. Result should be identical to input. -# Should print 1926073387 101484 + +echo "Test 1. Should print 1926073387 101484" test_ppm=${tmpdir}/testimg.ppm @@ -29,13 +30,11 @@ pamtogif ${test_blu} | giftopnm | \ rm ${test_ppm} ${test_grn} ${test_blu} ${out_red} ${out_grn} - -# Test 2. Should produce 1571496937 33838 -# which is the result of cksum testimg.red -# five times +echo "Test 2. Should produce 1571496937 33838 six times" test_gif=${tmpdir}/testimg.gif +cat ${test_red} | cksum pamtogif ${test_red} | giftopnm | cksum pamtogif -interlace ${test_red} | giftopnm | cksum pamtogif -noclear ${test_red} | giftopnm | cksum @@ -46,22 +45,23 @@ echo "junk" >> ${test_gif} && \ rm ${test_gif} ${test_red} +echo "Test 3. Should produce 281226646 481 six times" +# maze.pbm is too small for -noclear to take effect -# Test 3. Should produce 2425386270 41 five times. -# testgrid.pbm is too small for -noclear to take effect - -pamtogif testgrid.pbm | giftopnm | cksum -pamtogif -nolzw testgrid.pbm | giftopnm | cksum -pamtogif -transparent=black testgrid.pbm | giftopnm | cksum -pamtogif -alpha=testgrid.pbm testgrid.pbm | giftopnm | cksum -pamtogif -transparent=white testgrid.pbm | giftopnm -alpha=- | \ +cat maze.pbm | cksum +pamtogif maze.pbm | giftopnm | cksum +pamtogif -nolzw maze.pbm | giftopnm | cksum +pamtogif -transparent=black maze.pbm | giftopnm | cksum +pamtogif -alpha=maze.pbm maze.pbm | giftopnm | cksum +pamtogif -transparent=white maze.pbm | giftopnm -alpha=- | \ pnminvert | cksum # Test 4. # In this gif file the code length changes after the last image data. # Image data: 3 bits, end code 4 bits. -# Should produce P1 4 1 0 1 0 1 + +echo "Test 4. Should produce P1 4 1 0101" pbmmake -g 4 1 | \ pamtogif -verbose | giftopnm -plain | \ @@ -71,25 +71,18 @@ echo "" # Test 5. # Test whether saturated code tables are handled correctly. -# Test input images which most use up the string code table or +# Test input images which use up the string code table or # come close to doing so. -# Should produce: -# 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 -test4097_pgm=${tmpdir}/testimg4097.pgm +echo "Test 5. Should produce: N : 0 0 0 0 : 0 , N : 0 0 0 0 : 0" +echo "(N=238, 239, 240, 241, 255, 256, 257, 4030, 4031, 4097)" + test_pgm=${tmpdir}/testimg.pgm -# The following awk script produces a PGM file with no repeated sequences. +# The following awk scripts produce a PGM file with no repeated +# sequences. Obviously this cannot be compressed at all; the codes +# are consumed without ever being used. # Here is a smaller example with the same property: # P2 # 8 8 @@ -103,7 +96,9 @@ test_pgm=${tmpdir}/testimg.pgm # 3 6 3 7 4 5 4 6 # 4 7 5 6 5 7 6 7 -maxval=63 +test257_pgm=${tmpdir}/testimg257.pgm + +maxval=15 awk -v maxval=${maxval} 'BEGIN \ { print "P2" print "1 "(maxval+1) * (maxval+1) +1 @@ -115,26 +110,25 @@ awk -v maxval=${maxval} 'BEGIN \ for (j=i+1; j<=maxval; ++j) {print i; print j } print 0 -}' > ${test4097_pgm} +}' > ${test257_pgm} -for size in 4030 4031 4097 +for size in 238 239 240 241 255 256 257 do - pamcut -height ${size} ${test4097_pgm} > ${test_pgm} && + pamcut -height=${size} ${test257_pgm} > ${test_pgm} && pamtogif -verbose ${test_pgm} | giftopnm | pamdepth ${maxval} | \ cmp - ${test_pgm} - # pamdepth ${maxval} is necessary because - # giftopnm output is maxval 255 - echo -n ${size} ":" ${PIPESTATUS[@]} ":" $? ", " - pamtogif -nolzw ${test_pgm} | giftopnm | pamdepth ${maxval} | \ + printf "${size} : ${PIPESTATUS[*]} : $? , " + pamtogif -nolzw -verbose ${test_pgm} | giftopnm | pamdepth ${maxval} | \ cmp - ${test_pgm} - echo ${size} ":" ${PIPESTATUS[@]} ":" $? + printf "${size} : ${PIPESTATUS[*]} : $?\n" rm ${test_pgm} done -rm ${test4097_pgm} -test257_pgm=${tmpdir}/testimg257.pgm +rm ${test257_pgm} -maxval=15 +test4097_pgm=${tmpdir}/testimg4097.pgm + +maxval=63 awk -v maxval=${maxval} 'BEGIN \ { print "P2" print "1 "(maxval+1) * (maxval+1) +1 @@ -146,18 +140,20 @@ awk -v maxval=${maxval} 'BEGIN \ for (j=i+1; j<=maxval; ++j) {print i; print j } print 0 -}' > ${test257_pgm} +}' > ${test4097_pgm} -for size in 238 239 240 241 255 256 257 +for size in 4030 4031 4097 do - pamcut -height=${size} ${test257_pgm} > ${test_pgm} && + pamcut -height ${size} ${test4097_pgm} > ${test_pgm} && pamtogif -verbose ${test_pgm} | giftopnm | pamdepth ${maxval} | \ cmp - ${test_pgm} - echo -n ${size} ":" ${PIPESTATUS[@]} ":" $? ", " - pamtogif -nolzw -verbose ${test_pgm} | giftopnm | pamdepth ${maxval} | \ + # pamdepth ${maxval} is necessary because + # giftopnm output is maxval 255 + printf "${size} : ${PIPESTATUS[*]} : $? , " + pamtogif -nolzw ${test_pgm} | giftopnm | pamdepth ${maxval} | \ cmp - ${test_pgm} - echo ${size} ":" ${PIPESTATUS[@]} ":" $? + printf "${size} : ${PIPESTATUS[*]} : $?\n" rm ${test_pgm} done -rm ${test257_pgm} +rm ${test4097_pgm} diff --git a/test/gif-transparent1.ok b/test/gif-transparent1.ok new file mode 100644 index 00000000..a531329a --- /dev/null +++ b/test/gif-transparent1.ok @@ -0,0 +1,99 @@ +Test 0. +Should print 0 or 1 0. +Image 1: 1 0 +Image 2: 1 0 +Image 3: 0 +Image 4: 0 +Image 5: 0 +Test 1. +Should print 0 unless otherwise stated. +Image 1 +a1: 1 (should print 1) +a2: 0 +a3: 0 +b1: 1 (should print 1) +b2: 0 +b3: 0 +c1: 0 +c2: 0 +c3: 0 +c4: 0 +d1: 0 +d2: 0 +Image 2 +a1: 1 (should print 1) +a2: 0 +a3: 0 +b1: 1 (should print 1) +b2: 0 +b3: 0 +c1: 0 +c2: 0 +c3: 0 +c4: 0 +d1: 0 +d2: 0 +Image 3 +a1: 1 (should print 1) +a2: 0 +a3: 0 +b1: 1 (should print 1) +b2: 0 +b3: 0 +c1: 0 +c2: 0 +c3: 0 +c4: 0 +d1: 0 +d2: 0 +Test 2. +Should print 0 unless otherwise stated. +Image 1 +cl1: 0 +cl2: 0 +op1: 1 (should print 1) +op2: 0 +Image 2 +cl1: 0 +cl2: 0 +op1: 1 (should print 1) +op2: 0 +Image 3 +cl1: 0 +cl2: 0 +op1: 1 (should print 1) +op2: 0 +Test 3. +Should print 0 in all cases. +Image 1 +a2: 0 +a3: 0 +b2: 0 +b3: 0 +c4: 0 +Image 2 +a2: 0 +a3: 0 +b2: 0 +b3: 0 +c4: 0 +Image 3 +a2: 0 +a3: 0 +b2: 0 +b3: 0 +c4: 0 +Test 4. +Should print 0 in all cases. +color=rgb:0f/0f/0f +0 +0 +0 +color=rgb:ff/00/00 +0 +0 +0 +color=rgb:00/ff/00 +0 +0 +0 diff --git a/test/gif-transparent1.test b/test/gif-transparent1.test new file mode 100755 index 00000000..74496787 --- /dev/null +++ b/test/gif-transparent1.test @@ -0,0 +1,224 @@ +#! /bin/sh +# This script tests: giftopnm pamtogif ppmtogif +# Also requires: pamarith pamcomp pamdepth pamenlarge pamstack pbmmake +# Also requires: pnminvert ppmchange ppmpat ppmtopgm ppmtoppm + +tmpdir=${tmpdir:-/tmp} + +madras_ppm=${tmpdir}/madras.ppm +gingham_ppm=${tmpdir}/gingham.ppm +argyle_ppm=${tmpdir}/argyle.ppm + +alpha0_pbm=${tmpdir}/alpha0.pbm +alpha1_pbm=${tmpdir}/alpha1.pbm +clear_pbm=${tmpdir}/clear.pbm +opaque_pbm=${tmpdir}/opaque.pbm +alpha0_pam=${tmpdir}/alpha0.pam +alpha1_pam=${tmpdir}/alpha1.pam +clear_pam=${tmpdir}/clear.pam +opaque_pam=${tmpdir}/opaque.pam + +image0_alpha_pam=${tmpdir}/image0.alpha.pam +image1_alpha_pam=${tmpdir}/image1.alpha.pam + +out_pnm=${tmpdir}/out.pnm +out0_ppm=${tmpdir}/out0.ppm +out1_ppm=${tmpdir}/out1.ppm +out2_ppm=${tmpdir}/out2.ppm +a0_out_pbm=${tmpdir}/a0.out.pbm +a1_out_pbm=${tmpdir}/a1.out.pbm + +# Make test images & alpha masks + +ppmpat -argyle2 \ + -color=rgb:00/00/00,rgb:ff/ff/ff,rgb:ff/ff/ff 40 24 > ${argyle_ppm} +ppmpat -gingham3 \ + -color=rgb:3f/3f/3f,rgb:7f/7f/7f,rgb:ef/ef/ef 40 24 > ${gingham_ppm} +ppmpat -madras \ + -color=rgb:0f/0f/0f,rgb:ff/00/00,rgb:00/ff/00 40 24 > ${madras_ppm} + +pbmmake -g 5 3 | pamenlarge 8 | tee ${alpha0_pbm} | \ + pamdepth 255 > ${alpha0_pam} +pnminvert ${alpha0_pbm} | tee ${alpha1_pbm} | \ + pamdepth 255 > ${alpha1_pam} + +pbmmake -w 40 24 | tee ${clear_pbm} | pamdepth 255 > ${clear_pam} +pbmmake -b 40 24 | tee ${opaque_pbm} | pamdepth 255 > ${opaque_pam} + + +echo "Test 0." +echo "Should print 0 or 1 0." +i=1 +for test_pnm in ${argyle_ppm} ${gingham_ppm} ${madras_ppm} \ + ${alpha0_pbm} ${alpha1_pbm} + do + printf "Image $i: "; i=$((i+1)); + pamtogif ${test_pnm} | giftopnm | tee ${out_pnm} | \ + cmp -s - ${test_pnm}; result=$? + + if [ $result -eq 0 ]; + then echo $?; + else + ppmtoppm < ${out_pnm} | cmp -s - ${test_pnm}; echo $result $? + fi + # madras, alpha, alpha1 : should match + # argyle: giftopnm produces PBM, gingham: giftopnm produces PGM + rm ${out_pnm} + done + + +echo "Test 1." # Color + alpha channel +echo "Should print 0 unless otherwise stated." + +i=1 +for test_pnm in ${argyle_ppm} ${gingham_ppm} ${madras_ppm} + do + echo "Image $i"; i=$((i+1)); + + pamstack -tupletype="RGB_ALPHA" ${test_pnm} ${alpha0_pam} > \ + ${image0_alpha_pam} + pamstack -tupletype="RGB_ALPHA" ${test_pnm} ${alpha1_pam} > \ + ${image1_alpha_pam} + + pamtogif ${image0_alpha_pam} | giftopnm -alphaout=${a0_out_pbm} | \ + ppmtoppm | tee ${out0_ppm} | \ + cmp -s - ${test_pnm}; echo "a1:" $? "(should print 1)" + cmp -s ${alpha0_pbm} ${a0_out_pbm}; echo "a2:" $? # Should match + + pamarith -multiply ${test_pnm} ${alpha0_pbm} | \ + cmp -s - ${out0_ppm}; echo "a3:" $? # Should match + + pamtogif ${image1_alpha_pam} | giftopnm -alphaout=${a1_out_pbm} | \ + ppmtoppm | tee ${out1_ppm} | \ + cmp -s - ${test_pnm}; echo "b1:" $? "(should print 1)" + + cmp -s ${alpha1_pbm} ${a1_out_pbm}; echo "b2:" $? # Should match + + pamarith -multiply ${test_pnm} ${alpha1_pam} | \ + cmp -s - ${out1_ppm}; echo "b3:" $? # Should match + + pamarith -multiply ${test_pnm} ${alpha0_pbm} | \ + cmp -s - ${out0_ppm}; echo "c1:" $? # Should match + + pamarith -multiply ${test_pnm} ${alpha1_pbm} | \ + cmp -s - ${out1_ppm}; echo "c2:" $? # Should match + + pamcomp -alpha=${alpha0_pbm} ${out0_ppm} ${out1_ppm} | \ + cmp -s - ${test_pnm}; echo "c3:" $? # Should match + + pamcomp -alpha=${alpha1_pbm} ${out1_ppm} ${out0_ppm} | \ + cmp -s - ${test_pnm}; echo "c4:" $? # Should match + + pamtogif ${image0_alpha_pam} -alphacolor=rgb:00/00/80 | \ + giftopnm -alphaout=${a0_out_pbm} > /dev/null + cmp -s ${a0_out_pbm} ${alpha0_pbm}; echo "d1:" $? # Should match + + pamtogif ${image0_alpha_pam} -alphacolor=rgb:00/00/80 | \ + giftopnm | ppmtoppm | \ + ppmchange rgb:00/00/80 rgb:00/00/00 -remainder=rgb:ff/ff/ff | \ + ppmtopgm | \ + cmp -s - ${alpha0_pam}; echo "d2:" $? # Should match + + rm ${image0_alpha_pam} ${image1_alpha_pam} + rm ${out0_ppm} ${out1_ppm} # ${out0_pnm} ${out1_pnm} + rm ${a0_out_pbm} ${a1_out_pbm} + + done + +echo "Test 2." # clear/opaque alpha channel +echo "Should print 0 unless otherwise stated." + +i=1 +for test_pnm in ${argyle_ppm} ${gingham_ppm} ${madras_ppm} + do + echo "Image $i"; i=$((i+1)); + + pamstack -tupletype="RGB_ALPHA" ${test_pnm} ${clear_pam} > \ + ${image0_alpha_pam} + pamstack -tupletype="RGB_ALPHA" ${test_pnm} ${opaque_pam} > \ + ${image1_alpha_pam} + + # clear + pamtogif ${image0_alpha_pam} | giftopnm -alphaout=${a0_out_pbm} | \ + ppmtoppm | tee ${out0_ppm} | \ + cmp -s - ${test_pnm}; echo "cl1:" $? # Should match + cmp -s ${clear_pbm} ${a0_out_pbm}; echo "cl2:" $? # Should match + + # opaque + pamtogif ${image1_alpha_pam} | giftopnm -alphaout=${a1_out_pbm} | \ + tee ${out1_ppm} | \ + cmp -s - ${test_pnm}; echo "op1:" $? "(should print 1)" + + cmp -s ${opaque_pbm} ${a1_out_pbm}; echo "op2:" $? # Should match + + rm ${image0_alpha_pam} ${image1_alpha_pam} + rm ${out0_ppm} ${out1_ppm} + rm ${a0_out_pbm} ${a1_out_pbm} + + done + +rm ${clear_pbm} ${clear_pam} ${opaque_pbm} ${opaque_pam} + + +echo "Test 3." # ppmtogif +echo "Should print 0 in all cases." + +i=1 +for test_pnm in ${argyle_ppm} ${gingham_ppm} ${madras_ppm} + do + echo "Image $i"; i=$((i+1)); + + ppmtogif -alpha=${alpha0_pbm} ${test_pnm} | \ + giftopnm -alphaout=${a0_out_pbm} | \ + ppmtoppm > ${out0_ppm} + cmp -s ${alpha0_pbm} ${a0_out_pbm}; echo "a2:" $? # Should match + pamarith -multiply ${test_pnm} ${alpha0_pbm} | \ + cmp -s - ${out0_ppm}; echo "a3:" $? # Should match + + ppmtogif -alpha=${alpha1_pbm} ${test_pnm} | \ + giftopnm -alphaout=${a1_out_pbm} | \ + ppmtoppm > ${out1_ppm} + cmp -s ${alpha1_pbm} ${a1_out_pbm}; echo "b2:" $? # Should match + pamarith -multiply ${test_pnm} ${alpha1_pam} | \ + cmp -s - ${out1_ppm}; echo "b3:" $? # Should match + + pamcomp -alpha=${alpha1_pbm} ${out1_ppm} ${out0_ppm} | \ + cmp -s - ${test_pnm}; echo "c4:" $? # Should match + + rm ${out0_ppm} ${out1_ppm} + rm ${a0_out_pbm} ${a1_out_pbm} + + done + +rm ${alpha0_pbm} ${alpha1_pbm} +rm ${alpha0_pam} ${alpha1_pam} +rm ${argyle_ppm} ${gingham_ppm} + + +echo "Test 4." +echo "Should print 0 in all cases." +# no separate alpha channel +# designate colors which appear in madras as transparent + +for color in "0f/0f/0f" "ff/00/00" "00/ff/00" + do + echo "color=rgb:"${color} + pamtogif -transparent=rgb:${color} ${madras_ppm} | \ + giftopnm -alphaout=${a0_out_pbm} > ${out0_ppm} + cmp -s ${madras_ppm} ${out0_ppm}; echo $? # Should match + + pbmmake -g 40 24 | pamdepth 255 | pamstack ${madras_ppm} - | + pamtogif -transparent=rgb:${color} - | \ + giftopnm -alphaout=${a1_out_pbm} > ${out1_ppm} + cmp -s ${madras_ppm} ${out1_ppm}; echo $? # Should match + + ppmchange rgb:${color} rgb:00/00/00 \ + -remainder=rgb:ff/ff/ff ${madras_ppm} > ${out2_ppm} + + ppmtoppm < ${a0_out_pbm} | \ + cmp -s ${out2_ppm} -; echo $? # Should match + + rm ${out0_ppm} ${out1_ppm} ${out2_ppm} ${a0_out_pbm} ${a1_out_pbm} + done + +rm ${madras_ppm} diff --git a/test/hdiff-roundtrip.test b/test/hdiff-roundtrip.test index a4a4a906..ec7afc2c 100755 --- a/test/hdiff-roundtrip.test +++ b/test/hdiff-roundtrip.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: hdifftopam pamtohdiff # Also requires: diff --git a/test/ilbm-roundtrip.ok b/test/ilbm-roundtrip.ok index 54574a18..2d6fcff0 100644 --- a/test/ilbm-roundtrip.ok +++ b/test/ilbm-roundtrip.ok @@ -1,10 +1,18 @@ -829921912 685 -829921912 685 -829921912 685 -829921912 685 +Test 1. Should produce 669206373 10102 four times +669206373 10102 +669206373 10102 +669206373 10102 +669206373 10102 +Test 2. Should produce 1926073387 101484 three times 1926073387 101484 1926073387 101484 1926073387 101484 +Test 3. Should print 984199586 101484 984199586 101484 +Test 4. Should print 2059976475 661 three times 2059976475 661 2059976475 661 +2059976475 661 +Test 5. Should print 482756572 101484 twice +482756572 101484 +482756572 101484 diff --git a/test/ilbm-roundtrip.test b/test/ilbm-roundtrip.test index f62368ff..3d7d63ef 100755 --- a/test/ilbm-roundtrip.test +++ b/test/ilbm-roundtrip.test @@ -1,28 +1,58 @@ -#! /bin/bash +#! /bin/sh # This script tests: ppmtoilbm ilbmtoppm -# Also requires: pamseq pamdepth pamtopnm pnmremap +# Also requires: pamseq pamdepth pamtopnm pnmremap pnmcolormap -#Test. 1 Should produce 829921912 685 four times -#Output is PPM raw, 14 by 16 maxval 255 -ppmtoilbm testgrid.pbm | ilbmtoppm | cksum -ppmtoilbm -aga testgrid.pbm | ilbmtoppm | cksum -ppmtoilbm -ham6 testgrid.pbm | ilbmtoppm | cksum -ppmtoilbm -ham8 testgrid.pbm | ilbmtoppm | cksum +echo "Test 1. Should produce 669206373 10102 four times" +#Output is PPM raw, 57 by 59 maxval 255 +ppmtoilbm maze.pbm | ilbmtoppm | cksum +ppmtoilbm -aga maze.pbm | ilbmtoppm | cksum +ppmtoilbm -ham6 maze.pbm | ilbmtoppm | cksum +ppmtoilbm -ham8 maze.pbm | ilbmtoppm | cksum -#Test. 2 Should produce 1926073387 101484 three times + +echo "Test 2. Should produce 1926073387 101484 three times" ppmtoilbm testimg.ppm | ilbmtoppm | cksum ppmtoilbm -24force testimg.ppm | ilbmtoppm | cksum ppmtoilbm -dcbits 8 8 8 -nocompress testimg.ppm | ilbmtoppm | cksum +tmpdir=${tmpdir:-/tmp} -#Test. 3 Should print 984199586 101484 -pamseq 3 5 -tupletype=RGB | pamdepth 255 | pamtopnm | \ +echo "Test 3. Should print 984199586 101484" +test_ppm=${tmpdir}/test.ppm +pamseq 3 5 -tupletype=RGB | pamdepth 255 | pamtopnm | tee ${test_ppm} | \ pnmremap -mapfile=- testimg.ppm | ppmtoilbm | ilbmtoppm | cksum -#Test. 4 Should print 2059976475 661 twice -pamseq 3 5 -tupletype=RGB | pamtopnm | \ - ppmtoilbm -compress | ilbmtoppm | cksum -pamseq 3 5 -tupletype=RGB | pamtopnm | \ - ppmtoilbm -nocompress | ilbmtoppm | cksum +echo "Test 4. Should print 2059976475 661 three times" +cat ${test_ppm} | cksum +ppmtoilbm -compress ${test_ppm} | ilbmtoppm | cksum +ppmtoilbm -nocompress ${test_ppm} | ilbmtoppm | cksum + +rm ${test_ppm} + +echo "Test 5. Should print 482756572 101484 twice" +mapfile=${tmpdir}/mapfile + +# The following was produced by running "pnmcolormap -plain 32 testimg.ppm" +# We use a prefabricated mapfile because pnmcolormap is known to +# produce slightly different output on different systems. + +cat > ${mapfile} << EOF +P3 +32 1 +255 +106 82 80 46 43 34 128 62 46 189 68 63 209 41 43 209 65 46 241 62 72 + 240 189 195 +122 142 103 92 131 68 159 129 188 177 205 195 96 132 107 193 150 107 + 242 253 238 241 73 108 +121 75 67 182 67 47 98 88 48 237 36 47 66 45 42 68 84 43 182 45 41 + 70 77 67 +96 45 45 237 62 47 150 59 41 189 76 103 48 69 31 52 68 52 48 45 51 + 105 80 130 +EOF + +ppmtoilbm -map ${mapfile} testimg.ppm | ilbmtoppm | tee ${test_ppm} | cksum +ppmtoilbm -map ${mapfile} ${test_ppm} | ilbmtoppm | cksum + +rm ${mapfile} ${test_ppm} diff --git a/test/jbig-roundtrip.ok b/test/jbig-roundtrip.ok index b98a694b..c9164120 100644 --- a/test/jbig-roundtrip.ok +++ b/test/jbig-roundtrip.ok @@ -1,2 +1,2 @@ -2425386270 41 +281226646 481 1571496937 33838 diff --git a/test/jbig-roundtrip.test b/test/jbig-roundtrip.test index 570d7336..11cd1778 100755 --- a/test/jbig-roundtrip.test +++ b/test/jbig-roundtrip.test @@ -1,9 +1,9 @@ -#! /bin/bash +#! /bin/sh # This script tests: pnmtojbig jbigtopnm # Also requires: pamchannel pamtopnm -# Test 1. Should print 2425386270 41 -pnmtojbig testgrid.pbm | jbigtopnm | cksum +# Test 1. Should print 281226646 481 +pnmtojbig maze.pbm | jbigtopnm | cksum # Test 2. Should print 1571496937 33838 pamchannel -infile=testimg.ppm -tupletype="GRAYSCALE" 0 | pamtopnm | \ diff --git a/test/jpeg-roundtrip.test b/test/jpeg-roundtrip.test index 7cc0fc20..834c02e5 100755 --- a/test/jpeg-roundtrip.test +++ b/test/jpeg-roundtrip.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pnmtojpeg jpegtopnm # Also requires: pnmpsnr diff --git a/test/jpeg2k-roundtrip.test b/test/jpeg2k-roundtrip.test index 0995849d..4a09201d 100755 --- a/test/jpeg2k-roundtrip.test +++ b/test/jpeg2k-roundtrip.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamtojpeg2k jpeg2ktopam # Also requires: diff --git a/test/leaf-roundtrip.test b/test/leaf-roundtrip.test index 5628ed01..94b31092 100755 --- a/test/leaf-roundtrip.test +++ b/test/leaf-roundtrip.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: ppmtoleaf leaftoppm # Also requires: diff --git a/test/legacy-names.ok b/test/legacy-names.ok index 27baf672..f491a1ff 100644 --- a/test/legacy-names.ok +++ b/test/legacy-names.ok @@ -12,6 +12,7 @@ pgmoil: ok pgmslice: ok pngtopnm: ok pnmarith: ok +pnmcat: ok pnmcomp: ok pnmcut: ok pnmdepth: ok diff --git a/test/legacy-names.test b/test/legacy-names.test index e20dde76..9c0c5697 100755 --- a/test/legacy-names.test +++ b/test/legacy-names.test @@ -69,6 +69,7 @@ ordinary_testprogs="\ pgmslice \ pngtopnm \ pnmarith \ + pnmcat \ pnmcomp \ pnmcut \ pnmdepth \ diff --git a/test/lookup-roundtrip.test b/test/lookup-roundtrip.test index 63ec0777..19ebd40a 100755 --- a/test/lookup-roundtrip.test +++ b/test/lookup-roundtrip.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamlookup pamunlookup # Also requires: ppmhist @@ -10,3 +10,5 @@ ppmhist testimg.ppm -map > ${mapfile} # Test. Should produce 1926073387 101484 pamunlookup -lookupfile=${mapfile} testimg.ppm |\ pamlookup -lookupfile=${mapfile} | cksum + +rm ${mapfile} \ No newline at end of file diff --git a/test/lps-roundtrip.ok b/test/lps-roundtrip.ok index 02b1d1a9..c2c8ab3b 100644 --- a/test/lps-roundtrip.ok +++ b/test/lps-roundtrip.ok @@ -1 +1,4 @@ +Test 1. Should print match match +Test 2. Should print 0 +0 diff --git a/test/lps-roundtrip.test b/test/lps-roundtrip.test index f30062a8..24076ef1 100755 --- a/test/lps-roundtrip.test +++ b/test/lps-roundtrip.test @@ -1,22 +1,33 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmtolps pstopnm -# Also requires: gs pamdepth pamscale pnmcrop pnmpsnr +# Also requires: gs pamdepth pamscale pnmcrop pnmpsnr pamfile # The ordinary round-trip does not work because of the way ghostscript # renders: a line is considered wider than a single pixel and all pixels # it touches are set to black if the output is PBM. To work around this, # we tell pstopnm to output PGM at a high resolution (=large dpi value). +tmpdir=${tmpdir:-/tmp} +test_pgm=${tmpdir}/test.pgm +test_ps=${tmpdir}/test.ps -test_pgm=${tmpdir}/testgrid.pgm +echo "Test 1. Should print match" +xysize=$(pamfile -size testgrid.pbm | awk '{print "-xsize="$1,"-ysize="$2}') pamdepth 255 testgrid.pbm > ${test_pgm} - -pbmtolps -dpi 72 testgrid.pbm | \ + +pbmtolps -dpi 72 testgrid.pbm | tee ${test_ps} | \ pstopnm -dpi $((72*12)) -stdout -pgm | \ - pnmcrop -white | pamscale -xsize=14 -ysize=16 | \ + pnmcrop -white | pamscale ${xysize} | \ pnmpsnr -target=30 - ${test_pgm} -# ghostscript version 8.71: pnmpsnr lumina 33.14dB + # ghostscript version 8.71: pnmpsnr lumina 33.14dB + + +echo "Test 2. Should print 0" -rm ${test_pgm} +pbmtolps -dpi 72 < testgrid.pbm | sed 's/noname/testgrid.pbm/' | \ + cmp -s ${test_ps} - + echo $? + +rm ${test_pgm} ${test_ps} diff --git a/test/macp-roundtrip.ok b/test/macp-roundtrip.ok index 9ff9d249..28c16ee0 100644 --- a/test/macp-roundtrip.ok +++ b/test/macp-roundtrip.ok @@ -1,5 +1,14 @@ -2425386270 41 -2425386270 41 +Test 1. Should produce 281226646 481 twice +281226646 481 +281226646 481 +Test 2. Should produce 2329957971 51851 2329957971 51851 +Test 3. Should produce 2907103393 5086 three times 2907103393 5086 2907103393 5086 +2907103393 5086 +Test 4. Should produce 3432623660 51851 four times +3432623660 51851 +3432623660 51851 +3432623660 51851 +3432623660 51851 diff --git a/test/macp-roundtrip.test b/test/macp-roundtrip.test index 4774a2c2..9def7c4c 100755 --- a/test/macp-roundtrip.test +++ b/test/macp-roundtrip.test @@ -1,31 +1,51 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmtomacp macptopbm -# Also requires: pnmcrop pbmpage pbmupc pnmpad +# Also requires: pnmcrop pbmpage pbmupc pnmpad pbmmake tmpdir=${tmpdir:-/tmp} -temp1_pbm=${tmpdir}/temp1.ppm -temp2_pbm=${tmpdir}/temp2.ppm +temp1_pbm=${tmpdir}/temp1.pbm +temp2_pbm=${tmpdir}/temp2.pbm +tempupc_pbm=${tmpdir}/tempupc.pbm +temp3_pbm=${tmpdir}/temp3.pbm +temp3_macp=${tmpdir}/temp3.macp - -# Test 1. Should produce 2425386270 41 twice -# Because Macpaint files are fixed size (576 x 720 pixels) +# Macpaint files are fixed size (576 x 720 pixels) # pbmtomacp automatically adds padding when input is smaller. -pbmtomacp testgrid.pbm | macptopbm | tee ${temp1_pbm} | \ +echo "Test 1. Should produce 281226646 481 twice" +pbmtomacp maze.pbm | macptopbm | tee ${temp1_pbm} | \ pnmcrop | cksum pbmtomacp ${temp1_pbm} | macptopbm | pnmcrop | cksum +rm ${temp1_pbm} -#Test 2. Should produce 2329957971 51851 +echo "Test 2. Should produce 2329957971 51851" pbmpage 1 | pbmtomacp | macptopbm | cksum - -#Test 3. Should produce 2907103393 5086 twice -pbmupc 0 12345 67890 | pnmpad -black -t 44 -b 20 -l 100 -r 251 | pbmtomacp | macptopbm | \ +echo "Test 3. Should produce 2907103393 5086 three times" +pbmupc 0 12345 67890 | tee ${tempupc_pbm} | \ + pnmpad -black -t 44 -b 20 -l 100 -r 251 | \ + pbmtomacp | macptopbm | \ tee ${temp2_pbm} | \ pnmcrop | pnmcrop | cksum +pnmpad -black -t 44 -l 100 ${tempupc_pbm} | \ + pbmtomacp| macptopbm | pnmcrop -white | pnmcrop | cksum + pbmtomacp ${temp2_pbm} | macptopbm | pnmcrop | pnmcrop | cksum -rm ${temp1_pbm} ${temp2_pbm} +rm ${temp2_pbm} ${tempupc_pbm} + + +echo "Test 4. Should produce 3432623660 51851 four times" +pbmmake -b 576 720 | tee ${temp3_pbm} | cksum + +pbmtomacp ${temp3_pbm} | tee ${temp3_macp} | macptopbm | cksum + +pbmtomacp -norle ${temp3_pbm} | macptopbm | cksum + +( head -c 128 /dev/zero ; cat ${temp3_macp} ) | \ + macptopbm -extraskip 128 | cksum + +rm ${temp3_pbm} ${temp3_macp} diff --git a/test/maze.pbm b/test/maze.pbm new file mode 100644 index 00000000..9bdd80e1 --- /dev/null +++ b/test/maze.pbm Binary files differdiff --git a/test/mda-roundtrip.ok b/test/mda-roundtrip.ok index ef27ffd0..ab449885 100644 --- a/test/mda-roundtrip.ok +++ b/test/mda-roundtrip.ok @@ -1,2 +1,5 @@ +Test 1. Should print 1757803444 169 twice 1757803444 169 -2425386270 41 +1757803444 169 +Test 2. Should print 281226646 481 +281226646 481 diff --git a/test/mda-roundtrip.test b/test/mda-roundtrip.test index 58376f3f..c47d433e 100755 --- a/test/mda-roundtrip.test +++ b/test/mda-roundtrip.test @@ -1,13 +1,15 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmtomda mdatopbm -# Also requires: pbmmake pnmpad pamcut +# Also requires: pbmmake pnmpad pamcut pamfile # Pbmtomda requires input width and height to be multiples of 8. -# Test 1. Should print 1757803444 169 +echo "Test 1. Should print 1757803444 169 twice" +pbmmake -g 32 40 | cksum pbmmake -g 32 40 | pbmtomda | mdatopbm | cksum -# Test 2. Should print 2425386270 41 -pnmpad -right 2 testgrid.pbm | \ - pbmtomda | mdatopbm | pamcut 0 0 14 16 | cksum +echo "Test 2. Should print 281226646 481" +size=$(pamfile -size maze.pbm | awk '{print "-width="$1,"-height="$2}') +pnmpad -mwidth=8 -halign=0 -mheight=8 -valign=0 ${size} maze.pbm | \ + pbmtomda | mdatopbm | pamcut -left=0 -top=0 ${size} | cksum diff --git a/test/mgr-roundtrip.ok b/test/mgr-roundtrip.ok index 845be5fb..0e845958 100644 --- a/test/mgr-roundtrip.ok +++ b/test/mgr-roundtrip.ok @@ -1 +1,7 @@ -2425386270 41 +Test 1. Should print 281226646 481 +281226646 481 +Test 2. Should print 429369764 1034, 448060073 4105 twice each +429369764 1034 +429369764 1034 +448060073 4105 +448060073 4105 diff --git a/test/mgr-roundtrip.test b/test/mgr-roundtrip.test index 252ae996..9fb6211c 100755 --- a/test/mgr-roundtrip.test +++ b/test/mgr-roundtrip.test @@ -1,7 +1,15 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmtomgr mgrtopbm -# Also requires: +# Also requires: pbmmake +echo "Test 1. Should print 281226646 481" +pbmtomgr maze.pbm | mgrtopbm | cksum + +echo "Test 2. Should print 429369764 1034, 448060073 4105 twice each" +# Maximum width and height allowed + +pbmmake -g 4095 2 | cksum +pbmmake -g 4095 2 | pbmtomgr | mgrtopbm | cksum +pbmmake -g 1 4095 | cksum +pbmmake -g 1 4095 | pbmtomgr | mgrtopbm | cksum -# Should print 2425386270 41, cksum of testgrid.pbm -pbmtomgr testgrid.pbm | mgrtopbm | cksum diff --git a/test/mrf-roundtrip.ok b/test/mrf-roundtrip.ok index 845be5fb..5168378d 100644 --- a/test/mrf-roundtrip.ok +++ b/test/mrf-roundtrip.ok @@ -1 +1 @@ -2425386270 41 +281226646 481 diff --git a/test/mrf-roundtrip.test b/test/mrf-roundtrip.test index c9d8ce3a..5ce604e6 100755 --- a/test/mrf-roundtrip.test +++ b/test/mrf-roundtrip.test @@ -1,7 +1,7 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmtomrf mrftopbm # Also requires: -# Should print 2425386270 41, cksum of testgrid.pbm -pbmtomrf testgrid.pbm | mrftopbm | cksum +# Should print 281226646 481, cksum of maze.pbm +pbmtomrf maze.pbm | mrftopbm | cksum diff --git a/test/pad-crop-roundtrip.ok b/test/pad-crop-roundtrip.ok index 0e712ce7..764cadfa 100644 --- a/test/pad-crop-roundtrip.ok +++ b/test/pad-crop-roundtrip.ok @@ -1,4 +1,4 @@ 1926073387 101484 1926073387 101484 -2425386270 41 -2425386270 41 +281226646 481 +281226646 481 diff --git a/test/pad-crop-roundtrip.test b/test/pad-crop-roundtrip.test index 75979901..31e02c99 100755 --- a/test/pad-crop-roundtrip.test +++ b/test/pad-crop-roundtrip.test @@ -1,18 +1,26 @@ -#! /bin/bash +#! /bin/sh # This script tests: pnmcrop pnmmargin pnmpad # Also requires: +# Test 1. Should produce 1926073387 101484, cksum of testimg.ppm + pnmmargin -white 10 testimg.ppm | \ pnmcrop | cksum +# Test 2. Should produce 1926073387 101484 + pnmpad -white -left 10 -top 10 testimg.ppm | \ pnmpad -white -right 10 -bottom 10 | \ pnmcrop -right -bottom | pnmcrop -left -top | cksum -pnmmargin -white 10 testgrid.pbm | \ +# Test 3. Should produce 281226646 481, cksum of maze.pbm + +pnmmargin -white 10 maze.pbm | \ pnmcrop | cksum -pnmpad -white -left 10 -top 10 testgrid.pbm | \ +# Test 4. Should produce 281226646 481 + +pnmpad -white -left 10 -top 10 maze.pbm | \ pnmpad -white -right 10 -bottom 10 | \ pnmcrop -left -right | pnmcrop -top -bottom | cksum diff --git a/test/palm-roundtrip.ok b/test/palm-roundtrip.ok index b9ea3056..d69c3a96 100644 --- a/test/palm-roundtrip.ok +++ b/test/palm-roundtrip.ok @@ -1,10 +1,10 @@ -Test 1 -584219238 236 -584219238 236 -584219238 236 -584219238 236 -584219238 236 -Test 2 +Test 1. Should print 2067616594 3375 five times +2067616594 3375 +2067616594 3375 +2067616594 3375 +2067616594 3375 +2067616594 3375 +Test 2. Should print 0 0 0 : 0 four times 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 b00454ca..20fcefa9 100755 --- a/test/palm-roundtrip.test +++ b/test/palm-roundtrip.test @@ -6,11 +6,9 @@ tmpdir=${tmpdir:-/tmp} test4bit_pgm=${tmpdir}/test4bit.pgm test256color_ppm=${tmpdir}/test256color.ppm -# Test 1. Should print 584219238 236 5 times +echo "Test 1. Should print 2067616594 3375 five times" -echo "Test 1" - -pamdepth 15 testgrid.pbm | tee ${test4bit_pgm} | cksum +pamdepth 15 maze.pbm | tee ${test4bit_pgm} | cksum for flags in "" \ "-scanline_compression" \ @@ -21,9 +19,7 @@ for flags in "" \ rm ${test4bit_pgm} -# Test 2. Should print 0 4 times - -echo "Test 2" +echo "Test 2. Should print 0 0 0 : 0 four times" pnmquant 256 testimg.ppm > ${test256color_ppm} || echo "pnmquant failed" diff --git a/test/palm-roundtrip2.test b/test/palm-roundtrip2.test index 4c94df8c..f0c9b7c8 100755 --- a/test/palm-roundtrip2.test +++ b/test/palm-roundtrip2.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pnmtopalm palmtopnm # Also requires: pnmremap diff --git a/test/pamaddnoise-parameters.ok b/test/pamaddnoise-parameters.ok new file mode 100644 index 00000000..e86632cf --- /dev/null +++ b/test/pamaddnoise-parameters.ok @@ -0,0 +1,62 @@ +Test Invalid +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) +Expected failure 5 (no output) +Expected failure 6 (no output) +Expected failure 7 (no output) +Expected failure 8 (no output) +Expected failure 9 (no output) +Expected failure 10 (no output) +Expected failure 11 (no output) +Expected failure 12 (no output) +Expected failure 13 (no output) +Expected failure 14 (no output) +Expected failure 15 (no output) +Expected failure 16 (no output) +Expected failure 17 (no output) +Expected failure 18 (no output) +Expected failure 19 (no output) +Expected failure 20 (no output) +Expected failure 21 (no output) +Expected failure 22 (no output) +Expected failure 23 (no output) +Expected failure 24 (no output) +Expected failure 25 (no output) +Expected failure 26 (no output) +Expected failure 27 (no output) +Expected failure 28 (no output) +Expected failure 29 (no output) +Expected failure 30 (no output) +Expected failure 31 (no output) +Expected failure 32 (no output) +Expected failure 33 (no output) +Expected failure 34 (no output) +Expected failure 35 (no output) +Expected failure 36 (no output) +Expected failure 37 (no output) +Expected failure 38 (no output) +Expected failure 39 (no output) +Expected failure 40 (no output) +Expected failure 41 (no output) +Expected failure 42 (no output) +Expected failure 43 (no output) +Expected failure 44 (no output) +Expected failure 45 (no output) +Expected failure 46 (no output) +Expected failure 47 (no output) +Expected failure 48 (no output) +Expected failure 49 (no output) +Expected failure 50 (no output) +Expected failure 51 (no output) +Expected failure 52 (no output) +Expected failure 53 (no output) +Expected failure 54 (no output) +Expected failure 55 (no output) +Expected failure 56 (no output) +Expected failure 57 (no output) +Expected failure 58 (no output) +Expected failure 59 (no output) +Expected failure 60 (no output) +Expected failure 61 (no output) diff --git a/test/pamaddnoise-parameters.test b/test/pamaddnoise-parameters.test new file mode 100755 index 00000000..098d4946 --- /dev/null +++ b/test/pamaddnoise-parameters.test @@ -0,0 +1,337 @@ +#! /bin/sh +# This script tests: pamaddnoise +# Also requires: + +tmpdir=${tmpdir:-/tmp} +test_out=/${tmpdir}/test.out + +# Test Invalid +echo "Test Invalid" + +echo 1>&2 +echo "Invalid command-line argument combinations." 1>&2 +echo "Error messages should appear below the line." 1>&2 +echo "-----------------------------------------------------------" 1>&2 + +# type gaussian implied + +pamaddnoise -sigma1=-4.0 testgrid.pbm > ${test_out} || \ + printf "Expected failure 1 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -sigma2=-20.0 testgrid.pbm > ${test_out} || \ + printf "Expected failure 2 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -mgsigma=0.5 testgrid.pbm > ${test_out} || \ + printf "Expected failure 3 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -lsigma=10.0 testgrid.pbm > ${test_out} || \ + printf "Expected failure 4 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -tolerance=0.10 testgrid.pbm > ${test_out} || \ + printf "Expected failure 5 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -salt=0.50 testgrid.pbm > ${test_out} || \ + printf "Expected failure 6 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -lambda=12.0 testgrid.pbm > ${test_out} || \ + printf "Expected failure 7 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +# type gaussian explicitly stated + +pamaddnoise -type gaussian -sigma1=-0.01 testgrid.pbm > ${test_out} || \ + printf "Expected failure 8 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type gaussian -sigma2=-0.01 testgrid.pbm > ${test_out} || \ + printf "Expected failure 9 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type gaussian -mgsigma=0.5 testgrid.pbm > ${test_out} || \ + printf "Expected failure 10 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type gaussian -lsigma=10.0 testgrid.pbm > ${test_out} || \ + printf "Expected failure 11 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type gaussian -tolerance=0.10 testgrid.pbm > ${test_out} || \ + printf "Expected failure 12 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type gaussian -salt=0.50 testgrid.pbm > ${test_out} || \ + printf "Expected failure 13 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type gaussian -lambda=12.0 testgrid.pbm > ${test_out} || \ + printf "Expected failure 14 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +# type multiplicative gaussian + +pamaddnoise -type multiplicative_gaussian -sigma1=4.0 testgrid.pbm > ${test_out} || \ + printf "Expected failure 15 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type multiplicative_gaussian -sigma2=20.0 testgrid.pbm > ${test_out} || \ + printf "Expected failure 16 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type multiplicative_gaussian -mgsigma=-0.5 testgrid.pbm > ${test_out} || \ + printf "Expected failure 17 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type multiplicative_gaussian -lsigma=10.0 testgrid.pbm > ${test_out} || \ + printf "Expected failure 18 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type multiplicative_gaussian -tolerance=0.10 testgrid.pbm > ${test_out} || \ + printf "Expected failure 19 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type multiplicative_gaussian -salt=0.50 testgrid.pbm > ${test_out} || \ + printf "Expected failure 20 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type multiplicative_gaussian -lambda=12.0 testgrid.pbm > ${test_out} || \ + printf "Expected failure 21 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +# type laplacian + +pamaddnoise -type laplacian -sigma1=4.0 testgrid.pbm > ${test_out} || \ + printf "Expected failure 22 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type laplacian -sigma2=20.0 testgrid.pbm > ${test_out} || \ + printf "Expected failure 23 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type laplacian -mgsigma=0.5 testgrid.pbm > ${test_out} || \ + printf "Expected failure 24 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type laplacian -lsigma=-10.0 testgrid.pbm > ${test_out} || \ + printf "Expected failure 25 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type laplacian -tolerance=0.10 testgrid.pbm > ${test_out} || \ + printf "Expected failure 26 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type laplacian -salt=0.50 testgrid.pbm > ${test_out} || \ + printf "Expected failure 27 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type laplacian -lambda=12.0 testgrid.pbm > ${test_out} || \ + printf "Expected failure 28 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + + +# type impulse + +pamaddnoise -type impulse -sigma1=4.0 testgrid.pbm > ${test_out} || \ + printf "Expected failure 29 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type impulse -sigma2=20.0 testgrid.pbm > ${test_out} || \ + printf "Expected failure 30 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type impulse -mgsigma=0.5 testgrid.pbm > ${test_out} || \ + printf "Expected failure 31 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type impulse -lsigma=10.0 testgrid.pbm > ${test_out} || \ + printf "Expected failure 32 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type impulse -tolerance=-0.10 testgrid.pbm > ${test_out} || \ + printf "Expected failure 33 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type impulse -tolerance=1.10 testgrid.pbm > ${test_out} || \ + printf "Expected failure 34 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type impulse -salt=-0.10 testgrid.pbm > ${test_out} || \ + printf "Expected failure 35 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type impulse -salt=+1.10 testgrid.pbm > ${test_out} || \ + printf "Expected failure 36 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type impulse -lambda=12.0 testgrid.pbm > ${test_out} || \ + printf "Expected failure 37 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +# type poisson + +pamaddnoise -type poisson -sigma1=4.0 testgrid.pbm > ${test_out} || \ + printf "Expected failure 38 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type poisson -sigma2=20.0 testgrid.pbm > ${test_out} || \ + printf "Expected failure 39 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type poisson -mgsigma=0.5 testgrid.pbm > ${test_out} || \ + printf "Expected failure 40 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type poisson -lsigma=10.0 testgrid.pbm > ${test_out} || \ + printf "Expected failure 41 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type poisson -tolerance=0.10 testgrid.pbm > ${test_out} || \ + printf "Expected failure 42 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type poisson -salt=0.50 testgrid.pbm > ${test_out} || \ + printf "Expected failure 43 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type poisson -lambda=0 testgrid.pbm > ${test_out} || \ + printf "Expected failure 44 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +# Missing or invalid numerical parameters + +pamaddnoise -sigma1 testgrid.pbm > ${test_out} || \ + printf "Expected failure 45 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -sigma1 Z testgrid.pbm > ${test_out} || \ + printf "Expected failure 46 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type gaussian -sigma2 testgrid.pbm > ${test_out} || \ + printf "Expected failure 47 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type gaussian -sigma2 sigma testgrid.pbm > ${test_out} || \ + printf "Expected failure 48 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type mult -mgsigma testgrid.pbm > ${test_out} || \ + printf "Expected failure 49 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type mult -mgsigma 10,0 testgrid.pbm > ${test_out} || \ + printf "Expected failure 50 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type lapl -lsigma 1..0 testgrid.pbm > ${test_out} || \ + printf "Expected failure 51 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type lapl -lsigma lsigma testgrid.pbm > ${test_out} || \ + printf "Expected failure 52 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type impul -tolerance testgrid.pbm > ${test_out} || \ + printf "Expected failure 53 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type impul -tolerance t testgrid.pbm > ${test_out} || \ + printf "Expected failure 54 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type impul -salt testgrid.pbm > ${test_out} || \ + printf "Expected failure 55 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type impul -salt pepper testgrid.pbm > ${test_out} || \ + printf "Expected failure 56 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type pois -lambda testgrid.pbm > ${test_out} || \ + printf "Expected failure 57 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -type pois -lambda L testgrid.pbm > ${test_out} || \ + printf "Expected failure 58 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -seed -1 testgrid.pbm > ${test_out} || \ + printf "Expected failure 59 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pamaddnoise -seed random testgrid.pbm > ${test_out} || \ + printf "Expected failure 60 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + + +# no type specified + +pamaddnoise -type testgrid.pbm > ${test_out} || \ + printf "Expected failure 61 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} diff --git a/test/pamarith-compare-equal.ok b/test/pamarith-compare-equal.ok index ef1c2981..d6b1f624 100644 --- a/test/pamarith-compare-equal.ok +++ b/test/pamarith-compare-equal.ok @@ -6,6 +6,17 @@ Test 1 1:P3 1:8 8 1:2 +1:1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 0 0 0 2 2 2 0 0 +1:1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 2 2 2 0 0 0 2 2 +1:1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 0 0 0 2 2 2 0 0 +1:1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 2 2 2 0 0 0 2 2 +1:1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 0 0 0 2 2 2 0 0 +1:0 2 2 2 0 0 0 2 2 2 0 0 0 2 2 1 1 1 1 1 1 1 1 1 +1:2 0 0 0 2 2 2 0 0 0 2 2 2 0 0 1 1 1 1 1 1 1 1 1 +1:0 2 2 2 0 0 0 2 2 2 0 0 0 2 2 1 1 1 1 1 1 1 1 1 +1:P3 +1:8 8 +1:2 5:0 0 2 0 0 2 0 0 2 0 0 2 0 0 2 2 0 2 2 0 2 2 0 2 3:2 0 2 2 0 2 2 0 2 2 0 2 2 0 2 2 0 0 2 0 0 2 0 0 Test 2 @@ -16,14 +27,19 @@ Test 2 1:P3 1:8 8 1:1 +5:1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 +3:0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 +1:P3 +1:8 8 +1:1 8: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 3 1:P1 -1:14 16 -16:00000000000000 +1:35 33 +33:00000000000000000000000000000000000 1:P1 -1:14 16 -16:11111111111111 +1:35 33 +33:11111111111111111111111111111111111 1:P1 1:14 16 8:10101010101010 11111111111111 @@ -32,9 +48,9 @@ Test 3 8:01010101010101 00000000000000 Test 4 1:P2 -1:14 16 +1:35 33 1:2 -16:1 1 1 1 1 1 1 1 1 1 1 1 1 1 +33:1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1:P2 1:14 16 1:2 @@ -48,11 +64,11 @@ Test 4 1:2 8:1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Test 5 -Should produce 1285449498 54 +Should produce 1285449498 54 four times 1285449498 54 1285449498 54 1285449498 54 1285449498 54 -Should produce 244506188 54 +Should produce 244506188 54 twice 244506188 54 244506188 54 diff --git a/test/pamarith-compare-equal.test b/test/pamarith-compare-equal.test index 903ad538..7d1062b7 100755 --- a/test/pamarith-compare-equal.test +++ b/test/pamarith-compare-equal.test @@ -1,20 +1,25 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamarith -# Also requires: ppmpat pnminvert pbmmake pgmmake +# Also requires: ppmpat pnminvert pamfile pbmmake pgmmake pamcut tmpdir=${tmpdir:-/tmp} input1_ppm=${tmpdir}/input1.ppm +inputm_ppm=${tmpdir}/inputm.ppm input2_ppm=${tmpdir}/input2.ppm echo "Test 1" ppmpat -tartan -color=rgb:00/80/ff,rgb:80/ff/00,rgb:ff/00/80 \ 8 8 > ${input1_ppm} +ppmpat -tartan -color=rgb:00/80/ff,rgb:80/ff/00,rgb:ff/00/80 \ + -mesh 8 8 > ${inputm_ppm} ppmpat -tartan -color=rgb:80/ff/00,rgb:ff/00/80,rgb:00/80/ff \ 8 8 > ${input2_ppm} pamarith -compare -plain ${input1_ppm} ${input1_ppm} | \ uniq -c | sed -e 's/^ *//' -e 's/ /:/' +pamarith -compare -plain ${input1_ppm} ${inputm_ppm} | \ + uniq -c | sed -e 's/^ *//' -e 's/ /:/' pamarith -compare -plain ${input1_ppm} ${input2_ppm} | \ uniq -c | sed -e 's/^ *//' -e 's/ /:/' @@ -22,54 +27,66 @@ echo "Test 2" pamarith -equal -plain ${input1_ppm} ${input1_ppm} | \ uniq -c | sed -e 's/^ *//' -e 's/ /:/' +pamarith -equal -plain ${input1_ppm} ${inputm_ppm} | \ + uniq -c | sed -e 's/^ *//' -e 's/ /:/' pamarith -equal -plain ${input1_ppm} ${input2_ppm} | \ uniq -c | sed -e 's/^ *//' -e 's/ /:/' -rm ${input1_ppm} ${input2_ppm} +rm ${input1_ppm} ${inputm_ppm} ${input2_ppm} echo "Test 3" -pamarith -equal -plain testgrid.pbm testgrid.pbm | \ +input3_pbm=${tmpdir}/input3.pbm +pamcut maze.pbm -left=0 -top=0 -width=35 -height=33 > ${input3_pbm} + +pamarith -equal -plain ${input3_pbm} ${input3_pbm} | \ uniq -c | sed -e 's/^ *//' -e 's/ /:/' -pnminvert testgrid.pbm | pamarith -equal -plain testgrid.pbm - | \ +pnminvert ${input3_pbm} | pamarith -equal -plain ${input3_pbm} - | \ uniq -c | sed -e 's/^ *//' -e 's/ /:/' -pbmmake -w 14 16 | pamarith -equal -plain testgrid.pbm - | \ + +xysize=$(pamfile -size testgrid.pbm) + +pbmmake -w ${xysize} | pamarith -equal -plain testgrid.pbm - | \ awk '{printf("%s%c",$0, NR<3 || NR%2==0 ? "\n" : " ")}' | uniq -c | sed -e 's/^ *//' -e 's/ /:/' -pbmmake -b 14 16 | pamarith -equal -plain testgrid.pbm - | \ +pbmmake -b ${xysize} | pamarith -equal -plain testgrid.pbm - | \ awk '{printf("%s%c",$0, NR<3 || NR%2==0 ? "\n" : " ")}' | uniq -c | sed -e 's/^ *//' -e 's/ /:/' echo "Test 4" - -pamarith -compare -plain testgrid.pbm testgrid.pbm | \ + + +pamarith -compare -plain ${input3_pbm} ${input3_pbm} | \ uniq -c | sed -e 's/^ *//' -e 's/ /:/' + pnminvert testgrid.pbm | pamarith -compare -plain testgrid.pbm - | \ awk '{printf("%s%c",$0, NR<4 || NR%2==1 ? "\n" : " ")}' | uniq -c | sed -e 's/^ *//' -e 's/ /:/' -pbmmake -w 14 16 | pamarith -compare -plain testgrid.pbm - | \ +pbmmake -w ${xysize} | pamarith -compare -plain testgrid.pbm - | \ awk '{printf("%s%c",$0, NR<4 || NR%2==1 ? "\n" : " ")}' | uniq -c | sed -e 's/^ *//' -e 's/ /:/' -pbmmake -b 14 16 | pamarith -compare -plain testgrid.pbm - | \ +pbmmake -b ${xysize} | pamarith -compare -plain testgrid.pbm - | \ awk '{printf("%s%c",$0, NR<4 || NR%2==1 ? "\n" : " ")}' | uniq -c | sed -e 's/^ *//' -e 's/ /:/' +rm ${input3_pbm} echo "Test 5" # -closeness input40_pgm=${tmpdir}/input40.pgm input50_pgm=${tmpdir}/input50.pgm -equal_pgm=${tmpdir}/equal.pgm pgmmake -maxval=99 0.40 7 3 > ${input40_pgm} pgmmake -maxval=99 0.50 7 3 > ${input50_pgm} -echo "Should produce 1285449498 54" +echo "Should produce 1285449498 54 four times" pamarith -equal -plain ${input40_pgm} ${input40_pgm} | cksum pamarith -equal -plain -closeness=10.2 ${input40_pgm} ${input50_pgm} | cksum pamarith -equal -plain -closeness=11 ${input40_pgm} ${input50_pgm} | cksum pamarith -equal -plain -closeness=90 ${input40_pgm} ${input50_pgm} | cksum -echo "Should produce 244506188 54" +echo "Should produce 244506188 54 twice" pamarith -equal -plain ${input40_pgm} ${input50_pgm} | cksum -pamarith -equal -plain -closeness=09 ${input40_pgm} ${input50_pgm} | cksum +pamarith -equal -plain -closeness=09 ${input40_pgm} ${input50_pgm} | cksum + +rm ${input40_pgm} ${input50_pgm} \ No newline at end of file diff --git a/test/pamarith-multiple-input.test b/test/pamarith-multiple-input.test index 7df08817..b9c09662 100755 --- a/test/pamarith-multiple-input.test +++ b/test/pamarith-multiple-input.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamarith # Also requires: pgmmake ppmpat pamfunc @@ -14,7 +14,7 @@ pgmmake -maxval=99 0.01 16 11 > ${input1_pgm} add_command="pamarith -add "${input1_pgm} -for ((i=1 ; i<10 ; i++ )) +for i in 1 2 3 4 5 6 7 8 9 # for i in `seq 9` do echo ${i}":" add_command=${add_command}" "${input1_pgm} @@ -58,4 +58,4 @@ for function in "-add" "-and" "-or" "-xor" "-nand" "-nor" pamarith ${function} ${g2_ppm} ${g3_ppm} ${g2_ppm} | cksum done -rm ${g2_ppm} ${g3_ppm} \ No newline at end of file +rm ${g2_ppm} ${g3_ppm} diff --git a/test/pamarith.ok b/test/pamarith.ok index 0862df8e..a0942fb8 100644 --- a/test/pamarith.ok +++ b/test/pamarith.ok @@ -2,8 +2,8 @@ Test 1 P2 16 2 15 -0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 -2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 +0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 +2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 -add P2 16 1 15 2 3 4 5 6 7 8 9 10 11 12 13 14 15 15 15 1927712885 59 @@ -193,19 +193,19 @@ Test 3 3072492814 913 3072492814 913 Test 4 (input = output) -cksum is 2425386270 41 or 2921940274 59 +Prints 281226646 481 six times, then 2921940274 59 six times input image -2425386270 41 +281226646 481 -minimum -2425386270 41 +281226646 481 -maximum -2425386270 41 +281226646 481 -mean -2425386270 41 +281226646 481 -and -2425386270 41 +281226646 481 -or -2425386270 41 +281226646 481 input image 2921940274 59 -minimum @@ -219,13 +219,13 @@ input image -or 2921940274 59 Test 5 (blank output) -cksum is 2817549367 41 or 320101399 59 +Prints 2247801875 481 three times, then 320101399 59 three times -subtract -2817549367 41 +2247801875 481 -difference -2817549367 41 +2247801875 481 -xor -2817549367 41 +2247801875 481 -subtract 320101399 59 -difference @@ -233,45 +233,45 @@ cksum is 2817549367 41 or 320101399 59 -xor 320101399 59 Test Invalid -Expected failure 1 1 -Expected failure 2 1 -Expected failure 3 1 -Expected failure 4 1 -Expected failure 5 1 -Expected failure 6 1 -Expected failure 7 1 -Expected failure 8 1 -Expected failure 9 1 -Expected failure 10 1 -Expected failure 11 1 -Expected failure 12 1 -Expected failure 13 1 -Expected failure 14 1 -Expected failure 15 1 -Expected failure 16 1 -Expected failure 17 1 -Expected failure 18 1 -Expected failure 19 1 -Expected failure 20 1 -Expected failure 21 1 -Expected failure 22 1 -Expected failure 23 1 -Expected failure 24 1 -Expected failure 25 1 -Expected failure 26 1 -Expected failure 27 1 -Expected failure 28 1 -Expected failure 29 1 -Expected failure 30 1 -Expected failure 31 1 -Expected failure 32 1 -Expected failure 33 1 -Expected failure 34 1 -Expected failure 35 1 -Expected failure 36 1 -Expected failure 37 1 -Expected failure 38 1 -Expected failure 39 1 -Expected failure 40 1 -Expected failure 41 1 -Expected failure 42 1 +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) +Expected failure 5 (no output) +Expected failure 6 (no output) +Expected failure 7 (no output) +Expected failure 8 (no output) +Expected failure 9 (no output) +Expected failure 10 (no output) +Expected failure 11 (no output) +Expected failure 12 (no output) +Expected failure 13 (no output) +Expected failure 14 (no output) +Expected failure 15 (no output) +Expected failure 16 (no output) +Expected failure 17 (no output) +Expected failure 18 (no output) +Expected failure 19 (no output) +Expected failure 20 (no output) +Expected failure 21 (no output) +Expected failure 22 (no output) +Expected failure 23 (no output) +Expected failure 24 (no output) +Expected failure 25 (no output) +Expected failure 26 (no output) +Expected failure 27 (no output) +Expected failure 28 (no output) +Expected failure 29 (no output) +Expected failure 30 (no output) +Expected failure 31 (no output) +Expected failure 32 (no output) +Expected failure 33 (no output) +Expected failure 34 (no output) +Expected failure 35 (no output) +Expected failure 36 (no output) +Expected failure 37 (no output) +Expected failure 38 (no output) +Expected failure 39 (no output) +Expected failure 40 (no output) +Expected failure 41 (no output) +Expected failure 42 (no output) diff --git a/test/pamarith.test b/test/pamarith.test index a4c98859..20c4039d 100755 --- a/test/pamarith.test +++ b/test/pamarith.test @@ -1,7 +1,7 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamarith -# Also requires: pamtopnm rgb3toppm pamenlarge pnmcat pamseq pbmmake pgmmake -# Also requires: ppmpat pamchannel +# Also requires: pamtopnm rgb3toppm pamenlarge pamcat pamseq pbmmake pgmmake +# Also requires: ppmpat pamchannel tmpdir=${tmpdir:-/tmp} input1_pgm=${tmpdir}/input1.pgm @@ -15,10 +15,10 @@ echo "Test 1" pamseq 1 15 | pamtopnm -assume > ${input1_pgm} pgmmake -maxval 15 0.15 16 1 > ${input2_pgm} -rgb3toppm ${input1_pgm} ${input1_pgm} ${input1_pgm} > ${input1_ppm} -rgb3toppm ${input2_pgm} ${input2_pgm} ${input2_pgm} > ${input2_ppm} +rgb3toppm ${input1_pgm} ${input1_pgm} ${input1_pgm} > ${input1_ppm} +rgb3toppm ${input2_pgm} ${input2_pgm} ${input2_pgm} > ${input2_ppm} -pnmcat -tb -plain ${input1_pgm} ${input2_pgm} +pamcat -tb ${input1_pgm} ${input2_pgm} -plain for fn in "-add" "-subtract" "-multiply" "-divide" "-difference" \ "-minimum" "-maximum" "-mean" "-compare" "-equal" \ @@ -43,7 +43,7 @@ echo "Test 2 PBM" pbmmake -g 8 1 > ${input1_pbm} pbmmake -g 2 1 | pamenlarge -xscale=4 > ${input2_pbm} -pnmcat -tb -plain ${input1_pbm} ${input2_pbm} +pamcat -tb -plain ${input1_pbm} ${input2_pbm} for fn in "-add" "-subtract" "-multiply" "-divide" "-difference" \ "-minimum" "-maximum" "-mean" "-compare" "-equal" \ @@ -88,12 +88,12 @@ for fn in "-subtract" "-divide" "-compare" "-shiftleft" "-shiftright" rm ${input3_ppm} ${input4_ppm} ${input4_pgm} echo "Test 4 (input = output)" -echo "cksum is 2425386270 41 or 2921940274 59" +echo "Prints 281226646 481 six times, then 2921940274 59 six times" -for image in testgrid.pbm ${input1_ppm} +for image in maze.pbm ${input1_ppm} do echo "input image" - cat ${image} | cksum + cat ${image} | cksum for fn in "-minimum" "-maximum" "-mean" "-and" "-or" do echo ${fn} @@ -103,9 +103,9 @@ for image in testgrid.pbm ${input1_ppm} echo "Test 5 (blank output)" -echo "cksum is 2817549367 41 or 320101399 59" +echo "Prints 2247801875 481 three times, then 320101399 59 three times" -for image in testgrid.pbm ${input1_ppm} +for image in maze.pbm ${input1_ppm} do for fn in "-subtract" "-difference" "-xor" do @@ -116,112 +116,68 @@ for image in testgrid.pbm ${input1_ppm} rm ${input1_ppm} - -echo "Invalid command-line argument combinations." 1>&2 -echo "Error messages should appear below the line." 1>&2 -echo "-----------------------------------------------------------" 1>&2 - echo "Test Invalid" -output_ppm=${tmpdir}/output.ppm +. ${srcdir}/test-invalid.inc # multiple functions -pamarith -add -subtract testimg.ppm testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 1" - test -s ${output_ppm}; echo " "$? -pamarith -multiply -divide testimg.ppm testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 2" - test -s ${output_ppm}; echo " "$? -pamarith -difference -minimum testimg.ppm testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 3" - test -s ${output_ppm}; echo " "$? -pamarith -maximum -mean testimg.ppm testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 4" - test -s ${output_ppm}; echo " "$? -pamarith -compare -and testimg.ppm testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 5" - test -s ${output_ppm}; echo " "$? -pamarith -compare -equal testimg.ppm testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 6" - test -s ${output_ppm}; echo " "$? -pamarith -or -nand testimg.ppm testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 7" - test -s ${output_ppm}; echo " "$? -pamarith -nor -xor testimg.ppm testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 8" - test -s ${output_ppm}; echo " "$? -pamarith -shiftleft -shiftright testimg.ppm testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 9" - test -s ${output_ppm}; echo " "$? +invCmd "pamarith -add -subtract testimg.ppm testimg.ppm" +invCmd "pamarith -multiply -divide testimg.ppm testimg.ppm" +invCmd "pamarith -difference -minimum testimg.ppm testimg.ppm" +invCmd "pamarith -maximum -mean testimg.ppm testimg.ppm" +invCmd "pamarith -compare -and testimg.ppm testimg.ppm" +invCmd "pamarith -compare -equal testimg.ppm testimg.ppm" +invCmd "pamarith -or -nand testimg.ppm testimg.ppm" +invCmd "pamarith -nor -xor testimg.ppm testimg.ppm" +invCmd "pamarith -shiftleft -shiftright testimg.ppm testimg.ppm" # -add does not take a value -pamarith -add=1 testimg.ppm testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 10" - test -s ${output_ppm}; echo " "$? +invCmd "pamarith -add=1 testimg.ppm testimg.ppm" # No function -pamarith -plain testimg.ppm testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 11" - test -s ${output_ppm}; echo " "$? - -pamarith testimg.ppm testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 12" - test -s ${output_ppm}; echo " "$? +invCmd "pamarith -plain testimg.ppm testimg.ppm" +invCmd "pamarith testimg.ppm testimg.ppm" # Just one input image file -pamarith -add testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 13" - test -s ${output_ppm}; echo " "$? +invCmd "pamarith -add testimg.ppm" # No input image file -pamarith -add > ${output_ppm} || \ - echo -n "Expected failure 14" - test -s ${output_ppm}; echo " "$? +invCmd "pamarith -add" # Input images with different depth (number of planes) -pamchannel -infile testimg.ppm 0 1 | \ - pamarith -add testimg.ppm - > ${output_ppm} || \ - echo -n "Expected failure 15" - test -s ${output_ppm}; echo " "$? +input1_pam=${tmpdir}/input1.pam +pamchannel -infile testimg.ppm 0 1 > ${input1_pam} +invCmd "pamarith -add testimg.ppm ${input1_pam}" +rm ${input1_pam} # Input images with different x/y dimensions -pamarith -add testimg.ppm testgrid.pbm > ${output_ppm} || \ - echo -n "Expected failure 16" - test -s ${output_ppm}; echo " "$? +invCmd "pamarith -add testimg.ppm testgrid.pbm" -pamenlarge -xscale=2 testgrid.pbm | \ - pamarith -add testgrid.pbm - > ${output_ppm} || \ - echo -n "Expected failure 17" - test -s ${output_ppm}; echo " "$? +input1_pbm=${tmpdir}/input1.pbm +input2_pbm=${tmpdir}/input2.pbm -pamenlarge -yscale=3 testgrid.pbm | \ - pamarith -add testgrid.pbm - > ${output_ppm} || \ - echo -n "Expected failure 18" - test -s ${output_ppm}; echo " "$? +pamenlarge -xscale=2 testgrid.pbm > ${input1_pbm} +invCmd "pamarith -add testgrid.pbm ${input1_pbm}" +rm ${input1_pbm} +pamenlarge -yscale=3 testgrid.pbm > ${input2_pbm} +invCmd "pamarith -add testgrid.pbm ${input2_pbm}" +rm ${input2_pbm} # Invalid usage of -closeness -pamarith -equal -closeness=100.1 testgrid.pbm > ${output_ppm} || \ - echo -n "Expected failure 19" - test -s ${output_ppm}; echo " "$? -pamarith -equal -closeness=-10 testgrid.pbm > ${output_ppm} || \ - echo -n "Expected failure 20" - test -s ${output_ppm}; echo " "$? -pamarith -closeness -equal testgrid.pbm > ${output_ppm} || \ - echo -n "Expected failure 21" - test -s ${output_ppm}; echo " "$? -pamarith -compare -closeness=10 testgrid.pbm > ${output_ppm} || \ - echo -n "Expected failure 22" - test -s ${output_ppm}; echo " "$? +invCmd "pamarith -equal -closeness=100.1 testgrid.pbm" +invCmd "pamarith -equal -closeness=-10 testgrid.pbm" +invCmd "pamarith -closeness -equal testgrid.pbm" +invCmd "pamarith -compare -closeness=10 testgrid.pbm" # Bit string functions # Create PGM test input @@ -230,52 +186,27 @@ input3_pgm=${tmpdir}/input3.pgm input4_pgm=${tmpdir}/input4.pgm input5_pgm=${tmpdir}/input5.pgm -pgmmake -maxval=4095 1.0 3 1 > ${input3_pgm} +pgmmake -maxval=4095 1.0 3 1 > ${input3_pgm} pgmmake -maxval=4096 1.0 3 1 > ${input4_pgm} pgmmake -maxval=8191 1.0 3 1 > ${input5_pgm} # Bit string functions - Maxval must match -pamarith -and ${input3_pgm} ${input5_pgm} > ${output_ppm} || \ - echo -n "Expected failure 23" - test -s ${output_ppm}; echo " "$? -pamarith -or ${input3_pgm} ${input5_pgm} > ${output_ppm} || \ - echo -n "Expected failure 24" - test -s ${output_ppm}; echo " "$? -pamarith -nand ${input3_pgm} ${input5_pgm} > ${output_ppm} || \ - echo -n "Expected failure 25" - test -s ${output_ppm}; echo " "$? -pamarith -nor ${input3_pgm} ${input5_pgm} > ${output_ppm} || \ - echo -n "Expected failure 26" - test -s ${output_ppm}; echo " "$? -pamarith -xor ${input3_pgm} ${input5_pgm} > ${output_ppm} || \ - echo -n "Expected failure 27" - test -s ${output_ppm}; echo " "$? +invCmd "pamarith -and ${input3_pgm} ${input5_pgm}" +invCmd "pamarith -or ${input3_pgm} ${input5_pgm}" +invCmd "pamarith -nand ${input3_pgm} ${input5_pgm}" +invCmd "pamarith -nor ${input3_pgm} ${input5_pgm}" +invCmd "pamarith -xor ${input3_pgm} ${input5_pgm}" # Bit string functions - Maxval must be 2^n -1 -pamarith -and ${input4_pgm} ${input4_pgm} > ${output_ppm} || \ - echo -n "Expected failure 28" - test -s ${output_ppm}; echo " "$? -pamarith -or ${input4_pgm} ${input4_pgm} > ${output_ppm} || \ - echo -n "Expected failure 29" - test -s ${output_ppm}; echo " "$? -pamarith -nand ${input4_pgm} ${input4_pgm} > ${output_ppm} || \ - echo -n "Expected failure 30" - test -s ${output_ppm}; echo " "$? -pamarith -nor ${input4_pgm} ${input4_pgm} > ${output_ppm} || \ - echo -n "Expected failure 31" - test -s ${output_ppm}; echo " "$? -pamarith -xor ${input4_pgm} ${input4_pgm} > ${output_ppm} || \ - echo -n "Expected failure 32" - test -s ${output_ppm}; echo " "$? - -pamarith -shiftleft ${input4_pgm} ${input4_pgm} > ${output_ppm} || \ - echo -n "Expected failure 33" - test -s ${output_ppm}; echo " "$? -pamarith -shiftright ${input4_pgm} ${input4_pgm} > ${output_ppm} || \ - echo -n "Expected failure 34" - test -s ${output_ppm}; echo " "$? +invCmd "pamarith -and ${input4_pgm} ${input4_pgm}" +invCmd "pamarith -or ${input4_pgm} ${input4_pgm}" +invCmd "pamarith -nand ${input4_pgm} ${input4_pgm}" +invCmd "pamarith -nor ${input4_pgm} ${input4_pgm}" +invCmd "pamarith -xor ${input4_pgm} ${input4_pgm}" +invCmd "pamarith -shiftleft ${input4_pgm} ${input4_pgm}" +invCmd "pamarith -shiftright ${input4_pgm} ${input4_pgm}" rm ${input3_pgm} ${input4_pgm} ${input5_pgm} @@ -283,33 +214,15 @@ rm ${input3_pgm} ${input4_pgm} ${input5_pgm} # Only the functions that are commutative and associative allow # three or more inputs. -pamarith -subtract testimg.ppm testimg.ppm testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 35" - test -s ${output_ppm}; echo " "$? -pamarith -divide testimg.ppm testimg.ppm testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 36" - test -s ${output_ppm}; echo " "$? -pamarith -compare testimg.ppm testimg.ppm testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 37" - test -s ${output_ppm}; echo " "$? -pamarith -difference testimg.ppm testimg.ppm testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 38" - test -s ${output_ppm}; echo " "$? -pamarith -shiftleft testimg.ppm testimg.ppm testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 39" - test -s ${output_ppm}; echo " "$? -pamarith -shiftright testimg.ppm testimg.ppm testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 40" - test -s ${output_ppm}; echo " "$? +invCmd "pamarith -subtract testimg.ppm testimg.ppm testimg.ppm" +invCmd "pamarith -divide testimg.ppm testimg.ppm testimg.ppm" +invCmd "pamarith -compare testimg.ppm testimg.ppm testimg.ppm" +invCmd "pamarith -difference testimg.ppm testimg.ppm testimg.ppm" +invCmd "pamarith -shiftleft testimg.ppm testimg.ppm testimg.ppm" +invCmd "pamarith -shiftright testimg.ppm testimg.ppm testimg.ppm" # Currently -equal and -mean do not allow more than two input images. # These two cases should be removed once improvements are made. -pamarith -equal testgrid.pbm testgrid.pbm testgrid.pbm > ${output_ppm} || \ - echo -n "Expected failure 41" - test -s ${output_ppm}; echo " "$? -pamarith -mean testgrid.pbm testgrid.pbm testgrid.pbm > ${output_ppm} || \ - echo -n "Expected failure 42" - test -s ${output_ppm}; echo " "$? - -rm ${output_ppm} +invCmd "pamarith -equal testgrid.pbm testgrid.pbm testgrid.pbm" +invCmd "pamarith -mean testgrid.pbm testgrid.pbm testgrid.pbm" diff --git a/test/pambackground.test b/test/pambackground.test index 522f4823..eca9cc93 100755 --- a/test/pambackground.test +++ b/test/pambackground.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pambackground # Also requires: pamgradient pamseq pbmmake pnmmargin pnmremap pnmtile pnmpad diff --git a/test/pambrighten.ok b/test/pambrighten.ok index 6c58b4c9..8dc9e71e 100644 --- a/test/pambrighten.ok +++ b/test/pambrighten.ok @@ -78,19 +78,11 @@ Test 4: Should print 3990234518 268 six times 3990234518 268 3990234518 268 3990234518 268 -Test Error: Should print 1 six times -1 -1 -1 -1 -1 -1 -Test Error: Should print 99 followed by 1, four times -99 -1 -99 -1 -99 -1 -99 -1 +Test Invalid +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) +Expected failure 5 (no output) +Expected failure 6 (no output) +Expected failure 7 (no output) diff --git a/test/pambrighten.test b/test/pambrighten.test index 3e1a3eb1..d79ad583 100755 --- a/test/pambrighten.test +++ b/test/pambrighten.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pambrighten # Also requires: pgmramp @@ -10,7 +10,7 @@ cat > ${input_ppm} << EOF P3 8 1 255 -0 0 0 0 0 100 0 100 0 0 100 100 100 0 0 100 0 100 100 100 0 100 100 100 +0 0 0 0 0 100 0 100 0 0 100 100 100 0 0 100 0 100 100 100 0 100 100 100 EOF # Test 1 @@ -50,50 +50,14 @@ pambrighten -s +200 ${input_pgm} | cksum rm ${input_pgm} +echo "Test Invalid" -# Test 2 -# These should all fail. +. ${srcdir}/test-invalid.inc -echo "Invalid command-line argument combinations." 1>&2 -echo "Error messages should appear below the line." 1>&2 -echo "-----------------------------------------------------------" 1>&2 - -echo "Test Error: Should print 1 six times" - -output_ppm=${tmpdir}/output.ppm - -pambrighten -v -120 testimg.ppm > ${output_ppm} -echo $? -test -s ${output_ppm} -echo $? -pambrighten -s -120 testimg.ppm > ${output_ppm} -echo $? -test -s ${output_ppm} -echo $? -pambrighten 10 testimg.ppm > ${output_ppm} -echo $? -test -s ${output_ppm} -echo $? - - -echo "Test Error: Should print 99 followed by 1, four times" - -pambrighten -s 1.20 testimg.ppm > ${output_ppm} -echo $? -test -s ${output_ppm} -echo $? -pambrighten -v 10.5 testimg.ppm > ${output_ppm} -echo $? -test -s ${output_ppm} -echo $? -pambrighten -v testimg.ppm > ${output_ppm} -echo $? -test -s ${output_ppm} -echo $? -pambrighten -s testimg.ppm > ${output_ppm} -echo $? -test -s ${output_ppm} -echo $? - - -rm -f ${output_ppm} +invCmd "pambrighten -v -120 testimg.ppm" +invCmd "pambrighten -s -120 testimg.ppm" +invCmd "pambrighten 10 testimg.ppm" +invCmd "pambrighten -s 1.20 testimg.ppm" +invCmd "pambrighten -v 10.5 testimg.ppm" +invCmd "pambrighten -v testimg.ppm" +invCmd "pambrighten -s testimg.ppm" diff --git a/test/pamcat1.ok b/test/pamcat1.ok new file mode 100644 index 00000000..630b635f --- /dev/null +++ b/test/pamcat1.ok @@ -0,0 +1,150 @@ +Test 1. Should print 15135078 29, then 0 fourteen times +15135078 29 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +Test 2. Should print 1957849403 59, 0 six times, 1 once +1957849403 59 +0 +0 +0 +0 +0 +0 +1 +Test 3. Should print 2673197404 69, 0 six times, 1 once +2673197404 69 +0 +0 +0 +0 +0 +0 +1 +Test 4. Should print 2285402562 36, then 0 twelve times +2285402562 36 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +Test 5. Should print 1836757613 62, 0 six times, 1 once +1836757613 62 +0 +0 +0 +0 +0 +0 +1 +Test 6. Should print 3601245348 137, 0 six times, 1 once +3601245348 137 +0 +0 +0 +0 +0 +0 +1 +Test 7. Should print 1572996771 71, then 0 twelve times +1572996771 71 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +Test 8. Should print 270413826 252, 0 six times, 1 once +270413826 252 +0 +0 +0 +0 +0 +0 +1 +Test 9. Should print 2942772630 192, 0 six times, 1 once +2942772630 192 +0 +0 +0 +0 +0 +0 +1 +Test 10. Should print 2700536985 95, then 0 twelve times +2700536985 95 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +Test 11. Should print 2193235886 195, 0 eight times, 1 once +2193235886 195 +0 +0 +0 +0 +0 +0 +0 +0 +1 +Test 12. Should print 2773166369 245, 0 nine times, 1 once +2773166369 245 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +Test Invalid +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) +Expected failure 5 (no output) +Expected failure 6 (no output) +Expected failure 7 (no output) +Expected failure 8 (no output) +Expected failure 9 (no output) +Expected failure 10 (no output) +Expected failure 11 (no output) +Expected failure 12 (no output) +Expected failure 13 (no output) +Expected failure 14 (no output) diff --git a/test/pamcat1.test b/test/pamcat1.test new file mode 100755 index 00000000..9480228c --- /dev/null +++ b/test/pamcat1.test @@ -0,0 +1,215 @@ +#! /bin/sh +# This script tests: pamcat +# Also requires: pbmmake pgmmake ppmmake pamseq pamrestack + +tmpdir=${tmpdir:-/tmp} +check10x10_pbm=${tmpdir}/check10x10.pbm +check40x10_pbm=${tmpdir}/check40x10.pbm +check10x30_pbm=${tmpdir}/check10x30.pbm + +gray5x5_pgm=${tmpdir}/gray5x5.pgm +gray10x5_pgm=${tmpdir}/gray10x5.pgm +gray5x25_pgm=${tmpdir}/gray5x25.pgm + +yellow4x5_ppm=${tmpdir}/yellow4x5.ppm +yellow16x5_ppm=${tmpdir}/yellow16x5.ppm +yellow4x15_ppm=${tmpdir}/yellow4x15.ppm + +seq2_4h_pam=${tmpdir}/seq2_4h.pam +seq2_4h4_pam=${tmpdir}/seq2_4h4.pam +seq2_4v_pam=${tmpdir}/seq2_4v.pam +seq2_4v3_pam=${tmpdir}/seq2_4v3.pam + + +echo "Test 1. Should print 15135078 29, then 0 fourteen times" + +pbmmake -g 10 10 | tee ${check10x10_pbm} | cksum +for opt in "-leftright" "-lr" "-lr -jtop" "-lr -jcenter" "-lr -jbottom" \ + "-lr -white" "-lr -black" \ + "-topbottom" "-tb" "-tb -jleft" "-tb -jcenter" "-tb --jright" \ + "-tb -white" "-tb -black" + do + pamcat ${opt} ${check10x10_pbm} | cmp -s ${check10x10_pbm} - ; echo $? + done + + +echo "Test 2. Should print 1957849403 59, 0 six times, 1 once" +pbmmake -g 40 10 | tee ${check40x10_pbm} | cksum +for opt in "-leftright" "-lr -jtop" "-lr -jcenter" "-lr -jbottom" \ + "-lr -white" "-lr -black" \ + "-tb" + do + pamcat ${opt} ${check10x10_pbm} ${check10x10_pbm} \ + ${check10x10_pbm} ${check10x10_pbm} | \ + cmp -s ${check40x10_pbm} - ; echo $? + done + + +echo "Test 3. Should print 2673197404 69, 0 six times, 1 once" +pbmmake -g 10 30 | tee ${check10x30_pbm} | cksum +for opt in "-topbottom" "-tb -jleft" "-tb -jcenter" "-tb --jright" \ + "-tb -white" "-tb -black" \ + "-lr" + do + pamcat ${opt} ${check10x10_pbm} ${check10x10_pbm} ${check10x10_pbm} |\ + cmp -s ${check10x30_pbm} - ; echo $? + done + +rm ${check10x10_pbm} ${check40x10_pbm} ${check10x30_pbm} + + +echo "Test 4. Should print 2285402562 36, then 0 twelve times" + +pgmmake 0.125 5 5 | tee ${gray5x5_pgm} | cksum +for opt in "-leftright" "-lr -jtop" "-lr -jcenter" "-lr -jbottom" \ + "-lr -white" "-lr -black" \ + "-topbottom" "-tb -jleft" "-tb -jcenter" "-tb --jright" \ + "-tb -white" "-tb -black" + do + pamcat ${opt} ${gray5x5_pgm} | cmp -s ${gray5x5_pgm} - ; echo $? + done + + +echo "Test 5. Should print 1836757613 62, 0 six times, 1 once" +pgmmake 0.125 10 5 | tee ${gray10x5_pgm} | cksum +for opt in "-leftright" "-lr -jtop" "-lr -jcenter" "-lr -jbottom" \ + "-lr -white" "-lr -black" \ + "-tb" + do + pamcat ${opt} ${gray5x5_pgm} ${gray5x5_pgm} |\ + cmp -s ${gray10x5_pgm} - ; echo $? + done + + +echo "Test 6. Should print 3601245348 137, 0 six times, 1 once" +pgmmake 0.125 5 25 | tee ${gray5x25_pgm} | cksum +for opt in "-topbottom" "-tb -jleft" "-tb -jcenter" "-tb --jright" \ + "-tb -white" "-tb -black" \ + "-lr" + do + pamcat ${opt} ${gray5x5_pgm} ${gray5x5_pgm} ${gray5x5_pgm} \ + ${gray5x5_pgm} ${gray5x5_pgm} |\ + cmp -s ${gray5x25_pgm} - ; echo $? + done + + +rm ${gray5x5_pgm} ${gray10x5_pgm} ${gray5x25_pgm} + + +echo "Test 7. Should print 1572996771 71, then 0 twelve times" +ppmmake rgb:255/255/1 4 5 | tee ${yellow4x5_ppm} | cksum +for opt in "-leftright" "-lr -jtop" "-lr -jcenter" "-lr -jbottom" \ + "-lr -white" "-lr -black" \ + "-topbottom" "-tb -jleft" "-tb -jcenter" "-tb --jright" \ + "-tb -white" "-tb -black" + do + pamcat ${opt} ${yellow4x5_ppm} |\ + cmp -s ${yellow4x5_ppm} - ; echo $? + done + + +echo "Test 8. Should print 270413826 252, 0 six times, 1 once" +ppmmake rgb:255/255/1 16 5 | tee ${yellow16x5_ppm} | cksum +for opt in "-leftright" "-lr -jtop" "-lr -jcenter" "-lr -jbottom" \ + "-lr -white" "-lr -black" \ + "-tb" + do + pamcat ${opt} ${yellow4x5_ppm} ${yellow4x5_ppm} \ + ${yellow4x5_ppm} ${yellow4x5_ppm} |\ + cmp -s ${yellow16x5_ppm} - ; echo $? + done + + +echo "Test 9. Should print 2942772630 192, 0 six times, 1 once" +ppmmake rgb:255/255/1 4 15 | tee ${yellow4x15_ppm} | cksum +for opt in "-topbottom" "-tb -jleft" "-tb -jcenter" "-tb --jright" \ + "-tb -white" "-tb -black" \ + "-lr" + do + pamcat ${opt} ${yellow4x5_ppm} ${yellow4x5_ppm} ${yellow4x5_ppm} |\ + cmp -s ${yellow4x15_ppm} - ; echo $? + done + +rm ${yellow4x5_ppm} ${yellow16x5_ppm} ${yellow4x15_ppm} + + +echo "Test 10. Should print 2700536985 95, then 0 twelve times" +pamseq 2 4 | tee ${seq2_4h_pam} | cksum +for opt in "-leftright" "-lr -jtop" "-lr -jcenter" "-lr -jbottom" \ + "-lr -white" "-lr -black" \ + "-topbottom" "-tb -jleft" "-tb -jcenter" "-tb --jright" \ + "-tb -white" "-tb -black" + do + pamcat ${opt} ${seq2_4h_pam} |\ + cmp -s ${seq2_4h_pam} - ; echo $? + done + + +echo "Test 11. Should print 2193235886 195, 0 eight times, 1 once" +pamrestack -width=1 ${seq2_4h_pam} | tee ${seq2_4v_pam} |\ + pamenlarge -xscale=3 |\ + tee ${seq2_4v3_pam} | cksum +pamcat -lr ${seq2_4v_pam} ${seq2_4v_pam} | pamcat -lr - ${seq2_4v_pam} |\ + cmp -s ${seq2_4v3_pam} - ; echo $? +pamcat -lr ${seq2_4v_pam} | pamcat -lr - ${seq2_4v_pam} ${seq2_4v_pam} |\ + cmp -s ${seq2_4v3_pam} - ; echo $? +for opt in "-leftright" "-lr -jtop" "-lr -jcenter" "-lr -jbottom" \ + "-lr -white" "-lr -black" \ + "-topbottom" + do + pamcat ${opt} ${seq2_4v_pam} ${seq2_4v_pam} ${seq2_4v_pam} |\ + cmp -s ${seq2_4v3_pam} - ; echo $? + done + + +echo "Test 12. Should print 2773166369 245, 0 nine times, 1 once" +pamenlarge -yscale 4 ${seq2_4h_pam} | tee ${seq2_4h4_pam} | cksum +pamcat -tb ${seq2_4h_pam} |\ + pamcat -tb - ${seq2_4h_pam} ${seq2_4h_pam} ${seq2_4h_pam} |\ + cmp -s ${seq2_4h4_pam} - ; echo $? +pamcat -tb ${seq2_4h_pam} ${seq2_4h_pam} |\ + pamcat -tb - ${seq2_4h_pam} ${seq2_4h_pam} |\ + cmp -s ${seq2_4h4_pam} - ; echo $? +pamcat -tb ${seq2_4h_pam} ${seq2_4h_pam} ${seq2_4h_pam}|\ + pamcat -tb - ${seq2_4h_pam} |\ + cmp -s ${seq2_4h4_pam} - ; echo $? +for opt in "-topbottom" "-tb -jleft" "-tb -jcenter" "-tb --jright" \ + "-tb -white" "-tb -black" \ + "-leftright" + do + pamcat ${opt} ${seq2_4h_pam} ${seq2_4h_pam} ${seq2_4h_pam} ${seq2_4h_pam} |\ + cmp -s ${seq2_4h4_pam} - ; echo $? + done + +rm ${seq2_4h_pam} ${seq2_4v_pam} ${seq2_4v3_pam} ${seq2_4h4_pam} + + + +echo "Test Invalid" + +. ${srcdir}/test-invalid.inc + +# direction not specified +invCmd "pamcat testgrid.pbm testimg.ppm" + +# both directions specified +invCmd "pamcat -topbottom -leftright testgrid.pbm testimg.ppm" + +# both pad colors specified +invCmd "pamcat -topbottom -white -black testgrid.pbm testimg.ppm" +invCmd "pamcat -lr -jtop -jbottom testgrid.pbm testimg.ppm" +invCmd "pamcat -lr -jtop -jcenter testgrid.pbm testimg.ppm" +invCmd "pamcat -lr -jcenter -jbottom testgrid.pbm testimg.ppm" +invCmd "pamcat -tb -jleft -jright testgrid.pbm testimg.ppm" +invCmd "pamcat -tb -jleft -jcenter testgrid.pbm testimg.ppm" +invCmd "pamcat -tb -jcenter -jright testgrid.pbm testimg.ppm" +invCmd "pamcat -lr -jleft testgrid.pbm testimg.ppm" +invCmd "pamcat -lr -jright testgrid.pbm testimg.ppm" +invCmd "pamcat -tb -jtop testgrid.pbm testimg.ppm" +invCmd "pamcat -tb -jbottom testgrid.pbm testimg.ppm" + +# more than one input image from standard input +cat testgrid.pbm | pamcat -lr - - testimg.ppm > ${test_out} || \ + printf "Expected failure 14 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} diff --git a/test/pamcat2.ok b/test/pamcat2.ok new file mode 100644 index 00000000..549fe97a --- /dev/null +++ b/test/pamcat2.ok @@ -0,0 +1,93 @@ +Test 1. +P1 +1 1 +0 +P1 +1 1 +0 +P1 +1 1 +1 +P1 +1 1 +0 +Test 2. +P1 +7 5 +0000000 +1000001 +1000001 +1000001 +1000001 +P1 +7 5 +1000001 +1000001 +0000000 +1000001 +1000001 +P1 +7 5 +1000001 +1000001 +1000001 +1000001 +0000000 +P1 +7 5 +1000001 +1000001 +0000000 +1000001 +1000001 +P1 +5 7 +01111 +00000 +00000 +00000 +00000 +00000 +01111 +P1 +5 7 +11011 +00000 +00000 +00000 +00000 +00000 +11011 +P1 +5 7 +11110 +00000 +00000 +00000 +00000 +00000 +11110 +P1 +5 7 +11011 +00000 +00000 +00000 +00000 +00000 +11011 +Test 3. +1715060535 12 +1715060535 12 +3621575043 12 +3621575043 12 +Test 4. +1972597727 14 +1972597727 14 +Test 5. +2175144709 10456 +2175144709 10456 +2175144709 10456 +609107534 10444 +609107534 10444 +609107534 10444 diff --git a/test/pamcat2.test b/test/pamcat2.test new file mode 100755 index 00000000..ecc7ee5e --- /dev/null +++ b/test/pamcat2.test @@ -0,0 +1,64 @@ +#! /bin/sh +# This script tests: pamcat +# Also requires: pbmmake pamflip + +tmpdir=${tmpdir:-/tmp} +dotw_pbm=${tmpdir}/dotw.pbm +dotb_pbm=${tmpdir}/dotb.pbm +check5x5_pbm=${tmpdir}/check5x5.pbm +dot_ppm=${tmpdir}/dot.ppm + +echo "Test 1." +pbmmake -w 1 1 | tee ${dotw_pbm} | pamcat -tb -plain +pamcat -lr -plain ${dotw_pbm} +pbmmake -b 1 1 | tee ${dotb_pbm} | pamcat -tb -plain +pamcat -tb -plain ${dotw_pbm} + +echo "Test 2." + +pbmmake -w 5 5 > ${check5x5_pbm} + +pamcat -lr -jt -black ${dotw_pbm} ${check5x5_pbm} ${dotw_pbm} -plain +pamcat -lr -jc -black ${dotw_pbm} ${check5x5_pbm} ${dotw_pbm} -plain +pamcat -lr -jb -black ${dotw_pbm} ${check5x5_pbm} ${dotw_pbm} -plain +pamcat -lr -black ${dotw_pbm} ${check5x5_pbm} ${dotw_pbm} -plain + +pamcat -tb -jl -black ${dotw_pbm} ${check5x5_pbm} ${dotw_pbm} -plain +pamcat -tb -jc -black ${dotw_pbm} ${check5x5_pbm} ${dotw_pbm} -plain +pamcat -tb -jr -black ${dotw_pbm} ${check5x5_pbm} ${dotw_pbm} -plain +pamcat -tb -black ${dotw_pbm} ${check5x5_pbm} ${dotw_pbm} -plain + +rm ${dotw_pbm} + +echo "Test 3." +pbmmake -b 1 1 > ${dotb_pbm} + +pamcat -lr -jt -white ${dotb_pbm} ${check5x5_pbm} ${dotb_pbm} | cksum +pamcat -lr -jb -white ${dotb_pbm} ${check5x5_pbm} ${dotb_pbm} |\ + pamflip -tb | cksum +pamcat -tb -jl -white ${dotb_pbm} ${check5x5_pbm} ${dotb_pbm} |\ + pamflip -ccw | cksum +pamcat -tb -jr -white ${dotb_pbm} ${check5x5_pbm} ${dotb_pbm} |\ + pamflip -cw | cksum + +rm ${dotb_pbm} +rm ${check5x5_pbm} + + +echo "Test 4." +ppmmake rgb:20/40/d0 1 1 | tee ${dot_ppm} | pamcat -lr | cksum +pamcat -tb ${dot_ppm} | cksum + +echo "Test 5." +for just in -jtop -jcenter -jbottom +do +pamcat -lr ${just} ${dot_ppm} maze.pbm ${dot_ppm} | cksum +done + +for just in -jleft -jcenter -jright +do +pamcat -tb ${just} ${dot_ppm} maze.pbm ${dot_ppm} | cksum +done + +rm ${dot_ppm} + diff --git a/test/pamcat3.ok b/test/pamcat3.ok new file mode 100644 index 00000000..768f6f1e --- /dev/null +++ b/test/pamcat3.ok @@ -0,0 +1,19 @@ +Test 1. Should print 585134073 133221 four times +585134073 133221 +585134073 133221 +585134073 133221 +585134073 133221 +Test 2. Should print 1331083756 152559 three times +1331083756 152559 +1331083756 152559 +1331083756 152559 +Test Invalid +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) +Expected failure 5 (no output) +Expected failure 6 (no output) +Expected failure 7 (no output) +Expected failure 8 (no output) +Expected failure 9 (no output) diff --git a/test/pamcat3.test b/test/pamcat3.test new file mode 100755 index 00000000..fb89c3f6 --- /dev/null +++ b/test/pamcat3.test @@ -0,0 +1,97 @@ +#! /bin/sh +# This script tests: pamcat +# Also requires: + +tmpdir=${tmpdir:-/tmp} +list=${tmpdir}/list +list2=${tmpdir}/list2 +list3=${tmpdir}/list3 +liste1=${tmpdir}/liste1 +liste2=${tmpdir}/liste2 +liste3=${tmpdir}/liste3 +files="maze.pbm testgrid.pbm testimg.ppm" + +ls ${files} | tee ${list} | awk '{print ""; print $0; print ""}' > ${list3} +sed 's/maze.pbm/-/' ${list} > ${list2} + +echo "Test 1. Should print 585134073 133221 four times" +pamcat -lr -jt ${files} | cksum +pamcat -lr -jt -listfile=${list} | cksum +cat maze.pbm | pamcat -lr -jt -listfile=${list2} | cksum +pamcat -lr -jt -listfile=${list3} | cksum + +echo "Test 2. Should print 1331083756 152559 three times" +pamcat -tb -jl ${files} | cksum +pamcat -tb -jl -listfile=${list} | cksum +cat ${list} | pamcat -tb -jl -listfile=- | cksum + +echo "Test Invalid" + +test_out=${tmpdir}/test_out + +echo 1>&2 +echo "Invalid command-line argument combinations & listfile content." 1>&2 +echo "Error messages should appear below the line." 1>&2 +echo "-----------------------------------------------------------" 1>&2 + +# listfile not specified +pamcat -lr -listfile > ${test_out} || \ + printf "Expected failure 1 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +# listfile does not exist +pamcat -lr -listfile=`mktemp -u` > ${test_out} || \ + printf "Expected failure 2 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +# listfile empty +pamcat -lr -listfile=/dev/null > ${test_out} || \ + printf "Expected failure 3 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +# listfile from stdin, empty +cat /dev/null | pamcat -lr -listfile=- > ${test_out} || \ + printf "Expected failure 4 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +# Files provided from command line in addition to listfile +pamcat -lr -listfile=${list} testgrid.pbm testgrid.pbm > ${test_out} || \ + printf "Expected failure 5 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +# "-" (stdin) provided from command line in addition to listfile +pamcat -lr -listfile=${list} - > ${test_out} || \ + printf "Expected failure 6 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +# listfile has nothing but blank lines +sed 's/^.*$//' ${list3} > ${liste1} +pamcat -lr -listfile=${liste1} > ${test_out} || \ + printf "Expected failure 7 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} ${liste1} + +# Non-existing file in listfile +( cat ${list} ; mktemp -u ) > ${liste2} +pamcat -lr -listfile=${liste2} > ${test_out} || \ + printf "Expected failure 8 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} ${liste2} + +# Multiple instances of "-" in listfile +( echo "-"; cat ${list}; echo "-"; echo "-" ) > ${liste3} +pamcat -lr -listfile=${liste3} > ${test_out} || \ + printf "Expected failure 9 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} ${liste3} + + +rm ${list} ${list2} ${list3} + + diff --git a/test/pamchannel.ok b/test/pamchannel.ok index 41d3f890..72b84354 100644 --- a/test/pamchannel.ok +++ b/test/pamchannel.ok @@ -1,10 +1,12 @@ -Test 1 +Test 1:red-channel Should produce 1571496937 33838 1571496937 33838 -Test 2 +Test 2:green-channel Should produce 394856971 33838 394856971 33838 -Test 3 +Test 3:blue-channel Should produce 3164158573 33838 3164158573 33838 +Test 4:single-channel Should produce 281226646 481 +281226646 481 Test Invalid -Expected failure 1 1 -Expected failure 2 1 -Expected failure 3 1 +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) diff --git a/test/pamchannel.test b/test/pamchannel.test index 2e017ef2..f3399343 100755 --- a/test/pamchannel.test +++ b/test/pamchannel.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamchannel # Also requires: pamtopam pamtopnm @@ -12,27 +12,23 @@ # 3164158573 33838 testimg.blu -# Test 1. red channel -# Should produce 1571496937 33838 -echo "Test 1" - +echo "Test 1:red-channel Should produce 1571496937 33838" pamchannel -infile testimg.ppm 0 | \ pamtopnm --assume | cksum -# Test 2. green channel -# Should produce 394856971 33838 -echo "Test 2" - +echo "Test 2:green-channel Should produce 394856971 33838" pamchannel -infile testimg.ppm -tupletype="GRAYSCALE" 1 | \ pamtopnm | cksum -# Test 3. blue channel -# Should produce 3164158573 33838 -echo "Test 3" +echo "Test 3:blue-channel Should produce 3164158573 33838" pamchannel -infile testimg.ppm 2 | \ pamtopnm --assume | cksum +echo "Test 4:single-channel Should produce 281226646 481" +pamchannel -infile maze.pbm 0 | \ + pamtopnm --assume | cksum + # Test invalid: specified channel does not exist echo 1>&2 @@ -45,13 +41,8 @@ test_out=${tmpdir}/test_out echo "Test Invalid" -pamchannel -infile testgrid.pbm 1 > ${test_out} || \ - echo -n "Expected failure 1"; test -s ${test_out}; echo " "$? - -pamchannel -infile testimg.ppm 3 > ${test_out} || \ - echo -n "Expected failure 2"; test -s ${test_out}; echo " "$? - -pamtopam testimg.ppm | pamchannel -infile=- 4 > ${test_out} || \ - echo -n "Expected failure 3"; test -s ${test_out}; echo " "$? +. ${srcdir}/test-invalid.inc -rm ${test_out} \ No newline at end of file +invCmd "pamchannel -infile testgrid.pbm 1" +invCmd "pamchannel -infile testimg.ppm 3" +invCmd "pamtopam testimg.ppm | pamchannel -infile=- 4" diff --git a/test/pamcrater.ok b/test/pamcrater.ok index a5571f35..53faebf2 100644 --- a/test/pamcrater.ok +++ b/test/pamcrater.ok @@ -7,7 +7,7 @@ Test 2. 2 2 Test Invalid. -Expected failure 1 1 -Expected failure 2 1 -Expected failure 3 1 -Expected failure 4 1 +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) diff --git a/test/pamcrater.test b/test/pamcrater.test index ba10ca24..5362bde3 100755 --- a/test/pamcrater.test +++ b/test/pamcrater.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamcrater pamshadedrelief # Also requires: pamstack pamvalidate pamcut pamflip @@ -52,27 +52,17 @@ pamshadedrelief ${test100_pam} > ${testshaded_pam} pamcut -top=$((128 - 99)) -height=1 ${testshaded_pam} | cksum ) | uniq -c | awk '{print $1}' -rm ${testshaded_pam} ${test100_pam} +rm ${testshaded_pam} ${test150_pam} echo "Test Invalid." 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 +. ${srcdir}/test-invalid.inc -pamcrater -width 0 > ${test_out} || \ - echo -n "Expected failure 1"; test -s ${test_out}; echo " "$? +invCmd "pamcrater -width 0" +invCmd "pamcrater -height 0" +invCmd "pamcrater -number 0" +invCmd "pamshadedrelief -gamma 0 ${test100_pam}" -pamcrater -height 0 > ${test_out} || \ - echo -n "Expected failure 2"; test -s ${test_out}; echo " "$? - -pamcrater -number 0 > ${test_out} || \ - echo -n "Expected failure 3"; test -s ${test_out}; echo " "$? - -pamcrater -test -radius=10 | pamshadedrelief -gamma 0 > ${test_out} || \ - echo -n "Expected failure 4"; test -s ${test_out}; echo " "$? - -rm -f ${test_out} \ No newline at end of file +rm ${test100_pam} diff --git a/test/pamcut.ok b/test/pamcut.ok index 3d5c5a7f..18ed88e8 100644 --- a/test/pamcut.ok +++ b/test/pamcut.ok @@ -1,36 +1,106 @@ -Test 1. +Test 1a. Should print 0 259 0 159 227 149 260 160 twice +0 259 0 159 227 149 260 160 +0 259 0 159 227 149 260 160 +Test 1b. Should print 2958909756 124815 2958909756 124815 -Test 2. -1550940962 10933 -Test 3. +Test 2a. Should print 120 159 120 159 227 149 40 40 three times +120 159 120 159 227 149 40 40 +120 159 120 159 227 149 40 40 +120 159 120 159 227 149 40 40 +Test 2b. Should print 3876978825 4813 twice +3876978825 4813 +3876978825 4813 +Test 3a. Should print 5 5 5 5 227 149 1 1 three times +5 5 5 5 227 149 1 1 +5 5 5 5 227 149 1 1 +5 5 5 5 227 149 1 1 +Test 3b. Should print 708474423 14 708474423 14 -708474423 14 -Test 4. -659346598 80124 -659346598 80124 -659346598 80124 +Test 4a. Should print 10 216 10 138 227 149 207 129 five times +10 216 10 138 227 149 207 129 +10 216 10 138 227 149 207 129 +10 216 10 138 227 149 207 129 +10 216 10 138 227 149 207 129 +10 216 10 138 227 149 207 129 +Test 4b. Should print 659346598 80124 659346598 80124 -Test 5. -2425386270 41 -2425386270 41 -2425386270 41 -2425386270 41 -2425386270 41 -Test 6. +Test 5a. Should print 0 56 0 58 57 59 57 59 five times +0 56 0 58 57 59 57 59 +0 56 0 58 57 59 57 59 +0 56 0 58 57 59 57 59 +0 56 0 58 57 59 57 59 +0 56 0 58 57 59 57 59 +Test 5b. Should print 281226646 481 twice +281226646 481 +281226646 481 +Test 6a. Should print 5 34 5 34 50 50 30 30 +5 34 5 34 50 50 30 30 +Test 6b. Should print 3412257956 129 3412257956 129 +Test 7. Should print 284857390 12 sixteen times +284857390 12 +284857390 12 +284857390 12 +284857390 12 +284857390 12 +284857390 12 +284857390 12 +284857390 12 +284857390 12 +284857390 12 +284857390 12 +284857390 12 +284857390 12 +284857390 12 +284857390 12 +284857390 12 +Test 8. Should print 3125257619 29 four times +3125257619 29 +3125257619 29 +3125257619 29 +3125257619 29 +Test 9. Should print 3338453023 36 sixteen times +3338453023 36 +3338453023 36 +3338453023 36 +3338453023 36 +3338453023 36 +3338453023 36 +3338453023 36 +3338453023 36 +3338453023 36 +3338453023 36 +3338453023 36 +3338453023 36 +3338453023 36 +3338453023 36 +3338453023 36 +3338453023 36 +Test 10. Should print 3957742883 302 four times +3957742883 302 +3957742883 302 +3957742883 302 +3957742883 302 +Test 11. Should print 1576602925 8 four times +1576602925 8 +1576602925 8 +1576602925 8 +1576602925 8 Test Invalid -Expected failure 1 1 -Expected failure 2 1 -Expected failure 3 1 -Expected failure 4 1 -Expected failure 5 1 -Expected failure 6 1 -Expected failure 7 1 -Expected failure 8 1 -Expected failure 9 1 -Expected failure 6 1 -Expected failure 10 1 -Expected failure 11 1 -Expected failure 12 1 -Expected failure 13 1 -Expected failure 14 1 +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) +Expected failure 5 (no output) +Expected failure 6 (no output) +Expected failure 7 (no output) +Expected failure 8 (no output) +Expected failure 9 (no output) +Expected failure 10 (no output) +Expected failure 11 (no output) +Expected failure 12 (no output) +Expected failure 13 (no output) +Expected failure 14 (no output) +Expected failure 15 (no output) +Expected failure 16 (no output) +Expected failure 17 (no output) diff --git a/test/pamcut.test b/test/pamcut.test index e4d8c62f..7d60e1cd 100755 --- a/test/pamcut.test +++ b/test/pamcut.test @@ -1,109 +1,226 @@ -#! /bin/bash -# This script tests: pamcut pbmmake -# Also requires: +#! /bin/sh +# This script tests: pamcut +# Also requires: pbmmake pgmmake pamfile pnmpad pamflip -# Test 1. Should print 2958909756 124815 -echo Test 1. +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 -top 0 -left 0 -width 260 -height 160 \ - -pad testimg.ppm | cksum +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 -# Test 2. Should print 1550940962 10933 -echo Test 2. +echo "Test 2b. Should print 3876978825 4813 twice" -pamcut -top 200 -left 120 -width 40 -height 40 \ - -pad testimg.ppm | cksum +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 -# Test 3. Should print 708474423 14 twice -echo Test 3. +echo "Test 3a. Should print 5 5 5 5 227 149 1 1 three times" + +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 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 -# Test 4. Should print 659346598 80124 four times -echo Test 4. +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 5a. Should print 0 56 0 58 57 59 57 59 five times" -# Test 5. Should print 2425386270 41 five times -echo Test 5. +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 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 -pamcut testgrid.pbm | cksum +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 -# Test 6. Should print 3412257956 129 -echo Test 6. +echo "Test 5b. Should print 281226646 481 twice" -pbmmake -g 50 50 | pamcut 5 5 30 30 | cksum +pamcut -croptop 0 -cropleft 0 -cropbottom 0 -cropright 0 maze.pbm | \ + cksum +pamcut maze.pbm | cksum +test50_pbm=${tmpdir}/test50.pbm -echo "Test Invalid" +echo "Test 6a. Should print 5 34 5 34 50 50 30 30" -tmpdir=${tmpdir:-/tmp} -test_out=${tmpdir}/test_out +pbmmake -g 50 50 | tee ${test50_pbm} | pamcut -reportonly 5 5 30 30 -echo 1>&2 -echo "Invalid command-line argument combinations." 1>&2 -echo "Error messages should appear below the line." 1>&2 -echo "-----------------------------------------------------------" 1>&2 +echo "Test 6b. Should print 3412257956 129" -# overspecification -pamcut -left=1 -right=1 -width=14 testgrid.pbm > ${test_out} || \ - echo -n "Expected failure 1"; test -s ${test_out}; echo " "$? +pamcut 5 5 30 30 ${test50_pbm} | cksum -pamcut -top=1 -bottom=1 -height=16 testgrid.pbm > ${test_out} || \ - echo -n "Expected failure 2"; test -s ${test_out}; echo " "$? +rm ${test50_pbm} -pamcut -right=1 -cropright=1 testgrid.pbm > ${test_out} || \ - echo -n "Expected failure 3"; test -s ${test_out}; echo " "$? +echo "Test 7. Should print 284857390 12 sixteen times" -pamcut -top=1 -croptop=1 testgrid.pbm > ${test_out} || \ - echo -n "Expected failure 4"; test -s ${test_out}; echo " "$? +test1_pbm=${tmpdir}/test1.pbm -pamcut -bottom=1 -cropbottom=1 testgrid.pbm > ${test_out} || \ - echo -n "Expected failure 5"; test -s ${test_out}; echo " "$? +pbmmake -b 1 1 > ${test1_pbm} -pamcut -left=1 -cropleft=1 testgrid.pbm > ${test_out} || \ - echo -n "Expected failure 6"; test -s ${test_out}; echo " "$? +# pbmmake -b 5 5 | cksum -# excessive cropping -pamcut -cropleft=7 -cropright=8 testgrid.pbm > ${test_out} || \ - echo -n "Expected failure 7"; test -s ${test_out}; echo " "$? +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 -left=7 -right=6 testgrid.pbm > ${test_out} || \ - echo -n "Expected failure 8"; test -s ${test_out}; echo " "$? +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 -croptop=8 -cropbottom=8 testgrid.pbm > ${test_out} || \ - echo -n "Expected failure 9"; test -s ${test_out}; echo " "$? +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 -top=10 -bottom=9 testgrid.pbm > ${test_out} || \ - echo -n "Expected failure 6"; test -s ${test_out}; echo " "$? +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 -# pad absent -pamcut -cropleft=1 -width=14 testgrid.pbm > ${test_out} || \ - echo -n "Expected failure 10"; test -s ${test_out}; echo " "$? -pamcut -croptop=1 -height=16 testgrid.pbm > ${test_out} || \ - echo -n "Expected failure 11"; test -s ${test_out}; echo " "$? +echo "Test 8. Should print 3125257619 29 four times" -# legacy style: insufficient number of positional parameters -pamcut 5 testimg.ppm > ${test_out} || \ - echo -n "Expected failure 12"; test -s ${test_out}; echo " "$? +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 5 4 testimg.ppm > ${test_out} || \ - echo -n "Expected failure 13"; test -s ${test_out}; echo " "$? +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 5 5 30 testimg.ppm > ${test_out} || \ - echo -n "Expected failure 14"; test -s ${test_out}; echo " "$? +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 -rm -f ${test_out} \ No newline at end of file +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 +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 +invCmd "pamcut -cropleft=1 -width=14 testgrid.pbm" +invCmd "pamcut -croptop=1 -height=16 testgrid.pbm" + +# legacy style: insufficient number of positional parameters +invCmd "pamcut 5 testimg.ppm" +invCmd "pamcut 5 4 testimg.ppm" +invCmd "pamcut 5 5 30 testimg.ppm" diff --git a/test/pamdepth-roundtrip.ok b/test/pamdepth-roundtrip.ok index 89db1a57..28db2ee1 100644 --- a/test/pamdepth-roundtrip.ok +++ b/test/pamdepth-roundtrip.ok @@ -5,4 +5,4 @@ 1926073387 101484 1926073387 101484 1926073387 101484 -2425386270 41 +281226646 481 diff --git a/test/pamdepth-roundtrip.test b/test/pamdepth-roundtrip.test index 0c7cb8b0..6da9a612 100755 --- a/test/pamdepth-roundtrip.test +++ b/test/pamdepth-roundtrip.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamdepth pgmtopbm # Also requires: @@ -9,5 +9,5 @@ pamdepth $i testimg.ppm | \ pamdepth 255 | cksum done -pamdepth 255 testgrid.pbm | pamdepth 1 | \ +pamdepth 255 maze.pbm | pamdepth 1 | \ pgmtopbm -th -val=0.5 | cksum diff --git a/test/pamdepth.ok b/test/pamdepth.ok index 1bd897ac..fefcc14f 100644 --- a/test/pamdepth.ok +++ b/test/pamdepth.ok @@ -10,5 +10,5 @@ stdin: PAM RAW 14 16 1 1 GRAYSCALE Test 2 0 0 : 0 Test Invalid -Expected failure 1 1 -Expected failure 2 1 +Expected failure 1 (no output) +Expected failure 2 (no output) diff --git a/test/pamdepth.test b/test/pamdepth.test index da198973..e938a630 100755 --- a/test/pamdepth.test +++ b/test/pamdepth.test @@ -24,15 +24,7 @@ pamdepth 255 testimg.ppm | cmp -s - testimg.ppm # Test Invalid echo "Test Invalid" -echo 1>&2 -echo "Invalid command-line argument combinations." 1>&2 -echo "Error messages should appear below the line." 1>&2 -echo "-----------------------------------------------------------" 1>&2 +. ${srcdir}/test-invalid.inc -pamdepth 0 testgrid.pbm > ${test_out} || \ - echo -n "Expected failure 1"; test -s ${test_out}; echo " "$? - -pamdepth 65536 testimg.ppm > ${test_out} || \ - echo -n "Expected failure 2"; test -s ${test_out}; echo " "$? - -rm ${test_out} \ No newline at end of file +invCmd "pamdepth 0 testgrid.pbm" +invCmd "pamdepth 65536 testimg.ppm" diff --git a/test/pamdice-roundtrip.ok b/test/pamdice-roundtrip.ok index 4a850615..9f648fd0 100644 --- a/test/pamdice-roundtrip.ok +++ b/test/pamdice-roundtrip.ok @@ -1,18 +1,16 @@ -test 1 -2425386270 41 -test 2 -2425386270 41 -test 3 -2425386270 41 -test 4. +Test 1. Should print 281226646 481 +281226646 481 +Test 2. Should print 281226646 481 +281226646 481 +Test 3. Should print 281226646 481 +281226646 481 +Test 4. Should print 281226646 481 +281226646 481 +Test 5. Should print 1926073387 101484 five times 1926073387 101484 -test 4.-hoverlap=0 1926073387 101484 -test 4.-hoverlap=2 1926073387 101484 -test 4.-voverlap=0 1926073387 101484 -test 4.-voverlap=2 1926073387 101484 -test 5 +Test 6. Should print 1926073387 101484 1926073387 101484 diff --git a/test/pamdice-roundtrip.test b/test/pamdice-roundtrip.test index c5ccde66..4d3fba19 100755 --- a/test/pamdice-roundtrip.test +++ b/test/pamdice-roundtrip.test @@ -1,38 +1,60 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamdice pamundice -# Also requires: - +# Also requires: pamfile tmpdir=${tmpdir:-/tmp} fname_stem=${tmpdir}/pamdice_part -echo test 1 +mazesize=$(pamfile -size maze.pbm) +mw=$(echo ${mazesize} | cut -d " " -f 1) +mh=$(echo ${mazesize} | cut -d " " -f 2) + +echo "Test 1. Should print 281226646 481" -pamdice testgrid.pbm -outstem=${fname_stem} +pamdice maze.pbm -outstem=${fname_stem} pamundice ${fname_stem}_%1d_%1a.pbm -down=1 -across=1 | cksum rm ${fname_stem}_0_0.pbm -echo test 2 +echo "Test 2. Should print 281226646 481" + +width=10 +tiles=$(( (${mw}+${width}-1) / ${width} )) + + +pamdice maze.pbm -outstem=${fname_stem} -width=${width} +pamundice ${fname_stem}_%1d_%1a.pbm -across=${tiles} | cksum +rm ${fname_stem}_*_*.pbm + +echo "Test 3. Should print 281226646 481" -pamdice testgrid.pbm -outstem=${fname_stem} -width=3 -pamundice ${fname_stem}_%1d_%1a.pbm -across=5 | cksum -rm ${fname_stem}_0_?.pbm +width=5 +tiles=$(( (${mw}+${width}-1) / ${width} )) -echo test 3 +pamdice maze.pbm -outstem=${fname_stem} -width=${width} +pamundice ${fname_stem}_%1d_%2a.pbm -across=${tiles} | cksum +rm ${fname_stem}_*_*.pbm -pamdice testgrid.pbm -outstem=${fname_stem} -height=4 -pamundice ${fname_stem}_%1d_%1a.pbm -down=4 | cksum -rm ${fname_stem}_?_0.pbm -for flags in "" "-hoverlap=0" "-hoverlap=2" "-voverlap=0" "-voverlap=2" +echo "Test 4. Should print 281226646 481" + +height=10 +tiles=$(( (${mh}+${height}-1) / ${height} )) + +pamdice maze.pbm -outstem=${fname_stem} -height=${height} +pamundice ${fname_stem}_%1d_%1a.pbm -down=${tiles} | cksum +rm ${fname_stem}_*_*.pbm + +echo "Test 5. Should print 1926073387 101484 five times" + +for option in "" "-hoverlap=0" "-hoverlap=2" "-voverlap=0" "-voverlap=2" do - echo test 4.${flags} pamdice testimg.ppm -outstem=${fname_stem} -width=50 -height=40 pamundice ${fname_stem}_%1d_%1a.ppm -down=4 -across=5 | cksum rm ${fname_stem}_?_?.ppm done -echo test 5 +echo "Test 6. Should print 1926073387 101484" + pamdice testimg.ppm -outstem=${fname_stem} -width=20 -height=10 ls ${fname_stem}*.ppm | pamundice -listfile=- -across=12 -down=15 | cksum rm ${fname_stem}_??_??.ppm \ No newline at end of file diff --git a/test/pamdice.ok b/test/pamdice.ok index 99504ec0..9e978168 100644 --- a/test/pamdice.ok +++ b/test/pamdice.ok @@ -13,9 +13,14 @@ P1@1 1@0@ P1@1 1@1@ Test Invalid Expected failure 1 +Expected failure 1.rm Expected failure 2 +Expected failure 2.rm Expected failure 3 +Expected failure 3.rm Expected failure 4 +Expected failure 4.rm Expected failure 5 +Expected failure 5.rm Expected failure 6 -Expected failure (output files) +Expected failure 6.rm diff --git a/test/pamdice.test b/test/pamdice.test index 3199fd4a..04dd4d78 100755 --- a/test/pamdice.test +++ b/test/pamdice.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamdice # Also requires: pbmmake @@ -11,7 +11,7 @@ echo "Test 1." pbmmake -w 2 5 | pamdice -height=1 -width=1 -outstem=${fname_stem} -plain ls ${fname_stem}*.pbm | while read file do - cat ${file} | tr '\n' '@' ; echo + cat ${file} | tr '\n' '@' ; echo done | sort | uniq -c | sed 's/^ *//' rm ${fname_stem}*.pbm @@ -22,7 +22,7 @@ echo "Test 2." pbmmake -g 2 5 | pamdice -height=1 -width=1 -outstem=${fname_stem} -plain ls ${fname_stem}*.pbm | while read file do - cat ${file} | tr '\n' '@' ; echo + cat ${file} | tr '\n' '@' ; echo done rm ${fname_stem}*.pbm @@ -36,33 +36,44 @@ echo "Invalid command-line argument combinations." 1>&2 echo "Error messages should appear below the line." 1>&2 echo "-----------------------------------------------------------" 1>&2 +# No output files should be producd. With nothing to remove, +# the rm commands should always fail. + # No input file pamdice -width=10 -height=10 -outstem=${fname_stem} /dev/null || \ echo "Expected failure 1" +rm ${fname_stem}* || +echo "Expected failure 1.rm" # No -outstem pamdice -width=10 -height=10 testgrid.pbm || \ echo "Expected failure 2" +rm ${fname_stem}* || +echo "Expected failure 2.rm" # -width=0 pamdice -width=0 -height=10 -outstem=${fname_stem} testgrid.pbm || \ echo "Expected failure 3" +rm ${fname_stem}* || +echo "Expected failure 3.rm" # -height=0 pamdice -width=10 -height=0 -outstem=${fname_stem} testgrid.pbm || \ echo "Expected failure 4" +rm ${fname_stem}* || +echo "Expected failure 4.rm" # -hoverlap larger than width pamdice -width=10 -height=10 -hoverlap=11 \ -outstem=${fname_stem} testgrid.pbm || \ echo "Expected failure 5" +rm ${fname_stem}* || +echo "Expected failure 5.rm" + # -voverlap larger than height pamdice -width=10 -height=10 -voverlap=11 \ -outstem=${fname_stem} testgrid.pbm || \ echo "Expected failure 6" - - -# Ensure that no output files are produced by the above -ls ${fname_stem}* || \ -echo "Expected failure (output files)" \ No newline at end of file +rm ${fname_stem}* || +echo "Expected failure 6.rm" diff --git a/test/pamditherbw-random.ok b/test/pamditherbw-random.ok new file mode 100644 index 00000000..d21e3613 --- /dev/null +++ b/test/pamditherbw-random.ok @@ -0,0 +1,6 @@ +Test: Floyd-Steinberg +Should print 3849876047 33894 +3849876047 33894 +Test: Atkinson +Should print 2887295695 33894 +2887295695 33894 diff --git a/test/pamditherbw-random.test b/test/pamditherbw-random.test new file mode 100755 index 00000000..7a5de7bd --- /dev/null +++ b/test/pamditherbw-random.test @@ -0,0 +1,23 @@ +#! /bin/sh +# This script tests: pamditherbw +# Also requires: pamchannel pamtopnm + +tmpdir=${tmpdir:-/tmp} +test_red=${tmpdir}/testimg.red + +# Test 1. Floyd-Steinberg +echo "Test: Floyd-Steinberg" +echo "Should print 3849876047 33894" + +pamchannel -infile=testimg.ppm -tupletype="GRAYSCALE" 0 | pamtopnm | \ + tee ${test_red} | \ + pamditherbw -fs -randomseed=1 | cksum + + +# Test 2. Atkinson +echo "Test: Atkinson" +echo "Should print 2887295695 33894" + +pamditherbw -atkinson -randomseed=1 ${test_red} | cksum + +rm ${test_red} \ No newline at end of file diff --git a/test/pamditherbw.ok b/test/pamditherbw.ok index 02200d0f..da3f6e8b 100644 --- a/test/pamditherbw.ok +++ b/test/pamditherbw.ok @@ -14,15 +14,15 @@ Test: Cluster-4 Test: Cluster-8 3493215477 33894 Test: Invalid -Expected failure 1 1 -Expected failure 2 1 -Expected failure 3 1 -Expected failure 4 1 -Expected failure 5 1 -Expected failure 6 1 -Expected failure 7 1 -Expected failure 8 1 -Expected failure 9 1 -Expected failure 10 1 -Expected failure 11 1 -Expected failure 12 1 +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) +Expected failure 5 (no output) +Expected failure 6 (no output) +Expected failure 7 (no output) +Expected failure 8 (no output) +Expected failure 9 (no output) +Expected failure 10 (no output) +Expected failure 11 (no output) +Expected failure 12 (no output) diff --git a/test/pamditherbw.test b/test/pamditherbw.test index 40eb0a4d..76bcdbd7 100755 --- a/test/pamditherbw.test +++ b/test/pamditherbw.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamditherbw # Also requires: pamchannel pamtopnm @@ -39,36 +39,19 @@ pamditherbw -cluster8 ${test_red} | cksum echo "Test: Invalid" -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 - -pamditherbw -fs -atkinson ${test_red} > ${test_out} || \ - echo -n "Expected failure 1"; test -s ${test_out}; echo " "$? -pamditherbw -floyd -atkinson ${test_red} > ${test_out} || \ - echo -n "Expected failure 2"; test -s ${test_out}; echo " "$? -pamditherbw -dither8 -cluster3 ${test_red} > ${test_out} || \ - echo -n "Expected failure 3"; test -s ${test_out}; echo " "$? -pamditherbw -cluster3 -cluster4 ${test_red} > ${test_out} || \ - echo -n "Expected failure 4"; test -s ${test_out}; echo " "$? -pamditherbw -cluster3 -cluster8 ${test_red} > ${test_out} || \ - echo -n "Expected failure 5"; test -s ${test_out}; echo " "$? -pamditherbw -cluster4 -cluster8 ${test_red} > ${test_out} || \ - echo -n "Expected failure 6"; test -s ${test_out}; echo " "$? -pamditherbw -hilbert -threshold ${test_red} > ${test_out} || \ - echo -n "Expected failure 7"; test -s ${test_out}; echo " "$? -pamditherbw -clump=8 ${test_red} > ${test_out} || \ - echo -n "Expected failure 8"; test -s ${test_out}; echo " "$? -pamditherbw -fs -clump=8 ${test_red} > ${test_out} || \ - echo -n "Expected failure 9"; test -s ${test_out}; echo " "$? -pamditherbw -hilbert -clump=1 ${test_red} > ${test_out} || \ - echo -n "Expected failure 10"; test -s ${test_out}; echo " "$? -pamditherbw -th -value=-1 ${test_red} > ${test_out} || \ - echo -n "Expected failure 11"; test -s ${test_out}; echo " "$? -pamditherbw -th -value=1.1 ${test_red} > ${test_out} || \ - echo -n "Expected failure 12"; test -s ${test_out}; echo " "$? - -rm ${test_red} ${test_out} +. ${srcdir}/test-invalid.inc + +invCmd "pamditherbw -fs -atkinson ${test_red}" +invCmd "pamditherbw -floyd -atkinson ${test_red}" +invCmd "pamditherbw -dither8 -cluster3 ${test_red}" +invCmd "pamditherbw -cluster3 -cluster4 ${test_red}" +invCmd "pamditherbw -cluster3 -cluster8 ${test_red}" +invCmd "pamditherbw -cluster4 -cluster8 ${test_red}" +invCmd "pamditherbw -hilbert -threshold ${test_red}" +invCmd "pamditherbw -clump=8 ${test_red}" +invCmd "pamditherbw -fs -clump=8 ${test_red}" +invCmd "pamditherbw -hilbert -clump=1 ${test_red}" +invCmd "pamditherbw -th -value=-1 ${test_red}" +invCmd "pamditherbw -th -value=1.1 ${test_red}" + +rm ${test_red} diff --git a/test/pamedge.test b/test/pamedge.test index c63b30cc..8121f858 100755 --- a/test/pamedge.test +++ b/test/pamedge.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamedge # Also requires: pbmpscale pbmtext pgmtopbm pgmtopgm ppmtopgm diff --git a/test/pamendian-roundtrip.ok b/test/pamendian-roundtrip.ok index 50450617..6245abb9 100644 --- a/test/pamendian-roundtrip.ok +++ b/test/pamendian-roundtrip.ok @@ -1,4 +1,5 @@ -Test 1: Should print '0 0 0 : 0' +Test 1. Should print '0 0 0 : 0' 0 0 0 : 0 -Test 2 should print echo '0 0 0 0 0 : 0' +Test 2. Should print '0 0 0 0 0 : 0' twice +0 0 0 0 0 : 0 0 0 0 0 0 : 0 diff --git a/test/pamendian-roundtrip.test b/test/pamendian-roundtrip.test index aed03c76..b060b704 100755 --- a/test/pamendian-roundtrip.test +++ b/test/pamendian-roundtrip.test @@ -2,7 +2,7 @@ # This script tests: pamendian # Also requires: pamdepth pgmtopbm pamseq -echo "Test 1: Should print '0 0 0 : 0'" +echo "Test 1. Should print '0 0 0 : 0'" tmpdir=${tmpdir:-/tmp} test0_pam=${tmpdir}/test0.pam @@ -15,8 +15,12 @@ pamendian < ${test0_pam} | pamendian |\ rm ${test0_pam} -echo "Test 2 should print echo '0 0 0 0 0 : 0'" +echo "Test 2. Should print '0 0 0 0 0 : 0' twice" pamdepth 65535 testgrid.pbm | pamendian | pamendian | \ pgmtopbm -th -val=0.5 | cmp -s - testgrid.pbm + echo ${PIPESTATUS[@]} ":" $? + +pamdepth 4095 maze.pbm | pamendian | pamendian | \ + pgmtopbm -th -val=0.5 | cmp -s - maze.pbm echo ${PIPESTATUS[@]} ":" $? \ No newline at end of file diff --git a/test/pamenlarge-pamscale-point.test b/test/pamenlarge-pamscale-point.test index 08b34bb7..f0f0948b 100755 --- a/test/pamenlarge-pamscale-point.test +++ b/test/pamenlarge-pamscale-point.test @@ -29,8 +29,8 @@ enlarge_pbm=${tmpdir}/enlarge.pbm for option in "6 -nomix" "15 -nomix -linear" "24 -nomix" do scale=${option%% *} - pamenlarge $scale testgrid.pbm > ${enlarge_pbm} - pamscale $option testgrid.pbm | cmp -s - ${enlarge_pbm} + pamenlarge $scale maze.pbm > ${enlarge_pbm} + pamscale $option maze.pbm | cmp -s - ${enlarge_pbm} echo $option ${PIPESTATUS[@]} ":" $? rm ${enlarge_pbm} done diff --git a/test/pamenlarge-pbm.test b/test/pamenlarge-pbm.test index 10c00ba0..bea740c6 100755 --- a/test/pamenlarge-pbm.test +++ b/test/pamenlarge-pbm.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamenlarge # Also requires: pbmmake pnmpad @@ -18,22 +18,26 @@ LC_ALL=C awk 'BEGIN { print "P4"; # header # Test 1. echo "test 1" -for xs in `seq 23` +for xs in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 + # for xs in `seq 23` do - pamenlarge -xscale=$xs ${complete256_pbm} | cksum + pamenlarge -xscale=${xs} ${complete256_pbm} | cksum done # Test 2. echo "test 2" -for xs1 in `seq 15` +for xs1 in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 + # for xs1 in `seq 15` do - xs2=$((30-$xs1)) - pamenlarge -xscale=$xs1 ${complete256_pbm} | pamenlarge -xscale=$xs2 | cksum - if [ $xs1 != $xs2 ]; then - pamenlarge -xscale=$xs2 ${complete256_pbm} | pamenlarge -xscale=$xs1 | cksum + xs2=$((30-${xs1})) + pamenlarge -xscale=${xs1} ${complete256_pbm} | \ + pamenlarge -xscale=${xs2} | cksum + if [ ${xs1} != ${xs2} ]; then + pamenlarge -xscale=${xs2} ${complete256_pbm} | \ + pamenlarge -xscale=${xs1} | cksum fi - pamenlarge -xscale=$(($xs1 * $xs2)) ${complete256_pbm} | cksum + pamenlarge -xscale=$((${xs1} * ${xs2})) ${complete256_pbm} | cksum done rm ${complete256_pbm} @@ -43,19 +47,19 @@ echo "test 3" test3_pbm=${tmpdir}/test3.pbm -for width in `seq 16` +for width in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 # for width in `seq 16` do pbmmake -g ${width} 1 | pnmpad -top=1 -white | \ pnmpad -bottom=1 -black > ${test3_pbm}.${width} done - for xscale in `seq 16` - do echo -n ${xscale} " " - for width in `seq 16` + for xscale in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 # for xscale in `seq 16` + do printf "%d " ${xscale} + for width in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 # for width in `seq 16` do pamenlarge -xscale=${xscale} ${test3_pbm}.${width} ; done | cksum # # unlike most other tests we take the cksum of a composite PBM file # done -rm ${test3_pbm}.[1-9] ${test3_pbm}.1[1-6] \ No newline at end of file +rm ${test3_pbm}.[1-9] ${test3_pbm}.1[0-6] diff --git a/test/pamenlarge.ok b/test/pamenlarge.ok index a2408871..9107e870 100644 --- a/test/pamenlarge.ok +++ b/test/pamenlarge.ok @@ -1,4 +1,10 @@ +Test 1. Should print 3424505894 913236 3424505894 913236 +Test 2. Should print 3763267672 304422 3763267672 304422 -3342398172 297 +Test 3. Should print 3748791794 3905 +3748791794 3905 +Test 4. Should print 1618994486 1194 +1618994486 1194 +Test 5. Should print 398497872 6806 398497872 6806 diff --git a/test/pamenlarge.test b/test/pamenlarge.test index 3820f47e..7c46881d 100755 --- a/test/pamenlarge.test +++ b/test/pamenlarge.test @@ -1,14 +1,15 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamenlarge # Also requires: pamchannel pamseq pamtopnm - -# Test 1. Should print 3424505894 913236 +echo "Test 1. Should print 3424505894 913236" pamenlarge 3 testimg.ppm | cksum -# Test 2. Should print 3763267672 304422 +echo "Test 2. Should print 3763267672 304422" pamchannel -infile=testimg.ppm -tupletype="GRAYSCALE" 0 | pamtopnm | \ pamenlarge 3 | cksum -# Test 3. Should print 3342398172 297 -pamenlarge 3 testgrid.pbm | cksum -# Test 4. Should print 398497872 6806 +echo "Test 3. Should print 3748791794 3905" +pamenlarge 3 maze.pbm | cksum +echo "Test 4. Should print 1618994486 1194" +pamenlarge -xscale=21 -yscale=2 testgrid.pbm | cksum +echo "Test 5. Should print 398497872 6806" pamseq 3 4 | pamtopnm -assume | pamenlarge 3 -plain | cksum diff --git a/test/pamexec.test b/test/pamexec.test index 44c11339..7c2bf054 100755 --- a/test/pamexec.test +++ b/test/pamexec.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamexec # Also requires: pbmtext pamfile pbmminkowski pbmtog3 g3topbm @@ -6,7 +6,9 @@ tmpdir=${tmpdir:-/tmp} test_pbm=${tmpdir}/test.pbm combined_pbm=${tmpdir}/combined.pbm -for i in `seq 0 9`; do echo $i | pbmtext -builtin=fixed > ${test_pbm}$i; done +for i in 0 1 2 3 4 5 6 7 8 9 # for i in `seq 0 9` + do echo ${i} | pbmtext -builtin=fixed > ${test_pbm}${i} + done cat ${test_pbm}[0123456789] > ${combined_pbm} echo "Test 1 : Should print 10 stdin: PBM RAW 21 24 1 1 BLACKANDWHITE twice" @@ -16,7 +18,8 @@ pamexec "pamfile -mach" ${combined_pbm} | uniq -c | sed 's/^ *//' echo "Test 2: Should print 1791121103 989 twice" -for i in `seq 0 9`; do pbmminkowski ${test_pbm}$i ; done | cksum +for i in 0 1 2 3 4 5 6 7 8 9 # for i in `seq 0 9` + do pbmminkowski ${test_pbm}${i}; done | cksum pamexec "pbmminkowski" ${combined_pbm} | cksum rm ${test_pbm}[0123456789] @@ -27,7 +30,8 @@ pamexec "pbmtog3 -no | g3topbm" ${combined_pbm} | cksum cat ${combined_pbm} | cksum echo "Invalid command" 1>&2 -echo "Errors message should appear below the line." 1>&2 +echo "Executes quietly." 1>&2 +echo "Errors message should not appear below the line." 1>&2 echo "-----------------------------------------------------------" 1>&2 echo "Test Invalid: Should not print anything" @@ -35,4 +39,4 @@ echo "Test Invalid: Should not print anything" pamexec "false" ${combined_pbm} pamexec "pamfile | false" ${combined_pbm} -rm ${combined_pbm} \ No newline at end of file +rm ${combined_pbm} diff --git a/test/pamfile.ok b/test/pamfile.ok index e222592c..91beec60 100644 --- a/test/pamfile.ok +++ b/test/pamfile.ok @@ -14,6 +14,6 @@ Test 3 testimg.ppm: PPM RAW 227 149 3 255 RGB stdin: PBM RAW 14 16 1 1 BLACKANDWHITE Test Invalid -Expected failure 1 1 -Expected failure 2 1 -Expected failure 3 1 +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) diff --git a/test/pamfile.test b/test/pamfile.test index aa3e2895..d605326d 100755 --- a/test/pamfile.test +++ b/test/pamfile.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamfile # Also requires: pamchannel pamtopnm @@ -22,19 +22,13 @@ cat testgrid.pbm testimg.ppm testgrid.pbm | pamfile -machine echo "Test Invalid" -tmpdir=${tmpdir:-/tmp} -test_out=${tmpdir}/test_out +. ${srcdir}/test-invalid.inc -echo 1>&2 -echo "Invalid command-line argument combinations." 1>&2 -echo "Error messages should appear below the line." 1>&2 -echo "-----------------------------------------------------------" 1>&2 +invCmd "pamfile -size -machine testimg.ppm" +invCmd "pamfile -count -machine testimg.ppm" -pamfile -size -machine testimg.ppm > ${test_out} || \ - echo -n "Expected failure 1"; test -s ${test_out}; echo " "$? -pamfile -count -machine testimg.ppm > ${test_out} || \ - echo -n "Expected failure 2"; test -s ${test_out}; echo " "$? -head -n1 testimg.ppm | pamfile > ${test_out} || \ - echo -n "Expected failure 3"; test -s ${test_out}; echo " "$? +head1_ppm=${tmpdir}/head1.ppm -rm ${test_out} +head -n1 testimg.ppm > ${head1_ppm} +invCmd "pamfile ${head1_ppm}" +rm ${head1_ppm} diff --git a/test/pamfind.ok b/test/pamfind.ok index de53166e..7776ba37 100644 --- a/test/pamfind.ok +++ b/test/pamfind.ok @@ -258,7 +258,7 @@ Test 3 okay okay Test Invalid -Expected failure 1 1 -Expected failure 2 1 -Expected failure 3 1 -Expected failure 4 1 +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) diff --git a/test/pamfind.test b/test/pamfind.test index 074dde5c..079e35f4 100755 --- a/test/pamfind.test +++ b/test/pamfind.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamfind # Also requires: @@ -8,7 +8,7 @@ sorted1_res=${tmpdir}/pamfind_sorted1.res # Test 1 echo "Test 1" -pamfind -color=grey17 testimg.ppm +pamfind -color=grey17 testimg.ppm pamfind -target=210,57,41 testimg.ppm pamfind -target=50,55,49 -machine testimg.ppm @@ -25,31 +25,17 @@ pamfind -target=1 testgrid.pbm | sort > ${sorted1_res} comm -3 ${sorted0_res} ${sorted1_res} | awk 'END {if (NR==226) print "okay"; else printf("failure (line count=%d)\n", NR)}' -comm -12 ${sorted0_res} ${sorted1_res} | +comm -12 ${sorted0_res} ${sorted1_res} | awk '{print}; END { if(NR == 0) print "okay"; else printf("failure (line count=%d)\n", NR)}' rm ${sorted0_res} ${sorted1_res} -# Test 4 - -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 - echo "Test Invalid" -pamfind -color=black -target=1,1,1 testimg.ppm > ${test_out} || \ - echo -n "Expected failure 1"; test -s ${test_out}; echo " "$? -pamfind -target=0,0 testimg.ppm > ${test_out} || \ - echo -n "Expected failure 2"; test -s ${test_out}; echo " "$? -pamfind -target=0,0,0,0 testimg.ppm > ${test_out} || \ - echo -n "Expected failure 3"; test -s ${test_out}; echo " "$? -pamfind testimg.ppm > ${test_out} || \ - echo -n "Expected failure 4"; test -s ${test_out}; echo " "$? +. ${srcdir}/test-invalid.inc -rm ${test_out} +invCmd "pamfind -color=black -target=1,1,1 testimg.ppm" +invCmd "pamfind -target=0,0 testimg.ppm" +invCmd "pamfind -target=0,0,0,0 testimg.ppm" +invCmd "pamfind testimg.ppm" diff --git a/test/pamfix.ok b/test/pamfix.ok index 7302f91e..ba1c678a 100644 --- a/test/pamfix.ok +++ b/test/pamfix.ok @@ -62,7 +62,7 @@ P2 0 1 2 3 4 7 0 0 0 -Test invalid -Expected failure 1 1 -Expected failure 2 1 -Expected failure 3 1 +Test Invalid +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) diff --git a/test/pamfix.test b/test/pamfix.test index e6021b56..c274de86 100755 --- a/test/pamfix.test +++ b/test/pamfix.test @@ -1,48 +1,50 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamfix -# Also requires: +# Also requires: pbmmake + +tmpdir=${tmpdir:-/tmp} # Test 1. echo "Test 1" pbmmake -g 5 5 | pamfix -truncate -plain -echo -e "P1\n5 5\n01010\n10101\n01010\n00001\n1" |\ +printf "P1\n5 5\n01010\n10101\n01010\n00001\n1\n" |\ pamfix -truncate -plain -echo -e "P1\n5 5\n01010\n10101\n01010\n0000\n1" |\ +printf "P1\n5 5\n01010\n10101\n01010\n0000\n1\n" |\ pamfix -truncate -plain -echo -e "P1\n5 5\n01010\n10102\n01010\n00001\n1" |\ +printf "P1\n5 5\n01010\n10102\n01010\n00001\n1\n" |\ pamfix -truncate -plain # Test 2 echo "Test 2" -echo -e "P2\n3 3\n7\n0 1 2\n3 4 5\n6 7 0" |\ +printf "P2\n3 3\n7\n0 1 2\n3 4 5\n6 7 0\n" |\ pamfix -truncate -plain -echo -e "P2\n3 3\n7\n0 1 2\n3 4 5\n6 7" |\ +printf "P2\n3 3\n7\n0 1 2\n3 4 5\n6 7\n" |\ pamfix -truncate -plain -echo -e "P2\n3 3\n7\n0 1 2\n3 4 5\n6 7 8" |\ +printf "P2\n3 3\n7\n0 1 2\n3 4 5\n6 7 8\n" |\ pamfix -truncate -plain -echo -e "P2\n3 3\n7\n0 1 2\n3 4 5\n6 7 8" |\ +printf "P2\n3 3\n7\n0 1 2\n3 4 5\n6 7 8\n" |\ pamfix -change -plain -echo -e "P2\n3 3\n7\n0 1 2\n3 4 5\n6 7 8" |\ +printf "P2\n3 3\n7\n0 1 2\n3 4 5\n6 7 8\n" |\ pamfix -clip -plain -echo -e "P2\n3 3\n7\n0 1 2\n3 4 8\n0 0 0" |\ +printf "P2\n3 3\n7\n0 1 2\n3 4 8\n0 0 0\n" |\ pamfix -change -truncate -plain -echo -e "P2\n3 3\n7\n0 1 2\n3 4 8\n0 0 0" |\ +printf "P2\n3 3\n7\n0 1 2\n3 4 8\n0 0 0\n" |\ pamfix -clip -truncate -plain # Test Invalid -echo "Test invalid" +echo "Test Invalid" test_out=${tmpdir}/test_out @@ -51,16 +53,17 @@ echo "Invalid command-line combination, invalid input" 1>&2 echo "Error messages should appear below the line." 1>&2 echo "-----------------------------------------------------------" 1>&2 -echo -e "P2\n3 2\n7\n0 1 2\n6 7 8" | pamfix -change -clip > ${test_out} || \ - echo -n "Expected failure 1"; - test -s ${test_out}; echo " "$? - -echo -e "P1\n5 5" | pamfix -truncate -plain > ${test_out} || \ - echo -n "Expected failure 2"; - test -s ${test_out}; echo " "$? +printf "P2\n3 2\n7\n0 1 2\n6 7 8\n" | pamfix -change -clip > ${test_out} || \ + printf "Expected failure 1 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} -echo -e "P2\n3 3\255" | pamfix -truncate -plain > ${test_out} || \ - echo -n "Expected failure 3"; - test -s ${test_out}; echo " "$? +printf "P1\n5 5\n" | pamfix -truncate -plain > ${test_out} || \ + printf "Expected failure 2 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} -rm ${test_out} +printf "P2\n3 3\255\n" | pamfix -truncate -plain > ${test_out} || \ + printf "Expected failure 3 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} diff --git a/test/pamflip-pbm-roundtrip.ok b/test/pamflip-pbm-roundtrip.ok new file mode 100644 index 00000000..c72e40d6 --- /dev/null +++ b/test/pamflip-pbm-roundtrip.ok @@ -0,0 +1,122 @@ +Test 1. Should print 281226646 481 seven times +281226646 481 +281226646 481 +281226646 481 +281226646 481 +281226646 481 +281226646 481 +281226646 481 +Test 2. Should print 1576602925 8 fourteen times +1576602925 8 +1576602925 8 +1576602925 8 +1576602925 8 +1576602925 8 +1576602925 8 +1576602925 8 +1576602925 8 +1576602925 8 +1576602925 8 +1576602925 8 +1576602925 8 +1576602925 8 +1576602925 8 +Test 3. Should print N : 0 thirty-two times +1 : 0 +2 : 0 +3 : 0 +4 : 0 +5 : 0 +6 : 0 +7 : 0 +8 : 0 +9 : 0 +10 : 0 +11 : 0 +12 : 0 +13 : 0 +14 : 0 +15 : 0 +16 : 0 +17 : 0 +18 : 0 +19 : 0 +20 : 0 +21 : 0 +22 : 0 +23 : 0 +24 : 0 +25 : 0 +26 : 0 +27 : 0 +28 : 0 +29 : 0 +30 : 0 +31 : 0 +32 : 0 +Test 4. Should print N : 0 thirty-two times +1 : 0 +2 : 0 +3 : 0 +4 : 0 +5 : 0 +6 : 0 +7 : 0 +8 : 0 +9 : 0 +10 : 0 +11 : 0 +12 : 0 +13 : 0 +14 : 0 +15 : 0 +16 : 0 +17 : 0 +18 : 0 +19 : 0 +20 : 0 +21 : 0 +22 : 0 +23 : 0 +24 : 0 +25 : 0 +26 : 0 +27 : 0 +28 : 0 +29 : 0 +30 : 0 +31 : 0 +32 : 0 +Test 5. Should print N : 0 thirty-two times +1 : 0 +2 : 0 +3 : 0 +4 : 0 +5 : 0 +6 : 0 +7 : 0 +8 : 0 +9 : 0 +10 : 0 +11 : 0 +12 : 0 +13 : 0 +14 : 0 +15 : 0 +16 : 0 +17 : 0 +18 : 0 +19 : 0 +20 : 0 +21 : 0 +22 : 0 +23 : 0 +24 : 0 +25 : 0 +26 : 0 +27 : 0 +28 : 0 +29 : 0 +30 : 0 +31 : 0 +32 : 0 diff --git a/test/pamflip-pbm-roundtrip.test b/test/pamflip-pbm-roundtrip.test new file mode 100755 index 00000000..02a342cb --- /dev/null +++ b/test/pamflip-pbm-roundtrip.test @@ -0,0 +1,74 @@ +#! /bin/sh +# This script tests: pamflip +# Also requires: pbmmake pbmnoise + +tmpdir=${tmpdir:-/tmp} +dot_pbm=${tmpdir}/dot.pbm +noise_pbm=${tmpdir}/noise.pbm + +echo "Test 1. Should print 281226646 481 seven times" + +pamflip -null maze.pbm | cksum +pamflip -lr maze.pbm | pamflip -lr | cksum +pamflip -tb maze.pbm | pamflip -tb | cksum +pamflip -r180 maze.pbm | pamflip -r180 | cksum +pamflip -xy maze.pbm | pamflip -xy | cksum +pamflip -r90 maze.pbm | pamflip -r90 | pamflip -r90 | pamflip -r90 | cksum +pamflip -r270 maze.pbm | pamflip -r270 | pamflip -r270 | pamflip -r270 | cksum + +echo "Test 2. Should print 1576602925 8 fourteen times" + +pbmmake -b 1 1 | tee ${dot_pbm} | cksum +pamflip -null ${dot_pbm} | cksum + +# the next six aren't round-trip +pamflip -lr ${dot_pbm} | cksum +pamflip -tb ${dot_pbm} | cksum +pamflip -r180 ${dot_pbm} | cksum +pamflip -xy ${dot_pbm} | cksum +pamflip -r90 ${dot_pbm} | cksum +pamflip -r270 ${dot_pbm} | cksum + +pamflip -lr ${dot_pbm} | pamflip -lr | cksum +pamflip -tb ${dot_pbm} | pamflip -tb | cksum +pamflip -r180 ${dot_pbm} | pamflip -r180 | cksum +pamflip -xy ${dot_pbm} | pamflip -xy | cksum +pamflip -r90 ${dot_pbm} | pamflip -r90 | pamflip -r90 | pamflip -r90 | cksum +pamflip -r270 ${dot_pbm} | pamflip -r270 | \ + pamflip -r270 | pamflip -r270 | cksum + +rm ${dot_pbm} + +echo "Test 3. Should print N : 0 thirty-two times" + +for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 \ + 20 21 22 23 24 25 26 27 28 29 30 31 32 + do + pbmnoise -randomseed=${i} -pack ${i} 3 > ${noise_pbm} && \ + pamflip -lr ${noise_pbm} | pamflip -lr | cmp -s - ${noise_pbm} + echo $i : $? + rm ${noise_pbm} + done + +echo "Test 4. Should print N : 0 thirty-two times" + +for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 \ + 20 21 22 23 24 25 26 27 28 29 30 31 32 + do + pbmnoise -randomseed=${i} -pack 7 ${i} > ${noise_pbm} && \ + pamflip -tb ${noise_pbm} | pamflip -tb | cmp -s - ${noise_pbm} + echo $i : $? + rm ${noise_pbm} + done + + +echo "Test 5. Should print N : 0 thirty-two times" + +for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 \ + 20 21 22 23 24 25 26 27 28 29 30 31 32 + do + pbmnoise -randomseed=${i} -pack ${i} ${i} > ${noise_pbm} && \ + pamflip -xy ${noise_pbm} | pamflip -xy | cmp -s - ${noise_pbm} + echo $i : $? + rm ${noise_pbm} + done diff --git a/test/pamflip-roundtrip.ok b/test/pamflip-roundtrip.ok index 653ab007..70ed6424 100644 --- a/test/pamflip-roundtrip.ok +++ b/test/pamflip-roundtrip.ok @@ -1,12 +1,65 @@ -1926073387 101484 -1926073387 101484 -1926073387 101484 -1926073387 101484 -1926073387 101484 -1926073387 101484 -2425386270 41 -2425386270 41 -2425386270 41 -2425386270 41 -2425386270 41 -2425386270 41 +Test 1. Should print 1988581932 2989 fifteen times +1988581932 2989 +1988581932 2989 +1988581932 2989 +1988581932 2989 +1988581932 2989 +1988581932 2989 +1988581932 2989 +1988581932 2989 +1988581932 2989 +1988581932 2989 +1988581932 2989 +1988581932 2989 +1988581932 2989 +1988581932 2989 +1988581932 2989 +Test 2. Should print 2729474106 27 nine times +2729474106 27 +2729474106 27 +2729474106 27 +2729474106 27 +2729474106 27 +2729474106 27 +2729474106 27 +2729474106 27 +2729474106 27 +Test 3. Should print 1849343241 27 nine times +1849343241 27 +1849343241 27 +1849343241 27 +1849343241 27 +1849343241 27 +1849343241 27 +1849343241 27 +1849343241 27 +1849343241 27 +Test 4. Should print a single pixel PPM image maxval 65535 in +plain (ascii) format; then print 2434897823 19 fifteen times +P3 +1 1 +65535 +1 10000 65535 +2434897823 19 +2434897823 19 +2434897823 19 +2434897823 19 +2434897823 19 +2434897823 19 +2434897823 19 +2434897823 19 +2434897823 19 +2434897823 19 +2434897823 19 +2434897823 19 +2434897823 19 +2434897823 19 +2434897823 19 +Test 5. Should print 281226646 481 seven times +281226646 481 +281226646 481 +281226646 481 +281226646 481 +281226646 481 +281226646 481 +281226646 481 diff --git a/test/pamflip-roundtrip.test b/test/pamflip-roundtrip.test index c5a34ad9..6103f6fb 100755 --- a/test/pamflip-roundtrip.test +++ b/test/pamflip-roundtrip.test @@ -1,35 +1,115 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamflip -# Also requires: +# Also requires: ppmpat pamseq pamtopnm +tmpdir=${tmpdir:-/tmp} +tartan_ppm=${tmpdir}/test.ppm +test1_pgm=${tmpdir}/test1.pgm +test2_pgm=${tmpdir}/test2.pgm +dot_ppm=${tmpdir}/dot.ppm -pamflip -lr testimg.ppm | pamflip -lr | cksum -pamflip -tb testimg.ppm | pamflip -tb | cksum -pamflip -r180 testimg.ppm | \ - pamflip -r180 | cksum -pamflip -xy testimg.ppm | pamflip -xy | cksum -pamflip -r90 testimg.ppm | \ - pamflip -r90 | \ - pamflip -r90 | \ - pamflip -r90 | cksum -pamflip -r270 testimg.ppm | \ - pamflip -r270 | \ - pamflip -r270 | \ - pamflip -r270 | cksum - -pamflip -lr testgrid.pbm | \ - pamflip -lr | cksum -pamflip -tb testgrid.pbm | \ - pamflip -tb | cksum -pamflip -r180 testgrid.pbm | \ +echo "Test 1. Should print 1988581932 2989 fifteen times" + +ppmpat -tartan -mesh \ + -color=rgb:0/0/0,rgb:ff/00/ff,rgb:80/90/20 31 32 > ${tartan_ppm} + +pamflip -null ${tartan_ppm} | cksum +pamflip -lr ${tartan_ppm} | pamflip -lr | cksum +pamflip -tb ${tartan_ppm} | pamflip -tb | cksum +pamflip -r180 ${tartan_ppm} | \ pamflip -r180 | cksum -pamflip -xy testgrid.pbm | \ - pamflip -xy | cksum -pamflip -r90 testgrid.pbm | \ - pamflip -r90 | \ - pamflip -r90 | \ - pamflip -r90 | cksum -pamflip -r270 testgrid.pbm | \ - pamflip -r270 | \ - pamflip -r270 | \ - pamflip -r270 | cksum +pamflip -xy ${tartan_ppm} | pamflip -xy | cksum +pamflip -r90 ${tartan_ppm} | pamflip -r90 | \ + pamflip -r90 | pamflip -r90 | cksum +pamflip -r270 ${tartan_ppm} | pamflip -r270 | \ + pamflip -r270 | pamflip -r270 | cksum +pamflip -xform=leftright ${tartan_ppm} | pamflip -leftright | cksum +pamflip -xform=topbottom ${tartan_ppm} | pamflip -topbottom | cksum +pamflip -xform=transpose ${tartan_ppm} | pamflip -transpose | cksum +pamflip -xform=leftright,leftright ${tartan_ppm} | cksum +pamflip -xform=topbottom,topbottom ${tartan_ppm} | cksum +pamflip -xform=transpose,transpose ${tartan_ppm} | cksum +pamflip -tb ${tartan_ppm} | pamflip -lr | \ + pamflip -xform=leftright,topbottom | cksum +pamflip -tb ${tartan_ppm} | pamflip -lr | pamflip -xy | \ + pamflip -xform=leftright,topbottom,transpose | cksum + +rm ${tartan_ppm} + +pamseq 1 15 | pamtopnm -assume > ${test1_pgm} + +echo "Test 2. Should print 2729474106 27 nine times" + +pamflip -null ${test1_pgm} | cksum +pamflip -lr ${test1_pgm} | pamflip -lr | cksum +pamflip -tb ${test1_pgm} | pamflip -tb | cksum +pamflip -r180 ${test1_pgm} | pamflip -r180 | cksum +pamflip -xy ${test1_pgm} | pamflip -xy | cksum +pamflip -r90 ${test1_pgm} | pamflip -r270 | cksum +pamflip -r270 ${test1_pgm} | pamflip -r90 | cksum +pamflip -r90 ${test1_pgm} | pamflip -r90 | \ + pamflip -r90 | pamflip -r90 | cksum +pamflip -r270 ${test1_pgm} | pamflip -r270 | \ + pamflip -r270 | pamflip -r270 | cksum + +pamflip -r180 ${test1_pgm} > ${test2_pgm} +rm ${test1_pgm} + +echo "Test 3. Should print 1849343241 27 nine times" + +pamflip -null ${test2_pgm} | cksum +pamflip -lr ${test2_pgm} | pamflip -lr | cksum +pamflip -tb ${test2_pgm} | pamflip -tb | cksum +pamflip -r180 ${test2_pgm} | pamflip -r180 | cksum +pamflip -xy ${test2_pgm} | pamflip -xy | cksum +pamflip -r90 ${test2_pgm} | pamflip -r270 | cksum +pamflip -r270 ${test2_pgm} | pamflip -r90 | cksum +pamflip -r90 ${test2_pgm} | pamflip -r90 | \ + pamflip -r90 | pamflip -r90 | cksum +pamflip -r270 ${test2_pgm} | pamflip -r270 | \ + pamflip -r270 | pamflip -r270 | cksum + +rm ${test2_pgm} + +cat > ${dot_ppm} <<EOF +P3 +1 1 +65535 +1 10000 65535 +EOF + +echo "Test 4. Should print a single pixel PPM image maxval 65535 in " +echo "plain (ascii) format; then print 2434897823 19 fifteen times" + +pamflip -null -plain ${dot_ppm} + +# These are not round-trip +pamflip -null ${dot_ppm} | cksum +pamflip -lr ${dot_ppm} | cksum +pamflip -tb ${dot_ppm} | cksum +pamflip -xy ${dot_ppm} | cksum +pamflip -r90 ${dot_ppm} | cksum +pamflip -r180 ${dot_ppm} | cksum +pamflip -r270 ${dot_ppm} | cksum + +pamflip -lr ${dot_ppm} | pamflip -lr | cksum +pamflip -tb ${dot_ppm} | pamflip -tb | cksum +pamflip -r180 ${dot_ppm} | pamflip -r180 | cksum +pamflip -xy ${dot_ppm} | pamflip -xy | cksum +pamflip -r90 ${dot_ppm} | pamflip -r270 | cksum +pamflip -r270 ${dot_ppm} | pamflip -r90 | cksum +pamflip -r90 ${dot_ppm} | pamflip -r90 | pamflip -r90 | pamflip -r90 | cksum +pamflip -r270 ${dot_ppm} | pamflip -r270 | \ + pamflip -r270 | pamflip -r270 | cksum + +rm ${dot_ppm} + +echo "Test 5. Should print 281226646 481 seven times" + +pamflip -null maze.pbm | cksum +pamflip -lr maze.pbm | pamflip -lr | cksum +pamflip -tb maze.pbm | pamflip -tb | cksum +pamflip -r180 maze.pbm | pamflip -r180 | cksum +pamflip -xy maze.pbm | pamflip -xy | cksum +pamflip -r90 maze.pbm | pamflip -r90 | pamflip -r90 | pamflip -r90 | cksum +pamflip -r270 maze.pbm | pamflip -r270 | pamflip -r270 | pamflip -r270 | cksum diff --git a/test/pamflip1.ok b/test/pamflip1.ok index 64e0407e..1169d773 100644 --- a/test/pamflip1.ok +++ b/test/pamflip1.ok @@ -1,5 +1,10 @@ -2116496681 101484 +Test 1. Should print 1350702313 12336 +1350702313 12336 +Test 2. Should print 1035759697 40048 +1035759697 40048 +Test 3. Should print 217037000 101484 217037000 101484 -2052917888 101484 -3375384165 41 -604323149 41 +Test 4. Should print 1178735266 481 +1178735266 481 +Test 5. Should print 2339906255 481 +2339906255 481 diff --git a/test/pamflip1.test b/test/pamflip1.test index 840cac73..f8da3a74 100755 --- a/test/pamflip1.test +++ b/test/pamflip1.test @@ -1,15 +1,19 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamflip -# Also requires: +# Also requires: pamseq +echo "Test 1. Should print 1350702313 12336" +pamseq 3 15 | pamflip -lr | cksum -# Test 1. Should print 2116496681 101484 -pamflip -lr testimg.ppm | cksum -# Test 2. Should print 217037000 101484 +echo "Test 2. Should print 1035759697 40048" +pamseq 4 9 | pamflip -tb | cksum + +echo "Test 3. Should print 217037000 101484" pamflip -cw testimg.ppm | cksum -# Test 3. Should print 2052917888 101484 -pamflip -tb testimg.ppm | cksum -# Test 4. Should print 3375384165 41 -pamflip -lr testgrid.pbm | cksum -# Test 5. Should print 604323149 41 -pamflip -tb testgrid.pbm | cksum + +echo "Test 4. Should print 1178735266 481" +pamflip -lr maze.pbm | cksum + +echo "Test 5. Should print 2339906255 481" +pamflip -tb maze.pbm | cksum + diff --git a/test/pamflip2.ok b/test/pamflip2.ok index d2ea501e..e3b4185c 100644 --- a/test/pamflip2.ok +++ b/test/pamflip2.ok @@ -1,3 +1,6 @@ -490797850 37 -3727293411 37 -3511745816 37 +Test 1. Should print 748061765 465 +748061765 465 +Test 2. Should print 3217647947 465 +3217647947 465 +Test 2. Should print 1086015439 465 +1086015439 465 diff --git a/test/pamflip2.test b/test/pamflip2.test index 4dddb770..0393d73e 100755 --- a/test/pamflip2.test +++ b/test/pamflip2.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamflip # Also requires: @@ -9,9 +9,11 @@ ## optional SSE routine. If you make a wrong choice during configure, ## this test will fail. -# Test 1. Should print 490797850 37 -pamflip -cw testgrid.pbm | cksum -# Test 1. Should print 3727293411 37 -pamflip -ccw testgrid.pbm | cksum -# Test 2. Should print 3511745816 37 -pamflip -xy testgrid.pbm | cksum +echo "Test 1. Should print 748061765 465" +pamflip -cw maze.pbm | cksum + +echo "Test 2. Should print 3217647947 465" +pamflip -ccw maze.pbm | cksum + +echo "Test 2. Should print 1086015439 465" +pamflip -xy maze.pbm | cksum diff --git a/test/pamfunc.ok b/test/pamfunc.ok index 4a531577..0010476e 100644 --- a/test/pamfunc.ok +++ b/test/pamfunc.ok @@ -36,35 +36,35 @@ Test 4: Should print 1926073387 101484 eight times 1926073387 101484 1926073387 101484 1926073387 101484 -Test 5: Should print 2425386270 41 six times -2425386270 41 -2425386270 41 -2425386270 41 -2425386270 41 -2425386270 41 -2425386270 41 +Test 5: Should print 281226646 481 six times +281226646 481 +281226646 481 +281226646 481 +281226646 481 +281226646 481 +281226646 481 Test Invalid -Expected failure 1 1 -Expected failure 2 1 -Expected failure 3 1 -Expected failure 4 1 -Expected failure 5 1 -Expected failure 6 1 -Expected failure 7 1 -Expected failure 8 1 -Expected failure 9 1 -Expected failure 10 1 -Expected failure 11 1 -Expected failure 12 1 -Expected failure 13 1 -Expected failure 14 1 -Expected failure 15 1 -Expected failure 16 1 -Expected failure 17 1 -Expected failure 18 1 -Expected failure 19 1 -Expected failure 20 1 -Expected failure 21 1 -Expected failure 22 1 -Expected failure 23 1 -Expected failure 24 1 +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) +Expected failure 5 (no output) +Expected failure 6 (no output) +Expected failure 7 (no output) +Expected failure 8 (no output) +Expected failure 9 (no output) +Expected failure 10 (no output) +Expected failure 11 (no output) +Expected failure 12 (no output) +Expected failure 13 (no output) +Expected failure 14 (no output) +Expected failure 15 (no output) +Expected failure 16 (no output) +Expected failure 17 (no output) +Expected failure 18 (no output) +Expected failure 19 (no output) +Expected failure 20 (no output) +Expected failure 21 (no output) +Expected failure 22 (no output) +Expected failure 23 (no output) +Expected failure 24 (no output) diff --git a/test/pamfunc.test b/test/pamfunc.test index f9a8a33e..b1b9edfc 100755 --- a/test/pamfunc.test +++ b/test/pamfunc.test @@ -1,11 +1,11 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamfunc # Also requires: pamseq pamtopnm pbmmake tmpdir=${tmpdir:-/tmp} input_pgm=${tmpdir}/input.pgm -echo "Test 1" +echo "Test 1" pamseq 1 15 | pamtopnm -assume > ${input_pgm} pamtopnm -plain ${input_pgm} | tr '\n' ' '; echo @@ -73,94 +73,43 @@ pamfunc -shiftleft 0 testimg.ppm | cksum pamfunc -shiftright 0 testimg.ppm | cksum -echo "Test 5: Should print 2425386270 41 six times" +echo "Test 5: Should print 281226646 481 six times" -cat testgrid.pbm | cksum +cat maze.pbm | cksum -pamfunc -andmask 0x1 testgrid.pbm | cksum -pamfunc -ormask 0x0 testgrid.pbm | cksum -pamfunc -xormask 0x1 testgrid.pbm | pamfunc -xormask 0x1 | cksum +pamfunc -andmask 0x1 maze.pbm | cksum +pamfunc -ormask 0x0 maze.pbm | cksum +pamfunc -xormask 0x1 maze.pbm | pamfunc -xormask 0x1 | cksum -pamfunc -shiftleft 0 testgrid.pbm | cksum -pamfunc -shiftright 0 testgrid.pbm | cksum +pamfunc -shiftleft 0 maze.pbm | cksum +pamfunc -shiftright 0 maze.pbm | cksum -echo "Invalid command-line argument combinations." 1>&2 -echo "Error messages should appear below the line." 1>&2 -echo "-----------------------------------------------------------" 1>&2 echo "Test Invalid" -output_ppm=${tmpdir}/output.ppm - -pamfunc -multiplier testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 1" - test -s ${output_ppm}; echo " "$? -pamfunc -multiplier=-1 testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 2" - test -s ${output_ppm}; echo " "$? -pamfunc -divisor testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 3" - test -s ${output_ppm}; echo " "$? -pamfunc -divisor=-20 testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 4" - test -s ${output_ppm}; echo " "$? -pamfunc -adder testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 5" - test -s ${output_ppm}; echo " "$? -pamfunc -adder 0.5 testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 6" - test -s ${output_ppm}; echo " "$? -pamfunc -subtractor testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 7" - test -s ${output_ppm}; echo " "$? -pamfunc -subtractor 0.1 testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 8" - test -s ${output_ppm}; echo " "$? -pamfunc -multiplier=1 -divisor=2 testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 9" - test -s ${output_ppm}; echo " "$? -pamfunc -adder=2 -subtractor=3 testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 10" - test -s ${output_ppm}; echo " "$? -pamfunc -min testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 11" - test -s ${output_ppm}; echo " "$? -pamfunc -max testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 12" - test -s ${output_ppm}; echo " "$? -pamfunc -andmask testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 13" - test -s ${output_ppm}; echo " "$? -pamfunc -ormask testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 14" - test -s ${output_ppm}; echo " "$? -pamfunc -xormask testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 15" - test -s ${output_ppm}; echo " "$? -pamfunc -not 1 testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 16" - test -s ${output_ppm}; echo " "$? -pamfunc -min=1 -max=2 testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 17" - test -s ${output_ppm}; echo " "$? -pamfunc -andmask=1 -ormask=0 testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 18" - test -s ${output_ppm}; echo " "$? -pamfunc -andmask=0xffff testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 19" - test -s ${output_ppm}; echo " "$? -pamfunc -shiftleft testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 20" - test -s ${output_ppm}; echo " "$? -pamfunc -shiftright testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 21" - test -s ${output_ppm}; echo " "$? -pamfunc -changemaxval testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 22" - test -s ${output_ppm}; echo " "$? -pamfunc -shiftleft=1 -shiftright=1 testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 23" - test -s ${output_ppm}; echo " "$? -pamfunc -multiplier=0.5 -changemaxval=65535 testimg.ppm > ${output_ppm} || \ - echo -n "Expected failure 24" - test -s ${output_ppm}; echo " "$? +. ${srcdir}/test-invalid.inc + +invCmd "pamfunc -multiplier testimg.ppm" +invCmd "pamfunc -multiplier=-1 testimg.ppm" +invCmd "pamfunc -divisor testimg.ppm" +invCmd "pamfunc -divisor=-20 testimg.ppm" +invCmd "pamfunc -adder testimg.ppm" +invCmd "pamfunc -adder 0.5 testimg.ppm" +invCmd "pamfunc -subtractor testimg.ppm" +invCmd "pamfunc -subtractor 0.1 testimg.ppm" +invCmd "pamfunc -multiplier=1 -divisor=2 testimg.ppm" +invCmd "pamfunc -adder=2 -subtractor=3 testimg.ppm" +invCmd "pamfunc -min testimg.ppm" +invCmd "pamfunc -max testimg.ppm" +invCmd "pamfunc -andmask testimg.ppm" +invCmd "pamfunc -ormask testimg.ppm" +invCmd "pamfunc -xormask testimg.ppm" +invCmd "pamfunc -not 1 testimg.ppm" +invCmd "pamfunc -min=1 -max=2 testimg.ppm" +invCmd "pamfunc -andmask=1 -ormask=0 testimg.ppm" +invCmd "pamfunc -andmask=0xffff testimg.ppm" +invCmd "pamfunc -shiftleft testimg.ppm" +invCmd "pamfunc -shiftright testimg.ppm" +invCmd "pamfunc -changemaxval testimg.ppm" +invCmd "pamfunc -shiftleft=1 -shiftright=1 testimg.ppm" +invCmd "pamfunc -multiplier=0.5 -changemaxval=65535 testimg.ppm" diff --git a/test/pamgauss.ok b/test/pamgauss.ok index e31a2ee8..98d97312 100644 --- a/test/pamgauss.ok +++ b/test/pamgauss.ok @@ -84,8 +84,11 @@ Test 2 stdin: PAM, 3 by 3 by 1 maxval 255 Tuple type: GRAYSCALE Test Invalid -Expected failure 1 1 -Expected failure 2 1 -Expected failure 3 1 -Expected failure 4 1 -Expected failure 5 1 +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) +Expected failure 5 (no output) +Expected failure 6 (no output) +Expected failure 7 (no output) +Expected failure 8 (no output) diff --git a/test/pamgauss.test b/test/pamgauss.test index bb006ce9..34b6630a 100755 --- a/test/pamgauss.test +++ b/test/pamgauss.test @@ -1,16 +1,16 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamgauss # Also requires: pamfile echo "Test 1" -for i in `seq 3 11` -do -for s in `seq 1 9` -do -pamgauss $i $i -oversample=1 -sigma=.$s | cksum -done -done +for i in 3 4 5 6 7 8 9 10 11 # for i in `seq 3 11` + do + for s in 1 2 3 4 5 6 7 8 9 # for s in `seq 9` + do + pamgauss ${i} ${i} -oversample=1 -sigma=.${s} | cksum + done + done echo "Test 2" @@ -19,23 +19,13 @@ pamgauss 3 3 -sigma=0.5 -tupletype="GRAYSCALE" | pamfile echo "Test Invalid" -echo 1>&2 -echo "Invalid command-line argument combinations." 1>&2 -echo "Error messages should appear below the line." 1>&2 -echo "-----------------------------------------------------------" 1>&2 - -tmpdir=${tmpdir:-/tmp} -test_out=${tmpdir}/test_out - -pamgauss 3 3 > ${test_out} || \ - echo -n "Expected failure 1"; test -s ${test_out}; echo " "$? -pamgauss 3 3 -sigma=0 > ${test_out} || \ - echo -n "Expected failure 2"; test -s ${test_out}; echo " "$? -pamgauss 3 3 -sigma=-1.5 > ${test_out} || \ - echo -n "Expected failure 3"; test -s ${test_out}; echo " "$? -pamgauss 3 -sigma=0.5 > ${test_out} || \ - echo -n "Expected failure 4"; test -s ${test_out}; echo " "$? -pamgauss 3 3 3 -sigma=0.5 > ${test_out} || \ - echo -n "Expected failure 5"; test -s ${test_out}; echo " "$? - -rm ${test_out} +. ${srcdir}/test-invalid.inc + +invCmd "pamgauss -sigma=0.5 " +invCmd "pamgauss 0 5 -sigma=0.5 " +invCmd "pamgauss 5 0 -sigma=0.5" +invCmd "pamgauss 3 3 " +invCmd "pamgauss 3 3 -sigma=0 " +invCmd "pamgauss 3 3 -sigma=-1.5" +invCmd "pamgauss 3 -sigma=0.5 " +invCmd "pamgauss 3 3 3 -sigma=0.5 " diff --git a/test/pamhue-roundtrip.test b/test/pamhue-roundtrip.test index 643ac99a..d68ee344 100755 --- a/test/pamhue-roundtrip.test +++ b/test/pamhue-roundtrip.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamhue # Also requires: diff --git a/test/pamhue.ok b/test/pamhue.ok index 5935cc5e..4bc4c385 100644 --- a/test/pamhue.ok +++ b/test/pamhue.ok @@ -33,4 +33,4 @@ Test 4 0 0 : 0 0 0 : 0 Test Invalid -Expected failure 1 1 +Expected failure 1 (no output) diff --git a/test/pamhue.test b/test/pamhue.test index d81a0acb..ce148a45 100755 --- a/test/pamhue.test +++ b/test/pamhue.test @@ -16,11 +16,11 @@ pamseq -tupletype=RGB 3 1 | pamdepth 255 | pamhue -huechange=60 | \ echo "Test 3" # pamhue has no effect on monotone images -# Should print 2425386270 41 twice +# Should print 281226646 481 twice -pamhue -huechange=45 testgrid.pbm | cmp -s - testgrid.pbm +pamhue -huechange=45 maze.pbm | cmp -s - maze.pbm echo ${PIPESTATUS[@]} ":" $? -pamhue -huechange=180 testgrid.pbm | cmp -s - testgrid.pbm +pamhue -huechange=180 maze.pbm | cmp -s - maze.pbm echo ${PIPESTATUS[@]} ":" $? echo "Test 4" @@ -34,15 +34,6 @@ pamhue -huechange=360 testimg.ppm | cmp -s - testimg.ppm echo "Test Invalid" -tmpdir=${tmpdir:-/tmp} -test_out=${tmpdir}/test_out +. ${srcdir}/test-invalid.inc -echo 1>&2 -echo "Omission of mandatory argument." 1>&2 -echo "An error message should appear below the line." 1>&2 -echo "-----------------------------------------------------------" 1>&2 - -pamhue testimg.ppm > ${test_out} || \ - echo -n "Expected failure 1"; test -s ${test_out}; echo " "$? - -rm -f ${test_out} +invCmd "pamhue testimg.ppm " diff --git a/test/pammixmulti-identity.test b/test/pammixmulti-identity.test index d205c359..21136fbe 100755 --- a/test/pammixmulti-identity.test +++ b/test/pammixmulti-identity.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pammixmulti # Also requires: pgmnoise pnminvert pamsumm diff --git a/test/pamrecolor.ok b/test/pamrecolor.ok new file mode 100644 index 00000000..f1bd74fb --- /dev/null +++ b/test/pamrecolor.ok @@ -0,0 +1,11 @@ +Test 1. Should produce 3500040755 101532 +3500040755 101532 +Test 2. Should produce 3500040755 101532 twice +3500040755 101532 +3500040755 101532 +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) +Expected failure 5 (no output) +Expected failure 6 (no output) diff --git a/test/pamrecolor.test b/test/pamrecolor.test new file mode 100755 index 00000000..b5674776 --- /dev/null +++ b/test/pamrecolor.test @@ -0,0 +1,31 @@ +#! /bin/sh +# This script tests: pamrecolor +# Also requires: ppmtopgm pgmmake + +tmpdir=${tmpdir:-/tmp} +base_pgm=${tmpdir}/base.pgm + +pgmmake 0.5 230 150 > ${base_pgm} + +echo "Test 1. Should produce 3500040755 101532" + +pamrecolor --colorfile=${base_pgm} testimg.ppm | cksum + +echo "Test 2. Should produce 3500040755 101532 twice" + +pamrecolor --targetcolor=rgb:80/80/80 testimg.ppm | cksum +pamrecolor --colorspace=ntsc --targetcolor=rgb:80/80/80 testimg.ppm | cksum + +. ${srcdir}/test-invalid.inc + +truncated_file=${tmpdir}/truncated.txt +echo P6 > ${truncated_file} + +invCmd "pamrecolor --targetcolor=rgb:00/11/22 --colorfile=${base_pgm} testimg.ppm" +invCmd "pamrecolor --rmult=0.3 --gmult=0.3 --bmult=0.3 --colorfile=${base_pgm} testimg.ppm" +invCmd "pamrecolor --colorspace=void --targetcolor=rgb:80/80/80 testimg.ppm" +invCmd "pamrecolor --targetcolor=vague testimg.ppm" +invCmd "pamrecolor --colorfile=${truncated_file} testimg.ppm" +invCmd "pamrecolor --rmult=0.2989 --gmult=0.5866 testimg.ppm" + +rm ${base_pgm} ${truncated_file} diff --git a/test/pamrestack.ok b/test/pamrestack.ok new file mode 100644 index 00000000..63f809e8 --- /dev/null +++ b/test/pamrestack.ok @@ -0,0 +1,68 @@ +Test 1. +P2 +24 1 +7 +0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 +P2 +10 3 +7 +0 1 2 3 4 5 6 7 0 1 +2 3 4 5 6 7 0 1 2 3 +4 5 6 7 0 0 0 0 0 0 +P2 +10 2 +7 +0 1 2 3 4 5 6 7 0 1 +2 3 4 5 6 7 0 1 2 3 +P2 +4 6 +7 +0 1 2 3 +4 5 6 7 +0 1 2 3 +4 5 6 7 +0 1 2 3 +4 5 6 7 +P2 +12 2 +7 +0 1 2 3 4 5 6 7 0 1 2 3 +4 5 6 7 0 1 2 3 4 5 6 7 +Test 2. Should print 0 twelve times +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +Test 3. Should produce 3141273448 431 fifteen times +3141273448 431 +3141273448 431 +3141273448 431 +3141273448 431 +3141273448 431 +3141273448 431 +3141273448 431 +3141273448 431 +3141273448 431 +3141273448 431 +3141273448 431 +3141273448 431 +3141273448 431 +3141273448 431 +3141273448 431 +Test 4. Should produce 1768948962 101484 twice +1768948962 101484 +1768948962 101484 +Test Invalid. +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) +Expected failure 5 (no output) diff --git a/test/pamrestack.test b/test/pamrestack.test new file mode 100755 index 00000000..c91830e4 --- /dev/null +++ b/test/pamrestack.test @@ -0,0 +1,67 @@ +#! /bin/sh +# This script tests: pamrestack +# Also requires: pamfile pamflip pgmramp pnmcrop pnminvert + +tmpdir=${tmpdir:-/tmp} +ramp_pgm=${tmpdir}/ramp.pgm +ramp2_pgm=${tmpdir}/ramp2.pgm +maze_singlerow_pbm=${tmpdir}/maze_singlerow.pbm +maze_inverted_pbm=${tmpdir}/maze_inverted.pbm + +echo "Test 1." + +pgmramp -lr -maxval=7 8 3 | tee ${ramp_pgm} | pamrestack -plain +pamrestack -width=10 -trim=fill -plain ${ramp_pgm} +pamrestack -width=10 -trim=crop -plain ${ramp_pgm} +pamrestack -width=4 -trim=fill -plain ${ramp_pgm} +pamrestack -width=12 -trim=fill -plain ${ramp_pgm} + +echo "Test 2. Should print 0 twelve times" + +for width in 2 4 5 8 12 24 +do + pamrestack -width=${width} -trim=crop ${ramp_pgm} > ${ramp2_pgm} + for flag in "-trim=crop" "-trim=fill" + do + pamrestack -width=${width} ${flag} ${ramp2_pgm} | cmp -s - ${ramp2_pgm} + echo $? + done +done + +rm ${ramp_pgm} ${ramp2_pgm} + +echo "Test 3. Should produce 3141273448 431 fifteen times" + +# Invert maze.pbm because the lower right corner is black + +pixels=`pamfile -size maze.pbm | awk '{print $1 * $2}'` + +pnminvert maze.pbm | tee ${maze_inverted_pbm} | \ + pamrestack | tee ${maze_singlerow_pbm} | pnmcrop -right -black | cksum +for width in 1 2 3 100 1000 ${pixels} $((pixels -1)) +do +pamrestack -width=${width} ${maze_inverted_pbm} | pamrestack | \ + pnmcrop -right -black | cksum +pamrestack -width=${width} ${maze_singlerow_pbm} | \ + pamrestack | pnmcrop -right -black | cksum +done + +rm ${maze_inverted_pbm} ${maze_singlerow_pbm} + +echo "Test 4. Should produce 1768948962 101484 twice" + +pamrestack -width=1 testimg.ppm | pamflip -ccw | cksum +pamrestack \ + -width=`pamfile -size testimg.ppm | cut -d " " -f2` testimg.ppm | \ + pamrestack | cksum + +test_out=${tmpdir}/test_out +echo "Test Invalid." + +. ${srcdir}/test-invalid.inc + +invCmd "pamrestack testgrid.pbm maze.pbm" +invCmd "pamrestack -abort -width=$((pixels * 2 + 1 )) maze.pbm" +invCmd "pamrestack -crop -width=$((pixels * 2 + 1)) maze.pbm" +invCmd "pamrestack -width=0 maze.pbm" +invCmd "pamrestack -width maze.pbm" diff --git a/test/pamscale-filters1.test b/test/pamscale-filters1.test index 63e0d012..c81dcf9a 100755 --- a/test/pamscale-filters1.test +++ b/test/pamscale-filters1.test @@ -1,12 +1,12 @@ #! /bin/bash # This script tests: pamscale pamenlarge -# Also requires: pamvalidate pnmpsnr +# Also requires: pamfile pamvalidate pnmpsnr tmpdir=${tmpdir:-/tmp} enlarge_ppm=${tmpdir}/enlarge.ppm -width_height=`pamfile -size testimg.ppm | \ - awk '{print "-width="$1, "-height="$2}'` +width_height=$(pamfile -size testimg.ppm | \ + awk '{print "-width="$1, "-height="$2}') # The target values here were determined by running the test on a # 32-bit GNU/Linux system and subtracting 2.5 (dB) from observed diff --git a/test/pamscale-filters2.test b/test/pamscale-filters2.test index f7370020..d3cb8d6c 100755 --- a/test/pamscale-filters2.test +++ b/test/pamscale-filters2.test @@ -1,12 +1,12 @@ #! /bin/bash # This script tests: pamscale pamstretch pamstretch-gen -# Also requires: pamvalidate pnmpsnr +# Also requires: pamfile pamvalidate pnmpsnr tmpdir=${tmpdir:-/tmp} stretch_ppm=${tmpdir}/stretch.ppm -width_height=`pamfile -size testimg.ppm | \ - awk '{print "-width="$1, "-height="$2}'` +width_height=$(pamfile -size testimg.ppm | \ + awk '{print "-width="$1, "-height="$2}') pamstretch -xscale=4 -yscale=3 testimg.ppm | pamvalidate > ${stretch_ppm} echo -xscale=4 -yscale=3 mitchell: diff --git a/test/pamscale-filters3.test b/test/pamscale-filters3.test index 5a865508..8d20e690 100755 --- a/test/pamscale-filters3.test +++ b/test/pamscale-filters3.test @@ -1,12 +1,12 @@ #! /bin/bash # This script tests: pamscale pamstretch pamstretch-gen -# Also requires: pamvalidate pnmpsnr +# Also requires: pamfile pamvalidate pnmpsnr tmpdir=${tmpdir:-/tmp} stretch_ppm=${tmpdir}/stretch.ppm -width_height=`pamfile -size testimg.ppm | \ - awk '{print "-width="$1, "-height="$2}'` +width_height=$(pamfile -size testimg.ppm | \ + awk '{print "-width="$1, "-height="$2}') pamstretch-gen 3.96 testimg.ppm | pamvalidate > ${stretch_ppm} echo 3.96 hermite: diff --git a/test/pamscale-reportonly.ok b/test/pamscale-reportonly.ok index bf5cde99..a3ece300 100644 --- a/test/pamscale-reportonly.ok +++ b/test/pamscale-reportonly.ok @@ -12,9 +12,9 @@ Test 1 227 149 1.400881 2.684564 318 400 227 149 1.000000 1.000000 227 149 Test Invalid -Expected failure 1 1 -Expected failure 2 1 -Expected failure 3 1 -Expected failure 4 1 -Expected failure 5 1 -Expected failure 6 1 +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) +Expected failure 5 (no output) +Expected failure 6 (no output) diff --git a/test/pamscale-reportonly.test b/test/pamscale-reportonly.test index 45a38687..39745809 100755 --- a/test/pamscale-reportonly.test +++ b/test/pamscale-reportonly.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamscale # Also requires: @@ -19,33 +19,13 @@ pamscale -reportonly -pixels=45000 testimg.ppm echo "Test Invalid" -tmpdir=${tmpdir:-/tmp} -test_out=${tmpdir}/test_out +. ${srcdir}/test-invalid.inc # Expected failure cases -echo 1>&2 -echo "Invalid command-line argument combinations." 1>&2 -echo "Error messages should appear below the line." 1>&2 -echo "-----------------------------------------------------------" 1>&2 - -pamscale -reportonly -xsize=640 -ysize=400 -xscale=2 testimg.ppm > \ - ${test_out} \ - || echo -n "Expected failure 1"; test -s ${test_out}; echo " "$? -pamscale -reportonly -xsize=640 -xscale=2 -yscale=3 testimg.ppm > \ - ${test_out} \ - || echo -n "Expected failure 2"; test -s ${test_out}; echo " "$? -pamscale -reportonly -xsize=640 -ysize=400 -pixels=200000 testimg.ppm \ - > ${test_out} || \ - echo -n "Expected failure 3"; test -s ${test_out}; echo " "$? -pamscale -reportonly -xsize=640 -ysize=400 -xysize 640 400 testimg.ppm \ - > ${test_out} || \ - echo -n "Expected failure 4"; test -s ${test_out}; echo " "$? -pamscale -reportonly -xsize=640 -ysize=400 -xyfit 640 400 testimg.ppm \ - > ${test_out} || \ - echo -n "Expected failure 5"; test -s ${test_out}; echo " "$? -pamscale -reportonly -xsize=640 -ysize=400 -xyfill 640 400 testimg.ppm \ - > ${test_out} || \ - echo -n "Expected failure 6"; test -s ${test_out}; echo " "$? - -rm ${test_out} +invCmd "pamscale -reportonly -xsize=640 -ysize=400 -xscale=2 testimg.ppm" +invCmd "pamscale -reportonly -xsize=640 -xscale=2 -yscale=3 testimg.ppm" +invCmd "pamscale -reportonly -xsize=640 -ysize=400 -pixels=200000 testimg.ppm" +invCmd "pamscale -reportonly -xsize=640 -ysize=400 -xysize 640 400 testimg.ppm" +invCmd "pamscale -reportonly -xsize=640 -ysize=400 -xyfit 640 400 testimg.ppm" +invCmd "pamscale -reportonly -xsize=640 -ysize=400 -xyfill 640 400 testimg.ppm" diff --git a/test/pamseq.ok b/test/pamseq.ok index 654596fb..a632de66 100644 --- a/test/pamseq.ok +++ b/test/pamseq.ok @@ -1,7 +1,7 @@ Test 1 3929266994 304 Test Invalid -Expected failure 1 1 -Expected failure 2 1 -Expected failure 3 1 -Expected failure 4 1 +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) diff --git a/test/pamseq.test b/test/pamseq.test index 0681d396..894e8d6d 100755 --- a/test/pamseq.test +++ b/test/pamseq.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamseq # Also requires: @@ -8,27 +8,14 @@ pamseq 1 255 | cksum echo "Test Invalid" -echo 1>&2 -echo "Invalid command-line argument combinations." 1>&2 -echo "Error messages should appear below the line." 1>&2 -echo "-----------------------------------------------------------" 1>&2 +. ${srcdir}/test-invalid.inc -tmpdir=${tmpdir:-/tmp} -test_out=${tmpdir}/test_out - -pamseq 1 > ${test_out} || \ - echo -n "Expected failure 1"; test -s ${test_out}; echo " "$? -pamseq 0 255 > ${test_out} || \ - echo -n "Expected failure 2"; test -s ${test_out}; echo " "$? -pamseq 3 0 > ${test_out} || \ - echo -n "Expected failure 3"; test -s ${test_out}; echo " "$? +invCmd "pamseq 1" +invCmd "pamseq 0 255" +invCmd "pamseq 3 0" +# Tupletype string length=256 c64="0123456789012345678901234567890123456789012345678901234567890123" c256=${c64}${c64}${c64}${c64} -# Tupletype string length=256 - -pamseq -tupletype="${c256}" 3 15 > ${test_out} || \ - echo -n "Expected failure 4"; test -s ${test_out}; echo " "$? - -rm ${test_out} +invCmd "pamseq -tupletype=${c256} 3 15" diff --git a/test/pamshuffle.ok b/test/pamshuffle.ok new file mode 100644 index 00000000..ec8c1a9c --- /dev/null +++ b/test/pamshuffle.ok @@ -0,0 +1,19 @@ +Test 1. Should print 1081361896 1432 five times +1081361896 1432 +1081361896 1432 +1081361896 1432 +1081361896 1432 +1081361896 1432 +Test 2. Should print 1936883899 143517 four times +1936883899 143517 +1936883899 143517 +1936883899 143517 +1936883899 143517 +Test 3. Should print nomatch three times +nomatch +nomatch +nomatch +Test Invalid. +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) diff --git a/test/pamshuffle.test b/test/pamshuffle.test new file mode 100755 index 00000000..371b65a5 --- /dev/null +++ b/test/pamshuffle.test @@ -0,0 +1,53 @@ +#! /bin/sh +# This script tests: pamshuffle +# Also requires: pamseq pamrestack pgmhist ppmhist pnmpsnr + +tmpdir=${tmpdir:-/tmp} +seq_pam=${tmpdir}/seq.pam +seq16_pam=${tmpdir}/seq16.pam + +out1_pam=${tmpdir}/out1.pam + +echo "Test 1. Should print 1081361896 1432 five times" + +pgmhist -machine maze.pbm | cksum +pamshuffle -randomseed=1 maze.pbm | pgmhist -machine | cksum +pamshuffle -randomseed=2 maze.pbm | pgmhist -machine | cksum +pamshuffle -column -randomseed=3 maze.pbm | pgmhist -machine | cksum +pamrestack maze.pbm | pamshuffle -randomseed=3 | pgmhist -machine | cksum + +echo "Test 2. Should print 1936883899 143517 four times" + +pamseq -tupletype="RGB" 3 15 > ${seq_pam} + +ppmhist -map ${seq_pam} | cksum +pamshuffle -randomseed=2 ${seq_pam} | ppmhist -map | cksum +pamrestack -width=16 -trim=abort ${seq_pam} | tee ${seq16_pam} | \ + ppmhist -map | cksum +pamshuffle -column -randomseed=3 ${seq16_pam} | ppmhist -map | cksum + +echo "Test 3. Should print nomatch three times" + +pamshuffle -randomseed=$((100 +i)) ${seq16_pam} > ${out1_pam} +pamshuffle -randomseed=${i} ${seq16_pam} | \ +pnmpsnr -target=14.0 ${out1_pam} - +rm ${seq_pam} ${seq16_pam} ${out1_pam} + +pamshuffle -randomseed=$((100 +i)) testimg.ppm > ${out1_pam} +pamshuffle -randomseed=${i} testimg.ppm | \ + pnmpsnr -target=14.0 ${out1_pam} - +rm ${out1_pam} + +pamshuffle -randomseed=$((100 +i)) -column testimg.ppm > ${out1_pam} +pamshuffle -randomseed=${i} -column testimg.ppm | \ + pnmpsnr -target=14.0 ${out1_pam} - +rm ${out1_pam} + +test_out=${tmpdir}/test_out +echo "Test Invalid." + +. ${srcdir}/test-invalid.inc + +invCmd "pamshuffle testimg.ppm testgrid.pbm" +invCmd "pamshuffle -randomseed -column testgrid.pbm" +invCmd "pamshuffle -randomseed=null testgrid.pbm" diff --git a/test/pamslice-roundtrip.ok b/test/pamslice-roundtrip.ok index eae64745..50e83b2a 100644 --- a/test/pamslice-roundtrip.ok +++ b/test/pamslice-roundtrip.ok @@ -1,4 +1,9 @@ -2425386270 41 -914327477 4864 -914327477 4864 -914327477 4864 +Test 1. Should print 139976034 137 twice +139976034 137 +139976034 137 +Test 2. Should print 1624460505 574 three times +1624460505 574 +1624460505 574 +1624460505 574 +Test 3. Should print 1624460505 574 +1624460505 574 diff --git a/test/pamslice-roundtrip.test b/test/pamslice-roundtrip.test index 6cb5533f..2b7929cf 100755 --- a/test/pamslice-roundtrip.test +++ b/test/pamslice-roundtrip.test @@ -1,75 +1,75 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamslice pamdeinterlace -# Also requires: pamcut pamtopnm pamflip +# Also requires: pamfile pamcut pamtopnm pamflip - -# Test 1. -# Slice rows, one by one, out of testgrid.pbm. +echo "Test 1. Should print 139976034 137 twice" +# Slice rows, one by one, out of maze.pbm. # Add header and reconstruct pbm image. # Note that in pamslice output 0 is white and 1 is black: opposite of PBM -# Should print 2425386270 41 + +mwidth=$(pamfile -size maze.pbm | cut -d " " -f 1) +height=16 + +pamcut -top=0 -left=0 -height=${height} maze.pbm | cksum (echo "P1" - echo "14 16" - seq 0 15 | while read i; + echo "${mwidth} ${height}" + for i in `seq 0 $((${height}-1))` do - pamslice -row=$i testgrid.pbm - done | awk '{print $2}' | sed 'y/01/10/' ) \ + pamslice -row=$i maze.pbm + done | cut -d" " -f2- | sed 'y/01/10/' ) \ | pamtopnm | cksum -# Test 2. + +echo "Test 2. Should print 1624460505 574 three times" # Slice rows, one by one, out of ppm test image # We take a part out of testimg.ppm with pamcut for processing the # whole image takes much time. # Add header and reconstruct ppm image. -# Should print 914327477 4864 tmpdir=${tmpdir:-/tmp} +test1711_ppm=${tmpdir}/test1711.ppm -test4933_ppm=${tmpdir}/test4933.ppm - -pamcut 50 50 49 33 testimg.ppm > ${test4933_ppm} +pamcut -left=50 -top=50 -width=17 -height=11 testimg.ppm | \ + tee ${test1711_ppm} | cksum (echo "P3" - echo "49 33" + echo "17 11" echo "255" - seq 0 32 | while read i; + for i in 0 1 2 3 4 5 6 7 8 9 10 # for i in `seq 0 10` do - pamslice -row=$i ${test4933_ppm} - done | awk '{print $2, $3, $4}' ) \ + pamslice -row=${i} ${test1711_ppm} + done | cut -d" " -f2- ) \ | pamtopnm | cksum # Same as above test 2, but take cols instead of rows. -# Should print 914327477 4864 (echo "P3" - echo "33 49" + echo "11 17" echo "255" - seq 0 48 | while read i; + for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 # for i in `seq 0 16` do - pamslice -col=$i ${test4933_ppm} - done | awk '{print $2, $3, $4}' ) \ - | pamflip -xy | cksum + pamslice -col=${i} ${test1711_ppm} + done | cut -d " " -f2- ) | pamflip -xy | cksum -# Test 4. +echo "Test 3. Should print 1624460505 574" # Divide input image into two with pamdeinterlace and recombine. testeven_ppm=${tmpdir}/testeven.ppm testodd_ppm=${tmpdir}/testodd.ppm -pamdeinterlace -takeodd ${test4933_ppm} > ${testodd_ppm} -pamdeinterlace -takeeven ${test4933_ppm} > ${testeven_ppm} +pamdeinterlace -takeodd ${test1711_ppm} > ${testodd_ppm} +pamdeinterlace -takeeven ${test1711_ppm} > ${testeven_ppm} -(echo "P3" - echo "49 33" - echo "255" - ( seq 0 15 | while read i; - do - pamslice -row=$i ${testeven_ppm} - pamslice -row=$i ${testodd_ppm} - done - pamslice -row=16 ${testeven_ppm}; - ) | awk '{print $2, $3, $4}' ) \ - | pamtopnm | cksum +( echo "P3" + echo "17 11" + echo "255" + ( for i in 0 1 2 3 4 + do + pamslice -row=${i} ${testeven_ppm} + pamslice -row=${i} ${testodd_ppm} + done + pamslice -row=5 ${testeven_ppm}; + ) | cut -d" " -f2- ) | pamtopnm | cksum -rm ${test4933_ppm} ${testodd_ppm} ${testeven_ppm} +rm ${test1711_ppm} ${testodd_ppm} ${testeven_ppm} diff --git a/test/pamstack.ok b/test/pamstack.ok new file mode 100644 index 00000000..881cb6c5 --- /dev/null +++ b/test/pamstack.ok @@ -0,0 +1,38 @@ +test 0: Should print 1652911383 4046 +1652911383 4046 +test 1: Should print 1398841785 13544 three times +1398841785 13544 +1398841785 13544 +1398841785 13544 +test 2: Should print 210239904 3186 five times +210239904 3186 +210239904 3186 +210239904 3186 +210239904 3186 +210239904 3186 +test 3: maxval should be 65535 +stdin: PAM, 14 by 16 by 6 maxval 65535 + Tuple type: +stdin: PAM, 14 by 16 by 6 maxval 65535 + Tuple type: +stdin: PAM, 14 by 16 by 5 maxval 65535 + Tuple type: +stdin: PAM, 14 by 16 by 2 maxval 65535 + Tuple type: +test 4: maxval should be 255 then 767 +stdin: PAM, 14 by 16 by 2 maxval 255 + Tuple type: +stdin: PAM, 14 by 16 by 2 maxval 767 + Tuple type: +test 5: Should print 2741208386 719 twice +2741208386 719 +2741208386 719 +test 6: Should print true four times +true +true +true +true +Test Invalid +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) diff --git a/test/pamstack.test b/test/pamstack.test new file mode 100755 index 00000000..6374c4bd --- /dev/null +++ b/test/pamstack.test @@ -0,0 +1,108 @@ +#! /bin/sh +# This script tests: pamstack +# Also requires: pamdepth pgmmake pamfile + +tmpdir=${tmpdir:-/tmp} +i1_pgm=${tmpdir}/testimg_1.pnm +i2_pgm=${tmpdir}/testimg_2.pgm +i7_pgm=${tmpdir}/testimg_7.pgm +i31_pgm=${tmpdir}/testimg_31.pgm +std_pgm=${tmpdir}/testimg_255.pgm +max_pgm=${tmpdir}/testimg_max.pgm + +maze2_pbm=${tmpdir}/testimg_maze2.pgm +maze3_pbm=${tmpdir}/testimg_maze3.pgm + +pamdepth 1 testgrid.pbm > ${i1_pgm} +pgmmake -maxval=2 0 14 16 > ${i2_pgm} +pgmmake -maxval=7 0.5 14 16 > ${i7_pgm} +pgmmake -maxval=31 0.5 14 16 > ${i31_pgm} +pgmmake -maxval=255 0.5 14 16 > ${std_pgm} +pgmmake -maxval=65535 0.5 14 16 > ${max_pgm} +cat maze.pbm maze.pbm > ${maze2_pbm} +cat maze.pbm maze.pbm maze.pbm > ${maze3_pbm} + +# test 0 +echo test 0: Should print 1652911383 4046 + +# Test the integrity of the input files +cat ${i1_pgm} ${i2_pgm} ${i7_pgm} ${i31_pgm} ${std_pgm} ${max_pgm} \ + ${maze2_pbm} ${maze3_pbm}| cksum + +# test 1 +echo test 1: Should print 1398841785 13544 three times +pamstack ${maze2_pbm} ${maze2_pbm} | cksum +pamstack ${maze3_pbm} ${maze2_pbm} | cksum +pamstack ${maze2_pbm} ${maze3_pbm} | cksum + +rm ${maze2_pbm} ${maze3_pbm} + +# test 2 +echo test 2: Should print 210239904 3186 five times +pamstack -firstmaxval ${max_pgm} ${std_pgm} ${i31_pgm} \ + ${i7_pgm} ${i2_pgm} ${i1_pgm} ${i1_pgm} | cksum +pamstack -firstmaxval ${max_pgm} ${std_pgm} ${i31_pgm} \ + ${i7_pgm} ${i2_pgm} ${i1_pgm} testgrid.pbm | cksum + +pamstack -lcmmaxval ${max_pgm} ${std_pgm} ${i31_pgm} \ + ${i7_pgm} ${i2_pgm} ${i1_pgm} ${i1_pgm} | cksum +pamstack ${i1_pgm} ${i1_pgm} |\ + pamstack -firstmaxval ${max_pgm} ${std_pgm} ${i31_pgm} ${i7_pgm} ${i2_pgm} - | cksum +pamstack -firstmaxval ${i2_pgm} testgrid.pbm ${i1_pgm} |\ + pamstack -firstmaxval ${max_pgm} ${std_pgm} ${i31_pgm} ${i7_pgm} - | cksum + + +# test 3 +echo test 3: maxval should be 65535 +pamstack -firstmaxval ${max_pgm} ${std_pgm} ${i31_pgm} \ + ${i7_pgm} ${i2_pgm} ${i1_pgm} | pamfile + +pamstack -lcmmaxval ${max_pgm} ${std_pgm} ${i31_pgm} \ + ${i7_pgm} ${i2_pgm} ${i1_pgm} | pamfile + +pamstack -lcmmaxval ${max_pgm} ${std_pgm} ${i31_pgm} ${i7_pgm} ${i1_pgm} | pamfile + +pamstack -firstmaxval ${max_pgm} ${i2_pgm} | pamfile + + +# test 4 +echo test 4: maxval should be 255 then 767 +pamstack -firstmaxval ${std_pgm} ${i2_pgm} | pamfile +pamstack -lcmmaxval ${std_pgm} ${i2_pgm} | pamfile + +# test 5 +echo test 5: Should print 2741208386 719 twice + +pamstack -lcmmaxval ${i31_pgm} ${i1_pgm} ${i7_pgm} | cksum +pamstack -firstmaxval ${i31_pgm} ${i1_pgm} ${i7_pgm} | cksum + +# test 6 +echo test 6: Should print true four times + +s0=$(pamstack ${i1_pgm} | pamfile) +s1=$(pamstack -lcmmaxval ${i1_pgm} | pamfile) +s2=$(pamstack -firstmaxval ${i1_pgm} | pamfile) + +test "$s0" = "$s1" && echo "true" || echo "false" +test "$s0" = "$s2" && echo "true" || echo "false" + + +s0=$(pamstack ${std_pgm} | pamfile) +s1=$(pamstack -lcmmaxval ${std_pgm} | pamfile) +s2=$(pamstack -firstmaxval ${std_pgm} | pamfile) + +test "$s0" = "$s1" && echo "true" || echo "false" +test "$s0" = "$s2" && echo "true" || echo "false" + + +# Test Invalid +echo "Test Invalid" + +. ${srcdir}/test-invalid.inc + +invCmd "pamstack testgrid.pbm testimg.ppm" +invCmd "pamstack ${i1_pgm} ${std_pgm}" +invCmd "pamstack -lcmmaxval -firstmaxval testgrid.pbm testgrid.pbm" + +rm ${i1_pgm} ${i2_pgm} ${i7_pgm} ${i31_pgm} ${std_pgm} ${max_pgm} + diff --git a/test/pamstereogram.ok b/test/pamstereogram.ok new file mode 100644 index 00000000..265a4fc5 --- /dev/null +++ b/test/pamstereogram.ok @@ -0,0 +1,32 @@ +Test 00. Should print 729348909 237 +729348909 237 +Test 01. Should print 3308667841 293 +3308667841 293 +Test 02. Should print 3308667841 293 +3308667841 293 +Test 03. Should print 748200469 170 +748200469 170 +Test 04. Should print 1538641408 1070 +1538641408 1070 +Test 10. Should print 1266273778 293 +1266273778 293 +Test 11. Should print 55276708 1070 +55276708 1070 +Test 20. Should print 1920539795 289 +1920539795 289 +Test 21. Should print 4069109690 4068 +4069109690 4068 +Test 22. Should print 1163376052 4068 +1163376052 4068 +Test 30. Should print 2127252909 731 +2127252909 731 +Test 31. Should print 858421050 12062 +858421050 12062 +Test 40. Should print 1236679620 660 +1236679620 660 +Test 41. Should print 1022068930 5014 +1022068930 5014 +Test 51. Should print 3784833098 11071 +3784833098 11071 +Test 52. Should print 1419662425 1441 +1419662425 1441 diff --git a/test/pamstereogram.test b/test/pamstereogram.test new file mode 100755 index 00000000..02da9724 --- /dev/null +++ b/test/pamstereogram.test @@ -0,0 +1,80 @@ +#! /bin/sh +# This script tests: pamstereogram +# Also requires: pamdepth + +tmpdir=${tmpdir:-/tmp} +testgrid_pgm=${tmpdir}/testgrid.pgm + +# Make input file + +echo "Test 00. Should print 729348909 237" +pamdepth -quiet 255 testgrid.pbm | tee ${testgrid_pgm} | cksum + + +# Random pattern + +echo "Test 01. Should print 3308667841 293" +pamstereogram -randomseed=1 testgrid.pbm | cksum +echo "Test 02. Should print 3308667841 293" +pamstereogram -randomseed=1 -blackandwhite testgrid.pbm | cksum +echo "Test 03. Should print 748200469 170" +pamseq -tupletype=GRAYSCALE 1 100 | pamstereogram -randomseed=1 | cksum +echo "Test 04. Should print 1538641408 1070" +pamgauss 100 10 -maxval=10000 -sigma 20 | pamfunc -multiplier=500 | \ + pamstereogram -randomseed=1 -dpi=10 | cksum + +# Makemask + +echo "Test 10. Should print 1266273778 293" +pamstereogram -randomseed=1 -makemask testgrid.pbm | cksum + +echo "Test 11. Should print 55276708 1070" +pamgauss 100 10 -maxval=10000 -sigma 20 | pamfunc -multiplier=500 | \ + pamstereogram -randomseed=1 -dpi=10 -makemask | cksum + +# Grayscale + +echo "Test 20. Should print 1920539795 289" +pamstereogram -randomseed=1 -grayscale testgrid.pbm | cksum +echo "Test 21. Should print 4069109690 4068" +pamseq 1 100 | pnmtile 200 20 | \ + pamstereogram -randomseed=1 -dpi=10 -grayscale | \ + cksum +echo "Test 22. Should print 1163376052 4068" +pamseq 1 100 | pnmtile 200 20 | \ + pamstereogram -randomseed=1 -dpi=10 -grayscale -maxval 255 | \ + cksum + +# Color + +echo "Test 30. Should print 2127252909 731" +pamstereogram -randomseed=1 -color testgrid.pbm | cksum +echo "Test 31. Should print 858421050 12062" +pamseq 1 100 | pnmtile 200 20 | \ + pamstereogram -randomseed=1 -dpi=10 -color | \ + cksum + +# Pattern file + +echo "Test 40. Should print 1236679620 660" +pamgradient black gray50 white gray50 100 50 | \ + pamstereogram -patfile testgrid.pbm -eyesep=.1 -crosseyed | cksum + +echo "Test 41. Should print 1022068930 5014" +pamgradient black gray50 white gray50 100 50 | \ + pamstereogram -patfile ${testgrid_pgm} -eyesep=.1 -crosseyed | cksum + +# drawguides + +echo "Test 51. Should print 3784833098 11071" +pamgradient black gray50 white gray50 100 50 | \ + pamstereogram -randomseed=1 -dpi 10 -guidesize=20 -guidetop | cksum + +echo "Test 52. Should print 1419662425 1441" +pamgradient black gray50 white gray50 100 50 | \ + pamstereogram -patfile=testgrid.pbm -dpi 10 -guidesize=20 -guidetop | cksum + + +# Clean up files we created +rm ${testgrid_pgm} + diff --git a/test/pamstretch.test b/test/pamstretch.test index 55dd4e9c..38e3a649 100755 --- a/test/pamstretch.test +++ b/test/pamstretch.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamstretch # Also requires: pamcut pamfile @@ -13,6 +13,7 @@ pamstretch -xscale=2 -blackedge testimg.ppm | cksum # Test 3. Should print 3427416462 301047 echo test 3 +tmpdir=${tmpdir:-/tmp} dropedge1_ppm=${tmpdir}/drop1.ppm pamstretch -yscale=3 -dropedge testimg.ppm | tee ${dropedge1_ppm} | cksum @@ -39,10 +40,10 @@ blackedge_ppm=${tmpdir}/black.ppm pamstretch 3 testimg.ppm | tee ${stretch_ppm} | cksum pamstretch 3 -blackedge testimg.ppm | tee ${blackedge_ppm} | cksum pamstretch -xscale=3 -dropedge ${dropedge1_ppm} | tee ${dropedge_ppm} | cksum -width_height=`pamfile -size ${dropedge_ppm} | \ - awk '{print "-width="$1, "-height="$2}'` +width_height=$(pamfile -size ${dropedge_ppm} | \ + awk '{print "-width="$1, "-height="$2}') pamcut -left=0 -top=0 ${width_height} ${stretch_ppm} | cksum pamcut -left=0 -top=0 ${width_height} ${blackedge_ppm} | cksum pamcut -left=0 -top=0 ${width_height} ${dropedge_ppm} | cksum -rm ${stretch_ppm} ${dropedge_ppm} ${dropedge1_ppm} ${blackedge_ppm} \ No newline at end of file +rm ${stretch_ppm} ${dropedge_ppm} ${dropedge1_ppm} ${blackedge_ppm} diff --git a/test/pamsumm.ok b/test/pamsumm.ok index 63b5f6bd..5524e7b5 100644 --- a/test/pamsumm.ok +++ b/test/pamsumm.ok @@ -1,15 +1,20 @@ -Test 1 +Test 1. Should print in order: 56, 0, 1, 0.250000 56 0 1 0.250000 -Test 2 +Test 2. Should print in order: 1627, 0, 1, 0.483794 +1627 +0 +1 +0.483794 +Test 3. Should print in order: 10772432, 15, 255, 106.164760 10772432 15 255 106.164760 Test Invalid -Expected failure 1 1 -Expected failure 2 1 -Expected failure 3 1 -Expected failure 4 1 +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) diff --git a/test/pamsumm.test b/test/pamsumm.test index 5b4fdb17..eb41ee36 100755 --- a/test/pamsumm.test +++ b/test/pamsumm.test @@ -1,39 +1,34 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamsumm # Also requires: -echo "Test 1" +echo "Test 1. Should print in order: 56, 0, 1, 0.250000" for type in -sum -min -max -mean do pamsumm -brief $type testgrid.pbm done -echo "Test 2" +echo "Test 2. Should print in order: 1627, 0, 1, 0.483794" for type in -sum -min -max -mean do - pamsumm -brief $type testimg.ppm + pamsumm -brief $type maze.pbm done +echo "Test 3. Should print in order: 10772432, 15, 255, 106.164760" -echo "Test Invalid" +for type in -sum -min -max -mean + do + pamsumm -brief $type testimg.ppm + done -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 +echo "Test Invalid" -pamsumm -sum -min testimg.ppm > ${test_out} || \ - echo -n "Expected failure 1"; test -s ${test_out}; echo " "$? -pamsumm -sum -max testimg.ppm > ${test_out} || \ - echo -n "Expected failure 2"; test -s ${test_out}; echo " "$? -pamsumm -mean -max testimg.ppm > ${test_out} || \ - echo -n "Expected failure 3"; test -s ${test_out}; echo " "$? -pamsumm testimg.ppm > ${test_out} || \ - echo -n "Expected failure 4"; test -s ${test_out}; echo " "$? +. ${srcdir}/test-invalid.inc -rm ${test_out} +invCmd "pamsumm -sum -min testimg.ppm" +invCmd "pamsumm -sum -max testimg.ppm" +invCmd "pamsumm -mean -max testimg.ppm" +invCmd "pamsumm testimg.ppm" diff --git a/test/pamtable.ok b/test/pamtable.ok index c8db6002..b63a74c2 100644 --- a/test/pamtable.ok +++ b/test/pamtable.ok @@ -1,3 +1,4 @@ +Test 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 @@ -15,10 +16,66 @@ 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +Test 2 0 0 0|0 0 1|0 0 2|0 1 0|0 1 1|0 1 2|0 2 0|0 2 1|0 2 2|1 0 0|1 0 1|1 0 2|1 1 0|1 1 1|1 1 2|1 2 0|1 2 1|1 2 2|2 0 0|2 0 1|2 0 2|2 1 0|2 1 1|2 1 2|2 2 0|2 2 1|2 2 2 +Test 3 0 0 0 0|0 0 0 1|0 0 1 0|0 0 1 1|0 1 0 0|0 1 0 1|0 1 1 0|0 1 1 1|1 0 0 0|1 0 0 1|1 0 1 0|1 0 1 1|1 1 0 0|1 1 0 1|1 1 1 0|1 1 1 1 +Test 4 +(1) (0) (1) (0) (1) + +Test 5 +(1) +(0) +(1) +(0) +(1) +(0) +(1) +(0) +(1) +(0) + +Test 6 +(0,0,0) (0,0,1) (0,0,2) +(0,0,3) (0,1,0) (0,1,1) +(0,1,2) (0,1,3) (0,2,0) +(0,2,1) (0,2,2) (0,2,3) +(0,3,0) (0,3,1) (0,3,2) +(0,3,3) (1,0,0) (1,0,1) +(1,0,2) (1,0,3) (1,1,0) +(1,1,1) (1,1,2) (1,1,3) +(1,2,0) (1,2,1) (1,2,2) +(1,2,3) (1,3,0) (1,3,1) +(1,3,2) (1,3,3) (2,0,0) +(2,0,1) (2,0,2) (2,0,3) +(2,1,0) (2,1,1) (2,1,2) +(2,1,3) (2,2,0) (2,2,1) +(2,2,2) (2,2,3) (2,3,0) +(2,3,1) (2,3,2) (2,3,3) +(3,0,0) (3,0,1) (3,0,2) +(3,0,3) (3,1,0) (3,1,1) +(3,1,2) (3,1,3) (3,2,0) +(3,2,1) (3,2,2) (3,2,3) +(3,3,0) (3,3,1) (3,3,2) +(3,3,3) (0,0,0) (0,0,0) + +Test 7 +00 00|00 11|00 22|00 33|00 44|00 55|00 66|00 77 +00 88|00 99|00 aa|00 bb|00 cc|00 dd|00 ee|00 ff +0a 00|0a 11|0a 22|0a 33|0a 44|0a 55|0a 66|0a 77 +0a 88|0a 99|0a aa|0a bb|0a cc|0a dd|0a ee|0a ff +14 00|14 11|14 22|14 33|14 44|14 55|14 66|14 77 +14 88|14 99|14 aa|14 bb|14 cc|14 dd|14 ee|14 ff +1e 00|1e 11|1e 22|1e 33|1e 44|1e 55|1e 66|1e 77 +1e 88|1e 99|1e aa|1e bb|1e cc|1e dd|1e ee|1e ff +28 00|28 11|28 22|28 33|28 44|28 55|28 66|28 77 +28 88|28 99|28 aa|28 bb|28 cc|28 dd|28 ee|28 ff +32 00|32 11|32 22|32 33|32 44|32 55|32 66|32 77 +32 88|32 99|32 aa|32 bb|32 cc|32 dd|32 ee|32 ff + +Test 8 9 0 0 9 @@ -64,3 +121,5 @@ 65535 0 0| 0 0 65535| 0 0 65535| 0 65535 0 65535 0 0| 0 0 65535| 0 0 65535| 0 65535 0 +Test Invalid +Expected failure 1 (no output) diff --git a/test/pamtable.test b/test/pamtable.test index 335d45c4..d42187f9 100755 --- a/test/pamtable.test +++ b/test/pamtable.test @@ -1,20 +1,55 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamtable -# Also requires: pamseq pamdepth pbmmake ppmrainbow +# Also requires: pamseq pamrestack pamdepth pbmmake ppmrainbow +echo "Test 1" pamtable testgrid.pbm + echo +echo "Test 2" pamseq 3 2 -tupletype=RGB | pamtable + echo +echo "Test 3" pamseq 4 1 -tupletype=RGBA | pamtable + +echo +echo "Test 4" +pbmmake -gray 5 1 | pamtable -tuple + +echo +echo "Test 5" +pbmmake -gray 1 10 | pamtable -tuple + echo +echo "Test 6" +pamseq 3 3 -tupletype=RGB | pamrestack -width=3 | pamtable -tuple + +echo +echo "Test 7" +pamseq 2 255 -max=50,255 -step=10,17 | pamrestack -width=8 | \ + pamtable -hex + +echo +echo "Test 8" for maxval in 9 10 9999 10000 65535 - do pbmmake -g 2 2 | pamdepth $maxval | pamtable - echo - ppmrainbow -width=3 -height=2 -norepeat black white | \ - pamdepth $maxval | pamtable - echo - ppmrainbow -width=4 -height=2 -norepeat red blue green | \ - pamdepth $maxval | pamtable - echo + do + pbmmake -g 2 2 | pamdepth ${maxval} | pamtable + echo + ppmrainbow -width=3 -height=2 -norepeat black white | \ + pamdepth ${maxval} | pamtable + echo + ppmrainbow -width=4 -height=2 -norepeat red blue green | \ + pamdepth ${maxval} | pamtable + echo done + +echo "Test Invalid" + +. ${srcdir}/test-invalid.inc + +input1_pam=${tmpdir}/input1.pam + +pamseq -tupletype="void" 1 1 > ${input1_pam} +invCmd "pamtable -tuple -hex ${input1_pam}" +rm ${input1_pam} diff --git a/test/pamtopam.ok b/test/pamtopam.ok index dcb597d3..d84b2b6c 100644 --- a/test/pamtopam.ok +++ b/test/pamtopam.ok @@ -1,3 +1,18 @@ +Test 1. Should print five PAM headers +P7 +WIDTH 14 +HEIGHT 16 +DEPTH 1 +MAXVAL 1 +TUPLTYPE BLACKANDWHITE +ENDHDR +P7 +WIDTH 1 +HEIGHT 1 +DEPTH 1 +MAXVAL 255 +TUPLTYPE GRAYSCALE +ENDHDR P7 WIDTH 227 HEIGHT 149 @@ -6,11 +21,26 @@ MAXVAL 255 TUPLTYPE RGB ENDHDR P7 -WIDTH 14 -HEIGHT 16 -DEPTH 1 +WIDTH 64 +HEIGHT 1 +DEPTH 2 +MAXVAL 7 +TUPLTYPE GRAYSCALE_ALPHA +ENDHDR +P7 +WIDTH 16 +HEIGHT 1 +DEPTH 4 MAXVAL 1 -TUPLTYPE BLACKANDWHITE +TUPLTYPE RGB_ALPHA ENDHDR -1873848880 101532 +Test 2. Should print 2260748250 293 2260748250 293 +Test 3. Should print 1873848880 101532 +1873848880 101532 +Test 4. Should print 1475247910 3432 twice +1475247910 3432 +1475247910 3432 +Test 5. Should print 2347274358 101825 twice +2347274358 101825 +2347274358 101825 diff --git a/test/pamtopam.test b/test/pamtopam.test index 394d9904..c12470ec 100755 --- a/test/pamtopam.test +++ b/test/pamtopam.test @@ -1,10 +1,25 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamtopam -# Also requires: +# Also requires: pgmmake pamseq +echo "Test 1. Should print five PAM headers" -pamtopam < testimg.ppm | sed '/ENDHDR/q' pamtopam < testgrid.pbm | sed '/ENDHDR/q' +pgmmake 0.5 1 1 | pamtopam | sed '/ENDHDR/q' +pamtopam < testimg.ppm | sed '/ENDHDR/q' +pamseq -tupletype="GRAYSCALE_ALPHA" 2 7 | pamtopam | sed '/ENDHDR/q' +pamseq -tupletype="RGB_ALPHA" 4 1 | pamtopam | sed '/ENDHDR/q' -pamtopam < testimg.ppm | cksum +echo "Test 2. Should print 2260748250 293" pamtopam < testgrid.pbm | cksum + +echo "Test 3. Should print 1873848880 101532" +pamtopam < testimg.ppm | cksum + +echo "Test 4. Should print 1475247910 3432 twice" +pamtopam < maze.pbm | cksum +pamtopam < maze.pbm | pamtopam | cksum + +echo "Test 5. Should print 2347274358 101825 twice" +cat testgrid.pbm testimg.ppm | pamtopam | cksum +( pamtopam < testgrid.pbm; pamtopam < testimg.ppm ) | cksum diff --git a/test/pamtopdbimg.test b/test/pamtopdbimg.test index 9afee8f1..d6c105bf 100755 --- a/test/pamtopdbimg.test +++ b/test/pamtopdbimg.test @@ -82,13 +82,13 @@ awk 'BEGIN { ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; head -c 65533 ${text65597} > ${text65533} head -c 65534 ${text65597} > ${text65534} -pamtopdbimg -uncompressed testgrid.pbm | \ +pamtopdbimg -uncompressed maze.pbm | \ wc -c | tr -d ' ' echo ${PIPESTATUS[0]} -pamtopdbimg -uncompressed -notefile=${text65533} testgrid.pbm | \ +pamtopdbimg -uncompressed -notefile=${text65533} maze.pbm | \ wc -c | tr -d ' ' echo ${PIPESTATUS[0]} -pamtopdbimg -uncompressed -notefile=${text65534} testgrid.pbm | \ +pamtopdbimg -uncompressed -notefile=${text65534} maze.pbm | \ wc -c | tr -d ' ' echo ${PIPESTATUS[0]} diff --git a/test/pamtosvg.ok b/test/pamtosvg.ok new file mode 100644 index 00000000..918555e0 --- /dev/null +++ b/test/pamtosvg.ok @@ -0,0 +1,4 @@ +Test 1. Should print match +match +Test 2. Should print match +match diff --git a/test/pamtosvg.test b/test/pamtosvg.test new file mode 100755 index 00000000..4acf1fd9 --- /dev/null +++ b/test/pamtosvg.test @@ -0,0 +1,45 @@ +#! /bin/sh +# This script tests: pamtosvg +# Also requires: ppmmake ppmdraw + +tmpdir=${tmpdir:-/tmp} +testline_svg=${tmpdir}/testline.svg +testgrid_svg=${tmpdir}/testgrid.svg + +cat > ${testline_svg} << EOF +<?xml version="1.0" standalone="yes"?> +<svg width="20" height="20"> +<path style="fill:#000000; stroke:none;" d="M0 0L0 20L20 20L20 0L0 0z"/> +<path style="fill:#ffffff; stroke:none;" d="M5 2L15 18L16 18L5 2z"/> +</svg> +EOF + +echo "Test 1. Should print match" + +ppmmake black 20 20 | ppmdraw -script="line 5 2 15 17" | pamtosvg |\ + cmp -s ${testline_svg} - && echo "match" || echo "no match" +rm ${testline_svg} + +cat > ${testgrid_svg} << EOF +<?xml version="1.0" standalone="yes"?> +<svg width="14" height="16"> +<path style="fill:#000000; stroke:none;" d="M0 0L0 16L14 16L14 1L13 0L0 0z"/> +<path style="fill:#ffffff; stroke:none;" d="M1 0L2 1L1 0M3 0L4 1L3 0M5 0L6 \ +1L5 0M7 0L8 1L7 0M9 0L10 1L9 0M11 0L12 1L11 0M13 0L14 1L13 0M1 2L2 3L1 2M3 \ +2L4 3L3 2M5 2L6 3L5 2M7 2L8 3L7 2M9 2L10 3L9 2M11 2L12 3L11 2M13 2L14 3L13 \ +2M1 4L2 5L1 4M3 4L4 5L3 4M5 4L6 5L5 4M7 4L8 5L7 4M9 4L10 5L9 4M11 4L12 5L11 \ +4M13 4L14 5L13 4M1 6L2 7L1 6M3 6L4 7L3 6M5 6L6 7L5 6M7 6L8 7L7 6M9 6L10 7L9 \ +6M11 6L12 7L11 6M13 6L14 7L13 6M1 8L2 9L1 8M3 8L4 9L3 8M5 8L6 9L5 8M7 8L8 9L7 \ +8M9 8L10 9L9 8M11 8L12 9L11 8M13 8L14 9L13 8M1 10L2 11L1 10M3 10L4 11L3 10M5 \ +10L6 11L5 10M7 10L8 11L7 10M9 10L10 11L9 10M11 10L12 11L11 10M13 10L14 11L13 \ +10M1 12L2 13L1 12M3 12L4 13L3 12M5 12L6 13L5 12M7 12L8 13L7 12M9 12L10 13L9 \ +12M11 12L12 13L11 12M13 12L14 13L13 12M1 14L2 15L1 14M3 14L4 15L3 14M5 14L6 \ +15L5 14M7 14L8 15L7 14M9 14L10 15L9 14M11 14L12 15L11 14M13 14L14 15L13 14z"/> +</svg> +EOF + +echo "Test 2. Should print match" + +pamtosvg testgrid.pbm |\ + cmp -s ${testgrid_svg} - && echo "match" || echo "no match" +rm ${testgrid_svg} diff --git a/test/pamundice.ok b/test/pamundice.ok index ef0f6e13..9c869609 100644 --- a/test/pamundice.ok +++ b/test/pamundice.ok @@ -1,27 +1,27 @@ -Test 1. +Test 1. Should print 2096818803 2818 twice 2096818803 2818 2096818803 2818 -Test 2. +Test 2. Should print 2096818803 2818 twice 2096818803 2818 2096818803 2818 -Test 3. +Test 3. Should print 2096818803 2818 twice 2096818803 2818 2096818803 2818 -Test 4. -557392151 459 -557392151 459 -557392151 459 -557392151 459 +Test 4. Should print 2434390296 4436 four times +2434390296 4436 +2434390296 4436 +2434390296 4436 +2434390296 4436 Test Invalid -Expected failure 1 1 -Expected failure 2 1 -Expected failure 3 1 -Expected failure 4 1 -Expected failure 5 1 -Expected failure 6 1 -Expected failure 7 1 -Expected failure 8 1 -Expected failure 9 1 -Expected failure 10 1 -Expected failure 11 1 -Expected failure 12 1 +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) +Expected failure 5 (no output) +Expected failure 6 (no output) +Expected failure 7 (no output) +Expected failure 8 (no output) +Expected failure 9 (no output) +Expected failure 10 (no output) +Expected failure 11 (no output) +Expected failure 12 (no output) diff --git a/test/pamundice.test b/test/pamundice.test index e8add587..1190fbdc 100755 --- a/test/pamundice.test +++ b/test/pamundice.test @@ -1,15 +1,14 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamundice -# Also requires: pgmmake pnmtile pnmcat pnmpad +# Also requires: pamfile pgmmake pnmtile pamcat tmpdir=${tmpdir:-/tmp} fname_stem=${tmpdir}/part -# Test 1. -echo "Test 1." +echo "Test 1. Should print 2096818803 2818 twice" -for ((x=0; x<3; ++x)) - do for ((y=0; y<5; ++y)) +for x in 0 1 2 + do for y in 0 1 2 3 4 do pgmmake "."$(( x* 25 + y )) 11 17 > ${fname_stem}_${y}_${x}.pgm done @@ -18,46 +17,43 @@ for ((x=0; x<3; ++x)) pamundice -across=3 -down=5 ${fname_stem}"_%1d_%1a".pgm | cksum ls ${fname_stem}_?_?.pgm | \ - pamundice -across=3 -down=5 -listfile=- | cksum + pamundice -across=3 -down=5 -listfile=- | cksum - -# Test 2. -echo "Test 2." +echo "Test 2. Should print 2096818803 2818 twice" tempfile=${tmpdir}/temp -for ((y=0; y<5; ++y)) +for y in 0 1 2 3 4 do pamundice -across=3 ${fname_stem}"_"$y"_%1a".pgm > ${tempfile}_"$y" done - -pnmcat -tb ${tempfile}_[01234] | cksum + +pamcat -tb ${tempfile}_[01234] | cksum rm ${tempfile}_[01234] # Note: the following 2 are valid. There should not be warning messages. -for ((x=0; x<3; ++x)) +for x in 0 1 2 do pamundice -down=5 ${fname_stem}"_%1d_"$x.pgm > ${tempfile}"_"$x done -pnmcat -lr ${tempfile}_[012] | cksum +pamcat -lr ${tempfile}_[012] | cksum rm ${tempfile}_[012] rm ${fname_stem}_?_?.pgm -# Test 3. -echo "Test 3." +echo "Test 3. Should print 2096818803 2818 twice" -for ((x=0; x<2; ++x)) - do for ((y=0; y<5; ++y)) +for x in 0 1 + do for y in 0 1 2 3 4 do pgmmake "."$(( x* 25 + y )) 12 17 > ${fname_stem}_${y}_${x}.pgm done done -for ((x=2; x<3; ++x)) - do for ((y=0; y<5; ++y)) +for x in 2 + do for y in 0 1 2 3 4 do pgmmake "."$(( x* 25 + y )) 11 17 > ${fname_stem}_${y}_${x}.pgm done @@ -68,15 +64,15 @@ pamundice -across=3 -down=5 \ rm ${fname_stem}_?_?.pgm -for ((x=0; x<3; ++x)) - do for ((y=0; y<4; ++y)) +for x in 0 1 2 + do for y in 0 1 2 3 do pgmmake "."$(( x* 25 + y )) 11 18 > ${fname_stem}_${y}_${x}.pgm done done -for ((x=0; x<3; ++x)) - do for ((y=4; y<5; ++y)) +for x in 0 1 2 + do for y in 4 do pgmmake "."$(( x* 25 + y )) 11 17 > ${fname_stem}_${y}_${x}.pgm done @@ -89,21 +85,22 @@ rm ${fname_stem}_?_?.pgm # Test 4. -echo "Test 4." +echo "Test 4. Should print 2434390296 4436 four times" -# Add margins to testgrid.pbm +msize=$(pamfile -size maze.pbm) +mw=$(echo ${msize} | cut -d " " -f 1) +mh=$(echo ${msize} | cut -d " " -f 2) -testimg_pbm=${tmpdir}/testimg.pbm -pnmpad -top=2 -left=3 -black testgrid.pbm > ${testimg_pbm} +pnmtile $((${mw} * 2)) $((${mh} * 5)) maze.pbm | cksum -for x in `seq 0 1` - do for y in `seq 0 4` - do cp ${testimg_pbm} ${fname_stem}_${y}_${x}.pbm; done +for x in 0 1 + do for y in 0 1 2 3 4 + do cp maze.pbm ${fname_stem}_${y}_${x}.pbm; done done -for (( i=0 ; i<=9; ++i)) +for i in 0 1 2 3 4 5 6 7 8 9 do - echo ${testimg_pbm} + echo maze.pbm done | pamundice -down=5 -across=2 -listfile=- | cksum pamundice -down=5 -across=2 ${fname_stem}_"%1d"_"%1a".pbm | cksum @@ -111,11 +108,8 @@ pamundice -down=5 -across=2 ${fname_stem}_"%1d"_"%1a".pbm | cksum echo "A warning message should appear below the line." 1>&2 echo "-----------------------------------------------------------" 1>&2 -pamundice -down=5 -across=2 ${testimg_pbm} | cksum - -pnmtile 34 90 ${testimg_pbm} | cksum +pamundice -down=5 -across=2 maze.pbm | cksum -rm ${testimg_pbm} # Test Invalid. echo "Test Invalid" @@ -129,55 +123,80 @@ echo "-----------------------------------------------------------" 1>&2 # No input file pattern specified pamundice -down=5 -across=2 > ${test_out} || \ -echo -n "Expected failure 1"; test -s ${test_out}; echo " "$? + printf "Expected failure 1 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} # -down=0 pamundice -down=0 -across=2 ${fname_stem}_"%1d"_"%1a".pbm > ${test_out} || \ -echo -n "Expected failure 2"; test -s ${test_out}; echo " "$? + printf "Expected failure 2 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} # -across=0 pamundice -down=5 -across=0 ${fname_stem}_"%1d"_"%1a".pbm > ${test_out} || \ -echo -n "Expected failure 3"; test -s ${test_out}; echo " "$? + printf "Expected failure 3 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} # -down too large pamundice -down=6 -across=2 ${fname_stem}_"%1d"_"%1a".pbm > ${test_out} || \ -echo -n "Expected failure 4"; test -s ${test_out}; echo " "$? + printf "Expected failure 4 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} # -across too large pamundice -down=5 -across=3 ${fname_stem}_"%1d"_"%1a".pbm > ${test_out} || \ -echo -n "Expected failure 5"; test -s ${test_out}; echo " "$? + printf "Expected failure 5 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} # precision does not match pamundice -down=5 -across=2 ${fname_stem}_"%2d"_"%2a".pbm > ${test_out} || \ -echo -n "Expected failure 6"; test -s ${test_out}; echo " "$? + printf "Expected failure 6 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} # precision set to zero pamundice -down=5 -across=2 ${fname_stem}_"%0d"_"%0a".pbm > ${test_out} || \ -echo -n "Expected failure 7"; test -s ${test_out}; echo " "$? + printf "Expected failure 7 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} # no precision pamundice -down=5 -across=2 ${fname_stem}_"%d"_"%a".pbm > ${test_out} || \ -echo -n "Expected failure 8"; test -s ${test_out}; echo " "$? + printf "Expected failure 8 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} # -hoverlap too large -pamundice -down=5 -across=2 -hoverlap=18 \ +pamundice -down=5 -across=2 -hoverlap=$((${mw}+1)) \ ${fname_stem}_"%1d"_"%1a".pbm > ${test_out} || \ -echo -n "Expected failure 9"; test -s ${test_out}; echo " "$? + printf "Expected failure 9 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} # -voverlap too large -pamundice -down=5 -across=2 -voverlap=19 \ +pamundice -down=5 -across=2 -voverlap=$((${mh}+1)) \ ${fname_stem}_"%1d"_"%1a".pbm > ${test_out} || \ -echo -n "Expected failure 10"; test -s ${test_out}; echo " "$? + printf "Expected failure 10 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} # corrupt listfile : file names do not exist -seq 10 | sed -e 's/^/::::::/' -e 's/$/::::::/' | \ - pamundice -down=5 -across=2 -listfile=- > ${test_out} || \ -echo -n "Expected failure 11"; test -s ${test_out}; echo " "$? +for i in 0 1 2 3 4 5 6 7 8 9 + do + mktemp -u XXXXXXXXXX.${i} || echo ":::::::::::"${i}":::::::::::" + done | pamundice -down=5 -across=2 -listfile=- > ${test_out} || \ + printf "Expected failure 11 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} # listfile with insufficient lines (insufficient file entries) ls ${fname_stem}_*_*.pbm | head -n 9 | \ pamundice -down=5 -across=2 -listfile=- > ${test_out} || \ -echo -n "Expected failure 12"; test -s ${test_out}; echo " "$? + printf "Expected failure 12 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} rm ${fname_stem}*.pbm - diff --git a/test/pamvalidate.test b/test/pamvalidate.test index 4cabc7df..708197da 100755 --- a/test/pamvalidate.test +++ b/test/pamvalidate.test @@ -1,20 +1,20 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamvalidate # Also requires: echo "valid" -echo -e "P1\n5 5\n01010\n10101\n01010\n00000\n11111\n" | pamvalidate -plain +printf "P1\n5 5\n01010\n10101\n01010\n00000\n11111\n" | pamvalidate -plain echo "not valid: Should print 0 four times" -echo -e "P1\n5 5\n01010\n10101\n01010\n00000\n1111\n" | pamvalidate | \ +printf "P1\n5 5\n01010\n10101\n01010\n00000\n1111\n" | pamvalidate | \ wc -c | tr -d ' ' -echo -e "P1\n5 5\n01010\n10102\n01010\n00001\n11111\n" | pamvalidate | \ +printf "P1\n5 5\n01010\n10102\n01010\n00001\n11111\n" | pamvalidate | \ wc -c | tr -d ' ' -echo -e "P1\n5\n01010\n10101\n01010\n00000\n11111\n" | pamvalidate | \ +printf "P1\n5\n01010\n10101\n01010\n00000\n11111\n" | pamvalidate | \ wc -c | tr -d ' ' -echo -e "P1\n5 5" | pamvalidate | wc -c | tr -d ' ' +printf "P1\n5 5" | pamvalidate | wc -c | tr -d ' ' diff --git a/test/pbm-misc-converters.ok b/test/pbm-misc-converters.ok index a137102f..1ae5d817 100644 --- a/test/pbm-misc-converters.ok +++ b/test/pbm-misc-converters.ok @@ -1,27 +1,58 @@ -1638343024 43 -2141128209 77 -2542756600 120 -3102495729 32 -2414506375 47 -3241517214 145 -1454090165 46 -1436169407 46 -1454090165 46 -2912484298 46 -3576177652 52 -1478164284 52 -3213223606 141 -3213223606 141 -3213223606 141 -1463148415 108 -203901789 30 -3732005859 92 -2459345477 86 -424535246 92 -609530223 252 -4195053594 248 -2602382240 43 -129620534 361 -2256096096 80 -1349121911 149 +pbmto10x +3017587389 501 +3017587389 501 +pbmto4425 +2529120683 622 +2529120683 622 +pbmtoascii +2361485126 1740 +2361485126 1740 +4017331268 450 +pbmtodjvurle +2707446245 1744 +2707446245 1744 +pbmtoepson +2100180787 510 +2100180787 510 +2963515498 510 +2100180787 510 +1513122412 510 +pbmtogo +34750317 804 +34750317 804 +pbmtoibm23xx +1731023722 546 +1731023722 546 +pbmtolj +1540204160 762 +1540204160 762 +908699854 763 +908699854 763 +pbmtoln03 +1554612498 636 +1554612498 636 +pbmtomatrixorbital +1574732995 458 +1574732995 458 +pbmtonokia +3813814418 972 +3813814418 972 +1385394245 966 +3924854157 972 +3970098281 3388 +167529797 3384 +2260274013 483 +pbmtoplot +2120102625 5318 +2120102625 5318 +pbmtoptx +541430122 708 +541430122 708 +pbmtozinc +2297581967 1725 +2297581967 1725 +pbmtobbnbg +3481527833 672 +pbmtoppa +3955750161 284701 3955750161 284701 diff --git a/test/pbm-misc-converters.test b/test/pbm-misc-converters.test index ad96f13c..ba350bc7 100755 --- a/test/pbm-misc-converters.test +++ b/test/pbm-misc-converters.test @@ -1,40 +1,98 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmto10x pbmto4425 pbmtoascii pbmtobbnbg # This script tests: pbmtodjvurle pbmtoepson pbmtogo pbmtoibm23xx # This script tests: pbmtolj pbmtoln03 pbmtomatrixorbital pbmtonokia -# This script tests: pbmtoplot pbmtoptx pbmtozinc -# Also requires: pbmpage pbmtoppa +# This script tests: pbmtoplot pbmtoppa pbmtoptx pbmtozinc +# Also requires: pbmpage # Note: one-way test. # These converters do not have counterparts that work in the opposite # direction. We check whether the output is unchanged from older # versions. -pbmto10x testgrid.pbm | cksum -pbmto4425 testgrid.pbm | cksum -pbmtoascii testgrid.pbm | cksum -pbmtoascii -2x4 testgrid.pbm | cksum -pbmtobbnbg < testgrid.pbm | cksum -pbmtodjvurle testgrid.pbm | cksum -pbmtoepson testgrid.pbm | cksum -pbmtoepson -protocol=escp testgrid.pbm | cksum -pbmtoepson -protocol=escp9 testgrid.pbm | cksum -pbmtoepson -nonadjacent testgrid.pbm | cksum -pbmtogo testgrid.pbm | cksum -pbmtoibm23xx -xres=60 -yres=60 testgrid.pbm | cksum -pbmtolj testgrid.pbm | cksum -pbmtolj -packbits testgrid.pbm | cksum -pbmtolj -compress testgrid.pbm | cksum -pbmtoln03 testgrid.pbm | cksum -pbmtomatrixorbital < testgrid.pbm | cksum -pbmtonokia -fmt HEX_NOL testgrid.pbm | cksum -pbmtonokia -fmt HEX_NGG testgrid.pbm | cksum -pbmtonokia -fmt HEX_NPM testgrid.pbm | cksum -pbmtonokia -fmt NOL testgrid.pbm | cksum -pbmtonokia -fmt NGG testgrid.pbm | cksum -pbmtonokia -fmt NPM testgrid.pbm | cksum -pbmtoplot testgrid.pbm | cksum -pbmtoptx testgrid.pbm | cksum -pbmtozinc testgrid.pbm | cksum - -(pbmpage 1; pbmpage 2; pbmpage 3) | pbmtoppa | cksum +echo "pbmto10x" +pbmto10x maze.pbm | cksum +pbmto10x < maze.pbm | cksum + +echo "pbmto4425" +pbmto4425 maze.pbm | cksum +pbmto4425 < maze.pbm | cksum + +# Asciitopgm works in the opposite direction, but the round-trip is not accurate + +echo "pbmtoascii" +pbmtoascii maze.pbm | cksum +pbmtoascii < maze.pbm | cksum +pbmtoascii -2x4 maze.pbm | cksum + +echo "pbmtodjvurle" +pbmtodjvurle maze.pbm | cksum +pbmtodjvurle < maze.pbm | cksum + +echo "pbmtoepson" +pbmtoepson maze.pbm | cksum +pbmtoepson < maze.pbm | cksum +pbmtoepson -protocol=escp maze.pbm | cksum +pbmtoepson -protocol=escp9 maze.pbm | cksum +pbmtoepson -nonadjacent maze.pbm | cksum + +echo "pbmtogo" +pbmtogo maze.pbm | cksum +pbmtogo < maze.pbm | cksum + +echo "pbmtoibm23xx" +pbmtoibm23xx -xres=60 -yres=60 maze.pbm | cksum +pbmtoibm23xx -xres=60 -yres=60 < maze.pbm | cksum + +echo "pbmtolj" +pbmtolj maze.pbm | cksum +pbmtolj < maze.pbm | cksum +pbmtolj -packbits maze.pbm | cksum +pbmtolj -compress maze.pbm | cksum + +echo "pbmtoln03" +pbmtoln03 maze.pbm | cksum +pbmtoln03 < maze.pbm | cksum + +echo "pbmtomatrixorbital" +pbmtomatrixorbital maze.pbm | cksum +pbmtomatrixorbital < maze.pbm | cksum + +echo "pbmtonokia" +pbmtonokia -fmt HEX_NOL maze.pbm | cksum +pbmtonokia -fmt HEX_NOL < maze.pbm | cksum +pbmtonokia -fmt HEX_NGG maze.pbm | cksum +pbmtonokia -fmt HEX_NPM maze.pbm | cksum +pbmtonokia -fmt NOL maze.pbm | cksum +pbmtonokia -fmt NGG maze.pbm | cksum +pbmtonokia -fmt NPM maze.pbm | cksum + +echo "pbmtoplot" +pbmtoplot maze.pbm | cksum +pbmtoplot < maze.pbm | cksum + +echo "pbmtoptx" +pbmtoptx maze.pbm | cksum +pbmtoptx < maze.pbm | cksum + +# pbmtozinc embeds input filename in the output + +echo "pbmtozinc" +pbmtozinc maze.pbm | cksum +pbmtozinc < maze.pbm | sed 's/noname/maze/' | cksum + +# pbmtobbnbg input must be from stdin + +echo "pbmtobbnbg" +pbmtobbnbg < maze.pbm | cksum + +# pbmtoppa has constraints on what can be accepted as input; maze.pbm is not accepted +# pbmpage produces suitable input + +tmpdir=${tmpdir:-/tmp} +testpage_pbm=${tmpdir}/testpage.pbm + +echo "pbmtoppa" +(pbmpage 1; pbmpage 2; pbmpage 3) | tee ${testpage_pbm} | pbmtoppa | cksum +pbmtoppa ${testpage_pbm} | cksum +rm ${testpage_pbm} diff --git a/test/pbm-ppm-roundtrip.ok b/test/pbm-ppm-roundtrip.ok new file mode 100644 index 00000000..91c502b5 --- /dev/null +++ b/test/pbm-ppm-roundtrip.ok @@ -0,0 +1,39 @@ +Test 1. Should print 281226646 481 five times. +281226646 481 +281226646 481 +281226646 481 +281226646 481 +281226646 481 +Test 2. Should print three all-white, then three all-black PBM images +P1 +7 3 +0000000 +0000000 +0000000 + +P1 +7 3 +0000000 +0000000 +0000000 + +P1 +7 3 +0000000 +0000000 +0000000 + +P1 +17 2 +11111111111111111 +11111111111111111 + +P1 +17 2 +11111111111111111 +11111111111111111 + +P1 +17 2 +11111111111111111 +11111111111111111 diff --git a/test/pbm-ppm-roundtrip.test b/test/pbm-ppm-roundtrip.test new file mode 100755 index 00000000..9a3ff79f --- /dev/null +++ b/test/pbm-ppm-roundtrip.test @@ -0,0 +1,34 @@ +#! /bin/sh +# This script tests: pgmtoppm ppmtopgm ppmtoppm pgmtopbm +# Also requires: pbmmake ppmcolormask pnminvert + +echo "Test 1. Should print 281226646 481 five times." + +cat maze.pbm | cksum +pgmtoppm black-white maze.pbm | ppmtopgm | \ + pgmtopbm -th -val=0.5 | cksum +pgmtoppm white-black maze.pbm | ppmtopgm | \ + pgmtopbm -th -val=0.5 | pnminvert | cksum +pgmtoppm white-black maze.pbm | ppmcolormask white | cksum +ppmtoppm < maze.pbm | ppmtopgm | pgmtopbm -th -val=0.5 | cksum + +echo "Test 2. Should print three all-white, then three all-black PBM images" + +pbmmake -w 7 3 -plain +echo + +pbmmake -w 7 3 | pgmtoppm black-white | ppmtopgm | \ + pgmtopbm -th -val=0.5 -plain +echo +pbmmake -w 7 3 | ppmtoppm | ppmtopgm | \ + pgmtopbm -th -val=0.5 -plain +echo + +pbmmake -b 17 2 -plain +echo + +pbmmake -b 17 2 | pgmtoppm black-white | ppmtopgm | \ + pgmtopbm -th -val=0.5 -plain +echo +pbmmake -b 17 2 | ppmtoppm | ppmtopgm | \ + pgmtopbm -th -val=0.5 -plain diff --git a/test/pbmclean.ok b/test/pbmclean.ok index 17ee0338..5fc9a2d5 100644 --- a/test/pbmclean.ok +++ b/test/pbmclean.ok @@ -85,4 +85,4 @@ Test 3 436062787 5051 4188415575 5051 Test Invalid -Expected failure 1 1 +Expected failure 1 (no output) diff --git a/test/pbmclean.test b/test/pbmclean.test index c0c3a759..64ed6df0 100755 --- a/test/pbmclean.test +++ b/test/pbmclean.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmclean # Also requires: pbmmake pbmpage pbmtext pnmmargin pnmpad @@ -37,17 +37,8 @@ rm ${sheet_pbm} echo "Test Invalid" -test_out=${tmpdir}/test_out - -echo 1>&2 -echo "Invalid command-line argument combination." 1>&2 -echo "An error message should appear below the line." 1>&2 -echo "-----------------------------------------------------------" 1>&2 +. ${srcdir}/test-invalid.inc # overspecification -pbmclean -black -white -min=1 -extended testgrid.pbm > ${test_out} || \ - echo -n "Expected failure 1"; test -s ${test_out}; echo " "$? - +invCmd "pbmclean -black -white -min=1 -extended testgrid.pbm" # note that without -extended the above is valid. - -rm -f ${test_out} \ No newline at end of file diff --git a/test/pbmlife.ok b/test/pbmlife.ok new file mode 100644 index 00000000..bd214dfb --- /dev/null +++ b/test/pbmlife.ok @@ -0,0 +1,63 @@ +P1 +63 29 +000000000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000000 +000000000000001111111000111100000000000111000111000000000000000 +000000000000000100001001100110000000001000101001100000000000000 +000000000000000100000001000010000000001000101000100000000000000 +000000000000000100010010000001000010001100101000100000000000000 +000000000000000111110010000001000010000111001100100000000000000 +000000000000000100010010000001001111101001100111100000000000000 +000000000000000100000001000010000010001000100001000000000000000 +000000000000000100000001100110000010001000100011000000000000000 +000000000000001111000000111100000000000111001100000000000000000 +000000000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000000 + + tiles: 1722 + x-edges: 1812 + y-edges: 1842 +vertices: 1920 + area: 1722 +perimeter: 420 + eulerchi: -12 + + tiles: 17 + x-edges: 33 + y-edges: 33 +vertices: 64 + area: 17 +perimeter: 64 + eulerchi: 15 + + tiles: 2 + x-edges: 3 + y-edges: 4 +vertices: 6 + area: 2 +perimeter: 6 + eulerchi: 1 + + tiles: 0 + x-edges: 0 + y-edges: 0 +vertices: 0 + area: 0 +perimeter: 0 + eulerchi: 0 diff --git a/test/pbmlife.test b/test/pbmlife.test new file mode 100755 index 00000000..c292ee65 --- /dev/null +++ b/test/pbmlife.test @@ -0,0 +1,13 @@ +#! /bin/sh +# This script tests: pbmlife pbmminkowski +# Also requires: pbmtext + +pbmtext FO+89 -plain +echo +pbmtext FO+89 | pbmminkowski +echo +pbmtext FO+89 | pbmlife | pbmminkowski +echo +pbmtext FO+89 | pbmlife | pbmlife | pbmminkowski +echo +pbmtext FO+89 | pbmlife | pbmlife | pbmlife | pbmminkowski diff --git a/test/pbmmake.ok b/test/pbmmake.ok index e39f4cf8..4b13cf54 100644 --- a/test/pbmmake.ok +++ b/test/pbmmake.ok @@ -44,11 +44,11 @@ Test 2 3651864954 3375 3302595397 3849 Test Invalid -Expected failure 1 1 -Expected failure 2 1 -Expected failure 3 1 -Expected failure 4 1 -Expected failure 5 1 -Expected failure 6 1 -Expected failure 7 1 -Expected failure 8 1 +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) +Expected failure 5 (no output) +Expected failure 6 (no output) +Expected failure 7 (no output) +Expected failure 8 (no output) diff --git a/test/pbmmake.test b/test/pbmmake.test index 3f815617..32153f95 100755 --- a/test/pbmmake.test +++ b/test/pbmmake.test @@ -1,51 +1,36 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmmake # Also requires: echo "Test 1" -for i in `seq 1 8` -do -for color in -white -black -gray -do -pbmmake -plain $color $i $i | tr -d '\n'; echo -done -done +for size in 1 2 3 4 5 6 7 8 # for size in `seq 8` + do + for color in -white -black -gray + do + pbmmake -plain ${color} ${size} ${size} | tr -d '\n'; echo + done + done echo "Test 2" -for i in `seq 8 5 98` -do - ( pbmmake -w $i $i ; - pbmmake -b $i $i ; - pbmmake -g $i $i ) | cksum +for size in 8 13 18 23 28 33 38 43 48 53 58 63 68 73 78 83 88 93 98 + # for size in `seq 8 5 98` + do + ( pbmmake -w ${size} ${size} ; + pbmmake -b ${size} ${size} ; + pbmmake -g ${size} ${size} ) | cksum done echo "Test Invalid" -echo 1>&2 -echo "Invalid command-line argument combinations." 1>&2 -echo "Error messages should appear below the line." 1>&2 -echo "-----------------------------------------------------------" 1>&2 - -tmpdir=${tmpdir:-/tmp} -test_out=${tmpdir}/test_out - -pbmmake -b -w -plain 1 1 > ${test_out} || \ - echo -n "Expected failure 1"; test -s ${test_out}; echo " "$? -pbmmake -b -g -plain 1 1 > ${test_out} || \ - echo -n "Expected failure 2"; test -s ${test_out}; echo " "$? -pbmmake -white -gray -plain 1 1 > ${test_out} || \ - echo -n "Expected failure 3"; test -s ${test_out}; echo " "$? -pbmmake -white -plain > ${test_out} || \ - echo -n "Expected failure 4"; test -s ${test_out}; echo " "$? -pbmmake -white -plain 1 > ${test_out} || \ - echo -n "Expected failure 5"; test -s ${test_out}; echo " "$? -pbmmake -white -plain 1 0 > ${test_out} || \ - echo -n "Expected failure 6"; test -s ${test_out}; echo " "$? -pbmmake -white -plain 0 1 > ${test_out} || \ - echo -n "Expected failure 7"; test -s ${test_out}; echo " "$? -pbmmake -white -plain 1 1 1 > ${test_out} || \ - echo -n "Expected failure 8"; test -s ${test_out}; echo " "$? +. ${srcdir}/test-invalid.inc -rm ${test_out} +invCmd "pbmmake -b -w -plain 1 1" +invCmd "pbmmake -b -g -plain 1 1" +invCmd "pbmmake -white -gray -plain 1 1" +invCmd "pbmmake -white -plain" +invCmd "pbmmake -white -plain 1" +invCmd "pbmmake -white -plain 1 0" +invCmd "pbmmake -white -plain 0 1" +invCmd 'pbmmake -white -plain 1 1 1' diff --git a/test/pbmminkowski.ok b/test/pbmminkowski.ok index 71a909ce..9780e3c2 100644 --- a/test/pbmminkowski.ok +++ b/test/pbmminkowski.ok @@ -21,3 +21,11 @@ vertices: 224 area: 56 perimeter: 224 eulerchi: 56 + + tiles: 1627 + x-edges: 2479 + y-edges: 2427 +vertices: 3376 + area: 1627 +perimeter: 3304 + eulerchi: 97 diff --git a/test/pbmminkowski.test b/test/pbmminkowski.test index 389ff44a..790e45bd 100755 --- a/test/pbmminkowski.test +++ b/test/pbmminkowski.test @@ -1,11 +1,12 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmminkowski -# Also requires: pbmmake pnmmargin pnmpad +# Also requires: pbmmake pnmpad - -pbmmake -w 1 1 | pnmmargin -b 1 | \ +pbmmake -w 1 1 | pnmpad -black -top=1 -left=1 -bottom=1 -right=1 | \ pbmminkowski echo pbmmake -g 3 3 | pbmminkowski echo pbmminkowski testgrid.pbm +echo +pbmminkowski maze.pbm \ No newline at end of file diff --git a/test/pbmnoise-parameters.ok b/test/pbmnoise-parameters.ok new file mode 100644 index 00000000..640b438d --- /dev/null +++ b/test/pbmnoise-parameters.ok @@ -0,0 +1,28 @@ +Test Invalid +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) +Expected failure 5 (no output) +Expected failure 6 (no output) +Expected failure 7 (no output) +Expected failure 8 (no output) +Expected failure 9 (no output) +Expected failure 10 (no output) +Expected failure 11 (no output) +Expected failure 12 (no output) +Expected failure 13 (no output) +Expected failure 14 (no output) +Expected failure 15 (no output) +Expected failure 16 (no output) +Expected failure 17 (no output) +Expected failure 18 (no output) +Expected failure 19 (no output) +Expected failure 20 (no output) +Expected failure 21 (no output) +Expected failure 22 (no output) +Expected failure 23 (no output) +Expected failure 24 (no output) +Expected failure 25 (no output) +Expected failure 26 (no output) +Expected failure 27 (no output) diff --git a/test/pbmnoise-parameters.test b/test/pbmnoise-parameters.test new file mode 100755 index 00000000..d0e04ebf --- /dev/null +++ b/test/pbmnoise-parameters.test @@ -0,0 +1,43 @@ +#! /bin/sh +# This script tests: pbmnoise +# Also requires: + +echo "Test Invalid" + +. ${srcdir}/test-invalid.inc + +# Invalid -ratio arguments + +invCmd "pbmnoise -ratio 100 100" +invCmd "pbmnoise -ratio 0 1 100" +invCmd "pbmnoise -ratio=1.1 100 100" +invCmd "pbmnoise -ratio=-1 100 100" +invCmd "pbmnoise -ratio=half 100 100" +invCmd "pbmnoise -ratio=0/1/1 100 100" +invCmd "pbmnoise -ratio=-1/2 100 100" +invCmd "pbmnoise -ratio=1/0 100 100" +invCmd "pbmnoise -ratio=/2 100 100" +invCmd "pbmnoise -ratio=4/2 100 100" +invCmd "pbmnoise -ratio=6/ 100 100" +invCmd "pbmnoise -ratio=1.0/2.0 100 100" + +# denominator must be power of 2 +invCmd "pbmnoise -ratio=3/9 100 100" +invCmd "pbmnoise -ratio=a/2 100 100" +invCmd "pbmnoise -ratio=2/a 100 100" +invCmd "pbmnoise -ratio=1/-2 100 100" + +# Denominator must be 65536 or less +invCmd "pbmnoise -ratio=1/65537 100 100" +invCmd "pbmnoise -ratio=1/131072 100 100" + +# Other +invCmd "pbmnoise" +invCmd "pbmnoise 100" +invCmd "pbmnoise 100 0" +invCmd "pbmnoise 0 100" +invCmd "pbmnoise 100 200 300" +invCmd "pbmnoise -endian=large 100 100" +invCmd "pbmnoise -randomseed 100 100" +invCmd "pbmnoise -randomseed=-1 100 100" +invCmd "pbmnoise -randomseed=0.1 100 100" diff --git a/test/pbmnoise1.ok b/test/pbmnoise1.ok new file mode 100644 index 00000000..84f1f04e --- /dev/null +++ b/test/pbmnoise1.ok @@ -0,0 +1,50 @@ +Test 1. Should print 242292858 962 five times +242292858 962 +242292858 962 +242292858 962 +242292858 962 +242292858 962 +Test 2. +P1 32 1 00000000000000000000000000000000 +P1 32 1 00010000000001000000000000000000 +P1 32 1 00010000000001000010000000000000 +P1 32 1 00010000000001000000000000000000 +P1 32 1 00010000000001000010010000000000 +P1 32 1 01010001000101000000000000000000 +P1 32 1 00010000000001000010100000000000 +P1 32 1 01010001000111000000000000100010 +P1 32 1 10011001000001100010010000000000 +P1 32 1 01010001000111000000010100100010 +P1 32 1 01011001000101000010100000000000 +P1 32 1 01010001000111000001010100100110 +P1 32 1 00010000000001000111110000000100 +P1 32 1 01010001010111001001010100100110 +P1 32 1 01011011000111000010101000101010 +P1 32 1 01010001011111011001010100110110 +P1 32 1 10011001001001110010011000101110 +P1 32 1 01010001011111011011010101110110 +P1 32 1 01011011000111000010111110101010 +P1 32 1 01010001011111011011110101110110 +P1 32 1 11011001010101101111110000000100 +P1 32 1 01011001011111011011110101110110 +P1 32 1 01011011000111000111111110101110 +P1 32 1 01011011011111011011111101111110 +P1 32 1 10111111101011110111111000111111 +P1 32 1 01011011011111011011111111111110 +P1 32 1 11011011010111101111111110101110 +P1 32 1 01011011011111011111111111111110 +P1 32 1 11111111111111111111111000111111 +P1 32 1 11011011011111111111111111111110 +P1 32 1 11111111111111111111111110111111 +P1 32 1 11111111111111111111111111111111 +P1 32 1 11111111111111111111111111111111 +Test 3. Should print 126142586 1218 four times +126142586 1218 +126142586 1218 +126142586 1218 +126142586 1218 +Test 4. +P1 64 1 1000010001101101101000100101001110101011010010011111001011100110 +P1 64 1 1000010001101101101000100101001110101011010010011111001011100110 +P1 64 1 0101001110100010011011011000010011100110111100100100100110101011 +P1 64 1 0101001110100010011011011000010011100110111100100100100110101011 diff --git a/test/pbmnoise1.test b/test/pbmnoise1.test new file mode 100755 index 00000000..855a5629 --- /dev/null +++ b/test/pbmnoise1.test @@ -0,0 +1,38 @@ +#! /bin/sh +# This script tests: pbmnoise +# + +# Assumes that the random number generator is Mersenne Twister + +echo "Test 1. Should print 242292858 962 five times" + +for arg in "" "-ratio=1/2" "-ratio=256/512" "-ratio=32768/65536" "-pack" + do + pbmnoise -endian=big -randomseed=1 1088 7 ${arg} | cksum +done + +echo "Test 2." + +for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 \ + 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 + # for i in `seq 0 32` + do + pbmnoise -endian=little -randomseed=11 -ratio=$i/32 -plain 32 1 | \ + tr '\n' ' '; echo +done + +echo "Test 3. Should print 126142586 1218 four times" + +pbmnoise -endian=big -pack -randomseed=12 -plain 19 64 | sed 2d | tr -d '\n' | cksum +pbmnoise -endian=big -pack -randomseed=12 -plain 152 8 | sed 2d | tr -d '\n' | cksum +pbmnoise -endian=big -pack -randomseed=12 -plain 64 19 | sed 2d | tr -d '\n' | cksum +pbmnoise -endian=big -randomseed=12 -plain 64 19 | sed 2d | tr -d '\n' | cksum + +echo "Test 4." + + pbmnoise -endian=big -randomseed=23 64 1 -plain | tr '\n' ' '; echo +( pbmnoise -endian=native -randomseed=23 64 1 -plain | tr '\n' ' '; echo + pbmnoise -endian=swap -randomseed=23 64 1 -plain | tr '\n' ' '; echo +) | sort -nr + pbmnoise -endian=little -randomseed=23 64 1 -plain | tr '\n' ' '; echo + diff --git a/test/pbmnoise2.ok b/test/pbmnoise2.ok new file mode 100644 index 00000000..5c3959e0 --- /dev/null +++ b/test/pbmnoise2.ok @@ -0,0 +1,19 @@ +Test 1. Should print OK 1, then OK 2 three times +OK 1 +OK 2 +OK 2 +OK 2 +Test 2. Should print OK 1, then OK 2 three times +OK 1 +OK 2 +OK 2 +OK 2 +Test 3-black. Should print 255 384 100% 100% four times + 255 384 100% 100% + 255 384 100% 100% + 255 384 100% 100% + 255 384 100% 100% +Test 3-white. Should print 0 320 100% 100% three times + 0 320 100% 100% + 0 320 100% 100% + 0 320 100% 100% diff --git a/test/pbmnoise2.test b/test/pbmnoise2.test new file mode 100755 index 00000000..8845e3b8 --- /dev/null +++ b/test/pbmnoise2.test @@ -0,0 +1,85 @@ +#! /bin/sh +# This script tests: pbmnoise +# Also requires: pgmhist + +# Expected value and variance of binominal distribution: +# Pb: probability of getting a black pixel (=ratio) +# Pw: probability of getting a white pixel (= 1 - Pb = 1 - ratio) +# +# E(width, height, Pb, Pw) = width * height * Pb +# V(width, height, Pb, Pw) = width * height * Pb * Pw +# +# When width * height is large and Pb is not too near edges +# approximate with normal distribution + +echo "Test 1. Should print OK 1, then OK 2 three times" + +args1="-endian=big -randomseed=1" + +( pbmnoise ${args1} 320 200 | pgmhist + pbmnoise -ratio=1/2 ${args1} 160 400 | pgmhist + pbmnoise -ratio=2/4 ${args1} 64000 1 | pgmhist + pbmnoise -pack ${args1} 10 6400 | pgmhist ) | \ + awk 'BEGIN { pixels=64000; Pb=Pw=0.5; + average=pixels*Pb; + sd=sqrt(pixels*Pb*Pw); # standard deviation + sl=1.96 # significance level + limit1 = average - sd * sl; + limit2 = average + sd * sl + count=-1 # initial value + } + $1!=0 { next } + { v=1 } # initial value + limit1 < $2 && $2 < limit2 { v=0 } + v==0 {print "OK", (count==prev)+1} + v==1 {print "NG" $0} + {prev=count}' + + + +echo "Test 2. Should print OK 1, then OK 2 three times" + +args2="-endian=big -randomseed=2" + +( pbmnoise -ratio=11/32 ${args1} 32 119 | pgmhist + pbmnoise -ratio=11/32 ${args1} 224 17 | pgmhist + pbmnoise -ratio=22/64 ${args1} 3808 1 | pgmhist + pbmnoise -ratio=44/128 -pack ${args1} 1904 2 | pgmhist ) | \ + awk 'BEGIN {pixels=32*119; Pb=11/32; Pw=1-Pb; + average=pixels*Pb; + sd=sqrt(pixels*Pb*Pw); # standard deviation + sl=1.96 # significance level + limit1 = average - sd * sl; + limit2 = average + sd * sl + count=-1 # initial value + } + $1!=0 { next } + { v=1 } # initial value + limit1 < $2 && $2 < limit2 { v=0 } + v==0 {print "OK", (count==prev)+1} + v==1 {print "NG" $0} + {prev=count}' + + + + +echo "Test 3-black. Should print 255 384 100% 100% four times" + +pbmnoise -ratio=0/1 -randomseed=1 128 3 | pgmhist | \ + awk '$1==0 || $1==255' +pbmnoise -ratio=0/1024 -randomseed=1 64 6 | pgmhist | \ + awk '$1==0 || $1==255' +pbmnoise -ratio=0/8192 -randomseed=1 32 12 | pgmhist | \ + awk '$1==0 || $1==255' +pbmnoise -ratio=0/65536 -randomseed=1 -pack 1 384 | pgmhist | \ + awk '$1==0 || $1==255' + +echo "Test 3-white. Should print 0 320 100% 100% three times" + +pbmnoise -ratio=1/1 -randomseed=1 64 5 | pgmhist | \ + awk '$1==0 || $1==255' +pbmnoise -ratio=8/8 -randomseed=1 32 10 | pgmhist | \ + awk '$1==0 || $1==255' +pbmnoise -ratio=65536/65536 -randomseed=1 -pack 2 160 | pgmhist | \ + awk '$1==0 || $1==255' + diff --git a/test/pbmpage.ok b/test/pbmpage.ok index 8013f2f2..21731b08 100644 --- a/test/pbmpage.ok +++ b/test/pbmpage.ok @@ -4,6 +4,6 @@ Test 1 2347597649 4210813 3453559794 4349933 Test Invalid -Expected failure 1 1 -Expected failure 2 1 -Expected failure 3 1 +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) diff --git a/test/pbmpage.test b/test/pbmpage.test index 50570e3e..9cb46e22 100755 --- a/test/pbmpage.test +++ b/test/pbmpage.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmpage # Also requires: @@ -11,19 +11,9 @@ pbmpage -a4 2 | cksum echo "Test Invalid" -echo 1>&2 -echo "Invalid command-line argument combinations." 1>&2 -echo "Error messages should appear below the line." 1>&2 -echo "-----------------------------------------------------------" 1>&2 +. ${srcdir}/test-invalid.inc -tmpdir=${tmpdir:-/tmp} -test_out=${tmpdir}/test_out +invCmd "pbmpage -a3 1" +invCmd "pbmpage 0" +invCmd "pbmpage 4" -pbmpage -a3 1 > ${test_out} || \ - echo -n "Expected failure 1"; test -s ${test_out}; echo " "$? -pbmpage 0 > ${test_out} || \ - echo -n "Expected failure 2"; test -s ${test_out}; echo " "$? -pbmpage 4 > ${test_out} || \ - echo -n "Expected failure 3"; test -s ${test_out}; echo " "$? - -rm ${test_out} diff --git a/test/pbmpscale.ok b/test/pbmpscale.ok index c26ffef3..25552343 100644 --- a/test/pbmpscale.ok +++ b/test/pbmpscale.ok @@ -1,53 +1,178 @@ +Test 1. Should print "abc" rendered in PBM plain format P1 -21 45 -000000000000000000000 -000000000000000000000 -000000000000000000000 -000000000000000000000 -000000000000000000000 -000000000000000000000 -000000000000000000000 -000000000000000000000 -000000000000000000000 -111111111111111111110 -111111111111111111111 -111111111111111111111 -001111100000000001111 -000111000000000000111 -000111000000000000111 -000111000000000000000 -000111000000000000000 -000111000000000000000 -000111000000000111000 -000111000000000111000 -000111100000001111000 -000111111111111111000 -000111111111111111000 -000111111111111111000 -000111100000001111000 -000111000000000111000 -000111000000000111000 -000111000000000000000 -000111000000000000000 -000111000000000000000 -000111000000000000000 -000111000000000000000 -001111100000000000000 -111111111111000000000 -111111111111000000000 -111111111111000000000 -000000000000000000000 -000000000000000000000 -000000000000000000000 -000000000000000000000 -000000000000000000000 -000000000000000000000 -000000000000000000000 -000000000000000000000 -000000000000000000000 -2150868536 457 -3761734242 1065 -3462719777 1803 -Expected failure 1 1 -Expected failure 2 1 -Expected failure 3 1 +17 15 +00000000000000000 +00000000000000000 +00000000000000000 +00000011000000000 +00000001000000000 +00000001000000000 +00110001110000110 +01001001001001001 +00111001001001000 +01001001001001000 +01001001001001001 +00110101110000110 +00000000000000000 +00000000000000000 +00000000000000000 +Test 2. "ABC" in PBM plain format +P1 +48 30 +000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000 +000000001100000000111111111110000000000111100011 +000000001100000000111111111111100000011111110011 +000000001100000000011110000111100000011110011111 +000000011110000000001100000011110000111100001111 +000000010010000000001100000000110000111000000111 +000000110011000000001100000000110001110000000011 +000000110011000000001100000011110001100000000000 +000001100001100000001110000111100011000000000000 +000001000000100000001111111111000011000000000000 +000011000000110000001111111111000011000000000000 +000011111111110000001110000001100011000000000000 +000011111111110000001100000000110001100000000000 +000011100001110000001100000000110001110000000011 +000111000000111000001100000001110000111000000111 +001100000000001100001100000011110000111100001111 +011100000000001110011110000111100000011110011110 +111111000000111111111111111111100000011111111110 +111111000000111111111111111110000000000111111000 +000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000 +Test 3. "D.!" in PBM plain format +P1 +42 45 +000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000 +111111111111111110000000000000000000000111 +111111111111111111000000000000000000000111 +111111111111111111100000000000000000000111 +001111100000001111110000000000000000000111 +000111000000000111111000000000000000000111 +000111000000000111111000000000000000000111 +000111000000000001111000000000000000000111 +000111000000000000111000000000000000000111 +000111000000000000111100000000000000000111 +000111000000000000001110000000000000000111 +000111000000000000000111000000000000000111 +000111000000000000000111000000000000000111 +000111000000000000000111000000000000000111 +000111000000000000000111000000000000000111 +000111000000000000000111000000000000000111 +000111000000000000000111000000000000000111 +000111000000000000000111000000000000000111 +000111000000000000001110000000000000000111 +000111000000000000111100000000000000000111 +000111000000000000111000000000000000000111 +000111000000000001111000000000000000000111 +000111000000000111111000000000000000000000 +000111000000000111111000000000000000000000 +001111100000001111110000000000000000000000 +111111111111111111100000000000111000000111 +111111111111111111000000000000111000000111 +111111111111111110000000000000111000000111 +000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000 +Test 3. "E,?" in PBM plain format +P1 +60 60 +000000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000 +011111111111111111111111110000000000000000000000011111100000 +111111111111111111111111111000000000000000000000111111110000 +111111111111111111111111111100000000000000000001111111111000 +011111111111111111111111111100000000000000000011111111111100 +001111111100000000000011111100000000000000000111110000111110 +000111111000000000000001111100000000000000001111100000011111 +000011110000000000000000111100000000000000001111000000001111 +000011110000000000000000011000000000000000000110000000001111 +000011110000000000000000000000000000000000000000000000001111 +000011110000000000000000000000000000000000000000000000001111 +000011110000000000000000000000000000000000000000000000011111 +000011110000000000000000000000000000000000000000000000111110 +000011110000000000000110000000000000000000000000000001111100 +000011110000000000001111000000000000000000000000000011111000 +000011111000000000011111000000000000000000000000000111110000 +000011111100000000111111000000000000000000000000001111100000 +000011111111111111111111000000000000000000000000011111000000 +000011111111111111111111000000000000000000000000111110000000 +000011111111111111111111000000000000000000000000111100000000 +000011111111111111111111000000000000000000000000111100000000 +000011111100000000111111000000000000000000000000111100000000 +000011111000000000011111000000000000000000000000111100000000 +000011110000000000001111000000000000000000000000111100000000 +000011110000000000000110000000000000000000000000111100000000 +000011110000000000000000000000000000000000000000111100000000 +000011110000000000000000000000000000000000000000111100000000 +000011110000000000000000000000000000000000000000111100000000 +000011110000000000000000000000000000000000000000011000000000 +000011110000000000000000011000000000000000000000000000000000 +000011110000000000000000111100000000000000000000000000000000 +000111111000000000000001111100000000000000000000000000000000 +001111111100000000000011111100000000000000000000000000000000 +011111111111111111111111111100000000011000000000011000000000 +111111111111111111111111111100000000111100000000111100000000 +111111111111111111111111111000000000111100000000111100000000 +011111111111111111111111110000000000111100000000011000000000 +000000000000000000000000000000000000111100000000000000000000 +000000000000000000000000000000000000111100000000000000000000 +000000000000000000000000000000000001111100000000000000000000 +000000000000000000000000000000000011111000000000000000000000 +000000000000000000000000000000000111110000000000000000000000 +000000000000000000000000000000001111100000000000000000000000 +000000000000000000000000000000001111000000000000000000000000 +000000000000000000000000000000000110000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000 +Test 5. Should print 576003211 10631 +576003211 10631 +Test 6. Should print 3501321825 369 +3501321825 369 +Test 7. Should print 1588181271 535 +1588181271 535 +Test 8. Should print 2843090781 610 +2843090781 610 +Test 9. Should print 146160766 820 +146160766 820 +Test 10. Should print 3327221668 2111 +3327221668 2111 +Test Invalid +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) diff --git a/test/pbmpscale.test b/test/pbmpscale.test index 9c34734a..b99561f6 100755 --- a/test/pbmpscale.test +++ b/test/pbmpscale.test @@ -1,30 +1,34 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmpscale -# Also requires: pamenlarge pbmtext - - -pbmtext -nomargin "F" | pbmpscale 3 -plain - -for i in 2 3 4 -do -pamenlarge 2 testgrid.pbm | \ - pbmpscale $i | cksum -done - -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 - -pbmpscale testgrid.pbm > ${test_out} || \ - echo -n "Expected failure 1"; test -s ${test_out}; echo " "$? - -pbmpscale 0 testgrid.pbm > ${test_out} || \ - echo -n "Expected failure 2"; test -s ${test_out}; echo " "$? - -pbmpscale 2 3 testgrid.pbm > ${test_out} || \ - echo -n "Expected failure 3"; test -s ${test_out}; echo " "$? - -rm -f ${test_out} \ No newline at end of file +# Also requires: pbmtext + +echo "Test 1. Should print \"abc\" rendered in PBM plain format" +pbmtext -nomargin "abc" | pbmpscale 1 -plain +echo "Test 2. \"ABC\" in PBM plain format" +pbmtext -nomargin "ABC" | pbmpscale 2 -plain +echo "Test 3. \"D.!\" in PBM plain format" +pbmtext -nomargin "D.!" | pbmpscale 3 -plain +echo "Test 3. \"E,?\" in PBM plain format" +pbmtext -nomargin "E,?" | pbmpscale 4 -plain + +echo "Test 5. Should print 576003211 10631" +pbmpscale 5 maze.pbm | cksum + +echo "Test 6. Should print 3501321825 369" +pbmtext -nomargin "6" | pbmpscale 6 | cksum +echo "Test 7. Should print 1588181271 535" +pbmtext -nomargin "7" | pbmpscale 7 | cksum +echo "Test 8. Should print 2843090781 610" +pbmtext -nomargin "8" | pbmpscale 8 | cksum +echo "Test 9. Should print 146160766 820" +pbmtext -nomargin "9" | pbmpscale 9 | cksum +echo "Test 10. Should print 3327221668 2111" +pbmtext -nomargin "10" | pbmpscale 10 | cksum + +echo "Test Invalid" + +. ${srcdir}/test-invalid.inc + +invCmd "pbmpscale testgrid.pbm" +invCmd "pbmpscale 0 testgrid.pbm" +invCmd "pbmpscale 2 3 testgrid.pbm" diff --git a/test/pbmtext-bdf.test b/test/pbmtext-bdf.test index b12c10bf..f1d2019e 100755 --- a/test/pbmtext-bdf.test +++ b/test/pbmtext-bdf.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmtext # Also requires: @@ -173,3 +173,5 @@ do echo $? rm ${font_corrupt_bdf} done + +rm ${font_bdf} \ No newline at end of file diff --git a/test/pbmtext-iso88591.test b/test/pbmtext-iso88591.test index 69e6ec90..1472b89e 100755 --- a/test/pbmtext-iso88591.test +++ b/test/pbmtext-iso88591.test @@ -1,9 +1,9 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmtext # Also requires: # This test requires an iso-8859-1 locale -# Skip this test if it is not available +# Skip this test if none are available LANG=C LC_ALL=C @@ -12,26 +12,30 @@ export LANG LC_ALL tmpdir=${tmpdir:-/tmp} iso88591_locale_list=${tmpdir}/iso88591_locale_list +locale_to_test="en_US.iso88591" # Initial value; this +# does not have to be actually available. +# Edit the above value if you have a preferred locale. -locale_to_test="en_US.iso88591" # Initial value -# Edit the above value if necessary - -# Make a list of available locales which end in "iso88591" -locale -a | grep "\.iso88591$" > ${iso88591_locale_list} +# Make a list of available locales which end in "iso88591" etc. +# If none are found, abort test -# Hunt for a valid iso-8859-1 locale +locale -a |\ + grep -e "\.iso88591$" -e "\.iso-8859-1$" -e "\.ISO-8859-1$" \ + > ${iso88591_locale_list} || locale_to_test="" + +# Hunt for a valid iso-8859-1 locale # Submit each candidate to a trial pbmtext run until one that works is # encountered -i=0 until [ -z ${locale_to_test} ] || \ echo "A" | LC_ALL=${locale_to_test} pbmtext -wchar > /dev/null do - let i=$(($i+1)); - locale_to_test=`sed "$i"p -n ${iso88591_locale_list}`; + # Read first line of file + locale_to_test=`head -n 1 ${iso88591_locale_list}`; + # then erase the line + sed -i 1d ${iso88591_locale_list}; done; -rm ${iso88591_locale_list}; if [ -z ${locale_to_test} ] then echo "No iso-8859-1 locale available." 1>&2 echo "Skipping." 1>&2 @@ -42,7 +46,6 @@ fi; locale_for_test=${locale_to_test}; - # Two rows # Should print 2066913605 5110 twice echo "Test 1" diff --git a/test/pbmtext-utf8.ok b/test/pbmtext-utf8.ok index 84743a09..0d40adde 100644 --- a/test/pbmtext-utf8.ok +++ b/test/pbmtext-utf8.ok @@ -13,12 +13,12 @@ Test 5 Invalid 9998 989454365 52512 9999 -Expected failure 1 1 -Expected failure 2 1 +Expected failure 1 (no output) +Expected failure 2 (no output) Test 6 Invalid -6-1: 0 1 : 1 1 -6-2: 0 1 : 1 1 -6-3: 0 1 : 1 1 -6-4: 0 1 : 1 1 -6-5: 0 1 : 1 1 -6-6: 0 1 : 1 1 +6-1: 0 1 : 1 (no output) +6-2: 0 1 : 1 (no output) +6-3: 0 1 : 1 (no output) +6-4: 0 1 : 1 (no output) +6-5: 0 1 : 1 (no output) +6-6: 0 1 : 1 (no output) diff --git a/test/pbmtext-utf8.test b/test/pbmtext-utf8.test index 8ebb6e31..551cfe29 100755 --- a/test/pbmtext-utf8.test +++ b/test/pbmtext-utf8.test @@ -6,9 +6,8 @@ LANG=C LC_ALL=C export LANG LC_ALL - -# This test requires a working UTF-8 locale -# Skip this test if it is are not available +# This test requires a working UTF-8 locale +# Skip this test if none are available iconv /dev/null if [ $? -ne 0 ] @@ -20,25 +19,29 @@ fi tmpdir=${tmpdir:-/tmp} utf_locale_list=${tmpdir}/utf_locale_list -locale_to_test="en_US.utf8" # Initial value -# Edit the above value if necessary - -# Make a list of available locales which end in "utf8" -locale -a | grep "\.utf8$" > ${utf_locale_list} +locale_to_test="en_US.utf8" # Initial value; this +# does not have to be actually available. +# Edit the above value if you have a preferred locale. + +# Make a list of available locales which end in "utf8" etc. +# If none are found, abort test -# Hunt for a valid utf8 locale +locale -a | grep -e "\.utf8$" -e "\.utf-8$" -e "\.UTF-8$" \ + > ${utf_locale_list} || locale_to_test="" + +# Hunt for a valid utf8 locale # Submit each candidate to a trial pbmtext run until one that works is # encountered -i=0 until [ -z ${locale_to_test} ] || \ echo "A" | LC_ALL=${locale_to_test} pbmtext -wchar > /dev/null do - let i=$(($i+1)); - locale_to_test=`sed "$i"p -n ${utf_locale_list}`; + # Read first line of file + locale_to_test=`head -n 1 ${utf_locale_list}`; + # then erase the line + sed -i 1d ${utf_locale_list}; done; -rm ${utf_locale_list}; if [ -z ${locale_to_test} ] then echo "No utf-8 locale available." 1>&2 echo "Skipping." 1>&2 @@ -115,10 +118,10 @@ awk 'BEGIN { for (i=32; i<=126;++i) printf("%c",i); print "" } ' awk 'BEGIN { for (i=32; i<=126;++i) printf("%c",i); print ""}' | \ LC_ALL=${locale_for_test} pbmtext -builtin bdf -wchar -text-dump + # Test 5. # Long input text - echo "Test 5 Invalid" long_txt=${tmpdir}/long.txt @@ -135,19 +138,22 @@ echo "Test input text which exceeds length limit" 1>&2 echo "Error messages should appear below the line." 1>&2 echo "-----------------------------------------------------------" 1>&2 -echo -n "z" >> ${long_txt} +printf "z" >> ${long_txt} cat ${long_txt} | wc -c | tr -d ' ' cat ${long_txt} | \ LC_ALL=${locale_for_test} \ pbmtext -nomargins -builtin fixed -wchar > ${test_out} || \ - echo -n "Expected failure 1"; - test -s ${test_out}; echo " "$? + printf "Expected failure 1 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + cat ${long_txt} | \ LC_ALL=${locale_for_test} \ pbmtext -nomargins -builtin fixed -wchar > ${test_out} || \ - echo -n "Expected failure 2"; - test -s ${test_out}; echo " "$? + printf "Expected failure 2 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} rm ${long_txt} @@ -165,39 +171,42 @@ echo "Test 6 Invalid" awk 'BEGIN { printf("%c%c",128,129); print ""}' | \ LC_ALL=${locale_for_test} \ - pbmtext -builtin bdf -wchar -text-dump > ${test_out} - echo -n "6-1:" ${PIPESTATUS[@]} ":" $? - test -s ${test_out}; echo " "$? - + pbmtext -builtin bdf -wchar -text-dump > ${test_out} + printf "6-1: ${PIPESTATUS[*]} : $? " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + awk 'BEGIN { printf("ABC%c%c",192, 193); print ""}' | \ LC_ALL=${locale_for_test} \ - pbmtext -builtin bdf -wchar -text-dump > ${test_out} - echo -n "6-2:" ${PIPESTATUS[@]} ":" $? - test -s ${test_out}; echo " "$? + pbmtext -builtin bdf -wchar -text-dump > ${test_out} + printf "6-2: ${PIPESTATUS[*]} : $? " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} awk 'BEGIN { printf("abcde%c%c", 254, 253); print ""}' | \ LC_ALL=${locale_for_test} \ - pbmtext -builtin bdf -wchar -text-dump > ${test_out} - echo -n "6-3:" ${PIPESTATUS[@]} ":" $? - test -s ${test_out}; echo " "$? - + pbmtext -builtin bdf -wchar -text-dump > ${test_out} + printf "6-3: ${PIPESTATUS[*]} : $? " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + awk 'BEGIN { printf("abcdefg%c%c", 195, 15); print ""}' | \ LC_ALL=${locale_for_test} \ - pbmtext -builtin bdf -wchar -text-dump > ${test_out} - echo -n "6-4:" ${PIPESTATUS[@]} ":" $? - test -s ${test_out}; echo " "$? + pbmtext -builtin bdf -wchar -text-dump > ${test_out} + printf "6-4: ${PIPESTATUS[*]} : $? " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} awk 'BEGIN { printf("123456789%c%c%c", 224, 143 ,0); print ""}' | \ LC_ALL=${locale_for_test} \ - pbmtext -builtin bdf -wchar -text-dump > ${test_out} - echo -n "6-5:" ${PIPESTATUS[@]} ":" $? - test -s ${test_out}; echo " "$? + pbmtext -builtin bdf -wchar -text-dump > ${test_out} + printf "6-5: ${PIPESTATUS[*]} : $? " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} awk 'BEGIN { printf("abcdefg123ABCDEFG%c%c%c%c",247, 135, 135, 7); print ""}' | \ LC_ALL=${locale_for_test} \ - pbmtext -builtin bdf -wchar -text-dump > ${test_out} - echo -n "6-6:" ${PIPESTATUS[@]} ":" $? - test -s ${test_out}; echo " "$? - -rm ${test_out} - + pbmtext -builtin bdf -wchar -text-dump > ${test_out} + printf "6-6: ${PIPESTATUS[*]} : $? " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} diff --git a/test/pbmtext.ok b/test/pbmtext.ok index 68ed40d8..975911f2 100644 --- a/test/pbmtext.ok +++ b/test/pbmtext.ok @@ -20,20 +20,20 @@ Test 5 2547645687 4564 1174281741 5741 Test 6 Invalid -Expected failure 1 1 -Expected failure 2 1 -Expected failure 3 1 -Expected failure 4 1 -Expected failure 5 1 -Expected failure 6 1 -Expected failure 7 1 -Expected failure 8 1 +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) +Expected failure 5 (no output) +Expected failure 6 (no output) +Expected failure 7 (no output) +Expected failure 8 (no output) Test 7 text length: 4999 1854691667 52512 1854691667 52512 Test 8 Invalid text length: 5000 -Expected failure 1 1 -Expected failure 2 1 -Expected failure 3 1 +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) diff --git a/test/pbmtext.test b/test/pbmtext.test index 515711e4..d4ab027e 100755 --- a/test/pbmtext.test +++ b/test/pbmtext.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmtext # Also requires: pamfile @@ -10,13 +10,13 @@ echo "Test 1" # Should print 3898818212 967 twice pbmtext UNIX Philosophy: Do one thing and do it well. | cksum -echo -n "UNIX Philosophy: Do one thing and do it well." | pbmtext | cksum +printf "UNIX Philosophy: Do one thing and do it well." | pbmtext | cksum # Should print 2506052117 1354 twice pbmtext -builtin fixed \ For truth is always strange. Stranger than fiction. Lord Byron | cksum -echo -n "For truth is always strange. Stranger than fiction. Lord Byron" | \ +printf "For truth is always strange. Stranger than fiction. Lord Byron" | \ pbmtext -builtin fixed | cksum @@ -41,7 +41,7 @@ for flags in "" "-builtin fixed" do pbmtext ${flags} ${text} | tee ${temp_pbm} | cksum width1=`pamfile ${temp_pbm} | awk '$2=="PBM" && NR==1 {w=$4}; END {print w}' ` -width2=`pbmtext ${flags} ${text} --dry-run | awk '{print $1}' ` +width2=`pbmtext ${flags} ${text} --dry-run | cut -d " " -f 1` if [ ${width1} -eq ${width2} ]; then pbmtext ${flags} -width=${width1} ${text} | cksum @@ -112,29 +112,44 @@ echo "Test 6 Invalid" test_out=${tmpdir}/test_out pbmtext -font=testgrid.pbm foo > ${test_out} || \ - echo -n "Expected failure 1"; - test -s ${test_out}; echo " "$? + printf "Expected failure 1 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + pbmtext -font=testimg.ppm foo > ${test_out} || \ - echo -n "Expected failure 2"; - test -s ${test_out}; echo " "$? + printf "Expected failure 2 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + pbmtext -builtin=void foo > ${test_out} || \ - echo -n "Expected failure 3"; - test -s ${test_out}; echo " "$? + printf "Expected failure 3 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + pbmtext -font=${font_pbm} -builtin=fixed foo > ${test_out} || \ - echo -n "Expected failure 4"; - test -s ${test_out}; echo " "$? + printf "Expected failure 4 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + pbmtext -dry-run -text-dump foo > ${test_out} || \ - echo -n "Expected failure 5"; - test -s ${test_out}; echo " "$? + printf "Expected failure 5 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + pbmtext -dump-sheet -text-dump foo > ${test_out} || \ - echo -n "Expected failure 6"; - test -s ${test_out}; echo " "$? + printf "Expected failure 6 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + pbmtext -dry-run -dump-sheet foo > ${test_out} || \ - echo -n "Expected failure 7"; - test -s ${test_out}; echo " "$? + printf "Expected failure 7 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + pbmtext -wchar foo > ${test_out} || \ - echo -n "Expected failure 8"; - test -s ${test_out}; echo " "$? + printf "Expected failure 8 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} rm ${font_pbm} @@ -153,7 +168,7 @@ cat ${long_txt} | pbmtext -nomargins -builtin fixed | cksum echo "Test 8 Invalid" -echo -n "z" >> ${long_txt} +printf "z" >> ${long_txt} awk '{print "text length:", length($0)}' ${long_txt} echo 1>&2 @@ -162,14 +177,19 @@ echo "Error messages should appear below the line." 1>&2 echo "-----------------------------------------------------------" 1>&2 pbmtext -nomargins -builtin fixed `cat ${long_txt}` > ${test_out} || \ - echo -n "Expected failure 1"; - test -s ${test_out}; echo " "$? + printf "Expected failure 1 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + cat ${long_txt} | pbmtext -nomargins -builtin fixed > ${test_out} || \ - echo -n "Expected failure 2"; - test -s ${test_out}; echo " "$? + printf "Expected failure 2 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + cat ${long_txt} | \ LC_ALL=C pbmtext -nomargins -builtin fixed -wchar > ${test_out} || \ - echo -n "Expected failure 3"; - test -s ${test_out}; echo " "$? + printf "Expected failure 3 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} -rm ${long_txt} ${test_out} +rm ${long_txt} diff --git a/test/pbmtextps-dump.ok b/test/pbmtextps-dump.ok new file mode 100644 index 00000000..71b2d2a2 --- /dev/null +++ b/test/pbmtextps-dump.ok @@ -0,0 +1,88 @@ +Test 1 +-font=ZQUEl8eS38RlsvEahHGNfnrbSswrcJKFwvlCdEttwcheuXvCN49MvWmndqj4 +< /FindFont {/Times-Roman findfont} def +> /FindFont {/ZQUEl8eS38RlsvEahHGNfnrbSswrcJKFwvlCdEttwcheuXvCN49MvWmndqj4 findfont} def +-fontsize 2000 +< /fontsize 24.000000 def +> /fontsize 2000.000000 def +< /descent 36.000000 def +< /leftmargin 12.000000 def +> /descent 3000.000000 def +> /leftmargin 1000.000000 def +-resolution 7200 +-leftmargin=15 +< /leftmargin 12.000000 def +> /leftmargin 15.000000 def +-rightmargin=20 +< /rightmargin 0.000000 def +> /rightmargin 20.000000 def +-topmargin=10 +< /topmargin 0.000000 def +> /topmargin 10.000000 def +-bottommargin=14 +< /descent 36.000000 def +> /descent 0.000000 def +< /bottommargin 0.000000 def +> /bottommargin 14.000000 def +-ascent=30 +< /ascent 0.000000 def +> /ascent 30.000000 def +-descent=20 +< /descent 36.000000 def +> /descent 20.000000 def +-pad +< /descent 36.000000 def +> /descent 0.000000 def +< /pad false def +> /pad true def +-crop +< /descent 36.000000 def +< /leftmargin 12.000000 def +> /descent 0.000000 def +> /leftmargin 0.000000 def +-stroke 1 +< /pensize -1.000000 def +> /pensize 1.000000 def +Test 2 +30 31 32 20 41 42 43 2d 78 79 7a 2e +1 +303132204142432d78797a2e +1 +<303132 20 414243 2d 78797a 2e> +1 +Test Invalid +Expected failure 1 (-fontsize) (no output) +Expected failure 2 (-fontsize 0) (no output) +Expected failure 3 (-resolution) (no output) +Expected failure 4 (-resolution=0) (no output) +Expected failure 5 (-leftmargin) (no output) +Expected failure 6 (-leftmargin -1) (no output) +Expected failure 7 (-rightmargin) (no output) +Expected failure 8 (-rightmargin -1) (no output) +Expected failure 9 (-topmargin) (no output) +Expected failure 10 (-topmargin -1) (no output) +Expected failure 11 (-bottommargin) (no output) +Expected failure 12 (-bottommargin -1) (no output) +Expected failure 13 (-ascent) (no output) +Expected failure 14 (-ascent -1) (no output) +Expected failure 15 (-descent) (no output) +Expected failure 16 (-descent -1) (no output) +Expected failure 17 (-stroke=A) (no output) +Expected failure 18 (-pad -crop) (no output) +Expected failure 19 (-asciihex <a>) (no output) +Expected failure 20 (-asciihex ) (no output) +Expected failure 21 (-asciihex <53756c667572) (no output) +Expected failure 22 (-asciihex 53756c667572>) (no output) +Expected failure 23 (-asciihex <5375<6c667572>) (no output) +Expected failure 24 (-asciihex <53756c>667572>) (no output) +Expected failure 25 (-ascii85 <~@<6O!FD5W(~) (no output) +Expected failure 26 (-ascii85 ~@<6O!FD5W(~>) (no output) +Expected failure 27 (-ascii85 <~@<6O<~!FD5W(~>) (no output) +Expected failure 28 (-ascii85 <~@<6O~>!FD5W(~>) (no output) +Expected failure 29 (-ascii85 <~@<6O!FD5W(~~>) (no output) +Expected failure 30 (-ascii85 v) (no output) +Expected failure 31 (-ascii85 y) (no output) +Expected failure 32 (-ascii85 1z) (no output) +Expected failure 33 (-ascii85 z1z) (no output) +Expected failure 34 (-ascii85 <~0123z~>) (no output) +Expected failure 35 (-font="") (no output) diff --git a/test/pbmtextps-dump.test b/test/pbmtextps-dump.test new file mode 100755 index 00000000..fd68667d --- /dev/null +++ b/test/pbmtextps-dump.test @@ -0,0 +1,136 @@ +#! /bin/sh +# This script tests: pbmtextps +# Also requires: + +# Dump several variants of the ps file and compare against default. +# Ghostscript is not required. + +tmpdir=${tmpdir:-/tmp} +text1_ps=${tmpdir}/text1.ps +text2_ps=${tmpdir}/text2.ps + +text="UNIX Philosophy: Do one thing and do it well." + +# Test 1: +echo "Test 1" + +pbmtextps -dump-ps ${text} > ${text1_ps} + +# Font name is random sequence of alphanumerical characters. +# Should not match any real name. + +for flag in \ + "-font=ZQUEl8eS38RlsvEahHGNfnrbSswrcJKFwvlCdEttwcheuXvCN49MvWmndqj4" \ + "-fontsize 2000" \ + "-resolution 7200" \ + "-leftmargin=15" \ + "-rightmargin=20" \ + "-topmargin=10" \ + "-bottommargin=14" \ + "-ascent=30" \ + "-descent=20" \ + "-pad" \ + "-crop" \ + "-stroke 1" + do + echo ${flag} + pbmtextps -dump-ps ${flag} ${text} | diff ${text1_ps} - | grep "^[<>]" + done + +rm ${text1_ps} + + +# Test 2: +echo "Test 2" + +pbmtextps -dump-ps "012 ABC-xyz." > ${text2_ps} + +for hextext in \ + "30 31 32 20 41 42 43 2d 78 79 7a 2e" \ + "303132204142432d78797a2e" \ + "<303132 20 414243 2d 78797a 2e>" + do + echo ${hextext} + pbmtextps -dump-ps -asciihex ${hextext} | diff ${text2_ps} - | grep "^[<>]" + echo $? + done + +rm ${text2_ps} + + +echo "Test Invalid" + +echo 1>&2 +echo "Invalid command line arguments" 1>&2 +echo "Error messages should appear below the line." 1>&2 +echo "-----------------------------------------------------------" 1>&2 + +test_out=${tmpdir}/test.out + +n=1 + +for error_flag in \ + "-fontsize" \ + "-fontsize 0" \ + "-resolution" \ + "-resolution=0" \ + "-leftmargin" \ + "-leftmargin -1" \ + "-rightmargin" \ + "-rightmargin -1" \ + "-topmargin" \ + "-topmargin -1" \ + "-bottommargin" \ + "-bottommargin -1" \ + "-ascent" \ + "-ascent -1" \ + "-descent" \ + "-descent -1" \ + "-stroke=A" \ + "-pad -crop" + do + pbmtextps ${error_flag} -dump-ps ${text} >${test_out} || \ + printf "Expected failure $n (${error_flag}) " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + n=$((n + 1)) + done + +for asciihex_string in \ + "<a>" \ + "" \ + "<53756c667572" \ + "53756c667572>" \ + "<5375<6c667572>" \ + "<53756c>667572>" + do + pbmtextps -dump-ps -asciihex ${asciihex_string} >${test_out} || \ + printf "Expected failure $n (-asciihex ${asciihex_string}) " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + n=$((n + 1)) + done + +for ascii85_string in \ + '<~@<6O!FD5W(~'\ + '~@<6O!FD5W(~>'\ + "<~@<6O<~!FD5W(~>"\ + "<~@<6O~>!FD5W(~>"\ + "<~@<6O!FD5W(~~>"\ + "v"\ + "y"\ + "1z"\ + "z1z"\ + "<~0123z~>" + do + pbmtextps -dump-ps -ascii85 ${ascii85_string} >${test_out} || \ + printf "Expected failure $n (-ascii85 ${ascii85_string}) " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + n=$((n + 1)) + done + + pbmtextps -font="" -dump-ps ${text} >${test_out} || \ + printf "Expected failure $n (-font=\"\") " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} diff --git a/test/pbmtextps.ok b/test/pbmtextps.ok new file mode 100644 index 00000000..2063ac4a --- /dev/null +++ b/test/pbmtextps.ok @@ -0,0 +1,18 @@ +Test 1. Should print 0 five times. +0 +0 +0 +0 +0 +Test 2. Should print P1 1 1 0 five times +P1 1 1 0 +P1 1 1 0 +P1 1 1 0 +P1 1 1 0 +P1 1 1 0 +Test 3. Should print eulerchi: N + eulerchi: 1 + eulerchi: 2 + eulerchi: 3 + eulerchi: 4 + eulerchi: 5 diff --git a/test/pbmtextps.test b/test/pbmtextps.test new file mode 100755 index 00000000..55f3f96a --- /dev/null +++ b/test/pbmtextps.test @@ -0,0 +1,55 @@ +#! /bin/sh +# This script tests: pbmtextps pbmminkowski +# Also requires: gs pnmcrop + +tmpdir=${tmpdir:-/tmp} +text_pbm=${tmpdir}/text.pbm + +text="Do one thing and do it well." + +echo "Test 1. Should print 0 five times." +# -ascent -descent values too small to have effect + +pbmtextps -descent=1 ${text} > ${text_pbm} + echo $? + test -s ${text_pbm} + echo $? +pbmtextps -ascent=10 -descent=1 ${text} | cmp -s - ${text_pbm} + echo $? +pbmtextps -ascent=1 -descent=1 ${text} | cmp -s - ${text_pbm} + echo $? +pbmtextps -descent=2 ${text} | cmp -s - ${text_pbm} + echo $? + +rm ${text_pbm} + + +echo "Test 2. Should print P1 1 1 0 five times" +# blank images + +pbmtextps " " | pnmcrop -plain -blank-image=minimize |\ + tr '\n' ' ' ; echo +pbmtextps -fontsize=12 " " | pnmcrop -plain -blank-image=minimize |\ + tr '\n' ' ' ; echo +pbmtextps -resolution=50 " " | pnmcrop -plain -blank-image=minimize |\ + tr '\n' ' ' ; echo +pbmtextps -asciihex "20" | pnmcrop -plain -blank-image=minimize |\ + tr '\n' ' ' ; echo +pbmtextps -ascii85 "+9" | pnmcrop -plain -blank-image=minimize |\ + tr '\n' ' ' ; echo + + + +echo "Test 3. Should print eulerchi: N" +# Test with characters known to produce stable eulerchi values +# accross various fonts + +pbmtextps " " | pbmminkowski | grep "eulerchi" + +pbmtextps "+" | pbmminkowski | grep "eulerchi" + +pbmtextps "+" | pnmcrop -left -right | pbmminkowski | grep "eulerchi" + +pbmtextps "+" | pnmcrop | pbmminkowski | grep "eulerchi" + +pbmtextps "o" | pnmcrop | pbmminkowski | grep "eulerchi" diff --git a/test/pbmtog3.ok b/test/pbmtog3.ok index cef9e3f9..6660206b 100644 --- a/test/pbmtog3.ok +++ b/test/pbmtog3.ok @@ -1,10 +1,20 @@ -3697098186 144 -1248301383 122 -686713716 144 -215463240 122 +Test 1. Should print 2156383714 1106 +2156383714 1106 +Test 2. Should print 162371073 1049 +162371073 1049 +Test 3. Should print 750267045 1106 +750267045 1106 +Test 4. Should print 1140269483 1049 +1140269483 1049 +Test 5. Should print 28792587 47 28792587 47 +Test 6. Should print 277456854 32 277456854 32 +Test 7. Should print 28792587 47 28792587 47 +Test 8. Should print 3736247115 62 3736247115 62 +Test 9. Should print 2820255307 2191856 2820255307 2191856 +Test 10. Should print 4159089282 2226575 4159089282 2226575 diff --git a/test/pbmtog3.test b/test/pbmtog3.test index c5dc3357..8b9c29e1 100755 --- a/test/pbmtog3.test +++ b/test/pbmtog3.test @@ -1,25 +1,34 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmtog3 # Also requires: pbmmake -# Test 1. Should print 3697098186 144 -pbmtog3 testgrid.pbm | cksum -# Test 2. Should print 1248301383 122 -pbmtog3 -nofixedwidth testgrid.pbm | cksum -# Test 3. Should print 686713716 144 -pbmtog3 -reverse testgrid.pbm | cksum -# Test 4. Should print 215463240 122 -pbmtog3 -nofixedwidth -reverse testgrid.pbm | cksum -# Test 5. Should print 28792587 47 +echo "Test 1. Should print 2156383714 1106" +pbmtog3 maze.pbm | cksum + +echo "Test 2. Should print 162371073 1049" +pbmtog3 -nofixedwidth maze.pbm | cksum + +echo "Test 3. Should print 750267045 1106" +pbmtog3 -reverse maze.pbm | cksum + +echo "Test 4. Should print 1140269483 1049" +pbmtog3 -nofixedwidth -reverse maze.pbm | cksum + +echo "Test 5. Should print 28792587 47" pbmmake -w 10 10 | pbmtog3 | cksum -# Test 6. Should print 277456854 32 + +echo "Test 6. Should print 277456854 32" pbmmake -w 10 10 | \ pbmtog3 -nofixedwidth | cksum -# Test 7. Should print 28792587 47 + +echo "Test 7. Should print 28792587 47" pbmmake -w 10000 10 | pbmtog3 | cksum -# Test 8. Should print 3736247115 62 + +echo "Test 8. Should print 3736247115 62" pbmmake -b 10 10 | pbmtog3 | cksum -# Test 9. Should print 2820255307 2191856 + +echo "Test 9. Should print 2820255307 2191856" pbmmake -g 1700 2286 | pbmtog3 | cksum -# Test 10. Should print 4159089282 2226575 + +echo "Test 10. Should print 4159089282 2226575" pbmmake -g 1800 2286 | pbmtog3 | cksum diff --git a/test/pbmtopgm.ok b/test/pbmtopgm.ok index 6ccf9c64..11242259 100644 --- a/test/pbmtopgm.ok +++ b/test/pbmtopgm.ok @@ -19,7 +19,7 @@ P2 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Test Invalid -Expected failure 1 1 -Expected failure 2 1 -Expected failure 3 1 -Expected failure 4 1 +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) diff --git a/test/pbmtopgm.test b/test/pbmtopgm.test index a7ba6f7c..19378bb6 100755 --- a/test/pbmtopgm.test +++ b/test/pbmtopgm.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmtopgm # Also requires: @@ -9,24 +9,9 @@ pbmtopgm -plain 1 1 testgrid.pbm echo "Test Invalid" -tmpdir=${tmpdir:-/tmp} -test_out=${tmpdir}/test_out +. ${srcdir}/test-invalid.inc -echo 1>&2 -echo "Invalid command-line argument combinations." 1>&2 -echo "Error messages should appear below the line." 1>&2 -echo "-----------------------------------------------------------" 1>&2 - -pbmtopgm 5 0 testgrid.pbm > ${test_out} || \ - echo -n "Expected failure 1"; test -s ${test_out}; echo " "$? - -pbmtopgm 0 9 testgrid.pbm > ${test_out} || \ - echo -n "Expected failure 2"; test -s ${test_out}; echo " "$? - -pbmtopgm 15 5 testgrid.pbm > ${test_out} || \ - echo -n "Expected failure 3"; test -s ${test_out}; echo " "$? - -pbmtopgm 5 17 testgrid.pbm > ${test_out} || \ - echo -n "Expected failure 4"; test -s ${test_out}; echo " "$? - -rm -f ${test_out} +invCmd "pbmtopgm 5 0 testgrid.pbm" +invCmd "pbmtopgm 0 9 testgrid.pbm" +invCmd "pbmtopgm 15 5 testgrid.pbm" +invCmd "pbmtopgm 5 17 testgrid.pbm" diff --git a/test/pbmupc.ok b/test/pbmupc.ok index f1b91e99..4f2fd0ae 100644 --- a/test/pbmupc.ok +++ b/test/pbmupc.ok @@ -1,12 +1,12 @@ Test 1 2619309127 10172 Test Invalid -Expected failure 1 1 -Expected failure 2 1 -Expected failure 3 1 -Expected failure 4 1 -Expected failure 5 1 -Expected failure 6 1 -Expected failure 7 1 -Expected failure 8 1 -Expected failure 9 1 +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) +Expected failure 5 (no output) +Expected failure 6 (no output) +Expected failure 7 (no output) +Expected failure 8 (no output) +Expected failure 9 (no output) diff --git a/test/pbmupc.test b/test/pbmupc.test index fb9ec90e..74bd54d9 100755 --- a/test/pbmupc.test +++ b/test/pbmupc.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmupc # Also requires: @@ -20,22 +20,46 @@ echo "Error messages should appear below the line." 1>&2 echo "-----------------------------------------------------------" 1>&2 pbmupc -s3 0 72890 00011 > ${test_out} || \ - echo -n "Expected failure 1"; test -s ${test_out}; echo " "$? + printf "Expected failure 1 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + pbmupc -s1 72890 00011 > ${test_out} || \ - echo -n "Expected failure 2"; test -s ${test_out}; echo " "$? + printf "Expected failure 2 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + pbmupc -s1 0 72890 > ${test_out} || \ - echo -n "Expected failure 3"; test -s ${test_out}; echo " "$? + printf "Expected failure 3 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + pbmupc -s1 10 72890 00011 > ${test_out} || \ - echo -n "Expected failure 4"; test -s ${test_out}; echo " "$? + printf "Expected failure 4 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + pbmupc -s1 0 172890 00011 > ${test_out} || \ - echo -n "Expected failure 5"; test -s ${test_out}; echo " "$? + printf "Expected failure 5 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + pbmupc -s1 0 2890 00011 > ${test_out} || \ - echo -n "Expected failure 6"; test -s ${test_out}; echo " "$? + printf "Expected failure 6 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + pbmupc -s1 0 72890 100011 > ${test_out} || \ - echo -n "Expected failure 7"; test -s ${test_out}; echo " "$? + printf "Expected failure 7 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + pbmupc -s1 0 72890 0011 > ${test_out} || \ - echo -n "Expected failure 8"; test -s ${test_out}; echo " "$? -pbmupc -s1 0 72890 100011 1 > ${test_out} || \ - echo -n "Expected failure 9"; test -s ${test_out}; echo " "$? + printf "Expected failure 8 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} -rm ${test_out} +pbmupc -s1 0 72890 100011 1 > ${test_out} || \ + printf "Expected failure 9 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} diff --git a/test/pcx-roundtrip.ok b/test/pcx-roundtrip.ok index 968f46b9..0f5ac87d 100644 --- a/test/pcx-roundtrip.ok +++ b/test/pcx-roundtrip.ok @@ -1,5 +1,9 @@ +Test 1. Should print 1926073387 101484 1926073387 101484 +Test 2. Should print 369063776 101484 three times 369063776 101484 369063776 101484 369063776 101484 -829921912 685 +Test 3. Should print 669206373 10102 twice +669206373 10102 +669206373 10102 diff --git a/test/pcx-roundtrip.test b/test/pcx-roundtrip.test index 3dba42b9..194af131 100755 --- a/test/pcx-roundtrip.test +++ b/test/pcx-roundtrip.test @@ -1,7 +1,6 @@ -#! /bin/bash +#! /bin/sh # This script tests: ppmtopcx pcxtoppm -# Also requires: pnmremap - +# Also requires: pgmtoppm pnmremap tmpdir=${tmpdir:-/tmp} pcxstd_ppm=${tmpdir}/pcxstd_ppm @@ -29,17 +28,16 @@ P3 255 255 255 EOF -# Test 1. Should print 1926073387 101484 +echo "Test 1. Should print 1926073387 101484" ppmtopcx testimg.ppm | pcxtoppm | cksum -# Test 2. Should print 369063776 101484 three times +echo "Test 2. Should print 369063776 101484 three times" pnmremap testimg.ppm -mapfile=${pcxstd_ppm} | tee ${testpcx_ppm} | cksum ppmtopcx -stdpalette -packed ${testpcx_ppm} | pcxtoppm | cksum ppmtopcx -stdpalette -packed -8bit ${testpcx_ppm} | pcxtoppm | cksum rm ${testpcx_ppm} ${pcxstd_ppm} -# Test 3. Should print 829921912 685 which is the -# result of: -# pgmtoppm < testgrid.pbm | cksum -ppmtopcx -stdpalette -packed testgrid.pbm | pcxtoppm | cksum +echo "Test 3. Should print 669206373 10102 twice" +pgmtoppm < maze.pbm | cksum +ppmtopcx -stdpalette -packed maze.pbm | pcxtoppm | cksum diff --git a/test/pdb-roundtrip.ok b/test/pdb-roundtrip.ok index b903da8d..fbc897fe 100644 --- a/test/pdb-roundtrip.ok +++ b/test/pdb-roundtrip.ok @@ -1,18 +1,18 @@ -pbm grid +Test 1: pbm grid : Should print 2224198737 25671 three times 2224198737 25671 2224198737 25671 2224198737 25671 -pbm tiled +Test 2: pbmnoise : Should print 0 0 0 0 : 0 four times 0 0 0 0 : 0 0 0 0 0 : 0 0 0 0 0 : 0 0 0 0 0 : 0 -pgm ellipse +Test 3: pgm ellipse : Should print 0 0 0 0 0 : 0 four times 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 +Test 4: pgm ellipse -4depth : Should print 0 0 0 0 0 : 0 three times 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 32d7aa87..f56be1bf 100755 --- a/test/pdb-roundtrip.test +++ b/test/pdb-roundtrip.test @@ -1,37 +1,31 @@ #! /bin/bash # This script tests: pamtopdbimg pdbimgtopam -# Also requires: pnmtile pgmramp pamtopnm pamdepth +# Also requires: pbmnoise pgmramp pamtopnm pamdepth tmpdir=${tmpdir:-/tmp} -tiled_pbm=${tmpdir}/tiled.pbm +noise_pbm=${tmpdir}/noise.pbm ellipse_pgm=${tmpdir}/ellipse.pgm -# Test 1. Should produce 2224198737 25671 -# 3 times -echo pbm grid +echo "Test 1: pbm grid : Should print 2224198737 25671 three times" for flag in "-compressed" "-maybecompressed" "-uncompressed" do pamtopdbimg ${flag} testgrid.pbm | pdbimgtopam | cksum done -# Test 2. Should produce 0 0 0 -# 4 times -echo pbm tiled -pnmtile 160 160 testgrid.pbm > ${tiled_pbm} +echo "Test 2: pbmnoise : Should print 0 0 0 0 : 0 four times" +pbmnoise -randomseed=1 160 160 > ${noise_pbm} for flag in "" "-compressed" "-maybecompressed" "-uncompressed" do - pamtopdbimg ${flag} ${tiled_pbm} | pdbimgtopam | pamtopnm | \ - cmp -s - ${tiled_pbm} + pamtopdbimg ${flag} ${noise_pbm} | pdbimgtopam | pamtopnm | \ + cmp -s - ${noise_pbm} echo ${PIPESTATUS[@]} ":" $? done -rm ${tiled_pbm} +rm ${noise_pbm} -# Test 3. Should produce 0 0 0 -# 4 times -echo pgm ellipse +echo "Test 3: pgm ellipse : Should print 0 0 0 0 0 : 0 four times" pgmramp -ellipse 160 160 -maxval=3 > ${ellipse_pgm} for flag in "" "-compressed" "-maybecompressed" "-uncompressed" do @@ -42,9 +36,7 @@ for flag in "" "-compressed" "-maybecompressed" "-uncompressed" rm ${ellipse_pgm} -# Test 3. Should produce 0 0 0 -# 3 times -echo pgm ellipse -4depth +echo "Test 4: pgm ellipse -4depth : Should print 0 0 0 0 0 : 0 three times" pgmramp -ellipse 160 160 -maxval=15 > ${ellipse_pgm} for flag in "-compressed" "-maybecompressed" "-uncompressed" do @@ -52,4 +44,4 @@ for flag in "-compressed" "-maybecompressed" "-uncompressed" pamtopnm | pamdepth 15 | cmp -s - ${ellipse_pgm} echo ${PIPESTATUS[@]} ":" $? done -rm ${ellipse_pgm} \ No newline at end of file +rm ${ellipse_pgm} diff --git a/test/pfm-roundtrip.test b/test/pfm-roundtrip.test index f1b5d418..95bfc62f 100755 --- a/test/pfm-roundtrip.test +++ b/test/pfm-roundtrip.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamtopfm pfmtopam # Also requires: pamtopnm diff --git a/test/pgmbentley.test b/test/pgmbentley.test index 0429d54b..800aa1f7 100755 --- a/test/pgmbentley.test +++ b/test/pgmbentley.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pgmbentley # Also requires: pgmramp diff --git a/test/pgmhist.ok b/test/pgmhist.ok index 3be73ff9..f9184828 100644 --- a/test/pgmhist.ok +++ b/test/pgmhist.ok @@ -30,7 +30,7 @@ Test 2 230 255 Test Invalid -Expected failure 1 1 -Expected failure 2 1 -Expected failure 3 1 -Expected failure 4 1 +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) diff --git a/test/pgmhist.test b/test/pgmhist.test index ab3763fd..5c458a57 100755 --- a/test/pgmhist.test +++ b/test/pgmhist.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pgmhist # Also requires: pgmramp @@ -26,21 +26,9 @@ pgmramp -lr 256 1 | pgmhist -machine -decile | \ echo "Test Invalid" -tmpdir=${tmpdir:-/tmp} -test_out=${tmpdir}/test_out +. ${srcdir}/test-invalid.inc -echo 1>&2 -echo "Invalid command-line argument combinations." 1>&2 -echo "Error messages should appear below the line." 1>&2 -echo "-----------------------------------------------------------" 1>&2 - -pgmhist -median -quartile testgrid.pbm > ${test_out} || \ - echo -n "Expected failure 1"; test -s ${test_out}; echo " "$? -pgmhist -median -decile testgrid.pbm > ${test_out} || \ - echo -n "Expected failure 2"; test -s ${test_out}; echo " "$? -pgmhist -quartile -decile testgrid.pbm > ${test_out} || \ - echo -n "Expected failure 3"; test -s ${test_out}; echo " "$? -pgmhist testimg.ppm > ${test_out} || \ - echo -n "Expected failure 4"; test -s ${test_out}; echo " "$? - -rm ${test_out} +invCmd "pgmhist -median -quartile testgrid.pbm" +invCmd "pgmhist -median -decile testgrid.pbm" +invCmd "pgmhist -quartile -decile testgrid.pbm" +invCmd "pgmhist testimg.ppm" diff --git a/test/pgmmake.ok b/test/pgmmake.ok index 8b242822..9460162d 100644 --- a/test/pgmmake.ok +++ b/test/pgmmake.ok @@ -1,12 +1,25 @@ Test 1 +P2 +1 1 +255 +0 +P2 +1 1 +255 +255 +P2 +1 1 +2 +1 3662611538 2513 3109612402 5012 Test Invalid -Expected failure 1 1 -Expected failure 2 1 -Expected failure 3 1 -Expected failure 4 1 -Expected failure 5 1 -Expected failure 6 1 -Expected failure 7 1 -Expected failure 8 1 +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) +Expected failure 5 (no output) +Expected failure 6 (no output) +Expected failure 7 (no output) +Expected failure 8 (no output) +Expected failure 9 (no output) diff --git a/test/pgmmake.test b/test/pgmmake.test index 2fc63e72..d8e248d4 100755 --- a/test/pgmmake.test +++ b/test/pgmmake.test @@ -1,38 +1,25 @@ -#! /bin/bash +#! /bin/sh # This script tests: pgmmake # Also requires: echo "Test 1" +pgmmake -plain 0 1 1 +pgmmake -plain 1 1 1 +pgmmake -plain -maxval=2 0.5 1 1 pgmmake 1 50 50 | cksum pgmmake .2 50 100 -maxval=5 | cksum - echo "Test Invalid" -echo 1>&2 -echo "Invalid command-line argument combinations." 1>&2 -echo "Error messages should appear below the line." 1>&2 -echo "-----------------------------------------------------------" 1>&2 - -tmpdir=${tmpdir:-/tmp} -test_out=${tmpdir}/test_out - -pgmmake 100 5 5 > ${test_out} || \ - echo -n "Expected failure 1"; test -s ${test_out}; echo " "$? -pgmmake 1.01 5 5 > ${test_out} || \ - echo -n "Expected failure 2"; test -s ${test_out}; echo " "$? -pgmmake .5 5 > ${test_out} || \ - echo -n "Expected failure 3"; test -s ${test_out}; echo " "$? -pgmmake .5 > ${test_out} || \ - echo -n "Expected failure 4"; test -s ${test_out}; echo " "$? -pgmmake -maxval=5 5 5 > ${test_out} || \ - echo -n "Expected failure 5"; test -s ${test_out}; echo " "$? -pgmmake -maxval=0 .5 5 5 > ${test_out} || \ - echo -n "Expected failure 6"; test -s ${test_out}; echo " "$? -pgmmake -maxval=-1 .5 5 5 > ${test_out} || \ - echo -n "Expected failure 7"; test -s ${test_out}; echo " "$? -pgmmake -maxval=65536 .5 5 5 > ${test_out} || \ - echo -n "Expected failure 8"; test -s ${test_out}; echo " "$? - -rm ${test_out} +. ${srcdir}/test-invalid.inc + +invCmd "pgmmake" +invCmd "pgmmake 100 5 5" +invCmd "pgmmake 1.01 5 5" +invCmd "pgmmake .5 5" +invCmd "pgmmake .5" +invCmd "pgmmake -maxval=5 5 5" +invCmd "pgmmake -maxval=0 .5 5 5" +invCmd "pgmmake -maxval=-1 .5 5 5" +invCmd "pgmmake -maxval=65536 .5 5 5" diff --git a/test/pgmminkowski.test b/test/pgmminkowski.test index 52e02e19..e81de3e1 100755 --- a/test/pgmminkowski.test +++ b/test/pgmminkowski.test @@ -1,8 +1,8 @@ -#! /bin/bash +#! /bin/sh # This script tests: pgmminkowski -# Also requires: pbmmake pgmmake pnmmargin pnmpad +# Also requires: pbmmake pgmmake pnmpad -pgmmake .5 1 1 | pnmmargin -b 1 | \ +pgmmake .5 1 1 | pnmpad -black -top=1 -left=1 -bottom=1 -right=1 | \ pgmminkowski echo pbmmake -g 3 3 | pgmminkowski diff --git a/test/pgmnoise-parameters.ok b/test/pgmnoise-parameters.ok index 1bb1cd59..1e321f00 100644 --- a/test/pgmnoise-parameters.ok +++ b/test/pgmnoise-parameters.ok @@ -1,5 +1,7 @@ -Expected failure 1 1 -Expected failure 2 1 -Expected failure 3 1 -Expected failure 4 1 -Expected failure 5 1 +Test Invalid +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) +Expected failure 5 (no output) +Expected failure 6 (no output) diff --git a/test/pgmnoise-parameters.test b/test/pgmnoise-parameters.test index 1682afca..871aacf9 100755 --- a/test/pgmnoise-parameters.test +++ b/test/pgmnoise-parameters.test @@ -1,26 +1,14 @@ -#! /bin/bash +#! /bin/sh # This script tests: pgmnoise # Also requires: -tmpdir=${tmpdir:-/tmp} -test_out=${tmpdir}/test_out +echo "Test Invalid" -echo 1>&2 -echo "Invalid command-line argument combinations." 1>&2 -echo "Error messages should appear below the line." 1>&2 -echo "-----------------------------------------------------------" 1>&2 +. ${srcdir}/test-invalid.inc -pgmnoise -maxval=255 -randomseed=1 > ${test_out} || \ - echo -n "Expected failure 1"; test -s ${test_out}; echo " "$? - -pgmnoise 100 -randomseed=1 > ${test_out} || \ - echo -n "Expected failure 2"; test -s ${test_out}; echo " "$? - -pgmnoise 100 0 -randomseed=1 > ${test_out} || \ - echo -n "Expected failure 3"; test -s ${test_out}; echo " "$? - -pgmnoise 0 100 -randomseed=1 > ${test_out} || \ - echo -n "Expected failure 4"; test -s ${test_out}; echo " "$? - -pgmnoise 100 100 100 -randomseed=1 > ${test_out} || \ - echo -n "Expected failure 5"; test -s ${test_out}; echo " "$? +invCmd "pgmnoise" +invCmd "pgmnoise -maxval=255 -randomseed=1" +invCmd "pgmnoise 100 -randomseed=1" +invCmd "pgmnoise 100 0 -randomseed=1" +invCmd "pgmnoise 0 100 -randomseed=1" +invCmd "pgmnoise 100 100 100 -randomseed=1" diff --git a/test/pgmnoise.ok b/test/pgmnoise.ok new file mode 100644 index 00000000..2a2db565 --- /dev/null +++ b/test/pgmnoise.ok @@ -0,0 +1,102 @@ +Test 1. +Should print: 2132901423 10015 +2132901423 10015 +Test 2. +P2 +5 20 +9999 +1612 9302 6734 4585 4204 +5391 9429 3985 2298 7403 +2835 4565 740 4426 8239 +2720 519 8804 4697 8106 +3009 4609 4243 4039 746 +2626 2536 8553 8460 1771 +7212 4909 929 1418 4126 +2695 4553 893 8587 4728 +4844 7306 495 5920 2597 +8076 445 6934 5307 8902 +9058 5693 9660 3006 2222 +2786 6116 5227 1234 7006 +4839 1161 1026 3808 5152 +3250 4612 9652 7801 1673 +4425 7642 6209 5879 1891 +1326 2609 3880 4788 4008 +2678 1923 1099 1100 9586 +2873 7582 3983 1720 6969 +2059 8444 8154 2595 3247 +6536 8742 7111 4600 9344 +Test 3. +1 +P2 16 1 1 1 0 1 0 0 1 0 0 0 0 1 0 1 1 1 1 2 +P2 16 1 2 1 2 0 2 1 1 2 2 2 0 2 0 1 2 1 0 3 +P2 16 1 3 1 1 2 0 0 1 3 3 1 0 0 3 2 2 2 1 4 +P2 16 1 4 0 4 4 3 3 3 1 1 4 2 3 4 1 3 3 0 5 +P2 16 1 5 1 5 0 2 1 1 5 5 5 0 2 3 4 5 1 0 6 +P2 16 1 6 0 3 4 3 3 6 0 5 0 3 4 6 5 5 2 5 7 +P2 16 1 7 5 4 0 2 7 3 0 6 2 5 5 5 6 1 0 4 8 +P2 16 1 8 4 5 0 5 7 1 2 5 8 0 2 3 1 8 4 0 9 +P2 16 1 9 5 9 4 8 3 3 1 1 9 2 8 9 6 3 3 0 10 +P2 16 1 10 0 3 5 0 3 1 5 1 0 0 9 1 4 5 5 6 11 +P2 16 1 11 1 11 0 8 7 1 11 5 11 0 8 9 4 11 1 0 12 +P2 16 1 12 6 9 3 1 6 1 7 2 12 9 1 0 9 11 12 1 13 +P2 16 1 13 7 3 4 10 3 13 7 5 7 10 4 13 12 5 9 12 14 +P2 16 1 14 10 14 9 8 13 13 11 11 14 12 8 9 1 8 13 0 15 +P2 16 1 15 5 2 4 15 1 12 10 6 11 14 0 8 7 4 15 15 16 +P2 16 1 16 2 9 15 8 14 7 7 16 5 5 16 2 4 6 1 14 255 +P2 16 1 255 37 244 193 106 235 128 71 255 140 47 103 184 72 20 188 238 65535 +P2 16 1 65535 62501 27329 33003 65351 12172 47207 5192 61116 32511 7 50057 8396 43723 19813 7813 65473 +Test 4. +1 stdin: PGM raw, 1 by 10 maxval 1 +2 stdin: PGM raw, 2 by 10 maxval 2 +3 stdin: PGM raw, 3 by 10 maxval 3 +4 stdin: PGM raw, 4 by 10 maxval 4 +5 stdin: PGM raw, 5 by 10 maxval 5 +6 stdin: PGM raw, 6 by 10 maxval 6 +7 stdin: PGM raw, 7 by 10 maxval 7 +8 stdin: PGM raw, 8 by 10 maxval 8 +9 stdin: PGM raw, 9 by 10 maxval 9 +10 stdin: PGM raw, 10 by 10 maxval 10 +11 stdin: PGM raw, 11 by 10 maxval 11 +12 stdin: PGM raw, 12 by 10 maxval 12 +13 stdin: PGM raw, 13 by 10 maxval 13 +14 stdin: PGM raw, 14 by 10 maxval 14 +15 stdin: PGM raw, 15 by 10 maxval 15 +16 stdin: PGM raw, 16 by 10 maxval 16 +30 stdin: PGM raw, 30 by 10 maxval 30 +31 stdin: PGM raw, 31 by 10 maxval 31 +32 stdin: PGM raw, 32 by 10 maxval 32 +254 stdin: PGM raw, 254 by 10 maxval 254 +255 stdin: PGM raw, 255 by 10 maxval 255 +256 stdin: PGM raw, 256 by 10 maxval 256 +65534 stdin: PGM raw, 65534 by 10 maxval 65534 +65535 stdin: PGM raw, 65535 by 10 maxval 65535 +Test 5. +Should print four identical lines +969759084 1682 +969759084 1682 +969759084 1682 +969759084 1682 +Test 6. +First column should be 2^n - 1. Last column should be 'pool'. +1 pgmnoise: method: pool +3 pgmnoise: method: pool +7 pgmnoise: method: pool +15 pgmnoise: method: pool +31 pgmnoise: method: pool +63 pgmnoise: method: pool +127 pgmnoise: method: pool +255 pgmnoise: method: pool +511 pgmnoise: method: pool +1023 pgmnoise: method: pool +65535 pgmnoise: method: pool +Test Invalid +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) +Expected failure 5 (no output) +Expected failure 6 (no output) +Expected failure 7 (no output) +Expected failure 8 (no output) +Expected failure 9 (no output) +Expected failure 10 (no output) diff --git a/test/pgmnoise.rand-ok b/test/pgmnoise.rand-ok deleted file mode 100644 index b69f48e5..00000000 --- a/test/pgmnoise.rand-ok +++ /dev/null @@ -1,3 +0,0 @@ -000|0 -081|2005134911 10015 -082|3516404574 10015 diff --git a/test/pgmnoise.test b/test/pgmnoise.test index 03301ce6..36f16ab0 100755 --- a/test/pgmnoise.test +++ b/test/pgmnoise.test @@ -1,7 +1,126 @@ -#! /bin/bash +#! /bin/sh # This script tests: pgmnoise -# Also requires: +# Also requires: pgmhist pamvalidate pamfile -# Should print: 1663614689 10015 (Glibc) -# 3516404574 10015 (MAC OS) +echo "Test 1." +echo "Should print: 2132901423 10015" # (Mersenne Twister) pgmnoise --randomseed=0 100 100 | cksum + + +echo "Test 2." +# Output is similar to that of Test 2. of random-generator.test +# The lowest four decimal digits are printed. + +pgmnoise --randomseed=5489 -maxval=9999 -plain 5 20 + + +echo "Test 3." +for maxval in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 255 65535 + do + echo ${maxval} + pgmnoise -maxval=${maxval} -randomseed=1 -plain 16 1 | tr '\n' ' ' + done +echo + +echo "Test 4." +# Check for maxval violation +for maxval in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 \ + 30 31 32 254 255 256 65534 65535 + do + printf "%d " ${maxval} + pgmnoise -maxval=${maxval} -randomseed=1 -plain ${maxval} 10 | \ + pamvalidate | pamfile + done + +echo "Test 5." +echo "Should print four identical lines" +# width height values do not affect random number sequence +for xysize in "1 10000" "100 100" "250 40" "1000 10" + do pgmnoise --randomseed=0 ${xysize} | pgmhist -mach | cksum + done + + +tmpdir=${tmpdir:-/tmp} +outfile=${tmpdir}/out + +echo "Test 6." +echo "First column should be 2^n - 1. Last column should be 'pool'." +# The "pool" method of generating pixvals is used iff maxval is +# a power of 2 minus 1: 1, 3, 7, 15, 31 ... + + +for maxval in \ + 1 2 3 4 5 6 7 8 9 \ + 10 11 12 13 14 15 16 17 18 19 \ + 20 21 22 23 24 25 26 27 28 29 \ + 30 31 32 33 60 61 62 63 64 65 \ + 127 255 511 1023 65535 \ + 129 142 186 219 677 1068 1788 1820 2067 2154 2301 2317 \ + 5180 5321 5596 6304 7565 9525 \ + 10501 14178 25797 27451 28653 + do + pgmnoise -maxval=${maxval} -plain -randomseed=1 -verbose 1 1 \ + > /dev/null 2> ${outfile} + awk -v mval=${maxval} '/method/ && /pool/ { print mval, $0 }' ${outfile} + rm ${outfile} + done + + +echo "Test Invalid" + +test_out=${tmpdir}/test_out + +echo 1>&2 +echo "Invalid command-line arguments." 1>&2 +echo "Error messages should appear below the line." 1>&2 +echo "-----------------------------------------------------------" 1>&2 + +pgmnoise 0 0 > ${test_out} || \ + printf "Expected failure 1 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pgmnoise 0 1 > ${test_out} || \ + printf "Expected failure 2 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pgmnoise 1 0 > ${test_out} || \ + printf "Expected failure 3 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pgmnoise > ${test_out} || \ + printf "Expected failure 4 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pgmnoise 1 > ${test_out} || \ + printf "Expected failure 5 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pgmnoise 100 -1 > ${test_out} || \ + printf "Expected failure 6 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pgmnoise -randomseed=-1 100 100 > ${test_out} || \ + printf "Expected failure 7 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pgmnoise -maxval=-1 100 100 > ${test_out} || \ + printf "Expected failure 8 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pgmnoise -maxval=0 100 100 > ${test_out} || \ + printf "Expected failure 9 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pgmnoise -maxval=$((256 * 256 * 256 * 256)) 10 10 > ${test_out} || \ + printf "Expected failure 10 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} diff --git a/test/pgmramp.ok b/test/pgmramp.ok index de0d9206..71f92b13 100644 --- a/test/pgmramp.ok +++ b/test/pgmramp.ok @@ -42,8 +42,10 @@ Test 2 Test 3 886972785 131087 Test Invalid -Expected failure: -lr -tb 1 -Expected failure: -lr -rectangle 1 -Expected failure: -rectangle -ellipse 1 -Expected failure: insufficient parameters 1 -Expected failure: excessive parameters 1 +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) +Expected failure 5 (no output) +Expected failure 6 (no output) +Expected failure 7 (no output) diff --git a/test/pgmramp.test b/test/pgmramp.test index 3ec73749..84fe02ca 100755 --- a/test/pgmramp.test +++ b/test/pgmramp.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pgmramp # Also requires: @@ -21,24 +21,16 @@ pgmramp -diagonal -maxval=510 256 256 | cksum echo "Test Invalid" -echo 1>&2 -echo "Invalid command-line argument combinations." 1>&2 -echo "Error messages should appear below the line." 1>&2 -echo "-----------------------------------------------------------" 1>&2 +. ${srcdir}/test-invalid.inc -tmpdir=${tmpdir:-/tmp} -test_out=${tmpdir}/test_out for combination in "-lr -tb" "-lr -rectangle" "-rectangle -ellipse" -do pgmramp $combination 10 10 > ${test_out} || \ - echo -n "Expected failure: $combination" ; test -s ${test_out}; echo " "$? -done + do + invCmd "pgmramp ${combination} 10 10" + done -pgmramp -lr 1 > ${test_out} || \ - echo -n "Expected failure: insufficient parameters"; \ - test -s ${test_out}; echo " "$? -pgmramp -tb 1 1 1 > ${test_out} || \ - echo -n "Expected failure: excessive parameters"; \ - test -s ${test_out}; echo " "$? +invCmd "pgmramp -lr 10 0" +invCmd "pgmramp -lr 0 10" +invCmd "pgmramp -lr 1" +invCmd "pgmramp -tb 1 1 1" -rm ${test_out} diff --git a/test/pgmtopgm.ok b/test/pgmtopgm.ok index 53c25a44..38cfd268 100644 --- a/test/pgmtopgm.ok +++ b/test/pgmtopgm.ok @@ -1 +1,11 @@ -729348909 237 +Test 1. Should print two identical PGM images +P2 +10 1 +255 +0 0 0 0 0 0 0 0 0 0 +P2 +10 1 +255 +0 0 0 0 0 0 0 0 0 0 +Test 2. Should print 2582999797 3376 +2582999797 3376 diff --git a/test/pgmtopgm.test b/test/pgmtopgm.test index e919fdac..d81260d8 100755 --- a/test/pgmtopgm.test +++ b/test/pgmtopgm.test @@ -1,6 +1,12 @@ -#! /bin/bash +#! /bin/sh # This script tests: pgmtopgm -# Also requires: +# Also requires: pgmmake +echo "Test 1. Should print two identical PGM images" -pgmtopgm < testgrid.pbm | cksum +pgmmake -plain 0 10 1 +pgmmake 0 10 1 | pgmtopgm -plain + +echo "Test 2. Should print 2582999797 3376" + +pgmtopgm < maze.pbm | cksum diff --git a/test/pgmtoppm.ok b/test/pgmtoppm.ok index 55e5af95..4a2114ab 100644 --- a/test/pgmtoppm.ok +++ b/test/pgmtoppm.ok @@ -1,3 +1,39 @@ +Test 1. Should print 1767073524 779 twice, then 1676700883 779 +1767073524 779 1767073524 779 1676700883 779 +Test 2. Should print 718580145 779 twice +718580145 779 +718580145 779 +Test 3. Should print 718580145 779 twice +718580145 779 718580145 779 +Test 4. Should print 829921912 685 seven times +829921912 685 +829921912 685 +829921912 685 +829921912 685 +829921912 685 +829921912 685 +829921912 685 +Test 5. Should print 934505096 685 four times +934505096 685 +934505096 685 +934505096 685 +934505096 685 +Test 6. Should print 3083028153 685 three times +3083028153 685 +3083028153 685 +3083028153 685 +Test 7 Invalid +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) +Expected failure 5 (no output) +Expected failure 6 (no output) +Expected failure 7 (no output) +Expected failure 8 (no output) +Expected failure 9 (no output) +Expected failure 10 (no output) +Expected failure 11 (no output) diff --git a/test/pgmtoppm.test b/test/pgmtoppm.test index 70df0d97..6054fc03 100755 --- a/test/pgmtoppm.test +++ b/test/pgmtoppm.test @@ -1,22 +1,139 @@ -#! /bin/bash +#! /bin/sh # This script tests: pgmtoppm -# Also requires: pamseq pamtopnm pgmramp - +# Also requires: pamtopnm pnminvert pamseq pgmramp tmpdir=${tmpdir:-/tmp} +echo "Test 1. Should print 1767073524 779 twice, then 1676700883 779" + test_pgm=${tmpdir}/test.pgm -palette=${tmpdir}/palette +palette_pam=${tmpdir}/palette.pam +palette_ppm=${tmpdir}/palette.ppm -pgmramp -maxval=5 -lr 256 1 >${test_pgm} -pamseq 3 5 -tupletype=RGB | pamtopnm \ - >${palette} +pgmramp -maxval=5 -lr 256 1 > ${test_pgm} -# Test 1. pgmtoppm green ${test_pgm} | cksum - +pgmtoppm black-green ${test_pgm} | cksum pgmtoppm yellow-blue ${test_pgm} | cksum -pgmtoppm -map=${palette} ${test_pgm} | cksum -rm ${test_pgm} ${palette} +echo "Test 2. Should print 718580145 779 twice" +pamseq 3 5 -tupletype=RGB | tee ${palette_pam} | pamtopnm > ${palette_ppm} +pgmtoppm -map=${palette_pam} ${test_pgm} | cksum +pgmtoppm -map=${palette_ppm} ${test_pgm} | cksum + +rm ${palette_pam} + +echo "Test 3. Should print 718580145 779 twice" + +pgmtoppm white-black ${test_pgm} | pnminvert | cksum +pnminvert ${test_pgm} | pgmtoppm white-black | cksum + +rm ${test_pgm} + +echo "Test 4. Should print 829921912 685 seven times" + +pgmtoppm white testgrid.pbm | cksum +pgmtoppm black-white testgrid.pbm | cksum +pgmtoppm rgb:ff/ff/ff testgrid.pbm | cksum +pgmtoppm -white=rgb-255:255/255/255 testgrid.pbm | cksum +pgmtoppm rgb:00/00/00-rgb:ff/ff/ff testgrid.pbm | cksum +pgmtoppm rgbi:0/0/0-rgbi:1/1/1 testgrid.pbm | cksum +pgmtoppm -black=rgb-255:0/0/0 -white=rgb-255:255/255/255 testgrid.pbm | cksum + +echo "Test 5. Should print 934505096 685 four times" + +pgmtoppm white-black testgrid.pbm | cksum +pgmtoppm white testgrid.pbm | pnminvert| cksum +pnminvert testgrid.pbm | pgmtoppm black-white | cksum +pnminvert testgrid.pbm | pgmtoppm white | cksum + +echo "Test 6. Should print 3083028153 685 three times" + +pgmtoppm black testgrid.pbm | cksum +pgmtoppm black-black testgrid.pbm | cksum +pgmtoppm rgbi:0/0/0-rgbi:0/0/0 testgrid.pbm | cksum + +echo "Test 7 Invalid" + +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 + +pgmtoppm white testimg.ppm > \ + ${test_out} || \ + printf "Expected failure 1 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pgmtoppm -map=/dev/null testgrid.pbm > \ + ${test_out} || \ + printf "Expected failure 2 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pgmtoppm black white testgrid.pbm > \ + ${test_out} || \ + printf "Expected failure 3 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pgmtoppm hwite testgrid.pbm > \ + ${test_out} || \ + printf "Expected failure 4 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pgmtoppm off-color testgrid.pbm > \ + ${test_out} || \ + printf "Expected failure 5 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pgmtoppm rgb-255:7/7/7 testgrid.pbm > \ + ${test_out} || \ + printf "Expected failure 6 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pgmtoppm -black=black -white=white white testgrid.pbm > \ + ${test_out} || \ + printf "Expected failure 7 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pgmtoppm -black=rgb:0/0/0 -map=${palette_ppm} testgrid.pbm > \ + ${test_out} || \ + printf "Expected failure 8 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pgmtoppm -white=rgb:ff/ff/ff -map=${palette_ppm} testgrid.pbm > \ + ${test_out} || \ + printf "Expected failure 9 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pgmtoppm rgb:ff/ff/ff -map=${palette_ppm} testgrid.pbm > \ + ${test_out} || \ + printf "Expected failure 10 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pgmtoppm rgb:00/00/00-rgb:ff/ff/ff -map=${palette_ppm} testgrid.pbm > \ + ${test_out} || \ + printf "Expected failure 11 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +#pgmtoppm rgb-255:7/7/7 testgrid.pbm > \ +# ${test_out} || \ +# printf "Expected failure 12 " +# test -s ${test_out} && echo "unexpected output" || echo "(no output)" +# rm -f ${test_out} + +rm -f ${palette_ppm} diff --git a/test/pi3-roundtrip.ok b/test/pi3-roundtrip.ok index 3fde31b1..c4351b83 100644 --- a/test/pi3-roundtrip.ok +++ b/test/pi3-roundtrip.ok @@ -1,2 +1,5 @@ +Test 1. Should print: 3139449799 32011 twice 3139449799 32011 -2425386270 41 +3139449799 32011 +Test 2. Should print: 281226646 481, cksum of maze.pbm +281226646 481 diff --git a/test/pi3-roundtrip.test b/test/pi3-roundtrip.test index 5700337d..d795157d 100755 --- a/test/pi3-roundtrip.test +++ b/test/pi3-roundtrip.test @@ -1,16 +1,15 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmtopi3 pi3topbm -# Also requires: pbmmake pamcut - +# Also requires: pbmmake pamcut pamfile # The pi3 image format specifies a fixed image size of 640x400. # Pbmtopi3 rejects images that do not conform. -# Test -# Should print: 3139449799 32011 +echo "Test 1. Should print: 3139449799 32011 twice" +pbmmake -g 640 400 | cksum pbmmake -g 640 400 | pbmtopi3 | pi3topbm | cksum -# Test 2. -# Should print: 2425386270 41 -pamcut -pad 0 0 640 400 testgrid.pbm | \ - pbmtopi3 | pi3topbm | pamcut 0 0 14 16 | cksum +echo "Test 2. Should print: 281226646 481, cksum of maze.pbm" +size=$(pamfile -size maze.pbm | awk '{print "-width="$1,"-height="$2}') +pamcut -pad -left=0 -top=0 -width=640 -height=400 maze.pbm | \ + pbmtopi3 | pi3topbm | pamcut -left=0 -top=0 ${size} | cksum diff --git a/test/pict-roundtrip.test b/test/pict-roundtrip.test index cd207d48..b4910064 100755 --- a/test/pict-roundtrip.test +++ b/test/pict-roundtrip.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: picttoppm ppmtopict # Also requires: pamseq pamdepth pamtopnm pnmremap diff --git a/test/pj-roundtrip.test b/test/pj-roundtrip.test index 2b0d61e5..3ed30927 100755 --- a/test/pj-roundtrip.test +++ b/test/pj-roundtrip.test @@ -19,8 +19,8 @@ echo "Test 2. Should print: 0 0 : 0" testout_ppm=${tmpdir}/testout.ppm -ppmtopj testgrid.pbm | pjtoppm > ${testout_ppm} - ppmtoppm < testgrid.pbm | cmp -s - ${testout_ppm} > /dev/null +ppmtopj maze.pbm | pjtoppm > ${testout_ppm} + ppmtoppm < maze.pbm | cmp -s - ${testout_ppm} > /dev/null echo ${PIPESTATUS[@]} ":" $? rm ${testout_ppm} diff --git a/test/png-roundtrip.ok b/test/png-roundtrip.ok index 28b8c057..ec0a1937 100644 --- a/test/png-roundtrip.ok +++ b/test/png-roundtrip.ok @@ -16,21 +16,21 @@ 1926073387 101484 1926073387 101484 1926073387 101484 -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 -2425386270 41 -2425386270 41 +281226646 481 +281226646 481 +281226646 481 +281226646 481 +281226646 481 +281226646 481 +281226646 481 +281226646 481 +281226646 481 +281226646 481 +281226646 481 +281226646 481 +281226646 481 +281226646 481 +281226646 481 +281226646 481 +281226646 481 +281226646 481 diff --git a/test/png-roundtrip.test b/test/png-roundtrip.test index 7e7c4a9b..97cf9b2c 100755 --- a/test/png-roundtrip.test +++ b/test/png-roundtrip.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pngtopam pnmtopng # Also requires: @@ -28,7 +28,7 @@ for flags in "" -interlace \ pnmtopng testimg.ppm $flags | pngtopam | cksum done -# Test 2. Should print 2425386270 41 18 times +# Test 2. Should print 281226646 481 18 times for flags in "" -interlace \ -gamma=.45 \ -hist \ @@ -47,5 +47,5 @@ for flags in "" -interlace \ -comp_strategy=filtered \ -force do - pnmtopng testgrid.pbm $flags | pngtopam | cksum + pnmtopng maze.pbm $flags | pngtopam | cksum done diff --git a/test/png-roundtrip2.ok b/test/png-roundtrip2.ok index 0e712ce7..764cadfa 100644 --- a/test/png-roundtrip2.ok +++ b/test/png-roundtrip2.ok @@ -1,4 +1,4 @@ 1926073387 101484 1926073387 101484 -2425386270 41 -2425386270 41 +281226646 481 +281226646 481 diff --git a/test/png-roundtrip2.test b/test/png-roundtrip2.test index af2ad029..85149a91 100755 --- a/test/png-roundtrip2.test +++ b/test/png-roundtrip2.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pngtopam pamtopng # Also requires: @@ -15,8 +15,8 @@ for flags in "" -gamma=.45 pamtopng testimg.ppm $flags | pngtopam | cksum done -# Test 2. Should print 2425386270 41 twice +# Test 2. Should print 281226646 481 twice for flags in "" -gamma=.45 do - pamtopng testgrid.pbm $flags | pngtopam | cksum + pamtopng maze.pbm $flags | pngtopam | cksum done diff --git a/test/pnm-pam-roundtrip.ok b/test/pnm-pam-roundtrip.ok index 67f7a1fe..ace97410 100644 --- a/test/pnm-pam-roundtrip.ok +++ b/test/pnm-pam-roundtrip.ok @@ -1,2 +1,2 @@ 1926073387 101484 -2425386270 41 +281226646 481 diff --git a/test/pnm-pam-roundtrip.test b/test/pnm-pam-roundtrip.test index b8e60c88..da3021f9 100755 --- a/test/pnm-pam-roundtrip.test +++ b/test/pnm-pam-roundtrip.test @@ -1,7 +1,7 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamtopam pamtopnm # Also requires: pamtopam < testimg.ppm | pamtopnm | cksum -pamtopam < testgrid.pbm | pamtopnm | cksum +pamtopam < maze.pbm | pamtopnm | cksum diff --git a/test/pnm-plain-roundtrip.ok b/test/pnm-plain-roundtrip.ok index 67f7a1fe..ace97410 100644 --- a/test/pnm-plain-roundtrip.ok +++ b/test/pnm-plain-roundtrip.ok @@ -1,2 +1,2 @@ 1926073387 101484 -2425386270 41 +281226646 481 diff --git a/test/pnm-plain-roundtrip.test b/test/pnm-plain-roundtrip.test index 3779d761..14b8ca57 100755 --- a/test/pnm-plain-roundtrip.test +++ b/test/pnm-plain-roundtrip.test @@ -1,9 +1,9 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamtopnm # pamtopnm -plain testimg.ppm | \ pamtopnm | cksum -pamtopnm -plain testgrid.pbm | \ +pamtopnm -plain maze.pbm | \ pamtopnm | cksum diff --git a/test/pnmcat.ok b/test/pnmcat.ok index b92a1420..9958ad62 100644 --- a/test/pnmcat.ok +++ b/test/pnmcat.ok @@ -1,20 +1,98 @@ -Test 1. -1704087873 73 -4150323653 73 -1522490272 202953 -2862441566 202953 +Test 1. Should print a simple PBM image five times +P1 +2 2 +01 +10 +P1 +2 2 +01 +10 +P1 +2 2 +01 +10 +P1 +2 2 +01 +10 +P1 +2 2 +01 +10 +Test 2. Should print 2197356643 895 twice +2197356643 895 +2197356643 895 +Test 3. Should print 3313353797 954 +3313353797 954 +Test 4. Should print 1731660895 1308 three times +1731660895 1308 +1731660895 1308 +1731660895 1308 +Test 5. Should print 2985957591 1426 three times +2985957591 1426 +2985957591 1426 +2985957591 1426 +Test 6. Should print a simple PGM image three times +P2 +4 4 +3 +0 0 1 1 +0 1 1 2 +1 1 2 2 +1 2 2 3 +P2 +4 4 +3 +0 0 1 1 +0 1 1 2 +1 1 2 2 +1 2 2 3 +P2 +4 4 +3 +0 0 1 1 +0 1 1 2 +1 1 2 2 +1 2 2 3 +Test 7. Should print 2097565808 394 twice +2097565808 394 +2097565808 394 +Test 8. Should print 3086569577 394 +3086569577 394 +Test 9. Should print 4288335051 586 three times +4288335051 586 +4288335051 586 +4288335051 586 +Test 10. Should print 642720605 586 three times +642720605 586 +642720605 586 +642720605 586 +Test 11. Should print 3622741282 1019 twice +3622741282 1019 +3622741282 1019 +Test 12. Should print 1401081637 1019 +1401081637 1019 +Test 13. Should print 2756501917 1019 +2756501917 1019 +Test 14. Should print 587933655 107742 twice +587933655 107742 +587933655 107742 +Test 15. Should print 3948141157 107742 +3948141157 107742 +Test 16. Should print 3910239002 107742 +3910239002 107742 Test Invalid -Expected failure 1 1 -Expected failure 2 1 -Expected failure 3 1 -Expected failure 4 1 -Expected failure 5 1 -Expected failure 6 1 -Expected failure 7 1 -Expected failure 8 1 -Expected failure 9 1 -Expected failure 10 1 -Expected failure 11 1 -Expected failure 12 1 -Expected failure 13 1 -Expected failure 14 1 +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) +Expected failure 5 (no output) +Expected failure 6 (no output) +Expected failure 7 (no output) +Expected failure 8 (no output) +Expected failure 9 (no output) +Expected failure 10 (no output) +Expected failure 11 (no output) +Expected failure 12 (no output) +Expected failure 13 (no output) +Expected failure 14 (no output) diff --git a/test/pnmcat.test b/test/pnmcat.test index 40c29f50..8779638b 100755 --- a/test/pnmcat.test +++ b/test/pnmcat.test @@ -1,71 +1,132 @@ -#! /bin/bash +#! /bin/sh # This script tests: pnmcat -# Also requires: +# Also requires: pbmmake pgmramp ppmtoppm pamcat -echo "Test 1." +if [ ${CHECK_TYPE} = tree ] + then echo "Skipping." 1>&2 + echo "Running \"make package; make check\" is recommended." 1>&2 + exit 80; +fi -pnmcat -lr testgrid.pbm testgrid.pbm | cksum -pnmcat -tb testgrid.pbm testgrid.pbm | cksum - -pnmcat -lr testimg.ppm testimg.ppm | cksum -pnmcat -tb testimg.ppm testimg.ppm | cksum +tmpdir=${tmpdir:-/tmp} +check2x2_pbm=${tmpdir}/check2x2.pbm +maze2lr_pbm=${tmpdir}/maze2lr.pbm +maze2tb_pbm=${tmpdir}/maze2tb.pbm +diag_pgm=${tmpdir}/diag.pgm +diag_ppm=${tmpdir}/diag.ppm +diag2lr_ppm=${tmpdir}/diag2lr.ppm +diag2tb_ppm=${tmpdir}/diag2tb.ppm + +echo "Test 1. Should print a simple PBM image five times" +# Check input from stdin and from designated input file +# Similar to tests in stdin-p?m.test + +pbmmake -g 2 2 | tee ${check2x2_pbm} | pnmcat -lr -plain +pnmcat -tb -plain ${check2x2_pbm} +pnmcat -tb -plain < ${check2x2_pbm} +pnmcat -lr -black -plain ${check2x2_pbm} +cat ${check2x2_pbm} | pnmcat -tb -white -plain + +rm ${check2x2_pbm} + +echo "Test 2. Should print 2197356643 895 twice" +pnmcat -lr -white maze.pbm maze.pbm | tee ${maze2lr_pbm} | cksum +cat maze.pbm | pnmcat -lr -black maze.pbm - | cksum + +echo "Test 3. Should print 3313353797 954" +pnmcat -tb maze.pbm maze.pbm | tee ${maze2tb_pbm} | cksum + +echo "Test 4. Should print 1731660895 1308 three times" +pnmcat -lr maze.pbm maze.pbm maze.pbm | cksum +pnmcat -lr ${maze2lr_pbm} maze.pbm | cksum +cat ${maze2lr_pbm} | pnmcat -lr - maze.pbm | cksum + +echo "Test 5. Should print 2985957591 1426 three times" +pnmcat -tb maze.pbm maze.pbm maze.pbm | cksum +pnmcat -tb maze.pbm ${maze2tb_pbm} | cksum +cat maze.pbm | pnmcat -tb - ${maze2tb_pbm} | cksum + +rm ${maze2lr_pbm} ${maze2tb_pbm} + +echo "Test 6. Should print a simple PGM image three times" +# Use sed to scrape off space at line end for compatibility +# with older versions of pnmcat + +pgmramp -diag 4 4 -maxval=3 | tee ${diag_pgm} | pnmcat -lr -plain |\ + sed 's/ *$//' +pnmcat -tb -plain ${diag_pgm} | sed 's/ *$//' +cat ${diag_pgm} | pnmcat -tb -plain | sed 's/ *$//' + +rm ${diag_pgm} + +pgmramp -diag 8 8 -maxval 7 | ppmtoppm > ${diag_ppm} + +echo "Test 7. Should print 2097565808 394 twice" +pnmcat -lr -black ${diag_ppm} ${diag_ppm} | tee ${diag2lr_ppm} | cksum +cat ${diag_ppm} | pnmcat -lr -white ${diag_ppm} - | cksum + +echo "Test 8. Should print 3086569577 394" +pnmcat -tb ${diag_ppm} ${diag_ppm} | tee ${diag2tb_ppm} | cksum + +echo "Test 9. Should print 4288335051 586 three times" +pnmcat -lr ${diag_ppm} ${diag_ppm} ${diag_ppm} | cksum +pnmcat -lr ${diag_ppm} ${diag2lr_ppm} | cksum +cat ${diag2lr_ppm} | pnmcat -lr - ${diag_ppm} | cksum + +echo "Test 10. Should print 642720605 586 three times" +pnmcat -tb ${diag_ppm} ${diag_ppm} ${diag_ppm} | cksum +pnmcat -tb ${diag2tb_ppm} ${diag_ppm} | cksum +cat ${diag_ppm} | pnmcat -tb ${diag2tb_ppm} - | cksum + +rm ${diag2lr_ppm} ${diag2tb_ppm} + +echo "Test 11. Should print 3622741282 1019 twice" +pnmcat -tb -white testgrid.pbm ${diag_ppm} | cksum +pnmcat -tb -jcenter -white testgrid.pbm ${diag_ppm} | cksum +echo "Test 12. Should print 1401081637 1019" +pnmcat -tb -jleft -white testgrid.pbm ${diag_ppm} | cksum +echo "Test 13. Should print 2756501917 1019" +pnmcat -tb -jright -white testgrid.pbm ${diag_ppm} | cksum + +echo "Test 14. Should print 587933655 107742 twice" +pnmcat -lr -black testgrid.pbm testimg.ppm | cksum +pnmcat -lr -jcenter -black testgrid.pbm testimg.ppm | cksum +echo "Test 15. Should print 3948141157 107742" +pnmcat -lr -jtop -black testgrid.pbm testimg.ppm | cksum +echo "Test 16. Should print 3910239002 107742" +pnmcat -lr -jbottom -black testgrid.pbm testimg.ppm | cksum + +rm ${diag_ppm} echo "Test Invalid" -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 +. ${srcdir}/test-invalid.inc # direction not specified -pnmcat testgrid.pbm testimg.ppm > ${test_out} || \ - echo -n "Expected failure 1"; test -s ${test_out}; echo " "$? +invCmd "pnmcat testgrid.pbm testimg.ppm" # both directions specified -pnmcat -topbottom -leftright testgrid.pbm testimg.ppm > ${test_out} || \ - echo -n "Expected failure 2"; test -s ${test_out}; echo " "$? +invCmd "pnmcat -topbottom -leftright testgrid.pbm testimg.ppm" # both pad colors specified -pnmcat -topbottom -white -black testgrid.pbm testimg.ppm > ${test_out} || \ - echo -n "Expected failure 3"; test -s ${test_out}; echo " "$? +invCmd "pnmcat -topbottom -white -black testgrid.pbm testimg.ppm" # justification parameters overspecified -pnmcat -lr -jtop -jbottom testgrid.pbm testimg.ppm > ${test_out} || \ - echo -n "Expected failure 4"; test -s ${test_out}; echo " "$? - -pnmcat -lr -jtop -jcenter testgrid.pbm testimg.ppm > ${test_out} || \ - echo -n "Expected failure 5"; test -s ${test_out}; echo " "$? - -pnmcat -lr -jcenter -jbottom testgrid.pbm testimg.ppm > ${test_out} || \ - echo -n "Expected failure 6"; test -s ${test_out}; echo " "$? - -pnmcat -tb -jleft -jright testgrid.pbm testimg.ppm > ${test_out} || \ - echo -n "Expected failure 7"; test -s ${test_out}; echo " "$? - -pnmcat -tb -jleft -jcenter testgrid.pbm testimg.ppm > ${test_out} || \ - echo -n "Expected failure 8"; test -s ${test_out}; echo " "$? - -pnmcat -tb -jcenter -jright testgrid.pbm testimg.ppm > ${test_out} || \ - echo -n "Expected failure 9"; test -s ${test_out}; echo " "$? +invCmd "pnmcat -lr -jtop -jbottom testgrid.pbm testimg.ppm" +invCmd "pnmcat -lr -jtop -jcenter testgrid.pbm testimg.ppm" +invCmd "pnmcat -lr -jcenter -jbottom testgrid.pbm testimg.ppm" +invCmd "pnmcat -tb -jleft -jright testgrid.pbm testimg.ppm" +invCmd "pnmcat -tb -jleft -jcenter testgrid.pbm testimg.ppm" +invCmd "pnmcat -tb -jcenter -jright testgrid.pbm testimg.ppm" # justification parameter in the wrong direction -pnmcat -lr -jleft testgrid.pbm testimg.ppm > ${test_out} || \ - echo -n "Expected failure 10"; test -s ${test_out}; echo " "$? - -pnmcat -lr -jright testgrid.pbm testimg.ppm > ${test_out} || \ - echo -n "Expected failure 11"; test -s ${test_out}; echo " "$? - -pnmcat -tb -jtop testgrid.pbm testimg.ppm > ${test_out} || \ - echo -n "Expected failure 12"; test -s ${test_out}; echo " "$? - -pnmcat -tb -jbottom testgrid.pbm testimg.ppm > ${test_out} || \ - echo -n "Expected failure 13"; test -s ${test_out}; echo " "$? +invCmd "pnmcat -lr -jleft testgrid.pbm testimg.ppm" +invCmd "pnmcat -lr -jright testgrid.pbm testimg.ppm" +invCmd "pnmcat -tb -jtop testgrid.pbm testimg.ppm" +invCmd "pnmcat -tb -jbottom testgrid.pbm testimg.ppm" # more than one input image from standard input cat testgrid.pbm | pnmcat -lr - - testimg.ppm > ${test_out} || \ - echo -n "Expected failure 14"; test -s ${test_out}; echo " "$? - -rm -f ${test_out} + printf "Expected failure 14 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} diff --git a/test/pnmcolormap.ok b/test/pnmcolormap.ok index 126dfea4..8918cf25 100644 --- a/test/pnmcolormap.ok +++ b/test/pnmcolormap.ok @@ -1,16 +1,40 @@ +Test 1. P1 2 1 10 + P1 2 1 10 + P1 2 1 10 -Expected failure 1 1 -Expected failure 2 1 -Expected failure 3 1 -Expected failure 4 1 -Expected failure 5 1 -Expected failure 6 1 -Expected failure 7 1 + +Test 2. +P3 +3 1 +255 +0 0 255 64 0 191 128 0 128 + +P3 +2 2 +255 +0 0 255 64 0 191 +128 0 128 128 0 128 + +Test 3. +ok +ok +ok +ok +ok + +Test Invalid. +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) +Expected failure 5 (no output) +Expected failure 6 (no output) +Expected failure 7 (no output) diff --git a/test/pnmcolormap.test b/test/pnmcolormap.test index 13be8a44..953dece3 100755 --- a/test/pnmcolormap.test +++ b/test/pnmcolormap.test @@ -1,33 +1,47 @@ -#! /bin/bash +#! /bin/sh # This script tests: pnmcolormap -# Also requires: +# Also requires: ppmpat -pnmcolormap -plain -sort 2 testgrid.pbm -pnmcolormap -plain -sort -square 2 testgrid.pbm -pnmcolormap -plain -sort all testgrid.pbm - -echo 1>&2 -echo "Invalid command-line arguments." 1>&2 -echo "Error messages should appear below the line." 1>&2 -echo "-----------------------------------------------------------" 1>&2 +echo "Test 1." +pnmcolormap -plain -sort 2 maze.pbm +echo +pnmcolormap -plain -sort -square 2 maze.pbm +echo +pnmcolormap -plain -sort all maze.pbm +echo tmpdir=${tmpdir:-/tmp} -test_out=${tmpdir}/test_out - -pnmcolormap 0 testimg.ppm > ${test_out} || \ - echo -n "Expected failure 1"; test -s ${test_out}; echo " "$? -pnmcolormap -1 testimg.ppm > ${test_out} || \ - echo -n "Expected failure 2"; test -s ${test_out}; echo " "$? -pnmcolormap 0.1 testimg.ppm > ${test_out} || \ - echo -n "Expected failure 3"; test -s ${test_out}; echo " "$? -pnmcolormap -center -meancolor 16 testimg.ppm > ${test_out} || \ - echo -n "Expected failure 4"; test -s ${test_out}; echo " "$? -pnmcolormap -center -meanpixel 16 testimg.ppm > ${test_out} || \ - echo -n "Expected failure 5"; test -s ${test_out}; echo " "$? -pnmcolormap -meancolor -meanpixel 16 testimg.ppm > ${test_out} || \ - echo -n "Expected failure 6"; test -s ${test_out}; echo " "$? -pnmcolormap -spreadbrightness -spreadluminosity 16 \ - testimg.ppm > ${test_out} || \ - echo -n "Expected failure 7"; test -s ${test_out}; echo " "$? - -rm ${test_out} +tartan_ppm=${tmpdir}/tartan.ppm + +echo "Test 2." + +ppmpat -tartan -color="rgb:00/00/ff,rgb:00/80/ff,rgb:80/00/80" 20 20 |\ + tee ${tartan_ppm} | pnmcolormap -plain -sort all +echo +pnmcolormap -plain -sort -square all ${tartan_ppm} +rm ${tartan_ppm} +echo +echo "Test 3." +# Explicitly specify default options. Output should not vary. + +map=${tmpdir}/map.ppm + +pnmcolormap 64 testimg.ppm > ${map} && echo ok || echo bad +test -s ${map} && echo ok || echo bad +pnmcolormap -center 64 testimg.ppm | cmp -s ${map} - && echo ok || echo bad +pnmcolormap -spreadbrightness 64 testimg.ppm | cmp -s ${map} - && echo ok || echo bad +pnmcolormap -splitpixelct 64 testimg.ppm | cmp -s ${map} - && echo ok || echo bad +rm ${map} + +echo +echo "Test Invalid." + +. ${srcdir}/test-invalid.inc + +invCmd "pnmcolormap 0 testimg.ppm " +invCmd "pnmcolormap -1 testimg.ppm " +invCmd "pnmcolormap 0.1 testimg.ppm" +invCmd "pnmcolormap -center -meancolor 16 testimg.ppm " +invCmd "pnmcolormap -center -meanpixel 16 testimg.ppm " +invCmd "pnmcolormap -meancolor -meanpixel 16 testimg.ppm" +invCmd "pnmcolormap -spreadbrightness -spreadluminosity 16 testimg.ppm" diff --git a/test/pnmcolormap2.ok b/test/pnmcolormap2.ok new file mode 100644 index 00000000..aaf9fd42 --- /dev/null +++ b/test/pnmcolormap2.ok @@ -0,0 +1,37 @@ +Test. Should print 'match' eighteen times. +pnmcolormap 256 +match +pnmcolormap 128 +match +pnmcolormap 64 +match +pnmcolormap -meancolor 256 +match +pnmcolormap -meancolor 128 +match +pnmcolormap -meancolor 64 +match +pnmcolormap -meanpixel 256 +match +pnmcolormap -meanpixel 128 +match +pnmcolormap -meanpixel 64 +match +pnmcolormap -spreadluminosity 256 +match +pnmcolormap -spreadluminosity 128 +match +pnmcolormap -spreadluminosity 64 +match +pnmcolormap -splitcolorct 256 +match +pnmcolormap -splitcolorct 128 +match +pnmcolormap -splitcolorct 64 +match +pnmcolormap -splitspread 256 +match +pnmcolormap -splitspread 128 +match +pnmcolormap -splitspread 64 +match diff --git a/test/pnmcolormap2.test b/test/pnmcolormap2.test new file mode 100755 index 00000000..cea521aa --- /dev/null +++ b/test/pnmcolormap2.test @@ -0,0 +1,147 @@ +#! /bin/sh +# This script tests: pnmcolormap +# Also requires: pnmremap pnmpsnr + +tmpdir=${tmpdir:-/tmp} +map=${tmpdir}/map.ppm + +echo "Test. Should print 'match' eighteen times." + +# Threshold values (tgtN=xx.xx) were produced by calculating +# the S/N ratio when the original image is compared against a +# reference image with fewer colors than the target output image. + +# colors in following tests / colors for calculating threshold +# 256 / 224 +# 128 / 96 -splitspread +# 128 / 108 other +# 64 / 44 -center (default) +# 64 / 48 -splitspread +# 64 / 56 other + +# -center +echo pnmcolormap 256 +tgt1=37.19; tgt2=37.86; tgt3=37.77 +pnmcolormap 256 testimg.ppm > ${map} +pnmremap -mapfile=${map} testimg.ppm |\ +pnmpsnr -target1=${tgt1} -target2=${tgt2} -target3=${tgt3} testimg.ppm - +rm ${map} + +echo pnmcolormap 128 +tgt1=34.46; tgt2=35.61; tgt3=34.97 +pnmcolormap 128 testimg.ppm > ${map} +pnmremap -mapfile=${map} testimg.ppm |\ +pnmpsnr -target1=${tgt1} -target2=${tgt2} -target3=${tgt3} testimg.ppm - +rm ${map} + +echo pnmcolormap 64 +tgt1=30.30; tgt2=33.10; tgt3=31.74 +pnmcolormap 64 testimg.ppm > ${map} +pnmremap -mapfile=${map} testimg.ppm |\ +pnmpsnr -target1=${tgt1} -target2=${tgt2} -target3=${tgt3} testimg.ppm - +rm ${map} + +echo pnmcolormap -meancolor 256 +tgt1=38.36; tgt2=38.63; tgt3=38.95 +pnmcolormap -meancolor 256 testimg.ppm > ${map} +pnmremap -mapfile=${map} testimg.ppm |\ +pnmpsnr -target1=${tgt1} -target2=${tgt2} -target3=${tgt3} testimg.ppm - +rm ${map} + +echo pnmcolormap -meancolor 128 +tgt1=35.86; tgt2=37.17; tgt3=36.65 +pnmcolormap -meancolor 128 testimg.ppm > ${map} +pnmremap -mapfile=${map} testimg.ppm |\ +pnmpsnr -target1=${tgt1} -target2=${tgt2} -target3=${tgt3} testimg.ppm - +rm ${map} + +echo pnmcolormap -meancolor 64 +tgt1=33.64; tgt2=34.92; tgt3=34.44 +pnmcolormap -meancolor 64 testimg.ppm > ${map} +pnmremap -mapfile=${map} testimg.ppm |\ +pnmpsnr -target1=${tgt1} -target2=${tgt2} -target3=${tgt3} testimg.ppm - +rm ${map} + +echo pnmcolormap -meanpixel 256 +tgt1=38.40; tgt2=38.65; tgt3=38.90 +pnmcolormap -meanpixel 256 testimg.ppm > ${map} +pnmremap -mapfile=${map} testimg.ppm |\ +pnmpsnr -target1=${tgt1} -target2=${tgt2} -target3=${tgt3} testimg.ppm - +rm ${map} + +echo pnmcolormap -meanpixel 128 +tgt1=35.75; tgt2=37.13; tgt3=36.69 +pnmcolormap -meanpixel 128 testimg.ppm > ${map} +pnmremap -mapfile=${map} testimg.ppm |\ +pnmpsnr -target1=${tgt1} -target2=${tgt2} -target3=${tgt3} testimg.ppm - +rm ${map} + +echo pnmcolormap -meanpixel 64 +tgt1=33.75; tgt2=34.79; tgt3=34.53 +pnmcolormap -meanpixel 64 testimg.ppm > ${map} +pnmremap -mapfile=${map} testimg.ppm |\ +pnmpsnr -target1=${tgt1} -target2=${tgt2} -target3=${tgt3} testimg.ppm - +rm ${map} + +echo pnmcolormap -spreadluminosity 256 +tgt1=36.82; tgt2=36.87; tgt3=37.25 +pnmcolormap -spreadluminosity 256 testimg.ppm > ${map} +pnmremap -mapfile=${map} testimg.ppm |\ +pnmpsnr -target1=${tgt1} -target2=${tgt2} -target3=${tgt3} testimg.ppm - +rm ${map} + +echo pnmcolormap -spreadluminosity 128 +tgt1=34.61; tgt2=33.40; tgt3=34.66 +pnmcolormap -spreadluminosity 128 testimg.ppm > ${map} +pnmremap -mapfile=${map} testimg.ppm |\ +pnmpsnr -target1=${tgt1} -target2=${tgt2} -target3=${tgt3} testimg.ppm - +rm ${map} + +echo pnmcolormap -spreadluminosity 64 +tgt1=32.35; tgt2=30.23; tgt3=32.35 +pnmcolormap -spreadluminosity 64 testimg.ppm > ${map} +pnmremap -mapfile=${map} testimg.ppm |\ +pnmpsnr -target1=${tgt1} -target2=${tgt2} -target3=${tgt3} testimg.ppm - +rm ${map} + +echo pnmcolormap -splitcolorct 256 +tgt1=37.55; tgt2=38.37; tgt3=38.04 +pnmcolormap -splitcolorct 256 testimg.ppm > ${map} +pnmremap -mapfile=${map} testimg.ppm |\ +pnmpsnr -target1=${tgt1} -target2=${tgt2} -target3=${tgt3} testimg.ppm - +rm ${map} + +echo pnmcolormap -splitcolorct 128 +tgt1=34.84; tgt2=35.72; tgt3=34.64 +pnmcolormap -splitcolorct 128 testimg.ppm > ${map} +pnmremap -mapfile=${map} testimg.ppm |\ +pnmpsnr -target1=${tgt1} -target2=${tgt2} -target3=${tgt3} testimg.ppm - +rm ${map} + +echo pnmcolormap -splitcolorct 64 +tgt1=31.56; tgt2=33.74; tgt3=32.93 +pnmcolormap -splitcolorct 64 testimg.ppm > ${map} +pnmremap -mapfile=${map} testimg.ppm |\ +pnmpsnr -target1=${tgt1} -target2=${tgt2} -target3=${tgt3} testimg.ppm - +rm ${map} + +echo pnmcolormap -splitspread 256 +tgt1=35.18; tgt2=37.26; tgt3=36.17 +pnmcolormap -splitspread 256 testimg.ppm > ${map} +pnmremap -mapfile=${map} testimg.ppm |\ +pnmpsnr -target1=${tgt1} -target2=${tgt2} -target3=${tgt3} testimg.ppm - +rm ${map} + +echo pnmcolormap -splitspread 128 +tgt1=33.18; tgt2=35.58; tgt3=33.71 +pnmcolormap -splitspread 128 testimg.ppm > ${map} +pnmremap -mapfile=${map} testimg.ppm |\ +pnmpsnr -target1=${tgt1} -target2=${tgt2} -target3=${tgt3} testimg.ppm - +rm ${map} + +echo pnmcolormap -splitspread 64 +tgt1=31.27; tgt2=33.03; tgt3=30.97 +pnmcolormap -splitspread 64 testimg.ppm > ${map} +pnmremap -mapfile=${map} testimg.ppm |\ +pnmpsnr -target1=${tgt1} -target2=${tgt2} -target3=${tgt3} testimg.ppm - +rm ${map} diff --git a/test/pnmcrop-blank.test b/test/pnmcrop-blank.test index 087ad65e..bb26bdc0 100755 --- a/test/pnmcrop-blank.test +++ b/test/pnmcrop-blank.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pnmcrop # Also requires: pbmmake ppmmake diff --git a/test/pnmcrop1.ok b/test/pnmcrop1.ok index d02d14b3..35852c8c 100644 --- a/test/pnmcrop1.ok +++ b/test/pnmcrop1.ok @@ -1,103 +1,82 @@ Test 1 -test.pbm - -0 0 -7 0 28 25 rgb-1:1/1/1 0.000000 --white -0 0 -7 0 28 25 rgb-1:1/1/1 0.000000 --black -0 0 0 -2 28 30 rgb-1:0/0/0 0.000000 --sides -0 0 -7 0 28 25 rgb-1:1/1/1 0.000000 --top -0 0 -7 0 28 25 rgb-1:1/1/1 0.000000 --bottom -0 0 0 0 28 32 rgb-1:1/1/1 0.000000 --left -0 0 0 0 28 32 rgb-1:1/1/1 0.000000 --right -0 0 0 0 28 32 rgb-1:1/1/1 0.000000 --top -bottom -0 0 -7 0 28 25 rgb-1:1/1/1 0.000000 --bottom -bg-corner=bottomright -0 0 0 -2 28 30 rgb-1:0/0/0 0.000000 --right -bg-corner=bottomright -0 0 0 0 28 32 rgb-1:0/0/0 0.000000 --bg-color=white -0 0 0 0 28 32 rgb-1:1/1/1 0.000000 --bg-color=black -0 0 0 -2 28 30 rgb-1:0/0/0 0.000000 --bg-color=red -0 0 0 0 28 32 rgb-1:0/0/0 0.000000 -test.ppm - +file: maze.pbm option: +0 0 -7 0 71 68 rgb-1:1/1/1 0.000000 +file: maze.pbm option: -white +0 0 -7 0 71 68 rgb-1:1/1/1 0.000000 +file: maze.pbm option: -black +0 0 0 -2 71 73 rgb-1:0/0/0 0.000000 +file: maze.pbm option: -sides +0 0 -7 0 71 68 rgb-1:1/1/1 0.000000 +file: maze.pbm option: -top +0 0 -7 0 71 68 rgb-1:1/1/1 0.000000 +file: maze.pbm option: -bottom +0 0 0 0 71 75 rgb-1:1/1/1 0.000000 +file: maze.pbm option: -left +0 0 0 0 71 75 rgb-1:1/1/1 0.000000 +file: maze.pbm option: -right +0 0 0 0 71 75 rgb-1:1/1/1 0.000000 +file: maze.pbm option: -top -bottom +0 0 -7 0 71 68 rgb-1:1/1/1 0.000000 +file: maze.pbm option: -bottom -bg-corner=bottomright +0 0 0 -2 71 73 rgb-1:0/0/0 0.000000 +file: maze.pbm option: -right -bg-corner=bottomright +0 0 0 0 71 75 rgb-1:0/0/0 0.000000 +file: maze.pbm option: -bg-color=white +0 0 0 0 71 75 rgb-1:1/1/1 0.000000 +file: maze.pbm option: -bg-color=black +0 0 0 -2 71 73 rgb-1:0/0/0 0.000000 +file: maze.pbm option: -bg-color=red +0 0 0 0 71 75 rgb-1:0/0/0 0.000000 +file: rose.ppm option: 0 0 0 0 250 161 rgb-255:127/127/127 0.000000 --white +file: rose.ppm option: -white -6 0 0 0 244 161 rgb-255:255/255/255 0.000000 --black +file: rose.ppm option: -black 0 -11 0 0 239 161 rgb-255:0/0/0 0.000000 --sides +file: rose.ppm option: -sides -6 0 0 0 244 161 rgb-255:255/255/255 0.000000 --top +file: rose.ppm option: -top 0 0 0 0 250 161 rgb-255:127/127/127 0.000000 --bottom +file: rose.ppm option: -bottom 0 0 0 0 250 161 rgb-255:127/127/127 0.000000 --left +file: rose.ppm option: -left 0 0 0 0 250 161 rgb-255:127/127/127 0.000000 --right +file: rose.ppm option: -right 0 0 0 0 250 161 rgb-255:127/127/127 0.000000 --top -bottom +file: rose.ppm option: -top -bottom 0 0 0 0 250 161 rgb-255:127/127/127 0.000000 --bottom -bg-corner=bottomright +file: rose.ppm option: -bottom -bg-corner=bottomright 0 0 0 0 250 161 rgb-255:0/0/0 0.000000 --right -bg-corner=bottomright +file: rose.ppm option: -right -bg-corner=bottomright 0 -11 0 0 239 161 rgb-255:0/0/0 0.000000 --bg-color=white +file: rose.ppm option: -bg-color=white -6 0 0 0 244 161 rgb-255:255/255/255 0.000000 --bg-color=black +file: rose.ppm option: -bg-color=black 0 -11 0 0 239 161 rgb-255:0/0/0 0.000000 --bg-color=red +file: rose.ppm option: -bg-color=red 0 0 0 0 250 161 rgb-255:255/0/0 0.000000 -Test 2 -test.pbm - -3130931737 109 -3130931737 109 --white -3130931737 109 -3130931737 109 --top -3130931737 109 -3130931737 109 -test.ppm - -1435955776 120765 -1435955776 120765 --white -638507845 117867 -638507845 117867 --top -1435955776 120765 -1435955776 120765 +Test 2. Should print 0 six times +file: maze.pbm option: +0 +file: maze.pbm option: -white +0 +file: maze.pbm option: -top +0 +file: rose.ppm option: +0 +file: rose.ppm option: -white +0 +file: rose.ppm option: -top +0 Test Invalid --reportfull -reportsize -Expected failure: -reportfull -reportsize 1 --reportfull -borderfile=testgrid.pbm -Expected failure: -reportfull -borderfile=testgrid.pbm 1 --reportsize -borderfile=testgrid.pbm -Expected failure: -reportsize -borderfile=testgrid.pbm 1 --black -white -Expected failure: -black -white 1 --black -sides -Expected failure: -black -sides 1 --white -bg-color=red -Expected failure: -white -bg-color=red 1 --white -bg-corner=topleft -Expected failure: -white -bg-corner=topleft 1 --white -bg-corner=top -Expected failure: -white -bg-corner=top 1 --blank-image=pasturize -Expected failure: -blank-image=pasturize 1 --bg-color=black -closeness=-1 -Expected failure: -bg-color=black -closeness=-1 1 --bg-color=black -closeness=101 -Expected failure: -bg-color=black -closeness=101 1 +Expected failure: -reportfull -reportsize (no output) +Expected failure: -reportfull -borderfile=testgrid.pbm (no output) +Expected failure: -reportsize -borderfile=testgrid.pbm (no output) +Expected failure: -black -white (no output) +Expected failure: -black -sides (no output) +Expected failure: -white -bg-color=red (no output) +Expected failure: -white -bg-corner=topleft (no output) +Expected failure: -white -bg-corner=top (no output) +Expected failure: -blank-image=pasturize (no output) +Expected failure: -bg-color=black -closeness=-1 (no output) +Expected failure: -bg-color=black -closeness=101 (no output) diff --git a/test/pnmcrop1.test b/test/pnmcrop1.test index 34c7534a..811b36d8 100755 --- a/test/pnmcrop1.test +++ b/test/pnmcrop1.test @@ -1,13 +1,13 @@ -#! /bin/bash +#! /bin/sh # This script tests: pnmcrop # Also requires: pnmpad pnmmargin pamcut tmpdir=${tmpdir:-/tmp} -test_pbm=${tmpdir}/test.pbm -test_ppm=${tmpdir}/test.ppm +test_pbm=${tmpdir}/maze.pbm +test_ppm=${tmpdir}/rose.ppm -pnmmargin -white 7 testgrid.pbm | pnmpad -black -bottom=2 > ${test_pbm} +pnmmargin -white 7 maze.pbm | pnmpad -black -bottom=2 > ${test_pbm} pnmmargin -white 6 testimg.ppm | pnmpad -black -right=11 > ${test_ppm} #Test 1 @@ -15,36 +15,41 @@ echo Test 1 for input_file in ${test_pbm} ${test_ppm} do - echo `basename ${input_file}` + bfile=`basename ${input_file}` for option in "" "-white" "-black" "-sides" \ "-top" "-bottom" "-left" "-right" "-top -bottom" \ "-bottom -bg-corner=bottomright" \ "-right -bg-corner=bottomright" \ "-bg-color=white" "-bg-color=black" "-bg-color=red" do - echo ${option} + echo "file: ${bfile} option: ${option}" pnmcrop -reportfull ${option} ${input_file} || echo fail done done #Test 2 -echo Test 2 +echo "Test 2. Should print 0 six times" + +out_pnm=${tmpdir}/out.pnm for input_file in ${test_pbm} ${test_ppm} do - echo `basename ${input_file}` + bfile=`basename ${input_file}` for option in "" "-white" "-top" do - echo ${option} + echo file: ${bfile} option: ${option} # Normal crop operation - pnmcrop ${option} ${input_file} | cksum + pnmcrop ${option} ${input_file} > ${out_pnm} # Compute edge extents with pnmcrop; let pamcut do the actual cropping pamcut ${input_file} `pnmcrop -reportsize ${option} ${input_file} | \ awk 'NF==6 && NR==1 && \ $1<=0 && $2<=0 && $3<=0 && $4<=0 && $5>=0 && $6>=0 \ - { printf("-cropleft=%d -cropright=%d ", -$1, -$2); - printf("-croptop=%d -cropbottom=%d", -$3, -$4) }' ` | cksum + { printf("-cropleft=%d -cropright=%d ", -$1, -$2); + printf("-croptop=%d -cropbottom=%d ", -$3, -$4) }' ` | \ + cmp -s - ${out_pnm} + echo $? + rm ${out_pnm} done done @@ -72,8 +77,8 @@ for option in "-reportfull -reportsize" \ "-bg-color=black -closeness=-1" \ "-bg-color=black -closeness=101" do - echo ${option} pnmcrop -reportfull ${option} testgrid.pbm > ${test_out} || \ - echo -n "Expected failure: " ${option}; test -s ${test_out}; echo " "$? - rm ${test_out} + printf "Expected failure: %s" "${option} " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm ${test_out} done diff --git a/test/pnmcrop2.test b/test/pnmcrop2.test index d6c83c73..3d402a57 100755 --- a/test/pnmcrop2.test +++ b/test/pnmcrop2.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pnmcrop # Also requires: @@ -44,7 +44,7 @@ for corner in topleft topright bottomleft bottomright echo Test 3 -for closeness in `seq 0 6` +for closeness in 0 1 2 3 4 5 6 # for closeness in `seq 0 6` do echo ${closeness} pnmcrop -reportfull -bg-corner=topleft -closeness=${closeness} ${test_pgm} \ diff --git a/test/pnmcrop3.ok b/test/pnmcrop3.ok index 6824143a..4b096940 100644 --- a/test/pnmcrop3.ok +++ b/test/pnmcrop3.ok @@ -86,5 +86,5 @@ P1 1111111111111 -3 -1 -1 -1 9 13 544280424 101484 -4294967295 0 -4294967295 0 +Expected failure 1 (no output) +Expected failure 2 (no output) diff --git a/test/pnmcrop3.test b/test/pnmcrop3.test index c46fd7ea..3d32ca21 100755 --- a/test/pnmcrop3.test +++ b/test/pnmcrop3.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pnmcrop # Also requires: pnmpad pamfile pgmmake @@ -16,7 +16,7 @@ pnmpad -top=11 -bottom=1 -left=21 -right=9 testimg.ppm > ${test_ppm} pnmpad -top=4 -bottom=4 -left=8 -right=5 testgrid.pbm > ${border_pbm} pnmpad -top=7 -bottom=5 -left=30 -right=0 testimg.ppm > ${border_ppm} -pgmmake 0.5 `pamfile -size ${test_pbm}` > ${gray_pgm} +pgmmake 0.5 $(pamfile -size ${test_pbm}) > ${gray_pgm} # Test 1 echo Test 1 @@ -38,7 +38,7 @@ echo Test 2 for input_file in ${test_pbm} ${test_ppm} do echo `basename ${input_file}` - for margin in `seq 0 5` + for margin in 0 1 2 3 4 5 # for margin in `seq 0 5` do pnmcrop -reportsize -margin=${margin} ${input_file} || echo fail2 done @@ -59,13 +59,22 @@ pnmcrop -borderfile=${border_pbm} ${test_pbm} | pnmcrop -black -reportsize pnmcrop -borderfile=${border_ppm} ${test_ppm} | cksum -# The following two cases are expected to fai +test_out=${tmpdir}/test_out +# The following two cases are expected to fail + +echo "Border file size mismatch" 1>&2 echo "Error messages should appear below the line." 1>&2 echo "--------------------------------------------" 1>&2 -pnmcrop -borderfile=${border_ppm} ${test_pbm} | cksum -pnmcrop -borderfile=${border_pbm} ${test_ppm} | cksum +pnmcrop -borderfile=${border_ppm} ${test_pbm} > ${test_out} || \ + printf "Expected failure 1 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm ${test_out} +pnmcrop -borderfile=${border_pbm} ${test_ppm} > ${test_out} || \ + printf "Expected failure 2 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm ${test_out} -rm ${test_pbm} ${test_ppm} ${border_pbm} ${border_ppm} ${gray_pgm} \ No newline at end of file +rm ${test_pbm} ${test_ppm} ${border_pbm} ${border_ppm} ${gray_pgm} diff --git a/test/pnmindex.ok b/test/pnmindex.ok new file mode 100644 index 00000000..6155428d --- /dev/null +++ b/test/pnmindex.ok @@ -0,0 +1,34 @@ +Test 1. Should print 3391481002 889 +3391481002 889 +Test 2. Should print 1998876959 5290 twice +1998876959 5290 +1998876959 5290 +Test 3. Should print 3099638253 5290 +3099638253 5290 +Test 4. Should print 1397700642 3160 +1397700642 3160 +Test 5. Should print 243472565 28514 +243472565 28514 +Test 6. Should print 801388440 100455 +801388440 100455 +Test 7. Should print 256 twice +256 +256 +Test 8. Should print 100 twice +100 +100 +Test 9. Should print match +match +Test Invalid +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) +Expected failure 5 (no output) +Expected failure 6 (no output) +Expected failure 7 (no output) +Expected failure 8 (no output) +Expected failure 9 (no output) +Expected failure 10 (no output) +Expected failure 11 (no output) +Expected failure 12 (no output) diff --git a/test/pnmindex.test b/test/pnmindex.test new file mode 100755 index 00000000..174f60bd --- /dev/null +++ b/test/pnmindex.test @@ -0,0 +1,60 @@ +#! /bin/sh +# This script tests: pnmindex +# Also requires: pamcat pamscale pbmtext pnmcolormap pnmindex +# Also requires: pnminvert pnmquant pnmremap + +tmpdir=${tmpdir:-/tmp} +pnmindex256_ppm=${tmpdir}/pnmindex256.ppm + +echo "Test 1. Should print 3391481002 889" +pnmindex maze.pbm | cksum + +echo "Test 2. Should print 1998876959 5290 twice" +pnmindex maze.pbm maze.pbm maze.pbm maze.pbm maze.pbm maze.pbm | cksum +pnmindex -noquant maze.pbm maze.pbm maze.pbm maze.pbm maze.pbm maze.pbm | cksum + +echo "Test 3. Should print 3099638253 5290" +pnmindex -black maze.pbm maze.pbm maze.pbm maze.pbm maze.pbm maze.pbm | cksum + +echo "Test 4. Should print 1397700642 3160" +pnmindex -size 20 -across=3 testgrid.pbm testgrid.pbm testgrid.pbm \ + testgrid.pbm testgrid.pbm testgrid.pbm | cksum + +echo "Test 5. Should print 243472565 28514" +pnmindex -noquant testimg.ppm | cksum + +echo "Test 6. Should print 801388440 100455" +pnmindex -size 50 -across=2 -noquant testimg.ppm testimg.ppm testimg.ppm \ + testimg.ppm testimg.ppm testimg.ppm | tee ${pnmindex256_ppm} | cksum + +echo "Test 7. Should print 256 twice" +pnmindex testimg.ppm | ppmhist -nomap -noheader | wc -l +pnmindex -colors 256 testimg.ppm | ppmhist -nomap -noheader | wc -l + +echo "Test 8. Should print 100 twice" +pnmindex -colors 100 testimg.ppm | ppmhist -nomap -noheader | wc -l +pnmindex -colors 100 testimg.ppm testimg.ppm | ppmhist -nomap -noheader | wc -l + + +echo "Test 9. Should print match" +pnmindex -size 50 -across=2 -quant -colors=256 testimg.ppm testimg.ppm testimg.ppm \ + testimg.ppm testimg.ppm testimg.ppm |\ + pnmpsnr -rgb -target1=41.31 -target2=40.76 -target3=40.71 ${pnmindex256_ppm} - + + +echo "Test Invalid" + +. ${srcdir}/test-invalid.inc + +invCmd "pnmindex -size -1 testgrid.pbm" +invCmd "pnmindex -size 0 testgrid.pbm" +invCmd "pnmindex -size testgrid.pbm" +invCmd "pnmindex -across -1 testgrid.pbm" +invCmd "pnmindex -across 0 testgrid.pbm" +invCmd "pnmindex -across testgrid.pbm" +invCmd "pnmindex -colors -1 testgrid.pbm" +invCmd "pnmindex -colors 0 testgrid.pbm" +invCmd "pnmindex -colors testgrid.pbm" +invCmd "pnmindex -quant -noquant testgrid.pbm" +invCmd "pnmindex -colors 100 -noquant testgrid.pbm" +invCmd "pnmindex" diff --git a/test/pnminvert-roundtrip.ok b/test/pnminvert-roundtrip.ok index 67f7a1fe..ace97410 100644 --- a/test/pnminvert-roundtrip.ok +++ b/test/pnminvert-roundtrip.ok @@ -1,2 +1,2 @@ 1926073387 101484 -2425386270 41 +281226646 481 diff --git a/test/pnminvert-roundtrip.test b/test/pnminvert-roundtrip.test index 52d15039..c0f702c2 100755 --- a/test/pnminvert-roundtrip.test +++ b/test/pnminvert-roundtrip.test @@ -1,7 +1,7 @@ -#! /bin/bash +#! /bin/sh # This script tests: pnminvert # Also requires: pnminvert testimg.ppm | pnminvert | cksum -pnminvert testgrid.pbm | pnminvert | cksum +pnminvert maze.pbm | pnminvert | cksum diff --git a/test/pnminvert.ok b/test/pnminvert.ok index 6cf5f011..d35b30b9 100644 --- a/test/pnminvert.ok +++ b/test/pnminvert.ok @@ -1,7 +1,12 @@ -1240379484 41 +Test 1. Should print 1739442872 481 +1739442872 481 +Test 2. Should print 1416115901 101484 1416115901 101484 +Test 3. Should print 1174803406 33838 1174803406 33838 +Test 4. Should print 2595564405 14 three times 2595564405 14 2595564405 14 2595564405 14 +Test 7. Should print 2896726098 15 2896726098 15 diff --git a/test/pnminvert.test b/test/pnminvert.test index b80716ef..d2789bdf 100755 --- a/test/pnminvert.test +++ b/test/pnminvert.test @@ -1,26 +1,21 @@ -#! /bin/bash +#! /bin/sh # This script tests: pnminvert # Also requires: pbmmake pamchannel pamtopnm +echo "Test 1. Should print 1739442872 481" +pnminvert maze.pbm | cksum -# Test 1. Should print 1240379484 41 -pnminvert testgrid.pbm | cksum - -# Test 2. Should print 1416115901 101484 +echo "Test 2. Should print 1416115901 101484" pnminvert testimg.ppm | cksum -# Test 3. Should print 1174803406 33838 +echo "Test 3. Should print 1174803406 33838" pamchannel -infile=testimg.ppm -tupletype="GRAYSCALE" 0 | pamtopnm | \ pnminvert | cksum -# Test 4. Should print 2595564405 14 +echo "Test 4. Should print 2595564405 14 three times" pbmmake -w 7 7 | pnminvert | cksum - -# Test 5. Should print 2595564405 14 pbmmake -b 7 7 | cksum - -# Test 6. Should print 2595564405 14 pbmmake -b 7 7 | pnminvert | pnminvert | cksum -# Test 7. Should print 2896726098 15 +echo "Test 7. Should print 2896726098 15" pbmmake -g 8 8 | pnminvert | cksum diff --git a/test/pnmpad-color.ok b/test/pnmpad-color.ok new file mode 100644 index 00000000..91e3b264 --- /dev/null +++ b/test/pnmpad-color.ok @@ -0,0 +1,222 @@ +Test 1. PBM white infile +Should print match seven times +match +match +match +match +match +match +match +Should print match seven times +match +match +match +match +match +match +match +Should print match once +match +Should print match once +match +Should print match twice +match +match +Should print match twice +match +match +Should print match once +match +Should print match twice +match +match + +Test 2. PBM black infile +Should print match nine times +match +match +match +match +match +match +match +match +match +Should print match five times +match +match +match +match +match + +Test 3. PGM maxval 127 infile +Should print match five times +match +match +match +match +match +Should print match four times +match +match +match +match +Should print match twice +match +match +Should print match twice +match +match +Should print match twice +match +match +Should print match once +match +Should print match twice +match +match +Should print match twice +match +match +Should print match once +match +Should print match twice +match +match + +Test 4. PGM maxval 255 infile +Should print match five times +match +match +match +match +match +Should print match four times +match +match +match +match +Should print match twice +match +match +Should print match twice +match +match +Should print match twice +match +match +Should print match once +match +Should print match four times +match +match +match +match +Should print match four times +match +match +match +match +Should print match three times +match +match +match + +Test 5. PGM maxval 511 infile +Should print match five times +match +match +match +match +match +Should print match four times +match +match +match +match +Should print match twice +match +match +Should print match twice +match +match +Should print match twice +match +match +Should print match once +match +Should print match twice +match +match +Should print match twice +match +match +Should print match three times +match +match +match + +Test 6. PPM maxval 127 infile +Should print match five times +match +match +match +match +match +Should print match four times +match +match +match +match +Should print match twice +match +match +Should print match twice +match +match +Should print match twice +match +match +Should print match once +match +Should print match twice +match +match +Should print match twice +match +match +Should print match twice +match +match + +Test 7. PPM maxval 511 infile +Should print match five times +match +match +match +match +match +Should print match four times +match +match +match +match +Should print match six times +match +match +match +match +match +match +Should print match twice +match +match +Should print match twice +match +match +Should print match twice +match +match +Should print match twice +match +match diff --git a/test/pnmpad-color.test b/test/pnmpad-color.test new file mode 100755 index 00000000..05e8acca --- /dev/null +++ b/test/pnmpad-color.test @@ -0,0 +1,446 @@ +#! /bin/sh +# This script tests: pnmpad +# Also requires: pbmmake pgmmake ppmmake pamcut ppmtopgm + +tmpdir=${tmpdir:-/tmp} + +white_pbm=${tmpdir}/white.pbm +black_pbm=${tmpdir}/black.pbm +test127_pgm=${tmpdir}/testimg1.pgm +test255_pgm=${tmpdir}/testimg2.pgm +test511_pgm=${tmpdir}/testimg3.pgm +test127_ppm=${tmpdir}/testimg1.ppm +test255_ppm=${tmpdir}/testimg2.ppm +test511_ppm=${tmpdir}/testimg3.ppm +target_pnm=${tmpdir}/target.pnm + +BLACK="rgbi:0.0/0.0/0.0" +WHITE="rgbi:1.0/1.0/1.0" +LIGHTGRAY="rgbi:0.6/0.6/0.6" +LIGHTGRAYv=0.6 +DARKGRAY="rgbi:0.01/0.01/0.01" +DARKGRAYv=0.01 +PURPLE="rgb:A0/20/F0" +YELLOW="rgb:F0/F0/00" + +pbmmake -w 1 1 > ${white_pbm} +pbmmake -b 1 1 > ${black_pbm} +pgmmake 0.25 1 1 -maxval 127 > ${test127_pgm} +pgmmake 0.25 1 1 -maxval 255 > ${test255_pgm} +pgmmake 0.25 1 1 -maxval 511 > ${test511_pgm} +ppmmake ${YELLOW} 1 1 -maxval 127 > ${test127_ppm} +ppmmake ${YELLOW} 1 1 -maxval 255 > ${test255_ppm} +ppmmake ${YELLOW} 1 1 -maxval 511 > ${test511_ppm} + +ptop="-top 1" + +# define function +cmptarget () { pamcut -top 0 -left 0 -height 1 -width 1 $@ |\ + cmp -s ${target_ppm} - && echo "match" || echo "failure"; } + +echo "Test 1. PBM white infile" + +infile=${white_pbm} + +echo "Should print match seven times" + +pbmmake -w 1 1 > ${target_pnm} +pnmpad ${ptop} -white ${infile} | cmptarget +pnmpad ${ptop} -extend-edge ${infile} | cmptarget +pnmpad ${ptop} -detect-background ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} -promote format ${infile} | cmptarget +pnmpad ${ptop} -color ${LIGHTGRAY} -promote none ${infile} | cmptarget + +echo "Should print match seven times" + +pbmmake -b 1 1 > ${target_pnm} +pnmpad ${ptop} ${infile} | cmptarget +pnmpad ${ptop} -black ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} -promote format ${infile} | cmptarget +pnmpad ${ptop} -color ${DARKGRAY} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${PURPLE} -promote none ${infile} | cmptarget + +echo "Should print match once" + +pgmmake -maxval 1 ${LIGHTGRAYv} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${LIGHTGRAY} -promote format ${infile} | cmptarget + +echo "Should print match once" + +pgmmake -maxval 1 ${DARKGRAYv} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${DARKGRAY} -promote format ${infile} | cmptarget + +echo "Should print match twice" + +pgmmake -maxval 255 ${LIGHTGRAYv} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${LIGHTGRAY} ${infile} | cmptarget +pnmpad ${ptop} -color ${LIGHTGRAY} -promote all ${infile} | cmptarget + +echo "Should print match twice" + +pgmmake -maxval 255 ${DARKGRAYv} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${DARKGRAY} ${infile} | cmptarget +pnmpad ${ptop} -color ${DARKGRAY} -promote all ${infile} | cmptarget + +echo "Should print match once" + +ppmmake -maxval 1 ${PURPLE} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${PURPLE} -promote format ${infile} | cmptarget + +echo "Should print match twice" + +ppmmake -maxval 255 ${PURPLE} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${PURPLE} ${infile} | cmptarget +pnmpad ${ptop} -color ${PURPLE} -promote all ${infile} | cmptarget + +echo +echo "Test 2. PBM black infile" + +infile=${black_pbm} + +echo "Should print match nine times" + +pbmmake -b 1 1 > ${target_pnm} +pnmpad ${ptop} ${infile} | cmptarget +pnmpad ${ptop} -black ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} -promote format ${infile} | cmptarget +pnmpad ${ptop} -color ${DARKGRAY} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${PURPLE} -promote none ${infile} | cmptarget +pnmpad ${ptop} -extend-edge ${infile} | cmptarget +pnmpad ${ptop} -detect-background ${infile} | cmptarget + +echo "Should print match five times" + +pbmmake -w 1 1 > ${target_pnm} +pnmpad ${ptop} -white ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} -promote format ${infile} | cmptarget +pnmpad ${ptop} -color ${LIGHTGRAY} -promote none ${infile} | cmptarget + +echo +echo "Test 3. PGM maxval 127 infile" + +infile=${test127_pgm} + +echo "Should print match five times" + +pgmmake -maxval 127 0.0 1 1 > ${target_pnm} +pnmpad ${ptop} ${infile} | cmptarget +pnmpad ${ptop} -black ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} -promote format ${infile} | cmptarget + +echo "Should print match four times" + +pgmmake -maxval 127 1.0 1 1 > ${target_pnm} +pnmpad ${ptop} -white ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} -promote format ${infile} | cmptarget + +echo "Should print match twice" + +pamcut -t 0 -h 1 -w 1 ${infile} > ${target_pnm} +pnmpad ${ptop} -extend-edge ${infile} | cmptarget +pnmpad ${ptop} -detect-background ${infile} | cmptarget + +echo "Should print match twice" + +pgmmake -maxval 127 ${LIGHTGRAYv} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${LIGHTGRAY} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${LIGHTGRAY} -promote format ${infile} | cmptarget + +echo "Should print match twice" + +pgmmake -maxval 127 ${DARKGRAYv} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${DARKGRAY} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${DARKGRAY} -promote format ${infile} | cmptarget + +echo "Should print match once" + +ppmmake -maxval 127 ${PURPLE} 1 1 | ppmtopgm > ${target_pnm} +pnmpad ${ptop} -color ${PURPLE} -promote none ${infile} | cmptarget + +echo "Should print match twice" + +pgmmake -maxval 255 ${LIGHTGRAYv} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${LIGHTGRAY} ${infile} | cmptarget +pnmpad ${ptop} -color ${LIGHTGRAY} -promote all ${infile} | cmptarget + +echo "Should print match twice" + +pgmmake -maxval 255 ${DARKGRAYv} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${DARKGRAY} ${infile} | cmptarget +pnmpad ${ptop} -color ${DARKGRAY} -promote all ${infile} | cmptarget + +echo "Should print match once" + +ppmmake -maxval 127 ${PURPLE} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${PURPLE} -promote format ${infile} | cmptarget + +echo "Should print match twice" + +ppmmake -maxval 255 ${PURPLE} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${PURPLE} ${infile} | cmptarget +pnmpad ${ptop} -color ${PURPLE} -promote all ${infile} | cmptarget + + +echo +echo "Test 4. PGM maxval 255 infile" + +infile=${test255_pgm} + +echo "Should print match five times" + +pgmmake -maxval 255 0.0 1 1 > ${target_pnm} +pnmpad ${ptop} ${infile} | cmptarget +pnmpad ${ptop} -black ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} -promote format ${infile} | cmptarget + +echo "Should print match four times" + +pgmmake -maxval 255 1.0 1 1 > ${target_pnm} +pnmpad ${ptop} -white ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} -promote format ${infile} | cmptarget + +echo "Should print match twice" + +pamcut -t 0 -h 1 -w 1 ${infile} > ${target_pnm} +pnmpad ${ptop} -extend-edge ${infile} | cmptarget +pnmpad ${ptop} -detect-background ${infile} | cmptarget + +echo "Should print match twice" + +pgmmake -maxval 255 ${LIGHTGRAYv} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${LIGHTGRAY} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${LIGHTGRAY} -promote format ${infile} | cmptarget + +echo "Should print match twice" + +pgmmake -maxval 255 ${DARKGRAYv} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${DARKGRAY} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${DARKGRAY} -promote format ${infile} | cmptarget + +echo "Should print match once" + +ppmmake -maxval 255 ${PURPLE} 1 1 | ppmtopgm > ${target_pnm} +pnmpad ${ptop} -color ${PURPLE} -promote none ${infile} | cmptarget + +echo "Should print match four times" + +pgmmake -maxval 255 ${LIGHTGRAYv} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${LIGHTGRAY} ${infile} | cmptarget +pnmpad ${ptop} -color ${LIGHTGRAY} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${LIGHTGRAY} -promote format ${infile} | cmptarget +pnmpad ${ptop} -color ${LIGHTGRAY} -promote all ${infile} | cmptarget + +echo "Should print match four times" + +pgmmake -maxval 255 ${DARKGRAYv} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${DARKGRAY} ${infile} | cmptarget +pnmpad ${ptop} -color ${DARKGRAY} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${DARKGRAY} -promote format ${infile} | cmptarget +pnmpad ${ptop} -color ${DARKGRAY} -promote all ${infile} | cmptarget + +echo "Should print match three times" + +ppmmake -maxval 255 ${PURPLE} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${PURPLE} ${infile} | cmptarget +pnmpad ${ptop} -color ${PURPLE} -promote format ${infile} | cmptarget +pnmpad ${ptop} -color ${PURPLE} -promote all ${infile} | cmptarget + +echo +echo "Test 5. PGM maxval 511 infile" + +infile=${test511_pgm} + +echo "Should print match five times" + +pgmmake -maxval 511 0.0 1 1 > ${target_pnm} +pnmpad ${ptop} ${infile} | cmptarget +pnmpad ${ptop} -black ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} -promote format ${infile} | cmptarget + +echo "Should print match four times" + +pgmmake -maxval 511 1.0 1 1 > ${target_pnm} +pnmpad ${ptop} -white ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} -promote format ${infile} | cmptarget + +echo "Should print match twice" + +pamcut -t 0 -h 1 -w 1 ${infile} > ${target_pnm} +pnmpad ${ptop} -extend-edge ${infile} | cmptarget +pnmpad ${ptop} -detect-background ${infile} | cmptarget + +echo "Should print match twice" + +pgmmake -maxval 511 ${LIGHTGRAYv} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${LIGHTGRAY} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${LIGHTGRAY} -promote format ${infile} | cmptarget + +echo "Should print match twice" + +pgmmake -maxval 511 ${DARKGRAYv} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${DARKGRAY} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${DARKGRAY} -promote format ${infile} | cmptarget + +echo "Should print match once" + +ppmmake -maxval 511 ${PURPLE} 1 1 | ppmtopgm > ${target_pnm} +pnmpad ${ptop} -color ${PURPLE} -promote none ${infile} | cmptarget + +echo "Should print match twice" + +pgmmake -maxval 511 ${LIGHTGRAYv} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${LIGHTGRAY} ${infile} | cmptarget +pnmpad ${ptop} -color ${LIGHTGRAY} -promote all ${infile} | cmptarget + +echo "Should print match twice" + +pgmmake -maxval 511 ${DARKGRAYv} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${DARKGRAY} ${infile} | cmptarget +pnmpad ${ptop} -color ${DARKGRAY} -promote all ${infile} | cmptarget + +echo "Should print match three times" + +ppmmake -maxval 511 ${PURPLE} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${PURPLE} ${infile} | cmptarget +pnmpad ${ptop} -color ${PURPLE} -promote format ${infile} | cmptarget +pnmpad ${ptop} -color ${PURPLE} -promote all ${infile} | cmptarget + + +echo +echo "Test 6. PPM maxval 127 infile" + +infile=${test127_ppm} + +echo "Should print match five times" + +ppmmake -maxval 127 ${BLACK} 1 1 > ${target_pnm} +pnmpad ${ptop} ${infile} | cmptarget +pnmpad ${ptop} -black ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} -promote format ${infile} | cmptarget + +echo "Should print match four times" + +ppmmake -maxval 127 ${WHITE} 1 1 > ${target_pnm} +pnmpad ${ptop} -white ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} -promote format ${infile} | cmptarget + +echo "Should print match twice" + +ppmmake -maxval 127 ${PURPLE} 1 1 > ${target_pnm} +ppmmake -maxval 127 ${PURPLE} 1 2 | pnmpad ${ptop} -extend-edge | cmptarget +ppmmake -maxval 127 ${PURPLE} 1 2 | pnmpad ${ptop} -detect-background | cmptarget + +echo "Should print match twice" + +ppmmake -maxval 127 ${LIGHTGRAY} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${LIGHTGRAY} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${LIGHTGRAY} -promote format ${infile} | cmptarget + +echo "Should print match twice" + +ppmmake -maxval 127 ${DARKGRAY} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${DARKGRAY} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${DARKGRAY} -promote format ${infile} | cmptarget + +echo "Should print match once" + +ppmmake -maxval 127 ${PURPLE} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${PURPLE} -promote none ${infile} | cmptarget + +echo "Should print match twice" + +ppmmake -maxval 255 ${LIGHTGRAY} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${LIGHTGRAY} ${infile} | cmptarget +pnmpad ${ptop} -color ${LIGHTGRAY} -promote all ${infile} | cmptarget + +echo "Should print match twice" + +ppmmake -maxval 255 ${DARKGRAY} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${DARKGRAY} ${infile} | cmptarget +pnmpad ${ptop} -color ${DARKGRAY} -promote all ${infile} | cmptarget + +echo "Should print match twice" + +ppmmake -maxval 255 ${PURPLE} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${PURPLE} ${infile} | cmptarget +pnmpad ${ptop} -color ${PURPLE} -promote all ${infile} | cmptarget + +echo +echo "Test 7. PPM maxval 511 infile" + +infile=${test511_ppm} + +echo "Should print match five times" + +ppmmake -maxval 511 ${BLACK} 1 1 > ${target_pnm} +pnmpad ${ptop} ${infile} | cmptarget +pnmpad ${ptop} -black ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${BLACK} -promote format ${infile} | cmptarget + +echo "Should print match four times" + +ppmmake -maxval 511 ${WHITE} 1 1 > ${target_pnm} +pnmpad ${ptop} -white ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${WHITE} -promote format ${infile} | cmptarget + +echo "Should print match six times" + +ppmmake -maxval 511 ${PURPLE} 1 1 > ${target_pnm} +ppmmake -maxval 511 ${PURPLE} 1 5 | pnmpad ${ptop} -extend-edge | cmptarget +ppmmake -maxval 511 ${PURPLE} 1 5 | pnmpad ${ptop} -detect-background | cmptarget +pnmpad ${ptop} -color ${PURPLE} ${infile} | cmptarget +pnmpad ${ptop} -color ${PURPLE} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${PURPLE} -promote format ${infile} | cmptarget +pnmpad ${ptop} -color ${PURPLE} -promote all ${infile} | cmptarget + +echo "Should print match twice" + +ppmmake -maxval 511 ${LIGHTGRAY} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${LIGHTGRAY} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${LIGHTGRAY} -promote format ${infile} | cmptarget + +echo "Should print match twice" + +ppmmake -maxval 511 ${DARKGRAY} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${DARKGRAY} -promote none ${infile} | cmptarget +pnmpad ${ptop} -color ${DARKGRAY} -promote format ${infile} | cmptarget + +echo "Should print match twice" + +ppmmake -maxval 511 ${LIGHTGRAY} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${LIGHTGRAY} ${infile} | cmptarget +pnmpad ${ptop} -color ${LIGHTGRAY} -promote all ${infile} | cmptarget + +echo "Should print match twice" + +ppmmake -maxval 511 ${DARKGRAY} 1 1 > ${target_pnm} +pnmpad ${ptop} -color ${DARKGRAY} ${infile} | cmptarget +pnmpad ${ptop} -color ${DARKGRAY} -promote all ${infile} | cmptarget diff --git a/test/pnmpad-extend-enlarge.ok b/test/pnmpad-extend-enlarge.ok new file mode 100644 index 00000000..d1539022 --- /dev/null +++ b/test/pnmpad-extend-enlarge.ok @@ -0,0 +1,163 @@ +Test 1. Should print match forty-eight (24x2) times +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +Test 2. Should print match thirty-six (18x2) times +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +Test 3. Should print match twenty-four (4x6) times +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +Test 4. Should print match eighteen (3x6) times +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +Test 5. Should print match thirty-two (8x4) times +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match +match diff --git a/test/pnmpad-extend-enlarge.test b/test/pnmpad-extend-enlarge.test new file mode 100755 index 00000000..fde609a6 --- /dev/null +++ b/test/pnmpad-extend-enlarge.test @@ -0,0 +1,177 @@ +#! /bin/sh +# This script tests: pnmpad pamenlarge +# Also requires: pamcat pamcut pamenlarge pbmmake pbmnoise pgmmake pgmnoise +# Also requires: ppmmake ppmpat + +# If the padding function for -extend-edge is altered, make sure to run this +# test in a more thorough form. Replace "for leftpad in 0 1 7 9 16" +# with "for leftpad in `seq 0 16`". + +tmpdir=${tmpdir:-/tmp} +test_pnm=${tmpdir}/test.pnm + +padded_pnm=${tmpdir}/padded.pnm +#middle_pnm=${tmpdir}/middle.pnm +left_pnm=${tmpdir}/left.pnm +right_pnm=${tmpdir}/right.pnm +top_pnm=${tmpdir}/top.pnm +bottom_pnm=${tmpdir}/bottom.pnm + +echo "Test 1. Should print match forty-eight (24x2) times" + +for generator in "pbmnoise -randomseed=100 17 17" \ + "ppmpat -tartan -randomseed=100 11 11" + do + ${generator} > ${test_pnm} + for leftpad in 0 1 7 9 16 + do + for rightpad in 0 1 8 + do + pnmpad -extend-edge -l=${leftpad} -r=${rightpad} ${test_pnm} > ${padded_pnm} + pamcut -left=0 -width=1 ${test_pnm} |\ + pamenlarge -xscale=$(( ${leftpad} + 1 )) > ${left_pnm} + pamcut -right=-1 -width=1 ${test_pnm} |\ + pamenlarge -xscale=$(( ${rightpad} + 1 )) > ${right_pnm} + pamcut -cropleft=1 -cropright=1 ${test_pnm} |\ + pamcat -lr ${left_pnm} - ${right_pnm} |\ + cmp -s - ${padded_pnm} && echo "match" ||\ + echo "no match: lr ${generator} ${leftpad} ${rightpad}"; + rm ${left_pnm} ${right_pnm} ${padded_pnm} + done + done + + for toppad in 0 2 5 + do + for bottompad in 0 1 10 + do + pnmpad -extend-edge -t=${toppad} -b=${bottompad} ${test_pnm} > ${padded_pnm} + pamcut -top=0 -height=1 ${test_pnm} |\ + pamenlarge -yscale=$(( ${toppad} + 1 )) > ${top_pnm} + pamcut -bottom=-1 -height=1 ${test_pnm} |\ + pamenlarge -yscale=$(( ${bottompad} + 1 )) > ${bottom_pnm} + pamcut -croptop=1 -cropbottom=1 ${test_pnm} |\ + pamcat -tb ${top_pnm} - ${bottom_pnm} |\ + cmp -s - ${padded_pnm} && echo "match" ||\ + echo "no match: tb ${generator} ${toppad} ${bottompad}"; + rm ${top_pnm} ${bottom_pnm} ${padded_pnm} + done + done + rm ${test_pnm} +done + + +echo "Test 2. Should print match thirty-six (18x2) times" + +for generator in "pbmnoise -randomseed=100 17 17" \ + "ppmpat -tartan -randomseed=100 11 11" + do + ${generator} > ${test_pnm} + for leftpad in 0 1 2 + do + for rightpad in 0 1 3 + do + pnmpad -extend-edge -l=${leftpad} -r=${rightpad} ${test_pnm} > ${padded_pnm} + pamcut -left=0 -width=1 ${test_pnm} |\ + pamenlarge -xscale=$(( ${leftpad} + 1 )) > ${left_pnm} + pamcut -right=-1 -width=1 ${test_pnm} |\ + pamenlarge -xscale=$(( ${rightpad} + 1 )) > ${right_pnm} + pamcut -cropleft=1 -cropright=1 ${test_pnm} |\ + pamcat -lr ${left_pnm} - ${right_pnm} |\ + cmp -s - ${padded_pnm} && echo "match" ||\ + echo "no match: lr ${generator} ${leftpad} ${rightpad}"; + rm ${left_pnm} ${right_pnm} ${padded_pnm} + done + done + + for toppad in 0 1 12 + do + for bottompad in 0 1 5 + do + pnmpad -extend-edge -t=${toppad} -b=${bottompad} ${test_pnm} > ${padded_pnm} + pamcut -top=0 -height=1 ${test_pnm} |\ + pamenlarge -yscale=$(( ${toppad} + 1 )) > ${top_pnm} + pamcut -bottom=-1 -height=1 ${test_pnm} |\ + pamenlarge -yscale=$(( ${bottompad} + 1 )) > ${bottom_pnm} + pamcut -croptop=1 -cropbottom=1 ${test_pnm} |\ + pamcat -tb ${top_pnm} - ${bottom_pnm} |\ + cmp -s - ${padded_pnm} && echo "match" ||\ + echo "no match: tb ${generator} ${toppad} ${bottompad}"; + rm ${top_pnm} ${bottom_pnm} ${padded_pnm} + done + done + rm ${test_pnm} +done + + +echo "Test 3. Should print match twenty-four (4x6) times" + +stretch_pnm=${tmpdir}/stretch.pnm + +for generator in "pbmmake -b 1 1" \ + "pbmmake -b 1 11" \ + "pbmmake -w 1 1" \ + "pbmmake -w 1 8" \ + "pbmnoise -randomseed=100 1 17" \ + "pgmnoise -randomseed=100 1 12" + do + ${generator} > ${test_pnm} + pamenlarge -xscale=17 ${test_pnm} > ${stretch_pnm} + + for leftpad in 0 1 7 16 + do + pnmpad -extend-edge -l=${leftpad} -r=$((16 - ${leftpad})) ${test_pnm} |\ + cmp -s - ${stretch_pnm} && echo "match" ||\ + echo "no match: ${generator} ${leftpad}"; + done + rm ${stretch_pnm} ${test_pnm} +done + + +echo "Test 4. Should print match eighteen (3x6) times" + +stretch_pnm=${tmpdir}/stretch.pnm + +for generator in "pbmmake -b 1 1" \ + "pbmmake -b 8 1" \ + "pbmmake -w 1 1" \ + "pbmmake -w 3 1" \ + "pbmnoise -randomseed=100 17 1" \ + "pgmnoise -randomseed=100 8 1" + do + ${generator} > ${test_pnm} + pamenlarge -yscale=15 ${test_pnm} > ${stretch_pnm} + + for toppad in 0 1 14 + do + pnmpad -extend-edge -t=${toppad} -b=$((14 - ${toppad})) ${test_pnm} |\ + cmp -s - ${stretch_pnm} && echo "match" ||\ + echo "no match: ${generator} ${toppad}"; + done + rm ${stretch_pnm} ${test_pnm} +done + + +echo "Test 5. Should print match thirty-two (8x4) times" + +stretch_pnm=${tmpdir}/stretch.pnm + +for generator in "pbmmake -b 1 1" \ + "pbmmake -w 1 1" \ + "pgmmake 0.3 1 1" \ + "ppmmake rgbi:0.5/0.3/0.8 1 1" + do + ${generator} > ${test_pnm} + pamenlarge -xscale=66 -yscale=10 ${test_pnm} > ${stretch_pnm} + + for toppad in 0 8 + do + for leftpad in 0 1 15 64 + do + pnmpad -extend-edge -t=${toppad} -b=$((9 - ${toppad})) \ + -l=${leftpad} -r=$((65 - ${leftpad})) ${test_pnm} |\ + cmp -s - ${stretch_pnm} && echo "match" ||\ + echo "no match: ${generator} ${toppad} ${leftpad}" + done + done + rm ${stretch_pnm} ${test_pnm} +done diff --git a/test/pnmpad-flip.ok b/test/pnmpad-flip.ok new file mode 100644 index 00000000..af596ad3 --- /dev/null +++ b/test/pnmpad-flip.ok @@ -0,0 +1,64 @@ +Test 1. Should print match sixteen (8x2) times +(pbmnoise -randomseed=100 11 16) +match +match +match +match +match +match +match +match +(pgmnoise -randomseed=100 31 41) +match +match +match +match +match +match +match +match +Test 2. Should print match forty (10x4) times +(pbmmake -b 1 1) +match +match +match +match +match +match +match +match +match +match +(pbmmake -w 1 1) +match +match +match +match +match +match +match +match +match +match +(pbmmake -g 17 11) +match +match +match +match +match +match +match +match +match +match +(ppmpat -argyle1 -randomseed=100 7 8) +match +match +match +match +match +match +match +match +match +match diff --git a/test/pnmpad-flip.test b/test/pnmpad-flip.test new file mode 100755 index 00000000..2013874c --- /dev/null +++ b/test/pnmpad-flip.test @@ -0,0 +1,62 @@ +#! /bin/sh +# This script tests: pnmpad +# Also requires: pamflip pbmmake pbmnoise pgmnoise ppmpat + +# If any of the padding functions is altered, make sure to run this +# test in a more thorough form. Try more input images and more +# values of d0, d1, d2, d3. + +tmpdir=${tmpdir:-/tmp} +test_pnm=${tmpdir}/test.pnm +padded_pnm=${tmpdir}/padded.pnm + +echo "Test 1. Should print match sixteen (8x2) times" + +d0=1; d1=11; d2=10; d3=5; + +for generator in "pbmnoise -randomseed=100 11 16" \ + "pgmnoise -randomseed=100 31 41" + do + ${generator} > ${test_pnm} + echo "("${generator}")" + for method in "-black" "-white" "-color rgb:20/30/e0" "-extend-edge" + do + pnmpad ${method} -t ${d0} -r ${d1} -b ${d2} -l ${d3} ${test_pnm} > ${padded_pnm} + + pamflip -lr ${test_pnm} |\ + pnmpad ${method} -t ${d0} -l ${d1} -b ${d2} -r ${d3} | pamflip -lr |\ + cmp -s ${padded_pnm} - && echo "match" || echo "no match" + + pamflip -r90 ${test_pnm} |\ + pnmpad ${method} -l ${d0} -t ${d1} -r ${d2} -b ${d3} | pamflip -r270 |\ + cmp -s ${padded_pnm} - && echo "match" || echo "no match" + + done +done + +echo "Test 2. Should print match forty (10x4) times" + +# Test images with all corners with the same colors + +for generator in "pbmmake -b 1 1" \ + "pbmmake -w 1 1" \ + "pbmmake -g 17 11" \ + "ppmpat -argyle1 -randomseed=100 7 8" + do + ${generator} > ${test_pnm} + echo "("${generator}")" + for method in "-black" "-white" "-color rgb:20/30/e0 -promote none" \ + "-detect-background" "-extend-edge" + do + pnmpad ${method} -t ${d0} -r ${d1} -b ${d2} -l ${d3} ${test_pnm} > ${padded_pnm} + + pamflip -lr ${test_pnm} |\ + pnmpad ${method} -t ${d0} -l ${d1} -b ${d2} -r ${d3} | pamflip -lr |\ + cmp -s ${padded_pnm} - && echo "match" || echo "no match" + + pamflip -r90 ${test_pnm} |\ + pnmpad ${method} -l ${d0} -t ${d1} -r ${d2} -b ${d3} | pamflip -r270 |\ + cmp -s ${padded_pnm} - && echo "match" || echo "no match" + + done +done diff --git a/test/pnmpad-format.ok b/test/pnmpad-format.ok new file mode 100644 index 00000000..9938a170 --- /dev/null +++ b/test/pnmpad-format.ok @@ -0,0 +1,135 @@ +Test 1. PBM infile +Should print: PBM raw, 8 by 1 fourteen times +stdin: PBM raw, 8 by 1 +stdin: PBM raw, 8 by 1 +stdin: PBM raw, 8 by 1 +stdin: PBM raw, 8 by 1 +stdin: PBM raw, 8 by 1 +stdin: PBM raw, 8 by 1 +stdin: PBM raw, 8 by 1 +stdin: PBM raw, 8 by 1 +stdin: PBM raw, 8 by 1 +stdin: PBM raw, 8 by 1 +stdin: PBM raw, 8 by 1 +stdin: PBM raw, 8 by 1 +stdin: PBM raw, 8 by 1 +stdin: PBM raw, 8 by 1 +Should print: PGM raw, 8 by 1 maxval 1 twice +stdin: PGM raw, 8 by 1 maxval 1 +stdin: PGM raw, 8 by 1 maxval 1 +Should print: PGM raw, 8 by 1 maxval 255 twice +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +Should print: PPM raw, 8 by 1 maxval 1 once +stdin: PPM raw, 8 by 1 maxval 1 +Should print: PPM raw, 8 by 1 maxval 255 twice +stdin: PPM raw, 8 by 1 maxval 255 +stdin: PPM raw, 8 by 1 maxval 255 + +Test 2. PGM maxval 127 infile +Should print: PGM raw, 8 by 1 maxval 127 sixteen times +stdin: PGM raw, 8 by 1 maxval 127 +stdin: PGM raw, 8 by 1 maxval 127 +stdin: PGM raw, 8 by 1 maxval 127 +stdin: PGM raw, 8 by 1 maxval 127 +stdin: PGM raw, 8 by 1 maxval 127 +stdin: PGM raw, 8 by 1 maxval 127 +stdin: PGM raw, 8 by 1 maxval 127 +stdin: PGM raw, 8 by 1 maxval 127 +stdin: PGM raw, 8 by 1 maxval 127 +stdin: PGM raw, 8 by 1 maxval 127 +stdin: PGM raw, 8 by 1 maxval 127 +stdin: PGM raw, 8 by 1 maxval 127 +stdin: PGM raw, 8 by 1 maxval 127 +stdin: PGM raw, 8 by 1 maxval 127 +stdin: PGM raw, 8 by 1 maxval 127 +stdin: PGM raw, 8 by 1 maxval 127 +Should print: PGM raw, 8 by 1 maxval 255 four times +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +Should print: PPM raw, 8 by 1 maxval 127 once +stdin: PPM raw, 8 by 1 maxval 127 +Should print: PPM raw, 8 by 1 maxval 255 twice +stdin: PPM raw, 8 by 1 maxval 255 +stdin: PPM raw, 8 by 1 maxval 255 + +Test 3. PGM maxval 255 infile +Should print: PGM raw, 8 by 1 maxval 255 eighteen times +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +stdin: PGM raw, 8 by 1 maxval 255 +Should print: PPM raw, 8 by 1 maxval 255 three times +stdin: PPM raw, 8 by 1 maxval 255 +stdin: PPM raw, 8 by 1 maxval 255 +stdin: PPM raw, 8 by 1 maxval 255 + +Test 4. PPM maxval 127 infile +Should print: PPM raw, 8 by 1 maxval 127 seventeen times +stdin: PPM raw, 8 by 1 maxval 127 +stdin: PPM raw, 8 by 1 maxval 127 +stdin: PPM raw, 8 by 1 maxval 127 +stdin: PPM raw, 8 by 1 maxval 127 +stdin: PPM raw, 8 by 1 maxval 127 +stdin: PPM raw, 8 by 1 maxval 127 +stdin: PPM raw, 8 by 1 maxval 127 +stdin: PPM raw, 8 by 1 maxval 127 +stdin: PPM raw, 8 by 1 maxval 127 +stdin: PPM raw, 8 by 1 maxval 127 +stdin: PPM raw, 8 by 1 maxval 127 +stdin: PPM raw, 8 by 1 maxval 127 +stdin: PPM raw, 8 by 1 maxval 127 +stdin: PPM raw, 8 by 1 maxval 127 +stdin: PPM raw, 8 by 1 maxval 127 +stdin: PPM raw, 8 by 1 maxval 127 +stdin: PPM raw, 8 by 1 maxval 127 +Should print: PPM raw, 8 by 1 maxval 255 five times +stdin: PPM raw, 8 by 1 maxval 255 +stdin: PPM raw, 8 by 1 maxval 255 +stdin: PPM raw, 8 by 1 maxval 255 +stdin: PPM raw, 8 by 1 maxval 255 +stdin: PPM raw, 8 by 1 maxval 255 + +Test 5. PPM maxval 511 infile +Should print: PPM raw, 8 by 1 maxval 511 twenty-five times +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 +stdin: PPM raw, 8 by 1 maxval 511 diff --git a/test/pnmpad-format.test b/test/pnmpad-format.test new file mode 100755 index 00000000..73ea6d2b --- /dev/null +++ b/test/pnmpad-format.test @@ -0,0 +1,245 @@ +#! /bin/sh +# This script tests: pnmpad +# Also requires: pbmmake pgmmake ppmmake pamfile + +tmpdir=${tmpdir:-/tmp} + +white_pbm=${tmpdir}/white.pbm +#black_pbm=${tmpdir}/black.pbm +test127_pgm=${tmpdir}/testimg1.pgm +test255_pgm=${tmpdir}/testimg2.pgm +test511_pgm=${tmpdir}/testimg3.pgm +test127_ppm=${tmpdir}/testimg1.ppm +test255_ppm=${tmpdir}/testimg2.ppm +test511_ppm=${tmpdir}/testimg3.ppm + +BLACK="rgbi:0.0/0.0/0.0" +WHITE="rgbi:1.0/1.0/1.0" +LIGHTGRAY="rgbi:0.6/0.6/0.6" +LIGHTGRAYv=0.6 +DARKGRAY="rgbi:0.01/0.01/0.01" +DARKGRAYv=0.01 +PURPLE="rgb:A0/20/F0" +YELLOW="rgb:FF/FF/00" + +pbmmake -w 3 1 > ${white_pbm} +#pbmmake -b 3 1 > ${black_pbm} +pgmmake 0.2 3 1 -maxval 127 > ${test127_pgm} +pgmmake 0.2 3 1 -maxval 255 > ${test255_pgm} +ppmmake ${YELLOW} 3 1 -maxval 127 > ${test127_ppm} +ppmmake ${YELLOW} 3 1 -maxval 511 > ${test511_ppm} + +# define function +ckfmt() { pamfile || echo "failure"; } + +size="-width 8" + +echo "Test 1. PBM infile" + +infile=${white_pbm} + +echo "Should print: PBM raw, 8 by 1 fourteen times" + +pnmpad ${size} ${infile} | ckfmt +pnmpad ${size} -black ${infile} | ckfmt +pnmpad ${size} -white ${infile} | ckfmt +pnmpad ${size} -extend-edge ${infile} | ckfmt +pnmpad ${size} -detect-background ${infile} | ckfmt + +pnmpad ${size} -color ${BLACK} ${infile} | ckfmt +pnmpad ${size} -color ${BLACK} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${BLACK} -promote format ${infile} | ckfmt + +pnmpad ${size} -color ${WHITE} ${infile} | ckfmt +pnmpad ${size} -color ${WHITE} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${WHITE} -promote format ${infile} | ckfmt + +pnmpad ${size} -color ${LIGHTGRAY} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${DARKGRAY} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${PURPLE} -promote none ${infile} | ckfmt + +echo "Should print: PGM raw, 8 by 1 maxval 1 twice" + +pnmpad ${size} -color ${LIGHTGRAY} -promote format ${infile} | ckfmt +pnmpad ${size} -color ${DARKGRAY} -promote format ${infile} | ckfmt + +echo "Should print: PGM raw, 8 by 1 maxval 255 twice" + +pnmpad ${size} -color ${LIGHTGRAY} ${infile} | ckfmt +pnmpad ${size} -color ${DARKGRAY} ${infile} | ckfmt + +echo "Should print: PPM raw, 8 by 1 maxval 1 once" + +pnmpad ${size} -color ${PURPLE} -promote format ${infile} | ckfmt + +echo "Should print: PPM raw, 8 by 1 maxval 255 twice" + +pnmpad ${size} -color ${PURPLE} ${infile} | ckfmt +pnmpad ${size} -color ${PURPLE} -promote all ${infile} | ckfmt + +rm ${infile} + +echo +echo "Test 2. PGM maxval 127 infile" + +infile=${test127_pgm} + +echo "Should print: PGM raw, 8 by 1 maxval 127 sixteen times" + +pnmpad ${size} ${infile} | ckfmt +pnmpad ${size} -black ${infile} | ckfmt +pnmpad ${size} -white ${infile} | ckfmt +pnmpad ${size} -extend-edge ${infile} | ckfmt +pnmpad ${size} -detect-background ${infile} | ckfmt + +pnmpad ${size} -color ${BLACK} ${infile} | ckfmt +pnmpad ${size} -color ${BLACK} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${BLACK} -promote format ${infile} | ckfmt + +pnmpad ${size} -color ${WHITE} ${infile} | ckfmt +pnmpad ${size} -color ${WHITE} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${WHITE} -promote format ${infile} | ckfmt + +pnmpad ${size} -color ${LIGHTGRAY} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${LIGHTGRAY} -promote format ${infile} | ckfmt + +pnmpad ${size} -color ${DARKGRAY} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${DARKGRAY} -promote format ${infile} | ckfmt + +pnmpad ${size} -color ${PURPLE} -promote none ${infile} | ckfmt + +echo "Should print: PGM raw, 8 by 1 maxval 255 four times" + +pnmpad ${size} -color ${LIGHTGRAY} ${infile} | ckfmt +pnmpad ${size} -color ${LIGHTGRAY} -promote all ${infile} | ckfmt +pnmpad ${size} -color ${DARKGRAY} ${infile} | ckfmt +pnmpad ${size} -color ${DARKGRAY} -promote all ${infile} | ckfmt + +echo "Should print: PPM raw, 8 by 1 maxval 127 once" + +pnmpad ${size} -color ${PURPLE} -promote format ${infile} | ckfmt + +echo "Should print: PPM raw, 8 by 1 maxval 255 twice" + +pnmpad ${size} -color ${PURPLE} ${infile} | ckfmt +pnmpad ${size} -color ${PURPLE} -promote all ${infile} | ckfmt + +rm ${infile} + +echo +echo "Test 3. PGM maxval 255 infile" + +infile=${test255_pgm} + +echo "Should print: PGM raw, 8 by 1 maxval 255 eighteen times" + +pnmpad ${size} ${infile} | ckfmt +pnmpad ${size} -black ${infile} | ckfmt +pnmpad ${size} -white ${infile} | ckfmt +pnmpad ${size} -extend-edge ${infile} | ckfmt +pnmpad ${size} -detect-background ${infile} | ckfmt + +pnmpad ${size} -color ${BLACK} ${infile} | ckfmt +pnmpad ${size} -color ${BLACK} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${BLACK} -promote format ${infile} | ckfmt +pnmpad ${size} -color ${BLACK} -promote all ${infile} | ckfmt + +pnmpad ${size} -color ${LIGHTGRAY} ${infile} | ckfmt +pnmpad ${size} -color ${LIGHTGRAY} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${LIGHTGRAY} -promote format ${infile} | ckfmt +pnmpad ${size} -color ${LIGHTGRAY} -promote all ${infile} | ckfmt + + +pnmpad ${size} -color ${DARKGRAY} ${infile} | ckfmt +pnmpad ${size} -color ${DARKGRAY} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${DARKGRAY} -promote format ${infile} | ckfmt +pnmpad ${size} -color ${DARKGRAY} -promote all ${infile} | ckfmt + +pnmpad ${size} -color ${PURPLE} -promote none ${infile} | ckfmt + +echo "Should print: PPM raw, 8 by 1 maxval 255 three times" + +pnmpad ${size} -color ${PURPLE} ${infile} | ckfmt + +pnmpad ${size} -color ${PURPLE} -promote format ${infile} | ckfmt +pnmpad ${size} -color ${PURPLE} -promote all ${infile} | ckfmt + +rm ${infile} + +echo +echo "Test 4. PPM maxval 127 infile" + +infile=${test127_ppm} + +echo "Should print: PPM raw, 8 by 1 maxval 127 seventeen times" + +pnmpad ${size} ${infile} | ckfmt +pnmpad ${size} -black ${infile} | ckfmt +pnmpad ${size} -white ${infile} | ckfmt +pnmpad ${size} -extend-edge ${infile} | ckfmt +pnmpad ${size} -detect-background ${infile} | ckfmt + +pnmpad ${size} -color ${BLACK} ${infile} | ckfmt +pnmpad ${size} -color ${BLACK} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${BLACK} -promote format ${infile} | ckfmt +pnmpad ${size} -color ${WHITE} ${infile} | ckfmt +pnmpad ${size} -color ${WHITE} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${WHITE} -promote format ${infile} | ckfmt + +pnmpad ${size} -color ${LIGHTGRAY} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${LIGHTGRAY} -promote format ${infile} | ckfmt +pnmpad ${size} -color ${DARKGRAY} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${DARKGRAY} -promote format ${infile} | ckfmt + +pnmpad ${size} -color ${PURPLE} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${PURPLE} -promote format ${infile} | ckfmt + +echo "Should print: PPM raw, 8 by 1 maxval 255 five times" + +pnmpad ${size} -color ${LIGHTGRAY} ${infile} | ckfmt +pnmpad ${size} -color ${DARKGRAY} ${infile} | ckfmt +pnmpad ${size} -color ${PURPLE} ${infile} | ckfmt +pnmpad ${size} -color ${LIGHTGRAY} -promote all ${infile} | ckfmt +pnmpad ${size} -color ${PURPLE} -promote all ${infile} | ckfmt + +rm ${infile} + +echo +echo "Test 5. PPM maxval 511 infile" + +infile=${test511_ppm} + +echo "Should print: PPM raw, 8 by 1 maxval 511 twenty-five times" + +pnmpad ${size} ${infile} | ckfmt +pnmpad ${size} -black ${infile} | ckfmt +pnmpad ${size} -white ${infile} | ckfmt +pnmpad ${size} -extend-edge ${infile} | ckfmt +pnmpad ${size} -detect-background ${infile} | ckfmt + +pnmpad ${size} -color ${BLACK} ${infile} | ckfmt +pnmpad ${size} -color ${BLACK} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${BLACK} -promote format ${infile} | ckfmt +pnmpad ${size} -color ${BLACK} -promote all ${infile} | ckfmt + +pnmpad ${size} -color ${WHITE} ${infile} | ckfmt +pnmpad ${size} -color ${WHITE} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${WHITE} -promote format ${infile} | ckfmt +pnmpad ${size} -color ${WHITE} -promote all ${infile} | ckfmt + +pnmpad ${size} -color ${LIGHTGRAY} ${infile} | ckfmt +pnmpad ${size} -color ${LIGHTGRAY} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${LIGHTGRAY} -promote format ${infile} | ckfmt +pnmpad ${size} -color ${LIGHTGRAY} -promote all ${infile} | ckfmt + +pnmpad ${size} -color ${DARKGRAY} ${infile} | ckfmt +pnmpad ${size} -color ${DARKGRAY} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${DARKGRAY} -promote format ${infile} | ckfmt +pnmpad ${size} -color ${DARKGRAY} -promote all ${infile} | ckfmt + +pnmpad ${size} -color ${PURPLE} ${infile} | ckfmt +pnmpad ${size} -color ${PURPLE} -promote none ${infile} | ckfmt +pnmpad ${size} -color ${PURPLE} -promote format ${infile} | ckfmt +pnmpad ${size} -color ${PURPLE} -promote all ${infile} | ckfmt + +rm ${infile} diff --git a/test/pnmpad-pnmmargin.ok b/test/pnmpad-pnmmargin.ok new file mode 100644 index 00000000..552c530f --- /dev/null +++ b/test/pnmpad-pnmmargin.ok @@ -0,0 +1,15 @@ +Test 1. Should print match three times +match +match +match +Test 2. Should print match four times +match +match +match +match +Test 3. Should print match five times +match +match +match +match +match diff --git a/test/pnmpad-pnmmargin.test b/test/pnmpad-pnmmargin.test new file mode 100755 index 00000000..8b23be35 --- /dev/null +++ b/test/pnmpad-pnmmargin.test @@ -0,0 +1,79 @@ +#! /bin/sh +# This script tests: pnmpad pnmmargin +# Also requires: pamcat pamcut pamenlarge pbmmake pnmmargin ppmmake ppmpat + +tmpdir=${tmpdir:-/tmp} +padded_pbm=${tmpdir}/padded.pbm +argyle_ppm=${tmpdir}/argyle.ppm +padded_ppm=${tmpdir}/padded.ppm + +spacer_pnm=${tmpdir}/spacer.pnm + +# define function +addmargin () { + +# This function takes 3 positional parameters: +# $1: color black white or gofigure +# $2: color string (ignore if black white or gofigure) +# $3: margin +# $4: filename + + case $1 in + -color) ppmmake $2 $3 $3 > ${spacer_pnm}; infile=$4 ;; + -black) pbmmake -black $2 $2 > ${spacer_pnm}; infile=$3 ;; + -white) pbmmake -white $2 $2 > ${spacer_pnm}; infile=$3 ;; + *) pamcut -t 0 -l 0 -w 1 -h 1 $2 | pamenlarge $1 > ${spacer_pnm}; infile=$2 ;; + esac + pamcat -lr ${spacer_pnm} ${infile} ${spacer_pnm} |\ + pamcat -tb ${spacer_pnm} - ${spacer_pnm} + rm ${spacer_pnm} +} + +echo "Test 1. Should print match three times" + +pnmmargin -black 5 maze.pbm > ${padded_pbm} +pnmmargin -black 1 maze.pbm | pnmpad -black -t 4 -b 4 -l 4 -r 4 |\ + cmp -s ${padded_pbm} - && echo "match" || echo "no match" +pnmmargin 1 maze.pbm | pnmpad -black -t 4 -b 4 -l 4 -r 4 |\ + cmp -s ${padded_pbm} - && echo "match" || echo "no match" +pnmmargin -black 1 maze.pbm | pnmpad -extend-edge -t 4 -b 4 -l 4 -r 4 |\ + cmp -s ${padded_pbm} - && echo "match" || echo "no match" + + +echo "Test 2. Should print match four times" + +addmargin -black 5 maze.pbm |\ + cmp -s ${padded_pbm} - && echo "match" || echo "no match" +addmargin -black 1 maze.pbm | pnmpad -black -t 4 -b 4 -l 4 -r 4 |\ + cmp -s ${padded_pbm} - && echo "match" || echo "no match" +addmargin 1 maze.pbm | pnmpad -black -t 4 -b 4 -l 4 -r 4 |\ + cmp -s ${padded_pbm} - && echo "match" || echo "no match" +addmargin -black 1 maze.pbm | pnmpad -extend-edge -t 4 -b 4 -l 4 -r 4 |\ + cmp -s ${padded_pbm} - && echo "match" || echo "no match" + +rm ${padded_pbm} + +echo "Test 3. Should print match five times" + +ppmpat -argyle1 -color=rgb:20/30/ff,rgb:70/80/ff 30 20 > ${argyle_ppm} + +addmargin 3 ${argyle_ppm} > ${padded_ppm} + +addmargin -color rgb:20/30/ff 1 ${argyle_ppm} |\ + pnmpad -color=rgb:20/30/ff -t 2 -b 2 -r 2 -l 2 |\ + cmp -s ${padded_ppm} - && echo "match" || echo "no match" +addmargin -color rgb:20/30/ff 1 ${argyle_ppm} |\ + pnmpad -color=rgb:20/30/ff -t 2 -b 2 -r 2 -l 2 |\ + cmp -s ${padded_ppm} - && echo "match" || echo "no match" +addmargin 1 ${argyle_ppm} |\ + pnmpad -extend-edge -t 2 -b 2 -r 2 -l 2 |\ + cmp -s ${padded_ppm} - && echo "match" || echo "no match" + +pnmpad -color rgb:20/30/ff -t 3 -b 3 -r 3 -l 3 ${argyle_ppm} |\ + cmp -s ${padded_ppm} - && echo "match" || echo "no match" + +pnmpad -detect-background -t 3 -b 3 -r 3 -l 3 ${argyle_ppm} |\ + cmp -s ${padded_ppm} - && echo "match" || echo "no match" + + +rm ${argyle_ppm} ${padded_ppm} diff --git a/test/pnmpad-reportonly.ok b/test/pnmpad-reportonly.ok new file mode 100644 index 00000000..2cf58f39 --- /dev/null +++ b/test/pnmpad-reportonly.ok @@ -0,0 +1,75 @@ +Test 1. Should print 0 0 0 0 227 149 six times +0 0 0 0 227 149 +0 0 0 0 227 149 +0 0 0 0 227 149 +0 0 0 0 227 149 +0 0 0 0 227 149 +0 0 0 0 227 149 +Test 2. Should print 10 0 0 0 110 17 seven times +10 0 0 0 110 17 +10 0 0 0 110 17 +10 0 0 0 110 17 +10 0 0 0 110 17 +10 0 0 0 110 17 +10 0 0 0 110 17 +10 0 0 0 110 17 +Test 3. Should print 0 10 0 0 110 19 eight times +0 10 0 0 110 19 +0 10 0 0 110 19 +0 10 0 0 110 19 +0 10 0 0 110 19 +0 10 0 0 110 19 +0 10 0 0 110 19 +0 10 0 0 110 19 +0 10 0 0 110 19 +Test 4. Should print 10 10 0 0 120 19 four times +10 10 0 0 120 19 +10 10 0 0 120 19 +10 10 0 0 120 19 +10 10 0 0 120 19 +Test 5. Should print 0 0 10 0 27 110 seven times +0 0 10 0 27 110 +0 0 10 0 27 110 +0 0 10 0 27 110 +0 0 10 0 27 110 +0 0 10 0 27 110 +0 0 10 0 27 110 +0 0 10 0 27 110 +Test 6. Should print 0 0 0 10 19 110 eight times +0 0 0 10 19 110 +0 0 0 10 19 110 +0 0 0 10 19 110 +0 0 0 10 19 110 +0 0 0 10 19 110 +0 0 0 10 19 110 +0 0 0 10 19 110 +0 0 0 10 19 110 +Test 7. Should print 0 0 12 12 27 124 four times +0 0 12 12 27 124 +0 0 12 12 27 124 +0 0 12 12 27 124 +0 0 12 12 27 124 +Test 8. Should print 5 10 0 0 115 17 seven times +5 10 0 0 115 17 +5 10 0 0 115 17 +5 10 0 0 115 17 +5 10 0 0 115 17 +5 10 0 0 115 17 +5 10 0 0 115 17 +5 10 0 0 115 17 +Test 9. Should print 0 0 4 8 19 112 seven times +0 0 4 8 19 112 +0 0 4 8 19 112 +0 0 4 8 19 112 +0 0 4 8 19 112 +0 0 4 8 19 112 +0 0 4 8 19 112 +0 0 4 8 19 112 +Test Invalid +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) +Expected failure 5 (no output) +Expected failure 6 (no output) +Expected failure 7 (no output) diff --git a/test/pnmpad-reportonly.test b/test/pnmpad-reportonly.test new file mode 100755 index 00000000..412cb8a2 --- /dev/null +++ b/test/pnmpad-reportonly.test @@ -0,0 +1,158 @@ +#! /bin/sh +# This script tests: pnmpad +# Also requires: pbmmake pgmmake ppmmake pamfile + +tmpdir=${tmpdir:-/tmp} + +test1_pbm=${tmpdir}/test1.pbm +test2_pbm=${tmpdir}/test2.pbm +test_pgm=${tmpdir}/test.pgm +test_ppm=${tmpdir}/test.ppm + +testimg_size=$(pamfile -size testimg.ppm) + +echo "Test 1. Should print 0 0 0 0 ${testimg_size} six times" + +for pad in "" "-left=0" "-right=0" "-top=0" "-bottom=0" \ + "-left=0 -right=0 -top=0 -bottom=0" + do + pnmpad -reportonly ${pad} testimg.ppm || echo "failure" + done + + +echo "Test 2. Should print 10 0 0 0 110 17 seven times" + +pbmmake -w 100 17 > ${test1_pbm} +for pad in "-left=10" \ + "-left=10 -right=0" \ + "-left=10 -width=90" \ + "-left=10 -width=105" \ + "-left=10 -width=110" \ + "-right=0 -width=110" \ + "-halign=1.0 -width=110" + do + pnmpad -reportonly ${pad} ${test1_pbm} || echo "failure" + done + + +echo "Test 3. Should print 0 10 0 0 110 19 eight times" +pgmmake 0.5 100 19 > ${test_pgm} +for pad in "-right=10" \ + "-right=10 -left=0" \ + "-right=10 -width=90" \ + "-right=10 -width=105" \ + "-right=10 -width=110" \ + "-left=0 -width=110" \ + "-halign=0.0 -width=110" \ + "-right=1 -mwidth=11" + do + pnmpad -reportonly ${pad} ${test_pgm} || echo "failure" + done + + +echo "Test 4. Should print 10 10 0 0 120 19 four times" +for pad in "-left=10 -right=10" \ + "-right=10 -width=120" \ + "-halign=0.5 -width=120" \ + "-left=1 -right=1 -mwidth=30" + do + pnmpad -reportonly ${pad} ${test_pgm} || echo "failure" + done + + +echo "Test 5. Should print 0 0 10 0 27 110 seven times" + +pbmmake -w 27 100 > ${test2_pbm} +for pad in "-top=10" \ + "-top=10 -bottom=0" \ + "-top=10 -height=50" \ + "-top=10 -height=101" \ + "-top=10 -height=110" \ + "-bottom=0 -height=110" \ + "-valign=1.0 -height=110" + do + pnmpad -reportonly ${pad} ${test2_pbm} || echo "failure" + done + + +echo "Test 6. Should print 0 0 0 10 19 110 eight times" +ppmmake rgb:33/44/55 19 100 > ${test_ppm} +for pad in "-bottom=10" \ + "-bottom=10 -top=0" \ + "-bottom=10 -height=10" \ + "-bottom=10 -height=107" \ + "-bottom=10 -height=110" \ + "-top=0 -height=110" \ + "-valign=0.0 -height=110" \ + "-bottom=1 -mheight=10" + do + pnmpad -reportonly ${pad} ${test_ppm} || echo "failure" + done + + +echo "Test 7. Should print 0 0 12 12 27 124 four times" +for pad in "-top=12 -bottom=12" \ + "-top=12 -height=124" \ + "-valign=0.5 -height=124" \ + "-top=11 -bottom=11 -mheight=4" + do + pnmpad -reportonly ${pad} ${test2_pbm} || echo "failure" + done + + +echo "Test 8. Should print 5 10 0 0 115 17 seven times" +for pad in "-l 5 -r 10 -w 115" \ + "-l 5 -w 115" \ + " -r 10 -w 115" \ + "-l 5 -r 10 " \ + "-halign 0.333 -w 115 " \ + "-l 2 -r 4 -mw 23" \ + "-halign 0.333 -mw 23" + do + pnmpad -reportonly ${pad} ${test1_pbm} || echo "failure" + done + + +echo "Test 9. Should print 0 0 4 8 19 112 seven times" +for pad in "-t 4 -b 8 -h 112" \ + "-t 4 -h 112" \ + " -b 8 -h 112" \ + "-t 4 -b 8 " \ + "-t 4 -b 8 -mh 14" \ + "-valign 0.333 -mh 14" \ + "-valign 0.333 -h 112" + do + pnmpad -reportonly ${pad} ${test_ppm} || echo "failure" + done + +echo "Test Invalid" + +test_out=${tmpdir}/test_out +n=1 + +# define function +invcmd () { $1 > ${test_out} || \ + printf "Expected failure $n " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + n=$(($n +1)); } + +echo 1>&2 +echo "Invalid command-line arguments." 1>&2 +echo "Error messages should appear below the line." 1>&2 +echo "-----------------------------------------------------------" 1>&2 + +invcmd "pnmpad -reportonly -l 1 -r 1 -w 100 testgrid.pbm" +invcmd "pnmpad -reportonly -t 1 -b 1 -h 100 testgrid.pbm" +invcmd "pnmpad -reportonly -black -white -l 1 testgrid.pbm" +invcmd "pnmpad -reportonly -color -l 1 testgrid.pbm" +invcmd "pnmpad -reportonly -color rgbi:0/0/0 -white -l 1 testgrid.pbm" +invcmd "pnmpad -reportonly -color rgbi:0/0/0 -extend-edge -l 1 testgrid.pbm" +invcmd "pnmpad -reportonly -color rgbi:0/0/0 -detect-background -l 1 testgrid.pbm" + +# echo "Test Invalid. Should print failure twice" +# +# pnmpad -reportonly -l 1 -r 1 -w 100 testgrid.pbm && echo "unexpected success" || echo "failure" +# pnmpad -reportonly -t 1 -b 1 -h 100 testgrid.pbm && echo "unexpected success" || echo "failure" +# +rm ${test1_pbm} ${test2_pbm} ${test_pgm} ${test_ppm} diff --git a/test/pnmpaste-pbm.test b/test/pnmpaste-pbm.test index b75797af..70f2b266 100755 --- a/test/pnmpaste-pbm.test +++ b/test/pnmpaste-pbm.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pnmpaste # Also requires: pbmmake diff --git a/test/pnmpsnr.ok b/test/pnmpsnr.ok index 7042f86c..38bed0f3 100644 --- a/test/pnmpsnr.ok +++ b/test/pnmpsnr.ok @@ -8,7 +8,7 @@ Test 2 match match Test Invalid -Expected failure 1 1 -Expected failure 2 1 -Expected failure 3 1 -Expected failure 4 1 +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) diff --git a/test/pnmpsnr.test b/test/pnmpsnr.test index 7603459b..6ea05aed 100755 --- a/test/pnmpsnr.test +++ b/test/pnmpsnr.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pnmpsnr # Also requires: pbmmake @@ -27,21 +27,11 @@ pnmpsnr testimg.ppm testimg.ppm -target1=1000 -target2=1000 -target3=1000 echo "Test Invalid" -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 - -pnmpsnr ${b_pbm} ${w_pbm} ${b_pbm} > ${test_out} || \ - echo -n "Expected failure 1"; test -s ${test_out}; echo " "$? -pnmpsnr ${b_pbm} > ${test_out} || \ - echo -n "Expected failure 2"; test -s ${test_out}; echo " "$? -pnmpsnr ${b_pbm} ${w_pbm} -target1=100 > ${test_out} || \ - echo -n "Expected failure 3"; test -s ${test_out}; echo " "$? -pnmpsnr -machine > ${test_out} || \ - echo -n "Expected failure 4"; test -s ${test_out}; echo " "$? - -rm ${b_pbm} ${w_pbm} ${test_out} +. ${srcdir}/test-invalid.inc + +invCmd "pnmpsnr ${b_pbm} ${w_pbm} ${b_pbm} " +invCmd "pnmpsnr ${b_pbm} " +invCmd "pnmpsnr ${b_pbm} ${w_pbm} -target1=100" +invCmd "pnmpsnr -machine " + +rm ${b_pbm} ${w_pbm} diff --git a/test/pnmquant.ok b/test/pnmquant.ok index 407d42a3..f4229601 100644 --- a/test/pnmquant.ok +++ b/test/pnmquant.ok @@ -8,11 +8,11 @@ Test 1 1 1 1 1 Test Invalid -Expected failure 1 1 -Expected failure 2 1 -Expected failure 3 1 -Expected failure 4 1 -Expected failure 5 1 -Expected failure 6 1 -Expected failure 7 1 -Expected failure 8 1 +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) +Expected failure 5 (no output) +Expected failure 6 (no output) +Expected failure 7 (no output) +Expected failure 8 (no output) diff --git a/test/pnmquant.test b/test/pnmquant.test index 3a2ef906..4baff9a8 100755 --- a/test/pnmquant.test +++ b/test/pnmquant.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pnmquant # Also requires: ppmhist @@ -7,30 +7,30 @@ echo "Test 1" # Count colors in output image. pnmquant 256 testimg.ppm | ppmhist | \ - awk 'NR==1 {print ($2 <= 256) , ($2 > 256 * 0.95)}' + awk 'NR==1 {print ($2 <= 256) , ($2 > 256 * 0.95)}' pnmquant -center 256 testimg.ppm | ppmhist | \ - awk 'NR==1 {print ($2 <= 256) , ($2 > 256 * 0.95)}' + awk 'NR==1 {print ($2 <= 256) , ($2 > 256 * 0.95)}' pnmquant -spreadbrightness 256 testimg.ppm | ppmhist | \ - awk 'NR==1 {print ($2 <= 256) , ($2 > 256 * 0.95)}' + awk 'NR==1 {print ($2 <= 256) , ($2 > 256 * 0.95)}' pnmquant -spreadluminosity 128 testimg.ppm | ppmhist | \ - awk 'NR==1 {print ($2 <= 128) , ($2 > 128 * 0.95)}' + awk 'NR==1 {print ($2 <= 128) , ($2 > 128 * 0.95)}' pnmquant -floyd -randomseed=0 128 testimg.ppm | ppmhist | \ - awk 'NR==1 {print ($2 <= 128) , ($2 > 128 * 0.95)}' + awk 'NR==1 {print ($2 <= 128) , ($2 > 128 * 0.95)}' pnmquant 64 -meanpixel testimg.ppm | ppmhist | \ - awk 'NR==1 {print ($2 <= 64) , ($2 > 64 * 0.9)}' + awk 'NR==1 {print ($2 <= 64) , ($2 > 64 * 0.9)}' pnmquant 16 -meancolor testimg.ppm | ppmhist | \ - awk 'NR==1 {print ($2 <= 16) , ($2 > 16 * 0.9)}' + awk 'NR==1 {print ($2 <= 16) , ($2 > 16 * 0.9)}' pnmquant 2 testgrid.pbm | ppmhist | \ - awk 'NR==1 {print ($2 <= 2) , ($2 == 2) }' - + awk 'NR==1 {print ($2 <= 2) , ($2 == 2) }' + echo "Test Invalid" echo 1>&2 @@ -42,20 +42,41 @@ tmpdir=${tmpdir:-/tmp} test_out=${tmpdir}/test_out pnmquant 0 testimg.ppm > ${test_out} || \ - echo -n "Expected failure 1"; test -s ${test_out}; echo " "$? + printf "Expected failure 1 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + pnmquant testimg.ppm > ${test_out} || \ - echo -n "Expected failure 2"; test -s ${test_out}; echo " "$? + printf "Expected failure 2 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + pnmquant 10.5 testimg.ppm > ${test_out} || \ - echo -n "Expected failure 3"; test -s ${test_out}; echo " "$? + printf "Expected failure 3 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + pnmquant -center -meancolor 16 testimg.ppm > ${test_out} || \ - echo -n "Expected failure 4"; test -s ${test_out}; echo " "$? + printf "Expected failure 4 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + pnmquant -center -meanpixel 16 testimg.ppm > ${test_out} || \ - echo -n "Expected failure 5"; test -s ${test_out}; echo " "$? + printf "Expected failure 5 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + pnmquant -meancolor -meanpixel 16 testimg.ppm > ${test_out} || \ - echo -n "Expected failure 6"; test -s ${test_out}; echo " "$? + printf "Expected failure 6 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + pnmquant -spreadbrightness -spreadluminosity 16 testimg.ppm > ${test_out} || \ - echo -n "Expected failure 7"; test -s ${test_out}; echo " "$? -pnmquant -randomseed 1 -norandom 10 testimg.ppm > ${test_out} || \ - echo -n "Expected failure 8"; test -s ${test_out}; echo " "$? + printf "Expected failure 7 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} -rm ${test_out} +pnmquant -randomseed 1 -norandom 10 testimg.ppm > ${test_out} || \ + printf "Expected failure 8 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} diff --git a/test/pnmquantall.ok b/test/pnmquantall.ok index 5885d370..c7563d88 100644 --- a/test/pnmquantall.ok +++ b/test/pnmquantall.ok @@ -1,7 +1,14 @@ +Test 1. 2373957371 33838 3892560659 33838 1383839923 33838 -1 +color count 20: success +Test 2. +452076937 33838 +452076937 33838 +452076937 33838 +color count 1: success +Test Invalid Expected failure 1 Expected failure 1.rm Expected failure 2 diff --git a/test/pnmquantall.test b/test/pnmquantall.test index 4c1bb77f..7910d0fc 100755 --- a/test/pnmquantall.test +++ b/test/pnmquantall.test @@ -1,47 +1,71 @@ -#! /bin/bash +#! /bin/sh # This script tests: pnmquantall -# Also requires: ppmtorgb3 pgmhist pnmcat +# Also requires: ppmtorgb3 pgmhist pamcat tmpdir=${tmpdir:-/tmp} -test_ppm=${tmpdir}/testimg.ppm +rose_ppm=${tmpdir}/rose.ppm -cp testimg.ppm ${tmpdir} && -ppmtorgb3 ${test_ppm} +cp testimg.ppm ${rose_ppm} && +ppmtorgb3 ${rose_ppm} -test_red=${tmpdir}/testimg.red -test_grn=${tmpdir}/testimg.grn -test_blu=${tmpdir}/testimg.blu +rose_red=${tmpdir}/rose.red +rose_grn=${tmpdir}/rose.grn +rose_blu=${tmpdir}/rose.blu -pnmquantall 20 ${test_red} ${test_grn} ${test_blu} +cp ${rose_red} ${rose_red}.1 +cp ${rose_grn} ${rose_grn}.1 +cp ${rose_blu} ${rose_blu}.1 -for i in ${test_red} ${test_grn} ${test_blu} +echo "Test 1." + +pnmquantall 20 ${rose_red}.1 ${rose_grn}.1 ${rose_blu}.1 + +for i in ${rose_red}.1 ${rose_grn}.1 ${rose_blu}.1 do cat $i | cksum done -# Should print 1 +pamcat ${rose_red}.1 ${rose_grn}.1 ${rose_blu}.1 -tb | \ + pgmhist -m |\ + awk '$2>0 {s++}; + END { printf("color count %u: %s\n", s, + (s==20) ? "success" : "failure") }' -pnmcat ${test_red} ${test_grn} ${test_blu} -tb | \ - pgmhist -m | awk '$2>0 {s++}; END { print (s<=20) }' +rm ${rose_red}.1 ${rose_grn}.1 ${rose_blu}.1 +echo "Test 2." -tmpdir=${tmpdir:-/tmp} -test_out=${tmpdir}/test_out +pnmquantall -ext .2 1 ${rose_red} ${rose_grn} ${rose_blu} + +for i in ${rose_red}.2 ${rose_grn}.2 ${rose_blu}.2 +do +cat $i | cksum +done + +pamcat ${rose_red}.2 ${rose_grn}.2 ${rose_blu}.2 -tb | \ + pgmhist -m |\ + awk '$2>0 {s++}; + END { printf("color count %u: %s\n", s, + (s==1) ? "success" : "failure") }' + +rm ${rose_red}.2 ${rose_grn}.2 ${rose_blu}.2 + +echo "Test Invalid" echo 1>&2 echo "Invalid command-line argument combinations." 1>&2 echo "Error messages should appear below the line." 1>&2 echo "-----------------------------------------------------------" 1>&2 -pnmquantall -ext xx 0 ${test_red} ${test_grn} ${test_blu} || \ +pnmquantall -ext xx 0 ${rose_red} ${rose_grn} ${rose_blu} || \ echo "Expected failure 1" -rm ${test_red}xx ${test_grn}xx ${test_blu}xx || \ +rm ${rose_red}xx ${rose_grn}xx ${rose_blu}xx || \ echo "Expected failure 1.rm" -pnmquantall -ext xx 1 ${test_red} ${test_grn} ${test_blu} || \ +pnmquantall -ext yy ${rose_red} ${rose_grn} ${rose_blu} || \ echo "Expected failure 2" -rm ${test_red}xx ${test_grn}xx ${test_blu}xx || \ +rm ${rose_red}yy ${rose_grn}yy ${rose_blu}yy || \ echo "Expected failure 2.rm" -pnmquantall -ext xx 2 || \ +pnmquantall -ext zz 2 || \ echo "Expected failure 3" -rm ${test_red} ${test_grn} ${test_blu} ${test_ppm} \ No newline at end of file +rm ${rose_red} ${rose_grn} ${rose_blu} ${rose_ppm} diff --git a/test/pnmremap1.ok b/test/pnmremap1.ok index 23a9dddd..0f511754 100644 --- a/test/pnmremap1.ok +++ b/test/pnmremap1.ok @@ -1,7 +1,7 @@ 3602410851 101482 -Expected failure 1 1 -Expected failure 2 1 -Expected failure 3 1 -Expected failure 4 1 -Expected failure 5 1 -Expected failure 6 1 +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) +Expected failure 5 (no output) +Expected failure 6 (no output) diff --git a/test/pnmremap1.test b/test/pnmremap1.test index 18debcb8..9c60460b 100755 --- a/test/pnmremap1.test +++ b/test/pnmremap1.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pnmremap # Also requires: pamseq pamtopnm @@ -33,17 +33,32 @@ tmpdir=${tmpdir:-/tmp} test_out=${tmpdir}/test_out pnmremap -mapfile=/dev/null testimg.ppm > ${test_out} || \ - echo -n "Expected failure 1"; test -s ${test_out}; echo " "$? + printf "Expected failure 1 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + pnmremap -mapfile=/dev/zero testimg.ppm > ${test_out} || \ - echo -n "Expected failure 2"; test -s ${test_out}; echo " "$? + printf "Expected failure 2 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + pnmremap testimg.ppm > ${test_out} || \ - echo -n "Expected failure 3"; test -s ${test_out}; echo " "$? + printf "Expected failure 3 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + pnmremap -fs -nofs testimg.ppm > ${test_out} || \ - echo -n "Expected failure 4"; test -s ${test_out}; echo " "$? + printf "Expected failure 4 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + pnmremap -mapfile=testgrid.pbm -missingcolor=rgb:00/ff/00 testimg.ppm \ > ${test_out} || \ - echo -n "Expected failure 5"; test -s ${test_out}; echo " "$? -pnmremap -mapfile=testgrid.pbm -firstisdefault testimg.ppm > ${test_out} || \ - echo -n "Expected failure 6"; test -s ${test_out}; echo " "$? + printf "Expected failure 5 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} -rm ${test_out} +pnmremap -mapfile=testgrid.pbm -firstisdefault testimg.ppm > ${test_out} || \ + printf "Expected failure 6 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} diff --git a/test/pnmremap2.test b/test/pnmremap2.test index 76c2d566..7eea2c4a 100755 --- a/test/pnmremap2.test +++ b/test/pnmremap2.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pnmremap # Also requires: pamdepth pamseq pamtopnm diff --git a/test/pnmshear.test b/test/pnmshear.test index a19a9852..42e5c816 100755 --- a/test/pnmshear.test +++ b/test/pnmshear.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pnmshear # Also requires: pbmmake pnmpad diff --git a/test/pnmtile.ok b/test/pnmtile.ok index 279251b8..572893df 100644 --- a/test/pnmtile.ok +++ b/test/pnmtile.ok @@ -1,6 +1,6 @@ 4228632379 259 -0 0 : 0 -Expected failure 1 1 -Expected failure 2 1 -Expected failure 3 1 -Expected failure 4 1 +0 0 0 : 0 +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) diff --git a/test/pnmtile.test b/test/pnmtile.test index 11f576bd..35addbec 100755 --- a/test/pnmtile.test +++ b/test/pnmtile.test @@ -1,6 +1,6 @@ #! /bin/bash # This script tests: pnmtile -# Also requires: pnmcat +# Also requires: pamcat # Test 1. Should print 4228632379 259 @@ -8,36 +8,22 @@ pnmtile 40 50 testgrid.pbm | cksum tmpdir=${tmpdir:-/tmp} -# Test 2. Compare 2x2 tile images produced by pnmtile and pnmcat +# Test 2. Compare 2x2 tile images produced by pnmtile and pamcat # Should print 0 testimg2_ppm=${tmpdir}/testimg2.ppm testimg4_ppm=${tmpdir}/testimg4.ppm pnmtile 454 298 testimg.ppm > ${testimg4_ppm} && -pnmcat -lr testimg.ppm testimg.ppm > ${testimg2_ppm} && -pnmcat -tb ${testimg2_ppm} ${testimg2_ppm} | \ +pamcat -lr testimg.ppm testimg.ppm > ${testimg2_ppm} && +pamcat -tb ${testimg2_ppm} ${testimg2_ppm} | pamtopnm --assume |\ cmp -s - ${testimg4_ppm} echo ${PIPESTATUS[@]} ":" $? rm ${testimg2_ppm} ${testimg4_ppm} -test_out=${tmpdir}/test_out +. ${srcdir}/test-invalid.inc -echo 1>&2 -echo "Invalid command-line argument combinations." 1>&2 -echo "Error messages should appear below the line." 1>&2 -echo "-----------------------------------------------------------" 1>&2 - -pnmtile 100 testgrid.pbm > ${test_out} || \ - echo -n "Expected failure 1"; test -s ${test_out}; echo " "$? - -pnmtile 100 0 testgrid.pbm > ${test_out} || \ - echo -n "Expected failure 2"; test -s ${test_out}; echo " "$? - -pnmtile 0 100 testgrid.pbm > ${test_out} || \ - echo -n "Expected failure 3"; test -s ${test_out}; echo " "$? - -pnmtile 100 100 100 testgrid.pbm > ${test_out} || \ - echo -n "Expected failure 4"; test -s ${test_out}; echo " "$? - -rm -f ${test_out} \ No newline at end of file +invCmd "pnmtile 100 testgrid.pbm" +invCmd "pnmtile 100 0 testgrid.pbm" +invCmd "pnmtile 0 100 testgrid.pbm" +invCmd "pnmtile 100 100 100 testgrid.pbm" diff --git a/test/pnmtojpeg-scans.ok b/test/pnmtojpeg-scans.ok new file mode 100644 index 00000000..089dfebf --- /dev/null +++ b/test/pnmtojpeg-scans.ok @@ -0,0 +1,20 @@ +success +pnmtojpeg: Input file has format P6. +It has 149 rows of 227 columns of pixels with max sample value of 255. +pnmtojpeg: A scan script with 7 entries is being used: +pnmtojpeg: Scan 0: Ss= 0 Se= 0 Ah= 0 Al= 0 3 components +pnmtojpeg: Color component 0 index: 0 +pnmtojpeg: Color component 1 index: 1 +pnmtojpeg: Color component 2 index: 2 +pnmtojpeg: Scan 1: Ss= 1 Se= 2 Ah= 0 Al= 0 1 components +pnmtojpeg: Color component 0 index: 0 +pnmtojpeg: Scan 2: Ss= 3 Se= 5 Ah= 0 Al= 0 1 components +pnmtojpeg: Color component 0 index: 0 +pnmtojpeg: Scan 3: Ss= 1 Se=63 Ah= 0 Al= 0 1 components +pnmtojpeg: Color component 0 index: 1 +pnmtojpeg: Scan 4: Ss= 1 Se=63 Ah= 0 Al= 0 1 components +pnmtojpeg: Color component 0 index: 2 +pnmtojpeg: Scan 5: Ss= 6 Se= 9 Ah= 0 Al= 0 1 components +pnmtojpeg: Color component 0 index: 0 +pnmtojpeg: Scan 6: Ss=10 Se=63 Ah= 0 Al= 0 1 components +pnmtojpeg: Color component 0 index: 0 diff --git a/test/pnmtojpeg-scans.test b/test/pnmtojpeg-scans.test new file mode 100755 index 00000000..ea17c8c0 --- /dev/null +++ b/test/pnmtojpeg-scans.test @@ -0,0 +1,32 @@ +#! /bin/bash +# This script tests: pnmtojpeg +# Also requires: + +tmpdir=${tmpdir:-/tmp} +test_jpegscan=${tmpdir}/test.jpegscan +err_out=${tmpdir}/err.out + +cat > ${test_jpegscan} << EOF +# This is a example of a scan script to be used by 'pnmtojpeg' with -scan . +# It should work with any color image. + +#Interleaved DC scan for Y, Cb, Cr: +0, 1, 2: 0-0, 0, 0 ; + +# AC scans: +0: 1- 2, 0, 0 ; +0: 3- 5, 0, 0 ; +1: 1-63, 0, 0 ; +2: 1-63, 0, 0 ; +0: 6- 9, 0, 0 ; +0: 10-63, 0, 0 ; +EOF + +pnmtojpeg testimg.ppm -scans=${test_jpegscan} -verbose \ + > /dev/null 2> ${err_out} && echo "success" || echo "failure" + +cat ${err_out} + +rm ${err_out} ${test_jpegscan} + +# TODO test invalid scan script diff --git a/test/pnmtopnm-plain.ok b/test/pnmtopnm-plain.ok index 02d99f1e..640f0964 100644 --- a/test/pnmtopnm-plain.ok +++ b/test/pnmtopnm-plain.ok @@ -1,48 +1,51 @@ +Test. Should print three identical images in plain format, twice each P1 -14 16 -10101010101010 -11111111111111 -10101010101010 -11111111111111 -10101010101010 -11111111111111 -10101010101010 -11111111111111 -10101010101010 -11111111111111 -10101010101010 -11111111111111 -10101010101010 -11111111111111 -10101010101010 -11111111111111 +5 5 +01010 +10101 +01010 +10101 +01010 +P1 +5 5 +01010 +10101 +01010 +10101 +01010 +P2 +8 8 +7 +0 0 1 1 2 2 3 3 +0 1 1 2 2 3 3 4 +1 1 2 2 3 3 4 4 +1 2 2 3 3 4 4 5 +2 2 3 3 4 4 5 5 +2 3 3 4 4 5 5 6 +3 3 4 4 5 5 6 6 +3 4 4 5 5 6 6 7 P2 -14 16 +8 8 +7 +0 0 1 1 2 2 3 3 +0 1 1 2 2 3 3 4 +1 1 2 2 3 3 4 4 +1 2 2 3 3 4 4 5 +2 2 3 3 4 4 5 5 +2 3 3 4 4 5 5 6 +3 3 4 4 5 5 6 6 +3 4 4 5 5 6 6 7 +P3 +4 4 255 -0 255 0 255 0 255 0 255 0 255 0 255 0 255 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 255 0 255 0 255 0 255 0 255 0 255 0 255 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 255 0 255 0 255 0 255 0 255 0 255 0 255 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 255 0 255 0 255 0 255 0 255 0 255 0 255 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 255 0 255 0 255 0 255 0 255 0 255 0 255 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 255 0 255 0 255 0 255 0 255 0 255 0 255 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 255 0 255 0 255 0 255 0 255 0 255 0 255 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 255 0 255 0 255 0 255 0 255 0 255 0 255 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 31 255 0 31 255 63 0 0 0 31 255 +0 31 255 0 31 255 0 31 255 63 0 0 +0 31 255 63 0 0 63 0 0 63 0 0 +63 0 0 0 31 255 63 0 0 63 0 0 P3 -14 16 +4 4 255 -0 0 0 255 255 255 0 0 0 255 255 255 0 0 0 255 255 255 0 0 0 255 255 255 -0 0 0 255 255 255 0 0 0 255 255 255 0 0 0 255 255 255 -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 255 255 255 0 0 0 255 255 255 0 0 0 255 255 255 0 0 0 255 255 255 -0 0 0 255 255 255 0 0 0 255 255 255 0 0 0 255 255 255 -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 31 255 0 31 255 63 0 0 0 31 255 +0 31 255 0 31 255 0 31 255 63 0 0 +0 31 255 63 0 0 63 0 0 63 0 0 +63 0 0 0 31 255 63 0 0 63 0 0 diff --git a/test/pnmtopnm-plain.test b/test/pnmtopnm-plain.test index 5b7e4b48..87b74064 100755 --- a/test/pnmtopnm-plain.test +++ b/test/pnmtopnm-plain.test @@ -1,10 +1,14 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamtopnm -# Also requires: pgmtopgm ppmtoppm +# Also requires: pbmmake pgmramp ppmpat -pamtopnm -plain testgrid.pbm +echo "Test. Should print three identical images in plain format, twice each" -pgmtopgm < testgrid.pbm | pamtopnm -plain +pbmmake -g 5 5 -plain +pbmmake -g 5 5 | pamtopnm -plain -ppmtoppm < testgrid.pbm | pamtopnm -plain | \ - head -n11 +pgmramp -maxval 7 -diag 8 8 -plain +pgmramp -maxval 7 -diag 8 8 | pamtopnm -plain + +ppmpat -g2 -color=rgb:00/1f/ff,rgb:3f/00/00 -mesh 4 4 -plain +ppmpat -g2 -color=rgb:00/1f/ff,rgb:3f/00/00 -mesh 4 4 | pamtopnm -plain diff --git a/test/ppmbrighten.ok b/test/ppmbrighten.ok index 3895dbd0..95c90d24 100644 --- a/test/ppmbrighten.ok +++ b/test/ppmbrighten.ok @@ -4,8 +4,6 @@ Test 2: Should print 295150171 101484 295150171 101484 Test 3: Should print 1 1 -Test Error: Should print 1 four times -1 -1 -1 -1 +Test Invalid +Expected failure 1 (no output) +Expected failure 2 (no output) diff --git a/test/ppmbrighten.test b/test/ppmbrighten.test index 40fe08f6..8ae1d744 100755 --- a/test/ppmbrighten.test +++ b/test/ppmbrighten.test @@ -1,6 +1,6 @@ -#! /bin/bash +#! /bin/sh # This script tests: ppmbrighten -# Also requires: pnmnorm pambrighten pamsumm +# Also requires: pnmnorm pambrighten pamsumm # Failure message ## Ppmbrighten is sensitive to subtle differences in floating point math. @@ -20,19 +20,11 @@ echo "Test 3: Should print 1" ppmbrighten -v 100 -normalize testimg.ppm | pamsumm --mean | \ awk '{print ($NF > 132.0) && ($NF < 132.2)}' -echo "Invalid command-line argument combinations." 1>&2 -echo "Error messages should appear below the line." 1>&2 -echo "-----------------------------------------------------------" 1>&2 -echo "Test Error: Should print 1 four times" +echo "Test Invalid" -output_ppm=${tmpdir}/output.ppm +. ${srcdir}/test-invalid.inc + +invCmd "pambrighten -v -120 testimg.ppm" +invCmd "pambrighten -s -120 testimg.ppm" -pambrighten -v -120 testimg.ppm > ${output_ppm} -echo $? -test -s ${output_ppm} -echo $? -pambrighten -s -120 testimg.ppm > ${output_ppm} -echo $? -test -s ${output_ppm} -echo $? diff --git a/test/ppmchange-roundtrip.ok b/test/ppmchange-roundtrip.ok index a676a1f2..4fb7d428 100644 --- a/test/ppmchange-roundtrip.ok +++ b/test/ppmchange-roundtrip.ok @@ -1,2 +1,2 @@ -2425386270 41 -2425386270 41 +281226646 481 +281226646 481 diff --git a/test/ppmchange-roundtrip.test b/test/ppmchange-roundtrip.test index 78f5b548..5bd18150 100755 --- a/test/ppmchange-roundtrip.test +++ b/test/ppmchange-roundtrip.test @@ -1,12 +1,12 @@ -#! /bin/bash +#! /bin/sh # This script tests: ppmchange # Also requires: pgmtopbm pnminvert ppmtopgm -ppmchange black white white black testgrid.pbm | \ +ppmchange black white white black maze.pbm | \ pnminvert | ppmtopgm | \ pgmtopbm -th -val=0.5 | cksum -ppmchange black white white black testgrid.pbm | \ +ppmchange black white white black maze.pbm | \ ppmchange black white white black | \ ppmtopgm | pgmtopbm -th -val=0.5 | cksum diff --git a/test/ppmchange.test b/test/ppmchange.test index a749a5d2..a579631b 100755 --- a/test/ppmchange.test +++ b/test/ppmchange.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: ppmchange # Also requires: ppmrainbow pgmramp ppmhist diff --git a/test/ppmcie.test b/test/ppmcie.test index 0ce69dea..dd7f121f 100755 --- a/test/ppmcie.test +++ b/test/ppmcie.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: ppmcie # Also requires: pamsumm pamsharpness diff --git a/test/ppmdfont.test b/test/ppmdfont.test index 7d894789..e6b461f1 100755 --- a/test/ppmdfont.test +++ b/test/ppmdfont.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: ppmdmkfont ppmddumpfont ppmdcfont # Also requires: diff --git a/test/ppmdim.test b/test/ppmdim.test index 848e2e9f..48d9e891 100755 --- a/test/ppmdim.test +++ b/test/ppmdim.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: ppmdim # Also requires: pamfunc pamarith pamsumm diff --git a/test/ppmdither.test b/test/ppmdither.test index 7e32ef59..f82c34ff 100755 --- a/test/ppmdither.test +++ b/test/ppmdither.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: ppmdither # Also requires: diff --git a/test/ppmforge-parameters.ok b/test/ppmforge-parameters.ok index 37d89ccd..afb3e855 100644 --- a/test/ppmforge-parameters.ok +++ b/test/ppmforge-parameters.ok @@ -1,10 +1,14 @@ -Test 1 +Test 1: Should print 256 256 256 256 -100 90 +Test 2: Should print 40 30 +40 30 +Test 3: Should print 90 90 90 90 Test Invalid -Expected failure 1 1 -Expected failure 2 1 -Expected failure 3 1 -Expected failure 4 1 -Expected failure 5 1 +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) +Expected failure 5 (no output) +Expected failure 6 (no output) +Expected failure 7 (no output) diff --git a/test/ppmforge-parameters.test b/test/ppmforge-parameters.test index 28a92916..0525e7af 100755 --- a/test/ppmforge-parameters.test +++ b/test/ppmforge-parameters.test @@ -1,39 +1,35 @@ -#! /bin/bash +#! /bin/sh # This script tests: ppmforge # Also requires: pamfile -echo "Test 1" +echo "Test 1: Should print 256 256" -# Should print 256 256 -ppmforge -night | pamfile -size +# Default size is 256 256 +ppmforge -night -seed=1 | pamfile -size + +echo "Test 2: Should print 40 30" # Width is adjusted if not even -# becomes 100 in this case -ppmforge -night -width=99 -height=90 | pamfile -size +# becomes 40 in this case +ppmforge -night -seed=1 -width=39 -height=30 | pamfile -size + +echo "Test 3: Should print 90 90" # Width is adjusted if smaller than height -# brought up to 100 in this case -ppmforge -night -width=80 -height=90 | pamfile -size +# brought up to 90 in this case +ppmforge -night -seed=1 -width=80 -height=90 | pamfile -size echo "Test Invalid" tmpdir=${tmpdir:-/tmp} test_out=${tmpdir}/test_out -echo 1>&2 -echo "Invalid command-line arguments." 1>&2 -echo "Error messages should appear below the line." 1>&2 -echo "-----------------------------------------------------------" 1>&2 - -ppmforge -night -dimension=0 > ${test_out} || \ - echo -n "Expected failure 1"; test -s ${test_out}; echo " "$? -ppmforge -clouds -mesh=1.99 > ${test_out} || \ - echo -n "Expected failure 2"; test -s ${test_out}; echo " "$? -ppmforge -clouds -power=0 > ${test_out} || \ - echo -n "Expected failure 3"; test -s ${test_out}; echo " "$? -ppmforge -ice=0 > ${test_out} || \ - echo -n "Expected failure 4"; test -s ${test_out}; echo " "$? -ppmforge -glaciers=0 > ${test_out} || \ - echo -n "Expected failure 5"; test -s ${test_out}; echo " "$? - -rm ${test_out} +. ${srcdir}/test-invalid.inc + +invCmd "ppmforge -seed=0 -night -dimension=0" +invCmd "ppmforge -seed=0 -dimension=10" +invCmd "ppmforge -seed=0 -dimension=-1" +invCmd "ppmforge -seed=0 -clouds -mesh=1.99" +invCmd "ppmforge -seed=0 -clouds -power=0" +invCmd "ppmforge -seed=0 -ice=-1" +invCmd "ppmforge -seed=0 -glaciers=-1" diff --git a/test/ppmforge.ok b/test/ppmforge.ok new file mode 100644 index 00000000..d2ed4a66 --- /dev/null +++ b/test/ppmforge.ok @@ -0,0 +1,10 @@ +Test 1. Should print: 547829788 196623 (Mersenne Twister) +3820754824 196623 +Test 2. +match +Test 3. +match +Test 4. +match +Test 5. +match diff --git a/test/ppmforge.rand-ok b/test/ppmforge.rand-ok deleted file mode 100644 index c8b3ac9f..00000000 --- a/test/ppmforge.rand-ok +++ /dev/null @@ -1,3 +0,0 @@ -000|0 -081|3634219838 196623 -082|3262664440 196623 diff --git a/test/ppmforge.test b/test/ppmforge.test index 3ebea88c..2a120357 100755 --- a/test/ppmforge.test +++ b/test/ppmforge.test @@ -1,9 +1,50 @@ -#! /bin/bash +#! /bin/sh # This script tests: ppmforge -# Also requires: +# Also requires: pnmpsnr -# Use small x y values to avoid floating point issues. - -# Should print: 3634219838 196623 (Glibc) -# 3262664440 196623 (MAC OS) +echo "Test 1. Should print: 547829788 196623 (Mersenne Twister)" ppmforge -night -seed 1 | cksum + +tmpdir=${tmpdir:-/tmp} +test_ppm=${tmpdir}/test.ppm + +# Target values for following tests were determined by running the +# ppmforge command pairs 1000 times with different seeds, finding +# the minimum (or "poorest match") for each component and +# subtracting 0.01 dB. As such these are weak tests. + +echo "Test 2." +ppmforge -cloud -seed 110 -power 0.75 > ${test_ppm} +ppmforge -cloud -seed 110 -power 0.74 | \ + pnmpsnr -rgb -target1=40.53 -target2=40.53 -target3=999 - ${test_ppm} + + +rm ${test_ppm} + +echo "Test 3." +ppmforge -cloud -seed 111 -dimension 2.15 > ${test_ppm} +ppmforge -cloud -seed 111 -dimension 2.16 | \ + pnmpsnr -rgb -target1=40.34 -target2=40.34 -target3=999 - ${test_ppm} + + # Note that there should be no difference for the target3: blue. + + +rm ${test_ppm} + +echo "Test 4." +ppmforge -seed 200 -stars 0 -ice 0.01 -power 1.180 -hour 10 > ${test_ppm} +ppmforge -seed 200 -stars 0 -ice 0.01 -power 1.181 -hour 10 | \ + pnmpsnr -rgb -target1=45.9 -target2=45.81 -target3=32.11 - ${test_ppm} + +rm ${test_ppm} + + +echo "Test 5." +ppmforge -seed 300 -stars 0 -ice 0.01 \ + -inclination 9 -hour 12 -power 300 > ${test_ppm} +ppmforge -seed 300 -stars 0 -ice 0.01 \ + -inclination 9.1 -hour 12 -power 300 | \ + pnmpsnr -rgb -target1=44.86 -target2=44.86 -target3=42.43 - ${test_ppm} + + +rm ${test_ppm} diff --git a/test/ppmhist.ok b/test/ppmhist.ok index 468bd317..a78540f1 100644 --- a/test/ppmhist.ok +++ b/test/ppmhist.ok @@ -20,6 +20,6 @@ Test 2 Summary: 6 colors: 1 black, 0 white, 0 gray, 5 color Summary: 6 colors: 1 black, 1 white, 1 gray, 3 color Test Invalid -Expected failure 1 1 -Expected failure 2 1 -Expected failure 3 1 +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) diff --git a/test/ppmhist.test b/test/ppmhist.test index 1983bd13..1e814eb7 100755 --- a/test/ppmhist.test +++ b/test/ppmhist.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: ppmhist # Also requires: pgmramp pamtopnm pbmmake pamseq ppmpat @@ -27,19 +27,8 @@ ppmpat -madras --color=rgb:00/00/00,rgb:31/58/a3,rgb:ff/ff/ff 25 25 | \ echo "Test Invalid" -tmpdir=${tmpdir:-/tmp} -test_out=${tmpdir}/test_out +. ${srcdir}/test-invalid.inc -echo 1>&2 -echo "Invalid command-line argument combinations." 1>&2 -echo "Error messages should appear below the line." 1>&2 -echo "-----------------------------------------------------------" 1>&2 - -ppmhist -hexcolor -float testimg.ppm > ${test_out} || \ - echo -n "Expected failure 1"; test -s ${test_out}; echo " "$? -ppmhist -hexcolor -map testimg.ppm > ${test_out} || \ - echo -n "Expected failure 2"; test -s ${test_out}; echo " "$? -ppmhist -float -map testimg.ppm > ${test_out} || \ - echo -n "Expected failure 3"; test -s ${test_out}; echo " "$? - -rm ${test_out} +invCmd "ppmhist -hexcolor -float testimg.ppm" +invCmd "ppmhist -hexcolor -map testimg.ppm" +invCmd "ppmhist -float -map testimg.ppm" diff --git a/test/ppmmake.ok b/test/ppmmake.ok index 6d559c8d..e365bd9e 100644 --- a/test/ppmmake.ok +++ b/test/ppmmake.ok @@ -1,15 +1,23 @@ Test 1 +P3 +1 1 +5 +0 0 0 +P3 +1 1 +65535 +65535 65535 65535 2477651508 15012 -4294967295 0 +135932096 23 2378991101 7513 Test Invalid -Expected failure 1 1 -Expected failure 2 1 -Expected failure 3 1 -Expected failure 4 1 -Expected failure 5 1 -Expected failure 6 1 -Expected failure 7 1 -Expected failure 8 1 -Expected failure 9 1 -Expected failure 10 1 +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) +Expected failure 5 (no output) +Expected failure 6 (no output) +Expected failure 7 (no output) +Expected failure 8 (no output) +Expected failure 9 (no output) +Expected failure 10 (no output) diff --git a/test/ppmmake.test b/test/ppmmake.test index f28249c7..295e0bf4 100755 --- a/test/ppmmake.test +++ b/test/ppmmake.test @@ -1,42 +1,27 @@ -#! /bin/bash +#! /bin/sh # This script tests: ppmmake # Also requires: echo "Test 1" -ppmmake rgb:ff/80/80 50 100 -maxval=5 | cksum -ppmmake rgbi:0.5/1.0/0 2 | cksum +ppmmake -maxval=5 -plain rgb:00/00/00 1 1 +ppmmake -maxval=65535 -plain rgb:ff/ff/ff 1 1 +ppmmake -maxval=5 rgb:ff/80/80 50 100 | cksum +ppmmake rgbi:0.5/1.0/0 2 2 | cksum ppmmake red 50 50 | cksum echo "Test Invalid" -tmpdir=${tmpdir:-/tmp} -test_out=${tmpdir}/test_out +. ${srcdir}/test-invalid.inc -echo 1>&2 -echo "Invalid command-line argument combinations." 1>&2 -echo "Error messages should appear below the line." 1>&2 -echo "-----------------------------------------------------------" 1>&2 - -ppmmake rgb:gg/00/00 2 2 > ${test_out} || \ - echo -n "Expected failure 1"; test -s ${test_out}; echo " "$? -ppmmake rgb:ff/ff/00 2 > ${test_out} || \ - echo -n "Expected failure 2"; test -s ${test_out}; echo " "$? -ppmmake rgbi:1.1/0/0 2 2 > ${test_out} || \ - echo -n "Expected failure 3"; test -s ${test_out}; echo " "$? -ppmmake rgbi:1.0/.5 2 2 > ${test_out} || \ - echo -n "Expected failure 4"; test -s ${test_out}; echo " "$? -ppmmake rainbow 2 2 > ${test_out} || \ - echo -n "Expected failure 5"; test -s ${test_out}; echo " "$? -ppmmake 2 2 > ${test_out} || \ - echo -n "Expected failure 6"; test -s ${test_out}; echo " "$? -ppmmake blue -maxval=0 2 2 > ${test_out} || \ - echo -n "Expected failure 7"; test -s ${test_out}; echo " "$? -ppmmake blue -maxval=-1 2 2 > ${test_out} || \ - echo -n "Expected failure 8"; test -s ${test_out}; echo " "$? -ppmmake blue -maxval=65536 2 2 > ${test_out} || \ - echo -n "Expected failure 9"; test -s ${test_out}; echo " "$? -RGBDEF=/dev/null ppmmake red 2 2 > ${test_out} || \ - echo -n "Expected failure 10"; test -s ${test_out}; echo " "$? - -rm ${test_out} +invCmd "ppmmake rgb:gg/00/00 2 2" +invCmd "ppmmake rgb:ff/ff/00 2" +invCmd "ppmmake rgbi:1.1/0/0 2 2" +invCmd "ppmmake rgbi:1.0/.5 2 2" +invCmd "ppmmake rainbow 2 2" +invCmd "ppmmake 2 2" +invCmd "ppmmake blue -maxval=0 2 2" +invCmd "ppmmake blue -maxval=-1 2 2" +invCmd "ppmmake blue -maxval=65536 2 2" +export RGBDEF=/dev/null +invCmd "ppmmake red 2 2" diff --git a/test/ppmmix.test b/test/ppmmix.test index e1c6486b..c3900baf 100755 --- a/test/ppmmix.test +++ b/test/ppmmix.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: ppmmix # Also requires: pamdepth pamenlarge pamsumm pbmmake # Also requires: pgmtopgm pnminvert ppmtopgm diff --git a/test/ppmpat-random.ok b/test/ppmpat-random.ok new file mode 100644 index 00000000..71f631e5 --- /dev/null +++ b/test/ppmpat-random.ok @@ -0,0 +1,6 @@ +Test 1. Should print: 1366170000 36015 +1366170000 36015 +Test 2. Should print: 4073196212 16813 +4073196212 16813 +Test 3. Should print: 2292015301 16813 +2292015301 16813 diff --git a/test/ppmpat-random.rand-ok b/test/ppmpat-random.rand-ok deleted file mode 100644 index eb8779ab..00000000 --- a/test/ppmpat-random.rand-ok +++ /dev/null @@ -1,7 +0,0 @@ -000|0 -081|2219119109 36015 -081|3436846137 16813 -081|908097729 16813 -082|3606254242 36015 -082|3615722579 16813 -082|1756684515 16813 diff --git a/test/ppmpat-random.test b/test/ppmpat-random.test index a6daa982..4da0d77c 100755 --- a/test/ppmpat-random.test +++ b/test/ppmpat-random.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: ppmpat # Also requires: @@ -7,16 +7,16 @@ # These tests require random numbers. -# Test 1. Should print: 2219119109 36015 (glibc) -# 3606254242 36015 (MAC OS) +echo "Test 1. Should print: 1366170000 36015" # Mersenne Twister + ppmpat --randomseed=0 -camo 100 120 | cksum -# Test 2. Should print: 3436846137 16813 (glibc) -# 3615722579 16813 (MAC OS) +echo "Test 2. Should print: 4073196212 16813" # Mersenne Twister + ppmpat --randomseed=0 -anticamo 80 70 | cksum -# Test 3. Should print: 908097729 16813 (glibc) -# 1756684515 16813 (MAC OS) +echo "Test 3. Should print: 2292015301 16813" # Mersenne Twister + ppmpat --randomseed=0 --color \ rgb:55/c0/34,rgb:0/ff/0,rgb:0/ee/0,rgb:0/cd/0,rgb:0/8b/0,rgb:4f/4f/2f \ -camo 80 70 | cksum diff --git a/test/ppmpat.ok b/test/ppmpat.ok index 4a9cebd9..dc7922ed 100644 --- a/test/ppmpat.ok +++ b/test/ppmpat.ok @@ -1,39 +1,47 @@ -Test 1 +Test 1. Should print: 4008533639 781 4008533639 781 -Test 2 +Test 2. Should print: 738714211 781 +738714211 781 +Test 3. Should print: 3805937800 9613 3805937800 9613 -Test 3 +Test 4. Should print: 1586690955 9613 +1586690955 9613 +Test 5. Should print: 2698433077 1549 2698433077 1549 -Test 4 +Test 6. Should print: 1526189097 1549 +1526189097 1549 +Test 7. Should print: 3705929501 781 3705929501 781 -Test 5 +Test 8. Should print: 1996587666 781 +1996587666 781 +Test 9. Should print: 3057513592 661 3057513592 661 -Test 6 +Test 10. Should print: 1861389287 661 1861389287 661 Test Invalid -Expected failure 1 1 -Expected failure 2 1 -Expected failure 3 1 -Expected failure 4 1 -Expected failure 5 1 -Expected failure 6 1 -Expected failure 7 1 -Expected failure 8 1 -Expected failure 9 1 -Expected failure 10 1 -Expected failure 11 1 -Expected failure 12 1 -Expected failure 13 1 -Expected failure 14 1 -Expected failure 15 1 -Expected failure 16 1 -Expected failure 17 1 -Expected failure 18 1 -Expected failure 19 1 -Expected failure 20 1 -Expected failure 21 1 -Expected failure 22 1 -Expected failure 23 1 -Expected failure 24 1 -Expected failure 25 1 -Expected failure 26 1 +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) +Expected failure 5 (no output) +Expected failure 6 (no output) +Expected failure 7 (no output) +Expected failure 8 (no output) +Expected failure 9 (no output) +Expected failure 10 (no output) +Expected failure 11 (no output) +Expected failure 12 (no output) +Expected failure 13 (no output) +Expected failure 14 (no output) +Expected failure 15 (no output) +Expected failure 16 (no output) +Expected failure 17 (no output) +Expected failure 18 (no output) +Expected failure 19 (no output) +Expected failure 20 (no output) +Expected failure 21 (no output) +Expected failure 22 (no output) +Expected failure 23 (no output) +Expected failure 24 (no output) +Expected failure 25 (no output) +Expected failure 26 (no output) diff --git a/test/ppmpat.test b/test/ppmpat.test index 0a6127ca..00f8421e 100755 --- a/test/ppmpat.test +++ b/test/ppmpat.test @@ -1,107 +1,82 @@ -#! /bin/bash +#! /bin/sh # This script tests: ppmpat # Also requires: -# Test 1. Should print: 4008533639 781 -echo "Test 1" -ppmpat -g2 --color=rgb:32/0d/b7,rgb:31/58/a3 16 16 | cksum +echo "Test 1. Should print: 4008533639 781" +ppmpat -gingham2 \ + -color=rgb:32/0d/b7,rgb:31/58/a3 16 16 | cksum -# Test 2. Should print: 3805937800 9613 -echo "Test 2" -ppmpat -g3 --color=rgb:32/0d/b7,rgb:31/58/a3,rgb:e9/5e/d4 64 50 | cksum +echo "Test 2. Should print: 738714211 781" +ppmpat -g2 -mesh \ + --color=rgb:32/0d/b7,rgb:31/58/a3 16 16 | cksum -# Test 3. Should print: 2698433077 1549 -echo "Test 3" -ppmpat -madras --color=rgb:32/0d/b7,rgb:31/58/a3,rgb:e9/5e/d4 32 16 | cksum +echo "Test 3. Should print: 3805937800 9613" +ppmpat -gingham3 \ + -color=rgb:32/0d/b7,rgb:31/58/a3,rgb:e9/5e/d4 64 50 | cksum -# Test 4. Should print: 3705929501 781 -echo "Test 4" +echo "Test 4. Should print: 1586690955 9613" +ppmpat -g3 -mesh \ + -color=rgb:32/0d/b7,rgb:31/58/a3,rgb:e9/5e/d4 64 50 | cksum + +echo "Test 5. Should print: 2698433077 1549" +ppmpat -madras \ + --color=rgb:32/0d/b7,rgb:31/58/a3,rgb:e9/5e/d4 32 16 | cksum + +echo "Test 6. Should print: 1526189097 1549" +ppmpat -madras -mesh \ + --color=rgb:32/0d/b7,rgb:31/58/a3,rgb:e9/5e/d4 32 16 | cksum + +echo "Test 7. Should print: 3705929501 781" ppmpat -tartan --color=rgb:32/0d/b7,rgb:31/58/a3,rgb:e9/5e/d4 16 16 | cksum -# Test 5. Should print: 3057513592 661 -echo "Test 5" +echo "Test 8. Should print: 1996587666 781" +ppmpat -tartan -mesh \ + --color=rgb:32/0d/b7,rgb:31/58/a3,rgb:e9/5e/d4 16 16 | cksum + +echo "Test 9. Should print: 3057513592 661" ppmpat -argyle1 --color=rgb:ff/ff/ff,rgb:ff/0/0 12 18 | cksum -# Test 6. Should print: 1861389287 661 -echo "Test 6" +echo "Test 10. Should print: 1861389287 661" ppmpat -argyle2 --color=rgb:00/00/00,rgb:ff/80/80,rgb:e0/e0/e0 12 18 | cksum -# Test 7. echo "Test Invalid" -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 - -ppmpat -g2 -g3 10 10 > ${test_out} || \ - echo -n "Expected failure 1"; test -s ${test_out}; echo " "$? -ppmpat -madras -tartan 10 10 > ${test_out} || \ - echo -n "Expected failure 2"; test -s ${test_out}; echo " "$? -ppmpat -poles -squig 10 10 > ${test_out} || \ - echo -n "Expected failure 3"; test -s ${test_out}; echo " "$? -ppmpat -camo -anticamo 10 10 > ${test_out} || \ - echo -n "Expected failure 4"; test -s ${test_out}; echo " "$? -ppmpat -argyle1 -argyle2 10 10 > ${test_out} || \ - echo -n "Expected failure 5"; test -s ${test_out}; echo " "$? - -ppmpat 10 10 > ${test_out} || \ - echo -n "Expected failure 6"; test -s ${test_out}; echo " "$? -ppmpat -g2 10 > ${test_out} || \ - echo -n "Expected failure 7"; test -s ${test_out}; echo " "$? -ppmpat -g2 10 10 10 > ${test_out} || \ - echo -n "Expected failure 8"; test -s ${test_out}; echo " "$? -ppmpat -g2 10 > ${test_out} || \ - echo -n "Expected failure 9"; test -s ${test_out}; echo " "$? +. ${srcdir}/test-invalid.inc + +invCmd "ppmpat -g2 -g3 10 10" +invCmd "ppmpat -madras -tartan 10 10" +invCmd "ppmpat -poles -squig 10 10" +invCmd "ppmpat -camo -anticamo 10 10" +invCmd "ppmpat -argyle1 -argyle2 10 10" +invCmd "ppmpat 10 10" +invCmd "ppmpat -g2 10" +invCmd "ppmpat -g2 10 10 10" +invCmd "ppmpat -g2 10" clist1="-color=rgb:00/00/00" clist2="-color=rgb:00/00/00,rgb:00/00/ff" clist3="-color=rgb:00/00/00,rgb:00/00/ff,rgb:00/ff/ff" clist4="-color=rgb:00/00/00,rgb:00/00/ff,rgb:00/ff/ff,rgb:ff/ff/ff" -# These patterns require exactly 2 colors -ppmpat -gingham2 ${clist1} 10 10 > ${test_out} || \ - echo -n "Expected failure 10"; test -s ${test_out}; echo " "$? -ppmpat -argyle1 ${clist1} 10 10 > ${test_out} || \ - echo -n "Expected failure 11"; test -s ${test_out}; echo " "$? -ppmpat -gingham2 ${clist3} 10 10 > ${test_out} || \ - echo -n "Expected failure 12"; test -s ${test_out}; echo " "$? -ppmpat -argyle1 ${clist3} 10 10 > ${test_out} || \ - echo -n "Expected failure 13"; test -s ${test_out}; echo " "$? - -# These require exactly 3 colors -ppmpat -gingham3 ${clist2} 10 10 > ${test_out} || \ - echo -n "Expected failure 14"; test -s ${test_out}; echo " "$? -ppmpat -argyle2 ${clist2} 10 10 > ${test_out} || \ - echo -n "Expected failure 15"; test -s ${test_out}; echo " "$? -ppmpat -madras ${clist2} 10 10 > ${test_out} || \ - echo -n "Expected failure 16"; test -s ${test_out}; echo " "$? -ppmpat -tartan ${clist2} 10 10 > ${test_out} || \ - echo -n "Expected failure 17"; test -s ${test_out}; echo " "$? -ppmpat -gingham3 ${clist4} 10 10 > ${test_out} || \ - echo -n "Expected failure 18"; test -s ${test_out}; echo " "$? -ppmpat -argyle2 ${clist4} 10 10 > ${test_out} || \ - echo -n "Expected failure 19"; test -s ${test_out}; echo " "$? -ppmpat -madras ${clist4} 10 10 > ${test_out} || \ - echo -n "Expected failure 20"; test -s ${test_out}; echo " "$? -ppmpat -tartan ${clist4} 10 10 > ${test_out} || \ - echo -n "Expected failure 21"; test -s ${test_out}; echo " "$? - -# These require at least 3 colors -ppmpat -squig ${clist2} 10 10 > ${test_out} || \ - echo -n "Expected failure 22"; test -s ${test_out}; echo " "$? -ppmpat -camo ${clist2} 10 10 > ${test_out} || \ - echo -n "Expected failure 23"; test -s ${test_out}; echo " "$? -ppmpat -anticamo ${clist2} 10 10 > ${test_out} || \ - echo -n "Expected failure 24"; test -s ${test_out}; echo " "$? - -# The squig pattern has an aspect ratio restriction -ppmpat -squig ${clist3} 10 250 > ${test_out} || \ - echo -n "Expected failure 25"; test -s ${test_out}; echo " "$? -ppmpat -squig ${clist3} 500 20 > ${test_out} || \ - echo -n "Expected failure 26"; test -s ${test_out}; echo " "$? - -rm ${test_out} +# These patterns require exactly 2 colors +invCmd "ppmpat -gingham2 ${clist1} 10 10" +invCmd "ppmpat -argyle1 ${clist1} 10 10" +invCmd "ppmpat -gingham2 ${clist3} 10 10" +invCmd "ppmpat -argyle1 ${clist3} 10 10" + +# These require exactly 3 colors +invCmd "ppmpat -gingham3 ${clist2} 10 10" +invCmd "ppmpat -argyle2 ${clist2} 10 10" +invCmd "ppmpat -madras ${clist2} 10 10" +invCmd "ppmpat -tartan ${clist2} 10 10" +invCmd "ppmpat -gingham3 ${clist4} 10 10" +invCmd "ppmpat -argyle2 ${clist4} 10 10" +invCmd "ppmpat -madras ${clist4} 10 10" +invCmd "ppmpat -tartan ${clist4} 10 10" +invCmd "ppmpat -squig ${clist2} 10 10" +invCmd "ppmpat -camo ${clist2} 10 10" +invCmd "ppmpat -anticamo ${clist2} 10 10" + +# The squig pattern has an aspect ratio restriction +invCmd "ppmpat -squig ${clist3} 10 250" +invCmd "ppmpat -squig ${clist3} 500 20" diff --git a/test/ppmrelief.test b/test/ppmrelief.test index 3467dcde..c7241663 100755 --- a/test/ppmrelief.test +++ b/test/ppmrelief.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: ppmrelief # Also requires: pbmmake pgmramp pamflip diff --git a/test/ppmrough-parameters.ok b/test/ppmrough-parameters.ok new file mode 100644 index 00000000..473ace05 --- /dev/null +++ b/test/ppmrough-parameters.ok @@ -0,0 +1,25 @@ +Test Invalid +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) +Expected failure 5 (no output) +Expected failure 6 (no output) +Expected failure 7 (no output) +Expected failure 8 (no output) +Expected failure 9 (no output) +Expected failure 10 (no output) +Expected failure 11 (no output) +Expected failure 12 (no output) +Expected failure 13 (no output) +Expected failure 14 (no output) +Expected failure 15 (no output) +Expected failure 16 (no output) +Expected failure 17 (no output) +Expected failure 20 (no output) +Expected failure 18 (no output) +Expected failure 19 (no output) +Expected failure 20 (no output) +Expected failure 21 (no output) +Expected failure 22 (no output) +Expected failure 23 (no output) diff --git a/test/ppmrough-parameters.test b/test/ppmrough-parameters.test new file mode 100755 index 00000000..fb67424e --- /dev/null +++ b/test/ppmrough-parameters.test @@ -0,0 +1,145 @@ +#! /bin/sh +# This script tests: ppmrough +# Also requires: + +tmpdir=${tmpdir:-/tmp} +test_out=${tmpdir}/test_out + + +# Test Invalid +echo "Test Invalid" + +echo 1>&2 +echo "Invalid command-line argument combinations." 1>&2 +echo "Error messages should appear below the line." 1>&2 +echo "-----------------------------------------------------------" 1>&2 + +ppmrough -h 10 -w 10 -top -1 > ${test_out} || \ + printf "Expected failure 1 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +ppmrough -h 10 -w 100 -top 11 > ${test_out} || \ + printf "Expected failure 2 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + + +ppmrough -h 10 -w 10 -bottom -1 > ${test_out} || \ + printf "Expected failure 3 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +ppmrough -h 10 -w 1000 -bottom 11 > ${test_out} || \ + printf "Expected failure 4 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +ppmrough -h 10 -w 10 -left -1 > ${test_out} || \ + printf "Expected failure 5 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +ppmrough -h 10 -w 100 -left 101 > ${test_out} || \ + printf "Expected failure 6 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + + +ppmrough -h 10 -w 10 -right -1 > ${test_out} || \ + printf "Expected failure 7 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +ppmrough -h 10 -w 1000 -right 1001 > ${test_out} || \ + printf "Expected failure 8 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + + +ppmrough -width 0.1 > ${test_out} || \ + printf "Expected failure 9 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +ppmrough -width -1 > ${test_out} || \ + printf "Expected failure 10 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +ppmrough -width > ${test_out} || \ + printf "Expected failure 11 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + + +ppmrough -height 0.1 > ${test_out} || \ + printf "Expected failure 12 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +ppmrough -height -1 > ${test_out} || \ + printf "Expected failure 13 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +ppmrough -height > ${test_out} || \ + printf "Expected failure 14 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + + +ppmrough -randomseed 0.1 > ${test_out} || \ + printf "Expected failure 15 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +ppmrough -randomseed -1 > ${test_out} || \ + printf "Expected failure 16 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +ppmrough -randomseed > ${test_out} || \ + printf "Expected failure 17 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + + + +ppmrough -var A > ${test_out} || \ + printf "Expected failure 20 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +ppmrough -var -1 > ${test_out} || \ + printf "Expected failure 18 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +ppmrough -var > ${test_out} || \ + printf "Expected failure 19 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + + +ppmrough -bg redmint > ${test_out} || \ + printf "Expected failure 20 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +ppmrough -bg > ${test_out} || \ + printf "Expected failure 21 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + + +ppmrough -fg redmint > ${test_out} || \ + printf "Expected failure 22 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +ppmrough -fg > ${test_out} || \ + printf "Expected failure 23 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + diff --git a/test/ppmrough.ok b/test/ppmrough.ok new file mode 100644 index 00000000..4beff006 --- /dev/null +++ b/test/ppmrough.ok @@ -0,0 +1,24 @@ +Test 1. Should print 378403602 30015 +378403602 30015 +Test 2. Should print 378403602 30015 +378403602 30015 +Test 3. Should print 535171440 30015 +535171440 30015 +Test 4. Should print 937167683 30015 +937167683 30015 +Test 5. Should print 1927474861 30015 +1927474861 30015 +Test 6. Should print 3596045345 30015 +3596045345 30015 +Test 7. Should print 198510149 30015 +198510149 30015 +Test 8. Should print 1128371780 30015 +1128371780 30015 +Test 9. Should print 2909877411 30015 +2909877411 30015 +Test 10. Should print 2820370592 30015 +2820370592 30015 +Test 11. Should print 2028409204 30015 +2028409204 30015 +Test 12. Should print 4234304830 30015 +4234304830 30015 diff --git a/test/ppmrough.rand-ok b/test/ppmrough.rand-ok deleted file mode 100644 index 216545c7..00000000 --- a/test/ppmrough.rand-ok +++ /dev/null @@ -1,3 +0,0 @@ -000|0 -081|378403602 30015 -082|378403602 30015 diff --git a/test/ppmrough.test b/test/ppmrough.test index bd4211a3..e1d720d5 100755 --- a/test/ppmrough.test +++ b/test/ppmrough.test @@ -1,6 +1,48 @@ -#! /bin/bash +#! /bin/sh # This script tests: ppmrough # Also requires: -# Should print: 378403602 30015 (Glibc and MAC OS) -ppmrough -randomseed 1 | cksum +defaultopts="-randomseed 1 -bg rgb:00/ff/ff -fg rgb:ff/ff/00 -w 100 -h 100" + +# No border + +echo "Test 1. Should print 378403602 30015" +ppmrough -randomseed 1 | cksum + +echo "Test 2. Should print 378403602 30015" +ppmrough -randomseed 1 -var 0 | cksum + +# Vertical border + +echo "Test 3. Should print 535171440 30015" +ppmrough ${defaultopts} -left 20 | cksum + +echo "Test 4. Should print 937167683 30015" +ppmrough ${defaultopts} -right 20 | cksum + +echo "Test 5. Should print 1927474861 30015" +ppmrough ${defaultopts} -left 50 | cksum + +echo "Test 6. Should print 3596045345 30015" +ppmrough ${defaultopts} -right 50 | cksum + +echo "Test 7. Should print 198510149 30015" +ppmrough ${defaultopts} -right 20 -var 0 | cksum + +# Horizontal border + +echo "Test 8. Should print 1128371780 30015" +ppmrough ${defaultopts} -top 30 | cksum + +echo "Test 9. Should print 2909877411 30015" +ppmrough ${defaultopts} -bottom 25 | cksum + +echo "Test 10. Should print 2820370592 30015" +ppmrough ${defaultopts} -top 50 | cksum + +echo "Test 11. Should print 2028409204 30015" +ppmrough ${defaultopts} -bottom 50 | cksum + +echo "Test 12. Should print 4234304830 30015" +ppmrough ${defaultopts} -bottom 10 -var 0 | cksum + diff --git a/test/ppmshift.ok b/test/ppmshift.ok new file mode 100644 index 00000000..735ac445 --- /dev/null +++ b/test/ppmshift.ok @@ -0,0 +1,23 @@ +Test 1. Should print: 3705777303 101484 +3705777303 101484 +Test 2. Should print: 202790723 685 +202790723 685 +Test 3. Should print: 0 0 : 0 +0 0 : 0 +Test 4. Should print: 0 0 : 0 +0 0 : 0 +Test 5. (1) Should print: 1 twice +1 +1 +Test 5. (15) Should print: 1 twice +1 +1 +Test 5. (16) Should print: 1 twice +1 +1 +Test 5. (20) Should print: 1 twice +1 +1 +Test 5. (1000) Should print: 1 twice +1 +1 diff --git a/test/ppmshift.test b/test/ppmshift.test new file mode 100755 index 00000000..fff193b3 --- /dev/null +++ b/test/ppmshift.test @@ -0,0 +1,42 @@ +#! /bin/bash +# This script tests: ppmshift +# Also requires: pgmtoppm + +echo "Test 1. Should print: 3705777303 101484" +ppmshift -seed=1 10 testimg.ppm | cksum + +echo "Test 2. Should print: 202790723 685" +ppmshift -seed=1 1 testgrid.pbm | cksum + +echo "Test 3. Should print: 0 0 : 0" +ppmshift -seed=1 0 testimg.ppm | cmp -s - testimg.ppm + echo ${PIPESTATUS[@]} ":" $? + +tmpdir=${tmpdir:-/tmp} +test0_ppm=${tmpdir}/test0.ppm +test14_ppm=${tmpdir}/test14.ppm + +pgmtoppm < maze.pbm > ${test0_ppm} + +echo "Test 4. Should print: 0 0 : 0" + ppmshift -seed=2 0 maze.pbm | cmp -s - ${test0_ppm} + echo ${PIPESTATUS[@]} ":" $? + +ppmshift -seed=2 14 maze.pbm > ${test14_ppm} + +for i in 1 15 16 20 1000 + do + echo "Test 5. ("$i") Should print: 1 twice" + ppmshift -seed=2 $i maze.pbm | cmp -s - ${test0_ppm} + echo $? + ppmshift -seed=2 $i maze.pbm | cmp -s - ${test14_ppm} + echo $? + done + +# In Test 5 the image files are not supposed to match. +# When cmp finds a difference, it may terminate and stop reading input from +# the pipe at that point. This may cause a "broken pipe" exception; however +# this does not always happen. The broken pipe shows up as a non-zero value +# for ${PIPESTATUS[0]}. + +rm ${test0_ppm} ${test14_ppm} diff --git a/test/ppmspread.ok b/test/ppmspread.ok new file mode 100644 index 00000000..40f44465 --- /dev/null +++ b/test/ppmspread.ok @@ -0,0 +1,12 @@ +Test 1. +stdin: PPM RAW 227 149 3 255 RGB +stdin: PPM RAW 227 149 3 255 RGB +Test 2. +57 59 +57 59 +Test 3. Should print 281226646 481 +281226646 481 +Test 4. Should print 639729144 101484 +639729144 101484 +Test 5. Should print 3278353642 685 +3278353642 685 diff --git a/test/ppmspread.test b/test/ppmspread.test new file mode 100755 index 00000000..d7e0fb37 --- /dev/null +++ b/test/ppmspread.test @@ -0,0 +1,28 @@ +#! /bin/sh +# This script tests: ppmspread +# Also requires: pamfile ppmtopgm pgmtopbm + +# Input/output size does not change + +echo "Test 1." +cat testimg.ppm | pamfile -machine +ppmspread -randomseed=100 20 testimg.ppm | pamfile -machine + +echo "Test 2." +pamfile -size maze.pbm +ppmspread -randomseed=100 20 maze.pbm | pamfile -size + +# No change when spread distance value is 0 + +echo "Test 3. Should print 281226646 481" +ppmspread -randomseed=1 0 maze.pbm | ppmtopgm | pgmtopbm | cksum + +# The following tests will fail when changes are made to the random +# number generator + +echo "Test 4. Should print 639729144 101484" +ppmspread -randomseed=1 10 testimg.ppm | cksum + +echo "Test 5. Should print 3278353642 685" +ppmspread -randomseed=1 1 testgrid.pbm | cksum + diff --git a/test/ppmtoapplevol.ok b/test/ppmtoapplevol.ok new file mode 100644 index 00000000..daed172c --- /dev/null +++ b/test/ppmtoapplevol.ok @@ -0,0 +1,6 @@ +Test: should print 1518149010 3065 +1518149010 3065 +Test Invalid +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) diff --git a/test/ppmtoapplevol.test b/test/ppmtoapplevol.test new file mode 100755 index 00000000..a11e6aa6 --- /dev/null +++ b/test/ppmtoapplevol.test @@ -0,0 +1,30 @@ +#! /bin/sh +# This script tests: ppmtoapplevol +# Also requires: ppmmake pbmmake + +echo "Test: should print 1518149010 3065" +ppmmake rgb:0/0/0 255 12 | ppmtoapplevol | cksum + +echo "Invalid input." 1>&2 +echo "Error messages should appear below the line." 1>&2 +echo "-----------------------------------------------------------" 1>&2 + +echo "Test Invalid" + +tmpdir=${tmpdir:-/tmp} +test_out=${tmpdir}/test_out + +pbmmake 10 11 | ppmtoapplevol > ${test_out} || \ + printf "Expected failure 1 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pbmmake 10 13 | ppmtoapplevol > ${test_out} || \ + printf "Expected failure 2 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +pbmmake 256 12 | ppmtoapplevol > ${test_out} || \ + printf "Expected failure 3 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} diff --git a/test/ppmtoarbtxt-roundtrip.test b/test/ppmtoarbtxt-roundtrip.test index dff78250..f63aabe2 100755 --- a/test/ppmtoarbtxt-roundtrip.test +++ b/test/ppmtoarbtxt-roundtrip.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: ppmtoarbtxt # Also requires: pnminvert pamtopnm @@ -30,5 +30,4 @@ ppmtoarbtxt ${bodyskl} -hd ${headskl} testimg.ppm | tee ${inv_ppm} | cat ${inv_ppm} | ppmtoarbtxt ${bodyskl} -hd ${headskl} | pamtopnm | cksum - -rm ${bodyskl} ${headskl} +rm ${inv_ppm} ${bodyskl} ${headskl} diff --git a/test/ppmtomitsu.ok b/test/ppmtomitsu.ok new file mode 100644 index 00000000..812b2ffa --- /dev/null +++ b/test/ppmtomitsu.ok @@ -0,0 +1,14 @@ +Test 0. Should print 668243897 101532 +668243897 101532 +Test 1. Should print 3110813682 101562 +3110813682 101562 +Test 2. Should print 825518840 34209 +825518840 34209 +Test 3. Should print 3201293405 310 +3201293405 310 +Test 4. Should print 3354679572 752 +3354679572 752 +Test 5. Should print 3999654426 101549 +3999654426 101549 +Test 6. Should print 3103038403 101549 +3103038403 101549 diff --git a/test/ppmtomitsu.test b/test/ppmtomitsu.test new file mode 100755 index 00000000..31cd936f --- /dev/null +++ b/test/ppmtomitsu.test @@ -0,0 +1,31 @@ +#! /bin/sh +# This script tests: ppmtomitsu +# Also requires: pamseq pamdepth + +tmpdir=${tmpdir:-/tmp} +testimg216_ppm=${tmpdir}/testimg216.ppm + +echo "Test 0. Should print 668243897 101532" + +pamseq 3 5 -tupletype=RGB | pamdepth 255 | pnmremap -nofloyd -mapfile=- testimg.ppm |\ + tee ${testimg216_ppm} | cksum + +echo "Test 1. Should print 3110813682 101562" +ppmtomitsu testimg.ppm | cksum + +echo "Test 2. Should print 825518840 34209" +ppmtomitsu ${testimg216_ppm} | cksum + +echo "Test 3. Should print 3201293405 310" +ppmtomitsu testgrid.pbm | cksum + +echo "Test 4. Should print 3354679572 752" +ppmtomitsu -tiny testgrid.pbm | cksum + +echo "Test 5. Should print 3999654426 101549" +ppmtomitsu -tiny testimg.ppm | cksum + +echo "Test 6. Should print 3103038403 101549" +ppmtomitsu -tiny ${testimg216_ppm} | cksum + +rm ${testimg216_ppm} diff --git a/test/ppmtopgm.test b/test/ppmtopgm.test index 8503194b..696b660c 100755 --- a/test/ppmtopgm.test +++ b/test/ppmtopgm.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: ppmtopgm # Also requires: diff --git a/test/ppmtoppm.ok b/test/ppmtoppm.ok index 764a3464..2b4ad9f8 100644 --- a/test/ppmtoppm.ok +++ b/test/ppmtoppm.ok @@ -1 +1,23 @@ -829921912 685 +Test 1. Should print a simple 4 x 3 pattern +P3 +4 3 +255 +255 255 255 0 0 0 255 255 255 0 0 0 +0 0 0 255 255 255 0 0 0 255 255 255 +255 255 255 0 0 0 255 255 255 0 0 0 +Test 2. Should print a simple 6 x 8 pattern +P3 +6 8 +5 +0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 2 2 2 +0 0 0 0 0 0 1 1 1 1 1 1 2 2 2 2 2 2 +0 0 0 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 +1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 3 3 3 +1 1 1 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 +2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 4 4 4 +2 2 2 2 2 2 3 3 3 3 3 3 4 4 4 4 4 4 +2 2 2 3 3 3 3 3 3 4 4 4 4 4 4 5 5 5 +Test 3. Should print 669206373 10102 +669206373 10102 +Test 4. Should print 1926073387 101484 +1926073387 101484 diff --git a/test/ppmtoppm.test b/test/ppmtoppm.test index 797c733d..90ff2ddf 100755 --- a/test/ppmtoppm.test +++ b/test/ppmtoppm.test @@ -1,6 +1,15 @@ -#! /bin/bash +#! /bin/sh # This script tests: ppmtoppm -# Also requires: +# Also requires: pbmmake pgmramp +echo "Test 1. Should print a simple 4 x 3 pattern" +pbmmake -g 4 3 | ppmtoppm -plain -ppmtoppm < testgrid.pbm | cksum +echo "Test 2. Should print a simple 6 x 8 pattern" +pgmramp -diagonal -maxval=5 6 8 | ppmtoppm -plain + +echo "Test 3. Should print 669206373 10102" +ppmtoppm < maze.pbm | cksum + +echo "Test 4. Should print 1926073387 101484" +ppmtoppm < testimg.ppm | cksum \ No newline at end of file diff --git a/test/ppmwheel.ok b/test/ppmwheel.ok index 0b0a7746..525bee2c 100644 --- a/test/ppmwheel.ok +++ b/test/ppmwheel.ok @@ -2,7 +2,8 @@ Test 1. 1537578995 59 875938089 86 Test Invalid. -Expected failure 1 1 -Expected failure 2 1 -Expected failure 3 1 -Expected failure 4 1 +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) +Expected failure 5 (no output) diff --git a/test/ppmwheel.test b/test/ppmwheel.test index fd401951..ca439bea 100755 --- a/test/ppmwheel.test +++ b/test/ppmwheel.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: ppmwheel # Also requires: @@ -122,15 +122,26 @@ echo "Error messages should appear below the line." 1>&2 echo "-----------------------------------------------------------" 1>&2 ppmwheel 10 -huevalue -huesaturation > ${test_out} || \ - echo -n "Expected failure 1"; test -s ${test_out}; echo " "$? + printf "Expected failure 1 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} ppmwheel 0 > ${test_out} || \ - echo -n "Expected failure 2"; test -s ${test_out}; echo " "$? + printf "Expected failure 2 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +ppmwheel 3 > ${test_out} || \ + printf "Expected failure 3 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} ppmwheel > ${test_out} || \ - echo -n "Expected failure 3"; test -s ${test_out}; echo " "$? + printf "Expected failure 4 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} ppmwheel 10 10 > ${test_out} || \ - echo -n "Expected failure 4"; test -s ${test_out}; echo " "$? - -rm -f ${test_out} \ No newline at end of file + printf "Expected failure 5 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} diff --git a/test/ps-alt-roundtrip.ok b/test/ps-alt-roundtrip.ok index 2deba38d..a23005f9 100644 --- a/test/ps-alt-roundtrip.ok +++ b/test/ps-alt-roundtrip.ok @@ -1,2 +1,4 @@ +Test 1. Should print: 281226646 481 2425386270 41 -2916080186 235 +Test 2. Should print: 2154092425 3374 +2154092425 3374 diff --git a/test/ps-alt-roundtrip.test b/test/ps-alt-roundtrip.test index 8fc08f2b..bdecaffd 100755 --- a/test/ps-alt-roundtrip.test +++ b/test/ps-alt-roundtrip.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmtoepsi pbmtopsg3 psidtopgm pstopnm # Also requires: gs pnmcrop @@ -24,7 +24,9 @@ # pstopnm does not use libnetpbm functions for output. # Output is filtered through at least one Netpbm program. -# Test 1. Should print: 2425386270 41 +echo "Test 1. Should print: 281226646 481" + +tmpdir=${tmpdir:-/tmp} testgrid1_ps=${tmpdir}/testgrid1.ps pbmtopsg3 -dpi=72 testgrid.pbm \ @@ -36,13 +38,12 @@ pstopnm -xborder=0 -yborder=0 -llx=0 -lly=-16 -urx=14 \ rm ${testgrid1_ps} - -# Test 2. Should print: 2916080186 235 +echo "Test 2. Should print: 2154092425 3374" # Output is pgm maxval=1 with black and white inverted. -# + testgrid_epsi=${tmpdir}/testgrid.epsi -pbmtoepsi testgrid.pbm > ${testgrid_epsi} && \ +pbmtoepsi maze.pbm > ${testgrid_epsi} && \ xysizebps=`awk '/BeginPreview/ {print $2,$3,$4}' \ ${testgrid_epsi}` && \ awk '/^%%BeginPreview:/ { p=1; next } /^%%EndImage/ { p=0; next } \ diff --git a/test/ps-flate-roundtrip.ok b/test/ps-flate-roundtrip.ok index 57fb124f..0fdf23f2 100644 --- a/test/ps-flate-roundtrip.ok +++ b/test/ps-flate-roundtrip.ok @@ -1,3 +1,5 @@ +Test 1. Should print: 1926073387 101484 twice 1926073387 101484 1926073387 101484 -1386192571 507420 +Test 2. Should print 1831481505 608904 +1831481505 608904 diff --git a/test/ps-flate-roundtrip.test b/test/ps-flate-roundtrip.test index 08d1500c..9fc24ddb 100755 --- a/test/ps-flate-roundtrip.test +++ b/test/ps-flate-roundtrip.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pnmtops pstopnm # Also requires: pamtopnm gs zlib @@ -17,7 +17,7 @@ tmpdir=${tmpdir:-/tmp} # pstopnm does not use libnetpbm functions for output. # Output is filtered through pamtopnm. -# Test 1. Should print: 1926073387 101484 twice +echo "Test 1. Should print: 1926073387 101484 twice" test1_ps=${tmpdir}/testimg1.ps for flag in "-ps -flate" "-ps -rle -ascii -flate" @@ -32,16 +32,17 @@ for flag in "-ps -flate" "-ps -rle -ascii -flate" rm ${test1_ps} -# Test 2. Should print: 1386192571 507420 +echo "Test 2. Should print 1831481505 608904" # See comments in ps-roundtrip.test test3_ps=${tmpdir}/testimg3.ps flag="-ps -bitspersample=12 -flate -rle -vmreclaim" -cat testimg.ppm testimg.ppm testimg.ppm testgrid.pbm testgrid.pbm | \ -pnmtops -nocenter -equalpixels -dpi 72 -noturn -setpage ${flag} \ - > ${test3_ps} && +cat testimg.ppm testimg.ppm testimg.ppm maze.pbm \ + testgrid.pbm testgrid.pbm | \ + pnmtops -nocenter -equalpixels -dpi 72 -noturn -setpage ${flag} \ + > ${test3_ps} && xysize3=`awk '/BoundingBox/ {print "-xsize="$4,"-ysize="$5 ; exit}' \ - ${test3_ps}` && + ${test3_ps}` && pstopnm -portrait -xborder=0 -yborder=0 $xysize3 -stdout ${test3_ps} | \ pamtopnm | cksum diff --git a/test/ps-roundtrip.ok b/test/ps-roundtrip.ok index 5ef66cc4..1a69224d 100644 --- a/test/ps-roundtrip.ok +++ b/test/ps-roundtrip.ok @@ -1,7 +1,9 @@ +Test 1. Should print 1926073387 101484 four times 1926073387 101484 1926073387 101484 1926073387 101484 1926073387 101484 +Test 2. Should print 2918318199 62 seven times 2918318199 62 2918318199 62 2918318199 62 @@ -9,6 +11,7 @@ 2918318199 62 2918318199 62 2918318199 62 -1386192571 507420 -1386192571 507420 -1386192571 507420 +Test 3. Should print 1831481505 608904 three times +1831481505 608904 +1831481505 608904 +1831481505 608904 diff --git a/test/ps-roundtrip.test b/test/ps-roundtrip.test index 207646cc..5d7b7d65 100755 --- a/test/ps-roundtrip.test +++ b/test/ps-roundtrip.test @@ -1,6 +1,6 @@ -#! /bin/bash +#! /bin/sh # This script tests: pnmtops pstopnm -# Also requires: pamtopnm gs pbmmake pnmshear pnmpad pnmcat +# Also requires: pamtopnm gs pbmmake pnmshear pnmpad pamcat # Failure message @@ -11,7 +11,7 @@ tmpdir=${tmpdir:-/tmp} # pstopnm does not use libnetpbm functions for output. # Output is filtered through pamtopnm. -# Test 1. Should print: 1926073387 101484 four times +echo "Test 1. Should print 1926073387 101484 four times" test1_ps=${tmpdir}/testimg1.ps for flag in "" "-ps" "-rle" "-ps -ascii" @@ -25,9 +25,9 @@ for flag in "" "-ps" "-rle" "-ps -ascii" done rm ${test1_ps} -# Test 2. Should print: 2918318199 62 seven times + +echo "Test 2. Should print 2918318199 62 seven times" # Test image designed to detect problems with run-length compression -# g_pbm=${tmpdir}/g.pbm t_pbm=${tmpdir}/t.pbm @@ -37,7 +37,7 @@ pbmmake -g 2 2 > ${g_pbm} pbmmake -g 8 4 | \ pnmshear 45 -noantialias -background=black | \ pnmpad -right 60 | \ - pnmcat -tb -jright - ${g_pbm} > ${t_pbm} && + pamcat -tb -jright - ${g_pbm} > ${t_pbm} && for flag in "" "-rle" "-ps -rle -ascii" \ "-bitspersample=2 -rle" "-ps -bitspersample=4 -rle" \ "-bitspersample=8 -rle" "-ps -bitspersample=12 -rle -dict" @@ -52,8 +52,8 @@ for flag in "" "-rle" "-ps -rle -ascii" \ rm ${grid_ps} ${g_pbm} ${t_pbm} -#Test 3. Should print: 1386192571 507420 three times -# +echo "Test 3. Should print 1831481505 608904 three times" + # Special care is needed when conducting round-trips with multiple-image # files as input. # (1) pnmtops: -setpage is mandatory @@ -61,16 +61,16 @@ rm ${grid_ps} ${g_pbm} ${t_pbm} # 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. -# test3_ps=${tmpdir}/testimg3.ps for flag in "" "-ps" \ "-ps -bitspersample=12 -rle -vmreclaim" do -cat testimg.ppm testimg.ppm testimg.ppm testgrid.pbm testgrid.pbm | \ -pnmtops -nocenter -equalpixels -dpi 72 -noturn -setpage ${flag} \ - > ${test3_ps} && +cat testimg.ppm testimg.ppm testimg.ppm maze.pbm \ + testgrid.pbm testgrid.pbm | \ + pnmtops -nocenter -equalpixels -dpi 72 -noturn -setpage ${flag} \ + > ${test3_ps} && xysize3=`awk '/BoundingBox/ {print "-xsize="$4,"-ysize="$5 ; exit}' \ ${test3_ps}` && pstopnm -portrait -xborder=0 -yborder=0 $xysize3 -stdout ${test3_ps} | \ diff --git a/test/qoi-roundtrip.ok b/test/qoi-roundtrip.ok new file mode 100644 index 00000000..66e25bd8 --- /dev/null +++ b/test/qoi-roundtrip.ok @@ -0,0 +1,34 @@ +Test 1. Should print 1.N 0 0 +1.0 0 0 +1.1 0 0 +1.2 0 0 +1.3 0 0 +1.4 0 0 +Test 2. Should print 2.N 0 0 +2.0 0 0 +2.1 0 0 +2.2 0 0 +2.3 0 0 +2.4 0 0 +Test 3. Should print 3.N 0 0 +3.0 0 0 +3.1 0 0 +3.2 0 0 +3.3 0 0 +3.4 0 0 +Test Invalid +Should print: Expected failure N (no output) +Expected failure 1 (no output) +Expected failure 2 (no output) +Expected failure 3 (no output) +Expected failure 4 (no output) +Expected failure 5 (no output) +Expected failure 6 (no output) +Expected failure 7 (no output) +Expected failure 8 (no output) +------------------------------ +Should print: Expected failure N (output produced) +Expected failure 9 (output produced) +Expected failure 10 (output produced) +Expected failure 11 (output produced) +Expected failure 12 (output produced) diff --git a/test/qoi-roundtrip.test b/test/qoi-roundtrip.test new file mode 100755 index 00000000..52396e39 --- /dev/null +++ b/test/qoi-roundtrip.test @@ -0,0 +1,254 @@ +#! /bin/sh +# This script tests: qoitopam pamtoqoi +# Also requires: pamdepth pamfile pamseq pamstack pamtopnm pbmmake +# Also requires: pgmnoise ppmpat ppmtopgm + +# Ensure that sed operates in original narrow-character mode + +LANG=C +LC_ALL=C +export LANG LC_ALL + +tmpdir=${tmpdir:-/tmp} + +maze_qoi=${tmpdir}/maze.qoi +maze_bw_alpha=${tmpdir}/maze_bw_alpha.pam +maze_rgb=${tmpdir}/maze_rgb.pam +maze_rgb_alpha=${tmpdir}/maze_rgb_alpha.pam + +echo "Test 1. Should print 1.N 0 0" + +pbmmake -g $(pamfile -size maze.pbm) |\ + pamstack -tupletype="BLACKANDWHITE_ALPHA" maze.pbm - > ${maze_bw_alpha} + +pbmmake -g $(pamfile -size maze.pbm) |\ + pamstack -tupletype="RGB" maze.pbm maze.pbm maze.pbm |\ + pamdepth 255 > ${maze_rgb} +printf "1.0 $? " + +pbmmake -g $(pamfile -size maze.pbm) |\ + pamstack -tupletype="RGB_ALPHA" maze.pbm maze.pbm maze.pbm - |\ + pamdepth 255 > ${maze_rgb_alpha} +echo $? + +# PBM, PBM + alpha + +pamtoqoi maze.pbm | tee ${maze_qoi} | qoitopam | cmp -s - ${maze_rgb} +printf "1.1 $? " +test -s ${maze_qoi} +echo $? + +pamdepth 8 maze.pbm | pamtoqoi | qoitopam | cmp -s - ${maze_rgb} +printf "1.2 $? " +test -s ${maze_rgb} +echo $? + +pamtoqoi ${maze_bw_alpha} | qoitopam | cmp -s - ${maze_rgb_alpha} +printf "1.3 $? " +test -s ${maze_bw_alpha} +echo $? + +pamdepth 2 ${maze_bw_alpha} | pamstack -tupletype="GRAYSCALE_ALPHA" |\ + pamtoqoi | qoitopam | cmp -s - ${maze_rgb_alpha} +printf "1.4 $? " +test -s ${maze_rgb_alpha} +echo $? + +rm ${maze_rgb} ${maze_rgb_alpha} ${maze_bw_alpha} + +echo "Test 2. Should print 2.N 0 0" + +# ---- PGM, PGM + alpha + +noise1_pgm=${tmpdir}/noise1.pgm +noise2_pgm=${tmpdir}/noise2.pgm +test_gray_alpha=${tmpdir}/test_gray_alpha.pam +res_gray_alpha=${tmpdir}/res_gray_alpha.pam + +pgmnoise --randomseed=0 20 20 > ${noise1_pgm} +pgmnoise --randomseed=1 20 20 | tee ${noise2_pgm} |\ + pamstack -tupletype="GRAYSCALE_ALPHA" ${noise1_pgm} - \ + > ${test_gray_alpha} +printf "2.0 $? " + +pamstack -tupletype="RGB_ALPHA" \ + ${noise1_pgm} ${noise1_pgm} ${noise1_pgm} ${noise2_pgm} > ${res_gray_alpha} +echo $? + +rm ${noise2_pgm} + +pamtoqoi ${noise1_pgm} | qoitopam | pamtopnm | ppmtopgm |\ + cmp -s - ${noise1_pgm} +printf "2.1 $? " +test -s ${noise1_pgm} +echo $? + + +pamdepth 65535 ${noise1_pgm} | pamtoqoi | qoitopam | pamtopnm | ppmtopgm |\ + cmp -s - ${noise1_pgm} +printf "2.2 $? " +test -s ${noise1_pgm} +echo $? + +pamtoqoi ${test_gray_alpha} | qoitopam | cmp -s - ${res_gray_alpha} +printf "2.3 $? " +test -s ${test_gray_alpha} +echo $? + +pamdepth 4095 ${test_gray_alpha} | pamtoqoi | qoitopam |\ + cmp -s - ${res_gray_alpha} +printf "2.4 $? " +test -s ${res_gray_alpha} +echo $? + +rm ${test_gray_alpha} ${res_gray_alpha} + +echo "Test 3. Should print 3.N 0 0" + +# rgb rgb-alpha + +tartan_ppm=${tmpdir}/tartan.ppm +tartan_qoi=${tmpdir}/tartan.qoi +test_rgb_alpha=${tmpdir}/test_rgb_alpha.pam + +ppmpat -tartan 20 20 | tee ${tartan_ppm} |\ + pamstack -tupletype="RGB_ALPHA" - ${noise1_pgm} > ${test_rgb_alpha} +printf "3.0 $? " +test -s ${tartan_ppm} +echo $? + +pamtoqoi ${tartan_ppm} | tee ${tartan_qoi} | qoitopam | pamtopnm |\ + cmp -s - ${tartan_ppm} +printf "3.1 $? " +test -s ${tartan_qoi} +echo $? +rm ${tartan_qoi} + +pamdepth 4095 ${tartan_ppm} | pamtoqoi | tee ${tartan_qoi} |\ + qoitopam | pamtopnm | cmp -s - ${tartan_ppm} +printf "3.2 $? " +test -s ${tartan_qoi} +echo $? +rm ${tartan_qoi} + +pamtoqoi ${test_rgb_alpha} | qoitopam | cmp -s - ${test_rgb_alpha} +printf "3.3 $? " +test -s ${test_rgb_alpha} +echo $? + +pamdepth 511 ${test_rgb_alpha} | pamtoqoi | qoitopam |\ + cmp -s - ${test_rgb_alpha} +printf "3.4 $? " +test -s ${test_rgb_alpha} +echo $? + +rm ${noise1_pgm} ${tartan_ppm} ${test_rgb_alpha} + + +echo "Test Invalid" + +test_out=${tmpdir}/test.out +maze_qoi_size=$(cat ${maze_qoi} | wc -c) + +echo 1>&2 +echo "Invalid command-line argument combinations." 1>&2 +echo "Error messages should appear below the line." 1>&2 +echo "-----------------------------------------------------------" 1>&2 + +echo "Should print: Expected failure N (no output)" + +pamseq -tupletype="void" 1 1 | pamtoqoi > \ + ${test_out} || \ + printf "Expected failure 1 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +( echo "P1"; echo "400000001 1" ; + head -c 400000001 /dev/zero ) | pamtoqoi > \ + ${test_out} || \ + printf "Expected failure 2 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +# Replace fields in the qoi file header with invalid values + +( printf "qojf" + tail -c +5 ${maze_qoi} ) | qoitopam > \ + ${test_out} || \ + printf "Expected failure 3 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +( head -c 4 ${maze_qoi} + head -c 4 /dev/zero + tail -c +9 ${maze_qoi} ) | qoitopam > \ + ${test_out} || \ + printf "Expected failure 4 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +( head -c 8 ${maze_qoi} + head -c 4 /dev/zero + tail -c +13 ${maze_qoi} ) | qoitopam > \ + ${test_out} || \ + printf "Expected failure 5 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +# Following sed construct means: "replace first 8 bytes of input +# stream." echo -e -n and printf may be straightforward but +# unfortunately they are not portable. Is there any better solution? +# Suggestions welcome. + +( head -c 4 ${maze_qoi} + tail -c +5 ${maze_qoi} | \ + sed '1s/^......../\x00\x00\x4F\xFF\x00\x00\x4F\xFF/' ) | qoitopam > \ + ${test_out} || \ + printf "Expected failure 6 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +( head -c 12 ${maze_qoi} + tail -c +13 ${maze_qoi} | sed '1s/^./\x01/' ) | qoitopam > \ + ${test_out} || \ + printf "Expected failure 7 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +( head -c 13 ${maze_qoi} + tail -c +14 ${maze_qoi} | sed '1s/^./\x02/' ) | qoitopam > \ + ${test_out} || \ + printf "Expected failure 8 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + +echo "------------------------------" +echo "Should print: Expected failure N (output produced)" + +( head -c $(( ${maze_qoi_size} - 9 )) ${maze_qoi} + tail -c 9 ${maze_qoi} | sed '1s/^./\xfd/' ) | qoitopam > \ + ${test_out} || \ + printf "Expected failure 9 " + test -s ${test_out} && echo "(output produced)"|| echo "no output" + rm -f ${test_out} + +head -c $(( ${maze_qoi_size} - 1 )) ${maze_qoi} | qoitopam > \ + ${test_out} || \ + printf "Expected failure 10 " + test -s ${test_out} && echo "(output produced)"|| echo "no output" + rm -f ${test_out} + +( head -c $(( ${maze_qoi_size} - 1 )) ${maze_qoi} + printf '1' ) | qoitopam > \ + ${test_out} || \ + printf "Expected failure 11 " + test -s ${test_out} && echo "(output produced)"|| echo "no output" + rm -f ${test_out} + +( cat ${maze_qoi}; printf '1' ) | qoitopam > \ + ${test_out} || \ + printf "Expected failure 12 " + test -s ${test_out} && echo "(output produced)"|| echo "no output" + rm -f ${test_out} + +rm ${maze_qoi} diff --git a/test/random-generator.ok b/test/random-generator.ok new file mode 100644 index 00000000..e137d901 --- /dev/null +++ b/test/random-generator.ok @@ -0,0 +1,219 @@ +Test 1: Should produce: +P2 +12 1 +1023 +720 296 192 858 101 57 298 629 804 1019 64 617 +Above output is for Mersenne Twister +P2 +12 1 +1023 +720 296 192 858 101 57 298 629 804 1019 64 617 + +Test 2: Mersenne Twister random number generator +Should produce: +3499211612 581869302 3890346734 3586334585 545404204 +4161255391 3922919429 949333985 2715962298 1323567403 + ... + 297480282 1101405687 1473439254 2634793792 1341017984 + Total 1000 integers, 200 lines + +3499211612 581869302 3890346734 3586334585 545404204 +4161255391 3922919429 949333985 2715962298 1323567403 + 418932835 2350294565 1196140740 809094426 2348838239 +4264392720 4112460519 4279768804 4144164697 4156218106 + 676943009 3117454609 4168664243 4213834039 4111000746 + 471852626 2084672536 3427838553 3437178460 1275731771 + 609397212 20544909 1811450929 483031418 3933054126 +2747762695 3402504553 3772830893 4120988587 2163214728 +2816384844 3427077306 153380495 1551745920 3646982597 + 910208076 4011470445 2926416934 2915145307 1712568902 +3254469058 3181055693 3191729660 2039073006 1684602222 +1812852786 2815256116 746745227 735241234 1296707006 +3032444839 3424291161 136721026 1359573808 1189375152 +3747053250 198304612 640439652 417177801 4269491673 +3536724425 3530047642 2984266209 537655879 1361931891 +3280281326 4081172609 2107063880 147944788 2850164008 +1884392678 540721923 1638781099 902841100 3287869586 + 219972873 3415357582 156513983 802611720 1755486969 +2103522059 1967048444 1913778154 2094092595 2775893247 +3410096536 3046698742 3955127111 3241354600 3468319344 +1185518681 3031277329 2919300778 12105075 2813624502 +3052449900 698412071 2765791248 511091141 1958646067 +2140457296 3323948758 4122068897 2464257528 1461945556 +3765644424 2513705832 3471087299 961264978 76338300 +3226667454 3527224675 1095625157 3525484323 2173068963 +4037587209 3002511655 1772389185 3826400342 1817480335 +4120125281 2495189930 2350272820 678852156 595387438 +3271610651 641212874 988512770 1105989508 3477783405 +3610853094 4245667946 1092133642 1427854500 3497326703 +1287767370 1045931779 58150106 3991156885 933029415 +1503168825 3897101788 844370145 3644141418 1078396938 +4101769245 2645891717 3345340191 2032760103 4241106803 +1510366103 290319951 3568381791 3408475658 2513690134 +2553373352 2361044915 3147346559 3939316793 2986002498 +1227669233 2919803768 3252150224 1685003584 3237241796 +2411870849 1634002467 893645500 2438775379 2265043167 + 325791709 1736062366 231714000 1515103006 2279758133 +2546159170 3346497776 1530490810 4011545318 4144499009 + 557942923 663307952 2443079012 1696117849 2016017442 +1663423246 51119001 3122246755 1447930741 1668894615 + 696567687 3983551422 3411426125 1873110678 1336658413 +3705174600 2270032533 2664425968 711455903 513451233 +2585492744 2027039028 1129453058 1461232481 2809248324 +2275654012 2960153730 3075629128 3213286615 4245057188 +1935061435 3094495853 360010077 3919490483 983448591 +2171099548 3922754098 2397746050 654458600 2161184684 +3546856898 1986311591 2312163142 2347594600 4278366025 +1922360368 335761339 3669839044 1901288696 2595154464 + 458070173 2141230976 4131320786 4208748424 19903848 + 147391738 3328215103 4196191786 3510290616 1559873971 +3731015357 2918514861 362649214 1487061100 1717053387 +3675955720 1116134897 193529268 3436267940 2835191639 +1852908272 3220971953 3911201640 571213604 781027019 +4219206494 1133024903 409547355 625085180 1214072539 + 584409985 3445042528 3733581611 333104904 2489812253 +2694595213 2361631596 34763086 622576118 2921810672 +3663740744 2293225236 2671706445 1884059696 1507329019 + 857065948 2204390003 592711182 1725752375 1642107460 + 326274448 3274574484 1030432041 173822100 529650788 +1086437636 789877945 2167974914 1030588245 3533061365 +1792148406 4216468704 213264131 3536714075 3877136173 +1296338417 4057830103 205919137 2108245233 1064497347 +2101324080 2336703164 1450493809 3812754708 3865701845 +1476779561 1585902852 142887412 477612192 699530444 +3351157089 3768249319 1673915577 903239649 1038056164 +1171465372 1734789440 2115022236 414269055 959581346 + 566820984 2105828892 4046076449 4101450561 4106566571 +2800184123 2470502098 3253453343 256751188 1869365987 +1008372035 2374606708 1516804538 228288551 3527001547 +1385173098 66157275 1739381798 184785808 3901692666 + 725806641 3475217997 2787929747 1109372433 3142723729 + 557686578 2782047723 2118822689 1936702581 1625646963 +2349385293 3085804937 1272688179 1236112995 3198431244 +2677635414 811555596 3486972196 2949678043 1342211552 + 788174404 1656614077 1582629285 1477167035 2687011245 +3503701453 3351051324 2874557775 348432514 1629591495 +3991682351 1969229192 3331660584 1304012077 2090754125 +3910846836 1871998370 2098597104 1918921592 3246092887 +1315760974 464122393 2184028058 1690455542 2193747147 +3737423698 3511684278 1549884962 3413774919 3938991454 +2767325310 2335626851 1626114941 601913200 3485711542 + 858447440 2288468476 4075602213 1506361431 4252489875 +4032981007 1031118352 3762145731 70955369 2362903502 +1669089455 2673510137 3348740333 2521337794 2047144929 + 892246357 2319875070 1293843163 79245769 2022600352 +3866257397 989939126 835351312 3626278636 3805332945 + 836506264 1895040349 970326679 634920763 733185481 +1028655248 977810701 3434484235 1871311609 2031584214 +1336174158 385787519 3965885375 2768323462 1847726660 +2718987737 793780050 2509902580 3886434164 3120956802 +4207987247 1523159183 1884932179 2922324286 477253416 +3037922812 1108379444 697195677 1755438379 574393398 +2555059183 1930828628 1126190880 180621093 2589191337 +3424652760 3054648512 719646637 952394946 3570038180 + 504304985 1395707758 1274213163 2816553213 1369142370 +1804702100 1821782344 3358274235 2181234724 486158240 + 367287522 4267199121 1127352639 779850007 3440331597 +3276765484 125500149 1142120513 3989398167 1048565860 +3136747194 432668526 2098559576 1478877150 2484746208 +1209580219 1019125185 4160278734 1970740713 918146921 +4136433784 2602441845 2348512686 973030509 2238261365 + 815637919 994690313 1724736366 2099799816 1775069742 +2680317667 730798472 2916864943 1284417767 1698724919 +2733611686 1578128411 651006053 4243350375 3303874296 + 162087183 3796616231 3801767645 4119825424 3922537059 + 77594039 3419583692 2503306160 423966005 3293613218 +1124728190 1407880681 1440346680 554334954 2919409323 +1253962019 586491243 3638308238 3097648541 991125519 + 458538714 2155963569 2807866455 6862945 2122460897 + 53853750 3346001678 1230879976 3071060893 423909157 +3881450262 1652511030 3826483009 1526211009 1435219366 +3092251623 3001090498 281084412 849586749 2207008400 + 131172352 1820973075 3195774605 2962673849 2147580010 +1090677336 2061249893 1724513375 3885752424 1135918139 +2619357288 4012575714 2652856935 2029480458 3691276589 +2623865075 3459550738 2097670126 2477000057 2209844713 + 785646024 1052349661 1030500157 1430246618 3807539761 +2157629976 123154542 2560049331 2104110449 1332109867 + 721241591 4136042859 4203401395 998151922 3060999432 +3207929139 2149509272 1385268511 2023309182 1366796638 + 256061060 4090836236 2929047008 2296609403 182240337 +3744374619 306855912 4014087816 2240468995 2865233169 + 415452309 1244206523 3513921306 281425419 3511338031 + 995954022 3102854413 3026765331 643667197 837979907 +2832983005 1813414171 2227348307 4020325887 4178893912 + 610818241 2787397224 2762441380 3437393657 2030369078 +1949046312 1876612561 1857107382 1049344864 3544695775 +2172907342 358500115 3895295219 571965125 328582064 + 744698407 3066193991 1679065087 2650874932 3570748805 + 812110431 3450423805 1705023874 259721746 1192558045 +1714799045 3685508436 2262914445 3903852862 1790140070 +2651193482 2821191752 776610414 2697125035 2212010032 +1254062056 3541766210 1853927671 1543286708 66516686 +3505195914 4226521519 1260092911 717982876 739240369 + 456195732 2116515161 1599487648 838913496 850912042 +3712172413 2103192411 877020153 1458113119 2646869271 +4087221703 3771198399 3952796001 1685641891 226245966 +4065518354 3169076409 715963611 1155859114 4174181651 +1816065125 2422210778 2353087594 2569974907 4049024520 + 563593555 1794197249 2434290377 4222178191 2381045132 +1294739153 1333544226 3011196239 518183212 2861903570 +3168787443 2315530531 1042490149 2998340365 3534153126 +2862715604 796613230 765073073 1342937225 549817636 +3786981820 4291017601 2895722553 734959362 3175258828 + 140019477 268621172 2410334776 565052604 3787587805 + 386344800 2874086067 35710270 817904650 1960697289 +1584484509 2724312018 1978802819 2275314726 4216102886 +2138332912 671754166 1442240992 3674442465 1085868016 +2769242611 1003628378 1616076847 743729558 820011032 +2559719034 1839332599 3121982280 2070268989 3769147733 + 518022934 3037227899 2531915367 1008310588 971468687 +2052976098 1651926578 78218926 2503907441 3209763057 +1081499040 2812016370 1247433164 335294964 2650385171 +2030527826 1139372809 4279827824 3540669095 2285341455 +4220507154 3863048231 3136394663 3319584205 1476940506 + 875141230 2508558662 3896001866 462864388 1609807693 +3892563868 3642514037 3778083990 1403162576 3512254868 +1403323269 1119818229 2831288053 2552740643 2520136409 + 96690857 210381252 1826474872 3306977352 1343117402 +2112059492 693571694 2096734379 767794921 1843084587 +1816280216 1695342628 404711915 3334843684 2570639553 +4186538211 2022604264 3214805180 2989079529 2725165355 +3005995436 310011850 2742468706 2720274646 144327376 +2271696819 295519962 1272030376 1372670420 1397272558 +2280044719 2710639434 2810822904 4271368265 1750711132 +2216408539 3521792518 3111505866 3085328191 1054735512 +4160317205 1427385632 2282061755 3215251668 1396490078 +2933318719 453673969 2926038256 2624047458 338625410 +3344930154 1971116345 1818716442 2998517928 390083048 + 291563131 1144486353 296954266 659950561 2263631666 +1206908601 1125491020 1890151284 2076080514 2264060846 + 561805191 1964622705 405620012 3759692386 517035386 +2225016848 4165419081 4052828294 3248204933 2738939733 +1151808775 4113264137 3113447491 1033828852 1785686386 +2903923175 2038900010 1241522880 238119113 2885394101 +2636011022 2985605703 2107193353 292026696 3884689974 +1094315383 4016714705 962244585 3943968050 2868319718 +1304919603 3626636694 3393461291 1479454799 971639318 +3352306399 1928233566 2900529135 2190901098 28842068 + 990556577 2586302532 3057504668 1661169605 4228191763 +3934152427 2814119472 4943754 1171095774 1986204006 +2014406505 1822565279 12890078 1979620724 1917376192 +3307810835 4170173371 1385005883 1308519769 3370429606 + 923886311 2024463563 1063369787 153599761 3463680785 + 755374878 2088947962 3099927142 1750207400 2033606872 + 926120766 655932557 2320365045 1465119024 3105365454 +2608716819 1218456091 823539591 2331574954 3171519129 +3246671799 1043031086 1425831588 3940307546 3443545749 +1155610704 3681098065 3287797558 63959365 810297004 +3800799806 1234795257 2547289014 391329364 370300179 +2474800443 3972311925 2935022755 3924395679 2347599539 +4212318274 1828491430 3865565525 2767860661 4078993078 +2781496513 4013741232 2916354756 35752471 2730683119 +3340599926 4059491907 111492530 897368671 2524912702 +3046341697 2790787159 1014602604 1409764839 512802978 + 477082227 2608350570 533747000 1933326657 4182933327 +1970210993 2290203137 2843031053 2844558050 3308351089 +3041943368 1504174920 295229952 2843309586 884572473 +1787387521 1861566286 3616058184 48071792 3577350513 + 297480282 1101405687 1473439254 2634793792 1341017984 diff --git a/test/random-generator.test b/test/random-generator.test new file mode 100755 index 00000000..351b982e --- /dev/null +++ b/test/random-generator.test @@ -0,0 +1,83 @@ +#! /bin/sh +# This script tests: pgmnoise +# Also requires: + +# These tests are for examining the integrity of the random number +# generator. There is some overlap between the tests here and tests +# in pgmnoise.test, but the tests here are better focused for +# diagnosing problems with the random number generator. +# +# Test 1 is for determining the kind of random number generator in +# use. +# +# Test 2 prints random numbers in an output format close to what the +# test in the original Mersenne Twister code produces. +# +# If these tests fail, subsequent tests which depend on random numbers +# will fail too. There is no provision (beyond remarks in the script +# files) for generators other than the Mersenne Twister in those +# tests. + +echo "Test 1: Should produce:" + +echo "P2" +echo "12 1" +echo "1023" +echo "720 296 192 858 101 57 298 629 804 1019 64 617" +echo "Above output is for Mersenne Twister" + +pgmnoise -maxval=1023 -randomseed=3791 -plain 12 1 + +echo +echo "Test 2: Mersenne Twister random number generator" +echo "Should produce:" + +echo "3499211612 581869302 3890346734 3586334585 545404204" +echo "4161255391 3922919429 949333985 2715962298 1323567403" +echo " ... " +echo " 297480282 1101405687 1473439254 2634793792 1341017984" +echo " Total 1000 integers, 200 lines" +echo + +# Use perl to avoid mawk limitation +# (cannot convert 32 bit integers) + +perlPgmProcessorProgram=' + if (($#F+1) == 10) { + for (my $i = 0; $i <= 9; $i += 2) { + my $r = $F[$i + 1] * 65536 + $F[$i]; + printf "%10u ", $r; + } + print ""; + } +' + +pgmnoise -randomseed=5489 -plain -maxval=65535 10 200 | \ + perl -walne "$perlPgmProcessorProgram" + +# The above outputs (10 * 200 / 2) = 1000 samples. + +# Method to generate output for Test 2 from original +# Mersenne Twister source code +# +# Download Mersenne Twister code. See lib/util/randmersenne.c for URL. +# Edit mt19937ar.c: +# In function main() at bottom of file, replace +# init_by_array(init, length); +# with +# init_genrand(5489UL); +# +# We need only the output of genrand_int32(). +# Remove the second loop which produces double-precision floating point +# random numbers with genrand_real2(). +# +# Compile: gcc mt19937ar.c -o mt1000 +# Execute: ./mt1000 + +# 1000 may seem like a large number of samples but there is a reason +# for this. The generator produces random integers in batches of 624. +# The number of samples must be larger than 624 to ensure proper +# generation in batches after the first. + +# If you encounter problems, adjust the 200 (rows) above and tweak +# the code in mt19937ar.c accordingly to produce more random numbers. diff --git a/test/rgb3-roundtrip.ok b/test/rgb3-roundtrip.ok index 367e5429..cbdb369c 100644 --- a/test/rgb3-roundtrip.ok +++ b/test/rgb3-roundtrip.ok @@ -1,6 +1,12 @@ +Test 1. Should print 1926073387 101484 1926073387 101484 +Test 2. Should print 3744829044 101514 3744829044 101514 -2425386270 41 +Test 3. Should print 281226646 481 twice +281226646 481 +281226646 481 +Test 4. Should print 0 twice 0 0 +Test 5. Should print 0 0 : 0 0 0 : 0 diff --git a/test/rgb3-roundtrip.test b/test/rgb3-roundtrip.test index 42fd822f..76bd90f1 100755 --- a/test/rgb3-roundtrip.test +++ b/test/rgb3-roundtrip.test @@ -10,37 +10,45 @@ tmpdir=${tmpdir:-/tmp} # Test 1. PPM (color) input -testimg_ppm=${tmpdir}/testimg.ppm -testimg_red=${tmpdir}/testimg.red -testimg_grn=${tmpdir}/testimg.grn -testimg_blu=${tmpdir}/testimg.blu - -cp testimg.ppm ${tmpdir} && -ppmtorgb3 ${testimg_ppm} && -rgb3toppm ${testimg_red} ${testimg_grn} ${testimg_blu} | cksum - -cat ${testimg_red} ${testimg_grn} ${testimg_blu} | cksum - -rm ${testimg_ppm} ${testimg_red} ${testimg_grn} ${testimg_blu} - -# Test 2. PBM (monochrome) input -testgrid_pbm=${tmpdir}/testgrid.pbm -testgrid_red=${tmpdir}/testgrid.red -testgrid_grn=${tmpdir}/testgrid.grn -testgrid_blu=${tmpdir}/testgrid.blu - -cp testgrid.pbm ${tmpdir} && -ppmtorgb3 ${testgrid_pbm} && -rgb3toppm ${testgrid_red} ${testgrid_grn} ${testgrid_blu} | \ +echo "Test 1. Should print 1926073387 101484" +rose_ppm=${tmpdir}/rose.ppm +rose_red=${tmpdir}/rose.red +rose_grn=${tmpdir}/rose.grn +rose_blu=${tmpdir}/rose.blu + +cp testimg.ppm ${rose_ppm} && +ppmtorgb3 ${rose_ppm} && +rgb3toppm ${rose_red} ${rose_grn} ${rose_blu} | cksum + +# Simple cat of three planes +echo "Test 2. Should print 3744829044 101514" +cat ${rose_red} ${rose_grn} ${rose_blu} | cksum + +rm ${rose_ppm} ${rose_red} ${rose_grn} ${rose_blu} + +# Test 3. PBM (monochrome) input +echo "Test 3. Should print 281226646 481 twice" +maze_pbm=${tmpdir}/maze.pbm +maze_red=${tmpdir}/maze.red +maze_grn=${tmpdir}/maze.grn +maze_blu=${tmpdir}/maze.blu + +cp maze.pbm ${tmpdir} && +ppmtorgb3 ${maze_pbm} && +rgb3toppm ${maze_red} ${maze_grn} ${maze_blu} | \ ppmtopgm | pgmtopbm -th -val=0.5 | cksum +pgmtopbm -th -val=0.5 ${maze_red} | cksum -# Test 3. +# Test 4. # With PGM or PBM input, the three monochrome planes should be # identical. Test for this. -cmp -s ${testgrid_red} ${testgrid_grn} ; echo $? -cmp -s ${testgrid_grn} ${testgrid_blu} ; echo $? -pgmtopgm < testgrid.pbm | cmp -s - ${testgrid_red} +echo "Test 4. Should print 0 twice" +cmp -s ${maze_red} ${maze_grn} ; echo $? +cmp -s ${maze_grn} ${maze_blu} ; echo $? + +echo "Test 5. Should print 0 0 : 0" +pgmtopgm < maze.pbm | cmp -s - ${maze_red} echo ${PIPESTATUS[@]} ":" $? -rm ${testgrid_pbm} ${testgrid_red} ${testgrid_grn} ${testgrid_blu} +rm ${maze_pbm} ${maze_red} ${maze_grn} ${maze_blu} diff --git a/test/sbig-roundtrip.test b/test/sbig-roundtrip.test index 1fdaccfd..2611fa89 100755 --- a/test/sbig-roundtrip.test +++ b/test/sbig-roundtrip.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pgmtosbig sbigtopgm # Also requires: pamchannel pamtopnm diff --git a/test/sgi-roundtrip.ok b/test/sgi-roundtrip.ok index b1bd5ba6..3c3f022a 100644 --- a/test/sgi-roundtrip.ok +++ b/test/sgi-roundtrip.ok @@ -1,8 +1,13 @@ +Test 1. Should produce 1926073387 101484 twice 1926073387 101484 1926073387 101484 +Test 2. Should produce 1926073387 101484 twice 1926073387 101484 1926073387 101484 -538848130 235 -538848130 235 -2394972481 463 -2394972481 463 +Test 3. Should produce 281226646 481 twice +281226646 481 +281226646 481 +Test 4. Should produce 4155890407 6741 three times +4155890407 6741 +4155890407 6741 +4155890407 6741 diff --git a/test/sgi-roundtrip.test b/test/sgi-roundtrip.test index 5052bb81..50a9fbc2 100755 --- a/test/sgi-roundtrip.test +++ b/test/sgi-roundtrip.test @@ -1,14 +1,14 @@ -#! /bin/bash +#! /bin/sh # This script tests: pnmtosgi sgitopnm -# Also requires: rgb3toppm pamdepth pamtopnm - +# Also requires: rgb3toppm pamdepth pamtopnm pgmtopbm +tmpdir=${tmpdir:-/tmp} a_sgi=${tmpdir}/a.sgi a_red=${tmpdir}/a.red a_grn=${tmpdir}/a.grn a_blu=${tmpdir}/a.blu -# Test 1. Should produce 1926073387 101484 twice +echo "Test 1. Should produce 1926073387 101484 twice" pnmtosgi -rle testimg.ppm | tee ${a_sgi} | sgitopnm | cksum sgitopnm -channel=0 ${a_sgi} > ${a_red} sgitopnm -channel=1 ${a_sgi} > ${a_grn} @@ -21,7 +21,7 @@ b_red=${tmpdir}/b.red b_grn=${tmpdir}/b.grn b_blu=${tmpdir}/b.blu -# Test 2. Should produce 1926073387 101484 twice +echo "Test 2. Should produce 1926073387 101484 twice" pnmtosgi -verbatim testimg.ppm | tee ${b_sgi} | sgitopnm | cksum sgitopnm -channel=0 ${b_sgi} > ${b_red} sgitopnm -channel=1 ${b_sgi} > ${b_grn} @@ -29,15 +29,16 @@ sgitopnm -channel=2 ${b_sgi} > ${b_blu} rgb3toppm ${b_red} ${b_grn} ${b_blu} | cksum rm ${b_sgi} ${b_red} ${b_grn} ${b_blu} -# Test 3. Should produce 2425386270 41 twice -pnmtosgi testgrid.pbm | sgitopnm | cksum # Defaults to -rle -pnmtosgi -verbatim testgrid.pbm | sgitopnm | cksum - +echo "Test 3. Should produce 281226646 481 twice" +pnmtosgi maze.pbm | sgitopnm | pgmtopbm -threshold -value=0.5 | cksum +# Defaults to -rle +pnmtosgi -verbatim maze.pbm | sgitopnm | \ + pgmtopbm -threshold -value=0.5 | cksum -testgrid_pgm=${tmpdir}/testgrid.pgm +maze_pgm=${tmpdir}/maze.pgm -# Test 4. Should produce 2394972481 463 twice -pamdepth 65535 testgrid.pbm | pamtopnm | tee ${testgrid_pgm} | \ - pnmtosgi -rle | sgitopnm | cksum -pnmtosgi -verbatim ${testgrid_pgm} | sgitopnm | cksum -rm ${testgrid_pgm} +echo "Test 4. Should produce 4155890407 6741 three times" +pamdepth 65535 maze.pbm | pamtopnm | tee ${maze_pgm} | cksum +pnmtosgi -rle ${maze_pgm} | sgitopnm | cksum +pnmtosgi -verbatim ${maze_pgm} | sgitopnm | cksum +rm ${maze_pgm} diff --git a/test/st4-roundtrip.test b/test/st4-roundtrip.test index ffe8f348..f2e15078 100755 --- a/test/st4-roundtrip.test +++ b/test/st4-roundtrip.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pgmtost4 st4topgm # Also requires: pamchannel pamtopnm pamcut diff --git a/test/stdin-pam1.ok b/test/stdin-pam1.ok new file mode 100644 index 00000000..10e48622 --- /dev/null +++ b/test/stdin-pam1.ok @@ -0,0 +1,44 @@ +pamaddnoise -seed=1: 0 0 0 0 +pamaltsat -strength=1: 0 0 0 0 +pambackground: 0 0 0 0 +pambayer -type=2: 0 0 0 0 +pambrighten: 0 0 0 0 +pamcat -topbottom: 0 0 0 0 +pamcut: 0 0 0 0 +pamdeinterlace: 0 0 0 0 +pamdepth 15: 0 0 0 0 +pamditherbw -threshold: 0 0 0 0 +pamedge: 0 0 0 0 +pamexec cat: 0 0 0 0 +pamfile -size: 0 0 0 0 +pamfind -target=1: 0 0 0 0 +pamfix: 0 0 0 0 +pamflip -lr: 0 0 0 0 +pamfunc -not: 0 0 0 0 +pamhomography -from 0,0,0,1,1,0,1,1: 0 0 0 0 +pamhue -huechange=60: 0 0 0 0 +pamlevels -f1 rgb:0/0/0 -t1 rgb:0/0/0 -f2 rgb:ff/ff/ff -t2 rgb:ff/ff/ff: 0 0 0 0 +pammixinterlace: 0 0 0 0 +pammosaicknit: 0 0 0 0 +pamoil: 0 0 0 0 +pamperspective 0 0 0 1 1 0 1 1: 0 0 0 0 +pamrecolor: 0 0 0 0 +pamrestack: 0 0 0 0 +pamrubber -quad 1 1 2 2: 0 0 0 0 +pamscale 2: 0 0 0 0 +pamshadedrelief: 0 0 0 0 +pamsharpness: 0 0 0 0 +pamshuffle -randomseed=1: 0 0 0 0 +pamsistoaglyph: 0 0 0 0 +pamslice -row=1: 0 0 0 0 +pamstack: 0 0 0 0 +pamstereogram -randomseed=1: 0 0 0 0 +pamstretch 1: 0 0 0 0 +pamstretch-gen 1: 0 0 0 0 +pamsumm -max: 0 0 0 0 +pamsummcol -mean: 0 0 0 0 +pamtable: 0 0 0 0 +pamthreshold: 0 0 0 0 +pamtilt: 0 0 0 0 +pamtopnm: 0 0 0 0 +pamwipeout -tb: 0 0 0 0 diff --git a/test/stdin-pam1.test b/test/stdin-pam1.test new file mode 100755 index 00000000..2ab7b11c --- /dev/null +++ b/test/stdin-pam1.test @@ -0,0 +1,75 @@ +#! /bin/sh +# This script tests: pamaddnoise pamaltsat pambackground pambayer +# This script tests: pambrighten pamcat pamcut pamdeinterlace pamdepth pamditherbw +# This script tests: pamedge pamexec pamfile pamfind pamfix pamflip +# This script tests: pamfunc pamhomography pamhue pamlevels +# This script tests: pammixinterlace pammosaicknit pamoil +# This script tests: pamperspective pamrecolor pamrestack pamrubber pamscale +# This script tests: pamshadedrelief pamsharpness pamshuffle pamsistoaglyph +# This script tests: pamslice pamstack pamstereogram pamstretch +# This script tests: pamstretch-gen pamsumm pamsummcol pamtable pamthreshold +# This script tests: pamtilt pamtopnm pamwipeout +# Also requires: pbmmake + +tmpdir=${tmpdir:-/tmp} +out1=${tmpdir}/out1 +out2=${tmpdir}/out2 +small_pbm=${tmpdir}/small.pbm + +pbmmake -g 5 5 > ${small_pbm} + +for testprog in \ + "pamaddnoise -seed=1" \ + "pamaltsat -strength=1" \ + pambackground \ + "pambayer -type=2" \ + pambrighten \ + "pamcat -topbottom" \ + pamcut \ + pamdeinterlace \ + "pamdepth 15" \ + "pamditherbw -threshold" \ + pamedge \ + "pamexec cat" \ + "pamfile -size" \ + "pamfind -target=1" \ + pamfix \ + "pamflip -lr" \ + "pamfunc -not" \ + "pamhomography -from 0,0,0,1,1,0,1,1" \ + "pamhue -huechange=60" \ + "pamlevels -f1 rgb:0/0/0 -t1 rgb:0/0/0 -f2 rgb:ff/ff/ff -t2 rgb:ff/ff/ff" \ + pammixinterlace \ + pammosaicknit \ + pamoil \ + "pamperspective 0 0 0 1 1 0 1 1" \ + pamrecolor \ + pamrestack \ + "pamrubber -quad 1 1 2 2" \ + "pamscale 2" \ + pamshadedrelief \ + pamsharpness \ + "pamshuffle -randomseed=1" \ + pamsistoaglyph \ + "pamslice -row=1" \ + pamstack \ + "pamstereogram -randomseed=1" \ + "pamstretch 1" \ + "pamstretch-gen 1" \ + "pamsumm -max" \ + "pamsummcol -mean" \ + pamtable \ + pamthreshold \ + pamtilt \ + pamtopnm \ + "pamwipeout -tb" + do + ${testprog} ${small_pbm} > ${out1}; status1=$? + ${testprog} < ${small_pbm} > ${out2}; status2=$? + test -s ${out1}; status3=$? + cmp -s ${out1} ${out2} + echo ${testprog}": "${status1} ${status2} ${status3} $? + rm ${out1} ${out2} + done + +rm ${small_pbm} diff --git a/test/stdin-pam2.ok b/test/stdin-pam2.ok new file mode 100644 index 00000000..dd3148e8 --- /dev/null +++ b/test/stdin-pam2.ok @@ -0,0 +1,5 @@ +pammasksharpen: 0 0 0 0 +pammixmulti: 0 0 0 0 +pamdice: 0 0 0 0 +pamlookup: 0 0 0 0 +pamunlookup: 0 0 0 0 diff --git a/test/stdin-pam2.test b/test/stdin-pam2.test new file mode 100755 index 00000000..10713c77 --- /dev/null +++ b/test/stdin-pam2.test @@ -0,0 +1,70 @@ +#! /bin/sh +# This script tests: pammasksharpen pammixmulti pamdice +# This script tests: pamlookup pamunlookup +# Also requires: pbmmake + +tmpdir=${tmpdir:-/tmp} +out1=${tmpdir}/out1 +out2=${tmpdir}/out2 +out3=${tmpdir}/out3 +out4=${tmpdir}/out4 +small_pbm=${tmpdir}/small.pbm + +pbmmake -g 3 3 > ${small_pbm} + +for testprog in \ + pammasksharpen \ + pammixmulti + do + ${testprog} ${small_pbm} ${small_pbm} > ${out1}; status1=$? + ${testprog} ${small_pbm} < ${small_pbm} > ${out2}; status2=$? + test -s ${out1}; status3=$? + cmp -s ${out1} ${out2} + echo ${testprog}": "${status1} ${status2} ${status3} $? + rm ${out1} ${out2} +done + + + dicestem=${tmpdir}/dice + + testprog="pamdice -outstem=${dicestem}" + ${testprog} ${small_pbm}; status1=$? + cat ${dicestem}_*_*.pbm > ${out1} + rm ${dicestem}_*_*.pbm + ${testprog} < ${small_pbm}; status2=$? + cat ${dicestem}_*_*.pbm > ${out2} + rm ${dicestem}_*_*.pbm + test -s ${out1}; status3=$? + cmp -s ${out1} ${out2} + echo pamdice: ${status1} ${status2} ${status3} $? + # Do not use testprog, which contains a variable, in the above + # Same for pamlookup, pamunlookup + rm ${out1} ${out2} + +lookup_ppm=${tmpdir}/lookup.ppm + +cat > ${lookup_ppm} <<EOF +P3 +2 1 +2 +0 0 0 +0 1 2 +EOF + + testprog="pamlookup -lookupfile=${lookup_ppm}" + ${testprog} ${small_pbm} > ${out1}; status1=$? + ${testprog} < ${small_pbm} > ${out2}; status2=$? + test -s ${out1}; status3=$? + cmp -s ${out1} ${out2} + echo pamlookup": "${status1} ${status2} ${status3} $? + rm ${out2} + + testprog="pamunlookup -lookupfile=${lookup_ppm}" + ${testprog} ${out1} > ${out3}; status1=$? + ${testprog} < ${out1} > ${out4}; status2=$? + test -s ${out1}; status3=$? + cmp -s ${out3} ${out4} + echo pamunlookup": "${status1} ${status2} ${status3} $? + rm ${out1} ${out3} ${out4} + +rm ${lookup_ppm} ${small_pbm} diff --git a/test/stdin-pam3.ok b/test/stdin-pam3.ok new file mode 100644 index 00000000..516e9554 --- /dev/null +++ b/test/stdin-pam3.ok @@ -0,0 +1,34 @@ +Test. Should print (command): 0 0 0 0 +The following are exceptions: should print (command): 0 0 0 1 +pamtotga, pamtotiff + +pamtoavs: 0 0 0 0 +avstopam: 0 0 0 0 +pamtohdiff: 0 0 0 0 +hdifftopam: 0 0 0 0 +pamtojpeg2k: 0 0 0 0 +jpeg2ktopam: 0 0 0 0 +pamtopdbimg -fixedtime: 0 0 0 0 +pdbimgtopam: 0 0 0 0 +pamtopfm: 0 0 0 0 +pfmtopam: 0 0 0 0 +pamtopng: 0 0 0 0 +pngtopam: 0 0 0 0 +pamtoqoi: 0 0 0 0 +qoitopam: 0 0 0 0 +pamtosrf: 0 0 0 0 +srftopam: 0 0 0 0 +pamtosvg: 0 0 0 0 +svgtopam: 0 0 0 0 +pamtowinicon: 0 0 0 0 +winicontopam: 0 0 0 0 +pamtotga: 0 0 0 1 +tgatoppm: 0 0 0 0 +pamtoxvmini: 0 0 0 0 +xvminitoppm: 0 0 0 0 +pamtofits: 0 0 0 0 +fitstopnm: 0 0 0 0 +pamtogif: 0 0 0 0 +giftopnm: 0 0 0 0 +pamtotiff: 0 0 0 1 +tifftopnm: 0 0 0 0 diff --git a/test/stdin-pam3.test b/test/stdin-pam3.test new file mode 100755 index 00000000..40155671 --- /dev/null +++ b/test/stdin-pam3.test @@ -0,0 +1,75 @@ +#! /bin/sh +# This script tests: pamtoavs avstopam +# This script tests: pamtohdiff hdifftopam +# This script tests: pamtojpeg2k jpeg2ktopam +# This script tests: pamtopdbimg pdbimgtopam +# This script tests: pamtopfm pfmtopam +# This script tests: pamtopng pngtopam +# This script tests: pamtoqoi qoitopam +# This script tests: pamtosrf srftopam +# This script tests: pamtosvg svgtopam +# This script tests: pamtowinicon winicontopam +# This script tests: pamtotga tgatoppm +# This script tests: pamtoxvmini xvminitoppm +# This script tests: pamtofits fitstopnm +# This script tests: pamtogif giftopnm +# This script tests: pamtotiff tifftopnm +# Also requires: pgmmake + +tmpdir=${tmpdir:-/tmp} +test_pgm=${tmpdir}/test.pgm +out1=${tmpdir}/out1 +out2=${tmpdir}/out2 +out3=${tmpdir}/out3 +out4=${tmpdir}/out4 + +pgmmake -maxval 3 0.25 32 32 > ${test_pgm} + +echo "Test. Should print (command): 0 0 0 0" +echo "The following are exceptions: should print (command): 0 0 0 1" +echo "pamtotga, pamtotiff" +echo + +for fmt in \ + avs \ + hdiff \ + jpeg2k \ + pdbimg \ + pfm \ + png \ + qoi \ + srf \ + svg \ + winicon \ + tga \ + xvmini \ + fits \ + gif \ + tiff + do + + if [ ${fmt} = pdbimg ] + then testprog1="pamtopdbimg -fixedtime"; + else testprog1="pamto"${fmt}; + fi + + case $fmt in + "tga" | "xvmini") testprog2=${fmt}"toppm";; + "fits" | "gif" | "tiff") testprog2=${fmt}"topnm";; + *) testprog2=${fmt}"topam"; + esac + + ${testprog1} ${test_pgm} > ${out1}; status1=$? + ${testprog1} < ${test_pgm} > ${out2}; status2=$? + test -s ${out1}; status3=$? + cmp -s ${out1} ${out2} + echo ${testprog1}": "${status1} ${status2} ${status3} $? + + ${testprog2} ${out1} > ${out3}; status4=$? + ${testprog2} < ${out1} > ${out4}; status5=$? + test -s ${out3}; status6=$? + cmp -s ${out3} ${out4} + echo ${testprog2}": "${status4} ${status5} ${status6} $? + done + +rm ${test_pgm} ${out1} ${out2} ${out3} ${out4} diff --git a/test/stdin-pbm1.ok b/test/stdin-pbm1.ok new file mode 100644 index 00000000..0dd83466 --- /dev/null +++ b/test/stdin-pbm1.ok @@ -0,0 +1,9 @@ +pbmclean: 0 0 0 0 +pbmlife: 0 0 0 0 +pbmmask: 0 0 0 0 +pbmminkowski: 0 0 0 0 +pbmtoepsi: 0 0 0 0 +pbmtopsg3: 0 0 0 0 +pbmpscale 1 : 0 0 0 0 +pbmreduce -threshold 2 : 0 0 0 0 +pbmtopgm 2 2 : 0 0 0 0 diff --git a/test/stdin-pbm1.test b/test/stdin-pbm1.test new file mode 100755 index 00000000..4e99ba0b --- /dev/null +++ b/test/stdin-pbm1.test @@ -0,0 +1,45 @@ +#! /bin/sh +# This script tests: pbmclean pbmlife pbmmask pbmminkowski pbmtoepsi +# This script tests: pbmtopsg3 pbmpscale pbmreduce pbmtopgm +# Also requires: pbmmake + +# Tests whether output is unchanged when +# (1) input is a named file: pbm-command input-file +# (2) input is from stdin: pbm-command < input-file + +tmpdir=${tmpdir:-/tmp} +out1=${tmpdir}/out1 +out2=${tmpdir}/out2 +out3=${tmpdir}/out3 +out4=${tmpdir}/out4 +small_pbm=${tmpdir}/small.pbm + +pbmmake -b 3 3 > ${small_pbm} + +for testprog in \ + pbmclean \ + pbmlife \ + pbmmask \ + pbmminkowski \ + pbmtoepsi \ + pbmtopsg3 \ + "pbmpscale 1 " \ + "pbmreduce -threshold 2 " \ + "pbmtopgm 2 2 " + do + ${testprog} ${small_pbm} > ${out1}; status1=$? + ${testprog} < ${small_pbm} > ${out2}; status2=$? + test -s ${out1}; status3=$? + cmp -s ${out1} ${out2} + echo ${testprog}": "${status1} ${status2} ${status3} $? + rm ${out1} ${out2} + done + +rm ${small_pbm} + +# For Pbm converters not tested here see pbm-misc-converters.test + +# These programs do not have a converter in the opposite direction: +# Brushtopbm +# Ddbugtopbm +# Thinkjettopbm (?) diff --git a/test/stdin-pbm2.ok b/test/stdin-pbm2.ok new file mode 100644 index 00000000..c77f7b13 --- /dev/null +++ b/test/stdin-pbm2.ok @@ -0,0 +1,28 @@ +pbmtoatk: 0 0 0 0 +atktopbm: 0 0 0 0 +pbmtocis: 0 0 0 0 +cistopbm: 0 0 0 0 +pbmtocmuwm: 0 0 0 0 +cmuwmtopbm: 0 0 0 0 +pbmtoescp2: 0 0 0 0 +escp2topbm: 0 0 0 0 +pbmtog3: 0 0 0 0 +g3topbm: 0 0 0 0 +pbmtogem: 0 0 0 0 +gemtopnm: 0 0 0 0 +pbmtomacp: 0 0 0 0 +macptopbm: 0 0 0 0 +pbmtomda: 0 0 0 0 +mdatopbm: 0 0 0 0 +pbmtomgr: 0 0 0 0 +mgrtopbm: 0 0 0 0 +pbmtomrf: 0 0 0 0 +mrftopbm: 0 0 0 0 +pbmtopi3: 0 0 0 0 +pi3topbm: 0 0 0 0 +pbmtosunicon: 0 0 0 0 +sunicontopnm: 0 0 0 0 +pbmtowbmp: 0 0 0 0 +wbmptopbm: 0 0 0 0 +pbmtoybm: 0 0 0 0 +ybmtopbm: 0 0 0 0 diff --git a/test/stdin-pbm2.test b/test/stdin-pbm2.test new file mode 100755 index 00000000..ba585516 --- /dev/null +++ b/test/stdin-pbm2.test @@ -0,0 +1,78 @@ +#! /bin/sh +# This script tests: atktopbm pbmtoatk +# This script tests: cistopbm pbmtocis +# This script tests: cmuwmtopbm pbmtocmuwm +# This script tests: escp2topbm pbmtoescp2 +# This script tests: g3topbm pbmtog3 +# This script tests: gemtopnm pbmtogem +# This script tests: macptopbm pbmtomacp +# This script tests: mdatopbm pbmtomda +# This script tests: mgrtopbm pbmtomgr +# This script tests: mrftopbm pbmtomrf +# This script tests: pi3topbm pbmtopi3 +# This script tests: sunicontopnm pbmtosunicon +# This script tests: wbmptopbm pbmtowbmp +# This script tests: ybmtopbm pbmtoybm +# Also requires: + +tmpdir=${tmpdir:-/tmp} +out1=${tmpdir}/out1 +out2=${tmpdir}/out2 +out3=${tmpdir}/out3 +out4=${tmpdir}/out4 + +for fmt in \ + atk \ + cis \ + cmuwm \ + escp2 \ + g3 \ + gem \ + macp \ + mda \ + mgr \ + mrf \ + pi3 \ + sunicon \ + wbmp \ + ybm + do + testprog1="pbmto"${fmt} + + if [ ${fmt} = "sunicon" -o ${fmt} = "gem" ]; + then testprog2=${fmt}"topnm"; + else testprog2=${fmt}"topbm"; + fi + + ${testprog1} testgrid.pbm > ${out1}; status1=$? + ${testprog1} < testgrid.pbm > ${out2}; status2=$? + test -s ${out1}; status3=$? + cmp -s ${out1} ${out2} + echo ${testprog1}": "${status1} ${status2} ${status3} $? + rm ${out2} + + ${testprog2} ${out1} > ${out3}; status3=$? + ${testprog2} < ${out1} > ${out4}; status4=$? + + if [ ${fmt} = "xbm" ]; + then sed -i '3s/noname/testgrid/' ${out3}; + fi + + test -s ${out3}; status5=$? + cmp -s ${out3} ${out4} + echo ${testprog2}": "${status3} ${status4} ${status5} $? + rm ${out1} ${out3} ${out4} + done + +# We don't test Pbmtopgm Pgmtopbm Asciitopbm Asciitopgm here + +# Pbmtopk Pktopbm require resolution output pk file, tk file +# some conditions apply to input image dimensions + +# These three programs embed the input file name in the output +# If the input is from stdin, "noname" +# Pbmtolps tested in lps-roundtrip.test +# Pbmtoxbm xbm-roundtrip.test +# Pbmtozinc pbm-misc-converters.test + +# Icontopbm Pbmtoicon Pbmtox10bm are legacy diff --git a/test/stdin-pgm1.ok b/test/stdin-pgm1.ok new file mode 100644 index 00000000..b3159517 --- /dev/null +++ b/test/stdin-pgm1.ok @@ -0,0 +1,11 @@ +pgmabel: 0 0 0 0 +pgmbentley: 0 0 0 0 +pgmdeshadow: 0 0 0 0 +pgmenhance: 0 0 0 0 +pgmhist: 0 0 0 0 +pgmmedian: 0 0 0 0 +pgmminkowski: 0 0 0 0 +pgmtexture: 0 0 0 0 +pgmtopbm -th : 0 0 0 0 +pgmtoppm rgb:00/00/00 : 0 0 0 0 +rawtopgm -headerskip 11 3 3 : 0 0 0 0 diff --git a/test/stdin-pgm1.test b/test/stdin-pgm1.test new file mode 100755 index 00000000..f5980cdc --- /dev/null +++ b/test/stdin-pgm1.test @@ -0,0 +1,47 @@ +#! /bin/sh +# This script tests: pgmabel pgmbentley pgmdeshadow pgmenhance pgmhist +# This script tests: pgmmedian pgmminkowski pgmtexture pgmtopbm pgmtoppm +# This script tests: rawtopgm +# Also requires: pgmmake + +tmpdir=${tmpdir:-/tmp} +small_pgm=${tmpdir}/small.pgm +out1=${tmpdir}/out1 +out2=${tmpdir}/out2 +out3=${tmpdir}/out3 +out4=${tmpdir}/out4 + +pgmmake 0.5 3 3 > ${small_pgm} + +for testprog in \ + pgmabel \ + pgmbentley \ + pgmdeshadow \ + pgmenhance \ + pgmhist \ + pgmmedian \ + pgmminkowski \ + pgmtexture \ + "pgmtopbm -th " \ + "pgmtoppm rgb:00/00/00 " \ + "rawtopgm -headerskip 11 3 3 " + do + ${testprog} ${small_pgm} > ${out1}; status1=$? + ${testprog} < ${small_pgm} > ${out2}; status2=$? + test -s ${out1}; status3=$? + cmp -s ${out1} ${out2} + echo ${testprog}": "${status1} ${status2} ${status3} $? + rm ${out1} ${out2} + done + +rm ${small_pgm} + + +# Pgmtopgm accepts input only from stdin + +# These three programs are legacy +# Pgmedge +# Pgmnorm +# Pgmoil + +# Pgmmorphconv needs template file diff --git a/test/stdin-pgm2.ok b/test/stdin-pgm2.ok new file mode 100644 index 00000000..ee6d8082 --- /dev/null +++ b/test/stdin-pgm2.ok @@ -0,0 +1,6 @@ +pgmtofs : 0 0 0 0 +fstopgm : 0 0 0 0 +pgmtolispm : 0 0 0 0 +lispmtopgm : 0 0 0 0 +pgmtost4 : 0 0 0 0 +st4topgm : 0 0 0 0 diff --git a/test/stdin-pgm2.test b/test/stdin-pgm2.test new file mode 100755 index 00000000..3a6220d8 --- /dev/null +++ b/test/stdin-pgm2.test @@ -0,0 +1,49 @@ +#! /bin/sh +# This script tests: pgmtofs fstopgm +# This script tests: pgmtolispm lispmtopgm +# This script tests: pgmtost4 st4topgm +# Also requires: pgmmake + +tmpdir=${tmpdir:-/tmp} +test_pgm=${tmpdir}/test.pgm +out1=${tmpdir}/out1 +out2=${tmpdir}/out2 +out3=${tmpdir}/out3 +out4=${tmpdir}/out4 + +pgmmake 0.75 192 165 > ${test_pgm} + +for fmt in \ + fs \ + lispm \ + st4 + do + testprog1="pgmto"${fmt} + testprog2=${fmt}"topgm" + + ${testprog1} ${test_pgm} > ${out1}; status1=$? + ${testprog1} < ${test_pgm} > ${out2}; status2=$? + test -s ${out1}; status3=$? + cmp -s ${out1} ${out2} + echo ${testprog1}" :" ${status1} ${status2} ${status3} $? + rm ${out2} + + ${testprog2} ${out1} > ${out3}; status4=$? + ${testprog2} < ${out1} > ${out4}; status5=$? + test -s ${out3}; status6=$? + cmp -s ${out3} ${out4} + echo ${testprog2}" :" ${status4} ${status5} ${status6} $? + + rm ${out1} ${out3} ${out4} + done + +rm ${test_pgm} + +# pgmtost4 size must be 192 x 165 + +# The following programs do not have converters in the opposite direction: +# Bioradtopgm +# Hipstopgm +# Psidtopgm +# Rawtopgm +# Spottopgm diff --git a/test/stdin-pnm1.ok b/test/stdin-pnm1.ok new file mode 100644 index 00000000..9f427b23 --- /dev/null +++ b/test/stdin-pnm1.ok @@ -0,0 +1,22 @@ +pnmalias: 0 0 0 0 +pnmcolormap all : 0 0 0 0 +pnmconvol -matrix=-1,3,-1 : 0 0 0 0 +pnmcrop: 0 0 0 0 +pnmgamma -ungamma 0.5 : 0 0 0 0 +pnmhisteq: 0 0 0 0 +pnmhistmap: 0 0 0 0 +pnminvert: 0 0 0 0 +pnmmargin 2 : 0 0 0 0 +pnmmercator: 0 0 0 0 +pnmmontage: 0 0 0 0 +pnmnlfilt 0.5 0.5 : 0 0 0 0 +pnmnorm: 0 0 0 0 +pnmpad: 0 0 0 0 +pnmquant 64 : 0 0 0 0 +pnmrotate 90 : 0 0 0 0 +pnmscalefixed 1 : 0 0 0 0 +pnmshear 45 : 0 0 0 0 +pnmsmooth: 0 0 0 0 +pnmtile 4 4 : 0 0 0 0 +pnmtoddif: 0 0 0 0 +pnmtopclxl -colorok : 0 0 0 0 diff --git a/test/stdin-pnm1.test b/test/stdin-pnm1.test new file mode 100755 index 00000000..20902d41 --- /dev/null +++ b/test/stdin-pnm1.test @@ -0,0 +1,59 @@ +#! /bin/sh +# This script tests: pnmalias pnmcolormap pnmconvol pnmcrop pnmgamma +# This script tests: pnmhisteq pnmhistmap pnminvert pnmmargin pnmmercator +# This script tests: pnmmontage pnmnlfilt pnmnorm pnmpad pnmquant pnmrotate +# This script tests: pnmscalefixed pnmshear pnmsmooth pnmtile pnmtoddif +# This script tests: pnmtopclxl +# Also requires: ppmpat + +tmpdir=${tmpdir:-/tmp} +small_ppm=${tmpdir}/test.ppm +out1=${tmpdir}/out1 +out2=${tmpdir}/out2 + +ppmpat -g2 -color=rgb:00/00/ff,rgb:ff/00/00 -mesh 4 4 > ${small_ppm} + +for testprog in \ + pnmalias \ + "pnmcolormap all " \ + "pnmconvol -matrix=-1,3,-1 " \ + pnmcrop \ + "pnmgamma -ungamma 0.5 " \ + pnmhisteq \ + pnmhistmap \ + pnminvert \ + "pnmmargin 2 " \ + pnmmercator \ + pnmmontage \ + "pnmnlfilt 0.5 0.5 " \ + pnmnorm \ + pnmpad \ + "pnmquant 64 " \ + "pnmrotate 90 " \ + "pnmscalefixed 1 " \ + "pnmshear 45 " \ + pnmsmooth \ + "pnmtile 4 4 " \ + pnmtoddif \ + "pnmtopclxl -colorok " + do + ${testprog} ${small_ppm} > ${out1}; status1=$? + ${testprog} < ${small_ppm} > ${out2}; status2=$? + test -s ${out1}; status3=$? + cmp -s ${out1} ${out2} + echo ${testprog}": "${status1} ${status2} ${status3} $? + rm ${out1} ${out2} + done + + +rm ${small_ppm} + +# Pnmquantall: overwrites input files +# Pnmremap: requires -mapfile=file +# Pnmpsnr : compares two input files +# Pnmindex: no input from stdin +# Pnmpaste: requires two input files +# Pnmstitch: requires two input files + +# pnmmargin: uses pamflip +# pnmsmooth: uses pnmconvol diff --git a/test/stdin-pnm2.ok b/test/stdin-pnm2.ok new file mode 100644 index 00000000..093ff3f7 --- /dev/null +++ b/test/stdin-pnm2.ok @@ -0,0 +1,28 @@ +Test. Should print (command): 0 0 0 +The following are exceptions: should print (command): 0 0 0 1 +pnmtops, pstopnm, pnmtoxwd, pnmtotiffcmyk + +pnmtofiasco --progress-meter 0 : 0 0 0 0 +fiascotopnm: 0 0 0 0 +pnmtojbig: 0 0 0 0 +jbigtopnm: 0 0 0 0 +pnmtojpeg: 0 0 0 0 +jpegtopnm: 0 0 0 0 +pnmtopalm: 0 0 0 0 +palmtopnm: 0 0 0 0 +pnmtopng: 0 0 0 0 +pngtopam: 0 0 0 0 +pnmtops: 0 0 0 1 +pstopnm -stdout : 0 0 0 1 +pnmtorast: 0 0 0 0 +rasttopnm: 0 0 0 0 +pnmtorle: 0 0 0 0 +rletopnm: 0 0 0 0 +pnmtosgi: 0 0 0 0 +sgitopnm: 0 0 0 0 +pnmtosir: 0 0 0 0 +sirtopnm: 0 0 0 0 +pnmtoxwd: 0 0 0 1 +xwdtopnm: 0 0 0 0 +pnmtotiffcmyk: 0 0 0 1 +tifftopnm: 0 0 0 0 diff --git a/test/stdin-pnm2.test b/test/stdin-pnm2.test new file mode 100755 index 00000000..7622c279 --- /dev/null +++ b/test/stdin-pnm2.test @@ -0,0 +1,91 @@ +#! /bin/sh +# This script tests: pnmtofiasco fiascotopnm +# This script tests: pnmtojbig jbigtopnm +# This script tests: pnmtojpeg jpegtopnm +# This script tests: pnmtopalm palmtopnm +# This script tests: pnmtopng pngtopam +# This script tests: pnmtops pstopnm +# This script tests: pnmtorast rasttopnm +# This script tests: pnmtorle rletopnm +# This script tests: pnmtosgi sgitopnm +# This script tests: pnmtosir sirtopnm +# This script tests: pnmtoxwd xwdtopnm +# This script tests: pnmtotiffcmyk tifftopnm +# Also requires: pgmramp + +tmpdir=${tmpdir:-/tmp} +test_pgm=${tmpdir}/test.pgm +out1=${tmpdir}/out1 +out2=${tmpdir}/out2 +out3=${tmpdir}/out3 +out4=${tmpdir}/out4 + +pgmramp -diag 32 32 > ${test_pgm} + +echo "Test. Should print (command): 0 0 0" +echo "The following are exceptions: should print (command): 0 0 0 1" +echo "pnmtops, pstopnm, pnmtoxwd, pnmtotiffcmyk" +echo + +export NO_ADD_RLE_HISTORY=1 +# Suppress command-line sequence, execution time in pnmtorle header + +for fmt in \ + fiasco \ + jbig \ + jpeg \ + palm \ + png \ + ps \ + rast \ + rle \ + sgi \ + sir \ + xwd \ + tiffcmyk + do + + if [ ${fmt} = "fiasco" ] + then testprog1="pnmto"${fmt}" --progress-meter 0 "; + else + testprog1="pnmto"${fmt}; + fi + + if [ ${fmt} = "png" ] + then testprog2="pngtopam"; + elif [ ${fmt} = "ps" ] + then testprog2="pstopnm -stdout "; + elif [ ${fmt} = "tiffcmyk" ] + then testprog2="tifftopnm"; + else + testprog2=${fmt}"topnm"; + fi + + ${testprog1} ${test_pgm} > ${out1}; status1=$? + ${testprog1} < ${test_pgm} > ${out2}; status2=$? + test -s ${out1}; status3=$? + cmp -s ${out1} ${out2} + echo ${testprog1}": "${status1} ${status2} ${status3} $? + rm ${out2} + + ${testprog2} ${out1} > ${out3}; status4=$? + ${testprog2} < ${out1} > ${out4}; status5=$? + test -s ${out3}; status6=$? + cmp -s ${out3} ${out4} + echo ${testprog2}": "${status4} ${status5} ${status6} $? + rm ${out1} ${out3} ${out4} + + done + +rm ${test_pgm} + + +# pnmtofiasco width, height must be even and at least 32 +# use --progressmeter option to suppress progress meter +# +# pnmtojbig input must be bilevel black-white or gray +# pnmtops input file name embedded in output +# pnmtotiffcmyk input file name embedded in output +# "Standard input" if from stdin +# pnmtoxwd input file name embedded in output +# "stdin" if from stdin diff --git a/test/stdin-ppm1.ok b/test/stdin-ppm1.ok new file mode 100644 index 00000000..e84a31ea --- /dev/null +++ b/test/stdin-ppm1.ok @@ -0,0 +1,15 @@ +ppmchange: 0 0 0 0 +ppmcolormask -color=rgb:0/0/ff : 0 0 0 0 +ppmdim 0.5 : 0 0 0 0 +ppmdist: 0 0 0 0 +ppmdither: 0 0 0 0 +ppmflash 0.5 : 0 0 0 0 +ppmglobe 12 : 0 0 0 0 +ppmhist: 0 0 0 0 +ppmlabel: 0 0 0 0 +ppmntsc: 0 0 0 0 +ppmrelief: 0 0 0 0 +ppmshadow: 0 0 0 0 +ppmshift 2 -seed=1 : 0 0 0 0 +ppmspread 2 -randomseed=1 : 0 0 0 0 +ppmtv 0.5 : 0 0 0 0 diff --git a/test/stdin-ppm1.test b/test/stdin-ppm1.test new file mode 100755 index 00000000..84614326 --- /dev/null +++ b/test/stdin-ppm1.test @@ -0,0 +1,58 @@ +#! /bin/sh +# This script tests: ppmchange ppmcolormask ppmdim ppmdist ppmdither ppmflash +# This script tests: ppmglobe ppmhist ppmlabel ppmntsc ppmrelief ppmshadow +# This script tests: ppmshift ppmspread ppmtv +# Also requires: ppmpat + +tmpdir=${tmpdir:-/tmp} +test_ppm=${tmpdir}/test.ppm +out1=${tmpdir}/out1 +out2=${tmpdir}/out2 + +ppmpat -g2 -color=rgb:00/00/ff,rgb:ff/00/00 -mesh 12 12 > ${test_ppm} + +for testprog in \ + ppmchange \ + "ppmcolormask -color=rgb:0/0/ff " \ + "ppmdim 0.5 " \ + ppmdist \ + ppmdither \ + "ppmflash 0.5 " \ + "ppmglobe 12 " \ + ppmhist \ + ppmlabel \ + ppmntsc \ + ppmrelief \ + ppmshadow \ + "ppmshift 2 -seed=1 " \ + "ppmspread 2 -randomseed=1 " \ + "ppmtv 0.5 " + do + ${testprog} ${test_ppm} > ${out1}; status1=$? + ${testprog} < ${test_ppm} > ${out2}; status2=$? + test -s ${out1}; status3=$? + cmp -s ${out1} ${out2} + echo ${testprog}": "${status1} ${status2} ${status3} $? + rm ${out1} ${out2} + done + +rm ${test_ppm} + +# These utlities do not have a counterpart "ppmto*" program + +# Gouldtoppm +# Imgtoppm +# Mtvtoppm +# Pc1toppm +# Pgmtoppm +# Qrttoppm +# Rawtoppm +# Sldtoppm +# Spctoppm +# Ximtoppm + +# Tgatoppm -> Pamtotga +# Xvminitoppm -> Pamtoxvmini + +# Ppm3d and Ppmmix require input two files +# Ppmfade produces a series of output files diff --git a/test/stdin-ppm2.ok b/test/stdin-ppm2.ok new file mode 100644 index 00000000..e1335bfb --- /dev/null +++ b/test/stdin-ppm2.ok @@ -0,0 +1,11 @@ +ppmtoacad: 0 0 0 0 +ppmtoapplevol: 0 0 0 0 +ppmtoascii: 0 0 0 0 +ppmtoicr -windowname testimage: 0 0 0 0 +ppmtolj: 0 0 0 0 +ppmtomitsu: 0 0 0 0 +ppmtopgm: 0 0 0 0 +ppmtopuzz: 0 0 0 0 +ppmtosixel: 0 0 0 0 +ppmtoterm: 0 0 0 0 +ppmtoyuvsplit: 0 0 0 0 diff --git a/test/stdin-ppm2.test b/test/stdin-ppm2.test new file mode 100755 index 00000000..e43b6d4c --- /dev/null +++ b/test/stdin-ppm2.test @@ -0,0 +1,58 @@ +#! /bin/sh +# This script tests: ppmtoacad ppmtoapplevol ppmtoascii ppmtolj ppmtomitsu +# This script tests: ppmtopgm ppmtopuzz ppmtosixel ppmtoterm +# This script tests: ppmtoicr ppmtoyuvsplit +# Also requires: ppmpat + +tmpdir=${tmpdir:-/tmp} +test_ppm=${tmpdir}/test.ppm +out1=${tmpdir}/out1 +out2=${tmpdir}/out2 + +ppmpat -g2 -color=rgb:00/00/ff,rgb:ff/00/00 -mesh 12 12 > ${test_ppm} + +# These converters do not have counterparts in the reverse direction + +for testprog in \ + ppmtoacad \ + ppmtoapplevol \ + ppmtoascii \ + "ppmtoicr -windowname testimage" \ + ppmtolj \ + ppmtomitsu \ + ppmtopgm \ + ppmtopuzz \ + ppmtosixel \ + ppmtoterm + do + ${testprog} ${test_ppm} > ${out1}; status1=$? + ${testprog} < ${test_ppm} > ${out2}; status2=$? + test -s ${out1}; status3=$? + cmp -s ${out1} ${out2} + echo ${testprog}": "${status1} ${status2} ${status3} $? + rm ${out1} ${out2} + done + +rm ${test_ppm} + +testprog=ppmtoyuvsplit + +# Produces three output files + + ${testprog} ${tmpdir}/base testgrid.pbm; status1=$? + cat ${tmpdir}/base.Y ${tmpdir}/base.U ${tmpdir}/base.V > ${out1} + rm ${tmpdir}/base.Y ${tmpdir}/base.U ${tmpdir}/base.V + + ${testprog} ${tmpdir}/base < testgrid.pbm; status2=$? + cat ${tmpdir}/base.Y ${tmpdir}/base.U ${tmpdir}/base.V > ${out2} + rm ${tmpdir}/base.Y ${tmpdir}/base.U ${tmpdir}/base.V + test -s ${out1}; status3=$? + cmp -s ${out1} ${out2} + echo ${testprog}": "${status1} ${status2} ${status3} $? + rm ${out1} ${out2} + +# Ppmtoppm input is from standard input + +# Ppmtoapplevol height must be 12 +# Ppmtoarbtxt needs body template file +# Ppmtompeg parameter file must be given diff --git a/test/stdin-ppm3.ok b/test/stdin-ppm3.ok new file mode 100644 index 00000000..42932e92 --- /dev/null +++ b/test/stdin-ppm3.ok @@ -0,0 +1,20 @@ +ppmtobmp: 0 0 0 0 +bmptopnm: 0 0 0 0 +ppmtoilbm: 0 0 0 0 +ilbmtoppm: 0 0 0 0 +ppmtoleaf: 0 0 0 0 +leaftoppm: 0 0 0 0 +ppmtoneo: 0 0 0 0 +neotoppm: 0 0 0 0 +ppmtopcx: 0 0 0 0 +pcxtoppm: 0 0 0 0 +ppmtopi1: 0 0 0 0 +pi1toppm: 0 0 0 0 +ppmtopict: 0 0 0 0 +picttoppm: 0 0 0 0 +ppmtopj: 0 0 0 0 +pjtoppm: 0 0 0 0 +ppmtospu: 0 0 0 0 +sputoppm: 0 0 0 0 +ppmtoxpm -name small: 0 0 0 0 +xpmtoppm: 0 0 0 0 diff --git a/test/stdin-ppm3.test b/test/stdin-ppm3.test new file mode 100755 index 00000000..1313ac40 --- /dev/null +++ b/test/stdin-ppm3.test @@ -0,0 +1,75 @@ +#! /bin/sh +# This script tests: ppmtobmp bmptopnm +# This script tests: ppmtoilbm ilbmtoppm +# This script tests: ppmtoleaf leaftoppm +# This script tests: ppmtoneo neotoppm +# This script tests: ppmtopcx pcxtoppm +# This script tests: ppmtopi1 pi1toppm +# This script tests: ppmtopict picttoppm +# This script tests: ppmtopj pjtoppm +# This script tests: ppmtospu sputoppm +# This script tests: ppmtoxpm xpmtoppm +# Also requires: ppmmake + +tmpdir=${tmpdir:-/tmp} +small_ppm=${tmpdir}/small.ppm +large_ppm=${tmpdir}/large.ppm +out1=${tmpdir}/out1 +out2=${tmpdir}/out2 +out3=${tmpdir}/out3 +out4=${tmpdir}/out4 + +ppmmake -maxval 65535 rgb:00/00/00 8 3 > ${small_ppm} +ppmmake -maxval 7 rgb:00/00/00 320 200 > ${large_ppm} + +for fmt in \ + bmp \ + ilbm \ + leaf \ + neo \ + pcx \ + pi1 \ + pict \ + pj \ + spu \ + xpm +do + if [ ${fmt} = "xpm" ] + then testprog1="ppmto${fmt} -name small"; + else testprog1="ppmto${fmt}"; + fi + if [ ${fmt} = "bmp" ] + then testprog2=${fmt}"topnm"; + else testprog2=${fmt}"toppm"; + fi + + if [ ${fmt} = "spu" ] + then test_ppm=${large_ppm}; + else test_ppm=${small_ppm}; + fi + + ${testprog1} ${test_ppm} > ${out1}; status1=$? + ${testprog1} < ${test_ppm} > ${out2}; status2=$? + test -s ${out1}; status3=$? + cmp -s ${out1} ${out2} + echo ${testprog1}": "${status1} ${status2} ${status3} $? + rm ${out2} + + ${testprog2} ${out1} > ${out3}; status4=$? + ${testprog2} < ${out1} > ${out4}; status5=$? + test -s ${out1}; status6=$? + cmp -s ${out3} ${out4} + echo ${testprog2}": "${status4} ${status5} ${status6} $? + rm ${out1} ${out3} ${out4} + done + +rm ${small_ppm} ${large_ppm} + +# ppmtopict width must be 8 or more + +# ppmtospu sputoppm width=320 height=200 fixed + +# Eyuvtoppm, Yuvtoppm width, height are mandatory + +# Ppmtowinicon Winicontoppm legacy +# Winicontoppm max size 255 255 diff --git a/test/sunicon-roundtrip.ok b/test/sunicon-roundtrip.ok index 845be5fb..8bfdc3a0 100644 --- a/test/sunicon-roundtrip.ok +++ b/test/sunicon-roundtrip.ok @@ -1 +1,4 @@ -2425386270 41 +Test. Should print 0 three times +0 +0 +0 diff --git a/test/sunicon-roundtrip.test b/test/sunicon-roundtrip.test index a52fda68..38513ea8 100755 --- a/test/sunicon-roundtrip.test +++ b/test/sunicon-roundtrip.test @@ -1,8 +1,26 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmtosunicon sunicontopnm -# Also requires: pamcut +# Also requires: pbmnoise -# Width of Sun icons are multiples of 8. +# Width of a Sun icon is always a multiple of 8. -# Test. Should print: 2425386270 41 -pbmtosunicon testgrid.pbm | sunicontopnm | pamcut 1 0 14 16 | cksum +tmpdir=${tmpdir:-/tmp} + +noise16_pbm=${tmpdir}/noise16.pbm +noise32_pbm=${tmpdir}/noise32.pbm +noise64_pbm=${tmpdir}/noise64.pbm + +echo "Test. Should print 0 three times" +pbmnoise -randomseed=1 16 16 > ${noise16_pbm} && \ + pbmtosunicon ${noise16_pbm} | sunicontopnm | cmp -s - ${noise16_pbm} + echo $? + +pbmnoise -randomseed=1 32 32 > ${noise32_pbm} && \ + pbmtosunicon ${noise32_pbm} | sunicontopnm | cmp -s - ${noise32_pbm} + echo $? + +pbmnoise -randomseed=1 64 64 > ${noise64_pbm} && \ + pbmtosunicon ${noise64_pbm} | sunicontopnm | cmp -s - ${noise64_pbm} + echo $? + +rm ${noise16_pbm} ${noise32_pbm} ${noise64_pbm} \ No newline at end of file diff --git a/test/sunrast-roundtrip.test b/test/sunrast-roundtrip.test index a5cfa8c7..dfe68402 100755 --- a/test/sunrast-roundtrip.test +++ b/test/sunrast-roundtrip.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pnmtorast rasttopnm # Also requires: diff --git a/test/symmetry.ok b/test/symmetry.ok index a5945014..111f09cf 100644 --- a/test/symmetry.ok +++ b/test/symmetry.ok @@ -1,5 +1,8 @@ +Test 1. ok +Test 2. ok +Test 3. Should print ok 7 times ok ok ok @@ -7,7 +10,9 @@ ok ok ok ok +Test 4. ok +Test 5. Should print ok 7 times. ok ok ok @@ -15,4 +20,5 @@ ok ok ok ok +Test 6. ok diff --git a/test/symmetry.test b/test/symmetry.test index 52ba6388..3c495778 100755 --- a/test/symmetry.test +++ b/test/symmetry.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pgmramp pamgauss pgmkernel pbmmake pbmpscale # Also requires: pamflip @@ -25,7 +25,7 @@ tmpdir=${tmpdir:-/tmp} -# Test 1. +echo "Test 1." rect_pgm=${tmpdir}/rect.pgm pgmramp -rect 31 31 > ${rect_pgm} @@ -37,7 +37,8 @@ pgmramp -rect 31 31 > ${rect_pgm} rm ${rect_pgm} -# Test 2. + +echo "Test 2." circle_pgm=${tmpdir}/circle.pgm pgmramp -ell 63 63 > ${circle_pgm} @@ -48,7 +49,8 @@ pgmramp -ell 63 63 > ${circle_pgm} rm ${circle_pgm} -# Test 3. Should print "ok" 7 times + +echo "Test 3. Should print ok 7 times" gauss_pgm=${tmpdir}/gauss.pgm for size in 3 4 5 8 13 21 25 do @@ -63,7 +65,7 @@ rm ${gauss_pgm} done -# Test 4. +echo "Test 4." kernel_pgm=${tmpdir}/kernel.pgm pgmkernel 15 15 > ${kernel_pgm} @@ -74,12 +76,12 @@ pgmkernel 15 15 > ${kernel_pgm} rm ${kernel_pgm} -# Test 5. -# Should print "ok" 7 times. + +echo "Test 5. Should print ok 7 times." pscale_pbm=${tmpdir}/pscale.pbm -for size in `seq 1 7` -do -pbmmake -g 5 5 | pbmpscale $size > ${pscale_pbm} +for size in 1 2 3 4 5 6 7 # for size in `seq 7` + do + pbmmake -g 5 5 | pbmpscale ${size} > ${pscale_pbm} ( for op in -null -tb -lr -r90 do pamflip $op ${pscale_pbm} | cksum @@ -89,7 +91,8 @@ pbmmake -g 5 5 | pbmpscale $size > ${pscale_pbm} rm ${pscale_pbm} done -# Test 6. + +echo "Test 6." ell_pgm=${tmpdir}/ell.pgm pgmramp -ell 101 33 > ${ell_pgm} diff --git a/test/targa-roundtrip.ok b/test/targa-roundtrip.ok index 514f970f..beb6700e 100644 --- a/test/targa-roundtrip.ok +++ b/test/targa-roundtrip.ok @@ -1,15 +1,15 @@ -Test 1 -2425386270 41 -2425386270 41 -2425386270 41 -2425386270 41 -2425386270 41 -2425386270 41 -2425386270 41 -2425386270 41 -2425386270 41 -2425386270 41 -Test 2 +Test 1: Should print 281226646 481 ten times +281226646 481 +281226646 481 +281226646 481 +281226646 481 +281226646 481 +281226646 481 +281226646 481 +281226646 481 +281226646 481 +281226646 481 +Test 2: Should produce 1571496937 33838 ten times 1571496937 33838 1571496937 33838 1571496937 33838 @@ -20,19 +20,19 @@ Test 2 1571496937 33838 1571496937 33838 1571496937 33838 -Test 3 +Test 3. Should print 1926073387 101484 four times 1926073387 101484 1926073387 101484 1926073387 101484 1926073387 101484 -Test 4 +Test 4. Should print 0 0 0 : 0 six times 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 +Test 4. Should print 0 0 0 : 0 twice, then 0 0 0 0 : 0 six times 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 79b01b61..2dd04e91 100755 --- a/test/targa-roundtrip.test +++ b/test/targa-roundtrip.test @@ -4,25 +4,21 @@ tmpdir=${tmpdir:-/tmp} -#Test 1: Should print 2425386270 41, cksum of testgrid.pbm, ten times - -echo "Test 1" +echo "Test 1: Should print 281226646 481 ten times" for mode in "-mono" "-mono -norle" \ "-cmap" "-cmap -norle" "-cmap16" "-cmap16 -norle" \ "-rgb" "-rgb -norle" "" "-norle" do - pamtotga ${mode} testgrid.pbm | \ + pamtotga ${mode} maze.pbm | \ tgatoppm | ppmtopgm | \ pgmtopbm -threshold -val 0.5 | cksum done -#Test 2: Should produce 1571496937 33838, cksum of testimg.red, ten times - -echo "Test 2" +echo "Test 2: Should produce 1571496937 33838 ten times" test_pam=${tmpdir}/testimg.pgm -pamchannel -infile=testimg.ppm -tupletype="GRAYSCALE" 0 > ${test_pam} +pamchannel -infile=testimg.ppm -tupletype="GRAYSCALE" 0 > ${test_pam} for mode in "-mono" "-mono -norle" \ "-cmap" "-cmap -norle" "-cmap16" "-cmap16 -norle" \ @@ -33,19 +29,14 @@ for mode in "-mono" "-mono -norle" \ rm ${test_pam} - -#Test 3: Should print 1926073387 101484, cksum of testimg.ppm, four times - -echo "Test 3" +echo "Test 3. Should print 1926073387 101484 four times" 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" +echo "Test 4. Should print 0 0 0 : 0 six times" test256_ppm=${tmpdir}/test256.ppm pnmquant 256 testimg.ppm > ${test256_ppm} || echo "pnmquant failed" @@ -57,10 +48,7 @@ for mode in "-rgb" "-rgb -norle" "-cmap" "-cmap -norle" "" "-norle" echo ${PIPESTATUS[@]} ":" $? done - -#Test 5: Should print 0 eight times - -echo "Test 5" +echo "Test 4. Should print 0 0 0 : 0 twice, then 0 0 0 0 : 0 six times" test256_31_ppm=${tmpdir}/test256-31.ppm pamdepth 31 ${test256_ppm} > ${test256_31_ppm} || echo "pamdepth failed" diff --git a/test/test-invalid.inc b/test/test-invalid.inc new file mode 100644 index 00000000..e24cfd3f --- /dev/null +++ b/test/test-invalid.inc @@ -0,0 +1,16 @@ +echo 1>&2 +echo "Invalid command-line argument combination(s)." 1>&2 +echo "Error message(s) should appear below the line." 1>&2 +echo "-----------------------------------------------------------" 1>&2 + +tmpdir=${tmpdir:-/tmp} +test_out=${tmpdir}/test_out + +# define function +invCmd () { $1 > ${test_out} && \ + printf "Unexpected success ${testcnt} " || printf "Expected failure ${testcnt} " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + testcnt=$(($testcnt +1)); } + +testcnt=1 diff --git a/test/test1.info b/test/test1.info new file mode 100644 index 00000000..5510d8e8 --- /dev/null +++ b/test/test1.info Binary files differdiff --git a/test/test2.info b/test/test2.info new file mode 100644 index 00000000..7ddb5a6b --- /dev/null +++ b/test/test2.info Binary files differdiff --git a/test/tiff-flate-lzw-roundtrip.ok b/test/tiff-flate-lzw-roundtrip.ok index 4d5597cc..b3b0e1e7 100644 --- a/test/tiff-flate-lzw-roundtrip.ok +++ b/test/tiff-flate-lzw-roundtrip.ok @@ -1,7 +1,9 @@ +Test 1. Should print 1079668603 10237 six times 1079668603 10237 1079668603 10237 1079668603 10237 1079668603 10237 1079668603 10237 1079668603 10237 -2425386270 41 +Test 2. Should print 281226646 481 +281226646 481 diff --git a/test/tiff-flate-lzw-roundtrip.test b/test/tiff-flate-lzw-roundtrip.test index 59d4c483..2b0a4536 100755 --- a/test/tiff-flate-lzw-roundtrip.test +++ b/test/tiff-flate-lzw-roundtrip.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamtotiff tifftopnm # Also requires: ppmpat @@ -8,11 +8,11 @@ ## features. tmpdir=${tmpdir:-/tmp} - tartan_ppm=${tmpdir}/testimg40.ppm # Make a test image with reduced colors which compresses better -# cksum is 1079668603 10237 + +echo "Test 1. Should print 1079668603 10237 six times" ppmpat -tartan --color=rgb:32/0d/b7,rgb:31/58/a3,rgb:e9/5e/d4 71 48 | \ tee ${tartan_ppm} | cksum @@ -28,7 +28,9 @@ pamtotiff -adobeflate ${tartan_ppm} | tifftopnm | cksum pamtotiff -lzw ${tartan_ppm} | tifftopnm | cksum pamtotiff -lzw -predictor=1 ${tartan_ppm} | tifftopnm | cksum -# PBM image: test flate compression -pamtotiff -flate testgrid.pbm | tifftopnm | cksum - rm ${tartan_ppm} + +echo "Test 2. Should print 281226646 481" + +# PBM image: test flate compression +pamtotiff -flate maze.pbm | tifftopnm | cksum diff --git a/test/tiff-roundtrip.ok b/test/tiff-roundtrip.ok index 14258de2..dec662ed 100644 --- a/test/tiff-roundtrip.ok +++ b/test/tiff-roundtrip.ok @@ -1,36 +1,36 @@ -PPM-rose +Test 1:PPM-rose Should print 1926073387 101484 five times 1926073387 101484 1926073387 101484 1926073387 101484 1926073387 101484 1926073387 101484 -PPM-6 +Test 2:PPM-6 Should print 1646869394 29498 four times 1646869394 29498 1646869394 29498 1646869394 29498 1646869394 29498 -PPM-2 +Test 3:PPM-2 Should print 3743909631 14836 four times 3743909631 14836 3743909631 14836 3743909631 14836 3743909631 14836 -PPM-gray +Test 4:PPM-gray Should print 603974118 4954 six times 603974118 4954 603974118 4954 603974118 4954 603974118 4954 603974118 4954 603974118 4954 -PPM-bilevel-black-white +Test 5:PPM-bilevel-black-white Should print 1001018459 4954 four times 1001018459 4954 1001018459 4954 1001018459 4954 1001018459 4954 -PBM -2425386270 41 -2425386270 41 -2425386270 41 -Extract from multi-image TIFF +Test 6:PBM Should print 281226646 481 three times +281226646 481 +281226646 481 +281226646 481 +Test 7:Extract from multi-image TIFF 1926073387 101484 1646869394 29498 3743909631 14836 diff --git a/test/tiff-roundtrip.test b/test/tiff-roundtrip.test index 55aba278..c33ee904 100755 --- a/test/tiff-roundtrip.test +++ b/test/tiff-roundtrip.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamtotiff tifftopnm # Also requires: ppmpat pampick ppmtopgm @@ -13,9 +13,8 @@ argylegray_ppm=${tmpdir}/argyle2.ppm multiimage_tiff=${tmpdir}/multiimage.ppm # PPM image -# Should print 1926073387 101484 five times -echo PPM-rose +echo "Test 1:PPM-rose Should print 1926073387 101484 five times" pamtotiff testimg.ppm | tifftopnm -headerdump | cksum pamtotiff -truecolor testimg.ppm -output ${multiimage_tiff} && \ tifftopnm ${multiimage_tiff} -byrow | cksum @@ -25,9 +24,8 @@ pamtotiff -truecolor -lsb2msb testimg.ppm | \ tifftopnm -respectfillorder | cksum # PPM image with six colors -# Should print 1646869394 29498 four times -echo PPM-6 +echo "Test 2:PPM-6 Should print 1646869394 29498 four times" ppmpat -tartan -color=rgb:0/8/8,rgb:8/f/8,rgb:f/f/0 108 91 | \ tee ${tartan_ppm} | cksum pamtotiff -truecolor ${tartan_ppm} | tifftopnm | cksum @@ -37,12 +35,12 @@ pamtotiff ${tartan_ppm} -append -output ${multiimage_tiff} && \ # PPM image with two colors -# Should print 3743909631 14836 four times -echo PPM-2 +echo "Test 3:PPM-2 Should print 3743909631 14836 four times" ppmpat -argyle2 -color=rgb:0/0/0,rgb:f/8/f,rgb:0/0/0 61 81 | \ tee ${argylecolor_ppm} | cksum -pamtotiff -indexbits=2 ${argylecolor_ppm} -append -output ${multiimage_tiff} && \ +pamtotiff -indexbits=2 ${argylecolor_ppm} -append \ + -output ${multiimage_tiff} && \ tifftopnm ${multiimage_tiff} | pampick 2 | cksum pamtotiff -indexbits=1 ${argylecolor_ppm} | tifftopnm | cksum pamtotiff -indexbits=1 -g4 ${argylecolor_ppm} | tifftopnm | cksum @@ -51,9 +49,8 @@ pamtotiff -indexbits=1 -g4 ${argylecolor_ppm} | tifftopnm | cksum # pamtotiff detects the absence of colors and produces a grayscale # tiff image unless -color is specified # Pipeline output is PGM unless -color is specified -# Should print 603974118 4954 six times -echo PPM-gray +echo "Test 4:PPM-gray Should print 603974118 4954 six times" ppmpat -gingham3 -color=rgb:0/0/0,rgb:ff/ff/ff,rgb:0/0/0 61 81 | \ tee ${gingham_ppm} | ppmtopgm | cksum pamtotiff -color ${gingham_ppm} | tifftopnm | cksum @@ -67,9 +64,8 @@ pamtotiff -mb ${gingham_ppm} -append -output ${multiimage_tiff} && \ # pamtotiff detects the absence of colors and produces a grayscale # tiff image unless -color is specified # Pipeline output is PGM unless -color is specified -# Should print 1001018459 4954 four times -echo PPM-bilevel-black-white +echo "Test 5:PPM-bilevel-black-white Should print 1001018459 4954 four times" ppmpat -argyle2 -color=rgb:0/0/0,rgb:ff/ff/ff,rgb:0/0/0 61 81 | \ tee ${argylegray_ppm} | ppmtopgm | cksum pamtotiff -color -fill ${argylegray_ppm} | tifftopnm | cksum @@ -78,17 +74,17 @@ pamtotiff -mb ${argylegray_ppm} -append -output ${multiimage_tiff} && \ tifftopnm ${multiimage_tiff} | pampick 4 | cksum # PBM image -# Should print 2425386270 41 three times -echo PBM -pamtotiff testgrid.pbm | tifftopnm | cksum -pamtotiff -g3 -fill testgrid.pbm | tifftopnm | cksum -pamtotiff -g4 -mb testgrid.pbm -append -output ${multiimage_tiff} && \ + +echo "Test 6:PBM Should print 281226646 481 three times" +pamtotiff maze.pbm | tifftopnm | cksum +pamtotiff -g3 -fill maze.pbm | tifftopnm | cksum +pamtotiff -g4 -mb maze.pbm -append -output ${multiimage_tiff} && \ tifftopnm ${multiimage_tiff} | pampick 5 | cksum # Extract individual images from multi-image tiff file -echo "Extract from multi-image TIFF" +echo "Test 7:Extract from multi-image TIFF" tifftopnm ${multiimage_tiff} | pampick 0 | cksum tifftopnm ${multiimage_tiff} | pampick 1 | cksum tifftopnm ${multiimage_tiff} | pampick 2 | cksum diff --git a/test/tiffcmyk-roundtrip.test b/test/tiffcmyk-roundtrip.test index 133c81b7..ebbc5666 100755 --- a/test/tiffcmyk-roundtrip.test +++ b/test/tiffcmyk-roundtrip.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pnmtotiffcmyk tifftopnm # Also requires: pnmpsnr diff --git a/test/utahrle-roundtrip.test b/test/utahrle-roundtrip.test index 17f1a6c4..4dce0b40 100755 --- a/test/utahrle-roundtrip.test +++ b/test/utahrle-roundtrip.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pnmtorle rletopnm # Also requires: pamchannel pamtopnm diff --git a/test/wbmp-roundtrip.ok b/test/wbmp-roundtrip.ok index 845be5fb..5168378d 100644 --- a/test/wbmp-roundtrip.ok +++ b/test/wbmp-roundtrip.ok @@ -1 +1 @@ -2425386270 41 +281226646 481 diff --git a/test/wbmp-roundtrip.test b/test/wbmp-roundtrip.test index b651c3d0..cf747487 100755 --- a/test/wbmp-roundtrip.test +++ b/test/wbmp-roundtrip.test @@ -1,7 +1,7 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmtowbmp wbmptopbm # Also requires: -# Should print 2425386270 41, cksum of testgrid.pbm -pbmtowbmp testgrid.pbm | wbmptopbm | cksum +# Should print 281226646 481, cksum of maze.pbm +pbmtowbmp maze.pbm | wbmptopbm | cksum diff --git a/test/winicon-roundtrip.ok b/test/winicon-roundtrip.ok index 4ba2606e..73e5030c 100644 --- a/test/winicon-roundtrip.ok +++ b/test/winicon-roundtrip.ok @@ -3,10 +3,10 @@ Test 1. Should print 4241318573 6973 four times 4241318573 6973 4241318573 6973 4241318573 6973 -Test 1. Should print 819454437 1093 six times -819454437 1093 -819454437 1093 -819454437 1093 -819454437 1093 -819454437 1093 -819454437 1093 +Test 1. Should print 1009647580 1093 six times +1009647580 1093 +1009647580 1093 +1009647580 1093 +1009647580 1093 +1009647580 1093 +1009647580 1093 diff --git a/test/winicon-roundtrip.test b/test/winicon-roundtrip.test index 00c78400..31fb89aa 100755 --- a/test/winicon-roundtrip.test +++ b/test/winicon-roundtrip.test @@ -1,6 +1,7 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamtowinicon ppmtowinicon winicontopam -# Also requires: pamchannel pamcut pamdepth pamtopam pngtopam pnmtile pnmtopng +# Also requires: pamchannel pamcut pamdepth pamtopam +# Also requires: pngtopam pnmtopng tmpdir=${tmpdir:-/tmp} test_pam=${tmpdir}/testimg.pam @@ -18,9 +19,9 @@ pamtowinicon -pngthreshold=1 ${test_pam} | winicontopam | \ rm ${test_pam} -echo "Test 1. Should print 819454437 1093 six times" +echo "Test 1. Should print 1009647580 1093 six times" -pnmtile 32 32 testgrid.pbm | pamtopam | \ +pamcut -top=0 -left=0 -width=32 -height=32 maze.pbm | pamtopam | \ tee ${test_pam} | cksum pamtowinicon ${test_pam} | winicontopam | \ pamdepth 1 | pamchannel -tupletype="BLACKANDWHITE" 0 | cksum @@ -33,5 +34,6 @@ pamtowinicon -pngthreshold=1 ${test_pam} | winicontopam | rm ${test_pam} -pnmtile 32 32 testgrid.pbm | ppmtowinicon | winicontopam | \ +pamcut -top=0 -left=0 -width=32 -height=32 maze.pbm | \ + ppmtowinicon | winicontopam | \ pamdepth 1 | pamchannel -tupletype="BLACKANDWHITE" 0 | cksum diff --git a/test/winicon-roundtrip2.ok b/test/winicon-roundtrip2.ok index bb8c77d8..54ba54e6 100644 --- a/test/winicon-roundtrip2.ok +++ b/test/winicon-roundtrip2.ok @@ -1,3 +1,4 @@ +Should print: former checksum values 16 24 32 48 64 : 1 plane Should print 2588356089 8591 or 3783949470 69390 four times 2588356089 8591 @@ -38,6 +39,7 @@ Should print 2704877198 33359 or 1699833476 276750 four times Should print 2567279592 41655 or 4154838752 345902 twice 2567279592 41655 2567279592 41655 +Should print: latter checksum values 16 32 48 256 : 1 plane Should print 2588356089 8591 or 3783949470 69390 four times 3783949470 69390 diff --git a/test/winicon-roundtrip2.test b/test/winicon-roundtrip2.test index ec074055..de40446e 100755 --- a/test/winicon-roundtrip2.test +++ b/test/winicon-roundtrip2.test @@ -1,13 +1,13 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamtowinicon winicontopam -# Also requires: pamchannel pamdepth pamstack pamtopam pbmmake pngtopam -# Also requires: pnmtopng ppmpat +# Also requires: pamchannel pamdepth pamstack pamtopam pbmmake ppmpat +# Also requires: pngtopam pnmtopng tmpdir=${tmpdir:-/tmp} test_pam=${tmpdir}/testimg.pam test1_pam=${tmpdir}/testimg1.pam test2_pam=${tmpdir}/testimg2.pam -#test3_pam=${tmpdir}/testimg3.pam + test4_pam=${tmpdir}/testimg4.pam test5_pam=${tmpdir}/testimg5.pam black_pam=${tmpdir}/black.pam @@ -19,6 +19,10 @@ gray_pam=${tmpdir}/gray.pam for sizes in "16 24 32 48 64" "16 32 48 256" do + if echo $sizes | awk '{exit !($NF==64)}' ; + then echo "Should print: former checksum values"; + else echo "Should print: latter checksum values"; + fi for size in ${sizes} do @@ -65,11 +69,11 @@ for sizes in "16 24 32 48 64" "16 32 48 256" pamstack ${gray_pam} ${gray_pam} | \ pamchannel -tupletype="GRAYSCALE_ALPHA" 0 1 | tee ${test2_pam} | cksum pamtowinicon ${test2_pam} | winicontopam -allimages | \ - pamchannel -tupletype="GRAYSCALE_ALPHA" 0 1 | cksum + pamchannel -tupletype="GRAYSCALE_ALPHA" 0 1 | pamdepth 255 | cksum pamtowinicon -pngthreshold=300 ${test2_pam} | winicontopam -allimages | \ pamchannel -tupletype="GRAYSCALE_ALPHA" 0 1 | cksum pamtowinicon -pngthreshold=1 ${test2_pam} | winicontopam -allimages | \ - pamchannel -tupletype="GRAYSCALE_ALPHA" 0 1 | cksum + pamchannel -tupletype="GRAYSCALE_ALPHA" 0 1 | pamdepth 255 | cksum rm ${test2_pam} diff --git a/test/xbm-roundtrip.ok b/test/xbm-roundtrip.ok index a676a1f2..82c6b5d8 100644 --- a/test/xbm-roundtrip.ok +++ b/test/xbm-roundtrip.ok @@ -1,2 +1,3 @@ -2425386270 41 -2425386270 41 +Test. Should print 281226646 481 twice +281226646 481 +281226646 481 diff --git a/test/xbm-roundtrip.test b/test/xbm-roundtrip.test index e84d6fc3..a8754150 100755 --- a/test/xbm-roundtrip.test +++ b/test/xbm-roundtrip.test @@ -1,7 +1,8 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmtoxbm xbmtopbm # Also requires: +echo "Test. Should print 281226646 481 twice" -pbmtoxbm testgrid.pbm | xbmtopbm | cksum -pbmtoxbm -x10 testgrid.pbm | xbmtopbm | cksum +pbmtoxbm maze.pbm | xbmtopbm | cksum +pbmtoxbm -x10 < maze.pbm | xbmtopbm | cksum diff --git a/test/xpm-roundtrip.ok b/test/xpm-roundtrip.ok index 845be5fb..2083dc10 100644 --- a/test/xpm-roundtrip.ok +++ b/test/xpm-roundtrip.ok @@ -1 +1,4 @@ -2425386270 41 +Test 1. Should print 1926073387 101484 +1926073387 101484 +Test 2. Should print 281226646 481 +281226646 481 diff --git a/test/xpm-roundtrip.test b/test/xpm-roundtrip.test index fd0253b1..c016c8c3 100755 --- a/test/xpm-roundtrip.test +++ b/test/xpm-roundtrip.test @@ -1,9 +1,11 @@ -#! /bin/bash +#! /bin/sh # This script tests: ppmtoxpm xpmtoppm # Also requires: pgmtopbm ppmtopgm +echo "Test 1. Should print 1926073387 101484" +ppmtoxpm -hexonly testimg.ppm | \ + xpmtoppm | cksum -#ppmtoxpm -hexonly testimg.ppm | \ -# xpmtoppm | cksum -ppmtoxpm testgrid.pbm | xpmtoppm | \ +echo "Test 2. Should print 281226646 481" +ppmtoxpm maze.pbm | xpmtoppm | \ ppmtopgm | pgmtopbm -th -value=0.5 | cksum diff --git a/test/xv-roundtrip.test b/test/xv-roundtrip.test index d73933a1..70b298df 100755 --- a/test/xv-roundtrip.test +++ b/test/xv-roundtrip.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamtoxvmini xvminitoppm # Also requires: pamdepth diff --git a/test/xwd-roundtrip.ok b/test/xwd-roundtrip.ok index 25d3d871..31dcba3e 100644 --- a/test/xwd-roundtrip.ok +++ b/test/xwd-roundtrip.ok @@ -1,3 +1,9 @@ +Test 1. Should produce 1571496937 33838, cksum of testimg.red twice 1571496937 33838 +1571496937 33838 +Test 2. Should produce 1926073387 101484 1926073387 101484 -2425386270 41 +Test 3. Should produce 281226646 481 three times +281226646 481 +281226646 481 +281226646 481 diff --git a/test/xwd-roundtrip.test b/test/xwd-roundtrip.test index cd0d38ad..1583cd68 100755 --- a/test/xwd-roundtrip.test +++ b/test/xwd-roundtrip.test @@ -1,16 +1,22 @@ -#! /bin/bash +#! /bin/sh # This script tests: pnmtoxwd xwdtopnm -# Also requires: pamchannel pamtopnm pamdepth +# Also requires: pamchannel pamtopnm pamdepth ppmtopgm - -# Test 1. Should produce 1571496937 33838, cksum of testimg.red +echo "Test 1. Should produce 1571496937 33838, cksum of testimg.red twice" pamchannel -infile=testimg.ppm -tupletype="GRAYSCALE" 0 | pamtopnm | \ pnmtoxwd | xwdtopnm | pamdepth 255 | cksum -# Test 2. Should produce 1926073387 101484 -pnmtoxwd --quiet testimg.ppm | \ +pamchannel -infile=testimg.ppm -tupletype="GRAYSCALE" 0 | pamtopnm | \ + pnmtoxwd -direct | xwdtopnm -quiet | pamdepth 255 | ppmtopgm | cksum + +echo "Test 2. Should produce 1926073387 101484" +pnmtoxwd --quiet testimg.ppm | \ xwdtopnm --quiet | pamdepth 255 | cksum -# Test 3. Should produce 2425386270 41 -pnmtoxwd --quiet testgrid.pbm | \ - xwdtopnm | cksum +echo "Test 3. Should produce 281226646 481 three times" +pnmtoxwd --quiet maze.pbm | xwdtopnm | cksum + +pnmtoxwd --quiet -pseudodepth 1 maze.pbm | xwdtopnm | cksum + +pnmtoxwd --quiet -pseudodepth 16 maze.pbm | xwdtopnm | cksum + diff --git a/test/ybm-roundtrip.ok b/test/ybm-roundtrip.ok new file mode 100644 index 00000000..3873d097 --- /dev/null +++ b/test/ybm-roundtrip.ok @@ -0,0 +1,2 @@ +Test. Should print 281226646 481 +281226646 481 diff --git a/test/ybm-roundtrip.test b/test/ybm-roundtrip.test new file mode 100755 index 00000000..b53d2ba0 --- /dev/null +++ b/test/ybm-roundtrip.test @@ -0,0 +1,7 @@ +#! /bin/sh +# This script tests: pbmtoybm xbmtopbm +# Also requires: + +echo "Test. Should print 281226646 481" + +pbmtoybm maze.pbm | ybmtopbm | cksum diff --git a/test/yuv-roundtrip.test b/test/yuv-roundtrip.test index e339b418..68f459e8 100755 --- a/test/yuv-roundtrip.test +++ b/test/yuv-roundtrip.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: ppmtoyuv yuvtoppm # Also requires: pamgradient |