about summary refs log tree commit diff
path: root/test
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2020-09-07 16:02:14 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2020-09-07 16:02:14 +0000
commit333b03c6e0d8632b78db542c08119323a24af383 (patch)
treeb6d575a283dde402d099ed2b425b8df0fd1b6ee2 /test
parent51b81f893ead8949ebbcbc3e888269071909d7ce (diff)
downloadnetpbm-mirror-333b03c6e0d8632b78db542c08119323a24af383.tar.gz
netpbm-mirror-333b03c6e0d8632b78db542c08119323a24af383.tar.xz
netpbm-mirror-333b03c6e0d8632b78db542c08119323a24af383.zip
new tests
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@3949 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'test')
-rw-r--r--test/Test-Order7
-rw-r--r--test/channel-stack-roundtrip.ok11
-rwxr-xr-xtest/channel-stack-roundtrip.test34
-rw-r--r--test/pamarith.ok149
-rwxr-xr-xtest/pamarith.test104
-rw-r--r--test/pamfunc.ok80
-rwxr-xr-xtest/pamfunc.test88
-rw-r--r--test/winicon-roundtrip.ok14
-rwxr-xr-xtest/winicon-roundtrip.test42
-rw-r--r--test/winicon-roundtrip2.ok80
-rwxr-xr-xtest/winicon-roundtrip2.test150
11 files changed, 747 insertions, 12 deletions
diff --git a/test/Test-Order b/test/Test-Order
index 7bc0d02f..6c553be1 100644
--- a/test/Test-Order
+++ b/test/Test-Order
@@ -92,6 +92,9 @@ ppmdim.test
 pnmshear.test
 pgmbentley.test
 
+pamfunc.test
+pamarith.test
+
 pamenlarge.test
 pamenlarge-pbm.test
 
@@ -150,9 +153,10 @@ enlarge-reduce-roundtrip.test
 cut-cat-roundtrip.test
 pamhue-roundtrip.test
 
-# Round-trip tests: miscellaneous utility
+# Round-trip tests: miscellaneous utilities
 
 pamexec-roundtrip.test
+channel-stack-roundtrip.test
 
 # Round-trip tests : lossless converters
 
@@ -203,6 +207,7 @@ tiff-flate-lzw-roundtrip.test
 utahrle-roundtrip.test
 wbmp-roundtrip.test
 winicon-roundtrip.test
+winicon-roundtrip2.test
 xbm-roundtrip.test
 xpm-roundtrip.test
 xv-roundtrip.test
