about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2020-11-28 20:49:38 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2020-11-28 20:49:38 +0000
commit400a3b0dd97c190ccfaa0ff7e1888beb2562b850 (patch)
treedc7a41b82a46644d90238d80622a243085657fa2
parentafa1aed43637493282899056bfe9885a61696106 (diff)
downloadnetpbm-mirror-400a3b0dd97c190ccfaa0ff7e1888beb2562b850.tar.gz
netpbm-mirror-400a3b0dd97c190ccfaa0ff7e1888beb2562b850.tar.xz
netpbm-mirror-400a3b0dd97c190ccfaa0ff7e1888beb2562b850.zip
add comprehensive Pamarith tests
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@3990 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--test/Test-Order2
-rw-r--r--test/pamarith-compare-equal.ok58
-rwxr-xr-xtest/pamarith-compare-equal.test75
-rw-r--r--test/pamarith-multiple-input.ok66
-rwxr-xr-xtest/pamarith-multiple-input.test61
-rw-r--r--test/pamarith.ok99
-rwxr-xr-xtest/pamarith.test198
7 files changed, 533 insertions, 26 deletions
diff --git a/test/Test-Order b/test/Test-Order
index 6c553be1..aaf46985 100644
--- a/test/Test-Order
+++ b/test/Test-Order
@@ -94,6 +94,8 @@ pgmbentley.test
 
 pamfunc.test
 pamarith.test
+pamarith-compare-equal.test
+pamarith-multiple-input.test
 
 pamenlarge.test
 pamenlarge-pbm.test
