From ca00385342fb1122965d02e55fff15288138ee40 Mon Sep 17 00:00:00 2001 From: giraffedata Date: Tue, 25 Sep 2018 02:09:44 +0000 Subject: New tests for 'pamaltsat', 'pamgetcolor', 'pamlevels', 'pamtris'; Various test fixes git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@3338 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- test/Makefile | 2 +- test/all-in-place.ok | 4 +++ test/all-in-place.test | 4 +++ test/pbmtext-bdf.ok | 13 ++++++++ test/pbmtext-bdf.test | 78 +++++++++++++++++++++++++++++++++++++++++++--- test/pbmtext-iso88591.ok | 8 ++--- test/pbmtext-iso88591.test | 12 +++---- test/pbmtext-utf8.ok | 12 +++---- test/pbmtext-utf8.test | 28 ++++++++++------- test/pbmtext.ok | 4 +-- test/pbmtext.test | 4 +-- test/pgmnoise.ok | 1 - test/ppmforge.ok | 1 - test/ppmpat-random.ok | 3 -- test/ppmrough.ok | 1 - 15 files changed, 132 insertions(+), 43 deletions(-) delete mode 100644 test/pgmnoise.ok delete mode 100644 test/ppmforge.ok delete mode 100644 test/ppmpat-random.ok delete mode 100644 test/ppmrough.ok (limited to 'test') diff --git a/test/Makefile b/test/Makefile index 4f0c063f..c640dfff 100644 --- a/test/Makefile +++ b/test/Makefile @@ -31,4 +31,4 @@ include $(SRCDIR)/common.mk distclean clean: cleanlocal .PHONY: cleanlocal cleanlocal: - rm -f $(PROGS) $(OKSTOGENERATE) + rm -f $(PROGS) $(patsubst %.rand-ok,%.ok,$(wildcard *.rand-ok)) diff --git a/test/all-in-place.ok b/test/all-in-place.ok index b9db6ee1..81eaa320 100644 --- a/test/all-in-place.ok +++ b/test/all-in-place.ok @@ -36,6 +36,7 @@ mtvtoppm: ok neotoppm: ok palmtopnm: ok pamaddnoise: ok +pamaltsat: ok pamarith: ok pambackground: ok pambayer: ok @@ -56,7 +57,9 @@ pamfix: ok pamflip: ok pamfunc: ok pamgauss: ok +pamgetcolor: ok pamgradient: ok +pamlevels: ok pamlookup: ok pammasksharpen: ok pammixinterlace: ok @@ -106,6 +109,7 @@ pamtotiff: ok pamtouil: ok pamtowinicon: ok pamtoxvmini: ok +pamtris: ok pamundice: ok pamunlookup: ok pamvalidate: ok diff --git a/test/all-in-place.test b/test/all-in-place.test index a52739ed..cf402b6f 100755 --- a/test/all-in-place.test +++ b/test/all-in-place.test @@ -78,6 +78,7 @@ ordinary_testprogs="\ neotoppm \ palmtopnm \ pamaddnoise \ + pamaltsat \ pamarith \ pambackground \ pambayer \ @@ -98,7 +99,9 @@ ordinary_testprogs="\ pamflip \ pamfunc \ pamgauss \ + pamgetcolor \ pamgradient \ + pamlevels \ pamlookup \ pammasksharpen \ pammixinterlace \ @@ -148,6 +151,7 @@ ordinary_testprogs="\ pamtouil \ pamtowinicon \ pamtoxvmini \ + pamtris \ pamundice \ pamunlookup \ pamvalidate \ diff --git a/test/pbmtext-bdf.ok b/test/pbmtext-bdf.ok index 5ab8b4af..b1486493 100644 --- a/test/pbmtext-bdf.ok +++ b/test/pbmtext-bdf.ok @@ -6,3 +6,16 @@ 1 1 1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +0 +0 diff --git a/test/pbmtext-bdf.test b/test/pbmtext-bdf.test index 1bd7c52c..50df7b75 100755 --- a/test/pbmtext-bdf.test +++ b/test/pbmtext-bdf.test @@ -5,7 +5,7 @@ tmpdir=${tmpdir:-/tmp} font_bdf=${tmpdir}/font.bdf -font_corrupt_bdf=${tmpdir}/fontcorrupt.bdf +font_corrupt=${tmpdir}/fontcorrupt # Though this BDF font file defines only three letters, it is valid. @@ -69,31 +69,101 @@ pbmtext -font ${font_bdf} ABC | cksum # Test 2 -# The rest should all fail. Writes 1 seven times. +# These should all fail. Writes 1 eightteen times. echo "Test whether corrupted BDF font files are properly handled." 1>&2 -echo "Error messages will appear." 1>&2 -echo 1>&2 +echo "Error messages should appear below the line." 1>&2 +echo "-----------------------------------------------------------" 1>&2 pbmtext -font ${font_bdf} BCD echo $? +for token in "STARTPROPERTIES" "CHARS" "STARTCHAR" "ENCODING" "DWIDTH" +do + font_corrupt_bdf=${font_corrupt}.naked_${token}.bdf + sed 's/^'${token}' .*$/'${token}'/' \ + ${font_bdf} > ${font_corrupt_bdf} + pbmtext -font ${font_corrupt_bdf} ABC > /dev/null + echo $? + rm ${font_corrupt_bdf} +done + +font_corrupt_bdf=${font_corrupt}.fbbx_narrow.bdf sed 's/FONTBOUNDINGBOX 4 5 0 0/FONTBOUNDINGBOX 4 4 0 0/' \ + ${font_bdf} > ${font_corrupt_bdf} +pbmtext -font ${font_corrupt_bdf} ABC > /dev/null +echo $? +rm ${font_corrupt_bdf} + +font_corrupt_bdf=${font_corrupt}.fbbx_low.bdf +sed 's/FONTBOUNDINGBOX 4 5 0 0/FONTBOUNDINGBOX 3 5 0 0/' \ + ${font_bdf} > ${font_corrupt_bdf} +pbmtext -font ${font_corrupt_bdf} ABC > /dev/null +echo $? +rm ${font_corrupt_bdf} + +font_corrupt_bdf=${font_corrupt}.bbx_only3fields.bdf +sed 's/BBX 4 5 0 0/BBX 4 5 0/' \ + ${font_bdf} > ${font_corrupt_bdf} +pbmtext -font ${font_corrupt_bdf} ABC > /dev/null +echo $? +rm ${font_corrupt_bdf} + +font_corrupt_bdf=${font_corrupt}.bbx_wide.bdf +sed 's/BBX 4 5 0 0/BBX 9 5 0 0/' \ + ${font_bdf} > ${font_corrupt_bdf} +pbmtext -font ${font_corrupt_bdf} ABC > /dev/null +echo $? +rm ${font_corrupt_bdf} + +font_corrupt_bdf=${font_corrupt}.bbx_zerowidth.bdf +sed 's/BBX 4 5 0 0/BBX 0 5 0 0/' \ ${font_bdf} > ${font_corrupt_bdf} pbmtext -font ${font_corrupt_bdf} ABC > /dev/null echo $? rm ${font_corrupt_bdf} +font_corrupt_bdf=${font_corrupt}.bbx_tall.bdf sed 's/BBX 4 5 0 0/BBX 4 6 0 0/' \ ${font_bdf} > ${font_corrupt_bdf} pbmtext -font ${font_corrupt_bdf} ABC > /dev/null echo $? rm ${font_corrupt_bdf} +font_corrupt_bdf=${font_corrupt}.bbx_low.bdf +sed 's/BBX 4 5 0 0/BBX 4 1 0 0/' \ + ${font_bdf} > ${font_corrupt_bdf} +pbmtext -font ${font_corrupt_bdf} ABC > /dev/null +echo $? +rm ${font_corrupt_bdf} + +font_corrupt_bdf=${font_corrupt}.bbx_zeroheight.bdf +sed 's/BBX 4 5 0 0/BBX 4 0 0 0/' \ + ${font_bdf} > ${font_corrupt_bdf} +pbmtext -font ${font_corrupt_bdf} ABC > /dev/null +echo $? +rm ${font_corrupt_bdf} + for delete_line in 14 16 18 20 do + font_corrupt_bdf=${font_corrupt}.del${delete_line}.pdf sed "${delete_line}"d ${font_bdf} > ${font_corrupt_bdf} pbmtext -font ${font_corrupt_bdf} ABC > /dev/null echo $? rm ${font_corrupt_bdf} done + + +# Test 2 +# These should succeed. Warning messages will be displayed. +# Writes 1 two times. + +for token in "CHARSET_ENCODING" "CHARSET_REGISTRY" +do + font_corrupt_bdf=${font_corrupt}.naked_${token}.bdf + sed 's/^'${token}' .*$/'${token}'/' \ + ${font_bdf} > ${font_corrupt_bdf} + pbmtext -font ${font_corrupt_bdf} ABC > /dev/null + echo $? + rm ${font_corrupt_bdf} +done diff --git a/test/pbmtext-iso88591.ok b/test/pbmtext-iso88591.ok index d1516357..6cc1a856 100644 --- a/test/pbmtext-iso88591.ok +++ b/test/pbmtext-iso88591.ok @@ -1,4 +1,4 @@ -3491766365 5110 -3491766365 5110 -259944121 191 -259944121 191 +3806607098 5110 +3806607098 5110 +2858870527 192 +2858870527 192 diff --git a/test/pbmtext-iso88591.test b/test/pbmtext-iso88591.test index 34346f5c..bc5e83ab 100755 --- a/test/pbmtext-iso88591.test +++ b/test/pbmtext-iso88591.test @@ -21,26 +21,26 @@ if [ $? -ne 0 ] fi # Two rows -# Should print 3491766365 5110 twice +# Should print 3806607098 5110 twice LC_ALL=C \ -awk 'BEGIN { for (i=32; i<=125;++i) printf("%c",i); print ""; \ +awk 'BEGIN { for (i=32; i<=126;++i) printf("%c",i); print ""; \ for (i=160;i<=255;++i) printf("%c",i); }' | \ pbmtext -builtin bdf | cksum LC_ALL=C \ -awk 'BEGIN { for (i=32; i<=125;++i) printf("%c",i); print ""; \ +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 # Two rows -# Should print 259944121 191 twice +# Should print 2858870527 192 twice LC_ALL=C \ -awk 'BEGIN { for (i=32; i<=125;++i) printf("%c",i); print ""; \ +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<=125;++i) printf("%c",i); print ""; \ +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 diff --git a/test/pbmtext-utf8.ok b/test/pbmtext-utf8.ok index 864c530a..9e65dec4 100644 --- a/test/pbmtext-utf8.ok +++ b/test/pbmtext-utf8.ok @@ -1,8 +1,8 @@ -1240895458 5110 -1240895458 5110 -898975479 2272 -898975479 2272 +2066913605 5110 +2066913605 5110 +2920616515 2301 +2920616515 2301 0 - !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|} - !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|} + !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ + !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ 1 diff --git a/test/pbmtext-utf8.test b/test/pbmtext-utf8.test index ca1f45a2..010c02db 100755 --- a/test/pbmtext-utf8.test +++ b/test/pbmtext-utf8.test @@ -21,14 +21,14 @@ fi # Test 1. # Two rows -# Should print 1240895458 5110 twice +# Should print 2066913605 5110 twice LC_ALL=C \ -awk 'BEGIN { for (i=32; i<=125;++i) printf("%c",i); print ""; \ +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<=125;++i) printf("%c",i); print ""; \ +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 @@ -36,13 +36,13 @@ awk 'BEGIN { for (i=32; i<=125;++i) printf("%c",i); print ""; \ # Test 2. # One row -# Should print 898975479 2272 twice +# Should print 2920616515 2301 twice LC_ALL=C \ -awk 'BEGIN { for (i=32; i<=125;++i) printf("%c",i); print "" }' | \ +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<=125;++i) printf("%c",i); print ""}' | \ +awk 'BEGIN { for (i=32; i<=126;++i) printf("%c",i); print ""}' | \ LC_ALL=en_US.utf8 pbmtext -builtin bdf -wchar | cksum @@ -55,12 +55,12 @@ output=${tmpdir}/output # Output may be affected by locale. Compare with cmp. # Should print 0 LC_ALL=C \ -awk 'BEGIN { for (i=32; i<=125;++i) printf("%c",i); print ""; \ +awk 'BEGIN { for (i=32; i<=126;++i) printf("%c",i); print ""; \ for (i=161;i<=255;++i) printf("%c",i); print "" }' | \ - iconv -f iso88591 -t utf8 > ${output} + iconv -f iso8859-1 -t utf-8 > ${output} LC_ALL=C \ -awk 'BEGIN { for (i=32; i<=125;++i) printf("%c",i); print ""; \ +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 | \ @@ -73,15 +73,19 @@ rm ${output} # Test 4. # One row # Should print the following twice: -# !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|} +# !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ LC_ALL=C \ -awk 'BEGIN { for (i=32; i<=125;++i) printf("%c",i); print "" } ' +awk 'BEGIN { for (i=32; i<=126;++i) printf("%c",i); print "" } ' LC_ALL=C \ -awk 'BEGIN { for (i=32; i<=125;++i) printf("%c",i); print ""}' | \ +awk 'BEGIN { for (i=32; i<=126;++i) printf("%c",i); print ""}' | \ LC_ALL=en_US.utf8 pbmtext -builtin bdf -wchar -text-dump +echo "Invalid utf-8 sequence as input." 1>&2 +echo "An error message should appear below the line." 1>&2 +echo "-----------------------------------------------------------" 1>&2 + # Test 5. # Invalid utf-8 sequence # Should print 1 diff --git a/test/pbmtext.ok b/test/pbmtext.ok index 000c0897..96e351f9 100644 --- a/test/pbmtext.ok +++ b/test/pbmtext.ok @@ -12,5 +12,5 @@ 1647614653 2027 1647614653 2027 1647614653 2027 -3233136020 4535 -1216262214 5711 +2547645687 4564 +1174281741 5741 diff --git a/test/pbmtext.test b/test/pbmtext.test index c92ed599..38578636 100755 --- a/test/pbmtext.test +++ b/test/pbmtext.test @@ -82,13 +82,13 @@ rm ${fontRectangle_txt} ${font_pbm} # One long row # Should print 3233136020 4535 LC_ALL=C \ -awk 'BEGIN { for (i=32; i<=125;++i) printf("%c",i); +awk 'BEGIN { for (i=32; i<=126;++i) printf("%c",i); for (i=160;i<=255;++i) printf("%c",i); }' | \ pbmtext -builtin bdf | cksum # One tall column # Should print 1216262214 5711 LC_ALL=C \ -awk 'BEGIN { for (i=32; i<=125;++i) printf("%c\n",i); +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 diff --git a/test/pgmnoise.ok b/test/pgmnoise.ok deleted file mode 100644 index 138218c2..00000000 --- a/test/pgmnoise.ok +++ /dev/null @@ -1 +0,0 @@ -2005134911 10015 diff --git a/test/ppmforge.ok b/test/ppmforge.ok deleted file mode 100644 index e4a4c9e2..00000000 --- a/test/ppmforge.ok +++ /dev/null @@ -1 +0,0 @@ -3634219838 196623 diff --git a/test/ppmpat-random.ok b/test/ppmpat-random.ok deleted file mode 100644 index 4d298cec..00000000 --- a/test/ppmpat-random.ok +++ /dev/null @@ -1,3 +0,0 @@ -2219119109 36015 -3436846137 16813 -908097729 16813 diff --git a/test/ppmrough.ok b/test/ppmrough.ok deleted file mode 100644 index 83643849..00000000 --- a/test/ppmrough.ok +++ /dev/null @@ -1 +0,0 @@ -378403602 30015 -- cgit 1.4.1