about summary refs log tree commit diff
path: root/test/pbmtextps-dump.test
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2022-08-01 01:27:32 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2022-08-01 01:27:32 +0000
commitdb592a5379550479901fda96fa87490c5ff65eeb (patch)
tree5f2cb9c9937aa852ee6d050b87431e262b39d62b /test/pbmtextps-dump.test
parentb7735d8033c10a49fa7483921c86b7b282830307 (diff)
downloadnetpbm-mirror-db592a5379550479901fda96fa87490c5ff65eeb.tar.gz
netpbm-mirror-db592a5379550479901fda96fa87490c5ff65eeb.tar.xz
netpbm-mirror-db592a5379550479901fda96fa87490c5ff65eeb.zip
miscellaneous test updates
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@4383 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'test/pbmtextps-dump.test')
-rwxr-xr-xtest/pbmtextps-dump.test84
1 files changed, 84 insertions, 0 deletions
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}