diff --git a/test/pamarith-compare-equal.ok b/test/pamarith-compare-equal.ok
new file mode 100644
index 00000000..ef1c2981
--- /dev/null
+++ b/test/pamarith-compare-equal.ok
@@ -0,0 +1,58 @@
+Test 1
+1:P3
+1:8 8
+1:2
+8:1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
+1:P3
+1:8 8
+1:2
+5:0 0 2 0 0 2 0 0 2 0 0 2 0 0 2 2 0 2 2 0 2 2 0 2 
+3:2 0 2 2 0 2 2 0 2 2 0 2 2 0 2 2 0 0 2 0 0 2 0 0 
+Test 2
+1:P3
+1:8 8
+1:1
+8:1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
+1:P3
+1:8 8
+1:1
+8:0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
+Test 3
+1:P1
+1:14 16
+16:00000000000000
+1:P1
+1:14 16
+16:11111111111111
+1:P1
+1:14 16
+8:10101010101010 11111111111111
+1:P1
+1:14 16
+8:01010101010101 00000000000000
+Test 4
+1:P2
+1:14 16
+1:2
+16:1 1 1 1 1 1 1 1 1 1 1 1 1 1 
+1:P2
+1:14 16
+1:2
+8:0 2 0 2 0 2 0 2 0 2 0 2 0 2  0 0 0 0 0 0 0 0 0 0 0 0 0 0 
+1:P2
+1:14 16
+1:2
+8:0 1 0 1 0 1 0 1 0 1 0 1 0 1  0 0 0 0 0 0 0 0 0 0 0 0 0 0 
+1:P2
+1:14 16
+1:2
+8:1 2 1 2 1 2 1 2 1 2 1 2 1 2  1 1 1 1 1 1 1 1 1 1 1 1 1 1 
+Test 5
+Should produce 1285449498 54
+1285449498 54
+1285449498 54
+1285449498 54
+1285449498 54
+Should produce 244506188 54
+244506188 54
+244506188 54
diff --git a/test/pamarith-compare-equal.test b/test/pamarith-compare-equal.test
new file mode 100755
index 00000000..903ad538
--- /dev/null
+++ b/test/pamarith-compare-equal.test
@@ -0,0 +1,75 @@
+#! /bin/bash
+# This script tests: pamarith
+# Also requires: ppmpat pnminvert pbmmake pgmmake
+
+tmpdir=${tmpdir:-/tmp}
+input1_ppm=${tmpdir}/input1.ppm
+input2_ppm=${tmpdir}/input2.ppm
+
+echo "Test 1"
+
+ppmpat -tartan -color=rgb:00/80/ff,rgb:80/ff/00,rgb:ff/00/80 \
+   8 8  > ${input1_ppm}
+ppmpat -tartan -color=rgb:80/ff/00,rgb:ff/00/80,rgb:00/80/ff \
+   8 8  > ${input2_ppm}
+
+pamarith -compare -plain ${input1_ppm} ${input1_ppm} | \
+  uniq -c | sed -e 's/^ *//' -e 's/ /:/'
+pamarith -compare -plain ${input1_ppm} ${input2_ppm} | \
+  uniq -c | sed -e 's/^ *//' -e 's/ /:/'
+
+echo "Test 2"
+
+pamarith -equal -plain ${input1_ppm} ${input1_ppm} | \
+  uniq -c | sed -e 's/^ *//' -e 's/ /:/'
+pamarith -equal -plain ${input1_ppm} ${input2_ppm} | \
+  uniq -c | sed -e 's/^ *//' -e 's/ /:/'
+
+rm ${input1_ppm} ${input2_ppm}
+
+echo "Test 3"
+
+pamarith -equal -plain testgrid.pbm testgrid.pbm  | \
+  uniq -c | sed -e 's/^ *//' -e 's/ /:/'
+pnminvert testgrid.pbm | pamarith -equal -plain testgrid.pbm - | \
+  uniq -c | sed -e 's/^ *//' -e 's/ /:/'
+pbmmake -w 14 16 | pamarith -equal -plain testgrid.pbm - | \
+  awk '{printf("%s%c",$0, NR<3 || NR%2==0 ? "\n" : " ")}' | 
+  uniq -c | sed -e 's/^ *//' -e 's/ /:/'
+pbmmake -b 14 16 | pamarith -equal -plain testgrid.pbm - | \
+  awk '{printf("%s%c",$0, NR<3 || NR%2==0 ? "\n" : " ")}' | 
+  uniq -c | sed -e 's/^ *//' -e 's/ /:/'
+
+echo "Test 4"
+  
+pamarith -compare -plain testgrid.pbm testgrid.pbm  | \
+  uniq -c | sed -e 's/^ *//' -e 's/ /:/'
+pnminvert testgrid.pbm | pamarith -compare -plain testgrid.pbm - | \
+  awk '{printf("%s%c",$0, NR<4 || NR%2==1 ? "\n" : " ")}' | 
+  uniq -c | sed -e 's/^ *//' -e 's/ /:/'
+pbmmake -w 14 16 | pamarith -compare -plain testgrid.pbm - | \
+  awk '{printf("%s%c",$0, NR<4 || NR%2==1 ? "\n" : " ")}' | 
+  uniq -c | sed -e 's/^ *//' -e 's/ /:/'
+pbmmake -b 14 16 | pamarith -compare -plain testgrid.pbm - | \
+  awk '{printf("%s%c",$0, NR<4 || NR%2==1 ? "\n" : " ")}' | 
+  uniq -c | sed -e 's/^ *//' -e 's/ /:/'
+
+
+echo "Test 5"
+# -closeness
+
+input40_pgm=${tmpdir}/input40.pgm
+input50_pgm=${tmpdir}/input50.pgm
+equal_pgm=${tmpdir}/equal.pgm
+
+pgmmake -maxval=99 0.40 7 3 > ${input40_pgm}
+pgmmake -maxval=99 0.50 7 3 > ${input50_pgm}
+
+echo "Should produce 1285449498 54"
+pamarith -equal -plain ${input40_pgm} ${input40_pgm} | cksum
+pamarith -equal -plain -closeness=10.2 ${input40_pgm} ${input50_pgm} | cksum
+pamarith -equal -plain -closeness=11 ${input40_pgm} ${input50_pgm} | cksum
+pamarith -equal -plain -closeness=90 ${input40_pgm} ${input50_pgm} | cksum
+echo "Should produce 244506188 54"
+pamarith -equal -plain ${input40_pgm} ${input50_pgm} | cksum
+pamarith -equal -plain -closeness=09   ${input40_pgm} ${input50_pgm} | cksum
diff --git a/test/pamarith-multiple-input.ok b/test/pamarith-multiple-input.ok
new file mode 100644
index 00000000..3a333058
--- /dev/null
+++ b/test/pamarith-multiple-input.ok
@@ -0,0 +1,66 @@
+Test 1
+1:
+2881377455 188
+2881377455 188
+2:
+2161003541 188
+2161003541 188
+3:
+1352533811 188
+1352533811 188
+4:
+2079203209 188
+2079203209 188
+5:
+108934727 188
+108934727 188
+6:
+755904253 188
+755904253 188
+7:
+2719989180 188
+2719989180 188
+8:
+2305795334 188
+2305795334 188
+9:
+4110388424 188
+4110388424 188
+Test 2
+2285960269 1084
+-or
+2285960269 1084
+2285960269 1084
+2285960269 1084
+-and
+2285960269 1084
+2285960269 1084
+2285960269 1084
+-xor
+2285960269 1084
+2285960269 1084
+Test 3
+-add
+392744294 1084
+392744294 1084
+392744294 1084
+-and
+1732023142 1084
+1732023142 1084
+1732023142 1084
+-or
+549786223 1084
+549786223 1084
+549786223 1084
+-xor
+3485039940 1084
+3485039940 1084
+3485039940 1084
+-nand
+460693232 1084
+460693232 1084
+460693232 1084
+-nor
+1552687097 1084
+1552687097 1084
+1552687097 1084
diff --git a/test/pamarith-multiple-input.test b/test/pamarith-multiple-input.test
new file mode 100755
index 00000000..7df08817
--- /dev/null
+++ b/test/pamarith-multiple-input.test
@@ -0,0 +1,61 @@
+#! /bin/bash
+# This script tests: pamarith
+# Also requires: pgmmake ppmpat pamfunc
+
+tmpdir=${tmpdir:-/tmp}
+
+input1_pgm=${tmpdir}/input1.pgm
+
+
+echo "Test 1"
+# Compare pamarith addition with pamfunc multiplication"
+
+pgmmake -maxval=99 0.01 16 11 > ${input1_pgm}
+
+add_command="pamarith -add "${input1_pgm}
+
+for ((i=1 ; i<10 ; i++ ))
+  do
+  echo ${i}":"
+  add_command=${add_command}" "${input1_pgm}
+  ${add_command} | cksum
+  pamfunc -multiplier=$((i+1)) ${input1_pgm} | cksum
+  done
+
+rm ${input1_pgm}
+
+g2_ppm=${tmpdir}/g2.ppm
+g3_ppm=${tmpdir}/g3.ppm
+
+# Produce test input images with ppmpat
+ppmpat -g2 -color=rgb:00/00/00,rgb:ff/ff/ff 17 21 > ${g2_ppm}
+ppmpat -g3 -color=rgb:ff/00/00,rgb:00/ff/00,rgb:00/00/ff 17 21 > ${g3_ppm}
+
+echo "Test 2"
+
+cat ${g2_ppm} | cksum
+echo "-or"
+pamarith -or   ${g2_ppm} ${g2_ppm} | cksum
+pamarith -or   ${g2_ppm} ${g2_ppm} ${g2_ppm} | cksum
+pamarith -or   ${g2_ppm} ${g2_ppm} ${g2_ppm} ${g2_ppm} | cksum
+echo "-and"
+pamarith -and  ${g2_ppm} ${g2_ppm} | cksum
+pamarith -and  ${g2_ppm} ${g2_ppm} ${g2_ppm} | cksum
+pamarith -and  ${g2_ppm} ${g2_ppm} ${g2_ppm} ${g2_ppm} | cksum
+echo "-xor"
+pamarith -xor  ${g2_ppm} ${g2_ppm} ${g2_ppm} | cksum
+pamarith -xor  ${g2_ppm} ${g2_ppm} ${g2_ppm} ${g2_ppm} ${g2_ppm} | cksum
+
+
+echo "Test 3"
+# Order does not matter
+
+for function in "-add" "-and" "-or" "-xor" "-nand" "-nor"
+  do
+  echo ${function}
+  pamarith ${function} ${g2_ppm} ${g2_ppm} ${g3_ppm} | cksum
+  pamarith ${function} ${g3_ppm} ${g2_ppm} ${g2_ppm} | cksum
+  pamarith ${function} ${g2_ppm} ${g3_ppm} ${g2_ppm} | cksum
+  done
+
+rm ${g2_ppm} ${g3_ppm}
\ No newline at end of file
diff --git a/test/pamarith.ok b/test/pamarith.ok
index 782637d3..0862df8e 100644
--- a/test/pamarith.ok
+++ b/test/pamarith.ok
@@ -49,6 +49,11 @@ P2 16 1 2 0 0 1 2 2 2 2 2 2 2 2 2 2 2 2 2
 196115582 58
 196115582 58
 196115582 58
