diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2019-06-28 23:45:11 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2019-06-28 23:45:11 +0000 |
commit | cdf6e0151411d887fef61245cb303ef190b29335 (patch) | |
tree | 678c2212e125e66e0a868773e2b4ec460794da4e /test/pamtopdbimg.test | |
parent | de1311e820dc892f1a3c5c9ae70dbc56868030d8 (diff) | |
download | netpbm-mirror-cdf6e0151411d887fef61245cb303ef190b29335.tar.gz netpbm-mirror-cdf6e0151411d887fef61245cb303ef190b29335.tar.xz netpbm-mirror-cdf6e0151411d887fef61245cb303ef190b29335.zip |
Promote Advanced to Stable
git-svn-id: http://svn.code.sf.net/p/netpbm/code/stable@3641 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'test/pamtopdbimg.test')
-rwxr-xr-x | test/pamtopdbimg.test | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/test/pamtopdbimg.test b/test/pamtopdbimg.test new file mode 100755 index 00000000..8de78a70 --- /dev/null +++ b/test/pamtopdbimg.test @@ -0,0 +1,95 @@ +#! /bin/bash +# This script tests: pamtopdbimg +# Also requires: pgmmake pgmnoise + +tmpdir=${tmpdir:-/tmp} +mono_pgm=${tmpdir}/graymono.pgm +noise_pgm=${tmpdir}/graynoise.pgm +text65533=${tmpdir}/ascii65533.txt +text65534=${tmpdir}/ascii65534.txt +text65597=${tmpdir}/ascii65597.txt + +# The PDB image format has a time stamp. This causes pamtopdbimg +# to produce slightly different output files with each invocation. + +# Test 1. High compression +# -maybecompressed should produce a compressed file +# Should print: +# 2 +# 1 +echo high compression +pgmmake 0.5 -maxval=15 160 160 > ${mono_pgm} +for flag in "-compressed" "-maybecompressed" "-uncompressed" + do + pamtopdbimg $flag ${mono_pgm} | wc -c + done | uniq -c | awk '{print $1}' +rm ${mono_pgm} + + +# Test 2. Poor compression +# -maybecompressed should produce a uncompressed file +# Should print: +# 1 +# 2 +echo poor compression +pgmnoise -maxval=15 -randomseed=0 160 160 > ${noise_pgm} +for flag in "-compressed" "-maybecompressed" "-uncompressed" + do + pamtopdbimg $flag ${noise_pgm} | wc -c + done | uniq -c | awk '{print $1}' +rm ${noise_pgm} + + +# Test 3. long titles +# Should succeed twice and fail once, producing: +# 268 +# 0 +# 268 +# 0 +# 1 +# 0 + +# Some versions of wc have extra whitespace in the output (e.g. MAC OS) +# Delete with tr -d + +echo long titles +for flag in "" "-title=0123456789012345678901234567890" \ + "-title=01234567890123456789012345678901" + do + pamtopdbimg $flag testgrid.pbm | wc -c | tr -d ' ' + echo ${PIPESTATUS[0]} + done + + + +# Test 4. large notefile +# Should succeed twice and fail once, producing: +# 3344 +# 0 +# 68886 +# 0 +# 1 +# 0 +echo large notefile +awk 'BEGIN { ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + abc="abcdefghijklmnopqrstuvwxyz"; + digits="0123456789"; string =""; + + while ( length(string) < 65597 ) + string = string ABC abc digits; + + print string }' > ${text65597} + +head -c 65533 ${text65597} > ${text65533} +head -c 65534 ${text65597} > ${text65534} +pamtopdbimg -uncompressed testgrid.pbm | \ + wc -c | tr -d ' ' + echo ${PIPESTATUS[0]} +pamtopdbimg -uncompressed -notefile=${text65533} testgrid.pbm | \ + wc -c | tr -d ' ' + echo ${PIPESTATUS[0]} +pamtopdbimg -uncompressed -notefile=${text65534} testgrid.pbm | \ + wc -c | tr -d ' ' + echo ${PIPESTATUS[0]} + +rm ${text65533} ${text65534} ${text65597} \ No newline at end of file |