diff options
-rwxr-xr-x | test/Execute-Tests | 2 | ||||
-rw-r--r-- | test/Test-Order | 3 | ||||
-rw-r--r-- | test/all-in-place.ok | 1 | ||||
-rwxr-xr-x | test/all-in-place.test | 3 | ||||
-rw-r--r-- | test/pbmtextps-dump.ok | 65 | ||||
-rwxr-xr-x | test/pbmtextps-dump.test | 84 | ||||
-rw-r--r-- | test/pbmtextps.ok | 16 | ||||
-rwxr-xr-x | test/pbmtextps.test | 53 | ||||
-rw-r--r-- | test/qoi-roundtrip.ok | 34 | ||||
-rwxr-xr-x | test/qoi-roundtrip.test | 254 | ||||
-rw-r--r-- | test/stdin-pam1.ok | 1 | ||||
-rwxr-xr-x | test/stdin-pam1.test | 3 | ||||
-rw-r--r-- | test/stdin-pam3.ok | 2 | ||||
-rwxr-xr-x | test/stdin-pam3.test | 2 |
14 files changed, 520 insertions, 3 deletions
diff --git a/test/Execute-Tests b/test/Execute-Tests index 9b51cfd5..3c231d98 100755 --- a/test/Execute-Tests +++ b/test/Execute-Tests @@ -186,7 +186,7 @@ elif [ $VALGRIND_TESTS = "on" ] 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 tee tr uniq wc \ + printf rm sed seq sh sort tail tee tr uniq wc \ testrandom Available-Testprog # Tell valgrind not to probe execution of the above programs. diff --git a/test/Test-Order b/test/Test-Order index eafcb974..8ad544a2 100644 --- a/test/Test-Order +++ b/test/Test-Order @@ -16,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 @@ -232,6 +234,7 @@ pj-roundtrip.test ps-roundtrip.test ps-flate-roundtrip.test ps-alt-roundtrip.test +qoi-roundtrip.test sgi-roundtrip.test sbig-roundtrip.test st4-roundtrip.test diff --git a/test/all-in-place.ok b/test/all-in-place.ok index 0af78737..22e4cee5 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 diff --git a/test/all-in-place.test b/test/all-in-place.test index c2b99328..ca9b26a6 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 \ @@ -438,4 +439,4 @@ testExitStatus anytopnm 0 $? manweb --help > /dev/null testExitStatus manweb 0 $? -# We do not test vidtoppm. \ No newline at end of file +# We do not test vidtoppm. diff --git a/test/pbmtextps-dump.ok b/test/pbmtextps-dump.ok new file mode 100644 index 00000000..9fe3b2ea --- /dev/null +++ b/test/pbmtextps-dump.ok @@ -0,0 +1,65 @@ +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 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 (-font="") 1 diff --git a/test/pbmtextps-dump.test b/test/pbmtextps-dump.test new file mode 100755 index 00000000..3b3fbadd --- /dev/null +++ b/test/pbmtextps-dump.test @@ -0,0 +1,84 @@ +#! /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} +text_pbm=${tmpdir}/text.pbm +text_ps=${tmpdir}/text.ps + +text="UNIX Philosophy: Do one thing and do it well." + +# Test 1: +echo "Test 1" + +pbmtextps -dump-ps ${text} > ${text_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 ${text_ps} - | grep "^[<>]" + done + +rm ${text_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 + + 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..d407cb0a --- /dev/null +++ b/test/pbmtextps.ok @@ -0,0 +1,16 @@ +Test 1. Should print 0 five times. +0 +0 +0 +0 +0 +Test 2. Should print P1 1 1 0 three times +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..975f960c --- /dev/null +++ b/test/pbmtextps.test @@ -0,0 +1,53 @@ +#! /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 three 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 + + + +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/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..73878ce5 --- /dev/null +++ b/test/qoi-roundtrip.test @@ -0,0 +1,254 @@ +#! /bin/bash +# This script tests: qoitopnm 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/stdin-pam1.ok b/test/stdin-pam1.ok index e66da036..10e48622 100644 --- a/test/stdin-pam1.ok +++ b/test/stdin-pam1.ok @@ -3,6 +3,7 @@ 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 diff --git a/test/stdin-pam1.test b/test/stdin-pam1.test index 1331abd0..7cb15dfc 100755 --- a/test/stdin-pam1.test +++ b/test/stdin-pam1.test @@ -1,6 +1,6 @@ #! /bin/bash # This script tests: pamaddnoise pamaltsat pambackground pambayer -# This script tests: pambrighten pamcut pamdeinterlace pamdepth pamditherbw +# 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 @@ -24,6 +24,7 @@ for testprog in \ pambackground \ "pambayer -type=2" \ pambrighten \ + "pamcat -topbottom" \ pamcut \ pamdeinterlace \ "pamdepth 15" \ diff --git a/test/stdin-pam3.ok b/test/stdin-pam3.ok index 0ec9cf5d..516e9554 100644 --- a/test/stdin-pam3.ok +++ b/test/stdin-pam3.ok @@ -14,6 +14,8 @@ 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 diff --git a/test/stdin-pam3.test b/test/stdin-pam3.test index e8c31781..02257942 100755 --- a/test/stdin-pam3.test +++ b/test/stdin-pam3.test @@ -5,6 +5,7 @@ # 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 @@ -36,6 +37,7 @@ for fmt in \ pdbimg \ pfm \ png \ + qoi \ srf \ svg \ winicon \ |