+-equal
+P2 16 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0  
+4168278327 58
+4168278327 58
+4168278327 58
 -and
 P2 16 1 15 0 0 2 2 0 0 2 2 0 0 2 2 0 0 2 2  
 3660405045 59
@@ -107,6 +112,8 @@ P1 8 1 00000101
 P1 8 1 00000101 
 -compare
 P2 8 1 2 1 0 1 0 2 1 2 1  
+-equal
+P1 8 1 01011010 
 -and
 P1 8 1 01011111 
 -or
@@ -121,7 +128,71 @@ P1 8 1 10100101
 P1 8 1 11110101 
 -shiftright
 P1 8 1 11110101 
-Test 3 (input = output)
+Test 3
+-add
+2442291770 913
+2442291770 913
+2442291770 913
+-multiply
+3074858461 913
+3074858461 913
+3074858461 913
+-difference
+3788637303 913
+3788637303 913
+3788637303 913
+-minimum
+2046561746 913
+2046561746 913
+2046561746 913
+-maximum
+3724820523 913
+3724820523 913
+3724820523 913
+-mean
+5885382 913
+5885382 913
+5885382 913
+-equal
+780857755 911
+780857755 911
+780857755 911
+-and
+889537755 913
+889537755 913
+889537755 913
+-or
+2466056482 913
+2466056482 913
+2466056482 913
+-nand
+3743732043 913
+3743732043 913
+3743732043 913
+-nor
+2027723954 913
+2027723954 913
+2027723954 913
+-xor
+291709067 913
+291709067 913
+291709067 913
+-subtract
+3705429820 913
+3705429820 913
+-divide
+2136905608 913
+2136905608 913
+-compare
+1563790885 911
+1563790885 911
+-shiftleft
+51480286 913
+51480286 913
+-shiftright
+3072492814 913
+3072492814 913
+Test 4 (input = output)
 cksum is 2425386270 41 or 2921940274 59
 input image
 2425386270 41
