about summary refs log tree commit diff
path: root/test
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2023-08-06 01:54:11 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2023-08-06 01:54:11 +0000
commit5e8f6c0a506db90a88ac975b7beb764568b4b980 (patch)
tree37c038c4b7cb41a5f06beedd546b7abf38650b56 /test
parent3f183168c393a7d67ff8afc751496aa3079bf3e5 (diff)
downloadnetpbm-mirror-5e8f6c0a506db90a88ac975b7beb764568b4b980.tar.gz
netpbm-mirror-5e8f6c0a506db90a88ac975b7beb764568b4b980.tar.xz
netpbm-mirror-5e8f6c0a506db90a88ac975b7beb764568b4b980.zip
Add pamstack test
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@4577 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'test')
-rw-r--r--test/Test-Order1
-rw-r--r--test/pamstack.ok38
-rwxr-xr-xtest/pamstack.test125
3 files changed, 164 insertions, 0 deletions
diff --git a/test/Test-Order b/test/Test-Order
index 16eeaf8e..cef89618 100644
--- a/test/Test-Order
+++ b/test/Test-Order
@@ -89,6 +89,7 @@ pambackground.test
 pnmpad-reportonly.test
 pnmpaste-pbm.test
 
+pamstack.test
 pamrestack.test
 pamshuffle.test
 ppmshift.test