diff --git a/test/channel-stack-roundtrip.ok b/test/channel-stack-roundtrip.ok
new file mode 100644
index 00000000..708305f1
--- /dev/null
+++ b/test/channel-stack-roundtrip.ok
@@ -0,0 +1,11 @@
+Test 1: should print 1873848880 101532 twice, then 0
+1873848880 101532
+1873848880 101532
+1873848880 101532
+1873848880 101532
+1873848880 101532
+0
+Test 2: Should print 447072062 33892 three times
+447072062 33892
+447072062 33892
+447072062 33892
diff --git a/test/channel-stack-roundtrip.test b/test/channel-stack-roundtrip.test
new file mode 100755
index 00000000..dae64605
--- /dev/null
+++ b/test/channel-stack-roundtrip.test
@@ -0,0 +1,34 @@
+#! /bin/bash
+# This script tests: pamchanel pamstack
+# Also requires: pamtopam pamstack pamtopnm
+
+tmpdir=${tmpdir:-/tmp}
+r_pam=${tmpdir}/testimg_r.pam
+g_pam=${tmpdir}/testimg_g.pam
+b_pam=${tmpdir}/testimg_b.pam
+rgb_pam=${tmpdir}/testimg_rgb.pam
+
+echo "Test 1: should print 1873848880 101532 twice, then 0"
+
+pamchannel -tupletype="GRAYSCALE" -infile testimg.ppm 0 > ${r_pam}
+pamchannel -tupletype="GRAYSCALE" -infile testimg.ppm 1 > ${g_pam}
+pamchannel -tupletype="GRAYSCALE" -infile testimg.ppm 2 > ${b_pam}
+
+pamtopam < testimg.ppm | pamstack -tupletype="RGB" - | cksum
+pamstack ${r_pam} ${g_pam} | \
+pamstack -tupletype="RGB" - ${b_pam} | cksum
+pamstack ${r_pam} | \
+pamstack -tupletype="RGB" - ${g_pam} ${b_pam} | cksum
+pamstack ${r_pam} ${b_pam} ${g_pam} ${b_pam} ${b_pam} ${b_pam} | \
+  pamchannel -tupletype="RGB" 0 2 4 | cksum 
+pamstack -tupletype="RGB" ${r_pam} ${g_pam} ${b_pam} | tee ${rgb_pam} | cksum
+pamtopnm ${rgb_pam} | cmp - testimg.ppm
+echo $?
+
+echo "Test 2: Should print 447072062 33892 three times"
+
+cat ${r_pam} | cksum
+pamstack -tupletype="GRAYSCALE" ${r_pam} | cksum
+pamstack ${r_pam} | pamchannel -tupletype="GRAYSCALE" 0 | cksum
+
+rm ${r_pam} ${g_pam} ${b_pam} ${rgb_pam}
diff --git a/test/pamarith.ok b/test/pamarith.ok
new file mode 100644
index 00000000..a86b0260
--- /dev/null
+++ b/test/pamarith.ok
@@ -0,0 +1,149 @@
+Test 1
+P2
+16 2
+15
+0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
+2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
+-add
+P2 16 1 15 2 3 4 5 6 7 8 9 10 11 12 13 14 15 15 15  
+1927712885 59
+1927712885 59
+1927712885 59
+-subtract
+P2 16 1 15 0 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13  
+622443613 59
+622443613 59
+622443613 59
+-multiply
+P2 16 1 15 0 0 0 0 1 1 1 1 1 1 1 1 2 2 2 2  
+1589721418 59
+1589721418 59
+1589721418 59
+-divide
+P2 16 1 15 0 8 15 15 15 15 15 15 15 15 15 15 15 15 15 15  
+321546811 59
+321546811 59
+321546811 59
+-difference
+P2 16 1 15 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13  
+590140907 59
+590140907 59
+590140907 59
+-minimum
+P2 16 1 15 0 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2  
+3746423180 59
+3746423180 59
+3746423180 59
+-maximum
+P2 16 1 15 2 2 2 3 4 5 6 7 8 9 10 11 12 13 14 15  
+201376294 59
+201376294 59
+201376294 59
+-mean
+P2 16 1 15 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9  
+1456675831 59
+1456675831 59
+1456675831 59
+-compare
+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
+-and
+P2 16 1 15 0 0 2 2 0 0 2 2 0 0 2 2 0 0 2 2  
+3660405045 59
+3660405045 59
+3660405045 59
+-or
+P2 16 1 15 2 3 2 3 6 7 6 7 10 11 10 11 14 15 14 15  
+157317791 59
+157317791 59
+157317791 59
+-nand
+P2 16 1 15 15 15 13 13 15 15 13 13 15 15 13 13 15 15 13 13  
+1625584307 59
+1625584307 59
+1625584307 59
+-nor
+P2 16 1 15 13 12 13 12 9 8 9 8 5 4 5 4 1 0 1 0  
+3014218009 59
+3014218009 59
+3014218009 59
+-xor
+P2 16 1 15 2 3 0 1 6 7 4 5 10 11 8 9 14 15 12 13  
+3227090877 59
+3227090877 59
+3227090877 59
+-shiftleft
+P2 16 1 15 0 4 8 12 0 4 8 12 0 4 8 12 0 4 8 12  
+952940636 59
+952940636 59
+952940636 59
+-shiftright
+P2 16 1 15 0 0 0 0 1 1 1 1 2 2 2 2 3 3 3 3  
+2898922266 59
+2898922266 59
+2898922266 59
+Test 2 (input = output)
+cksum is 2425386270 41 or 2921940274 59
+input image
+2425386270 41
+-minimum
+2425386270 41
+-maximum
+2425386270 41
+-mean
+2425386270 41
+-and
+2425386270 41
+-or
+2425386270 41
+input image
+2921940274 59
+-minimum
+2921940274 59
+-maximum
+2921940274 59
+-mean
+2921940274 59
+-and
+2921940274 59
+-or
+2921940274 59
+Test 3 (blank output)
+cksum is 2817549367 41 or 320101399 59
+-subtract
+2817549367 41
+-difference
+2817549367 41
+-xor
+2817549367 41
+-subtract
+320101399 59
+-difference
+320101399 59
+-xor
+320101399 59
+Test Error: Should print 1 twenty-two times
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
diff --git a/test/pamarith.test b/test/pamarith.test
new file mode 100755
index 00000000..72d3d503
--- /dev/null
+++ b/test/pamarith.test
@@ -0,0 +1,104 @@
+#! /bin/bash
+# This script tests: pamarith
+# Also requires: pamchannel pamseq pamtopnm pgmmake pnmcat rgb3toppm
+
+tmpdir=${tmpdir:-/tmp}
+input1_pgm=${tmpdir}/input1.pgm
+input2_pgm=${tmpdir}/input2.pgm
+output_pgm=${tmpdir}/output.pgm
+input1_ppm=${tmpdir}/input1.ppm
+input2_ppm=${tmpdir}/input2.ppm
+
+echo "Test 1"
+
+pamseq 1 15 | pamtopnm -assume > ${input1_pgm}
+pgmmake -maxval 15 0.15 16 1 > ${input2_pgm}
+
+rgb3toppm ${input1_pgm} ${input1_pgm} ${input1_pgm} > ${input1_ppm} 
+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" \
+    "-and" "-or" "-nand" "-nor"  "-xor" \
+    "-shiftleft" "-shiftright"
+  do
+  echo ${fn}
+  pamarith ${fn} -plain ${input1_pgm} ${input2_pgm} | tr '\n' ' '; echo
+  pamarith ${fn} ${input1_pgm} ${input2_pgm} > ${output_pgm}
+  rgb3toppm  ${output_pgm} ${output_pgm} ${output_pgm} | cksum
+  pamarith ${fn} ${input1_ppm} ${input2_pgm} | cksum
+  pamarith ${fn} ${input1_ppm} ${input2_ppm} | cksum
+  done
+
+rm ${input1_pgm} ${input2_pgm} ${output_pgm} ${input2_ppm}
+
+echo "Test 2 (input = output)"
+echo "cksum is 2425386270 41 or 2921940274 59"
+
+for image in testgrid.pbm ${input1_ppm}
+  do
+  echo "input image"
+  cat ${image} | cksum 
+  for fn in "-minimum" "-maximum" "-mean" "-and" "-or"
+    do
+    echo ${fn}
+    pamarith ${fn} ${image} ${image} | cksum
+    done
+  done
+
+
+echo "Test 3 (blank output)"
+echo "cksum is 2817549367 41 or 320101399 59"
+
+for image in testgrid.pbm ${input1_ppm}
+  do
+  for fn in "-subtract" "-difference" "-xor"
+    do
+    echo ${fn}
+    pamarith ${fn} ${image} ${image} | cksum
+    done
+  done
+
+rm ${input1_ppm}
+
+
+echo "Invalid command-line argument combinations." 1>&2
+echo "Error messages should appear below the line." 1>&2
+echo "-----------------------------------------------------------" 1>&2
+
+echo "Test Error: Should print 1 twenty-two times"
+
+output_ppm=${tmpdir}/output.ppm
+
+for option in "-add -subtract" \
+    "-multiply -divide" \
+    "-difference -minimum" \
+    "-maximum -mean" \
+    "-compare -and" \
+    "-or -nand" \
+    "-nor -xor" \
+    "-shiftleft -shiftright"
+  do
+  pamarith ${option} testimg.ppm testimg.ppm > ${output_ppm}
+    echo $?
+    test -s ${output_ppm}
+    echo $?
+  done
+
+  pamarith -add testimg.ppm testimg.ppm testimg.ppm > ${output_ppm}
+    echo $?
+    test -s ${output_ppm}
+    echo $?
+  pamarith -add testimg.ppm testgrid.pbm > ${output_ppm}
+    echo $?
+    test -s ${output_ppm}
+    echo $?
+  pamchannel -infile testimg.ppm 0 1 | \
+    pamarith -add testimg.ppm - > ${output_ppm}
+    echo $?
+    test -s ${output_ppm}
+    echo $?
+
+rm ${output_ppm}
\ No newline at end of file
diff --git a/test/pamfunc.ok b/test/pamfunc.ok
new file mode 100644
index 00000000..50336866
--- /dev/null
+++ b/test/pamfunc.ok
@@ -0,0 +1,80 @@
+Test 1
+P2 16 1 15 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15  
+P2 16 1 15 3 4 5 6 7 8 9 10 11 12 13 14 15 15 15 15  
+P2 16 1 15 0 0 0 0 1 2 3 4 5 6 7 8 9 10 11 12  
+P2 16 1 15 0 3 6 9 12 15 15 15 15 15 15 15 15 15 15 15  
+P2 16 1 15 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8  
+P2 16 1 15 0 1 2 3 4 5 6 6 6 6 6 6 6 6 6 6  
+P2 16 1 15 5 5 5 5 5 5 6 7 8 9 10 11 12 13 14 15  
+P2 16 1 15 0 2 4 6 8 10 12 14 0 2 4 6 8 10 12 14  
+P2 16 1 15 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7  
+P2 16 1 15 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7  
+P2 16 1 15 0 0 2 2 4 4 6 6 8 8 10 10 12 12 14 14  
+Test 2 (-changemaxval)
+P2 16 1 30 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15  
+P2 16 1 60 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15  
+Test 3: Should print 1926073387 101484 eight times
+1926073387 101484
+1926073387 101484
+1926073387 101484
+1926073387 101484
+1926073387 101484
+1926073387 101484
+1926073387 101484
+1926073387 101484
+Test 4: Should print 2425386270 41 six times
+2425386270 41
+2425386270 41
+2425386270 41
+2425386270 41
+2425386270 41
+2425386270 41
+Test Error: Should print 0 then 1 twenty-four times
+0
+1
+0
+1
+0
+1
+0
+1
+0
+1
+0
+1
+0
+1
+0
+1
+0
+1
+0
+1
+0
+1
+0
+1
+0
+1
+0
+1
+0
+1
+0
+1
+0
+1
+0
+1
+0
+1
+0
+1
+0
+1
+0
+1
+0
+1
+0
+1
diff --git a/test/pamfunc.test b/test/pamfunc.test
new file mode 100755
index 00000000..2271974e
--- /dev/null
+++ b/test/pamfunc.test
@@ -0,0 +1,88 @@
+#! /bin/bash
+# This script tests: pamfunc
+# Also requires: pamseq pamtopnm
+
+tmpdir=${tmpdir:-/tmp}
+input_pgm=${tmpdir}/input.pgm
+
+echo "Test 1"  
+
+pamseq 1 15 | pamtopnm -assume > ${input_pgm}
+pamtopnm -plain ${input_pgm} | tr '\n' ' '; echo
+
+pamfunc -adder=3 -plain ${input_pgm} | tr '\n' ' '; echo
+pamfunc -subtractor=3 -plain ${input_pgm} | tr '\n' ' '; echo
+pamfunc -multiplier=3 -plain ${input_pgm} | tr '\n' ' '; echo
+pamfunc -divisor=2 -plain ${input_pgm} | tr '\n' ' '; echo
+pamfunc -max=6 -plain ${input_pgm} | tr '\n' ' '; echo
+pamfunc -min=5 -plain ${input_pgm} | tr '\n' ' '; echo
+
+pamfunc -shiftleft  1  -plain ${input_pgm} | tr '\n' ' '; echo
+pamfunc -shiftright 1  -plain ${input_pgm} | tr '\n' ' '; echo
+pamfunc -shiftleft  1 ${input_pgm} | pamfunc -shiftright 1 -plain | \
+  tr '\n' ' '; echo
+pamfunc -shiftright 1 ${input_pgm} | pamfunc -shiftleft 1  -plain | \
+  tr '\n' ' '; echo
+
+
+echo "Test 2 (-changemaxval)"
+
+pamfunc -divisor 2 -changemaxval ${input_pgm} -plain | \
+  tr '\n' ' '; echo
+pamfunc -multiplier 0.25 -changemaxval ${input_pgm} -plain | \
+  tr '\n' ' '; echo
+
+rm ${input_pgm}
+
+echo "Test 3: Should print 1926073387 101484 eight times"
+
+cat testimg.ppm | cksum
+
+pamfunc -not testimg.ppm | pamfunc -not | cksum
+pamfunc -andmask 0xff testimg.ppm | cksum
+pamfunc -ormask  0x00 testimg.ppm | cksum
+pamfunc -xormask 0x00 testimg.ppm | cksum
+pamfunc -xormask 0xff testimg.ppm | pamfunc -xormask 0xff | cksum
+pamfunc -shiftleft  0 testimg.ppm | cksum
+pamfunc -shiftright 0 testimg.ppm | cksum
+
+
+echo "Test 4: Should print 2425386270 41 six times"
+
+cat testgrid.pbm | cksum
+
+pamfunc -andmask  0x1 testgrid.pbm | cksum
+pamfunc -ormask   0x0 testgrid.pbm | cksum
+pamfunc -xormask  0x1 testgrid.pbm | pamfunc -xormask 0x1 | cksum
+
+pamfunc -shiftleft  0 testgrid.pbm | cksum
+pamfunc -shiftright 0 testgrid.pbm | cksum
+
+echo "Invalid command-line argument combinations." 1>&2
+echo "Error messages should appear below the line." 1>&2
+echo "-----------------------------------------------------------" 1>&2
+
+echo "Test Error: Should print 0 then 1 twenty-four times"
+
+output_ppm=${tmpdir}/output.ppm
+
+for fn in "-multiplier" "-multiplier=-1" \
+  "-divisor" "-divisor=-20" \
+  "-adder" "-adder 0.5" "-subtractor" "-subtractor 0.1" \
+  "-multiplier=1 -divisor=2" "-adder=2 -subtractor=3" \
+  "-min" "-max" "-andmask" "-ormask" "-xormask" "-not 1" \
+  "-min=1 -max=2"  "-andmask=1 -ormask=0" "-andmask=0xffff" \
+  "-shiftleft" "-shiftright" "-changemaxval" \
+  "-shiftleft=1 -shiftright=1" \
+  "-multiplier=0.5 -changemaxval=65535"
+  do
+
+  # uncomment to debug
+  # echo ${fn}
+
+  pamfunc ${fn} testimg.ppm > ${output_ppm}
+  test $? -eq 1 -o $? -eq 99
+  echo $?
+  test -s ${output_ppm}
+  echo $?
+  done
\ No newline at end of file
diff --git a/test/winicon-roundtrip.ok b/test/winicon-roundtrip.ok
index 8334ff4e..4ba2606e 100644
--- a/test/winicon-roundtrip.ok
+++ b/test/winicon-roundtrip.ok
@@ -1,2 +1,12 @@
-71846281 6925
-326197919 137
+Test 1. Should print 4241318573 6973 four times
+4241318573 6973
+4241318573 6973
+4241318573 6973
+4241318573 6973
+Test 1. Should print 819454437 1093 six times
+819454437 1093
+819454437 1093
+819454437 1093
+819454437 1093
+819454437 1093
+819454437 1093
diff --git a/test/winicon-roundtrip.test b/test/winicon-roundtrip.test
index b37a33e1..00c78400 100755
--- a/test/winicon-roundtrip.test
+++ b/test/winicon-roundtrip.test
@@ -1,13 +1,37 @@
 #! /bin/bash