@@ -147,7 +218,7 @@ input image
 2921940274 59
 -or
 2921940274 59
-Test 4 (blank output)
+Test 5 (blank output)
 cksum is 2817549367 41 or 320101399 59
 -subtract
 2817549367 41
@@ -180,3 +251,27 @@ Expected failure 15 1
 Expected failure 16 1
 Expected failure 17 1
 Expected failure 18 1
+Expected failure 19 1
+Expected failure 20 1
+Expected failure 21 1
+Expected failure 22 1
+Expected failure 23 1
+Expected failure 24 1
+Expected failure 25 1
+Expected failure 26 1
+Expected failure 27 1
+Expected failure 28 1
+Expected failure 29 1
+Expected failure 30 1
+Expected failure 31 1
+Expected failure 32 1
+Expected failure 33 1
+Expected failure 34 1
+Expected failure 35 1
+Expected failure 36 1
+Expected failure 37 1
+Expected failure 38 1
+Expected failure 39 1
+Expected failure 40 1
+Expected failure 41 1
+Expected failure 42 1
diff --git a/test/pamarith.test b/test/pamarith.test
index d8055385..a4c98859 100755
--- a/test/pamarith.test
+++ b/test/pamarith.test
@@ -1,8 +1,7 @@
-
 #! /bin/bash
 # This script tests: pamarith
-# Also requires: pamchannel pamseq pamtopnm pgmmake pnmcat rgb3toppm
-# Also requires: pbmmake pamenlarge
+# Also requires: pamtopnm rgb3toppm pamenlarge pnmcat pamseq pbmmake pgmmake 
+# Also requires: ppmpat pamchannel 
 
 tmpdir=${tmpdir:-/tmp}
 input1_pgm=${tmpdir}/input1.pgm
@@ -22,7 +21,7 @@ rgb3toppm ${input2_pgm} ${input2_pgm} ${input2_pgm} > ${input2_ppm}
 pnmcat -tb -plain ${input1_pgm} ${input2_pgm}
 
 for fn in "-add" "-subtract" "-multiply" "-divide" "-difference" \
-    "-minimum" "-maximum" "-mean" "-compare" \
+    "-minimum" "-maximum" "-mean" "-compare" "-equal" \
     "-and" "-or" "-nand" "-nor"  "-xor" \
     "-shiftleft" "-shiftright"
   do
@@ -36,7 +35,6 @@ for fn in "-add" "-subtract" "-multiply" "-divide" "-difference" \
 
 rm ${input1_pgm} ${input2_pgm} ${output_pgm} ${input2_ppm}
 
