diff options
Diffstat (limited to 'test')
378 files changed, 13129 insertions, 1411 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/Available-Testprog b/test/Available-Testprog index 8176b57a..033c7eec 100755 --- a/test/Available-Testprog +++ b/test/Available-Testprog @@ -6,7 +6,6 @@ if [ "${CHECK_TYPE}" = "install" ]; then fi # Special case: no arguments were passed to this program -# For all-in-place.test and legacy-names.test if [ $# = 0 ]; then exit 0 @@ -19,6 +18,10 @@ fi # each directory (for example converter/other/Makefile) for library # requirements and relevant variables. +# Note that any variable used to determine whether a program exists +# (BUILD_FIASCO, JASPERLIB, JBIGLIB, JPEGLIB, etc.) +# must be in CHECK_VARS in GNUMakefile to be detected here. + for i in $@ do case $i in @@ -57,6 +60,9 @@ for i in $@ svgtopam) [ "${XML2_LIBS}" = "NONE" ] && exit 1 ;; + ppmsvgalib) + [ "${LINUXSVGALIB}" = "NONE" ] && exit 1 ;; + thinkjettopbm) [ -z "${LEX}" ] && exit 1 ;; diff --git a/test/Execute-Tests b/test/Execute-Tests index 7a65d51f..3c231d98 100755 --- a/test/Execute-Tests +++ b/test/Execute-Tests @@ -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,12 +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 cat cksum cmp cp cut date dirname egrep fgrep file grep gs \ - head iconv mkdir mktemp perl rm sed seq sh tee testrandom tr uniq \ - Available-Testprog + for i in awk basename cat cksum cmp comm cp cut date dirname \ + 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; @@ -237,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 \ @@ -295,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 49eaeff2..16eeaf8e 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 @@ -22,10 +25,15 @@ ppmcie.test ppmwheel.test pamcrater.test ppmpat.test +ppmforge-parameters.test # Generators with random components +pbmnoise1.test +pbmnoise2.test +pbmnoise-parameters.test pgmnoise.test +pgmnoise-parameters.test ppmpat-random.test ppmforge.test ppmrough.test @@ -40,10 +48,15 @@ ppmhist.test pamsumm.test pnmpsnr.test pbmminkowski.test +pgmminkowski.test + +pnmcolormap.test +pnmcolormap2.test # Basic (internal) converter tests pamtopam.test +pbmtopgm.test pgmtopgm.test ppmtoppm.test pgmtoppm.test @@ -52,24 +65,43 @@ pnmtopnm-plain.test # Editor tests +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 + pamflip1.test pamflip2.test pnminvert.test pamchannel.test ppmchange.test pambackground.test +pnmpad-reportonly.test pnmpaste-pbm.test +pamrestack.test +pamshuffle.test +ppmshift.test +ppmspread.test + pbmpscale.test +pamrecolor.test pnmremap1.test pnmremap2.test +pnmquant.test pnmquantall.test pnmtile.test +pambrighten.test ppmbrighten.test ppmdither.test ppmrelief.test @@ -78,6 +110,11 @@ ppmdim.test pnmshear.test pgmbentley.test +pamfunc.test +pamarith.test +pamarith-compare-equal.test +pamarith-multiple-input.test + pamenlarge.test pamenlarge-pbm.test @@ -89,6 +126,11 @@ pamenlarge-pamscale-point.test pamstretch.test +pnmcrop1.test +pnmcrop2.test +pnmcrop3.test +pnmcrop-blank.test + ppmmix.test pammixmulti-identity.test @@ -96,18 +138,41 @@ pammixmulti-identity.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 pbmtog3.test +ppmtoapplevol.test 411toppm.test eyuvtoppm.test +rawtoppm.test -pbm-misc-converters.test +gif-transparent1.test # Miscellaneous utility tests ppmdfont.test +pamfix.test +pamvalidate.test +pamexec.test +pbmlife.test # Round-trip tests : editors @@ -115,8 +180,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 @@ -125,6 +192,13 @@ pamslice-roundtrip.test lookup-roundtrip.test enlarge-reduce-roundtrip.test cut-cat-roundtrip.test +pamhue-roundtrip.test + +# Round-trip tests: miscellaneous utilities + +pamendian-roundtrip.test +pamexec-roundtrip.test +channel-stack-roundtrip.test # Round-trip tests : lossless converters @@ -160,9 +234,11 @@ pi3-roundtrip.test pict-roundtrip.test png-roundtrip.test png-roundtrip2.test +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 @@ -174,6 +250,7 @@ tiff-flate-lzw-roundtrip.test utahrle-roundtrip.test wbmp-roundtrip.test winicon-roundtrip.test +winicon-roundtrip2.test xbm-roundtrip.test xpm-roundtrip.test xv-roundtrip.test @@ -183,5 +260,6 @@ xwd-roundtrip.test fiasco-roundtrip.test 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 2df9f392..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 @@ -238,11 +243,9 @@ pnmtosir: ok pnmtotiffcmyk: ok pnmtoxwd: ok ppm3d: ok -ppmbrighten: ok ppmchange: ok ppmcie: ok ppmcolormask: ok -ppmcolors: ok ppmdcfont: ok ppmddumpfont: ok ppmdim: ok @@ -266,6 +269,7 @@ ppmrough: ok ppmshadow: ok ppmshift: ok ppmspread: ok +ppmsvgalib: ok ppmtoacad: ok ppmtoapplevol: ok ppmtoarbtxt: ok @@ -276,6 +280,7 @@ ppmtoicr: ok ppmtoilbm: ok ppmtoleaf: ok ppmtolj: ok +ppmtompeg: ok ppmtomitsu: ok ppmtoneo: ok ppmtopcx: 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 6cf677ef..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 \ @@ -280,11 +285,9 @@ ordinary_testprogs="\ pnmtotiffcmyk \ pnmtoxwd \ ppm3d \ - ppmbrighten \ ppmchange \ ppmcie \ ppmcolormask \ - ppmcolors \ ppmdcfont \ ppmddumpfont \ ppmdim \ @@ -308,6 +311,7 @@ ordinary_testprogs="\ ppmshadow \ ppmshift \ ppmspread \ + ppmsvgalib \ ppmtoacad \ ppmtoapplevol \ ppmtoarbtxt \ @@ -318,6 +322,7 @@ ordinary_testprogs="\ ppmtoilbm \ ppmtoleaf \ ppmtolj \ + ppmtompeg \ ppmtomitsu \ ppmtoneo \ ppmtopcx \ @@ -340,6 +345,7 @@ ordinary_testprogs="\ ppmwheel \ psidtopgm \ pstopnm \ + qoitopam \ qrttoppm \ rasttopnm \ rawtopgm \ @@ -431,3 +437,5 @@ testExitStatus anytopnm 0 $? manweb --help > /dev/null testExitStatus manweb 0 $? + +# 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-quant-roundtrip.test b/test/bmp-quant-roundtrip.test index 2c223b7c..9f1036d0 100755 --- a/test/bmp-quant-roundtrip.test +++ b/test/bmp-quant-roundtrip.test @@ -1,6 +1,6 @@ #! /bin/bash # This script tests: bmptopnm ppmtobmp pnmquant -# Also requires: ppmhist +# Also requires: tmpdir=${tmpdir:-/tmp} quant_ppm=${tmpdir}/quant.ppm 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.ok b/test/channel-stack-roundtrip.ok new file mode 100644 index 00000000..708305f1 --- /dev/null +++ b/test/channel-stack-roundtrip.ok @@ -0,0 +1,11 @@ +Test 1: should print 1873848880 101532 twice, then 0 +1873848880 101532 +1873848880 101532 +1873848880 101532 +1873848880 101532 +1873848880 101532 +0 +Test 2: Should print 447072062 33892 three times +447072062 33892 +447072062 33892 +447072062 33892 diff --git a/test/channel-stack-roundtrip.test b/test/channel-stack-roundtrip.test new file mode 100755 index 00000000..14ac0d2e --- /dev/null +++ b/test/channel-stack-roundtrip.test @@ -0,0 +1,34 @@ +#! /bin/sh +# This script tests: pamchannel pamstack +# Also requires: pamtopam pamtopnm + +tmpdir=${tmpdir:-/tmp} +r_pam=${tmpdir}/testimg_r.pam +g_pam=${tmpdir}/testimg_g.pam +b_pam=${tmpdir}/testimg_b.pam +rgb_pam=${tmpdir}/testimg_rgb.pam + +echo "Test 1: should print 1873848880 101532 twice, then 0" + +pamchannel -tupletype="GRAYSCALE" -infile testimg.ppm 0 > ${r_pam} +pamchannel -tupletype="GRAYSCALE" -infile testimg.ppm 1 > ${g_pam} +pamchannel -tupletype="GRAYSCALE" -infile testimg.ppm 2 > ${b_pam} + +pamtopam < testimg.ppm | pamstack -tupletype="RGB" - | cksum +pamstack ${r_pam} ${g_pam} | \ +pamstack -tupletype="RGB" - ${b_pam} | cksum +pamstack ${r_pam} | \ +pamstack -tupletype="RGB" - ${g_pam} ${b_pam} | cksum +pamstack ${r_pam} ${b_pam} ${g_pam} ${b_pam} ${b_pam} ${b_pam} | \ + pamchannel -tupletype="RGB" 0 2 4 | cksum +pamstack -tupletype="RGB" ${r_pam} ${g_pam} ${b_pam} | tee ${rgb_pam} | cksum +pamtopnm ${rgb_pam} | cmp - testimg.ppm +echo $? + +echo "Test 2: Should print 447072062 33892 three times" + +cat ${r_pam} | cksum +pamstack -tupletype="GRAYSCALE" ${r_pam} | cksum +pamstack ${r_pam} | pamchannel -tupletype="GRAYSCALE" 0 | cksum + +rm ${r_pam} ${g_pam} ${b_pam} ${rgb_pam} diff --git a/test/cis-roundtrip.ok b/test/cis-roundtrip.ok index da90078b..1bb50cb7 100644 --- a/test/cis-roundtrip.ok +++ b/test/cis-roundtrip.ok @@ -1,2 +1,5 @@ +Test 1. Should print 2631579683 1546 twice 2631579683 1546 -2425386270 41 +2631579683 1546 +Test 2. Should print 281226646 481, cksum of maze.pbm +281226646 481 diff --git a/test/cis-roundtrip.test b/test/cis-roundtrip.test index 62fcc3b9..ad34173e 100755 --- a/test/cis-roundtrip.test +++ b/test/cis-roundtrip.test @@ -1,14 +1,20 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmtocis cistopbm -# Also requires: pbmmake pamcut +# Also requires: pbmmake pamcut pamfile +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 +echo "Test 2. Should print 281226646 481, cksum of maze.pbm" +size=$(pamfile -size maze.pbm | awk '{print "-width="$1,"-height="$2}') +pbmtocis maze.pbm | cistopbm | pamcut -left=0 -top=0 ${size} | cksum + +rm ${test_pbm} \ No newline at end of file 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 6e31c587..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 +# 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 94ef875f..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 @@ -26,14 +27,16 @@ pnmtofits: ok pnmtoplainpnm: ok pnmtopnm: ok pnmtotiff: ok +ppmbrighten: ok +ppmcolors: ok ppmnorm: ok ppmquant: ok ppmquantall: ok ppmtogif: ok ppmtojpeg: ok ppmtomap: ok -ppmtompeg: ok ppmtotga: ok ppmtouil: ok hpcdtoppm: ok pcdovtoppm: ok +pcdindex: ok diff --git a/test/legacy-names.test b/test/legacy-names.test index 5a65615f..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 \ @@ -83,13 +84,14 @@ ordinary_testprogs="\ pnmtoplainpnm \ pnmtopnm \ pnmtotiff \ + ppmbrighten \ + ppmcolors \ ppmnorm \ ppmquant \ ppmquantall \ ppmtogif \ ppmtojpeg \ ppmtomap \ - ppmtompeg \ ppmtotga \ ppmtouil \ " @@ -125,10 +127,13 @@ for i in $ordinary_testprogs -# Test hpcdtoppm and pcdovtoppm. Simply confirm their existence. +# Test hpcdtoppm, pcdovtoppm and pcdindex. Simply confirm their existence. type -p hpcdtoppm > /dev/null testExitStatus hpcdtoppm 0 $? type -p pcdovtoppm > /dev/null testExitStatus pcdovtoppm 0 $? + +type -p pcdindex > /dev/null +testExitStatus pcdindex 0 $? 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 new file mode 100644 index 00000000..c2c8ab3b --- /dev/null +++ b/test/lps-roundtrip.ok @@ -0,0 +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 new file mode 100755 index 00000000..24076ef1 --- /dev/null +++ b/test/lps-roundtrip.test @@ -0,0 +1,33 @@ +#! /bin/sh +# This script tests: pbmtolps pstopnm +# 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 + +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 | tee ${test_ps} | \ + pstopnm -dpi $((72*12)) -stdout -pgm | \ + pnmcrop -white | pamscale ${xysize} | \ + pnmpsnr -target=30 - ${test_pgm} + + # ghostscript version 8.71: pnmpsnr lumina 33.14dB + + +echo "Test 2. Should print 0" + +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 67f7a1fe..764cadfa 100644 --- a/test/pad-crop-roundtrip.ok +++ b/test/pad-crop-roundtrip.ok @@ -1,2 +1,4 @@ 1926073387 101484 -2425386270 41 +1926073387 101484 +281226646 481 +281226646 481 diff --git a/test/pad-crop-roundtrip.test b/test/pad-crop-roundtrip.test index c7780d68..31e02c99 100755 --- a/test/pad-crop-roundtrip.test +++ b/test/pad-crop-roundtrip.test @@ -1,9 +1,26 @@ -#! /bin/bash -# This script tests: pnmcrop pnmmargin -# Also requires: pnmpad +#! /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 -pnmmargin -white 10 testgrid.pbm | \ + +# 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 + +# Test 3. Should produce 281226646 481, cksum of maze.pbm + +pnmmargin -white 10 maze.pbm | \ pnmcrop | cksum + +# 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/pamarith-compare-equal.ok b/test/pamarith-compare-equal.ok new file mode 100644 index 00000000..d6b1f624 --- /dev/null +++ b/test/pamarith-compare-equal.ok @@ -0,0 +1,74 @@ +Test 1 +1:P3 +1:8 8 +1:2 +8: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: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 +1:P3 +1:8 8 +1:1 +8: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: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:35 33 +33:00000000000000000000000000000000000 +1:P1 +1:35 33 +33:11111111111111111111111111111111111 +1:P1 +1:14 16 +8:10101010101010 11111111111111 +1:P1 +1:14 16 +8:01010101010101 00000000000000 +Test 4 +1:P2 +1:35 33 +1:2 +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 +8:0 2 0 2 0 2 0 2 0 2 0 2 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +1:P2 +1:14 16 +1:2 +8: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 +1:P2 +1:14 16 +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 four times +1285449498 54 +1285449498 54 +1285449498 54 +1285449498 54 +Should produce 244506188 54 twice +244506188 54 +244506188 54 diff --git a/test/pamarith-compare-equal.test b/test/pamarith-compare-equal.test new file mode 100755 index 00000000..7d1062b7 --- /dev/null +++ b/test/pamarith-compare-equal.test @@ -0,0 +1,92 @@ +#! /bin/sh +# This script tests: pamarith +# 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/ /:/' + +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} ${inputm_ppm} ${input2_ppm} + +echo "Test 3" + +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 ${input3_pbm} | pamarith -equal -plain ${input3_pbm} - | \ + uniq -c | sed -e 's/^ *//' -e 's/ /:/' + +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 ${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 ${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 ${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 ${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 + +pgmmake -maxval=99 0.40 7 3 > ${input40_pgm} +pgmmake -maxval=99 0.50 7 3 > ${input50_pgm} + +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 twice" +pamarith -equal -plain ${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.ok b/test/pamarith-multiple-input.ok new file mode 100644 index 00000000..3a333058 --- /dev/null +++ b/test/pamarith-multiple-input.ok @@ -0,0 +1,66 @@ +Test 1 +1: +2881377455 188 +2881377455 188 +2: +2161003541 188 +2161003541 188 +3: +1352533811 188 +1352533811 188 +4: +2079203209 188 +2079203209 188 +5: +108934727 188 +108934727 188 +6: +755904253 188 +755904253 188 +7: +2719989180 188 +2719989180 188 +8: +2305795334 188 +2305795334 188 +9: +4110388424 188 +4110388424 188 +Test 2 +2285960269 1084 +-or +2285960269 1084 +2285960269 1084 +2285960269 1084 +-and +2285960269 1084 +2285960269 1084 +2285960269 1084 +-xor +2285960269 1084 +2285960269 1084 +Test 3 +-add +392744294 1084 +392744294 1084 +392744294 1084 +-and +1732023142 1084 +1732023142 1084 +1732023142 1084 +-or +549786223 1084 +549786223 1084 +549786223 1084 +-xor +3485039940 1084 +3485039940 1084 +3485039940 1084 +-nand +460693232 1084 +460693232 1084 +460693232 1084 +-nor +1552687097 1084 +1552687097 1084 +1552687097 1084 diff --git a/test/pamarith-multiple-input.test b/test/pamarith-multiple-input.test new file mode 100755 index 00000000..b9c09662 --- /dev/null +++ b/test/pamarith-multiple-input.test @@ -0,0 +1,61 @@ +#! /bin/sh +# This script tests: pamarith +# Also requires: pgmmake ppmpat pamfunc + +tmpdir=${tmpdir:-/tmp} + +input1_pgm=${tmpdir}/input1.pgm + + +echo "Test 1" +# Compare pamarith addition with pamfunc multiplication" + +pgmmake -maxval=99 0.01 16 11 > ${input1_pgm} + +add_command="pamarith -add "${input1_pgm} + +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} + ${add_command} | cksum + pamfunc -multiplier=$((i+1)) ${input1_pgm} | cksum + done + +rm ${input1_pgm} + +g2_ppm=${tmpdir}/g2.ppm +g3_ppm=${tmpdir}/g3.ppm + +# Produce test input images with ppmpat +ppmpat -g2 -color=rgb:00/00/00,rgb:ff/ff/ff 17 21 > ${g2_ppm} +ppmpat -g3 -color=rgb:ff/00/00,rgb:00/ff/00,rgb:00/00/ff 17 21 > ${g3_ppm} + +echo "Test 2" + +cat ${g2_ppm} | cksum +echo "-or" +pamarith -or ${g2_ppm} ${g2_ppm} | cksum +pamarith -or ${g2_ppm} ${g2_ppm} ${g2_ppm} | cksum +pamarith -or ${g2_ppm} ${g2_ppm} ${g2_ppm} ${g2_ppm} | cksum +echo "-and" +pamarith -and ${g2_ppm} ${g2_ppm} | cksum +pamarith -and ${g2_ppm} ${g2_ppm} ${g2_ppm} | cksum +pamarith -and ${g2_ppm} ${g2_ppm} ${g2_ppm} ${g2_ppm} | cksum +echo "-xor" +pamarith -xor ${g2_ppm} ${g2_ppm} ${g2_ppm} | cksum +pamarith -xor ${g2_ppm} ${g2_ppm} ${g2_ppm} ${g2_ppm} ${g2_ppm} | cksum + + +echo "Test 3" +# Order does not matter + +for function in "-add" "-and" "-or" "-xor" "-nand" "-nor" + do + echo ${function} + pamarith ${function} ${g2_ppm} ${g2_ppm} ${g3_ppm} | cksum + pamarith ${function} ${g3_ppm} ${g2_ppm} ${g2_ppm} | cksum + pamarith ${function} ${g2_ppm} ${g3_ppm} ${g2_ppm} | cksum + done + +rm ${g2_ppm} ${g3_ppm} diff --git a/test/pamarith.ok b/test/pamarith.ok new file mode 100644 index 00000000..c2d34dea --- /dev/null +++ b/test/pamarith.ok @@ -0,0 +1,277 @@ +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 +-add +P2 16 1 15 2 3 4 5 6 7 8 9 10 11 12 13 14 15 15 15 +1927712885 59 +1927712885 59 +1927712885 59 +-subtract +P2 16 1 15 0 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 +622443613 59 +622443613 59 +622443613 59 +-multiply +P2 16 1 15 0 0 0 0 1 1 1 1 1 1 1 1 2 2 2 2 +1589721418 59 +1589721418 59 +1589721418 59 +-divide +P2 16 1 15 0 8 15 15 15 15 15 15 15 15 15 15 15 15 15 15 +321546811 59 +321546811 59 +321546811 59 +-difference +P2 16 1 15 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 +590140907 59 +590140907 59 +590140907 59 +-minimum +P2 16 1 15 0 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 +3746423180 59 +3746423180 59 +3746423180 59 +-maximum +P2 16 1 15 2 2 2 3 4 5 6 7 8 9 10 11 12 13 14 15 +201376294 59 +201376294 59 +201376294 59 +-mean +P2 16 1 15 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 +1456675831 59 +1456675831 59 +1456675831 59 +-compare +P2 16 1 2 0 0 1 2 2 2 2 2 2 2 2 2 2 2 2 2 +196115582 58 +196115582 58 +196115582 58 +-equal +P2 16 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 +4168278327 58 +4168278327 58 +4168278327 58 +-and +P2 16 1 15 0 0 2 2 0 0 2 2 0 0 2 2 0 0 2 2 +3660405045 59 +3660405045 59 +3660405045 59 +-or +P2 16 1 15 2 3 2 3 6 7 6 7 10 11 10 11 14 15 14 15 +157317791 59 +157317791 59 +157317791 59 +-nand +P2 16 1 15 15 15 13 13 15 15 13 13 15 15 13 13 15 15 13 13 +1625584307 59 +1625584307 59 +1625584307 59 +-nor +P2 16 1 15 13 12 13 12 9 8 9 8 5 4 5 4 1 0 1 0 +3014218009 59 +3014218009 59 +3014218009 59 +-xor +P2 16 1 15 2 3 0 1 6 7 4 5 10 11 8 9 14 15 12 13 +3227090877 59 +3227090877 59 +3227090877 59 +-shiftleft +P2 16 1 15 0 4 8 12 0 4 8 12 0 4 8 12 0 4 8 12 +952940636 59 +952940636 59 +952940636 59 +-shiftright +P2 16 1 15 0 0 0 0 1 1 1 1 2 2 2 2 3 3 3 3 +2898922266 59 +2898922266 59 +2898922266 59 +Test 2 PBM +P1 +8 2 +01010101 +00001111 +-add +P1 8 1 00000101 +-subtract +P1 8 1 11110101 +-multiply +P1 8 1 01011111 +-divide +P1 8 1 01010000 +-difference +P1 8 1 10100101 +-minimum +P1 8 1 01011111 +-maximum +P1 8 1 00000101 +-mean +P1 8 1 00000101 +-compare +P2 8 1 2 1 0 1 0 2 1 2 1 +-equal +P1 8 1 01011010 +-and +P1 8 1 01011111 +-or +P1 8 1 00000101 +-nand +P1 8 1 10100000 +-nor +P1 8 1 11111010 +-xor +P1 8 1 10100101 +-shiftleft +P1 8 1 11110101 +-shiftright +P1 8 1 11110101 +Test 3 +-add +2442291770 913 +2442291770 913 +2442291770 913 +-multiply +3074858461 913 +3074858461 913 +3074858461 913 +-difference +3788637303 913 +3788637303 913 +3788637303 913 +-minimum +2046561746 913 +2046561746 913 +2046561746 913 +-maximum +3724820523 913 +3724820523 913 +3724820523 913 +-mean +5885382 913 +5885382 913 +5885382 913 +-equal +780857755 911 +780857755 911 +780857755 911 +-and +889537755 913 +889537755 913 +889537755 913 +-or +2466056482 913 +2466056482 913 +2466056482 913 +-nand +3743732043 913 +3743732043 913 +3743732043 913 +-nor +2027723954 913 +2027723954 913 +2027723954 913 +-xor +291709067 913 +291709067 913 +291709067 913 +-subtract +3705429820 913 +3705429820 913 +-divide +2136905608 913 +2136905608 913 +-compare +1563790885 911 +1563790885 911 +-shiftleft +51480286 913 +51480286 913 +-shiftright +3072492814 913 +3072492814 913 +Test 4 (input = output) +Prints 281226646 481 six times, then 2921940274 59 six times +input image +281226646 481 +-minimum +281226646 481 +-maximum +281226646 481 +-mean +281226646 481 +-and +281226646 481 +-or +281226646 481 +input image +2921940274 59 +-minimum +2921940274 59 +-maximum +2921940274 59 +-mean +2921940274 59 +-and +2921940274 59 +-or +2921940274 59 +Test 5 (blank output) +Prints 2247801875 481 three times, then 320101399 59 three times +-subtract +2247801875 481 +-difference +2247801875 481 +-xor +2247801875 481 +-subtract +320101399 59 +-difference +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 diff --git a/test/pamarith.test b/test/pamarith.test new file mode 100755 index 00000000..061f9488 --- /dev/null +++ b/test/pamarith.test @@ -0,0 +1,378 @@ +#! /bin/sh +# This script tests: pamarith +# Also requires: pamtopnm rgb3toppm pamenlarge pamcat pamseq pbmmake pgmmake +# Also requires: ppmpat pamchannel + +tmpdir=${tmpdir:-/tmp} +input1_pgm=${tmpdir}/input1.pgm +input2_pgm=${tmpdir}/input2.pgm +output_pgm=${tmpdir}/output.pgm +input1_ppm=${tmpdir}/input1.ppm +input2_ppm=${tmpdir}/input2.ppm + +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} + +pamcat -tb ${input1_pgm} ${input2_pgm} -plain + +for fn in "-add" "-subtract" "-multiply" "-divide" "-difference" \ + "-minimum" "-maximum" "-mean" "-compare" "-equal" \ + "-and" "-or" "-nand" "-nor" "-xor" \ + "-shiftleft" "-shiftright" + do + echo ${fn} + pamarith ${fn} -plain ${input1_pgm} ${input2_pgm} | tr '\n' ' '; echo + pamarith ${fn} ${input1_pgm} ${input2_pgm} > ${output_pgm} + rgb3toppm ${output_pgm} ${output_pgm} ${output_pgm} | cksum + pamarith ${fn} ${input1_ppm} ${input2_pgm} | cksum + pamarith ${fn} ${input1_ppm} ${input2_ppm} | cksum + done + +rm ${input1_pgm} ${input2_pgm} ${output_pgm} ${input2_ppm} + +input1_pbm=${tmpdir}/input1.pbm +input2_pbm=${tmpdir}/input2.pbm + +echo "Test 2 PBM" + +pbmmake -g 8 1 > ${input1_pbm} +pbmmake -g 2 1 | pamenlarge -xscale=4 > ${input2_pbm} + +pamcat -tb -plain ${input1_pbm} ${input2_pbm} + +for fn in "-add" "-subtract" "-multiply" "-divide" "-difference" \ + "-minimum" "-maximum" "-mean" "-compare" "-equal" \ + "-and" "-or" "-nand" "-nor" "-xor" \ + "-shiftleft" "-shiftright" + do + echo ${fn} + pamarith ${fn} -plain ${input1_pbm} ${input2_pbm} | tr '\n' ' '; echo + done + +rm ${input1_pbm} ${input2_pbm} + +echo "Test 3" + +input3_ppm=${tmpdir}/input3.ppm +input4_ppm=${tmpdir}/input4.ppm +input4_pgm=${tmpdir}/input4.pgm + +ppmpat -tartan -color=rgb:f0/f0/00,rgb:80/00/80,rgb:0f/00/0f 20 15 \ + > ${input3_ppm} +ppmpat -argyle2 -color=rgb:01/01/01,rgb:02/02/02,rgb:05/05/05 20 15 \ + > ${input4_ppm} +pamchannel -infile ${input4_ppm} 0 > ${input4_pgm} + +for fn in "-add" "-multiply" "-difference" \ + "-minimum" "-maximum" "-mean" "-equal" \ + "-and" "-or" "-nand" "-nor" "-xor" + do + echo ${fn} + pamarith ${fn} ${input3_ppm} ${input4_ppm} | cksum + pamarith ${fn} ${input4_ppm} ${input3_ppm} | cksum + pamarith ${fn} ${input3_ppm} ${input4_pgm} | pamtopnm | cksum + done + +for fn in "-subtract" "-divide" "-compare" "-shiftleft" "-shiftright" + do + echo ${fn} + pamarith ${fn} ${input3_ppm} ${input4_ppm} | cksum + pamarith ${fn} ${input3_ppm} ${input4_pgm} | pamtopnm | cksum + done + +rm ${input3_ppm} ${input4_ppm} ${input4_pgm} + +echo "Test 4 (input = output)" +echo "Prints 281226646 481 six times, then 2921940274 59 six times" + +for image in maze.pbm ${input1_ppm} + do + echo "input image" + cat ${image} | cksum + for fn in "-minimum" "-maximum" "-mean" "-and" "-or" + do + echo ${fn} + pamarith ${fn} ${image} ${image} | cksum + done + done + + +echo "Test 5 (blank output)" +echo "Prints 2247801875 481 three times, then 320101399 59 three times" + +for image in maze.pbm ${input1_ppm} + do + for fn in "-subtract" "-difference" "-xor" + do + echo ${fn} + pamarith ${fn} ${image} ${image} | cksum + done + done + +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" + +test_out=${tmpdir}/test_out + +# multiple functions + +pamarith -add -subtract testimg.ppm testimg.ppm > ${test_out} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -multiply -divide testimg.ppm testimg.ppm > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -difference -minimum testimg.ppm testimg.ppm > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -maximum -mean testimg.ppm testimg.ppm > ${test_out} || \ + printf "Expected failure 4" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -compare -and testimg.ppm testimg.ppm > ${test_out} || \ + printf "Expected failure 5" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -compare -equal testimg.ppm testimg.ppm > ${test_out} || \ + printf "Expected failure 6" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -or -nand testimg.ppm testimg.ppm > ${test_out} || \ + printf "Expected failure 7" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -nor -xor testimg.ppm testimg.ppm > ${test_out} || \ + printf "Expected failure 8" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -shiftleft -shiftright testimg.ppm testimg.ppm > ${test_out} || \ + printf "Expected failure 9" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# -add does not take a value + +pamarith -add=1 testimg.ppm testimg.ppm > ${test_out} || \ + printf "Expected failure 10" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# No function + +pamarith -plain testimg.ppm testimg.ppm > ${test_out} || \ + printf "Expected failure 11" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith testimg.ppm testimg.ppm > ${test_out} || \ + printf "Expected failure 12" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# Just one input image file + +pamarith -add testimg.ppm > ${test_out} || \ + printf "Expected failure 13" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# No input image file + +pamarith -add > ${test_out} || \ + printf "Expected failure 14" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# Input images with different depth (number of planes) + +pamchannel -infile testimg.ppm 0 1 | \ + pamarith -add testimg.ppm - > ${test_out} || \ + printf "Expected failure 15" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# Input images with different x/y dimensions + +pamarith -add testimg.ppm testgrid.pbm > ${test_out} || \ + printf "Expected failure 16" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamenlarge -xscale=2 testgrid.pbm | \ + pamarith -add testgrid.pbm - > ${test_out} || \ + printf "Expected failure 17" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamenlarge -yscale=3 testgrid.pbm | \ + pamarith -add testgrid.pbm - > ${test_out} || \ + printf "Expected failure 18" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# Invalid usage of -closeness + +pamarith -equal -closeness=100.1 testgrid.pbm > ${test_out} || \ + printf "Expected failure 19" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -equal -closeness=-10 testgrid.pbm > ${test_out} || \ + printf "Expected failure 20" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -closeness -equal testgrid.pbm > ${test_out} || \ + printf "Expected failure 21" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -compare -closeness=10 testgrid.pbm > ${test_out} || \ + printf "Expected failure 22" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# Bit string functions +# Create PGM test input + +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=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} > ${test_out} || \ + printf "Expected failure 23" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -or ${input3_pgm} ${input5_pgm} > ${test_out} || \ + printf "Expected failure 24" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -nand ${input3_pgm} ${input5_pgm} > ${test_out} || \ + printf "Expected failure 25" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -nor ${input3_pgm} ${input5_pgm} > ${test_out} || \ + printf "Expected failure 26" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -xor ${input3_pgm} ${input5_pgm} > ${test_out} || \ + printf "Expected failure 27" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# Bit string functions - Maxval must be 2^n -1 + +pamarith -and ${input4_pgm} ${input4_pgm} > ${test_out} || \ + printf "Expected failure 28" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -or ${input4_pgm} ${input4_pgm} > ${test_out} || \ + printf "Expected failure 29" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -nand ${input4_pgm} ${input4_pgm} > ${test_out} || \ + printf "Expected failure 30" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -nor ${input4_pgm} ${input4_pgm} > ${test_out} || \ + printf "Expected failure 31" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -xor ${input4_pgm} ${input4_pgm} > ${test_out} || \ + printf "Expected failure 32" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -shiftleft ${input4_pgm} ${input4_pgm} > ${test_out} || \ + printf "Expected failure 33" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -shiftright ${input4_pgm} ${input4_pgm} > ${test_out} || \ + printf "Expected failure 34" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +rm ${input3_pgm} ${input4_pgm} ${input5_pgm} + +# Functions that do not allow more than two input images. +# Only the functions that are commutative and associative allow +# three or more inputs. + +pamarith -subtract testimg.ppm testimg.ppm testimg.ppm > ${test_out} || \ + printf "Expected failure 35" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -divide testimg.ppm testimg.ppm testimg.ppm > ${test_out} || \ + printf "Expected failure 36" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -compare testimg.ppm testimg.ppm testimg.ppm > ${test_out} || \ + printf "Expected failure 37" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -difference testimg.ppm testimg.ppm testimg.ppm > ${test_out} || \ + printf "Expected failure 38" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -shiftleft testimg.ppm testimg.ppm testimg.ppm > ${test_out} || \ + printf "Expected failure 39" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -shiftright testimg.ppm testimg.ppm testimg.ppm > ${test_out} || \ + printf "Expected failure 40" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# 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 > ${test_out} || \ + printf "Expected failure 41" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -mean testgrid.pbm testgrid.pbm testgrid.pbm > ${test_out} || \ + printf "Expected failure 42" + test -s ${test_out}; echo " "$? + rm -f ${test_out} 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 new file mode 100644 index 00000000..6c58b4c9 --- /dev/null +++ b/test/pambrighten.ok @@ -0,0 +1,96 @@ +Test 1 +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 + +P3 +8 1 +255 +0 0 0 0 0 110 0 110 0 0 110 110 110 0 0 110 0 110 110 110 0 110 110 110 + +P3 +8 1 +255 +0 0 0 0 0 90 0 90 0 0 90 90 90 0 0 90 0 90 90 90 0 90 90 90 + +P3 +8 1 +255 +0 0 0 0 0 200 0 200 0 0 200 200 200 0 0 200 0 200 200 200 0 200 200 200 + +P3 +8 1 +255 +0 0 0 0 0 255 0 255 0 0 255 255 255 0 0 255 0 255 255 255 0 255 255 255 + +P3 +8 1 +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 + +Test 2 +P3 +8 1 +255 +0 0 0 10 10 100 10 100 10 10 100 100 100 10 10 100 10 100 100 100 10 100 100 100 + +P3 +8 1 +255 +0 0 0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 + +Test 3: Output invariant +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 + +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 + +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 + +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 + +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 + +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 + +Test 4: Should print 3990234518 268 six times +3990234518 268 +3990234518 268 +3990234518 268 +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 diff --git a/test/pambrighten.test b/test/pambrighten.test new file mode 100755 index 00000000..00e405dd --- /dev/null +++ b/test/pambrighten.test @@ -0,0 +1,99 @@ +#! /bin/sh +# This script tests: pambrighten +# Also requires: pgmramp + +tmpdir=${tmpdir:-/tmp} + +input_ppm=${tmpdir}/input.ppm + +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 +EOF + +# Test 1 + +echo "Test 1" +pambrighten -v 0 -plain ${input_ppm} +pambrighten -v +10 -plain ${input_ppm} +pambrighten -v -10 -plain ${input_ppm} +pambrighten -v +100 -plain ${input_ppm} +pambrighten -v +200 -plain ${input_ppm} +pambrighten -v -100 -plain ${input_ppm} + +echo "Test 2" +pambrighten -s -10 -plain ${input_ppm} +pambrighten -s -100 -plain ${input_ppm} + +echo "Test 3: Output invariant" +pambrighten -plain ${input_ppm} +pambrighten -v 0 -plain ${input_ppm} +pambrighten -s 0 -plain ${input_ppm} +pambrighten -s +10 -plain ${input_ppm} +pambrighten -s +100 -plain ${input_ppm} +pambrighten -s +200 -plain ${input_ppm} + +rm ${input_ppm} + +echo "Test 4: Should print 3990234518 268 six times" + +input_pgm=${tmpdir}/input.pgm + +pgmramp -lr 255 1 | tee ${input_pgm} | cksum +pambrighten -s -100 ${input_pgm} | cksum +pambrighten -s -10 ${input_pgm} | cksum +pambrighten -s +10 ${input_pgm} | cksum +pambrighten -s +100 ${input_pgm} | cksum +pambrighten -s +200 ${input_pgm} | cksum + +rm ${input_pgm} + + +# Test 2 +# These should all fail. + +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} diff --git a/test/pamcat1.ok b/test/pamcat1.ok new file mode 100644 index 00000000..4e23666f --- /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 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 diff --git a/test/pamcat1.test b/test/pamcat1.test new file mode 100755 index 00000000..67d941cc --- /dev/null +++ b/test/pamcat1.test @@ -0,0 +1,271 @@ +#! /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" + +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 + +# direction not specified +pamcat testgrid.pbm testimg.ppm > ${test_out} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# both directions specified +pamcat -topbottom -leftright testgrid.pbm testimg.ppm > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# both pad colors specified +pamcat -topbottom -white -black testgrid.pbm testimg.ppm > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# justification parameters overspecified +pamcat -lr -jtop -jbottom testgrid.pbm testimg.ppm > ${test_out} || \ + printf "Expected failure 4" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamcat -lr -jtop -jcenter testgrid.pbm testimg.ppm > ${test_out} || \ + printf "Expected failure 5" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamcat -lr -jcenter -jbottom testgrid.pbm testimg.ppm > ${test_out} || \ + printf "Expected failure 6" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamcat -tb -jleft -jright testgrid.pbm testimg.ppm > ${test_out} || \ + printf "Expected failure 7" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamcat -tb -jleft -jcenter testgrid.pbm testimg.ppm > ${test_out} || \ + printf "Expected failure 8" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamcat -tb -jcenter -jright testgrid.pbm testimg.ppm > ${test_out} || \ + printf "Expected failure 9" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# justification parameter in the wrong direction +pamcat -lr -jleft testgrid.pbm testimg.ppm > ${test_out} || \ + printf "Expected failure 10" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamcat -lr -jright testgrid.pbm testimg.ppm > ${test_out} || \ + printf "Expected failure 11" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamcat -tb -jtop testgrid.pbm testimg.ppm > ${test_out} || \ + printf "Expected failure 12" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamcat -tb -jbottom testgrid.pbm testimg.ppm > ${test_out} || \ + printf "Expected failure 13" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# 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 " "$? + 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..5dbb2cbc --- /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 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 diff --git a/test/pamcat3.test b/test/pamcat3.test new file mode 100755 index 00000000..3aed0131 --- /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 " "$? + rm -f ${test_out} + +# listfile does not exist +pamcat -lr -listfile=`mktemp -u` > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# listfile empty +pamcat -lr -listfile=/dev/null > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + 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 " "$? + 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 " "$? + 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 " "$? + 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 " "$? + 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 " "$? + 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 " "$? + rm -f ${test_out} ${liste3} + + +rm ${list} ${list2} ${list3} + + diff --git a/test/pamchannel.ok b/test/pamchannel.ok index 79317f03..91629202 100644 --- a/test/pamchannel.ok +++ b/test/pamchannel.ok @@ -1,3 +1,12 @@ +Test 1:red-channel Should produce 1571496937 33838 1571496937 33838 +Test 2:green-channel Should produce 394856971 33838 394856971 33838 +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 diff --git a/test/pamchannel.test b/test/pamchannel.test index 3529f4fe..f2662706 100755 --- a/test/pamchannel.test +++ b/test/pamchannel.test @@ -1,7 +1,6 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamchannel -# Also requires: pamtopnm - +# Also requires: pamtopam pamtopnm # Extract planes one by one. # Convert output to pgm to make it identical to ppmtorgb3 output. @@ -13,20 +12,47 @@ # 3164158573 33838 testimg.blu -# Test 1. red channel -# Should produce 1571496937 33838 - +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: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: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 +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 + +echo "Test Invalid" + +pamchannel -infile testgrid.pbm 1 > ${test_out} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamchannel -infile testimg.ppm 3 > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamtopam testimg.ppm | pamchannel -infile=- 4 > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + diff --git a/test/pamcrater.ok b/test/pamcrater.ok index cfb186a6..a5571f35 100644 --- a/test/pamcrater.ok +++ b/test/pamcrater.ok @@ -1,6 +1,13 @@ +Test 1. 4 4 4 +Test 2. 2 2 2 +Test Invalid. +Expected failure 1 1 +Expected failure 2 1 +Expected failure 3 1 +Expected failure 4 1 diff --git a/test/pamcrater.test b/test/pamcrater.test index 4d3858b9..e0c98afb 100755 --- a/test/pamcrater.test +++ b/test/pamcrater.test @@ -1,10 +1,10 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamcrater pamshadedrelief # Also requires: pamstack pamvalidate pamcut pamflip -# We use the undocumented --test and --radius options of pamcrater. -# pamcrater --test --radius=N +# We use the undocumented -test and -radius options of pamcrater. +# pamcrater -test -radius=N # The above draws a single crater of radius N. # The resulting image should be symmetric. @@ -18,11 +18,12 @@ test100_pam=${tmpdir}/test100.pam test150_pam=${tmpdir}/test150.pam # Test 1. Should print 4 three times +echo "Test 1." -pamcrater --test --radius=10 > $test10_pam -pamcrater --test --radius=50 > $test50_pam -pamcrater --test --radius=100 > $test100_pam -pamcrater --test --radius=150 > $test150_pam +pamcrater -test -radius=10 > $test10_pam +pamcrater -test -radius=50 > $test50_pam +pamcrater -test -radius=100 > $test100_pam +pamcrater -test -radius=150 > $test150_pam pamstack ${test10_pam} ${test50_pam} ${test100_pam} ${test150_pam} | pamvalidate > ${test_pam} @@ -39,6 +40,7 @@ for i in 1 10 70 rm ${test_pam} ${test10_pam} ${test50_pam} # Test 2. Should print 2 three times +echo "Test 2." pamshadedrelief ${test100_pam} > ${testshaded_pam} @@ -50,4 +52,33 @@ 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} ${test100_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 + +pamcrater -width 0 > ${test_out} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamcrater -height 0 > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamcrater -number 0 > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamcrater -test -radius=10 | pamshadedrelief -gamma 0 > ${test_out} || \ + printf "Expected failure 4" + test -s ${test_out}; echo " "$? + rm -f ${test_out} diff --git a/test/pamcut.ok b/test/pamcut.ok index b08bc531..fc4dc3de 100644 --- a/test/pamcut.ok +++ b/test/pamcut.ok @@ -1,19 +1,36 @@ -Test 1. +Test 1. Should print 2958909756 124815 2958909756 124815 -Test 2. +Test 2. Should print 1550940962 10933 1550940962 10933 -Test 3. +Test 3. Should print 708474423 14 twice 708474423 14 708474423 14 -Test 4. +Test 4. Should print 659346598 80124 four times 659346598 80124 659346598 80124 659346598 80124 659346598 80124 -Test 5. -2425386270 41 -2425386270 41 -2425386270 41 -2425386270 41 -Test 6. +Test 5. Should print 281226646 481 five times +281226646 481 +281226646 481 +281226646 481 +281226646 481 +281226646 481 +Test 6. Should print 3412257956 129 3412257956 129 +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 diff --git a/test/pamcut.test b/test/pamcut.test index 9971b1a5..a489635a 100755 --- a/test/pamcut.test +++ b/test/pamcut.test @@ -1,28 +1,23 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamcut pbmmake -# Also requires: +# Also requires: pamfile -# Test 1. Should print 2958909756 124815 -echo Test 1. +echo "Test 1. Should print 2958909756 124815" pamcut -top 0 -left 0 -width 260 -height 160 \ -pad testimg.ppm | cksum -# Test 2. Should print 1550940962 10933 -echo Test 2. +echo "Test 2. Should print 1550940962 10933" pamcut -top 200 -left 120 -width 40 -height 40 \ -pad testimg.ppm | cksum -# Test 3. Should print 708474423 14 twice -echo Test 3. +echo "Test 3. Should print 708474423 14 twice" pamcut -top 5 -left 5 -bottom 5 -right 5 testimg.ppm | cksum pamcut -width 1 -height 1 -bottom 5 -right 5 testimg.ppm | cksum - -# Test 4. Should print 659346598 80124 four times -echo Test 4. +echo "Test 4. Should print 659346598 80124 four times" pamcut -croptop 10 -cropleft 10 -cropbottom 10 -cropright 10 testimg.ppm | \ cksum @@ -30,18 +25,110 @@ pamcut -top 10 -left 10 -bottom 138 -right 216 testimg.ppm | cksum pamcut -top 10 -left 10 -bottom -11 -right -11 testimg.ppm | cksum pamcut -top 10 -left 10 -width 207 -height 129 testimg.ppm | cksum +echo "Test 5. Should print 281226646 481 five times" -# Test 5. Should print 2425386270 41 four times -echo Test 5. - -pamcut -croptop 0 -cropleft 0 -cropbottom 0 -cropright 0 testgrid.pbm | \ +mazesize=$(pamfile -size maze.pbm) +width=$(echo ${mazesize} | cut -d " " -f 1) +height=$(echo ${mazesize} | cut -d " " -f 2) + +pamcut -croptop 0 -cropleft 0 -cropbottom 0 -cropright 0 maze.pbm | \ cksum -pamcut -top 0 -left 0 -bottom 15 -right 13 testgrid.pbm | cksum -pamcut -top 0 -left 0 -bottom -1 -right -1 testgrid.pbm | cksum -pamcut -top 0 -left 0 -width 14 -height 16 testgrid.pbm | cksum +pamcut -top 0 -left 0 -bottom $((${height} -1)) -right $((${width} -1)) \ + maze.pbm | cksum +pamcut -top 0 -left 0 -bottom -1 -right -1 maze.pbm | cksum +pamcut -top 0 -left 0 -width ${width} -height ${height} maze.pbm | cksum +pamcut maze.pbm | cksum + +echo "Test 6. Should print 3412257956 129" + +pbmmake -g 50 50 | pamcut 5 5 30 30 | cksum -# Test 6. Should print 3412257956 129 -echo Test 6. +echo "Test Invalid" -pbmmake -g 50 50 | pamcut 5 5 30 30 | cksum +tmpdir=${tmpdir:-/tmp} +test_out=${tmpdir}/test_out + +echo 1>&2 +echo "Invalid command-line argument combinations." 1>&2 +echo "Error messages should appear below the line." 1>&2 +echo "-----------------------------------------------------------" 1>&2 + +# overspecification +pamcut -left=1 -right=1 -width=14 testgrid.pbm > ${test_out} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamcut -top=1 -bottom=1 -height=16 testgrid.pbm > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamcut -right=1 -cropright=1 testgrid.pbm > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamcut -top=1 -croptop=1 testgrid.pbm > ${test_out} || \ + printf "Expected failure 4" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamcut -bottom=1 -cropbottom=1 testgrid.pbm > ${test_out} || \ + printf "Expected failure 5" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamcut -left=1 -cropleft=1 testgrid.pbm > ${test_out} || \ + printf "Expected failure 6" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# excessive cropping +pamcut -cropleft=7 -cropright=8 testgrid.pbm > ${test_out} || \ + printf "Expected failure 7" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamcut -left=7 -right=6 testgrid.pbm > ${test_out} || \ + printf "Expected failure 8" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamcut -croptop=8 -cropbottom=8 testgrid.pbm > ${test_out} || \ + printf "Expected failure 9" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamcut -top=10 -bottom=9 testgrid.pbm > ${test_out} || \ + printf "Expected failure 6" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# pad absent +pamcut -cropleft=1 -width=14 testgrid.pbm > ${test_out} || \ + printf "Expected failure 10" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamcut -croptop=1 -height=16 testgrid.pbm > ${test_out} || \ + printf "Expected failure 11" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# legacy style: insufficient number of positional parameters +pamcut 5 testimg.ppm > ${test_out} || \ + printf "Expected failure 12" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamcut 5 4 testimg.ppm > ${test_out} || \ + printf "Expected failure 13" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamcut 5 5 30 testimg.ppm > ${test_out} || \ + printf "Expected failure 14" + test -s ${test_out}; echo " "$? + rm -f ${test_out} 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 new file mode 100644 index 00000000..1bd897ac --- /dev/null +++ b/test/pamdepth.ok @@ -0,0 +1,14 @@ +Test 1 +538848130 235 +stdin: PGM RAW 14 16 1 1 GRAYSCALE +538848130 235 +stdin: PGM RAW 14 16 1 1 GRAYSCALE +831461512 289 +stdin: PAM RAW 14 16 1 1 GRAYSCALE +831461512 289 +stdin: PAM RAW 14 16 1 1 GRAYSCALE +Test 2 +0 0 : 0 +Test Invalid +Expected failure 1 1 +Expected failure 2 1 diff --git a/test/pamdepth.test b/test/pamdepth.test new file mode 100755 index 00000000..7ff73f41 --- /dev/null +++ b/test/pamdepth.test @@ -0,0 +1,40 @@ +#! /bin/bash +# This script tests: pamdepth +# Also requires: pbmtopgm pamtopam pamfile + +tmpdir=${tmpdir:-/tmp} +test_out=${tmpdir}/test_out + +# Test 1 +echo "Test 1" +pamdepth 1 testgrid.pbm | tee ${test_out} | cksum + cat ${test_out} | pamfile -machine +pbmtopgm 1 1 testgrid.pbm | pamdepth 1 | tee ${test_out} | cksum + cat ${test_out} | pamfile -machine +pamdepth 1 testgrid.pbm | pamtopam | tee ${test_out} | cksum + cat ${test_out} | pamfile -machine +pbmtopgm 1 1 testgrid.pbm | pamtopam | pamdepth 1 | tee ${test_out} | cksum + cat ${test_out} | pamfile -machine + +# Test 2 +echo "Test 2" +pamdepth 255 testimg.ppm | cmp -s - testimg.ppm + echo ${PIPESTATUS[@]} ":" $? + +# 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 + +pamdepth 0 testgrid.pbm > ${test_out} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamdepth 65536 testimg.ppm > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} diff --git a/test/pamdice-roundtrip.ok b/test/pamdice-roundtrip.ok index 82eac5a8..9f648fd0 100644 --- a/test/pamdice-roundtrip.ok +++ b/test/pamdice-roundtrip.ok @@ -1 +1,16 @@ +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 +1926073387 101484 +1926073387 101484 +1926073387 101484 +1926073387 101484 +Test 6. Should print 1926073387 101484 1926073387 101484 diff --git a/test/pamdice-roundtrip.test b/test/pamdice-roundtrip.test index 28997742..4d3fba19 100755 --- a/test/pamdice-roundtrip.test +++ b/test/pamdice-roundtrip.test @@ -1,12 +1,60 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamdice pamundice -# Also requires: - +# Also requires: pamfile tmpdir=${tmpdir:-/tmp} -fname_stem=${tmpdir}/a +fname_stem=${tmpdir}/pamdice_part + +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 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. 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" + +width=5 +tiles=$(( (${mw}+${width}-1) / ${width} )) + +pamdice maze.pbm -outstem=${fname_stem} -width=${width} +pamundice ${fname_stem}_%1d_%2a.pbm -across=${tiles} | cksum +rm ${fname_stem}_*_*.pbm + + +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 + 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 -pamdice testimg.ppm -outstem=${fname_stem} -width=50 -height=40 -pamundice ${fname_stem}_%1d_%1a.ppm -down=4 -across=5 | cksum +echo "Test 6. Should print 1926073387 101484" -rm ${fname_stem}_?_?.ppm +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 new file mode 100644 index 00000000..9e978168 --- /dev/null +++ b/test/pamdice.ok @@ -0,0 +1,26 @@ +Test 1. +10 P1@1 1@0@ +Test 2. +P1@1 1@0@ +P1@1 1@1@ +P1@1 1@1@ +P1@1 1@0@ +P1@1 1@0@ +P1@1 1@1@ +P1@1 1@1@ +P1@1 1@0@ +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 6.rm diff --git a/test/pamdice.test b/test/pamdice.test new file mode 100755 index 00000000..04dd4d78 --- /dev/null +++ b/test/pamdice.test @@ -0,0 +1,79 @@ +#! /bin/sh +# This script tests: pamdice +# Also requires: pbmmake + +tmpdir=${tmpdir:-/tmp} +fname_stem=${tmpdir}/pamdice_part + +# Test 1. +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 + done | sort | uniq -c | sed 's/^ *//' + +rm ${fname_stem}*.pbm + +# Test 1. +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 + done + +rm ${fname_stem}*.pbm + + +# 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 + +# 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" +rm ${fname_stem}* || +echo "Expected failure 6.rm" diff --git a/test/pamditherbw-random.ok b/test/pamditherbw-random.ok new file mode 100755 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 e8186c24..02200d0f 100644 --- a/test/pamditherbw.ok +++ b/test/pamditherbw.ok @@ -1,4 +1,28 @@ +Test: simple threshold 1316122660 33894 +Test: Hilbert 3342429190 33894 +2905156049 33894 +339841328 33894 +1633267750 33894 +Test: Dither-8 3325147568 33894 +Test: Cluster-3 4124728025 33894 +Test: Cluster-4 +4124728025 33894 +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 diff --git a/test/pamditherbw.test b/test/pamditherbw.test index 3f377f81..be560089 100755 --- a/test/pamditherbw.test +++ b/test/pamditherbw.test @@ -1,32 +1,109 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamditherbw # Also requires: pamchannel pamtopnm - tmpdir=${tmpdir:-/tmp} test_red=${tmpdir}/testimg.red # Test 1. Simple threshold +echo "Test: simple threshold" + pamchannel -infile=testimg.ppm -tupletype="GRAYSCALE" 0 | pamtopnm | \ tee ${test_red} | \ pamditherbw -threshold -val=0.5 | cksum -# Test 2. Floyd-Steinberg -#pamditherbw -floyd -val=0.5 ${test_red} | cksum - -# Test 3. Atkinson -#pamditherbw -atkinson -val=0.5 ${test_red} | cksum -# Test 4. Hilbert +# Test 2. Hilbert +echo "Test: Hilbert" pamditherbw -hilbert ${test_red} | cksum +pamditherbw -hilbert -clump=4 ${test_red} | cksum +pamditherbw -hilbert -clump=16 ${test_red} | cksum +pamditherbw -hilbert -clump=100 ${test_red} | cksum -# Test 5. Dither-8 +# Test 3. Dither-8 +echo "Test: Dither-8" pamditherbw -dither8 ${test_red} | cksum -# Test 6. Cluster4 +# Test 4. Cluster-3 +echo "Test: Cluster-3" pamditherbw -cluster4 ${test_red} | cksum -# Test 7. Atkinson -#pamditherbw -atkinson -val=0.5 ${test_red} | cksum +# Test 5. Cluster-4 +echo "Test: Cluster-4" +pamditherbw -cluster4 ${test_red} | cksum + +# Test 6. Cluster-8 +echo "Test: Cluster-8" +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} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamditherbw -floyd -atkinson ${test_red} > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamditherbw -dither8 -cluster3 ${test_red} > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamditherbw -cluster3 -cluster4 ${test_red} > ${test_out} || \ + printf "Expected failure 4" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamditherbw -cluster3 -cluster8 ${test_red} > ${test_out} || \ + printf "Expected failure 5" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamditherbw -cluster4 -cluster8 ${test_red} > ${test_out} || \ + printf "Expected failure 6" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamditherbw -hilbert -threshold ${test_red} > ${test_out} || \ + printf "Expected failure 7" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamditherbw -clump=8 ${test_red} > ${test_out} || \ + printf "Expected failure 8" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamditherbw -fs -clump=8 ${test_red} > ${test_out} || \ + printf "Expected failure 9" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamditherbw -hilbert -clump=1 ${test_red} > ${test_out} || \ + printf "Expected failure 10" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamditherbw -th -value=-1 ${test_red} > ${test_out} || \ + printf "Expected failure 11" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamditherbw -th -value=1.1 ${test_red} > ${test_out} || \ + printf "Expected failure 12" + test -s ${test_out}; echo " "$? + rm -f ${test_out} 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 new file mode 100644 index 00000000..6245abb9 --- /dev/null +++ b/test/pamendian-roundtrip.ok @@ -0,0 +1,5 @@ +Test 1. Should print '0 0 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 new file mode 100755 index 00000000..b060b704 --- /dev/null +++ b/test/pamendian-roundtrip.test @@ -0,0 +1,26 @@ +#! /bin/bash +# This script tests: pamendian +# Also requires: pamdepth pgmtopbm pamseq + +echo "Test 1. Should print '0 0 0 : 0'" + +tmpdir=${tmpdir:-/tmp} +test0_pam=${tmpdir}/test0.pam + +pamseq 1 65535 > ${test0_pam} +pamendian < ${test0_pam} | pamendian |\ + cmp -s ${test0_pam} - + echo ${PIPESTATUS[@]} ":" $? + +rm ${test0_pam} + + +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-roundtrip.ok b/test/pamexec-roundtrip.ok new file mode 100644 index 00000000..604ab5de --- /dev/null +++ b/test/pamexec-roundtrip.ok @@ -0,0 +1,10 @@ +Test 1: should print stdin: PPM RAW 17 22 3 255 RGB six times +stdin: PPM RAW 17 22 3 255 RGB +stdin: PPM RAW 17 22 3 255 RGB +stdin: PPM RAW 17 22 3 255 RGB +stdin: PPM RAW 17 22 3 255 RGB +stdin: PPM RAW 17 22 3 255 RGB +stdin: PPM RAW 17 22 3 255 RGB +Test 2: should print '0 0 : 0' twice +0 0 : 0 +0 0 : 0 diff --git a/test/pamexec-roundtrip.test b/test/pamexec-roundtrip.test new file mode 100755 index 00000000..fce7b6b5 --- /dev/null +++ b/test/pamexec-roundtrip.test @@ -0,0 +1,25 @@ +#! /bin/bash +# This script tests: pamexec +# Also requires: ppmpat ppmmake pamfile + +tmpdir=${tmpdir:-/tmp} +test_ppm=${tmpdir}/test_ppm + +echo "Test 1: should print stdin: PPM RAW 17 22 3 255 RGB six times" + +( ppmmake rgb:0/255/127 17 22 + ppmpat -g2 --color=rgb:143/188/143,rgb:161/161/161 17 22 + ppmpat -g3 --color=rgb:224/255/255,rgb:255/130/171,rgb:255/48/48 17 22 + ppmpat -madras --color=rgb:181/181/181,rgb:51/62/99,rgb:205/193/197 17 22 + ppmpat -tartan --color=rgb:238/233/191,rgb:84/84/84,rgb:255/160/122 17 22 + ppmpat -argyle2 --color=rgb:205/104/57,rgb:119/136/153,rgb:255/255/255 17 22 +) | tee ${test_ppm} | pamfile -all -machine + +echo "Test 2: should print '0 0 : 0' twice" + +pamexec "ppmtoppm " ${test_ppm} | cmp -s ${test_ppm} - + echo ${PIPESTATUS[@]} ":" $? +pamexec "cat " ${test_ppm} | cmp -s ${test_ppm} - + echo ${PIPESTATUS[@]} ":" $? + +rm ${test_ppm} diff --git a/test/pamexec.ok b/test/pamexec.ok new file mode 100644 index 00000000..23e4268e --- /dev/null +++ b/test/pamexec.ok @@ -0,0 +1,10 @@ +Test 1 : Should print 10 stdin: PBM RAW 21 24 1 1 BLACKANDWHITE twice +10 stdin: PBM RAW 21 24 1 1 BLACKANDWHITE +10 stdin: PBM RAW 21 24 1 1 BLACKANDWHITE +Test 2: Should print 1791121103 989 twice +1791121103 989 +1791121103 989 +Test 3: Should print 2983705297 810 twice +2983705297 810 +2983705297 810 +Test Invalid: Should not print anything diff --git a/test/pamexec.test b/test/pamexec.test new file mode 100755 index 00000000..7c2bf054 --- /dev/null +++ b/test/pamexec.test @@ -0,0 +1,42 @@ +#! /bin/sh +# This script tests: pamexec +# Also requires: pbmtext pamfile pbmminkowski pbmtog3 g3topbm + +tmpdir=${tmpdir:-/tmp} +test_pbm=${tmpdir}/test.pbm +combined_pbm=${tmpdir}/combined.pbm + +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" + +cat ${combined_pbm} | pamfile -all -mach | uniq -c | sed 's/^ *//' +pamexec "pamfile -mach" ${combined_pbm} | uniq -c | sed 's/^ *//' + +echo "Test 2: Should print 1791121103 989 twice" + +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] + +echo "Test 3: Should print 2983705297 810 twice" + +pamexec "pbmtog3 -no | g3topbm" ${combined_pbm} | cksum +cat ${combined_pbm} | cksum + +echo "Invalid command" 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" + +pamexec "false" ${combined_pbm} +pamexec "pamfile | false" ${combined_pbm} + +rm ${combined_pbm} diff --git a/test/pamfile.ok b/test/pamfile.ok index c0d80c28..e222592c 100644 --- a/test/pamfile.ok +++ b/test/pamfile.ok @@ -1,12 +1,19 @@ +Test 1 testimg.ppm: PPM raw, 227 by 149 maxval 255 testgrid.pbm: PBM raw, 14 by 16 stdin: PGM raw, 227 by 149 maxval 255 stdin: PAM, 227 by 149 by 1 maxval 255 Tuple type: GRAYSCALE +Test 2 stdin: 3 images stdin: Image 0: PBM raw, 14 by 16 stdin: Image 1: PBM raw, 14 by 16 stdin: Image 2: PBM raw, 14 by 16 +Test 3 227 149 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 diff --git a/test/pamfile.test b/test/pamfile.test index 545a2289..260d0b27 100755 --- a/test/pamfile.test +++ b/test/pamfile.test @@ -1,16 +1,46 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamfile # Also requires: pamchannel pamtopnm +echo "Test 1" pamfile testimg.ppm pamfile testgrid.pbm pamchannel -infile=testimg.ppm -tupletype="GRAYSCALE" 0 | pamtopnm | pamfile pamchannel -tupletype="GRAYSCALE" -infile=testimg.ppm 0 | pamfile +echo "Test 2" + cat testgrid.pbm testgrid.pbm testgrid.pbm | pamfile -count cat testgrid.pbm testgrid.pbm testgrid.pbm | pamfile -allimages +echo "Test 3" + pamfile -size testimg.ppm pamfile -machine testimg.ppm cat testgrid.pbm testimg.ppm testgrid.pbm | pamfile -machine + +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 + +pamfile -size -machine testimg.ppm > ${test_out} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamfile -count -machine testimg.ppm > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +head -n1 testimg.ppm | pamfile > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} diff --git a/test/pamfind.ok b/test/pamfind.ok index dc0f95ed..de53166e 100644 --- a/test/pamfind.ok +++ b/test/pamfind.ok @@ -20,6 +20,14 @@ Locations containing tuple (210/57/41)/255: (101, 77) (101, 78) (102, 72) +118 195 +137 176 +137 177 +137 178 +138 183 +139 205 +140 188 +144 199 Test 2 Locations containing tuple (1)/1: (0, 1) @@ -78,6 +86,179 @@ Locations containing tuple (1)/1: (14, 9) (14, 11) (14, 13) +00 00 +00 02 +00 04 +00 06 +00 08 +00 10 +00 12 +01 00 +01 01 +01 02 +01 03 +01 04 +01 05 +01 06 +01 07 +01 08 +01 09 +01 10 +01 11 +01 12 +01 13 +02 00 +02 02 +02 04 +02 06 +02 08 +02 10 +02 12 +03 00 +03 01 +03 02 +03 03 +03 04 +03 05 +03 06 +03 07 +03 08 +03 09 +03 10 +03 11 +03 12 +03 13 +04 00 +04 02 +04 04 +04 06 +04 08 +04 10 +04 12 +05 00 +05 01 +05 02 +05 03 +05 04 +05 05 +05 06 +05 07 +05 08 +05 09 +05 10 +05 11 +05 12 +05 13 +06 00 +06 02 +06 04 +06 06 +06 08 +06 10 +06 12 +07 00 +07 01 +07 02 +07 03 +07 04 +07 05 +07 06 +07 07 +07 08 +07 09 +07 10 +07 11 +07 12 +07 13 +08 00 +08 02 +08 04 +08 06 +08 08 +08 10 +08 12 +09 00 +09 01 +09 02 +09 03 +09 04 +09 05 +09 06 +09 07 +09 08 +09 09 +09 10 +09 11 +09 12 +09 13 +10 00 +10 02 +10 04 +10 06 +10 08 +10 10 +10 12 +11 00 +11 01 +11 02 +11 03 +11 04 +11 05 +11 06 +11 07 +11 08 +11 09 +11 10 +11 11 +11 12 +11 13 +12 00 +12 02 +12 04 +12 06 +12 08 +12 10 +12 12 +13 00 +13 01 +13 02 +13 03 +13 04 +13 05 +13 06 +13 07 +13 08 +13 09 +13 10 +13 11 +13 12 +13 13 +14 00 +14 02 +14 04 +14 06 +14 08 +14 10 +14 12 +15 00 +15 01 +15 02 +15 03 +15 04 +15 05 +15 06 +15 07 +15 08 +15 09 +15 10 +15 11 +15 12 +15 13 Test 3 okay okay +Test Invalid +Expected failure 1 1 +Expected failure 2 1 +Expected failure 3 1 +Expected failure 4 1 diff --git a/test/pamfind.test b/test/pamfind.test index 39cb1437..9165fbdf 100755 --- a/test/pamfind.test +++ b/test/pamfind.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamfind # Also requires: @@ -7,26 +7,58 @@ sorted0_res=${tmpdir}/pamfind_sorted0.res sorted1_res=${tmpdir}/pamfind_sorted1.res # Test 1 -echo Test 1 -pamfind -color=grey17 testimg.ppm +echo "Test 1" +pamfind -color=grey17 testimg.ppm pamfind -target=210,57,41 testimg.ppm +pamfind -target=50,55,49 -machine testimg.ppm # Test 2 -echo Test 2 +echo "Test 2" pamfind -target=1 testgrid.pbm +pamfind -target=0 -machine testgrid.pbm # Test 3 # The two outputs should be disjoint -echo Test 3 +echo "Test 3" pamfind -target=0 testgrid.pbm | sort > ${sorted0_res} 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} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamfind -target=0,0 testimg.ppm > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamfind -target=0,0,0,0 testimg.ppm > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamfind testimg.ppm > ${test_out} || \ + printf "Expected failure 4" + test -s ${test_out}; echo " "$? + rm -f ${test_out} diff --git a/test/pamfix.ok b/test/pamfix.ok new file mode 100644 index 00000000..7302f91e --- /dev/null +++ b/test/pamfix.ok @@ -0,0 +1,68 @@ +Test 1 +P1 +5 5 +01010 +10101 +01010 +10101 +01010 +P1 +5 4 +01010 +10101 +01010 +00001 +P1 +5 4 +01010 +10101 +01010 +00001 +P1 +5 1 +01010 +Test 2 +P2 +3 3 +7 +0 1 2 +3 4 5 +6 7 0 +P2 +3 2 +7 +0 1 2 +3 4 5 +P2 +3 2 +7 +0 1 2 +3 4 5 +P2 +3 3 +8 +0 1 2 +3 4 5 +6 7 8 +P2 +3 3 +7 +0 1 2 +3 4 5 +6 7 7 +P2 +3 3 +8 +0 1 2 +3 4 8 +0 0 0 +P2 +3 3 +7 +0 1 2 +3 4 7 +0 0 0 +Test invalid +Expected failure 1 1 +Expected failure 2 1 +Expected failure 3 1 diff --git a/test/pamfix.test b/test/pamfix.test new file mode 100755 index 00000000..a18cae10 --- /dev/null +++ b/test/pamfix.test @@ -0,0 +1,69 @@ +#! /bin/sh +# This script tests: pamfix +# Also requires: pbmmake + +tmpdir=${tmpdir:-/tmp} + +# Test 1. +echo "Test 1" + +pbmmake -g 5 5 | pamfix -truncate -plain + +printf "P1\n5 5\n01010\n10101\n01010\n00001\n1\n" |\ + pamfix -truncate -plain + +printf "P1\n5 5\n01010\n10101\n01010\n0000\n1\n" |\ + pamfix -truncate -plain + +printf "P1\n5 5\n01010\n10102\n01010\n00001\n1\n" |\ + pamfix -truncate -plain + +# Test 2 + +echo "Test 2" + +printf "P2\n3 3\n7\n0 1 2\n3 4 5\n6 7 0\n" |\ + pamfix -truncate -plain + +printf "P2\n3 3\n7\n0 1 2\n3 4 5\n6 7\n" |\ + pamfix -truncate -plain +printf "P2\n3 3\n7\n0 1 2\n3 4 5\n6 7 8\n" |\ + pamfix -truncate -plain + +printf "P2\n3 3\n7\n0 1 2\n3 4 5\n6 7 8\n" |\ + pamfix -change -plain + +printf "P2\n3 3\n7\n0 1 2\n3 4 5\n6 7 8\n" |\ + pamfix -clip -plain + +printf "P2\n3 3\n7\n0 1 2\n3 4 8\n0 0 0\n" |\ + pamfix -change -truncate -plain + +printf "P2\n3 3\n7\n0 1 2\n3 4 8\n0 0 0\n" |\ + pamfix -clip -truncate -plain + +# Test Invalid + +echo "Test invalid" + +test_out=${tmpdir}/test_out + +echo 1>&2 +echo "Invalid command-line combination, invalid input" 1>&2 +echo "Error messages should appear below the line." 1>&2 +echo "-----------------------------------------------------------" 1>&2 + +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 " "$? + rm -f ${test_out} + +printf "P1\n5 5\n" | pamfix -truncate -plain > ${test_out} || \ + printf "Expected failure 2"; + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +printf "P2\n3 3\255\n" | pamfix -truncate -plain > ${test_out} || \ + printf "Expected failure 3"; + test -s ${test_out}; echo " "$? + 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 new file mode 100644 index 00000000..d358355b --- /dev/null +++ b/test/pamfunc.ok @@ -0,0 +1,70 @@ +Test 1 +P2 16 1 15 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 +P2 16 1 15 3 4 5 6 7 8 9 10 11 12 13 14 15 15 15 15 +P2 16 1 15 0 0 0 0 1 2 3 4 5 6 7 8 9 10 11 12 +P2 16 1 15 0 3 6 9 12 15 15 15 15 15 15 15 15 15 15 15 +P2 16 1 15 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 +P2 16 1 15 0 1 2 3 4 5 6 6 6 6 6 6 6 6 6 6 +P2 16 1 15 5 5 5 5 5 5 6 7 8 9 10 11 12 13 14 15 +P2 16 1 15 0 2 4 6 8 10 12 14 0 2 4 6 8 10 12 14 +P2 16 1 15 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 +P2 16 1 15 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 +P2 16 1 15 0 0 2 2 4 4 6 6 8 8 10 10 12 12 14 14 +Test 2 +P1 8 1 01010101 +P1 8 1 00000000 +P1 8 1 11111111 +P1 8 1 01010101 +P1 8 1 01010101 +P1 8 1 01010101 +P1 8 1 00000000 +P1 8 1 11111111 +P1 8 1 11111111 +P1 8 1 11111111 +P1 8 1 11111111 +Test 3 (-changemaxval) +P2 16 1 30 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 +P2 16 1 60 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 +P1 8 1 01010101 +P1 8 1 11111111 +Test 4: Should print 1926073387 101484 eight times +1926073387 101484 +1926073387 101484 +1926073387 101484 +1926073387 101484 +1926073387 101484 +1926073387 101484 +1926073387 101484 +1926073387 101484 +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 diff --git a/test/pamfunc.test b/test/pamfunc.test new file mode 100755 index 00000000..fe142be7 --- /dev/null +++ b/test/pamfunc.test @@ -0,0 +1,213 @@ +#! /bin/sh +# This script tests: pamfunc +# Also requires: pamseq pamtopnm pbmmake + +tmpdir=${tmpdir:-/tmp} +input_pgm=${tmpdir}/input.pgm + +echo "Test 1" + +pamseq 1 15 | pamtopnm -assume > ${input_pgm} +pamtopnm -plain ${input_pgm} | tr '\n' ' '; echo + +pamfunc -adder=3 -plain ${input_pgm} | tr '\n' ' '; echo +pamfunc -subtractor=3 -plain ${input_pgm} | tr '\n' ' '; echo +pamfunc -multiplier=3 -plain ${input_pgm} | tr '\n' ' '; echo +pamfunc -divisor=2 -plain ${input_pgm} | tr '\n' ' '; echo +pamfunc -max=6 -plain ${input_pgm} | tr '\n' ' '; echo +pamfunc -min=5 -plain ${input_pgm} | tr '\n' ' '; echo + +pamfunc -shiftleft 1 -plain ${input_pgm} | tr '\n' ' '; echo +pamfunc -shiftright 1 -plain ${input_pgm} | tr '\n' ' '; echo +pamfunc -shiftleft 1 ${input_pgm} | pamfunc -shiftright 1 -plain | \ + tr '\n' ' '; echo +pamfunc -shiftright 1 ${input_pgm} | pamfunc -shiftleft 1 -plain | \ + tr '\n' ' '; echo + + +input_pbm=${tmpdir}/input.pbm + +echo "Test 2" + +pbmmake -g 8 1 > ${input_pbm} +pamtopnm -plain ${input_pbm} | tr '\n' ' '; echo + +pamfunc -adder=1 -plain ${input_pbm} | tr '\n' ' '; echo +pamfunc -subtractor=1 -plain ${input_pbm} | tr '\n' ' '; echo +pamfunc -multiplier=1 -plain ${input_pbm} | tr '\n' ' '; echo +pamfunc -divisor=1 -plain ${input_pbm} | tr '\n' ' '; echo +pamfunc -max=1 -plain ${input_pbm} | tr '\n' ' '; echo +pamfunc -min=1 -plain ${input_pbm} | tr '\n' ' '; echo + +pamfunc -shiftleft 1 -plain ${input_pbm} | tr '\n' ' '; echo +pamfunc -shiftright 1 -plain ${input_pbm} | tr '\n' ' '; echo +pamfunc -shiftleft 1 ${input_pbm} | pamfunc -shiftright 1 -plain | \ + tr '\n' ' '; echo +pamfunc -shiftright 1 ${input_pbm} | pamfunc -shiftleft 1 -plain | \ + tr '\n' ' '; echo + + +echo "Test 3 (-changemaxval)" + +pamfunc -divisor 2 -changemaxval ${input_pgm} -plain | \ + tr '\n' ' '; echo +pamfunc -multiplier 0.25 -changemaxval ${input_pgm} -plain | \ + tr '\n' ' '; echo +pamfunc -divisor 2 -changemaxval ${input_pbm} -plain | \ + tr '\n' ' '; echo +pamfunc -multiplier 0.25 -changemaxval ${input_pbm} -plain | \ + tr '\n' ' '; echo + +rm ${input_pgm} ${input_pbm} + +echo "Test 4: Should print 1926073387 101484 eight times" + +cat testimg.ppm | cksum + +pamfunc -not testimg.ppm | pamfunc -not | cksum +pamfunc -andmask 0xff testimg.ppm | cksum +pamfunc -ormask 0x00 testimg.ppm | cksum +pamfunc -xormask 0x00 testimg.ppm | cksum +pamfunc -xormask 0xff testimg.ppm | pamfunc -xormask 0xff | cksum +pamfunc -shiftleft 0 testimg.ppm | cksum +pamfunc -shiftright 0 testimg.ppm | cksum + + +echo "Test 5: Should print 281226646 481 six times" + +cat maze.pbm | 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 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" + +test_out=${tmpdir}/test_out + +pamfunc -multiplier testimg.ppm > ${test_out} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamfunc -multiplier=-1 testimg.ppm > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamfunc -divisor testimg.ppm > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamfunc -divisor=-20 testimg.ppm > ${test_out} || \ + printf "Expected failure 4" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamfunc -adder testimg.ppm > ${test_out} || \ + printf "Expected failure 5" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamfunc -adder 0.5 testimg.ppm > ${test_out} || \ + printf "Expected failure 6" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamfunc -subtractor testimg.ppm > ${test_out} || \ + printf "Expected failure 7" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamfunc -subtractor 0.1 testimg.ppm > ${test_out} || \ + printf "Expected failure 8" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamfunc -multiplier=1 -divisor=2 testimg.ppm > ${test_out} || \ + printf "Expected failure 9" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamfunc -adder=2 -subtractor=3 testimg.ppm > ${test_out} || \ + printf "Expected failure 10" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamfunc -min testimg.ppm > ${test_out} || \ + printf "Expected failure 11" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamfunc -max testimg.ppm > ${test_out} || \ + printf "Expected failure 12" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamfunc -andmask testimg.ppm > ${test_out} || \ + printf "Expected failure 13" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamfunc -ormask testimg.ppm > ${test_out} || \ + printf "Expected failure 14" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamfunc -xormask testimg.ppm > ${test_out} || \ + printf "Expected failure 15" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamfunc -not 1 testimg.ppm > ${test_out} || \ + printf "Expected failure 16" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamfunc -min=1 -max=2 testimg.ppm > ${test_out} || \ + printf "Expected failure 17" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamfunc -andmask=1 -ormask=0 testimg.ppm > ${test_out} || \ + printf "Expected failure 18" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamfunc -andmask=0xffff testimg.ppm > ${test_out} || \ + printf "Expected failure 19" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamfunc -shiftleft testimg.ppm > ${test_out} || \ + printf "Expected failure 20" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamfunc -shiftright testimg.ppm > ${test_out} || \ + printf "Expected failure 21" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamfunc -changemaxval testimg.ppm > ${test_out} || \ + printf "Expected failure 22" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamfunc -shiftleft=1 -shiftright=1 testimg.ppm > ${test_out} || \ + printf "Expected failure 23" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamfunc -multiplier=0.5 -changemaxval=65535 testimg.ppm > ${test_out} || \ + printf "Expected failure 24" + test -s ${test_out}; echo " "$? + rm -f ${test_out} diff --git a/test/pamgauss.ok b/test/pamgauss.ok index 153d4f6e..e31a2ee8 100644 --- a/test/pamgauss.ok +++ b/test/pamgauss.ok @@ -1,3 +1,4 @@ +Test 1 3712518499 55 3712518499 55 1147844094 55 @@ -79,3 +80,12 @@ 4102007360 169 3022719594 169 1769176609 169 +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 diff --git a/test/pamgauss.test b/test/pamgauss.test index b48517c4..9400e928 100755 --- a/test/pamgauss.test +++ b/test/pamgauss.test @@ -1,12 +1,53 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamgauss -# Also requires: +# 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" + +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} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamgauss 3 3 -sigma=0 > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamgauss 3 3 -sigma=-1.5 > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamgauss 3 -sigma=0.5 > ${test_out} || \ + printf "Expected failure 4" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamgauss 3 3 3 -sigma=0.5 > ${test_out} || \ + printf "Expected failure 5" + test -s ${test_out}; echo " "$? + rm -f ${test_out} diff --git a/test/pamhue-roundtrip.ok b/test/pamhue-roundtrip.ok new file mode 100644 index 00000000..b341398c --- /dev/null +++ b/test/pamhue-roundtrip.ok @@ -0,0 +1,10 @@ +input image +1926073387 101484 +360 +1926073387 101484 +180 +1926073387 101484 +120 +1926073387 101484 +60 +1926073387 101484 diff --git a/test/pamhue-roundtrip.test b/test/pamhue-roundtrip.test new file mode 100755 index 00000000..d68ee344 --- /dev/null +++ b/test/pamhue-roundtrip.test @@ -0,0 +1,19 @@ +#! /bin/sh +# This script tests: pamhue +# Also requires: + +echo input image +cat testimg.ppm | cksum + +echo 360 +pamhue -huechange=360 testimg.ppm | cksum +echo 180 +pamhue -huechange=180 testimg.ppm | pamhue -huechange=180 | cksum +echo 120 +pamhue -huechange=120 testimg.ppm | pamhue -huechange=120 | \ + pamhue -huechange=120 | cksum +echo 60 +pamhue -huechange=60 testimg.ppm | pamhue -huechange=60 | \ + pamhue -huechange=60 | pamhue -huechange=60 | \ + pamhue -huechange=60 | pamhue -huechange=60 | cksum + diff --git a/test/pamhue.ok b/test/pamhue.ok new file mode 100644 index 00000000..5935cc5e --- /dev/null +++ b/test/pamhue.ok @@ -0,0 +1,36 @@ +Test 1 +1213482165 83 +1213482165 83 +Test 2 + Summary: 8 colors: 1 black, 1 white, 0 gray, 6 color + + r g b lum count + ----- ----- ----- ----- ------- + 0 0 0 0 1 + 0 0 255 29 1 + 0 255 0 150 1 + 0 255 255 179 1 + 255 0 0 76 1 + 255 0 255 105 1 + 255 255 0 226 1 + 255 255 255 255 1 + Summary: 8 colors: 1 black, 1 white, 0 gray, 6 color + + r g b lum count + ----- ----- ----- ----- ------- + 0 0 0 0 1 + 0 0 255 29 1 + 0 255 0 150 1 + 0 255 255 179 1 + 255 0 0 76 1 + 255 0 255 105 1 + 255 255 0 226 1 + 255 255 255 255 1 +Test 3 +0 0 : 0 +0 0 : 0 +Test 4 +0 0 : 0 +0 0 : 0 +Test Invalid +Expected failure 1 1 diff --git a/test/pamhue.test b/test/pamhue.test new file mode 100755 index 00000000..5979e414 --- /dev/null +++ b/test/pamhue.test @@ -0,0 +1,48 @@ +#! /bin/bash +# This script tests: pamhue +# Also requires: pamseq ppmhist pamdepth + +echo "Test 1" +# Should print 1213482165 83 twice + +pamseq -tupletype=RGB 3 1 | pamdepth 255 | pamhue -huechange=60 | cksum +pamseq -tupletype=RGB 3 1 | pamdepth 255 | pamhue -huechange=-300 | cksum + +echo "Test 2" + +pamseq -tupletype=RGB 3 1 | pamdepth 255 | ppmhist -sort=rgb +pamseq -tupletype=RGB 3 1 | pamdepth 255 | pamhue -huechange=60 | \ + ppmhist -sort=rgb + +echo "Test 3" +# pamhue has no effect on monotone images +# Should print 281226646 481 twice + +pamhue -huechange=45 maze.pbm | cmp -s - maze.pbm + echo ${PIPESTATUS[@]} ":" $? +pamhue -huechange=180 maze.pbm | cmp -s - maze.pbm + echo ${PIPESTATUS[@]} ":" $? + +echo "Test 4" +# spinning the color wheel by multiples of 360 leaves the image unchanged +# Should print 1926073387 101484 twice + +pamhue -huechange=0 testimg.ppm | cmp -s - testimg.ppm + echo ${PIPESTATUS[@]} ":" $? +pamhue -huechange=360 testimg.ppm | cmp -s - testimg.ppm + echo ${PIPESTATUS[@]} ":" $? + +echo "Test Invalid" + +tmpdir=${tmpdir:-/tmp} +test_out=${tmpdir}/test_out + +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} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} 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 100755 index 00000000..0a6b5413 --- /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 1 +Expected failure 2 1 +Expected failure 3 1 +Expected failure 4 1 +Expected failure 5 1 +Expected failure 6 1 diff --git a/test/pamrecolor.test b/test/pamrecolor.test new file mode 100755 index 00000000..a5fecc1f --- /dev/null +++ b/test/pamrecolor.test @@ -0,0 +1,62 @@ +#! /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 + + +test_out=${tmpdir}/test_out +truncated_file=${tmpdir}/truncated.txt +echo P6 > ${truncated_file} + +echo 1>&2 +echo "Invalid command-line argument combinations." 1>&2 +echo "Error messages should appear below the line." 1>&2 +echo "-----------------------------------------------------------" 1>&2 + +pamrecolor --targetcolor=rgb:00/11/22 \ + --colorfile=${base1_pgm} testimg.ppm > ${test_out} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamrecolor --rmult=0.3 --gmult=0.3 --bmult=0.3 \ + --colorfile=${base1_pgm} testimg.ppm > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamrecolor --colorspace=void \ + --targetcolor=rgb:80/80/80 testimg.ppm > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamrecolor --targetcolor=vague testimg.ppm > ${test_out} || \ + printf "Expected failure 4" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamrecolor --colorfile=${truncated_file} testimg.ppm > ${test_out} || \ + printf "Expected failure 5" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamrecolor --rmult=0.2989 --gmult=0.5866 testimg.ppm > ${test_out} || \ + printf "Expected failure 6" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +rm ${base_pgm} ${truncated_file} diff --git a/test/pamrestack.ok b/test/pamrestack.ok new file mode 100644 index 00000000..07552913 --- /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 1 +Expected failure 2 1 +Expected failure 3 1 +Expected failure 4 1 +Expected failure 5 1 diff --git a/test/pamrestack.test b/test/pamrestack.test new file mode 100755 index 00000000..2ebee49f --- /dev/null +++ b/test/pamrestack.test @@ -0,0 +1,91 @@ +#! /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." + +echo 1>&2 +echo "Invalid command-line argument combinations." 1>&2 +echo "Error messages should appear below the line." 1>&2 +echo "-----------------------------------------------------------" 1>&2 + +pamrestack testgrid.pbm maze.pbm > ${test_out} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamrestack -abort \ + -width=$((pixels * 2 + 1 )) maze.pbm > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamrestack -crop \ + -width=$((pixels * 2 + 1)) maze.pbm > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamrestack -width=0 maze.pbm > ${test_out} || \ + printf "Expected failure 4" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamrestack -width maze.pbm > ${test_out} || \ + printf "Expected failure 5" + test -s ${test_out}; echo " "$? + rm -f ${test_out} 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.ok b/test/pamscale-filters3.ok index 94d4ae96..182700cd 100644 --- a/test/pamscale-filters3.ok +++ b/test/pamscale-filters3.ok @@ -1,4 +1,3 @@ -failure : 0 3.96 hermite: match match diff --git a/test/pamscale-filters3.test b/test/pamscale-filters3.test index 83198e2b..8d20e690 100755 --- a/test/pamscale-filters3.test +++ b/test/pamscale-filters3.test @@ -1,13 +1,12 @@ #! /bin/bash # This script tests: pamscale pamstretch pamstretch-gen - # Also requires: pamvalidate pnmpsnr || \ - echo failure ${PIPESTATUS[@]} ":" $? +# 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 00152411..bf5cde99 100644 --- a/test/pamscale-reportonly.ok +++ b/test/pamscale-reportonly.ok @@ -1,3 +1,4 @@ +Test 1 227 149 3.000000 3.000000 681 447 227 149 5.000000 5.000000 1135 745 227 149 2.682819 2.684564 609 400 @@ -10,9 +11,10 @@ 227 149 2.819383 2.000000 640 298 227 149 1.400881 2.684564 318 400 227 149 1.000000 1.000000 227 149 -expected error -expected error -expected error -expected error -expected error -expected error +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 diff --git a/test/pamscale-reportonly.test b/test/pamscale-reportonly.test index 7205be2f..924fb7c2 100755 --- a/test/pamscale-reportonly.test +++ b/test/pamscale-reportonly.test @@ -1,7 +1,9 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamscale # Also requires: +echo "Test 1" + pamscale -reportonly 3 testimg.ppm pamscale -reportonly 5 testimg.ppm pamscale -reportonly -xysize 640 400 testimg.ppm @@ -15,21 +17,50 @@ pamscale -reportonly -width=640 -yscale=2 testimg.ppm pamscale -reportonly -xscale=1.4 -height=400 testimg.ppm pamscale -reportonly -pixels=45000 testimg.ppm -# expected error cases +echo "Test Invalid" + +tmpdir=${tmpdir:-/tmp} +test_out=${tmpdir}/test_out + +# 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 || \ - echo expected error -pamscale -reportonly -xsize=640 -xscale=2 -yscale=3 testimg.ppm || \ - echo expected error -pamscale -reportonly -xsize=640 -ysize=400 -pixels=200000 testimg.ppm || \ - echo expected error -pamscale -reportonly -xsize=640 -ysize=400 -xysize 640 400 testimg.ppm || \ - echo expected error -pamscale -reportonly -xsize=640 -ysize=400 -xyfit 640 400 testimg.ppm || \ - echo expected error -pamscale -reportonly -xsize=640 -ysize=400 -xyfill 640 400 testimg.ppm || \ - echo expected error +pamscale -reportonly -xsize=640 -ysize=400 -xscale=2 testimg.ppm > \ + ${test_out} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamscale -reportonly -xsize=640 -xscale=2 -yscale=3 testimg.ppm > \ + ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamscale -reportonly -xsize=640 -ysize=400 -pixels=200000 testimg.ppm \ + > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamscale -reportonly -xsize=640 -ysize=400 -xysize 640 400 testimg.ppm \ + > ${test_out} || \ + printf "Expected failure 4" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamscale -reportonly -xsize=640 -ysize=400 -xyfit 640 400 testimg.ppm \ + > ${test_out} || \ + printf "Expected failure 5" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamscale -reportonly -xsize=640 -ysize=400 -xyfill 640 400 testimg.ppm \ + > ${test_out} || \ + printf "Expected failure 6" + test -s ${test_out}; echo " "$? + rm -f ${test_out} diff --git a/test/pamseq.ok b/test/pamseq.ok index 52bb3dd8..654596fb 100644 --- a/test/pamseq.ok +++ b/test/pamseq.ok @@ -1 +1,7 @@ +Test 1 3929266994 304 +Test Invalid +Expected failure 1 1 +Expected failure 2 1 +Expected failure 3 1 +Expected failure 4 1 diff --git a/test/pamseq.test b/test/pamseq.test index e7b8060d..ce3d4995 100755 --- a/test/pamseq.test +++ b/test/pamseq.test @@ -1,6 +1,42 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamseq # Also requires: +echo "Test 1" 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 + +tmpdir=${tmpdir:-/tmp} +test_out=${tmpdir}/test_out + +pamseq 1 > ${test_out} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamseq 0 255 > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamseq 3 0 > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +c64="0123456789012345678901234567890123456789012345678901234567890123" +c256=${c64}${c64}${c64}${c64} + +# Tupletype string length=256 + +pamseq -tupletype="${c256}" 3 15 > ${test_out} || \ + printf "Expected failure 4" + test -s ${test_out}; echo " "$? + rm -f ${test_out} diff --git a/test/pamshuffle.ok b/test/pamshuffle.ok new file mode 100755 index 00000000..4f829744 --- /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 1 +Expected failure 2 1 +Expected failure 3 1 diff --git a/test/pamshuffle.test b/test/pamshuffle.test new file mode 100755 index 00000000..2941a9bc --- /dev/null +++ b/test/pamshuffle.test @@ -0,0 +1,67 @@ +#! /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." + +echo 1>&2 +echo "Invalid command-line argument combinations." 1>&2 +echo "Error messages should appear below the line." 1>&2 +echo "-----------------------------------------------------------" 1>&2 + +pamshuffle testimg.ppm testgrid.pbm > ${test_out} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamshuffle -randomseed -column testgrid.pbm > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamshuffle -randomseed=null testgrid.pbm > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} 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/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 0643081b..b9ce0269 100644 --- a/test/pamsumm.ok +++ b/test/pamsumm.ok @@ -1,8 +1,20 @@ +Test 1. Should print in order: 56, 0, 1, 0.250000 56 0 1 0.250000 +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 diff --git a/test/pamsumm.test b/test/pamsumm.test index a99dea0e..f482911a 100755 --- a/test/pamsumm.test +++ b/test/pamsumm.test @@ -1,14 +1,55 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamsumm # Also requires: +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. Should print in order: 1627, 0, 1, 0.483794" + +for type in -sum -min -max -mean + do + pamsumm -brief $type maze.pbm + done + +echo "Test 3. Should print in order: 10772432, 15, 255, 106.164760" + for type in -sum -min -max -mean do pamsumm -brief $type testimg.ppm done + + +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 + +pamsumm -sum -min testimg.ppm > ${test_out} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamsumm -sum -max testimg.ppm > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamsumm -mean -max testimg.ppm > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamsumm testimg.ppm > ${test_out} || \ + printf "Expected failure 4" + test -s ${test_out}; echo " "$? + rm -f ${test_out} diff --git a/test/pamtable.ok b/test/pamtable.ok index c8db6002..d63c7720 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,6 @@ 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 +Should print: Expected failure 1 +Expected failure 1 diff --git a/test/pamtable.test b/test/pamtable.test index 5c66b7ae..e948ad0c 100755 --- a/test/pamtable.test +++ b/test/pamtable.test @@ -1,20 +1,62 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamtable -# Also requires: pamgradient pamseq pamdepth +# 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" + +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 "Should print: Expected failure 1" + +pamseq -tupletype="void" 1 1 | pamtable -tuple -hex > \ + ${test_out} || \ + printf "Expected failure" + test -s ${test_out}; echo " "$? + rm -f ${test_out} 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 8de78a70..d6c105bf 100755 --- a/test/pamtopdbimg.test +++ b/test/pamtopdbimg.test @@ -21,7 +21,7 @@ echo high compression pgmmake 0.5 -maxval=15 160 160 > ${mono_pgm} for flag in "-compressed" "-maybecompressed" "-uncompressed" do - pamtopdbimg $flag ${mono_pgm} | wc -c + pamtopdbimg $flag ${mono_pgm} | wc -c | tr -d ' ' done | uniq -c | awk '{print $1}' rm ${mono_pgm} @@ -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/pamundice.ok b/test/pamundice.ok new file mode 100644 index 00000000..1234431d --- /dev/null +++ b/test/pamundice.ok @@ -0,0 +1,27 @@ +Test 1. Should print 2096818803 2818 twice +2096818803 2818 +2096818803 2818 +Test 2. Should print 2096818803 2818 twice +2096818803 2818 +2096818803 2818 +Test 3. Should print 2096818803 2818 twice +2096818803 2818 +2096818803 2818 +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 diff --git a/test/pamundice.test b/test/pamundice.test new file mode 100755 index 00000000..ba532c30 --- /dev/null +++ b/test/pamundice.test @@ -0,0 +1,202 @@ +#! /bin/sh +# This script tests: pamundice +# Also requires: pamfile pgmmake pnmtile pamcat + +tmpdir=${tmpdir:-/tmp} +fname_stem=${tmpdir}/part + +echo "Test 1. Should print 2096818803 2818 twice" + +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 + done + +pamundice -across=3 -down=5 ${fname_stem}"_%1d_%1a".pgm | cksum + +ls ${fname_stem}_?_?.pgm | \ + pamundice -across=3 -down=5 -listfile=- | cksum + +echo "Test 2. Should print 2096818803 2818 twice" + +tempfile=${tmpdir}/temp + +for y in 0 1 2 3 4 + do + pamundice -across=3 ${fname_stem}"_"$y"_%1a".pgm > ${tempfile}_"$y" + done + +pamcat -tb ${tempfile}_[01234] | cksum +rm ${tempfile}_[01234] + +# Note: the following 2 are valid. There should not be warning messages. + +for x in 0 1 2 + do + pamundice -down=5 ${fname_stem}"_%1d_"$x.pgm > ${tempfile}"_"$x + done + +pamcat -lr ${tempfile}_[012] | cksum +rm ${tempfile}_[012] + +rm ${fname_stem}_?_?.pgm + +echo "Test 3. Should print 2096818803 2818 twice" + +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 in 2 + do for y in 0 1 2 3 4 + do + pgmmake "."$(( x* 25 + y )) 11 17 > ${fname_stem}_${y}_${x}.pgm + done + done + +pamundice -across=3 -down=5 \ + -hoverlap=1 ${fname_stem}"_%1d_%1a".pgm | cksum + +rm ${fname_stem}_?_?.pgm + +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 in 0 1 2 + do for y in 4 + do + pgmmake "."$(( x* 25 + y )) 11 17 > ${fname_stem}_${y}_${x}.pgm + done + done + +pamundice -across=3 -down=5 \ + -voverlap=1 ${fname_stem}"_%1d_%1a".pgm | cksum + +rm ${fname_stem}_?_?.pgm + + +# Test 4. +echo "Test 4. Should print 2434390296 4436 four times" + +msize=$(pamfile -size maze.pbm) +mw=$(echo ${msize} | cut -d " " -f 1) +mh=$(echo ${msize} | cut -d " " -f 2) + +pnmtile $((${mw} * 2)) $((${mh} * 5)) maze.pbm | cksum + +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 in 0 1 2 3 4 5 6 7 8 9 + do + echo maze.pbm + done | pamundice -down=5 -across=2 -listfile=- | cksum + +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 maze.pbm | cksum + + +# Test Invalid. +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 + +# No input file pattern specified +pamundice -down=5 -across=2 > ${test_out} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# -down=0 +pamundice -down=0 -across=2 ${fname_stem}_"%1d"_"%1a".pbm > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# -across=0 +pamundice -down=5 -across=0 ${fname_stem}_"%1d"_"%1a".pbm > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# -down too large +pamundice -down=6 -across=2 ${fname_stem}_"%1d"_"%1a".pbm > ${test_out} || \ + printf "Expected failure 4" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# -across too large +pamundice -down=5 -across=3 ${fname_stem}_"%1d"_"%1a".pbm > ${test_out} || \ + printf "Expected failure 5" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# precision does not match +pamundice -down=5 -across=2 ${fname_stem}_"%2d"_"%2a".pbm > ${test_out} || \ + printf "Expected failure 6" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# precision set to zero +pamundice -down=5 -across=2 ${fname_stem}_"%0d"_"%0a".pbm > ${test_out} || \ + printf "Expected failure 7" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# no precision +pamundice -down=5 -across=2 ${fname_stem}_"%d"_"%a".pbm > ${test_out} || \ + printf "Expected failure 8" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# -hoverlap too large +pamundice -down=5 -across=2 -hoverlap=$((${mw}+1)) \ + ${fname_stem}_"%1d"_"%1a".pbm > ${test_out} || \ + printf "Expected failure 9" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# -voverlap too large +pamundice -down=5 -across=2 -voverlap=$((${mh}+1)) \ + ${fname_stem}_"%1d"_"%1a".pbm > ${test_out} || \ + printf "Expected failure 10" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# corrupt listfile : file names do not exist +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 " "$? + 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} || \ + printf "Expected failure 12" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +rm ${fname_stem}*.pbm diff --git a/test/pamvalidate.ok b/test/pamvalidate.ok new file mode 100644 index 00000000..98b0f70a --- /dev/null +++ b/test/pamvalidate.ok @@ -0,0 +1,13 @@ +valid +P1 +5 5 +01010 +10101 +01010 +00000 +11111 +not valid: Should print 0 four times +0 +0 +0 +0 diff --git a/test/pamvalidate.test b/test/pamvalidate.test new file mode 100755 index 00000000..708197da --- /dev/null +++ b/test/pamvalidate.test @@ -0,0 +1,20 @@ +#! /bin/sh +# This script tests: pamvalidate +# Also requires: + +echo "valid" +printf "P1\n5 5\n01010\n10101\n01010\n00000\n11111\n" | pamvalidate -plain + +echo "not valid: Should print 0 four times" +printf "P1\n5 5\n01010\n10101\n01010\n00000\n1111\n" | pamvalidate | \ + wc -c | tr -d ' ' + +printf "P1\n5 5\n01010\n10102\n01010\n00001\n11111\n" | pamvalidate | \ + wc -c | tr -d ' ' + +printf "P1\n5\n01010\n10101\n01010\n00000\n11111\n" | 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 aa71489b..ba350bc7 100755 --- a/test/pbm-misc-converters.test +++ b/test/pbm-misc-converters.test @@ -1,8 +1,8 @@ -#! /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 +# This script tests: pbmtoplot pbmtoppa pbmtoptx pbmtozinc # Also requires: pbmpage # Note: one-way test. @@ -10,31 +10,89 @@ # 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 71b622d0..17ee0338 100644 --- a/test/pbmclean.ok +++ b/test/pbmclean.ok @@ -1,3 +1,4 @@ +Test 1 P1 7 7 1111111 @@ -70,4 +71,18 @@ P1 0000000 0000000 0000000 +Test 2 760076056 4210813 +Test 3 +2096087149 5051 +2096087149 5051 +3762787431 5051 +1966718 5051 +544084261 5051 +2970762900 5051 +2571756059 5051 +2571756059 5051 +436062787 5051 +4188415575 5051 +Test Invalid +Expected failure 1 1 diff --git a/test/pbmclean.test b/test/pbmclean.test index a8e469b1..5eba68e0 100755 --- a/test/pbmclean.test +++ b/test/pbmclean.test @@ -1,19 +1,53 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmclean -# Also requires: pbmmake pbmpage pnmmargin pnmpad +# Also requires: pbmmake pbmpage pbmtext pnmmargin pnmpad tmpdir=${tmpdir:-/tmp} test_pbm=${tmpdir}/test.pbm +sheet_pbm=${tmpdir}/sheet.pbm + +echo "Test 1" pbmmake -g 3 3 | pnmmargin -black 2 > ${test_pbm} for n in 1 2 3 4 5 6 7 8 -do -pbmclean -min=$n -black -plain ${test_pbm} -done + do + pbmclean -min=${n} -black -plain ${test_pbm} + done rm ${test_pbm} + +echo "Test 2" + # Should print 760076056 4210813 pbmpage 1 | pbmclean -black | cksum + + +echo "Test 3" + +pbmtext -dump-sheet > ${sheet_pbm} +for n in 1 2 3 4 5 6 7 8 9 10 + do + pbmclean -min=${n} -extended ${sheet_pbm} | cksum + done + +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 + +# overspecification +pbmclean -black -white -min=1 -extended testgrid.pbm > ${test_out} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# note that without -extended the above is valid. diff --git a/test/pbmlife.ok b/test/pbmlife.ok new file mode 100755 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 754eefdf..e39f4cf8 100644 --- a/test/pbmmake.ok +++ b/test/pbmmake.ok @@ -1,3 +1,4 @@ +Test 1 P11 10 P11 11 P11 10 @@ -22,6 +23,7 @@ P17 70101010101010101010101010101010101010101010101010 P18 80000000000000000000000000000000000000000000000000000000000000000 P18 81111111111111111111111111111111111111111111111111111111111111111 P18 80101010110101010010101011010101001010101101010100101010110101010 +Test 2 4058563256 45 3969089344 105 702117756 189 @@ -41,3 +43,12 @@ P18 80101010110101010010101011010101001010101101010100101010110101010 1824232358 2931 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 diff --git a/test/pbmmake.test b/test/pbmmake.test index 4b18e3ea..1d1c682b 100755 --- a/test/pbmmake.test +++ b/test/pbmmake.test @@ -1,18 +1,73 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmmake # Also requires: +echo "Test 1" -for i in `seq 1 8` -do -for color in -w -b -g -do -pbmmake -plain $color $i $i | tr -d '\n'; echo -done -done -for i in `seq 8 5 98` -do - ( pbmmake -w $i $i ; - pbmmake -b $i $i ; - pbmmake -g $i $i ) | cksum -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 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} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmmake -b -g -plain 1 1 > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmmake -white -gray -plain 1 1 > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmmake -white -plain > ${test_out} || \ + printf "Expected failure 4" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmmake -white -plain 1 > ${test_out} || \ + printf "Expected failure 5" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmmake -white -plain 1 0 > ${test_out} || \ + printf "Expected failure 6" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmmake -white -plain 0 1 > ${test_out} || \ + printf "Expected failure 7" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmmake -white -plain 1 1 1 > ${test_out} || \ + printf "Expected failure 8" + test -s ${test_out}; echo " "$? + rm -f ${test_out} 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..c2a61c37 --- /dev/null +++ b/test/pbmnoise-parameters.ok @@ -0,0 +1,26 @@ +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 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 diff --git a/test/pbmnoise-parameters.test b/test/pbmnoise-parameters.test new file mode 100755 index 00000000..17d2c76b --- /dev/null +++ b/test/pbmnoise-parameters.test @@ -0,0 +1,143 @@ +#! /bin/sh +# This script tests: pbmnoise +# Also requires: + +echo "Invalid command-line argument combinations." 1>&2 +echo "Error messages should appear below the line." 1>&2 +echo "-----------------------------------------------------------" 1>&2 + +echo "Test Invalid" + +test_out=${tmpdir}/test_out + +# Invalid -ratio arguments + +pbmnoise -ratio 100 100 > ${test_out} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmnoise -ratio 0 1 100 > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmnoise -ratio=1.1 100 100 > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmnoise -ratio=-1 100 100 > ${test_out} || \ + printf "Expected failure 4" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmnoise -ratio=half 100 100 > ${test_out} || \ + printf "Expected failure 5" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmnoise -ratio=0/1/1 100 100 > ${test_out} || \ + printf "Expected failure 6" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmnoise -ratio=-1/2 100 100 > ${test_out} || \ + printf "Expected failure 7" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmnoise -ratio=1/0 100 100 > ${test_out} || \ + printf "Expected failure 8" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmnoise -ratio=/2 100 100 > ${test_out} || \ + printf "Expected failure 9" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmnoise -ratio=4/2 100 100 > ${test_out} || \ + printf "Expected failure 10" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmnoise -ratio=6/ 100 100 > ${test_out} || \ + printf "Expected failure 11" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmnoise -ratio=1.0/2.0 100 100 > ${test_out} || \ + printf "Expected failure 12" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# denominator must be power of 2 +pbmnoise -ratio=3/9 100 100 > ${test_out} || \ + printf "Expected failure 13" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmnoise -ratio=a/2 100 100 > ${test_out} || \ + printf "Expected failure 14" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + + +pbmnoise -ratio=2/a 100 100 > ${test_out} || \ + printf "Expected failure 15" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmnoise -ratio=1/-2 100 100 > ${test_out} || \ + printf "Expected failure 16" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# Denominator must be 65536 or less +pbmnoise -ratio=1/65537 100 100 > ${test_out} || \ + printf "Expected failure 17" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmnoise -ratio=1/131072 100 100 > ${test_out} || \ + printf "Expected failure 17" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmnoise -endian=large 100 100 > ${test_out} || \ + printf "Expected failure 18" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmnoise -randomseed 100 100 > ${test_out} || \ + printf "Expected failure 19" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmnoise -randomseed=-1 100 100 > ${test_out} || \ + printf "Expected failure 20" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmnoise -randomseed=0.1 100 100 > ${test_out} || \ + printf "Expected failure 21" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmnoise > ${test_out} || \ + printf "Expected failure 22" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmnoise 100 > ${test_out} || \ + printf "Expected failure 23" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmnoise 100 200 300 > ${test_out} || \ + printf "Expected failure 24" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + + 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 7f68da74..8013f2f2 100644 --- a/test/pbmpage.ok +++ b/test/pbmpage.ok @@ -1,3 +1,9 @@ +Test 1 550172004 4210813 4142746975 4210813 2347597649 4210813 +3453559794 4349933 +Test Invalid +Expected failure 1 1 +Expected failure 2 1 +Expected failure 3 1 diff --git a/test/pbmpage.test b/test/pbmpage.test index e9bfe352..4f15452d 100755 --- a/test/pbmpage.test +++ b/test/pbmpage.test @@ -1,8 +1,35 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmpage # Also requires: +echo "Test 1" -pbmpage 1 | cksum -pbmpage 2 | cksum -pbmpage 3 | cksum +pbmpage 1 | cksum +pbmpage 2 | cksum +pbmpage 3 | cksum +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 + +tmpdir=${tmpdir:-/tmp} +test_out=${tmpdir}/test_out + +pbmpage -a3 1 > ${test_out} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmpage 0 > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmpage 4 > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} diff --git a/test/pbmpscale.ok b/test/pbmpscale.ok index e25d4027..9ea594d8 100644 --- a/test/pbmpscale.ok +++ b/test/pbmpscale.ok @@ -1,50 +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 +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 1 +Expected failure 2 1 +Expected failure 3 1 diff --git a/test/pbmpscale.test b/test/pbmpscale.test index 42046c74..efa5bfb5 100755 --- a/test/pbmpscale.test +++ b/test/pbmpscale.test @@ -1,12 +1,51 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmpscale -# Also requires: pamenlarge pbmtext +# 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 -pbmtext -nomargin "F" | pbmpscale 3 -plain +echo "Test 5. Should print 576003211 10631" +pbmpscale 5 maze.pbm | cksum -for i in 2 3 4 -do -pamenlarge 2 testgrid.pbm | \ - pbmpscale $i | cksum -done +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 + +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 + +pbmpscale testgrid.pbm > ${test_out} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmpscale 0 testgrid.pbm > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmpscale 2 3 testgrid.pbm > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} diff --git a/test/pbmtext-bdf.ok b/test/pbmtext-bdf.ok index b1486493..eab8a4bd 100644 --- a/test/pbmtext-bdf.ok +++ b/test/pbmtext-bdf.ok @@ -1,4 +1,6 @@ +Test 1 386826492 35 +Test 2 1 1 1 @@ -17,5 +19,6 @@ 1 1 1 +Test 3 0 0 diff --git a/test/pbmtext-bdf.test b/test/pbmtext-bdf.test index 50df7b75..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: @@ -65,8 +65,10 @@ EOF # Test 1 # This should succeed and produce 386826492 35 -pbmtext -font ${font_bdf} ABC | cksum +echo "Test 1" + +pbmtext -font ${font_bdf} ABC | cksum # Test 2 # These should all fail. Writes 1 eightteen times. @@ -75,6 +77,8 @@ echo "Test whether corrupted BDF font files are properly handled." 1>&2 echo "Error messages should appear below the line." 1>&2 echo "-----------------------------------------------------------" 1>&2 +echo "Test 2" + pbmtext -font ${font_bdf} BCD echo $? @@ -154,10 +158,12 @@ for delete_line in 14 16 18 20 done -# Test 2 +# Test 3 # These should succeed. Warning messages will be displayed. # Writes 1 two times. +echo "Test 3" + for token in "CHARSET_ENCODING" "CHARSET_REGISTRY" do font_corrupt_bdf=${font_corrupt}.naked_${token}.bdf @@ -167,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.ok b/test/pbmtext-iso88591.ok index 6cc1a856..842c435d 100644 --- a/test/pbmtext-iso88591.ok +++ b/test/pbmtext-iso88591.ok @@ -1,4 +1,6 @@ -3806607098 5110 -3806607098 5110 +Test 1 +2066913605 5110 +2066913605 5110 +Test 2 2858870527 192 2858870527 192 diff --git a/test/pbmtext-iso88591.test b/test/pbmtext-iso88591.test index bc5e83ab..6df296dd 100755 --- a/test/pbmtext-iso88591.test +++ b/test/pbmtext-iso88591.test @@ -1,46 +1,69 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmtext # Also requires: -# This test requires the following locale: -# LC_ALL en_US.iso88591 +# This test requires an iso-8859-1 locale # Skip this test if it is not available -iconv /dev/null -if [ $? -ne 0 ] - then echo "iconv command not available." 1>&2 - echo "Skipping." 1>&2 - exit 80; -fi +LANG=C +LC_ALL=C +export LANG LC_ALL + +tmpdir=${tmpdir:-/tmp} +iso88591_locale_list=${tmpdir}/iso88591_locale_list + + +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} + +# 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}`; + done; -echo "A" | LC_ALL=en_US.iso88591 pbmtext -wchar > /dev/null -if [ $? -ne 0 ] - then echo "LC_ALL could not be set to en_US.iso88591" 1>&2 +rm ${iso88591_locale_list}; +if [ -z ${locale_to_test} ] + then echo "No iso-8859-1 locale available." 1>&2 echo "Skipping." 1>&2 - exit 80; -fi + exit 80; +else + echo "Testing with locale set to ${locale_to_test}" 1>&2 +fi; + +locale_for_test=${locale_to_test}; + # Two rows -# Should print 3806607098 5110 twice -LC_ALL=C \ +# Should print 2066913605 5110 twice +echo "Test 1" + awk 'BEGIN { for (i=32; i<=126;++i) printf("%c",i); print ""; \ - for (i=160;i<=255;++i) printf("%c",i); }' | \ + for (i=161;i<=255;++i) printf("%c",i); }' | \ pbmtext -builtin bdf | cksum - -LC_ALL=C \ awk 'BEGIN { for (i=32; i<=126;++i) printf("%c",i); print ""; \ - for (i=160;i<=255;++i) printf("%c",i); }' | \ - LC_ALL=en_US.iso88591 pbmtext -builtin bdf -wchar | cksum + for (i=161;i<=255;++i) printf("%c",i); }' | \ + LC_ALL=${locale_for_test} pbmtext -builtin bdf -wchar | cksum # Two rows # Should print 2858870527 192 twice -LC_ALL=C \ + +echo "Test 2" + awk 'BEGIN { for (i=32; i<=126;++i) printf("%c",i); print ""; \ for (i=161;i<=255;++i) printf("%c",i); print "" }' | cksum -LC_ALL=C \ awk 'BEGIN { for (i=32; i<=126;++i) printf("%c",i); print ""; \ for (i=161;i<=255;++i) printf("%c",i); print ""}' | \ - LC_ALL=en_US.iso88591 pbmtext -builtin bdf -wchar -text-dump | cksum \ No newline at end of file + LC_ALL=${locale_for_test} pbmtext -builtin bdf -wchar -text-dump | cksum diff --git a/test/pbmtext-utf8.ok b/test/pbmtext-utf8.ok index 588bf617..84743a09 100644 --- a/test/pbmtext-utf8.ok +++ b/test/pbmtext-utf8.ok @@ -1,8 +1,24 @@ +Test 1 2066913605 5110 2066913605 5110 +Test 2 2920616515 2301 2920616515 2301 -0 0 0 0 : 0 +Test 3 +0 0 0 : 0 +Test 4 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ -0 1 : 1 +Test 5 Invalid +9998 +989454365 52512 +9999 +Expected failure 1 1 +Expected failure 2 1 +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 diff --git a/test/pbmtext-utf8.test b/test/pbmtext-utf8.test index cf495b7c..9203607f 100755 --- a/test/pbmtext-utf8.test +++ b/test/pbmtext-utf8.test @@ -2,68 +2,101 @@ # This script tests: pbmtext # Also requires: -# This test requires the en_US.utf8 locale -# Skip this test if it is not available +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 iconv /dev/null if [ $? -ne 0 ] then echo "iconv command not available." 1>&2 echo "Skipping." 1>&2 - exit 80; + exit 80; fi -echo "A" | LC_ALL=en_US.utf8 pbmtext -wchar > /dev/null -if [ $? -ne 0 ] - then echo "LC_ALL could not be set to en_US.utf8." 1>&2 +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} + +# 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}`; + done; + +rm ${utf_locale_list}; +if [ -z ${locale_to_test} ] + then echo "No utf-8 locale available." 1>&2 echo "Skipping." 1>&2 - exit 80; -fi + exit 80; + else + echo "Testing with locale set to ${locale_to_test}" 1>&2 +fi; + +locale_for_test=${locale_to_test} + # Test 1. # Two rows # Should print 2066913605 5110 twice -LC_ALL=C \ + +echo "Test 1" + awk 'BEGIN { for (i=32; i<=126;++i) printf("%c",i); print ""; \ for (i=161;i<=255;++i) printf("%c",i); }' | \ pbmtext -builtin bdf | cksum -LC_ALL=C \ awk 'BEGIN { for (i=32; i<=126;++i) printf("%c",i); print ""; \ - for (i=161;i<=255;++i) printf("%c",i); }' | \ - iconv -f iso8859-1 -t utf-8 | \ - LC_ALL=en_US.utf8 pbmtext -builtin bdf -wchar | cksum + for (i=161;i<=191;++i) printf("%c%c",194,i); \ + for (i=128;i<=191;++i) printf("%c%c",195,i); }' | \ + LC_ALL=${locale_for_test} pbmtext -builtin bdf -wchar | cksum # Test 2. # One row # Should print 2920616515 2301 twice -LC_ALL=C \ + +echo "Test 2" + awk 'BEGIN { for (i=32; i<=126;++i) printf("%c",i); print "" }' | \ pbmtext -builtin bdf | cksum -LC_ALL=C \ awk 'BEGIN { for (i=32; i<=126;++i) printf("%c",i); print ""}' | \ - LC_ALL=en_US.utf8 pbmtext -builtin bdf -wchar | cksum - + LC_ALL=${locale_for_test} pbmtext -builtin bdf -wchar | cksum -tmpdir=${tmpdir:-/tmp} output=${tmpdir}/output # Test 3. # Two rows -# Output may be affected by locale. Compare with cmp. -# Should print 0 -LC_ALL=C \ +# Compare with cmp. +# Should print 0 0 0 : 0 + +echo "Test 3" + awk 'BEGIN { for (i=32; i<=126;++i) printf("%c",i); print ""; \ - for (i=161;i<=255;++i) printf("%c",i); print "" }' | \ - iconv -f iso8859-1 -t utf-8 > ${output} + for (i=161;i<=191;++i) printf("%c%c",194,i); \ + for (i=128;i<=191;++i) printf("%c%c",195,i); print ""}' \ + > ${output} -LC_ALL=C \ awk 'BEGIN { for (i=32; i<=126;++i) printf("%c",i); print ""; \ - for (i=161;i<=255;++i) printf("%c",i); print "" }' | \ - iconv -f iso8859-1 -t utf-8 | \ - LC_ALL=en_US.utf8 pbmtext -builtin bdf -wchar -text-dump | \ + for (i=161;i<=191;++i) printf("%c%c",194,i); \ + for (i=128;i<=191;++i) printf("%c%c",195,i); print ""}' | \ + LC_ALL=${locale_for_test} pbmtext -builtin bdf -wchar -text-dump | \ cmp --quiet - ${output} echo ${PIPESTATUS[@]} ":" $? @@ -71,25 +104,106 @@ rm ${output} # Test 4. -# One row +# One row ASCII 7-bit range # Should print the following twice: # !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ -LC_ALL=C \ + +echo "Test 4" + awk 'BEGIN { for (i=32; i<=126;++i) printf("%c",i); print "" } ' -LC_ALL=C \ awk 'BEGIN { for (i=32; i<=126;++i) printf("%c",i); print ""}' | \ - LC_ALL=en_US.utf8 pbmtext -builtin bdf -wchar -text-dump + LC_ALL=${locale_for_test} pbmtext -builtin bdf -wchar -text-dump + +# Test 5. +# Long input text -echo "Invalid utf-8 sequence as input." 1>&2 -echo "An error message should appear below the line." 1>&2 +echo "Test 5 Invalid" + +long_txt=${tmpdir}/long.txt +test_out=${tmpdir}/test_out + +head -c 4999 /dev/zero | sed 's@\x00@\xc2\xbe@g' > ${long_txt} +cat ${long_txt} | wc -c | tr -d ' ' + +cat ${long_txt} | \ + LC_ALL=${locale_for_test} pbmtext -nomargins -builtin fixed -wchar | cksum + +echo 1>&2 +echo "Test input text which exceeds length limit" 1>&2 +echo "Error messages should appear below the line." 1>&2 echo "-----------------------------------------------------------" 1>&2 -# Test 5. -# Invalid utf-8 sequence -# Should print 1 -LC_ALL=C \ -awk 'BEGIN { for (i=128; i<=129;++i) printf("%c",i); print ""}' | \ - LC_ALL=en_US.utf8 pbmtext -builtin bdf -wchar -text-dump -echo ${PIPESTATUS[@]} ":" $? +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} || \ + printf "Expected failure 1"; + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +cat ${long_txt} | \ + LC_ALL=${locale_for_test} \ + pbmtext -nomargins -builtin fixed -wchar > ${test_out} || \ + printf "Expected failure 2"; + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +rm ${long_txt} + + +# Test 6. +# Invalid utf-8 sequences +# For each case output should be: +# 6-x : 0 1 : 1 1 + +echo "Invalid utf-8 sequences as input." 1>&2 +echo "Errors message should appear below the line." 1>&2 +echo "-----------------------------------------------------------" 1>&2 + +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} + printf "6-1: ${PIPESTATUS[*]} : $?" + test -s ${test_out}; echo " "$? + 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} + printf "6-2: ${PIPESTATUS[*]} : $?" + test -s ${test_out}; echo " "$? + 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} + printf "6-3: ${PIPESTATUS[*]} : $?" + test -s ${test_out}; echo " "$? + 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} + printf "6-4: ${PIPESTATUS[*]} : $?" + test -s ${test_out}; echo " "$? + 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} + printf "6-5: ${PIPESTATUS[*]} : $?" + test -s ${test_out}; echo " "$? + 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} + printf "6-6: ${PIPESTATUS[*]} : $?" + test -s ${test_out}; echo " "$? + rm -f ${test_out} diff --git a/test/pbmtext.ok b/test/pbmtext.ok index 96e351f9..68ed40d8 100644 --- a/test/pbmtext.ok +++ b/test/pbmtext.ok @@ -1,16 +1,39 @@ +Test 1 3898818212 967 3898818212 967 2506052117 1354 2506052117 1354 +Test 2 1028079028 967 1888680721 445 1305436978 1018 +Test 3 1028079028 967 1028079028 967 1305436978 1018 1305436978 1018 +Test 4 1647614653 2027 1647614653 2027 1647614653 2027 +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 +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 diff --git a/test/pbmtext.test b/test/pbmtext.test index 38578636..247f76c5 100755 --- a/test/pbmtext.test +++ b/test/pbmtext.test @@ -1,27 +1,29 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmtext # Also requires: pamfile tmpdir=${tmpdir:-/tmp} # Test 1: +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 text="The quick brown fog jumps over the lazy docs." # Test 2: +echo "Test 2" for flags in "" "-nomargins" "-builtin fixed" do @@ -33,12 +35,13 @@ temp_pbm=${tmpdir}/temp.pbm # Test 3: Check if image is produced unaltered when -width is specified # Should print 1028079028 967 twice, then 1305436978 1018 twice +echo "Test 3" 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 @@ -50,7 +53,7 @@ done # Test 4: Should print 1647614653 2027 three times -# Note: backslashes inserted in 3 locations in the rectange to make +# Note: backslashes inserted in 3 locations in the rectangle to make # possible input as a here document. fontRectangle_txt=${tmpdir}/fontRectangle.txt @@ -71,13 +74,16 @@ _ PQRSTUVWXYZ[ _ M ",/^_[\`jpqy| M EOF +echo "Test 4" + pbmtext -dump-sheet -builtin fixed | tee ${font_pbm} | cksum cat ${fontRectangle_txt} | pbmtext -nom -builtin fixed | cksum cat ${fontRectangle_txt} | pbmtext -nom -font ${font_pbm} | cksum -rm ${fontRectangle_txt} ${font_pbm} +rm ${fontRectangle_txt} # Test 5: Print all characters defined in the built-in bdf font +echo "Test 5" # One long row # Should print 3233136020 4535 @@ -92,3 +98,98 @@ LC_ALL=C \ awk 'BEGIN { for (i=32; i<=126;++i) printf("%c\n",i); for (i=160;i<=255;++i) printf("%c\n",i); }' | \ pbmtext -nomargins -builtin bdf | cksum + + +# Test 6 + +echo 1>&2 +echo "Invalid font file specifications & command-line argument combinations." 1>&2 +echo "Error messages should appear below the line." 1>&2 +echo "-----------------------------------------------------------" 1>&2 + +echo "Test 6 Invalid" + +test_out=${tmpdir}/test_out + +pbmtext -font=testgrid.pbm foo > ${test_out} || \ + printf "Expected failure 1"; + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmtext -font=testimg.ppm foo > ${test_out} || \ + printf "Expected failure 2"; + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmtext -builtin=void foo > ${test_out} || \ + printf "Expected failure 3"; + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmtext -font=${font_pbm} -builtin=fixed foo > ${test_out} || \ + printf "Expected failure 4"; + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmtext -dry-run -text-dump foo > ${test_out} || \ + printf "Expected failure 5"; + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmtext -dump-sheet -text-dump foo > ${test_out} || \ + printf "Expected failure 6"; + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmtext -dry-run -dump-sheet foo > ${test_out} || \ + printf "Expected failure 7"; + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmtext -wchar foo > ${test_out} || \ + printf "Expected failure 8"; + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +rm ${font_pbm} + +# Test 7 +# Text to render in very long single line + +echo "Test 7" + +long_txt=${tmpdir}/long.txt + +head -c 4999 /dev/zero | tr '\0' 'A' > ${long_txt} +awk '{print "text length:", length($0)}' ${long_txt} + +pbmtext -nomargins -builtin fixed `cat ${long_txt}` | cksum +cat ${long_txt} | pbmtext -nomargins -builtin fixed | cksum + +echo "Test 8 Invalid" + +printf "z" >> ${long_txt} +awk '{print "text length:", length($0)}' ${long_txt} + +echo 1>&2 +echo "Test input text which exceeds length limit" 1>&2 +echo "Error messages should appear below the line." 1>&2 +echo "-----------------------------------------------------------" 1>&2 + +pbmtext -nomargins -builtin fixed `cat ${long_txt}` > ${test_out} || \ + printf "Expected failure 1"; + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +cat ${long_txt} | pbmtext -nomargins -builtin fixed > ${test_out} || \ + printf "Expected failure 2"; + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +cat ${long_txt} | \ + LC_ALL=C pbmtext -nomargins -builtin fixed -wchar > ${test_out} || \ + printf "Expected failure 3"; + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +rm ${long_txt} diff --git a/test/pbmtextps-dump.ok b/test/pbmtextps-dump.ok new file mode 100644 index 00000000..11a4c5fd --- /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) 1 +Expected failure 2 (-fontsize 0) 1 +Expected failure 3 (-resolution) 1 +Expected failure 4 (-resolution=0) 1 +Expected failure 5 (-leftmargin) 1 +Expected failure 6 (-leftmargin -1) 1 +Expected failure 7 (-rightmargin) 1 +Expected failure 8 (-rightmargin -1) 1 +Expected failure 9 (-topmargin) 1 +Expected failure 10 (-topmargin -1) 1 +Expected failure 11 (-bottommargin) 1 +Expected failure 12 (-bottommargin -1) 1 +Expected failure 13 (-ascent) 1 +Expected failure 14 (-ascent -1) 1 +Expected failure 15 (-descent) 1 +Expected failure 16 (-descent -1) 1 +Expected failure 17 (-stroke=A) 1 +Expected failure 18 (-pad -crop) 1 +Expected failure 19 (-asciihex <a>) 1 +Expected failure 20 (-asciihex ) 1 +Expected failure 21 (-asciihex <53756c667572) 1 +Expected failure 22 (-asciihex 53756c667572>) 1 +Expected failure 23 (-asciihex <5375<6c667572>) 1 +Expected failure 24 (-asciihex <53756c>667572>) 1 +Expected failure 25 (-ascii85 <~@<6O!FD5W(~) 1 +Expected failure 26 (-ascii85 ~@<6O!FD5W(~>) 1 +Expected failure 27 (-ascii85 <~@<6O<~!FD5W(~>) 1 +Expected failure 28 (-ascii85 <~@<6O~>!FD5W(~>) 1 +Expected failure 29 (-ascii85 <~@<6O!FD5W(~~>) 1 +Expected failure 30 (-ascii85 v) 1 +Expected failure 31 (-ascii85 y) 1 +Expected failure 32 (-ascii85 1z) 1 +Expected failure 33 (-ascii85 z1z) 1 +Expected failure 34 (-ascii85 <~0123z~>) 1 +Expected failure 35 (-font="") 1 diff --git a/test/pbmtextps-dump.test b/test/pbmtextps-dump.test new file mode 100755 index 00000000..82856f7e --- /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 " "$? + 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 " "$? + 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 " "$? + 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 " "$? + 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 new file mode 100644 index 00000000..6ccf9c64 --- /dev/null +++ b/test/pbmtopgm.ok @@ -0,0 +1,25 @@ +Test 1 +P2 +14 16 +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 +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 +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 +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 +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 +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 +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 +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 diff --git a/test/pbmtopgm.test b/test/pbmtopgm.test new file mode 100755 index 00000000..02f2bb21 --- /dev/null +++ b/test/pbmtopgm.test @@ -0,0 +1,38 @@ +#! /bin/sh +# This script tests: pbmtopgm +# Also requires: + +#Test 1 +echo "Test 1" + +pbmtopgm -plain 1 1 testgrid.pbm + +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 + +pbmtopgm 5 0 testgrid.pbm > ${test_out} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmtopgm 0 9 testgrid.pbm > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmtopgm 15 5 testgrid.pbm > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmtopgm 5 17 testgrid.pbm > ${test_out} || \ + printf "Expected failure 4" + test -s ${test_out}; echo " "$? + rm -f ${test_out} diff --git a/test/pbmupc.ok b/test/pbmupc.ok index 3e58f409..f1b91e99 100644 --- a/test/pbmupc.ok +++ b/test/pbmupc.ok @@ -1 +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 diff --git a/test/pbmupc.test b/test/pbmupc.test index 275117d5..f8343dd7 100755 --- a/test/pbmupc.test +++ b/test/pbmupc.test @@ -1,9 +1,65 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmupc # Also requires: +echo "Test 1" for type in -s1 -s2 do pbmupc $type 0 72890 00011 done | cksum + +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 + +pbmupc -s3 0 72890 00011 > ${test_out} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmupc -s1 72890 00011 > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmupc -s1 0 72890 > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmupc -s1 10 72890 00011 > ${test_out} || \ + printf "Expected failure 4" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmupc -s1 0 172890 00011 > ${test_out} || \ + printf "Expected failure 5" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmupc -s1 0 2890 00011 > ${test_out} || \ + printf "Expected failure 6" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmupc -s1 0 72890 100011 > ${test_out} || \ + printf "Expected failure 7" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmupc -s1 0 72890 0011 > ${test_out} || \ + printf "Expected failure 8" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmupc -s1 0 72890 100011 1 > ${test_out} || \ + printf "Expected failure 9" + test -s ${test_out}; echo " "$? + 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 6b4e152c..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 +# 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 7d89bb33..3be73ff9 100644 --- a/test/pgmhist.ok +++ b/test/pgmhist.ok @@ -1,3 +1,4 @@ +Test 1 value count b% w% ----- ----- ------ ------ 0 2 12.5% 100% @@ -12,3 +13,24 @@ value count b% w% ----- ----- ------ ------ 0 168 75% 100% 255 56 100% 25% +Test 2 +127 +63 +127 +191 +255 +25 +51 +76 +102 +127 +153 +179 +204 +230 +255 +Test Invalid +Expected failure 1 1 +Expected failure 2 1 +Expected failure 3 1 +Expected failure 4 1 diff --git a/test/pgmhist.test b/test/pgmhist.test index 42666fbf..c141627d 100755 --- a/test/pgmhist.test +++ b/test/pgmhist.test @@ -1,12 +1,55 @@ -#! /bin/bash +#! /bin/sh # This script tests: pgmhist # Also requires: pgmramp # Ignore differences in spaces. +echo "Test 1" + pgmramp -maxval=8 -lr 8 2 | pgmhist | \ sed -e 's/ */ /g' -e 's/ *$//' pgmhist testgrid.pbm | \ sed -e 's/ */ /g' -e 's/ *$//' + +echo "Test 2" + +pgmramp -lr 256 1 | pgmhist -machine -median | \ + sed -e 's/ */ /g' -e 's/ *$//' + +pgmramp -lr 256 1 | pgmhist -machine -quartile | \ + sed -e 's/ */ /g' -e 's/ *$//' + +pgmramp -lr 256 1 | pgmhist -machine -decile | \ + sed -e 's/ */ /g' -e 's/ *$//' + +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 + +pgmhist -median -quartile testgrid.pbm > ${test_out} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pgmhist -median -decile testgrid.pbm > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pgmhist -quartile -decile testgrid.pbm > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pgmhist testimg.ppm > ${test_out} || \ + printf "Expected failure 4" + test -s ${test_out}; echo " "$? + rm -f ${test_out} diff --git a/test/pgmmake.ok b/test/pgmmake.ok index b9a03af2..8b242822 100644 --- a/test/pgmmake.ok +++ b/test/pgmmake.ok @@ -1,2 +1,12 @@ +Test 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 diff --git a/test/pgmmake.test b/test/pgmmake.test index 4a3c4842..3c96d99e 100755 --- a/test/pgmmake.test +++ b/test/pgmmake.test @@ -1,7 +1,59 @@ -#! /bin/bash +#! /bin/sh # This script tests: pgmmake # Also requires: +echo "Test 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} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pgmmake 1.01 5 5 > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pgmmake .5 5 > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pgmmake .5 > ${test_out} || \ + printf "Expected failure 4" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pgmmake -maxval=5 5 5 > ${test_out} || \ + printf "Expected failure 5" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pgmmake -maxval=0 .5 5 5 > ${test_out} || \ + printf "Expected failure 6" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pgmmake -maxval=-1 .5 5 5 > ${test_out} || \ + printf "Expected failure 7" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pgmmake -maxval=65536 .5 5 5 > ${test_out} || \ + printf "Expected failure 8" + test -s ${test_out}; echo " "$? + rm -f ${test_out} diff --git a/test/pgmminkowski.ok b/test/pgmminkowski.ok new file mode 100644 index 00000000..86f43207 --- /dev/null +++ b/test/pgmminkowski.ok @@ -0,0 +1,17 @@ +#threshold tiles x-edges y-edges vertices +#--------- ----- ------- ------- -------- +0.000000 9 12 12 16 1 1 1 +0.501961 1 2 2 4 0.111111 0.333333 1 +# check: 0 0 0 0 + +#threshold tiles x-edges y-edges vertices +#--------- ----- ------- ------- -------- +0.000000 9 12 12 16 1 1 1 +1.000000 5 10 10 16 0.555556 1.66667 1 +# check: 0 0 0 0 + +#threshold tiles x-edges y-edges vertices +#--------- ----- ------- ------- -------- +0.000000 224 240 238 255 1 1 1 +1.000000 56 112 112 224 0.25 3.73333 56 +# check: 0 0 0 0 diff --git a/test/pgmminkowski.test b/test/pgmminkowski.test new file mode 100755 index 00000000..e81de3e1 --- /dev/null +++ b/test/pgmminkowski.test @@ -0,0 +1,10 @@ +#! /bin/sh +# This script tests: pgmminkowski +# Also requires: pbmmake pgmmake pnmpad + +pgmmake .5 1 1 | pnmpad -black -top=1 -left=1 -bottom=1 -right=1 | \ + pgmminkowski +echo +pbmmake -g 3 3 | pgmminkowski +echo +pgmminkowski testgrid.pbm diff --git a/test/pgmnoise-parameters.ok b/test/pgmnoise-parameters.ok new file mode 100644 index 00000000..1bb1cd59 --- /dev/null +++ b/test/pgmnoise-parameters.ok @@ -0,0 +1,5 @@ +Expected failure 1 1 +Expected failure 2 1 +Expected failure 3 1 +Expected failure 4 1 +Expected failure 5 1 diff --git a/test/pgmnoise-parameters.test b/test/pgmnoise-parameters.test new file mode 100755 index 00000000..c5e6ada5 --- /dev/null +++ b/test/pgmnoise-parameters.test @@ -0,0 +1,36 @@ +#! /bin/sh +# This script tests: pgmnoise +# Also requires: + +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 + +pgmnoise -maxval=255 -randomseed=1 > ${test_out} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pgmnoise 100 -randomseed=1 > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pgmnoise 100 0 -randomseed=1 > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pgmnoise 0 100 -randomseed=1 > ${test_out} || \ + printf "Expected failure 4" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pgmnoise 100 100 100 -randomseed=1 > ${test_out} || \ + printf "Expected failure 5" + test -s ${test_out}; echo " "$? + rm -f ${test_out} diff --git a/test/pgmnoise.ok b/test/pgmnoise.ok new file mode 100644 index 00000000..d98ee053 --- /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 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 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..6141121a 100755 --- a/test/pgmnoise.test +++ b/test/pgmnoise.test @@ -1,7 +1,128 @@ -#! /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) +# 1663614689 10015 (Glibc rand()) +# 3516404574 10015 (MAC OS rand()) 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 " "$? + rm -f ${test_out} + +pgmnoise 0 1 > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pgmnoise 1 0 > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pgmnoise > ${test_out} || \ + printf "Expected failure 4" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pgmnoise 1 > ${test_out} || \ + printf "Expected failure 5" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pgmnoise 100 -1 > ${test_out} || \ + printf "Expected failure 6" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pgmnoise -randomseed=-1 100 100 > ${test_out} || \ + printf "Expected failure 7" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pgmnoise -maxval=-1 100 100 > ${test_out} || \ + printf "Expected failure 8" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pgmnoise -maxval=0 100 100 > ${test_out} || \ + printf "Expected failure 9" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pgmnoise -maxval=$((256 * 256 * 256 * 256)) 10 10 > ${test_out} || \ + printf "Expected failure 10" + test -s ${test_out}; echo " "$? + rm -f ${test_out} diff --git a/test/pgmramp.ok b/test/pgmramp.ok index 989ef7d4..de0d9206 100644 --- a/test/pgmramp.ok +++ b/test/pgmramp.ok @@ -1,3 +1,4 @@ +Test 1 P2 4 4 6 @@ -33,8 +34,16 @@ P2 1 2 3 4 2 3 4 5 3 4 5 6 +Test 2 1777787286 65551 2046889993 65551 1975520432 65551 807973067 65551 +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 diff --git a/test/pgmramp.test b/test/pgmramp.test index f6f770fe..b4dbb3cd 100755 --- a/test/pgmramp.test +++ b/test/pgmramp.test @@ -1,15 +1,47 @@ -#! /bin/bash +#! /bin/sh # This script tests: pgmramp # Also requires: +echo "Test 1" for type in -lr -tb -rectangle -ellipse -diagonal do pgmramp -maxval=6 $type 4 4 -plain done +echo "Test 2" + for type in -lr -tb -rectangle -ellipse do pgmramp $type 256 256 | cksum done +echo "Test 3" + 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 + +tmpdir=${tmpdir:-/tmp} +test_out=${tmpdir}/test_out + +for combination in "-lr -tb" "-lr -rectangle" "-rectangle -ellipse" +do pgmramp $combination 10 10 > ${test_out} || \ + printf "Expected failure: $combination" + test -s ${test_out}; echo " "$? + rm -f ${test_out} +done + +pgmramp -lr 1 > ${test_out} || \ + printf "Expected failure: insufficient parameters"; \ + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pgmramp -tb 1 1 1 > ${test_out} || \ + printf "Expected failure: excessive parameters"; \ + test -s ${test_out}; echo " "$? + rm -f ${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..2484c487 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 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 diff --git a/test/pgmtoppm.test b/test/pgmtoppm.test index 70df0d97..36f63de7 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 " "$? + rm -f ${test_out} + +pgmtoppm -map=/dev/null testgrid.pbm > \ + ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pgmtoppm black white testgrid.pbm > \ + ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pgmtoppm hwite testgrid.pbm > \ + ${test_out} || \ + printf "Expected failure 4" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pgmtoppm off-color testgrid.pbm > \ + ${test_out} || \ + printf "Expected failure 5" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pgmtoppm rgb-255:7/7/7 testgrid.pbm > \ + ${test_out} || \ + printf "Expected failure 6" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pgmtoppm -black=black -white=white white testgrid.pbm > \ + ${test_out} || \ + printf "Expected failure 7" + test -s ${test_out}; echo " "$? + 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 " "$? + 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 " "$? + 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 " "$? + 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 " "$? + rm -f ${test_out} + +#pgmtoppm rgb-255:7/7/7 testgrid.pbm > \ +# ${test_out} || \ +# printf "Expected failure 12" +# test -s ${test_out}; echo " "$? +# 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.ok b/test/pj-roundtrip.ok new file mode 100644 index 00000000..195443ba --- /dev/null +++ b/test/pj-roundtrip.ok @@ -0,0 +1,4 @@ +Test 1. Should print: 0 0 0 0 : 0 +0 0 0 0 : 0 +Test 2. Should print: 0 0 : 0 +0 0 : 0 diff --git a/test/pj-roundtrip.test b/test/pj-roundtrip.test new file mode 100755 index 00000000..3ed30927 --- /dev/null +++ b/test/pj-roundtrip.test @@ -0,0 +1,26 @@ +#! /bin/bash +# This script tests: ppmtopj pjtoppm +# Also requires: pamseq pnmremap pamtopnm pamdepth ppmtoppm + +echo "Test 1. Should print: 0 0 0 0 : 0" + +tmpdir=${tmpdir:-/tmp} +test8_ppm=${tmpdir}/testimg8.ppm + +pamseq 3 1 | pnmremap -map - testimg.ppm | pamtopnm -assume > ${test8_ppm} + +ppmtopj ${test8_ppm} | pjtoppm | pamdepth 1 | \ + cmp -s - ${test8_ppm} > /dev/null + echo ${PIPESTATUS[@]} ":" $? + +rm ${test8_ppm} + +echo "Test 2. Should print: 0 0 : 0" + +testout_ppm=${tmpdir}/testout.ppm + +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 68052957..96e2b884 100644 --- a/test/pnmcat.ok +++ b/test/pnmcat.ok @@ -1,4 +1,98 @@ -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 diff --git a/test/pnmcat.test b/test/pnmcat.test index c643320d..bf40ada2 100755 --- a/test/pnmcat.test +++ b/test/pnmcat.test @@ -1,10 +1,184 @@ -#! /bin/bash +#! /bin/sh # This script tests: pnmcat -# Also requires: +# Also requires: pbmmake pgmramp ppmtoppm pamcat +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 +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 -pnmcat -lr testimg.ppm testimg.ppm | cksum -pnmcat -tb testimg.ppm testimg.ppm | cksum +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" + +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 + +# direction not specified +pnmcat testgrid.pbm testimg.ppm > ${test_out} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# both directions specified +pnmcat -topbottom -leftright testgrid.pbm testimg.ppm > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# both pad colors specified +pnmcat -topbottom -white -black testgrid.pbm testimg.ppm > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# justification parameters overspecified +pnmcat -lr -jtop -jbottom testgrid.pbm testimg.ppm > ${test_out} || \ + printf "Expected failure 4" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pnmcat -lr -jtop -jcenter testgrid.pbm testimg.ppm > ${test_out} || \ + printf "Expected failure 5" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pnmcat -lr -jcenter -jbottom testgrid.pbm testimg.ppm > ${test_out} || \ + printf "Expected failure 6" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pnmcat -tb -jleft -jright testgrid.pbm testimg.ppm > ${test_out} || \ + printf "Expected failure 7" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pnmcat -tb -jleft -jcenter testgrid.pbm testimg.ppm > ${test_out} || \ + printf "Expected failure 8" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pnmcat -tb -jcenter -jright testgrid.pbm testimg.ppm > ${test_out} || \ + printf "Expected failure 9" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# justification parameter in the wrong direction +pnmcat -lr -jleft testgrid.pbm testimg.ppm > ${test_out} || \ + printf "Expected failure 10" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pnmcat -lr -jright testgrid.pbm testimg.ppm > ${test_out} || \ + printf "Expected failure 11" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pnmcat -tb -jtop testgrid.pbm testimg.ppm > ${test_out} || \ + printf "Expected failure 12" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pnmcat -tb -jbottom testgrid.pbm testimg.ppm > ${test_out} || \ + printf "Expected failure 13" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# more than one input image from standard input +cat testgrid.pbm | pnmcat -lr - - testimg.ppm > ${test_out} || \ + printf "Expected failure 14" + test -s ${test_out}; echo " "$? + rm -f ${test_out} diff --git a/test/pnmcolormap.ok b/test/pnmcolormap.ok new file mode 100644 index 00000000..0c6f0d71 --- /dev/null +++ b/test/pnmcolormap.ok @@ -0,0 +1,40 @@ +Test 1. +P1 +2 1 +10 + +P1 +2 1 +10 + +P1 +2 1 +10 + +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 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 diff --git a/test/pnmcolormap.test b/test/pnmcolormap.test new file mode 100755 index 00000000..11d47385 --- /dev/null +++ b/test/pnmcolormap.test @@ -0,0 +1,80 @@ +#! /bin/sh +# This script tests: pnmcolormap +# Also requires: ppmpat + +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} +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." + +echo 1>&2 +echo "Invalid command-line arguments." 1>&2 +echo "Error messages should appear below the line." 1>&2 +echo "-----------------------------------------------------------" 1>&2 + +tmpdir=${tmpdir:-/tmp} +test_out=${tmpdir}/test_out + +pnmcolormap 0 testimg.ppm > ${test_out} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pnmcolormap -1 testimg.ppm > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pnmcolormap 0.1 testimg.ppm > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pnmcolormap -center -meancolor 16 testimg.ppm > ${test_out} || \ + printf "Expected failure 4" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pnmcolormap -center -meanpixel 16 testimg.ppm > ${test_out} || \ + printf "Expected failure 5" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pnmcolormap -meancolor -meanpixel 16 testimg.ppm > ${test_out} || \ + printf "Expected failure 6" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pnmcolormap -spreadbrightness -spreadluminosity 16 \ + testimg.ppm > ${test_out} || \ + printf "Expected failure 7" + test -s ${test_out}; echo " "$? + rm -f ${test_out} diff --git a/test/pnmcolormap2.ok b/test/pnmcolormap2.ok new file mode 100644 index 00000000..2eab38b8 --- /dev/null +++ b/test/pnmcolormap2.ok @@ -0,0 +1,9 @@ +Test. Should print 'match' eight times. +match +match +match +match +match +match +match +match diff --git a/test/pnmcolormap2.test b/test/pnmcolormap2.test new file mode 100755 index 00000000..bb870e7f --- /dev/null +++ b/test/pnmcolormap2.test @@ -0,0 +1,55 @@ +#! /bin/sh +# This script tests: pnmcolormap +# Also requires: pnmremap pnmpsnr + +tmpdir=${tmpdir:-/tmp} +map=${tmpdir}/map.ppm + +echo "Test. Should print 'match' eight times." +# Threshold values (targetN=xx.xx) here were produced by calculating +# the S/N ratio with reduced colors. + +# colors in following tests / colors for calculating threshold +# 100 / 90 +# 200 / 180 +# 30 / 25 + +pnmcolormap 100 testimg.ppm > ${map} +pnmremap -mapfile=${map} testimg.ppm |\ + pnmpsnr -target1=33.42 -target2=35.14 -target3=34.35 testimg.ppm - +rm ${map} + +pnmcolormap -meancolor 100 testimg.ppm > ${map} +pnmremap -mapfile=${map} testimg.ppm |\ + pnmpsnr -target1=34.91 -target2=36.86 -target3=35.84 testimg.ppm - +rm ${map} + +pnmcolormap -meanpixel 100 testimg.ppm > ${map} +pnmremap -mapfile=${map} testimg.ppm |\ + pnmpsnr -target1=34.95 -target2=36.77 -target3=35.81 testimg.ppm - +rm ${map} + +pnmcolormap -spreadluminosity 100 testimg.ppm > ${map} +pnmremap -mapfile=${map} testimg.ppm |\ + pnmpsnr -target1=33.71 -target2=32.91 -target3=33.93 testimg.ppm - +rm ${map} + +pnmcolormap -splitcolorct 100 testimg.ppm > ${map} +pnmremap -mapfile=${map} testimg.ppm |\ + pnmpsnr -target1=33.97 -target2=35.34 -target3=34.23 testimg.ppm - +rm ${map} + +pnmcolormap -splitspread 100 testimg.ppm > ${map} +pnmremap -mapfile=${map} testimg.ppm |\ + pnmpsnr -target1=32.98 -target2=35.06 -target3=33.19 testimg.ppm - +rm ${map} + +pnmcolormap 200 testimg.ppm > ${map} +pnmremap -mapfile=${map} testimg.ppm |\ + pnmpsnr -target1=36.14 -target2=36.87 -target3=36.79 testimg.ppm - +rm ${map} + +pnmcolormap 30 testimg.ppm > ${map} +pnmremap -mapfile=${map} testimg.ppm |\ + pnmpsnr -target1=28.53 -target2=31.62 -target3=29.99 testimg.ppm - +rm ${map} diff --git a/test/pnmcrop-blank.ok b/test/pnmcrop-blank.ok new file mode 100644 index 00000000..55103acb --- /dev/null +++ b/test/pnmcrop-blank.ok @@ -0,0 +1,130 @@ +Test 1 +-blank-image=pass +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +-blank-image=minimize +-7 -7 -7 -6 1 1 +0 0 0 0 15 14 +-7 -7 -7 -6 1 1 +-7 -7 -7 -6 1 1 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +-7 -7 -7 -6 1 1 +-blank-image=minimize -top +0 0 -13 0 15 1 +0 0 0 0 15 14 +0 0 -13 0 15 1 +0 0 -13 0 15 1 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 -13 0 15 1 +-blank-image=minimize -bottom +0 0 0 -13 15 1 +0 0 0 0 15 14 +0 0 0 -13 15 1 +0 0 0 -13 15 1 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 -13 15 1 +-blank-image=minimize -left +-14 0 0 0 1 14 +0 0 0 0 15 14 +-14 0 0 0 1 14 +-14 0 0 0 1 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +-14 0 0 0 1 14 +-blank-image=minimize -right +0 -14 0 0 1 14 +0 0 0 0 15 14 +0 -14 0 0 1 14 +0 -14 0 0 1 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 -14 0 0 1 14 +-blank-image=minimize -left -right +-7 -7 0 0 1 14 +0 0 0 0 15 14 +-7 -7 0 0 1 14 +-7 -7 0 0 1 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +-7 -7 0 0 1 14 +-blank-image=maxcrop +-15 -15 -14 -14 15 14 +0 0 0 0 15 14 +-15 -15 -14 -14 15 14 +-15 -15 -14 -14 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +0 0 0 0 15 14 +-15 -15 -14 -14 15 14 +-blank-image=abort +fail1 +fail2 +0 0 0 0 15 14 +0 0 0 0 15 14 +fail3 + +fail1 +fail2 +0 0 0 0 15 14 +0 0 0 0 15 14 +fail3 +Test 2 +-blank-image=maxcrop -top +0 0 -99 0 100 99 +0 0 -99 0 100 99 +0 0 0 0 100 99 +-blank-image=minimize +-50 -49 -49 -49 1 1 +-50 -49 -49 -49 1 1 +0 0 0 0 100 99 +-blank-image=maxcrop +-100 -100 -99 -99 100 99 +-100 -100 -99 -99 100 99 +0 0 0 0 100 99 +-blank-image=maxcrop -top +0 0 -99 0 100 99 +0 0 -99 0 100 99 +0 0 0 0 100 99 +-blank-image=maxcrop -bottom +0 0 0 -99 100 99 +0 0 0 -99 100 99 +0 0 0 0 100 99 +-blank-image=maxcrop -left +-100 0 0 0 100 99 +-100 0 0 0 100 99 +0 0 0 0 100 99 +-blank-image=maxcrop -right +0 -100 0 0 100 99 +0 -100 0 0 100 99 +0 0 0 0 100 99 +-blank-image=maxcrop -top -bottom -right +0 -100 -99 -99 100 99 +0 -100 -99 -99 100 99 +0 0 0 0 100 99 + +fail4 +fail5 +0 0 0 0 100 99 diff --git a/test/pnmcrop-blank.test b/test/pnmcrop-blank.test new file mode 100755 index 00000000..bb26bdc0 --- /dev/null +++ b/test/pnmcrop-blank.test @@ -0,0 +1,55 @@ +#! /bin/sh +# This script tests: pnmcrop +# Also requires: pbmmake ppmmake + +tmpdir=${tmpdir:-/tmp} + +test_pbm=${tmpdir}/test.pbm +test_ppm=${tmpdir}/test.ppm + +echo "Error messages should appear below the line." 1>&2 +echo "--------------------------------------------" 1>&2 + +#Test 1 +echo Test 1 + +( pbmmake -white 15 14; pbmmake -gray 15 14; pbmmake -black 15 14 ) > \ + ${test_pbm} +for type in "-blank-image=pass" \ + "-blank-image=minimize" \ + "-blank-image=minimize -top" \ + "-blank-image=minimize -bottom" \ + "-blank-image=minimize -left" \ + "-blank-image=minimize -right" \ + "-blank-image=minimize -left -right" \ + "-blank-image=maxcrop" \ + "-blank-image=abort" "" + do + echo ${type} + pnmcrop -reportsize ${type} ${test_pbm} || echo "fail1" + pnmcrop -reportsize ${type} -white ${test_pbm} || echo "fail2" + pnmcrop -reportsize ${type} -black ${test_pbm} || echo "fail3" + done + +rm ${test_pbm} + + +#Test 2 + +ppmmake rgb:ff/ff/ff 100 99 > ${test_ppm} +echo Test 2 +for type in "-blank-image=maxcrop -top" \ + "-blank-image=minimize" "-blank-image=maxcrop" \ + "-blank-image=maxcrop -top" \ + "-blank-image=maxcrop -bottom" \ + "-blank-image=maxcrop -left" \ + "-blank-image=maxcrop -right" \ + "-blank-image=maxcrop -top -bottom -right" "" + do + echo ${type} + pnmcrop -reportsize ${type} ${test_ppm} || echo "fail4" + pnmcrop -reportsize ${type} -white ${test_ppm} || echo "fail5" + pnmcrop -reportsize ${type} -black ${test_ppm} || echo "fail6" + done + +rm ${test_ppm} \ No newline at end of file diff --git a/test/pnmcrop1.ok b/test/pnmcrop1.ok new file mode 100644 index 00000000..d979d2db --- /dev/null +++ b/test/pnmcrop1.ok @@ -0,0 +1,82 @@ +Test 1 +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 +file: rose.ppm option: -white +-6 0 0 0 244 161 rgb-255:255/255/255 0.000000 +file: rose.ppm option: -black +0 -11 0 0 239 161 rgb-255:0/0/0 0.000000 +file: rose.ppm option: -sides +-6 0 0 0 244 161 rgb-255:255/255/255 0.000000 +file: rose.ppm option: -top +0 0 0 0 250 161 rgb-255:127/127/127 0.000000 +file: rose.ppm option: -bottom +0 0 0 0 250 161 rgb-255:127/127/127 0.000000 +file: rose.ppm option: -left +0 0 0 0 250 161 rgb-255:127/127/127 0.000000 +file: rose.ppm option: -right +0 0 0 0 250 161 rgb-255:127/127/127 0.000000 +file: rose.ppm option: -top -bottom +0 0 0 0 250 161 rgb-255:127/127/127 0.000000 +file: rose.ppm option: -bottom -bg-corner=bottomright +0 0 0 0 250 161 rgb-255:0/0/0 0.000000 +file: rose.ppm option: -right -bg-corner=bottomright +0 -11 0 0 239 161 rgb-255:0/0/0 0.000000 +file: rose.ppm option: -bg-color=white +-6 0 0 0 244 161 rgb-255:255/255/255 0.000000 +file: rose.ppm option: -bg-color=black +0 -11 0 0 239 161 rgb-255:0/0/0 0.000000 +file: rose.ppm option: -bg-color=red +0 0 0 0 250 161 rgb-255:255/0/0 0.000000 +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 +Expected failure: -reportfull -reportsize 1 +Expected failure: -reportfull -borderfile=testgrid.pbm 1 +Expected failure: -reportsize -borderfile=testgrid.pbm 1 +Expected failure: -black -white 1 +Expected failure: -black -sides 1 +Expected failure: -white -bg-color=red 1 +Expected failure: -white -bg-corner=topleft 1 +Expected failure: -white -bg-corner=top 1 +Expected failure: -blank-image=pasturize 1 +Expected failure: -bg-color=black -closeness=-1 1 +Expected failure: -bg-color=black -closeness=101 1 diff --git a/test/pnmcrop1.test b/test/pnmcrop1.test new file mode 100755 index 00000000..3c86efd7 --- /dev/null +++ b/test/pnmcrop1.test @@ -0,0 +1,84 @@ + #! /bin/sh +# This script tests: pnmcrop +# Also requires: pnmpad pnmmargin pamcut + +tmpdir=${tmpdir:-/tmp} + +test_pbm=${tmpdir}/maze.pbm +test_ppm=${tmpdir}/rose.ppm + +pnmmargin -white 7 maze.pbm | pnmpad -black -bottom=2 > ${test_pbm} +pnmmargin -white 6 testimg.ppm | pnmpad -black -right=11 > ${test_ppm} + +#Test 1 +echo Test 1 + +for input_file in ${test_pbm} ${test_ppm} + do + 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 "file: ${bfile} option: ${option}" + pnmcrop -reportfull ${option} ${input_file} || echo fail + done + done + +#Test 2 +echo "Test 2. Should print 0 six times" + +out_pnm=${tmpdir}/out.pnm + +for input_file in ${test_pbm} ${test_ppm} + do + bfile=`basename ${input_file}` + for option in "" "-white" "-top" + do + echo file: ${bfile} option: ${option} + # Normal crop operation + 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) }' ` | \ + cmp -s - ${out_pnm} + echo $? + rm ${out_pnm} + done + done + +rm ${test_pbm} ${test_ppm} + +# Test 3 +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 + +for option in "-reportfull -reportsize" \ + "-reportfull -borderfile=testgrid.pbm" \ + "-reportsize -borderfile=testgrid.pbm" \ + "-black -white" \ + "-black -sides" \ + "-white -bg-color=red" \ + "-white -bg-corner=topleft" \ + "-white -bg-corner=top" \ + "-blank-image=pasturize" \ + "-bg-color=black -closeness=-1" \ + "-bg-color=black -closeness=101" + do + pnmcrop -reportfull ${option} testgrid.pbm > ${test_out} || \ + printf "Expected failure: %s" "${option}" + test -s ${test_out}; echo " "$? + rm ${test_out} + done diff --git a/test/pnmcrop2.ok b/test/pnmcrop2.ok new file mode 100644 index 00000000..4eff830d --- /dev/null +++ b/test/pnmcrop2.ok @@ -0,0 +1,29 @@ +Test 1 + +0 0 0 0 5 5 rgb-200:2/2/2 0.000000 +-sides +0 0 0 0 5 5 rgb-200:6/6/6 0.000000 +Test 2 +topleft +0 0 0 0 5 5 rgb-200:0/0/0 0.000000 +topright +0 0 0 0 5 5 rgb-200:4/4/4 0.000000 +bottomleft +0 0 0 0 5 5 rgb-200:8/8/8 0.000000 +bottomright +0 0 0 0 5 5 rgb-200:15/15/15 0.000000 +Test 3 +0 +0 0 0 0 5 5 rgb-200:0/0/0 0.000000 +1 +0 0 0 0 5 5 rgb-200:0/0/0 1.000000 +2 +0 0 -1 0 5 4 rgb-200:0/0/0 2.000000 +3 +-1 0 -1 0 4 4 rgb-200:0/0/0 3.000000 +4 +-1 0 -1 0 4 4 rgb-200:0/0/0 4.000000 +5 +-1 -1 -1 -1 3 3 rgb-200:0/0/0 5.000000 +6 +-1 -1 -1 -1 3 3 rgb-200:0/0/0 6.000000 diff --git a/test/pnmcrop2.test b/test/pnmcrop2.test new file mode 100755 index 00000000..3d402a57 --- /dev/null +++ b/test/pnmcrop2.test @@ -0,0 +1,55 @@ +#! /bin/sh +# This script tests: pnmcrop +# Also requires: + +tmpdir=${tmpdir:-/tmp} +test_pgm=${tmpdir}/test.pgm + +cat > ${test_pgm} << EOF +P2 +5 5 +200 +0 1 2 3 4 +5 199 199 199 9 +6 199 199 199 10 +7 199 199 199 11 +8 12 13 14 15 +EOF + +# Test 1 +# Test color detection; none of the sides are cropped + +echo Test 1 + +for option in "" "-sides" + do + echo ${option} + pnmcrop -reportfull ${option} ${test_pgm} || echo fail1 + done + +# Test 2 +# Test color detection; none of the sides are cropped +echo Test 2 + +for corner in topleft topright bottomleft bottomright + do + echo ${corner} + pnmcrop -reportfull -bg-corner=${corner} ${test_pgm} || echo fail2 + done + +# Test 3 +# Left edge is cropped at closeness 2% and above +# Top edge is cropped at closeness 3% and above +# All edges are cropped at closeness 5% and above + +echo Test 3 + +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} \ + || echo fail3 + done + +rm ${test_pgm} + diff --git a/test/pnmcrop3.ok b/test/pnmcrop3.ok new file mode 100644 index 00000000..5a86139c --- /dev/null +++ b/test/pnmcrop3.ok @@ -0,0 +1,90 @@ +Test 1 +test.pbm +-left +-12 0 0 0 15 24 +-right +0 -2 0 0 25 24 +-top +0 0 -3 0 27 21 +-bottom +0 0 0 -6 27 18 +-left -right +-12 -2 0 0 13 24 +-left -bottom +-12 0 0 -6 15 18 +-right -bottom +0 -2 0 -6 25 18 +test.ppm +-left +-21 0 0 0 236 161 +-right +0 -9 0 0 248 161 +-top +0 0 -11 0 257 150 +-bottom +0 0 0 -1 257 160 +-left -right +-21 -9 0 0 227 161 +-left -bottom +-21 0 0 -1 236 160 +-right -bottom +0 -9 0 -1 248 160 +Test 2 +test.pbm +-12 -2 -3 -6 13 15 +-11 -1 -2 -5 15 17 +-10 0 -1 -4 17 19 +-9 +1 0 -3 19 21 +-8 +2 +1 -2 21 23 +-7 +3 +2 -1 23 25 +test.ppm +-21 -9 -11 -1 227 149 +-20 -8 -10 0 229 151 +-19 -7 -9 +1 231 153 +-18 -6 -8 +2 233 155 +-17 -5 -7 +3 235 157 +-16 -4 -6 +4 237 159 +Test 3 +13 15 +P2 +13 15 +255 +128 128 128 128 128 128 128 128 128 128 128 128 128 +128 128 128 128 128 128 128 128 128 128 128 128 128 +128 128 128 128 128 128 128 128 128 128 128 128 128 +128 128 128 128 128 128 128 128 128 128 128 128 128 +128 128 128 128 128 128 128 128 128 128 128 128 128 +128 128 128 128 128 128 128 128 128 128 128 128 128 +128 128 128 128 128 128 128 128 128 128 128 128 128 +128 128 128 128 128 128 128 128 128 128 128 128 128 +128 128 128 128 128 128 128 128 128 128 128 128 128 +128 128 128 128 128 128 128 128 128 128 128 128 128 +128 128 128 128 128 128 128 128 128 128 128 128 128 +128 128 128 128 128 128 128 128 128 128 128 128 128 +128 128 128 128 128 128 128 128 128 128 128 128 128 +128 128 128 128 128 128 128 128 128 128 128 128 128 +128 128 128 128 128 128 128 128 128 128 128 128 128 +13 15 +0 0 0 0 13 15 +13 15 +P1 +13 15 +1111111111111 +1110101010101 +1111111111111 +1110101010101 +1111111111111 +1110101010101 +1111111111111 +1110101010101 +1111111111111 +1110101010101 +1111111111111 +1110101010101 +1111111111111 +1110101010101 +1111111111111 +-3 -1 -1 -1 9 13 +544280424 101484 +Expected failure 1 1 +Expected failure 2 1 diff --git a/test/pnmcrop3.test b/test/pnmcrop3.test new file mode 100755 index 00000000..1e8da345 --- /dev/null +++ b/test/pnmcrop3.test @@ -0,0 +1,80 @@ +#! /bin/sh +# This script tests: pnmcrop +# Also requires: pnmpad pamfile pgmmake + +tmpdir=${tmpdir:-/tmp} + +test_pbm=${tmpdir}/test.pbm +test_ppm=${tmpdir}/test.ppm +border_pbm=${tmpdir}/border.pbm +border_ppm=${tmpdir}/border.ppm +gray_pgm=${tmpdir}/gray.pgm + +pnmpad -top=3 -bottom=5 -left=11 -right=2 testgrid.pbm > ${test_pbm} +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} + +# Test 1 +echo Test 1 + +for input_file in ${test_pbm} ${test_ppm} + do + echo `basename ${input_file}` + for option in "-left" "-right" "-top" "-bottom" \ + "-left -right" "-left -bottom" "-right -bottom" + do + echo ${option} + pnmcrop -reportsize ${option} ${input_file} || echo fail1 + done + done + +# Test 2 +echo Test 2 + +for input_file in ${test_pbm} ${test_ppm} + do + echo `basename ${input_file}` + 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 + done + +# Test 3 +echo Test 3 + +pnmcrop -borderfile=${border_pbm} ${gray_pgm} | pamfile -size +pnmcrop -borderfile=${border_pbm} ${gray_pgm} -plain + +pnmcrop -borderfile=${test_pbm} ${test_pbm} | pamfile -size +pnmcrop -borderfile=${test_pbm} ${test_pbm} | pnmcrop -black -reportsize + +pnmcrop -borderfile=${border_pbm} ${test_pbm} | pamfile -size +pnmcrop -borderfile=${border_pbm} ${test_pbm} -plain +pnmcrop -borderfile=${border_pbm} ${test_pbm} | pnmcrop -black -reportsize + +pnmcrop -borderfile=${border_ppm} ${test_ppm} | cksum + +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} > ${test_out} || \ + printf "Expected failure 1"; + test -s ${test_out}; echo " "$? + rm ${test_out} + +pnmcrop -borderfile=${border_pbm} ${test_ppm} > ${test_out} || \ + printf "Expected failure 2"; + test -s ${test_out}; echo " "$? + rm ${test_out} + +rm ${test_pbm} ${test_ppm} ${border_pbm} ${border_ppm} ${gray_pgm} 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-reportonly.ok b/test/pnmpad-reportonly.ok new file mode 100644 index 00000000..e7d0a0d1 --- /dev/null +++ b/test/pnmpad-reportonly.ok @@ -0,0 +1,67 @@ +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 diff --git a/test/pnmpad-reportonly.test b/test/pnmpad-reportonly.test new file mode 100755 index 00000000..ccd79e69 --- /dev/null +++ b/test/pnmpad-reportonly.test @@ -0,0 +1,129 @@ +#! /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 + + +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 3469f836..7042f86c 100644 --- a/test/pnmpsnr.ok +++ b/test/pnmpsnr.ok @@ -1,7 +1,14 @@ +Test 1 0.00 inf 1000.00 match +Test 2 300.00 300.00 300.00 match match +Test Invalid +Expected failure 1 1 +Expected failure 2 1 +Expected failure 3 1 +Expected failure 4 1 diff --git a/test/pnmpsnr.test b/test/pnmpsnr.test index f24c08aa..ae6ba3cc 100755 --- a/test/pnmpsnr.test +++ b/test/pnmpsnr.test @@ -1,23 +1,58 @@ -#! /bin/bash +#! /bin/sh # This script tests: pnmpsnr # Also requires: pbmmake tmpdir=${tmpdir:-/tmp} - w_pbm=${tmpdir}/w.pbm b_pbm=${tmpdir}/b.pbm pbmmake -w 10 10 > ${w_pbm} pbmmake -b 10 10 > ${b_pbm} +echo "Test 1" + pnmpsnr ${w_pbm} ${b_pbm} -machine pnmpsnr ${w_pbm} ${w_pbm} -machine pnmpsnr ${w_pbm} ${w_pbm} -machine -max=1000 pnmpsnr ${w_pbm} ${w_pbm} -target=1000 + +echo "Test 2" + pnmpsnr testimg.ppm testimg.ppm -machine -max=300 pnmpsnr testimg.ppm testimg.ppm -target=1000 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} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pnmpsnr ${b_pbm} > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pnmpsnr ${b_pbm} ${w_pbm} -target1=100 > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pnmpsnr -machine > ${test_out} || \ + printf "Expected failure 4" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + rm ${b_pbm} ${w_pbm} diff --git a/test/pnmquant.ok b/test/pnmquant.ok new file mode 100644 index 00000000..407d42a3 --- /dev/null +++ b/test/pnmquant.ok @@ -0,0 +1,18 @@ +Test 1 +1 1 +1 1 +1 1 +1 1 +1 1 +1 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 diff --git a/test/pnmquant.test b/test/pnmquant.test new file mode 100755 index 00000000..cbe69f5c --- /dev/null +++ b/test/pnmquant.test @@ -0,0 +1,82 @@ +#! /bin/sh +# This script tests: pnmquant +# Also requires: ppmhist + +echo "Test 1" + +# Count colors in output image. + +pnmquant 256 testimg.ppm | ppmhist | \ + 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)}' + +pnmquant -spreadbrightness 256 testimg.ppm | ppmhist | \ + 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)}' + +pnmquant -floyd -randomseed=0 128 testimg.ppm | ppmhist | \ + 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)}' + +pnmquant 16 -meancolor testimg.ppm | ppmhist | \ + awk 'NR==1 {print ($2 <= 16) , ($2 > 16 * 0.9)}' + + +pnmquant 2 testgrid.pbm | ppmhist | \ + awk 'NR==1 {print ($2 <= 2) , ($2 == 2) }' + +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 + +tmpdir=${tmpdir:-/tmp} +test_out=${tmpdir}/test_out + +pnmquant 0 testimg.ppm > ${test_out} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pnmquant testimg.ppm > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pnmquant 10.5 testimg.ppm > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pnmquant -center -meancolor 16 testimg.ppm > ${test_out} || \ + printf "Expected failure 4" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pnmquant -center -meanpixel 16 testimg.ppm > ${test_out} || \ + printf "Expected failure 5" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pnmquant -meancolor -meanpixel 16 testimg.ppm > ${test_out} || \ + printf "Expected failure 6" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pnmquant -spreadbrightness -spreadluminosity 16 testimg.ppm > ${test_out} || \ + printf "Expected failure 7" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pnmquant -randomseed 1 -norandom 10 testimg.ppm > ${test_out} || \ + printf "Expected failure 8" + test -s ${test_out}; echo " "$? + rm -f ${test_out} diff --git a/test/pnmquantall.ok b/test/pnmquantall.ok index 172eb0aa..5885d370 100644 --- a/test/pnmquantall.ok +++ b/test/pnmquantall.ok @@ -1,5 +1,9 @@ -got color map 2373957371 33838 3892560659 33838 1383839923 33838 1 +Expected failure 1 +Expected failure 1.rm +Expected failure 2 +Expected failure 2.rm +Expected failure 3 diff --git a/test/pnmquantall.test b/test/pnmquantall.test index cd01bb8d..f047e856 100755 --- a/test/pnmquantall.test +++ b/test/pnmquantall.test @@ -1,27 +1,47 @@ -#! /bin/bash +#! /bin/sh # This script tests: pnmquantall -# Also requires: ppmtorgb3 pgmhist +# 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} +pnmquantall 20 ${rose_red} ${rose_grn} ${rose_blu} -for i in ${test_red} ${test_grn} ${test_blu} +for i in ${rose_red} ${rose_grn} ${rose_blu} do cat $i | cksum done # Should print 1 -pnmcat ${test_red} ${test_grn} ${test_blu} -tb | \ +pamcat ${rose_red} ${rose_grn} ${rose_blu} -tb | \ pgmhist -m | awk '$2>0 {s++}; END { print (s<=20) }' -rm ${test_red} ${test_grn} ${test_blu} ${test_ppm} \ No newline at end of file + +tmpdir=${tmpdir:-/tmp} +rose_out=${tmpdir}/rose_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 + +pnmquantall -ext xx 0 ${rose_red} ${rose_grn} ${rose_blu} || \ + echo "Expected failure 1" +rm ${rose_red}xx ${rose_grn}xx ${rose_blu}xx || \ + echo "Expected failure 1.rm" +pnmquantall -ext xx 1 ${rose_red} ${rose_grn} ${rose_blu} || \ + echo "Expected failure 2" +rm ${rose_red}xx ${rose_grn}xx ${rose_blu}xx || \ + echo "Expected failure 2.rm" +pnmquantall -ext xx 2 || \ + echo "Expected failure 3" + +rm ${rose_red} ${rose_grn} ${rose_blu} ${rose_ppm} diff --git a/test/pnmremap1.ok b/test/pnmremap1.ok index 07954684..23a9dddd 100644 --- a/test/pnmremap1.ok +++ b/test/pnmremap1.ok @@ -1 +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 diff --git a/test/pnmremap1.test b/test/pnmremap1.test index d7c5189c..8626c50f 100755 --- a/test/pnmremap1.test +++ b/test/pnmremap1.test @@ -1,8 +1,7 @@ -#! /bin/bash +#! /bin/sh # This script tests: pnmremap # Also requires: pamseq pamtopnm - tmpdir=${tmpdir:-/tmp} palette=${tmpdir}/palette #palette255=${tmpdir}/palette255 @@ -24,3 +23,42 @@ pnmremap -mapfile=${palette} -floyd -norandom \ # testimg.ppm | cksum rm ${palette} # ${palette255} + +echo 1>&2 +echo "Invalid command-line arguments." 1>&2 +echo "Error messages should appear below the line." 1>&2 +echo "-----------------------------------------------------------" 1>&2 + +tmpdir=${tmpdir:-/tmp} +test_out=${tmpdir}/test_out + +pnmremap -mapfile=/dev/null testimg.ppm > ${test_out} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pnmremap -mapfile=/dev/zero testimg.ppm > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pnmremap testimg.ppm > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pnmremap -fs -nofs testimg.ppm > ${test_out} || \ + printf "Expected failure 4" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pnmremap -mapfile=testgrid.pbm -missingcolor=rgb:00/ff/00 testimg.ppm \ + > ${test_out} || \ + printf "Expected failure 5" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pnmremap -mapfile=testgrid.pbm -firstisdefault testimg.ppm > ${test_out} || \ + printf "Expected failure 6" + test -s ${test_out}; echo " "$? + 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 4a29e0dc..d28fafa3 100644 --- a/test/pnmtile.ok +++ b/test/pnmtile.ok @@ -1,2 +1,6 @@ 4228632379 259 -0 0 : 0 +0 0 0 : 0 +Expected failure 1 1 +Expected failure 2 1 +Expected failure 3 1 +Expected failure 4 1 diff --git a/test/pnmtile.test b/test/pnmtile.test index e297da66..b72ef946 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,15 +8,42 @@ 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 + +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} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pnmtile 100 0 testgrid.pbm > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pnmtile 0 100 testgrid.pbm > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pnmtile 100 100 100 testgrid.pbm > ${test_out} || \ + printf "Expected failure 4" + test -s ${test_out}; echo " "$? + rm -f ${test_out} 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 376e71d3..3895dbd0 100644 --- a/test/ppmbrighten.ok +++ b/test/ppmbrighten.ok @@ -1,3 +1,11 @@ +Test 1: Should print 1969633344 101484 1969633344 101484 -3688219243 101484 +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 diff --git a/test/ppmbrighten.test b/test/ppmbrighten.test index 46c5cab5..e346d1d0 100755 --- a/test/ppmbrighten.test +++ b/test/ppmbrighten.test @@ -1,12 +1,41 @@ -#! /bin/bash +#! /bin/sh # This script tests: ppmbrighten -# Also requires: +# Also requires: pnmnorm pambrighten pamsumm # Failure message ## Ppmbrighten is sensitive to subtle differences in floating point math. ## If this test fails, please run the program and visually examine ## the output. +echo "Test 1: Should print 1969633344 101484" + ppmbrighten -v 100 testimg.ppm | cksum -ppmbrighten -v 100 -normalize testimg.ppm | cksum + +echo "Test 2: Should print 295150171 101484" + ppmbrighten -s 100 -v -50 testimg.ppm | cksum + +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" + +tmpdir=${tmpdir:-/tmp} +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 $? + +rm ${output_ppm} 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 new file mode 100644 index 00000000..c8edc5dd --- /dev/null +++ b/test/ppmforge-parameters.ok @@ -0,0 +1,14 @@ +Test 1: Should print 256 256 +256 256 +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 6 1 +Expected failure 7 1 diff --git a/test/ppmforge-parameters.test b/test/ppmforge-parameters.test new file mode 100755 index 00000000..e5822673 --- /dev/null +++ b/test/ppmforge-parameters.test @@ -0,0 +1,65 @@ +#! /bin/sh +# This script tests: ppmforge +# Also requires: pamfile + +echo "Test 1: Should print 256 256" + +# Default size is 256 256 +ppmforge -night | pamfile -size + +echo "Test 2: Should print 40 30" + +# Width is adjusted if not even +# becomes 40 in this case +ppmforge -night -width=39 -height=30 | pamfile -size + +echo "Test 3: Should print 90 90" + +# Width is adjusted if smaller than height +# brought up to 90 in this case +ppmforge -night -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} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmforge -dimension=10 > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmforge -dimension=-1 > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmforge -clouds -mesh=1.99 > ${test_out} || \ + printf "Expected failure 4" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmforge -clouds -power=0 > ${test_out} || \ + printf "Expected failure 5" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmforge -ice=-1 > ${test_out} || \ + printf "Expected failure 6" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmforge -glaciers=-1 > ${test_out} || \ + printf "Expected failure 7" + test -s ${test_out}; echo " "$? + rm -f ${test_out} diff --git a/test/ppmforge.ok b/test/ppmforge.ok new file mode 100644 index 00000000..2f3f9501 --- /dev/null +++ b/test/ppmforge.ok @@ -0,0 +1,10 @@ +Test 1. Should print: 547829788 196623 (Mersenne Twister) +547829788 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..75de7cf7 100755 --- a/test/ppmforge.test +++ b/test/ppmforge.test @@ -1,9 +1,52 @@ -#! /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)" +# 3634219838 196623 (Glibc rand() ) +# 3262664440 196623 (MAC OS rand() ) 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 30 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 1 -power 0.75 > ${test_ppm} +ppmforge -cloud -seed 1 -power 0.74 | \ + pnmpsnr -rgb -target1=41.15 -target2=41.15 -target3=999 - ${test_ppm} + +rm ${test_ppm} + +echo "Test 3." +ppmforge -cloud -seed 1 -dimension 2.15 > ${test_ppm} +ppmforge -cloud -seed 1 -dimension 2.175 | \ + pnmpsnr -rgb -target1=43.39 -target2=43.39 -target3=999 - ${test_ppm} + + # Note that there should be no difference for the target3: blue. + + + +rm ${test_ppm} + +echo "Test 4." +ppmforge -seed 1 -stars 0 -ice 0.01 -power 1.18 -hour 10 > ${test_ppm} +ppmforge -seed 1 -stars 0 -ice 0.01 -power 1.22 -hour 10 | \ + pnmpsnr -target1=27.89 -target2=24.25 -target3=37.87 - ${test_ppm} + +rm ${test_ppm} + +echo "Test 5." +ppmforge -seed 1 -stars 0 -ice 0.01 \ + -inclination 9 -hour 12 -power 200 > ${test_ppm} +ppmforge -seed 1 -stars 0 -ice 0.01 \ + -inclination 10 -hour 12 -power 200 | \ + pnmpsnr -target1=46.07 -target2=52.00 -target3=67.77 - ${test_ppm} + +rm ${test_ppm} diff --git a/test/ppmhist.ok b/test/ppmhist.ok index f2ba637b..468bd317 100644 --- a/test/ppmhist.ok +++ b/test/ppmhist.ok @@ -1,3 +1,4 @@ +Test 1 0 0 0 0 2 1 1 1 1 2 2 2 2 2 2 @@ -7,6 +8,7 @@ 6 6 6 6 2 8 8 8 8 2 3081591280 60957 +Test 2 Summary: 1 colors: 1 black, 0 white, 0 gray, 0 color Summary: 1 colors: 0 black, 1 white, 0 gray, 0 color Summary: 2 colors: 1 black, 1 white, 0 gray, 0 color @@ -17,3 +19,7 @@ Summary: 6 colors: 0 black, 0 white, 0 gray, 6 color 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 diff --git a/test/ppmhist.test b/test/ppmhist.test index 27d31562..8c2eedbc 100755 --- a/test/ppmhist.test +++ b/test/ppmhist.test @@ -1,12 +1,16 @@ -#! /bin/bash +#! /bin/sh # This script tests: ppmhist # Also requires: pgmramp pamtopnm pbmmake pamseq ppmpat +echo "Test 1" + pgmramp -maxval=8 -lr 8 2 | ppmhist -sort=rgb -noheader ppmhist -map -sort=rgb -noheader testimg.ppm | pamtopnm | cksum # Test summary header +echo "Test 2" + pbmmake -b 2 1 | ppmhist | head -n1 pbmmake -w 2 1 | ppmhist | head -n1 pbmmake -g 2 1 | ppmhist | head -n1 @@ -19,4 +23,29 @@ ppmpat -madras --color=rgb:32/0d/b7,rgb:31/58/a3,rgb:e9/5e/d4 25 25 | \ ppmpat -madras --color=rgb:00/00/00,rgb:31/58/a3,rgb:e9/5e/d4 25 25 | \ ppmhist | head -n1 ppmpat -madras --color=rgb:00/00/00,rgb:31/58/a3,rgb:ff/ff/ff 25 25 | \ - ppmhist | head -n1 \ No newline at end of file + ppmhist | head -n1 + +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 + +ppmhist -hexcolor -float testimg.ppm > ${test_out} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmhist -hexcolor -map testimg.ppm > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmhist -float -map testimg.ppm > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} diff --git a/test/ppmmake.ok b/test/ppmmake.ok index 0e871732..6d559c8d 100644 --- a/test/ppmmake.ok +++ b/test/ppmmake.ok @@ -1,2 +1,15 @@ +Test 1 2477651508 15012 +4294967295 0 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 diff --git a/test/ppmmake.test b/test/ppmmake.test index 879a367e..30eb596a 100755 --- a/test/ppmmake.test +++ b/test/ppmmake.test @@ -1,7 +1,69 @@ -#! /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 red 50 50 | cksum + +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 + +ppmmake rgb:gg/00/00 2 2 > ${test_out} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmmake rgb:ff/ff/00 2 > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmmake rgbi:1.1/0/0 2 2 > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmmake rgbi:1.0/.5 2 2 > ${test_out} || \ + printf "Expected failure 4" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmmake rainbow 2 2 > ${test_out} || \ + printf "Expected failure 5" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmmake 2 2 > ${test_out} || \ + printf "Expected failure 6" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmmake blue -maxval=0 2 2 > ${test_out} || \ + printf "Expected failure 7" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmmake blue -maxval=-1 2 2 > ${test_out} || \ + printf "Expected failure 8" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmmake blue -maxval=65536 2 2 > ${test_out} || \ + printf "Expected failure 9" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +RGBDEF=/dev/null ppmmake red 2 2 > ${test_out} || \ + printf "Expected failure 10" + test -s ${test_out}; echo " "$? + rm -f ${test_out} 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 100755 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..b1b78d94 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,22 @@ # 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 +# 2219119109 36015 (glibc rand()) +# 3606254242 36015 (MAC OS rand()) + 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 +# 3436846137 16813 (glibc) +# 3615722579 16813 (MAC OS rand()) + 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 +# 908097729 16813 (glibc rand()) +# 1756684515 16813 (MAC OS rand()) + 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 bb940aee..f2b355a9 100644 --- a/test/ppmpat.ok +++ b/test/ppmpat.ok @@ -1,6 +1,47 @@ +Test 1. Should print: 4008533639 781 4008533639 781 +Test 2. Should print: 738714211 781 +738714211 781 +Test 3. Should print: 3805937800 9613 3805937800 9613 +Test 4. Should print: 1586690955 9613 +1586690955 9613 +Test 5. Should print: 2698433077 1549 2698433077 1549 +Test 6. Should print: 1526189097 1549 +1526189097 1549 +Test 7. Should print: 3705929501 781 3705929501 781 +Test 8. Should print: 1996587666 781 +1996587666 781 +Test 9. Should print: 3057513592 661 3057513592 661 +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 diff --git a/test/ppmpat.test b/test/ppmpat.test index cd00c0f1..ced2e64a 100755 --- a/test/ppmpat.test +++ b/test/ppmpat.test @@ -1,21 +1,189 @@ -#! /bin/bash +#! /bin/sh # This script tests: ppmpat # Also requires: -# Test 1. Should print: 4008533639 781 -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 -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 -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. 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 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 10. Should print: 1861389287 661" ppmpat -argyle2 --color=rgb:00/00/00,rgb:ff/80/80,rgb:e0/e0/e0 12 18 | cksum + +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} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmpat -madras -tartan 10 10 > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmpat -poles -squig 10 10 > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmpat -camo -anticamo 10 10 > ${test_out} || \ + printf "Expected failure 4" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmpat -argyle1 -argyle2 10 10 > ${test_out} || \ + printf "Expected failure 5" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmpat 10 10 > ${test_out} || \ + printf "Expected failure 6" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmpat -g2 10 > ${test_out} || \ + printf "Expected failure 7" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmpat -g2 10 10 10 > ${test_out} || \ + printf "Expected failure 8" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmpat -g2 10 > ${test_out} || \ + printf "Expected failure 9" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +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} || \ + printf "Expected failure 10" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmpat -argyle1 ${clist1} 10 10 > ${test_out} || \ + printf "Expected failure 11" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmpat -gingham2 ${clist3} 10 10 > ${test_out} || \ + printf "Expected failure 12" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmpat -argyle1 ${clist3} 10 10 > ${test_out} || \ + printf "Expected failure 13" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# These require exactly 3 colors +ppmpat -gingham3 ${clist2} 10 10 > ${test_out} || \ + printf "Expected failure 14" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmpat -argyle2 ${clist2} 10 10 > ${test_out} || \ + printf "Expected failure 15" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmpat -madras ${clist2} 10 10 > ${test_out} || \ + printf "Expected failure 16" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmpat -tartan ${clist2} 10 10 > ${test_out} || \ + printf "Expected failure 17" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmpat -gingham3 ${clist4} 10 10 > ${test_out} || \ + printf "Expected failure 18" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmpat -argyle2 ${clist4} 10 10 > ${test_out} || \ + printf "Expected failure 19" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmpat -madras ${clist4} 10 10 > ${test_out} || \ + printf "Expected failure 20" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmpat -tartan ${clist4} 10 10 > ${test_out} || \ + printf "Expected failure 21" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# These require at least 3 colors +ppmpat -squig ${clist2} 10 10 > ${test_out} || \ + printf "Expected failure 22" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmpat -camo ${clist2} 10 10 > ${test_out} || \ + printf "Expected failure 23" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmpat -anticamo ${clist2} 10 10 > ${test_out} || \ + printf "Expected failure 24" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# The squig pattern has an aspect ratio restriction +ppmpat -squig ${clist3} 10 250 > ${test_out} || \ + printf "Expected failure 25" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmpat -squig ${clist3} 500 20 > ${test_out} || \ + printf "Expected failure 26" + test -s ${test_out}; echo " "$? + rm -f ${test_out} 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.ok b/test/ppmrough.ok new file mode 100755 index 00000000..83643849 --- /dev/null +++ b/test/ppmrough.ok @@ -0,0 +1 @@ +378403602 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..b10ba941 100755 --- a/test/ppmrough.test +++ b/test/ppmrough.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: ppmrough # Also requires: diff --git a/test/ppmshift.ok b/test/ppmshift.ok new file mode 100755 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 100755 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..46acda60 --- /dev/null +++ b/test/ppmtoapplevol.ok @@ -0,0 +1,6 @@ +Test: should print 1518149010 3065 +1518149010 3065 +Test Invalid +Expected failure 1 1 +Expected failure 2 1 +Expected failure 3 1 diff --git a/test/ppmtoapplevol.test b/test/ppmtoapplevol.test new file mode 100755 index 00000000..4964ede8 --- /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 " "$? + rm -f ${test_out} + +pbmmake 10 13 | ppmtoapplevol > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pbmmake 256 12 | ppmtoapplevol > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + 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/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 24756d1e..790a19cb 100644 --- a/test/ppmwheel.ok +++ b/test/ppmwheel.ok @@ -1,2 +1,9 @@ +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 5 1 diff --git a/test/ppmwheel.test b/test/ppmwheel.test index f528e209..c6583f97 100755 --- a/test/ppmwheel.test +++ b/test/ppmwheel.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: ppmwheel # Also requires: @@ -6,6 +6,8 @@ # For values 6 and above, x86(-32) and x86-64 produce different output. # SSE floating-point math is the probable cause. +echo "Test 1." + for i in 4 5 do ppmwheel $i | cksum @@ -108,3 +110,38 @@ done # 98: 4086203619 28825 1961862620 28825 # 99: 3656777902 29416 2475351252 29416 # 100: 2246720411 30015 4055518595 30015 + +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 + +ppmwheel 10 -huevalue -huesaturation > ${test_out} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmwheel 0 > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmwheel 3 > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmwheel > ${test_out} || \ + printf "Expected failure 4" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +ppmwheel 10 10 > ${test_out} || \ + printf "Expected failure 5" + test -s ${test_out}; echo " "$? + rm -f ${test_out} diff --git a/test/ps-alt-roundtrip.ok b/test/ps-alt-roundtrip.ok index 1cd73f75..a23005f9 100644 --- a/test/ps-alt-roundtrip.ok +++ b/test/ps-alt-roundtrip.ok @@ -1,3 +1,4 @@ +Test 1. Should print: 281226646 481 2425386270 41 -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 d90c4ddb..bdecaffd 100755 --- a/test/ps-alt-roundtrip.test +++ b/test/ps-alt-roundtrip.test @@ -1,27 +1,32 @@ -#! /bin/bash -# This script tests: pbmtoepsi pbmtopsg3 pbmtolps psidtopgm pstopnm +#! /bin/sh +# This script tests: pbmtoepsi pbmtopsg3 psidtopgm pstopnm # Also requires: gs pnmcrop # This script is for testing alternative (or minor) utilities that # read/write Postscript and encapsulated Postscript: -# pbmtoepsi, pbmtopsg3, pbmtolps and psidtopgm. +# pbmtoepsi, pbmtopsg3 and psidtopgm. # # We keep these tests separate from those for pnmtops and pstopnm # which are far more popular. # -# pbmtopsg3 and pbmtolps produce output that require pstopnm for decoding. +# pbmtopsg3 produces output that requires pstopnm for decoding. +# +# We used to test pbmtolps here, but moved it out when gs changed its +# rendering formula. # # Failure message ## If ps-roundtrip.test succeeds and this test fails, it is most likely ## a problem with one of the alternate Postscipt utilities: -## pbmtoepsi, pbmtopsg3, pbmtolps or psidtopgm. +## pbmtoepsi, pbmtopsg3, or psidtopgm. ## If both tests fail it indicates a problem with pstopnm or gs. # 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 \ @@ -33,23 +38,12 @@ pstopnm -xborder=0 -yborder=0 -llx=0 -lly=-16 -urx=14 \ rm ${testgrid1_ps} -# Test 2. Should print: 2425386270 41 -testgrid2_ps=${tmpdir}/testgrid2.ps - -pbmtolps -dpi 72 testgrid.pbm \ - > ${testgrid2_ps} && \ -pstopnm -xborder=0 -yborder=0 -dpi=72 -stdout \ - -quiet ${testgrid2_ps} -pbm | \ - pnmcrop | cksum - -rm ${testgrid2_ps} - -# Test 3. 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 de1105f0..9fc24ddb 100755 --- a/test/ps-flate-roundtrip.test +++ b/test/ps-flate-roundtrip.test @@ -1,11 +1,11 @@ -#! /bin/bash +#! /bin/sh # This script tests: pnmtops pstopnm # Also requires: pamtopnm gs zlib # This script tests the optional flate (zlib) compression feature of # pstopnm. # Flate compression allows you to make smaller output (.ps) files: -# it is useful, but not essential. Flate compression is not neccessary for +# it is useful, but not essential. Flate compression is not necessary for # printing pages with postscript printers - which is why many people need # pnmtops on their systems. @@ -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..faa7601f --- /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 1 +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 +------------------------------ +Should print: Expected failure N 0 +Expected failure 9 0 +Expected failure 10 0 +Expected failure 11 0 +Expected failure 12 0 diff --git a/test/qoi-roundtrip.test b/test/qoi-roundtrip.test new file mode 100755 index 00000000..f758abcc --- /dev/null +++ b/test/qoi-roundtrip.test @@ -0,0 +1,254 @@ +#! /bin/bash +# 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 1" + +pamseq -tupletype="void" 1 1 | pamtoqoi > \ + ${test_out} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + 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 " "$? + 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 " "$? + 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 " "$? + 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 " "$? + 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 " "$? + 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 " "$? + 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 " "$? + rm -f ${test_out} + +echo "------------------------------" +echo "Should print: Expected failure N 0" + +( 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 " "$? + rm -f ${test_out} + +head -c $(( ${maze_qoi_size} - 1 )) ${maze_qoi} | qoitopam > \ + ${test_out} || \ + printf "Expected failure 10" + test -s ${test_out}; echo " "$? + 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 " "$? + rm -f ${test_out} + +( cat ${maze_qoi}; printf '1' ) | qoitopam > \ + ${test_out} || \ + printf "Expected failure 12" + test -s ${test_out}; echo " "$? + 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..14b6f11a --- /dev/null +++ b/test/random-generator.test @@ -0,0 +1,86 @@ +#! /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" + +# GNU libc rand(): 593 252 207 990 507 824 961 805 559 110 167 172 +# MAC OS rand(): 9 782 60 418 364 654 670 172 1022 515 593 903 + +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/rawtoppm.ok b/test/rawtoppm.ok new file mode 100644 index 00000000..c61e75aa --- /dev/null +++ b/test/rawtoppm.ok @@ -0,0 +1,23 @@ +Test 1: should print '0 0 : 0' +0 0 : 0 +Test 2: should print '0 0 : 0' five times +0 0 : 0 +0 0 : 0 +0 0 : 0 +0 0 : 0 +0 0 : 0 +Test 3: should print '0 0 0 : 0' five times +0 0 0 : 0 +0 0 0 : 0 +0 0 0 : 0 +0 0 0 : 0 +0 0 0 : 0 +Test 4 +P3 +5 5 +255 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 5 5 5 5 5 9 9 9 9 9 +0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 +0 1 2 3 4 1 2 3 4 5 2 3 4 5 6 +9 8 7 6 5 4 3 2 1 0 0 0 0 0 0 diff --git a/test/rawtoppm.test b/test/rawtoppm.test new file mode 100755 index 00000000..3c309259 --- /dev/null +++ b/test/rawtoppm.test @@ -0,0 +1,72 @@ +#! /bin/bash +# This script tests: rawtoppm +# Also requires: pamcut ppmtorgb3 rgb3toppm ppmtoppm + +# Test 1 + +echo "Test 1: should print '0 0 : 0'" + +rawtoppm -headerskip 15 227 149 testimg.ppm | cmp -s - testimg.ppm + echo ${PIPESTATUS[@]} ":" $? + +# Test 2 +echo "Test 2: should print '0 0 : 0' five times" + +tmpdir=${tmpdir:-/tmp} +test0_ppm=${tmpdir}/test0.ppm + +for i in 0 1 10 99 220 + do + pamcut -cropright $i testimg.ppm > ${test0_ppm} + rawtoppm -headerskip 15 -rowskip $((i * 3)) $((227 - i)) 149 testimg.ppm | \ + cmp -s ${test0_ppm} - + echo ${PIPESTATUS[@]} ":" $? + done + +rm ${test0_ppm} + + +# Test 3 +echo "Test 3: should print '0 0 0 : 0' five times" + +ppmtorgb3 testimg.ppm + +rgb3toppm testimg.red testimg.blu testimg.grn | \ + rawtoppm -headerskip 15 -rbg 227 149 | cmp -s - testimg.ppm + echo ${PIPESTATUS[@]} ":" $? + +rgb3toppm testimg.grn testimg.red testimg.blu | \ + rawtoppm -headerskip 15 -grb 227 149 | cmp -s - testimg.ppm + echo ${PIPESTATUS[@]} ":" $? + +rgb3toppm testimg.grn testimg.blu testimg.red | \ + rawtoppm -headerskip 15 -gbr 227 149 | cmp -s - testimg.ppm + echo ${PIPESTATUS[@]} ":" $? + +rgb3toppm testimg.blu testimg.red testimg.grn | \ + rawtoppm -headerskip 15 -brg 227 149 | cmp -s - testimg.ppm + echo ${PIPESTATUS[@]} ":" $? + +rgb3toppm testimg.blu testimg.grn testimg.red | \ + rawtoppm -headerskip 15 -bgr 227 149 | cmp -s - testimg.ppm + echo ${PIPESTATUS[@]} ":" $? + +# Test 4 +echo "Test 4" + +test1_ppm=${tmpdir}/test1.ppm + +cat <<EOF > ${test1_ppm} +P3 +5 5 +9 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 5 5 5 5 5 9 9 9 9 9 +0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 +0 1 2 3 4 1 2 3 4 5 2 3 4 5 6 +9 8 7 6 5 4 3 2 1 0 0 0 0 0 0 +EOF + +ppmtoppm < ${test1_ppm} | rawtoppm -headerskip 9 5 5 -plain + +rm ${test1_ppm} testimg.red testimg.grn testimg.blu 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 88efb75e..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 - +# 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..7cb15dfc --- /dev/null +++ b/test/stdin-pam1.test @@ -0,0 +1,75 @@ +#! /bin/bash +# 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..f47df604 --- /dev/null +++ b/test/stdin-pam2.test @@ -0,0 +1,70 @@ +#! /bin/bash +# 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..ae848752 --- /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 pamflip + +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..064e3e22 --- /dev/null +++ b/test/stdin-ppm3.test @@ -0,0 +1,75 @@ +o#! /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/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 8334ff4e..73e5030c 100644 --- a/test/winicon-roundtrip.ok +++ b/test/winicon-roundtrip.ok @@ -1,2 +1,12 @@ -71846281 6925 -326197919 137 +Test 1. Should print 4241318573 6973 four times +4241318573 6973 +4241318573 6973 +4241318573 6973 +4241318573 6973 +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 b37a33e1..31fb89aa 100755 --- a/test/winicon-roundtrip.test +++ b/test/winicon-roundtrip.test @@ -1,13 +1,39 @@ -#! /bin/bash -# This script tests: pamtowinicon winicontopam -# Also requires: pamcut pnmtile pamtopnm ppmtopgm pgmtopbm +#! /bin/sh +# This script tests: pamtowinicon ppmtowinicon winicontopam +# Also requires: pamchannel pamcut pamdepth pamtopam +# Also requires: pngtopam pnmtopng +tmpdir=${tmpdir:-/tmp} +test_pam=${tmpdir}/testimg.pam -pamcut --left=30 --width=48 --height=48 testimg.ppm | \ -pamtowinicon | winicontopam | \ - pamtopnm | cksum +echo "Test 1. Should print 4241318573 6973 four times" -pnmtile 32 32 testgrid.pbm | \ -pamtowinicon | winicontopam | \ - pamtopnm | ppmtopgm | \ - pgmtopbm -th -val=0.5 | cksum +pamcut --left=30 --width=48 --height=48 testimg.ppm | pamtopam | \ + tee ${test_pam} | cksum +pamtowinicon ${test_pam} | winicontopam | \ + pamchannel -tupletype="RGB" 0 1 2 | cksum +pamtowinicon -pngthreshold=300 ${test_pam} | winicontopam | \ + pamchannel -tupletype="RGB" 0 1 2 | cksum +pamtowinicon -pngthreshold=1 ${test_pam} | winicontopam | \ + pamchannel -tupletype="RGB" 0 1 2 | cksum + +rm ${test_pam} + +echo "Test 1. Should print 1009647580 1093 six times" + +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 +pamtowinicon -pngthreshold=300 ${test_pam} | winicontopam | \ + pamdepth 1 | pamchannel -tupletype="BLACKANDWHITE" 0 | cksum +pamtowinicon -pngthreshold=1 ${test_pam} | winicontopam | + pamdepth 1 | pamchannel -tupletype="BLACKANDWHITE" 0 | cksum +pamtowinicon -pngthreshold=1 ${test_pam} | winicontopam | + pamchannel -tupletype="BLACKANDWHITE" 0 | cksum + +rm ${test_pam} + +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 new file mode 100644 index 00000000..54ba54e6 --- /dev/null +++ b/test/winicon-roundtrip2.ok @@ -0,0 +1,82 @@ +Should print: former checksum values +16 24 32 48 64 : 1 plane +Should print 2588356089 8591 or 3783949470 69390 four times +2588356089 8591 +2588356089 8591 +2588356089 8591 +2588356089 8591 +16 24 32 48 64 : 2 planes +Should print 3357739334 16877 or 3331485515 138534 four times +3357739334 16877 +3357739334 16877 +3357739334 16877 +3357739334 16877 +16 24 32 48 64 : 3 planes +Should print 3734212737 25073 or 56221695 207606 four times +3734212737 25073 +3734212737 25073 +3734212737 25073 +3734212737 25073 +16 24 32 48 64 : 4 planes +Should print 1294260080 33359 or 732184466 276750 four times +1294260080 33359 +1294260080 33359 +1294260080 33359 +1294260080 33359 +16 24 32 48 64 : 5 planes: output 3 +Should print 3734212737 25073 or 56221695 207606 four times +3734212737 25073 +3734212737 25073 +3734212737 25073 +3734212737 25073 +16 24 32 48 64 : 5 planes : output 4 +Should print 2704877198 33359 or 1699833476 276750 four times +2704877198 33359 +2704877198 33359 +2704877198 33359 +2704877198 33359 +16 24 32 48 64 : 5 planes : output 5 +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 +3783949470 69390 +3783949470 69390 +3783949470 69390 +16 32 48 256 : 2 planes +Should print 3357739334 16877 or 3331485515 138534 four times +3331485515 138534 +3331485515 138534 +3331485515 138534 +3331485515 138534 +16 32 48 256 : 3 planes +Should print 3734212737 25073 or 56221695 207606 four times +56221695 207606 +56221695 207606 +56221695 207606 +56221695 207606 +16 32 48 256 : 4 planes +Should print 1294260080 33359 or 732184466 276750 four times +732184466 276750 +732184466 276750 +732184466 276750 +732184466 276750 +16 32 48 256 : 5 planes: output 3 +Should print 3734212737 25073 or 56221695 207606 four times +56221695 207606 +56221695 207606 +56221695 207606 +56221695 207606 +16 32 48 256 : 5 planes : output 4 +Should print 2704877198 33359 or 1699833476 276750 four times +1699833476 276750 +1699833476 276750 +1699833476 276750 +1699833476 276750 +16 32 48 256 : 5 planes : output 5 +Should print 2567279592 41655 or 4154838752 345902 twice +4154838752 345902 +4154838752 345902 diff --git a/test/winicon-roundtrip2.test b/test/winicon-roundtrip2.test new file mode 100755 index 00000000..de40446e --- /dev/null +++ b/test/winicon-roundtrip2.test @@ -0,0 +1,154 @@ +#! /bin/sh +# This script tests: pamtowinicon winicontopam +# 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 + +test4_pam=${tmpdir}/testimg4.pam +test5_pam=${tmpdir}/testimg5.pam +black_pam=${tmpdir}/black.pam +white_pam=${tmpdir}/white.pam +gray_pam=${tmpdir}/gray.pam + +# classic: 16 24 32 48 64 +# full: 16 32 48 256 + +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 + ppmpat -tartan -color=rgb:1f/1f/1f,rgb:7f/ff/00,rgb:00/ff/3f \ + ${size} ${size} + done | pamtopam > ${test_pam} + + for size in ${sizes} + do + pbmmake -black ${size} ${size} | pamdepth 255 + done | pamtopam > ${black_pam} + + for size in ${sizes} + do + pbmmake -white ${size} ${size} | pamdepth 255 + done | pamtopam > ${white_pam} + + for size in ${sizes} + do + pbmmake -gray ${size} ${size} | pamdepth 255 + done | pamtopam > ${gray_pam} + +# 1 plane + + echo ${sizes} ": 1 plane" + echo "Should print 2588356089 8591 or 3783949470 69390 four times" + + pamchannel -tupletype="GRAYSCALE" 0 < ${test_pam} | \ + tee ${test1_pam} | cksum + pamtowinicon ${test1_pam} | winicontopam -allimages | \ + pamchannel -tupletype="GRAYSCALE" 0 | cksum + pamtowinicon -pngthreshold=300 ${test1_pam} | winicontopam -allimages | \ + pamchannel -tupletype="GRAYSCALE" 0 | cksum + pamtowinicon -pngthreshold=1 ${test1_pam} | winicontopam -allimages | \ + pamchannel -tupletype="GRAYSCALE" 0 | cksum + + rm ${test1_pam} + +# 2 planes + + echo ${sizes} ": 2 planes" + echo "Should print 3357739334 16877 or 3331485515 138534 four times" + + 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 | 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 | pamdepth 255 | cksum + + rm ${test2_pam} + +# 3 planes + + echo ${sizes} ": 3 planes" + echo "Should print 3734212737 25073 or 56221695 207606 four times" + + pamchannel -tupletype="RGB" 0 1 2 < ${test_pam} | cksum + pamtowinicon ${test_pam} | winicontopam -allimages | \ + pamchannel -tupletype="RGB" 0 1 2 | cksum + pamtowinicon -pngthreshold=300 ${test_pam} | winicontopam -allimages | \ + pamchannel -tupletype="RGB" 0 1 2 | cksum + pamtowinicon -pngthreshold=1 ${test_pam} | winicontopam -allimages | \ + pamchannel -tupletype="RGB" 0 1 2 | cksum + +# 4 planes + + echo ${sizes} ": 4 planes" + echo "Should print 1294260080 33359 or 732184466 276750 four times" + + pamdepth 255 ${black_pam} | pamstack ${test_pam} - | \ + pamchannel -tupletype="RGB_ALPHA" 0 1 2 3 | tee ${test4_pam} | cksum + pamtowinicon ${test4_pam} | winicontopam -allimages | \ + pamchannel -tupletype="RGB_ALPHA" 0 1 2 3 | cksum + pamtowinicon -pngthreshold=300 ${test4_pam} | winicontopam -allimages | \ + pamchannel -tupletype="RGB_ALPHA" 0 1 2 3 | cksum + pamtowinicon -pngthreshold=1 ${test4_pam} | winicontopam -allimages | \ + pamchannel -tupletype="RGB_ALPHA" 0 1 2 3 | cksum + + rm ${test4_pam} + +# 5 planes + + echo ${sizes} ": 5 planes: output 3" + echo "Should print 3734212737 25073 or 56221695 207606 four times" + + pamstack ${test_pam} ${gray_pam} ${white_pam} | \ + pamchannel -tupletype="RGB" 0 1 2 | \ + tee ${test5_pam} | cksum + pamtowinicon ${test5_pam} | winicontopam -allimages -andmasks | \ + pamchannel -tupletype="RGB" 0 1 2 | cksum + pamtowinicon -pngthreshold=300 ${test5_pam} | \ + winicontopam -allimages -andmasks | \ + pamchannel -tupletype="RGB" 0 1 2 | cksum + pamtowinicon -pngthreshold=1 ${test5_pam} | \ + winicontopam -allimages -andmasks | \ + pamchannel -tupletype="RGB" 0 1 2 | cksum + + echo ${sizes} ": 5 planes : output 4" + echo "Should print 2704877198 33359 or 1699833476 276750 four times" + + pamstack ${test_pam} ${gray_pam} ${white_pam} | \ + pamchannel -tupletype="RGB_ALPHA" 0 1 2 3 | \ + tee ${test5_pam} | cksum + pamtowinicon ${test5_pam} | winicontopam -allimages -andmasks | \ + pamchannel -tupletype="RGB_ALPHA" 0 1 2 3 | cksum + pamtowinicon -pngthreshold=300 ${test5_pam} | \ + winicontopam -allimages -andmasks | \ + pamchannel -tupletype="RGB_ALPHA" 0 1 2 3 | cksum + pamtowinicon -pngthreshold=1 ${test5_pam} | \ + winicontopam -allimages -andmasks | \ + pamchannel -tupletype="RGB_ALPHA" 0 1 2 3 | cksum + + echo ${sizes} ": 5 planes : output 5" + echo "Should print 2567279592 41655 or 4154838752 345902 twice" + + pamstack ${test_pam} ${gray_pam} ${white_pam} | \ + pamchannel -tupletype="RGB_ALPHA_ANDMASK" 0 1 2 3 4 | \ + tee ${test5_pam} | cksum + pamtowinicon -pngthreshold=300 ${test5_pam} | \ + winicontopam -allimages -andmasks | \ + pamchannel -tupletype="RGB_ALPHA_ANDMASK" 0 1 2 3 4 | cksum + + rm ${test5_pam} + + rm ${test_pam} ${gray_pam} ${white_pam} ${black_pam} +done 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..5168378d 100644 --- a/test/xpm-roundtrip.ok +++ b/test/xpm-roundtrip.ok @@ -1 +1 @@ -2425386270 41 +281226646 481 diff --git a/test/xpm-roundtrip.test b/test/xpm-roundtrip.test index fd0253b1..6e3e415b 100755 --- a/test/xpm-roundtrip.test +++ b/test/xpm-roundtrip.test @@ -1,9 +1,9 @@ -#! /bin/bash +#! /bin/sh # This script tests: ppmtoxpm xpmtoppm # Also requires: pgmtopbm ppmtopgm #ppmtoxpm -hexonly testimg.ppm | \ # xpmtoppm | cksum -ppmtoxpm testgrid.pbm | xpmtoppm | \ +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..864d737a 100644 --- a/test/xwd-roundtrip.ok +++ b/test/xwd-roundtrip.ok @@ -1,3 +1,6 @@ +Test 1. Should produce 1571496937 33838, cksum of testimg.red 1571496937 33838 +Test 2. Should produce 1926073387 101484 1926073387 101484 -2425386270 41 +Test 3. Should produce 281226646 481 +281226646 481 diff --git a/test/xwd-roundtrip.test b/test/xwd-roundtrip.test index cd0d38ad..2d00971d 100755 --- a/test/xwd-roundtrip.test +++ b/test/xwd-roundtrip.test @@ -1,16 +1,15 @@ -#! /bin/bash +#! /bin/sh # This script tests: pnmtoxwd xwdtopnm # Also requires: pamchannel pamtopnm pamdepth - -# Test 1. Should produce 1571496937 33838, cksum of testimg.red +echo "Test 1. Should produce 1571496937 33838, cksum of testimg.red" pamchannel -infile=testimg.ppm -tupletype="GRAYSCALE" 0 | pamtopnm | \ pnmtoxwd | xwdtopnm | pamdepth 255 | cksum -# Test 2. Should produce 1926073387 101484 -pnmtoxwd --quiet testimg.ppm | \ +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 | \ +echo "Test 3. Should produce 281226646 481" +pnmtoxwd --quiet maze.pbm | \ xwdtopnm | 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 |