about summary refs log tree commit diff
path: root/test/pnmpad-format.test
diff options
context:
space:
mode:
Diffstat (limited to 'test/pnmpad-format.test')
-rwxr-xr-xtest/pnmpad-format.test245
1 files changed, 245 insertions, 0 deletions
diff --git a/test/pnmpad-format.test b/test/pnmpad-format.test
new file mode 100755
index 00000000..73ea6d2b
--- /dev/null
+++ b/test/pnmpad-format.test
@@ -0,0 +1,245 @@
+#! /bin/sh
+# This script tests: pnmpad
+# Also requires: pbmmake pgmmake ppmmake pamfile
+
+tmpdir=${tmpdir:-/tmp}
+
+white_pbm=${tmpdir}/white.pbm
+#black_pbm=${tmpdir}/black.pbm
+test127_pgm=${tmpdir}/testimg1.pgm
+test255_pgm=${tmpdir}/testimg2.pgm
+test511_pgm=${tmpdir}/testimg3.pgm
+test127_ppm=${tmpdir}/testimg1.ppm
+test255_ppm=${tmpdir}/testimg2.ppm
+test511_ppm=${tmpdir}/testimg3.ppm
+
+BLACK="rgbi:0.0/0.0/0.0"
+WHITE="rgbi:1.0/1.0/1.0"
+LIGHTGRAY="rgbi:0.6/0.6/0.6"
+LIGHTGRAYv=0.6
+DARKGRAY="rgbi:0.01/0.01/0.01"
+DARKGRAYv=0.01
+PURPLE="rgb:A0/20/F0"
+YELLOW="rgb:FF/FF/00"
+
+pbmmake -w 3 1 > ${white_pbm}
+#pbmmake -b 3 1 > ${black_pbm}
+pgmmake 0.2 3 1 -maxval 127 > ${test127_pgm}
+pgmmake 0.2 3 1 -maxval 255 > ${test255_pgm}
+ppmmake ${YELLOW} 3 1 -maxval 127 > ${test127_ppm}
+ppmmake ${YELLOW} 3 1 -maxval 511 > ${test511_ppm}
+
+# define function
+ckfmt() { pamfile || echo "failure"; }
+
+size="-width 8"
+
+echo "Test 1. PBM infile"
+
+infile=${white_pbm}
+
+echo "Should print: PBM raw, 8 by 1 fourteen times"
+
+pnmpad ${size} ${infile} | ckfmt
+pnmpad ${size} -black ${infile} | ckfmt
+pnmpad ${size} -white ${infile} | ckfmt
+pnmpad ${size} -extend-edge ${infile} | ckfmt
+pnmpad ${size} -detect-background ${infile} | ckfmt
+
+pnmpad ${size} -color ${BLACK} ${infile} | ckfmt
+pnmpad ${size} -color ${BLACK} -promote none   ${infile} | ckfmt
+pnmpad ${size} -color ${BLACK} -promote format ${infile} | ckfmt
+
+pnmpad ${size} -color ${WHITE} ${infile} | ckfmt
+pnmpad ${size} -color ${WHITE} -promote none   ${infile} | ckfmt
+pnmpad ${size} -color ${WHITE} -promote format ${infile} | ckfmt
+
+pnmpad ${size} -color ${LIGHTGRAY} -promote none ${infile} | ckfmt
+pnmpad ${size} -color ${DARKGRAY} -promote none ${infile} | ckfmt
+pnmpad ${size} -color ${PURPLE}   -promote none ${infile} | ckfmt
+
+echo "Should print: PGM raw, 8 by 1  maxval 1 twice"
+
+pnmpad ${size} -color ${LIGHTGRAY} -promote format ${infile} | ckfmt
+pnmpad ${size} -color ${DARKGRAY} -promote format ${infile} | ckfmt
+
+echo "Should print: PGM raw, 8 by 1  maxval 255 twice"
+
+pnmpad ${size} -color ${LIGHTGRAY} ${infile} | ckfmt
+pnmpad ${size} -color ${DARKGRAY} ${infile} | ckfmt
+
+echo "Should print: PPM raw, 8 by 1  maxval 1 once"
+
+pnmpad ${size} -color ${PURPLE} -promote format ${infile} | ckfmt
+
+echo "Should print: PPM raw, 8 by 1  maxval 255 twice"
+
+pnmpad ${size} -color ${PURPLE} ${infile} | ckfmt
+pnmpad ${size} -color ${PURPLE} -promote all ${infile} | ckfmt
+
+rm ${infile}
+
+echo
+echo "Test 2. PGM maxval 127 infile"
+
+infile=${test127_pgm}
+
+echo "Should print: PGM raw, 8 by 1  maxval 127 sixteen times"
+
+pnmpad ${size} ${infile} | ckfmt
+pnmpad ${size} -black ${infile} | ckfmt
+pnmpad ${size} -white ${infile} | ckfmt
+pnmpad ${size} -extend-edge ${infile} | ckfmt
+pnmpad ${size} -detect-background ${infile} | ckfmt
+
+pnmpad ${size} -color ${BLACK} ${infile} | ckfmt
+pnmpad ${size} -color ${BLACK} -promote none   ${infile} | ckfmt
+pnmpad ${size} -color ${BLACK} -promote format ${infile} | ckfmt
+
+pnmpad ${size} -color ${WHITE} ${infile} | ckfmt
+pnmpad ${size} -color ${WHITE} -promote none   ${infile} | ckfmt
+pnmpad ${size} -color ${WHITE} -promote format ${infile} | ckfmt
+
+pnmpad ${size} -color ${LIGHTGRAY} -promote none ${infile} | ckfmt
+pnmpad ${size} -color ${LIGHTGRAY} -promote format ${infile} | ckfmt
+
+pnmpad ${size} -color ${DARKGRAY} -promote none ${infile} | ckfmt
+pnmpad ${size} -color ${DARKGRAY} -promote format ${infile} | ckfmt
+
+pnmpad ${size} -color ${PURPLE}   -promote none ${infile} | ckfmt
+
+echo "Should print: PGM raw, 8 by 1  maxval 255 four times"
+
+pnmpad ${size} -color ${LIGHTGRAY}              ${infile} | ckfmt
+pnmpad ${size} -color ${LIGHTGRAY} -promote all ${infile} | ckfmt
+pnmpad ${size} -color ${DARKGRAY}               ${infile} | ckfmt
+pnmpad ${size} -color ${DARKGRAY}  -promote all ${infile} | ckfmt
+
+echo "Should print: PPM raw, 8 by 1  maxval 127 once"
+
+pnmpad ${size} -color ${PURPLE} -promote format ${infile} | ckfmt
+
+echo "Should print: PPM raw, 8 by 1  maxval 255 twice"
+
+pnmpad ${size} -color ${PURPLE} ${infile} | ckfmt
+pnmpad ${size} -color ${PURPLE} -promote all ${infile} | ckfmt
+
+rm ${infile}
+
+echo
+echo "Test 3. PGM maxval 255 infile"
+
+infile=${test255_pgm}
+
+echo "Should print: PGM raw, 8 by 1  maxval 255 eighteen times"
+
+pnmpad ${size} ${infile} | ckfmt
+pnmpad ${size} -black ${infile} | ckfmt
+pnmpad ${size} -white ${infile} | ckfmt
+pnmpad ${size} -extend-edge ${infile} | ckfmt
+pnmpad ${size} -detect-background ${infile} | ckfmt
+
+pnmpad ${size} -color ${BLACK} ${infile} | ckfmt
+pnmpad ${size} -color ${BLACK} -promote none   ${infile} | ckfmt
+pnmpad ${size} -color ${BLACK} -promote format ${infile} | ckfmt
+pnmpad ${size} -color ${BLACK} -promote all    ${infile} | ckfmt
+
+pnmpad ${size} -color ${LIGHTGRAY} ${infile} | ckfmt
+pnmpad ${size} -color ${LIGHTGRAY} -promote none   ${infile} | ckfmt
+pnmpad ${size} -color ${LIGHTGRAY} -promote format ${infile} | ckfmt
+pnmpad ${size} -color ${LIGHTGRAY} -promote all    ${infile} | ckfmt
+
+
+pnmpad ${size} -color ${DARKGRAY} ${infile} | ckfmt
+pnmpad ${size} -color ${DARKGRAY} -promote none   ${infile} | ckfmt
+pnmpad ${size} -color ${DARKGRAY} -promote format ${infile} | ckfmt
+pnmpad ${size} -color ${DARKGRAY} -promote all    ${infile} | ckfmt
+
+pnmpad ${size} -color ${PURPLE}   -promote none   ${infile} | ckfmt
+
+echo "Should print: PPM raw, 8 by 1  maxval 255 three times"
+
+pnmpad ${size} -color ${PURPLE} ${infile} | ckfmt
+
+pnmpad ${size} -color ${PURPLE} -promote format ${infile} | ckfmt
+pnmpad ${size} -color ${PURPLE} -promote all    ${infile} | ckfmt
+
+rm ${infile}
+
+echo
+echo "Test 4. PPM maxval 127 infile"
+
+infile=${test127_ppm}
+
+echo "Should print: PPM raw, 8 by 1  maxval 127 seventeen times"
+
+pnmpad ${size} ${infile} | ckfmt
+pnmpad ${size} -black ${infile} | ckfmt
+pnmpad ${size} -white ${infile} | ckfmt
+pnmpad ${size} -extend-edge ${infile} | ckfmt
+pnmpad ${size} -detect-background ${infile} | ckfmt
+
+pnmpad ${size} -color ${BLACK} ${infile} | ckfmt
+pnmpad ${size} -color ${BLACK} -promote none   ${infile} | ckfmt
+pnmpad ${size} -color ${BLACK} -promote format ${infile} | ckfmt
+pnmpad ${size} -color ${WHITE} ${infile} | ckfmt
+pnmpad ${size} -color ${WHITE} -promote none   ${infile} | ckfmt
+pnmpad ${size} -color ${WHITE} -promote format ${infile} | ckfmt
+
+pnmpad ${size} -color ${LIGHTGRAY} -promote none   ${infile} | ckfmt
+pnmpad ${size} -color ${LIGHTGRAY} -promote format ${infile} | ckfmt
+pnmpad ${size} -color ${DARKGRAY} -promote none   ${infile} | ckfmt
+pnmpad ${size} -color ${DARKGRAY} -promote format ${infile} | ckfmt
+
+pnmpad ${size} -color ${PURPLE} -promote none   ${infile} | ckfmt
+pnmpad ${size} -color ${PURPLE} -promote format ${infile} | ckfmt
+
+echo "Should print: PPM raw, 8 by 1  maxval 255 five times"
+
+pnmpad ${size} -color ${LIGHTGRAY} ${infile} | ckfmt
+pnmpad ${size} -color ${DARKGRAY}  ${infile} | ckfmt
+pnmpad ${size} -color ${PURPLE}    ${infile} | ckfmt
+pnmpad ${size} -color ${LIGHTGRAY} -promote all ${infile} | ckfmt
+pnmpad ${size} -color ${PURPLE}    -promote all ${infile} | ckfmt
+
+rm ${infile}
+
+echo
+echo "Test 5. PPM maxval 511 infile"
+
+infile=${test511_ppm}
+
+echo "Should print: PPM raw, 8 by 1  maxval 511 twenty-five times"
+
+pnmpad ${size} ${infile} | ckfmt
+pnmpad ${size} -black ${infile} | ckfmt
+pnmpad ${size} -white ${infile} | ckfmt
+pnmpad ${size} -extend-edge ${infile} | ckfmt
+pnmpad ${size} -detect-background ${infile} | ckfmt
+
+pnmpad ${size} -color ${BLACK} ${infile} | ckfmt
+pnmpad ${size} -color ${BLACK} -promote none   ${infile} | ckfmt
+pnmpad ${size} -color ${BLACK} -promote format ${infile} | ckfmt
+pnmpad ${size} -color ${BLACK} -promote all    ${infile} | ckfmt
+
+pnmpad ${size} -color ${WHITE} ${infile} | ckfmt
+pnmpad ${size} -color ${WHITE} -promote none   ${infile} | ckfmt
+pnmpad ${size} -color ${WHITE} -promote format ${infile} | ckfmt
+pnmpad ${size} -color ${WHITE} -promote all    ${infile} | ckfmt
+
+pnmpad ${size} -color ${LIGHTGRAY} ${infile} | ckfmt
+pnmpad ${size} -color ${LIGHTGRAY} -promote none   ${infile} | ckfmt
+pnmpad ${size} -color ${LIGHTGRAY} -promote format ${infile} | ckfmt
+pnmpad ${size} -color ${LIGHTGRAY} -promote all    ${infile} | ckfmt
+
+pnmpad ${size} -color ${DARKGRAY} ${infile} | ckfmt
+pnmpad ${size} -color ${DARKGRAY} -promote none   ${infile} | ckfmt
+pnmpad ${size} -color ${DARKGRAY} -promote format ${infile} | ckfmt
+pnmpad ${size} -color ${DARKGRAY} -promote all    ${infile} | ckfmt
+
+pnmpad ${size} -color ${PURPLE} ${infile} | ckfmt
+pnmpad ${size} -color ${PURPLE} -promote none   ${infile} | ckfmt
+pnmpad ${size} -color ${PURPLE} -promote format ${infile} | ckfmt
+pnmpad ${size} -color ${PURPLE} -promote all    ${infile} | ckfmt
+
+rm ${infile}