-
 input1_pbm=${tmpdir}/input1.pbm
 input2_pbm=${tmpdir}/input2.pbm
 
@@ -48,7 +46,7 @@ pbmmake -g 2 1 | pamenlarge -xscale=4 > ${input2_pbm}
 pnmcat -tb -plain ${input1_pbm} ${input2_pbm}
 
 for fn in "-add" "-subtract" "-multiply" "-divide" "-difference" \
-    "-minimum" "-maximum" "-mean" "-compare" \
+    "-minimum" "-maximum" "-mean" "-compare" "-equal" \
     "-and" "-or" "-nand" "-nor"  "-xor" \
     "-shiftleft" "-shiftright"
   do
@@ -58,8 +56,38 @@ for fn in "-add" "-subtract" "-multiply" "-divide" "-difference" \
 
 rm ${input1_pbm} ${input2_pbm}
 
+echo "Test 3"
+
+input3_ppm=${tmpdir}/input3.ppm
+input4_ppm=${tmpdir}/input4.ppm
+input4_pgm=${tmpdir}/input4.pgm
+
+ppmpat -tartan  -color=rgb:f0/f0/00,rgb:80/00/80,rgb:0f/00/0f 20 15 \
+  > ${input3_ppm}
+ppmpat -argyle2 -color=rgb:01/01/01,rgb:02/02/02,rgb:05/05/05 20 15 \
+  > ${input4_ppm}
+pamchannel -infile ${input4_ppm} 0 > ${input4_pgm}
+
+for fn in "-add" "-multiply" "-difference" \
+    "-minimum" "-maximum" "-mean" "-equal" \
+    "-and" "-or" "-nand" "-nor" "-xor"
+  do
+  echo ${fn}
+  pamarith ${fn} ${input3_ppm} ${input4_ppm} | cksum
+  pamarith ${fn} ${input4_ppm} ${input3_ppm} | cksum
+  pamarith ${fn} ${input3_ppm} ${input4_pgm} | pamtopnm | cksum
+  done
+
+for fn in "-subtract" "-divide" "-compare" "-shiftleft" "-shiftright"
+  do
+  echo ${fn}
+  pamarith ${fn} ${input3_ppm} ${input4_ppm} | cksum
+  pamarith ${fn} ${input3_ppm} ${input4_pgm} | pamtopnm | cksum
+  done
+
+rm ${input3_ppm} ${input4_ppm} ${input4_pgm}
 
-echo "Test 3 (input = output)"
+echo "Test 4 (input = output)"
 echo "cksum is 2425386270 41 or 2921940274 59"
 
 for image in testgrid.pbm ${input1_ppm}
@@ -74,7 +102,7 @@ for image in testgrid.pbm ${input1_ppm}
   done
 
 
-echo "Test 4 (blank output)"
+echo "Test 5 (blank output)"
 echo "cksum is 2817549367 41 or 320101399 59"
 
 for image in testgrid.pbm ${input1_ppm}
@@ -97,6 +125,8 @@ echo "Test Invalid"
 
 output_ppm=${tmpdir}/output.ppm
 
+# multiple functions
+
 pamarith -add -subtract testimg.ppm testimg.ppm > ${output_ppm} || \
   echo -n "Expected failure 1"
   test -s ${output_ppm}; echo " "$?
@@ -112,54 +142,174 @@ pamarith -maximum -mean testimg.ppm testimg.ppm > ${output_ppm} || \
 pamarith -compare -and testimg.ppm testimg.ppm > ${output_ppm} || \
   echo -n "Expected failure 5"
   test -s ${output_ppm}; echo " "$?
-pamarith -or -nand testimg.ppm testimg.ppm > ${output_ppm} || \
+pamarith -compare -equal testimg.ppm testimg.ppm > ${output_ppm} || \
   echo -n "Expected failure 6"
   test -s ${output_ppm}; echo " "$?
-pamarith -nor -xor testimg.ppm testimg.ppm > ${output_ppm} || \
+pamarith -or -nand testimg.ppm testimg.ppm > ${output_ppm} || \
   echo -n "Expected failure 7"
   test -s ${output_ppm}; echo " "$?