-# This script tests: pamtowinicon winicontopam
-# Also requires: pamcut pnmtile pamtopnm ppmtopgm pgmtopbm
+# This script tests: pamtowinicon ppmtowinicon winicontopam
+# Also requires: pamchannel pamcut pamdepth pamtopam pngtopam pnmtile pnmtopng
 
+tmpdir=${tmpdir:-/tmp}
+test_pam=${tmpdir}/testimg.pam
 
-pamcut --left=30 --width=48 --height=48 testimg.ppm | \
-pamtowinicon | winicontopam | \
-  pamtopnm | cksum
+echo "Test 1. Should print 4241318573 6973 four times"
 
-pnmtile 32 32 testgrid.pbm | \
-pamtowinicon | winicontopam | \
-  pamtopnm | ppmtopgm | \
-  pgmtopbm  -th -val=0.5 | cksum
+pamcut --left=30 --width=48 --height=48 testimg.ppm | pamtopam | \
+  tee ${test_pam} | cksum
+pamtowinicon ${test_pam} | winicontopam | \
+  pamchannel -tupletype="RGB" 0 1 2 | cksum
+pamtowinicon -pngthreshold=300 ${test_pam} | winicontopam | \
+  pamchannel -tupletype="RGB" 0 1 2 | cksum
+pamtowinicon -pngthreshold=1   ${test_pam} | winicontopam | \
+  pamchannel -tupletype="RGB" 0 1 2 | cksum
+
+rm ${test_pam}
+
+echo "Test 1. Should print 819454437 1093 six times"
+
+pnmtile 32 32 testgrid.pbm | pamtopam | \
+  tee ${test_pam} | cksum
+pamtowinicon ${test_pam} | winicontopam | \
+  pamdepth 1 | pamchannel -tupletype="BLACKANDWHITE" 0 | cksum
+pamtowinicon -pngthreshold=300 ${test_pam} | winicontopam | \
+  pamdepth 1 | pamchannel -tupletype="BLACKANDWHITE" 0 | cksum
+pamtowinicon -pngthreshold=1   ${test_pam} | winicontopam | 
+  pamdepth 1 | pamchannel -tupletype="BLACKANDWHITE" 0 | cksum
+pamtowinicon -pngthreshold=1   ${test_pam} | winicontopam | 
+  pamchannel -tupletype="BLACKANDWHITE" 0 | cksum
+
+rm ${test_pam}
+
+pnmtile 32 32 testgrid.pbm | ppmtowinicon | winicontopam | \
+  pamdepth 1 | pamchannel -tupletype="BLACKANDWHITE" 0 | cksum
diff --git a/test/winicon-roundtrip2.ok b/test/winicon-roundtrip2.ok
new file mode 100644
index 00000000..bb8c77d8
--- /dev/null
+++ b/test/winicon-roundtrip2.ok
@@ -0,0 +1,80 @@
+16 24 32 48 64 : 1 plane
+Should print 2588356089 8591 or 3783949470 69390 four times
+2588356089 8591
+2588356089 8591
+2588356089 8591
+2588356089 8591
+16 24 32 48 64 : 2 planes
+Should print 3357739334 16877 or 3331485515 138534 four times
+3357739334 16877
+3357739334 16877
+3357739334 16877
+3357739334 16877
+16 24 32 48 64 : 3 planes
+Should print 3734212737 25073 or 56221695 207606 four times
+3734212737 25073
+3734212737 25073
+3734212737 25073
+3734212737 25073
+16 24 32 48 64 : 4 planes
+Should print 1294260080 33359 or 732184466 276750 four times
+1294260080 33359
+1294260080 33359
+1294260080 33359
+1294260080 33359
+16 24 32 48 64 : 5 planes: output 3
+Should print 3734212737 25073 or 56221695 207606 four times
+3734212737 25073
+3734212737 25073
+3734212737 25073
+3734212737 25073
+16 24 32 48 64 : 5 planes : output 4
+Should print 2704877198 33359 or 1699833476 276750 four times
+2704877198 33359
+2704877198 33359
+2704877198 33359
+2704877198 33359
+16 24 32 48 64 : 5 planes : output 5
+Should print 2567279592 41655 or 4154838752 345902 twice
+2567279592 41655
+2567279592 41655
+16 32 48 256 : 1 plane
+Should print 2588356089 8591 or 3783949470 69390 four times
+3783949470 69390
+3783949470 69390
+3783949470 69390
+3783949470 69390
+16 32 48 256 : 2 planes
+Should print 3357739334 16877 or 3331485515 138534 four times
+3331485515 138534
+3331485515 138534
+3331485515 138534
+3331485515 138534
+16 32 48 256 : 3 planes
+Should print 3734212737 25073 or 56221695 207606 four times
+56221695 207606
+56221695 207606
+56221695 207606
+56221695 207606
+16 32 48 256 : 4 planes
+Should print 1294260080 33359 or 732184466 276750 four times
+732184466 276750
+732184466 276750
+732184466 276750
+732184466 276750
+16 32 48 256 : 5 planes: output 3
+Should print 3734212737 25073 or 56221695 207606 four times
+56221695 207606
+56221695 207606
+56221695 207606
+56221695 207606
+16 32 48 256 : 5 planes : output 4
+Should print 2704877198 33359 or 1699833476 276750 four times
+1699833476 276750
+1699833476 276750
+1699833476 276750
+1699833476 276750
+16 32 48 256 : 5 planes : output 5
+Should print 2567279592 41655 or 4154838752 345902 twice
+4154838752 345902
+4154838752 345902
diff --git a/test/winicon-roundtrip2.test b/test/winicon-roundtrip2.test
new file mode 100755
index 00000000..ec074055
--- /dev/null
+++ b/test/winicon-roundtrip2.test
@@ -0,0 +1,150 @@
+#! /bin/bash
+# This script tests: pamtowinicon winicontopam
+# Also requires: pamchannel pamdepth pamstack pamtopam pbmmake pngtopam
+# Also requires: pnmtopng ppmpat
+
+tmpdir=${tmpdir:-/tmp}
+test_pam=${tmpdir}/testimg.pam
+test1_pam=${tmpdir}/testimg1.pam
+test2_pam=${tmpdir}/testimg2.pam
+#test3_pam=${tmpdir}/testimg3.pam
+test4_pam=${tmpdir}/testimg4.pam
+test5_pam=${tmpdir}/testimg5.pam
+black_pam=${tmpdir}/black.pam
+white_pam=${tmpdir}/white.pam
+gray_pam=${tmpdir}/gray.pam
+
+# classic: 16 24 32 48 64
+# full: 16 32 48 256
+
+for sizes in "16 24 32 48 64" "16 32 48 256"
+  do
+
+  for size in ${sizes}
+    do
+    ppmpat -tartan -color=rgb:1f/1f/1f,rgb:7f/ff/00,rgb:00/ff/3f \
+      ${size} ${size}
+    done | pamtopam > ${test_pam}
+
+  for size in ${sizes}
+    do
+    pbmmake -black ${size} ${size} | pamdepth 255
+    done | pamtopam > ${black_pam}
+
+  for size in ${sizes}
+    do
+    pbmmake -white ${size} ${size} | pamdepth 255
+    done | pamtopam > ${white_pam}
+
+  for size in ${sizes}
+    do
+    pbmmake -gray ${size} ${size} | pamdepth 255
+    done | pamtopam > ${gray_pam}
+
+# 1 plane
+
+  echo ${sizes} ": 1 plane"
+  echo "Should print 2588356089 8591 or 3783949470 69390 four times"
+
+  pamchannel -tupletype="GRAYSCALE" 0 < ${test_pam} | \
+    tee ${test1_pam} | cksum
+  pamtowinicon ${test1_pam} | winicontopam -allimages | \
+    pamchannel -tupletype="GRAYSCALE" 0 | cksum
+  pamtowinicon -pngthreshold=300 ${test1_pam} | winicontopam -allimages | \
+    pamchannel -tupletype="GRAYSCALE" 0 | cksum
+  pamtowinicon -pngthreshold=1   ${test1_pam} | winicontopam -allimages | \
+    pamchannel -tupletype="GRAYSCALE" 0 | cksum
+
+  rm ${test1_pam}
+
+# 2 planes
+
+  echo ${sizes} ": 2 planes"
+  echo "Should print 3357739334 16877 or 3331485515 138534 four times"
+
+  pamstack ${gray_pam} ${gray_pam} | \
+  pamchannel -tupletype="GRAYSCALE_ALPHA" 0 1 | tee ${test2_pam} | cksum
+  pamtowinicon ${test2_pam} | winicontopam -allimages | \
+    pamchannel -tupletype="GRAYSCALE_ALPHA" 0 1 | cksum
+  pamtowinicon -pngthreshold=300 ${test2_pam} | winicontopam -allimages | \
+    pamchannel -tupletype="GRAYSCALE_ALPHA" 0 1 | cksum
+  pamtowinicon -pngthreshold=1   ${test2_pam} | winicontopam -allimages | \
+    pamchannel -tupletype="GRAYSCALE_ALPHA" 0 1 | cksum
+
+  rm ${test2_pam}
+
+# 3 planes
+
+  echo ${sizes} ": 3 planes"
+  echo "Should print 3734212737 25073 or 56221695 207606 four times"
+
+  pamchannel -tupletype="RGB" 0 1 2 < ${test_pam} | cksum
+  pamtowinicon ${test_pam} | winicontopam -allimages | \
+    pamchannel -tupletype="RGB" 0 1 2 | cksum
+  pamtowinicon -pngthreshold=300 ${test_pam} | winicontopam -allimages | \
+    pamchannel -tupletype="RGB" 0 1 2 | cksum
+  pamtowinicon -pngthreshold=1   ${test_pam} | winicontopam -allimages | \
+    pamchannel -tupletype="RGB" 0 1 2 | cksum
+  
+# 4 planes
+
+  echo ${sizes} ": 4 planes"
+  echo "Should print 1294260080 33359 or 732184466 276750 four times"
+
+  pamdepth 255 ${black_pam} | pamstack ${test_pam} - | \
+  pamchannel -tupletype="RGB_ALPHA" 0 1 2 3 | tee ${test4_pam} | cksum
+  pamtowinicon ${test4_pam} | winicontopam -allimages | \
+    pamchannel -tupletype="RGB_ALPHA" 0 1 2 3 | cksum
+  pamtowinicon -pngthreshold=300 ${test4_pam} | winicontopam -allimages | \
+    pamchannel -tupletype="RGB_ALPHA" 0 1 2 3 | cksum
+  pamtowinicon -pngthreshold=1   ${test4_pam} | winicontopam -allimages | \
+    pamchannel -tupletype="RGB_ALPHA" 0 1 2 3 | cksum
+
+  rm ${test4_pam}
+
+# 5 planes
+
+  echo ${sizes} ": 5 planes: output 3"
+  echo "Should print 3734212737 25073 or 56221695 207606 four times"
+
+  pamstack ${test_pam} ${gray_pam} ${white_pam} | \
+  pamchannel -tupletype="RGB" 0 1 2 | \
+    tee ${test5_pam} | cksum
+  pamtowinicon ${test5_pam} | winicontopam -allimages -andmasks | \
+    pamchannel -tupletype="RGB" 0 1 2 | cksum
+  pamtowinicon -pngthreshold=300 ${test5_pam} | \
+    winicontopam -allimages -andmasks | \
+    pamchannel -tupletype="RGB" 0 1 2 | cksum
+  pamtowinicon -pngthreshold=1   ${test5_pam} | \
+    winicontopam -allimages -andmasks | \
+    pamchannel -tupletype="RGB" 0 1 2 | cksum
+    
+  echo ${sizes} ": 5 planes : output 4"
+  echo "Should print 2704877198 33359 or 1699833476 276750 four times"
+
+  pamstack ${test_pam} ${gray_pam} ${white_pam} | \
+  pamchannel -tupletype="RGB_ALPHA" 0 1 2 3 | \
+    tee ${test5_pam} | cksum
+  pamtowinicon ${test5_pam} | winicontopam -allimages -andmasks | \
+    pamchannel -tupletype="RGB_ALPHA" 0 1 2 3 | cksum
+  pamtowinicon -pngthreshold=300 ${test5_pam} | \
+    winicontopam -allimages -andmasks  | \
+    pamchannel -tupletype="RGB_ALPHA" 0 1 2 3 | cksum
+  pamtowinicon -pngthreshold=1   ${test5_pam} | \
+    winicontopam -allimages -andmasks | \
+    pamchannel -tupletype="RGB_ALPHA" 0 1 2 3 | cksum
+    
+  echo ${sizes} ": 5 planes : output 5"
+  echo "Should print 2567279592 41655 or 4154838752 345902 twice"
+
+  pamstack ${test_pam} ${gray_pam} ${white_pam} | \
+  pamchannel -tupletype="RGB_ALPHA_ANDMASK" 0 1 2 3 4 | \
+    tee ${test5_pam} | cksum
+  pamtowinicon -pngthreshold=300 ${test5_pam} | \
+    winicontopam -allimages -andmasks  | \
+    pamchannel -tupletype="RGB_ALPHA_ANDMASK" 0 1 2 3 4 | cksum
+    
+  rm ${test5_pam}
+
+  rm ${test_pam} ${gray_pam} ${white_pam} ${black_pam}
+done