about summary refs log tree commit diff
path: root/test/pbmtext.test
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2016-04-24 00:08:56 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2016-04-24 00:08:56 +0000
commit6c791c551342a88dff3b74b45e0c0fa14d85d4f9 (patch)
tree9954df7f85eda92cbf5e783802743a885c6e7914 /test/pbmtext.test
parent4f193de66cf672ea408a829bd5233d180cf72bba (diff)
downloadnetpbm-mirror-6c791c551342a88dff3b74b45e0c0fa14d85d4f9.tar.gz
netpbm-mirror-6c791c551342a88dff3b74b45e0c0fa14d85d4f9.tar.xz
netpbm-mirror-6c791c551342a88dff3b74b45e0c0fa14d85d4f9.zip
Additional tests
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@2714 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'test/pbmtext.test')
-rwxr-xr-xtest/pbmtext.test125
1 files changed, 117 insertions, 8 deletions
diff --git a/test/pbmtext.test b/test/pbmtext.test
index 0a177270..20c9b285 100755
--- a/test/pbmtext.test
+++ b/test/pbmtext.test
@@ -19,9 +19,9 @@ text="The quick brown fog jumps over the lazy docs."
 
 # Test 2:
 
-for flags in "" "-nom" "-builtin fixed"
+for flags in "" "-nomargins" "-builtin fixed"
 do
-echo $text | pbmtext $flags | cksum
+echo ${text} | pbmtext ${flags} | cksum
 done
 
 temp_pbm=${tmpdir}/temp.pbm
@@ -33,13 +33,19 @@ temp_pbm=${tmpdir}/temp.pbm
 for flags in "" "-builtin fixed"
 do
 pbmtext ${flags} ${text} | tee ${temp_pbm} | cksum
-width=`pamfile ${temp_pbm} | awk '$2=="PBM" && NR==1 { w=$4}; END {print w}' `
-pbmtext ${flags} -width=$width $text | cksum
+width1=`pamfile ${temp_pbm} | awk '$2=="PBM" && NR==1 {w=$4}; END {print w}' `
+width2=`pbmtext ${flags} ${text} --dry-run | awk '{print $1}' `
+
+if [ ${width1} -eq ${width2} ]; then
+    pbmtext ${flags} -width=${width1} ${text} | cksum
+else
+    echo ${width1} ${width2}
+fi
 rm ${temp_pbm}
 done
 
 
-# Test 3: Should print 1647614653 2027 twice
+# Test 4: Should print 1647614653 2027 three times
 # Note: backslashes inserted in 3 locations in the rectange to make
 # possible input as a here document.
 
@@ -61,8 +67,111 @@ _ PQRSTUVWXYZ[ _
 M ",/^_[\`jpqy| M
 EOF
 
-cat ${fontRectangle_txt} | pbmtext -nom -builtin fixed | tee ${font_pbm} | \
-cksum
+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}
+
+
+# Test 5: Print all characters defined in the built-in bdf font
+
+# One long row
+# Should print
+awk 'BEGIN { for (i=32; i<=125;++i) printf("%c",i);
+             for (i=160;i<=255;++i) printf("%c",i); }' | \
+    pbmtext -builtin bdf | cksum
+
+# One tall column
+# Should print
+awk 'BEGIN { for (i=32; i<=125;++i) printf("%c\n",i);
+             for (i=160;i<=255;++i) printf("%c\n",i); }' | \
+    pbmtext -nomargins -builtin bdf | cksum
+
+
+# Test 6:
+# Test corruptions in BDF font file.
+
+font_bdf=${tmpdir}/font.bdf
+font_corrupt_bdf=${tmpdir}/fontcorrupt.bdf
+
+# Though this is BDF font file defines only three letters, it is valid.
+
+cat > ${font_bdf} << EOF
+STARTFONT 2.1
+COMMENT $XFree86: xc/fonts/bdf/misc/micro.bdf,v 1.1 1999/09/25 14:36:34 dawes Exp $  - Modified for test
+FONT micro
+SIZE 4 75 75
+FONTBOUNDINGBOX 4 5 0 0
+STARTPROPERTIES 3
+FONT_DESCENT 0
+FONT_ASCENT 5
+CHARSET_REGISTRY "ISO88591"
+CHARSET_ENCODING "1"
+COPYRIGHT "Public domain font.  Share and enjoy."
+ENDPROPERTIES
+CHARS 3
+STARTCHAR A
+ENCODING 65
+SWIDTH 1000 0
+DWIDTH 4 0
+BBX 4 5 0 0
+BITMAP
+e0
+a0
+e0
+a0
+a0
+ENDCHAR
+STARTCHAR B
+ENCODING 66
+SWIDTH 1000 0
+DWIDTH 4 0
+BBX 4 5 0 0
+BITMAP
+e0
+a0
+c0
+a0
+e0
+ENDCHAR
+STARTCHAR C
+ENCODING 67
+SWIDTH 1000 0
+DWIDTH 4 0
+BBX 4 5 0 0
+BITMAP
+e0
+80
+80
+80
+e0
+ENDCHAR
+ENDFONT
+EOF
+
+# This should succeed and produce 386826492 35
+pbmtext -font ${font_bdf} ABC | cksum
+
+# The rest should all fail.  Writes 1 seven times.
+pbmtext -font ${font_bdf} BCD
+echo $?
+
+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}
+
+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}
+
+for delete_line in 14 16 18 20
+  do
+  sed "${delete_line}"d ${font_bdf} >  ${font_corrupt_bdf}
+  pbmtext -font ${font_corrupt_bdf} ABC > /dev/null
+  echo $?
+  rm ${font_corrupt_bdf}
+  done