-pamarith -shiftleft -shiftright testimg.ppm testimg.ppm > ${output_ppm} || \
+pamarith -nor -xor testimg.ppm testimg.ppm > ${output_ppm} || \
   echo -n "Expected failure 8"
   test -s ${output_ppm}; echo " "$?
-pamarith -add=1 testimg.ppm testimg.ppm > ${output_ppm} || \
+pamarith -shiftleft -shiftright testimg.ppm testimg.ppm > ${output_ppm} || \
   echo -n "Expected failure 9"
   test -s ${output_ppm}; echo " "$?
 
-pamarith -plain testimg.ppm testimg.ppm > ${output_ppm} || \
+# -add does not take a value
+
+pamarith -add=1 testimg.ppm testimg.ppm > ${output_ppm} || \
   echo -n "Expected failure 10"
-  test -s ${output_ppm}; echo " "$?
+ test -s ${output_ppm}; echo " "$?
 
-pamarith testimg.ppm testimg.ppm > ${output_ppm} || \
+# No function
+
+pamarith -plain testimg.ppm testimg.ppm > ${output_ppm} || \
   echo -n "Expected failure 11"
   test -s ${output_ppm}; echo " "$?
 
-pamarith -add testimg.ppm testimg.ppm testimg.ppm > ${output_ppm}
+pamarith testimg.ppm testimg.ppm > ${output_ppm} || \
   echo -n "Expected failure 12"
   test -s ${output_ppm}; echo " "$?
-pamarith -add testimg.ppm > ${output_ppm}
+
+# Just one input image file
+
+pamarith -add testimg.ppm > ${output_ppm} || \
   echo -n "Expected failure 13"
   test -s ${output_ppm}; echo " "$?
-pamarith -add > ${output_ppm}
+
+# No input image file
+
+pamarith -add > ${output_ppm} || \
   echo -n "Expected failure 14"
   test -s ${output_ppm}; echo " "$?
 
-pamarith -add testimg.ppm testgrid.pbm > ${output_ppm}
+# Input images with different depth (number of planes)
+
+pamchannel -infile testimg.ppm 0 1 | \
+  pamarith -add testimg.ppm - > ${output_ppm} || \
   echo -n "Expected failure 15"
   test -s ${output_ppm}; echo " "$?
 
-pamchannel -infile testimg.ppm 0 1 | \
-  pamarith -add testimg.ppm - > ${output_ppm}
+
+# Input images with different x/y dimensions
+
+pamarith -add testimg.ppm testgrid.pbm > ${output_ppm} || \
   echo -n "Expected failure 16"
   test -s ${output_ppm}; echo " "$?
 
 pamenlarge -xscale=2 testgrid.pbm | \
-  pamarith -add testgrid.pbm - > ${output_ppm}
+  pamarith -add testgrid.pbm - > ${output_ppm} || \
   echo -n "Expected failure 17"
   test -s ${output_ppm}; echo " "$?
 
 pamenlarge -yscale=3 testgrid.pbm | \
-  pamarith -add testgrid.pbm - > ${output_ppm}
+  pamarith -add testgrid.pbm - > ${output_ppm} || \
   echo -n "Expected failure 18"
   test -s ${output_ppm}; echo " "$?
 