diff --git a/test/pamstack.ok b/test/pamstack.ok
new file mode 100644
index 00000000..881cb6c5
--- /dev/null
+++ b/test/pamstack.ok
@@ -0,0 +1,38 @@
+test 0: Should print 1652911383 4046
+1652911383 4046
+test 1: Should print 1398841785 13544 three times
+1398841785 13544
+1398841785 13544
+1398841785 13544
+test 2: Should print 210239904 3186 five times
+210239904 3186
+210239904 3186
+210239904 3186
+210239904 3186
+210239904 3186
+test 3: maxval should be 65535
+stdin:	PAM, 14 by 16 by 6 maxval 65535
+    Tuple type: 
+stdin:	PAM, 14 by 16 by 6 maxval 65535
+    Tuple type: 
+stdin:	PAM, 14 by 16 by 5 maxval 65535
+    Tuple type: 
+stdin:	PAM, 14 by 16 by 2 maxval 65535
+    Tuple type: 
+test 4: maxval should be 255 then 767
+stdin:	PAM, 14 by 16 by 2 maxval 255
+    Tuple type: 
+stdin:	PAM, 14 by 16 by 2 maxval 767
+    Tuple type: 
+test 5: Should print 2741208386 719 twice
+2741208386 719
+2741208386 719
+test 6: Should print true four times
+true
+true
+true
+true
+Test Invalid
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
diff --git a/test/pamstack.test b/test/pamstack.test
new file mode 100755
index 00000000..7c375b12
--- /dev/null
+++ b/test/pamstack.test
@@ -0,0 +1,125 @@
+#! /bin/sh
+# This script tests: pamstack
+# Also requires: pamdepth pgmmake pamfile
+
+tmpdir=${tmpdir:-/tmp}
+i1_pgm=${tmpdir}/testimg_1.pnm
+i2_pgm=${tmpdir}/testimg_2.pgm
+i7_pgm=${tmpdir}/testimg_7.pgm
+i31_pgm=${tmpdir}/testimg_31.pgm
+std_pgm=${tmpdir}/testimg_255.pgm
+max_pgm=${tmpdir}/testimg_max.pgm
+
+maze2_pbm=${tmpdir}/testimg_maze2.pgm
+maze3_pbm=${tmpdir}/testimg_maze3.pgm
+
+pamdepth 1 testgrid.pbm > ${i1_pgm}
+pgmmake -maxval=2 0 14 16 > ${i2_pgm}
+pgmmake -maxval=7 0.5 14 16 > ${i7_pgm}
+pgmmake -maxval=31 0.5 14 16 > ${i31_pgm}
+pgmmake -maxval=255 0.5 14 16 > ${std_pgm}
+pgmmake -maxval=65535 0.5 14 16 > ${max_pgm}
+cat maze.pbm maze.pbm > ${maze2_pbm}
+cat maze.pbm maze.pbm maze.pbm > ${maze3_pbm}
+
+# test 0
+echo test 0: Should print 1652911383 4046
+
+# Test the integrity of the input files
+cat ${i1_pgm} ${i2_pgm} ${i7_pgm} ${i31_pgm} ${std_pgm} ${max_pgm} \
+    ${maze2_pbm} ${maze3_pbm}| cksum
+
+# test 1
+echo test 1: Should print 1398841785 13544 three times
+pamstack ${maze2_pbm} ${maze2_pbm} | cksum
+pamstack ${maze3_pbm} ${maze2_pbm} | cksum
+pamstack ${maze2_pbm} ${maze3_pbm} | cksum
+
+rm ${maze2_pbm} ${maze3_pbm}
+
+# test 2
+echo test 2: Should print 210239904 3186 five times
+pamstack -firstmaxval ${max_pgm} ${std_pgm} ${i31_pgm} \
+                      ${i7_pgm} ${i2_pgm} ${i1_pgm} ${i1_pgm} | cksum
+pamstack -firstmaxval ${max_pgm} ${std_pgm} ${i31_pgm} \
+	              ${i7_pgm} ${i2_pgm} ${i1_pgm} testgrid.pbm | cksum
+
+pamstack -lcmmaxval   ${max_pgm} ${std_pgm} ${i31_pgm} \
+	              ${i7_pgm} ${i2_pgm} ${i1_pgm} ${i1_pgm} | cksum
+pamstack ${i1_pgm} ${i1_pgm} |\
+  pamstack -firstmaxval ${max_pgm} ${std_pgm} ${i31_pgm} ${i7_pgm} ${i2_pgm} - | cksum
+pamstack -firstmaxval ${i2_pgm} testgrid.pbm ${i1_pgm} |\
+  pamstack -firstmaxval ${max_pgm} ${std_pgm} ${i31_pgm} ${i7_pgm} - | cksum
+
+
+# test 3
+echo test 3: maxval should be 65535
+pamstack -firstmaxval ${max_pgm} ${std_pgm} ${i31_pgm} \
+	              ${i7_pgm} ${i2_pgm} ${i1_pgm} | pamfile
+
+pamstack -lcmmaxval ${max_pgm} ${std_pgm} ${i31_pgm} \
+	            ${i7_pgm} ${i2_pgm} ${i1_pgm} | pamfile
+
+pamstack -lcmmaxval ${max_pgm} ${std_pgm} ${i31_pgm} ${i7_pgm} ${i1_pgm} | pamfile
+
+pamstack -firstmaxval ${max_pgm} ${i2_pgm} | pamfile
+
+
+# test 4
+echo test 4: maxval should be 255 then 767
+pamstack -firstmaxval ${std_pgm} ${i2_pgm} | pamfile
+pamstack -lcmmaxval ${std_pgm} ${i2_pgm} | pamfile
+
+# test 5
+echo test 5: Should print 2741208386 719 twice
+
+pamstack -lcmmaxval   ${i31_pgm} ${i1_pgm} ${i7_pgm} | cksum
+pamstack -firstmaxval ${i31_pgm} ${i1_pgm} ${i7_pgm}  | cksum
+
+# test 6
+echo test 6: Should print true four times
+
+s0=$(pamstack ${i1_pgm} | pamfile)
+s1=$(pamstack -lcmmaxval ${i1_pgm} | pamfile)
+s2=$(pamstack -firstmaxval ${i1_pgm} | pamfile)
+
+test "$s0" = "$s1" && echo "true" || echo "false"
+test "$s0" = "$s2" && echo "true" || echo "false"
+
+
+s0=$(pamstack ${std_pgm} | pamfile)
+s1=$(pamstack -lcmmaxval ${std_pgm} | pamfile)
+s2=$(pamstack -firstmaxval ${std_pgm} | pamfile)
+
+test "$s0" = "$s1" && echo "true" || echo "false"
+test "$s0" = "$s2" && echo "true" || echo "false"
+  
+
+# Test Invalid
+echo "Test Invalid"
+
+echo 1>&2
+echo "Invalid command-line argument combinations." 1>&2
+echo "Error messages should appear below the line." 1>&2
+echo "-----------------------------------------------------------" 1>&2
+
+test_out=${tmpdir}/test_out
+
+pamstack testgrid.pbm testimg.ppm > ${test_out} || \
+  printf "Expected failure 1 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamstack ${i1_pgm} ${std_pgm} > ${test_out} || \
+  printf "Expected failure 2 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+pamstack -lcmmaxval -firstmaxval testgrid.pbm testgrid.pbm > ${test_out} || \
+  printf "Expected failure 3 "
+  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  rm -f ${test_out}
+
+  
+rm ${i1_pgm} ${i2_pgm} ${i7_pgm} ${i31_pgm} ${std_pgm} ${max_pgm}
+