diff options
Diffstat (limited to 'test/pbmtext.test')
-rwxr-xr-x | test/pbmtext.test | 76 |
1 files changed, 48 insertions, 28 deletions
diff --git a/test/pbmtext.test b/test/pbmtext.test index 515711e4..d4ab027e 100755 --- a/test/pbmtext.test +++ b/test/pbmtext.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmtext # Also requires: pamfile @@ -10,13 +10,13 @@ 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 @@ -41,7 +41,7 @@ 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 @@ -112,29 +112,44 @@ echo "Test 6 Invalid" test_out=${tmpdir}/test_out pbmtext -font=testgrid.pbm foo > ${test_out} || \ - echo -n "Expected failure 1"; - test -s ${test_out}; echo " "$? + printf "Expected failure 1 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + pbmtext -font=testimg.ppm foo > ${test_out} || \ - echo -n "Expected failure 2"; - test -s ${test_out}; echo " "$? + printf "Expected failure 2 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + pbmtext -builtin=void foo > ${test_out} || \ - echo -n "Expected failure 3"; - test -s ${test_out}; echo " "$? + printf "Expected failure 3 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + pbmtext -font=${font_pbm} -builtin=fixed foo > ${test_out} || \ - echo -n "Expected failure 4"; - test -s ${test_out}; echo " "$? + printf "Expected failure 4 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + pbmtext -dry-run -text-dump foo > ${test_out} || \ - echo -n "Expected failure 5"; - test -s ${test_out}; echo " "$? + printf "Expected failure 5 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + pbmtext -dump-sheet -text-dump foo > ${test_out} || \ - echo -n "Expected failure 6"; - test -s ${test_out}; echo " "$? + printf "Expected failure 6 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + pbmtext -dry-run -dump-sheet foo > ${test_out} || \ - echo -n "Expected failure 7"; - test -s ${test_out}; echo " "$? + printf "Expected failure 7 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + pbmtext -wchar foo > ${test_out} || \ - echo -n "Expected failure 8"; - test -s ${test_out}; echo " "$? + printf "Expected failure 8 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} rm ${font_pbm} @@ -153,7 +168,7 @@ cat ${long_txt} | pbmtext -nomargins -builtin fixed | cksum echo "Test 8 Invalid" -echo -n "z" >> ${long_txt} +printf "z" >> ${long_txt} awk '{print "text length:", length($0)}' ${long_txt} echo 1>&2 @@ -162,14 +177,19 @@ echo "Error messages should appear below the line." 1>&2 echo "-----------------------------------------------------------" 1>&2 pbmtext -nomargins -builtin fixed `cat ${long_txt}` > ${test_out} || \ - echo -n "Expected failure 1"; - test -s ${test_out}; echo " "$? + printf "Expected failure 1 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + cat ${long_txt} | pbmtext -nomargins -builtin fixed > ${test_out} || \ - echo -n "Expected failure 2"; - test -s ${test_out}; echo " "$? + printf "Expected failure 2 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + cat ${long_txt} | \ LC_ALL=C pbmtext -nomargins -builtin fixed -wchar > ${test_out} || \ - echo -n "Expected failure 3"; - test -s ${test_out}; echo " "$? + printf "Expected failure 3 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} -rm ${long_txt} ${test_out} +rm ${long_txt} |