-rm ${output_ppm}
\ No newline at end of file
+
+# Invalid usage of -closeness
+
+pamarith -equal -closeness=100.1 testgrid.pbm > ${output_ppm} || \
+  echo -n "Expected failure 19"
+  test -s ${output_ppm}; echo " "$?
+pamarith -equal -closeness=-10 testgrid.pbm > ${output_ppm} || \
+  echo -n "Expected failure 20"
+  test -s ${output_ppm}; echo " "$?
+pamarith -closeness -equal testgrid.pbm > ${output_ppm} || \
+  echo -n "Expected failure 21"
+  test -s ${output_ppm}; echo " "$?
+pamarith -compare -closeness=10 testgrid.pbm > ${output_ppm} || \
+  echo -n "Expected failure 22"
+  test -s ${output_ppm}; echo " "$?
+
+# Bit string functions
+# Create PGM test input
+
+input3_pgm=${tmpdir}/input3.pgm
+input4_pgm=${tmpdir}/input4.pgm
+input5_pgm=${tmpdir}/input5.pgm
+
+pgmmake -maxval=4095 1.0 3 1 > ${input3_pgm} 
+pgmmake -maxval=4096 1.0 3 1 > ${input4_pgm}
+pgmmake -maxval=8191 1.0 3 1 > ${input5_pgm}
+
+# Bit string functions - Maxval must match
+
+pamarith -and ${input3_pgm} ${input5_pgm} > ${output_ppm} || \
+  echo -n "Expected failure 23"
+  test -s ${output_ppm}; echo " "$?
+pamarith -or ${input3_pgm} ${input5_pgm} > ${output_ppm} || \
+  echo -n "Expected failure 24"
+  test -s ${output_ppm}; echo " "$?
+pamarith -nand ${input3_pgm} ${input5_pgm} > ${output_ppm} || \
+  echo -n "Expected failure 25"
+  test -s ${output_ppm}; echo " "$?
+pamarith -nor ${input3_pgm} ${input5_pgm} > ${output_ppm} || \
+  echo -n "Expected failure 26"
+  test -s ${output_ppm}; echo " "$?
+pamarith -xor ${input3_pgm} ${input5_pgm} > ${output_ppm} || \
+  echo -n "Expected failure 27"
+  test -s ${output_ppm}; echo " "$?
+
+# Bit string functions - Maxval must be 2^n -1
+
+pamarith -and ${input4_pgm} ${input4_pgm} > ${output_ppm} || \
+  echo -n "Expected failure 28"
+  test -s ${output_ppm}; echo " "$?
+pamarith -or ${input4_pgm} ${input4_pgm} > ${output_ppm} || \
+  echo -n "Expected failure 29"
+  test -s ${output_ppm}; echo " "$?
+pamarith -nand ${input4_pgm} ${input4_pgm} > ${output_ppm} || \
+  echo -n "Expected failure 30"
+  test -s ${output_ppm}; echo " "$?
+pamarith -nor ${input4_pgm} ${input4_pgm} > ${output_ppm} || \
+  echo -n "Expected failure 31"
+  test -s ${output_ppm}; echo " "$?
+pamarith -xor ${input4_pgm} ${input4_pgm} > ${output_ppm} || \
+  echo -n "Expected failure 32"
+  test -s ${output_ppm}; echo " "$?
+
+pamarith -shiftleft ${input4_pgm} ${input4_pgm} > ${output_ppm} || \
+  echo -n "Expected failure 33"
+  test -s ${output_ppm}; echo " "$?
+pamarith -shiftright ${input4_pgm} ${input4_pgm} > ${output_ppm} || \
+  echo -n "Expected failure 34"
+  test -s ${output_ppm}; echo " "$?
+
+rm ${input3_pgm} ${input4_pgm} ${input5_pgm}
+
+# Functions that do not allow more than two input images.
+# Only the functions that are commutative and associative allow
+# three or more inputs.
+
+pamarith -subtract testimg.ppm testimg.ppm testimg.ppm > ${output_ppm} || \
+  echo -n "Expected failure 35"
+  test -s ${output_ppm}; echo " "$?
+pamarith -divide testimg.ppm testimg.ppm testimg.ppm > ${output_ppm} || \
+  echo -n "Expected failure 36"
+  test -s ${output_ppm}; echo " "$?
+pamarith -compare testimg.ppm testimg.ppm testimg.ppm > ${output_ppm} || \
+  echo -n "Expected failure 37"
+  test -s ${output_ppm}; echo " "$?
+pamarith -difference testimg.ppm testimg.ppm testimg.ppm > ${output_ppm} || \
+  echo -n "Expected failure 38"
+  test -s ${output_ppm}; echo " "$?
+pamarith -shiftleft testimg.ppm testimg.ppm testimg.ppm > ${output_ppm} || \
+  echo -n "Expected failure 39"
+  test -s ${output_ppm}; echo " "$?
+pamarith -shiftright testimg.ppm testimg.ppm testimg.ppm > ${output_ppm} || \
+  echo -n "Expected failure 40"
+  test -s ${output_ppm}; echo " "$?
+
+# Currently -equal and -mean do not allow more than two input images.
+# These two cases should be removed once improvements are made.
+
+pamarith -equal testgrid.pbm testgrid.pbm testgrid.pbm > ${output_ppm} || \
+  echo -n "Expected failure 41"
+  test -s ${output_ppm}; echo " "$?
+pamarith -mean testgrid.pbm  testgrid.pbm testgrid.pbm > ${output_ppm} || \
+  echo -n "Expected failure 42"
+  test -s ${output_ppm}; echo " "$?
+
+rm ${output_ppm}