about summary refs log tree commit diff
path: root/test
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2014-11-16 19:53:37 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2014-11-16 19:53:37 +0000
commit525bfc8c52ea88c15207de0f83941b3fc515c20b (patch)
treeb7b0f226c88276fb49152bbe271180b74e9a50fb /test
parent1a543185d9f1fcf85598eeeb3fd2325f81af3d7b (diff)
downloadnetpbm-mirror-525bfc8c52ea88c15207de0f83941b3fc515c20b.tar.gz
netpbm-mirror-525bfc8c52ea88c15207de0f83941b3fc515c20b.tar.xz
netpbm-mirror-525bfc8c52ea88c15207de0f83941b3fc515c20b.zip
Add tests for Ppmchange, Pambackground miscellaneous other refinements
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@2314 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'test')
-rw-r--r--test/Test-Order2
-rwxr-xr-xtest/gif-roundtrip.test5
-rw-r--r--test/pambackground.ok3
-rwxr-xr-xtest/pambackground.test42
-rwxr-xr-xtest/pamcrater.test38
-rw-r--r--test/pamenlarge.ok2
-rwxr-xr-xtest/pamenlarge.test9
-rwxr-xr-xtest/png-roundtrip.test2
-rwxr-xr-xtest/ppmchange-roundtrip.test2
-rw-r--r--test/ppmchange.ok4
-rwxr-xr-xtest/ppmchange.test63
-rwxr-xr-xtest/ppmmix.test9
-rwxr-xr-xtest/symmetry.test3
13 files changed, 152 insertions, 32 deletions
diff --git a/test/Test-Order b/test/Test-Order
index cc79570e..7467ba0b 100644
--- a/test/Test-Order
+++ b/test/Test-Order
@@ -55,6 +55,8 @@ pamflip2.test
 pamenlarge.test
 pnminvert.test
 pamchannel.test
+ppmchange.test
+pambackground.test
 
 pbmpscale.test
 pnmremap1.test
diff --git a/test/gif-roundtrip.test b/test/gif-roundtrip.test
index cb62bfb1..8d1a9bbe 100755
--- a/test/gif-roundtrip.test
+++ b/test/gif-roundtrip.test
@@ -27,7 +27,7 @@ test_grn=${tmpdir}/testimg.grn
 test_blu=${tmpdir}/testimg.blu
 out_red=${tmpdir}/out.red
 out_grn=${tmpdir}/out.grn
-out_blu=${tmpdir}/out.blu
+#out_blu=${tmpdir}/out.blu
 
 pamtogif ${test_red} | giftopnm > ${out_red} &&
 pamtogif ${test_grn} | giftopnm > ${out_grn} &&
@@ -35,8 +35,7 @@ pamtogif ${test_blu} | giftopnm | \
   rgb3toppm ${out_red} ${out_grn} - | \
   cksum
 
-rm ${test_ppm} ${test_grn} ${test_blu} \
-   ${out_red} ${out_grn} ${out_blu}
+rm ${test_ppm} ${test_grn} ${test_blu} ${out_red} ${out_grn}
 
 
 # Test 2. Should produce 1571496937 33838
diff --git a/test/pambackground.ok b/test/pambackground.ok
new file mode 100644
index 00000000..acb69bfa
--- /dev/null
+++ b/test/pambackground.ok
@@ -0,0 +1,3 @@
+2155020792 451
+2514682516 33871
+2667595257 17328
diff --git a/test/pambackground.test b/test/pambackground.test
new file mode 100755
index 00000000..58526fdd
--- /dev/null
+++ b/test/pambackground.test
@@ -0,0 +1,42 @@
+#! /bin/bash
+# This script tests: pambackground 
+# Also requires: pamgradient pamseq pbmmake pnmmargin pnmremap pnmtile
+
+  alias pambackground="${PBM_TESTPREFIX}pambackground"
+  alias pamgradient="${PBM_BINPREFIX}pamgradient"
+  alias pamseq="${PBM_BINPREFIX}pamseq"
+  alias pbmmake="${PBM_BINPREFIX}pbmmake"
+  alias pnmmargin="${PBM_BINPREFIX}pnmmargin"
+  alias pnmremap="${PBM_BINPREFIX}pnmremap"
+  alias pnmtile="${PBM_BINPREFIX}pnmtile"
+  shopt -s expand_aliases
+
+tmpdir=${tmpdir:-/tmp}
+
+# Test 1.
+# Should produce: 2155020792 451
+pbmmake -g 23 11 | pnmmargin -black 2 | pambackground | cksum
+
+
+# Test 2.
+# Should produce: 2514682516 33871
+ibmttl_pam=${tmpdir}/ibmttl.pam
+
+pamseq 3 1 > ${ibmttl_pam} && \
+pnmremap -quiet -mapfile ${ibmttl_pam} testimg.ppm | pambackground | cksum
+rm ${ibmttl_pam}
+
+
+# Test 3.
+# Should produce: 2667595257 17328
+pamgradient rgb:01/01/01 rgb:ff/7f/00 rgb:00/ff/7f rgb:fe/fe/fe 10 10 | \
+pnmmargin -white 2 | pnmtile 144 120 | pambackground | cksum
+
+
+# pamgradient rgb:01/01/01 rgb:ff/7f/00  rgb:00/ff/7f rgb:fe/fe/fe 10 10 | \
+# pnmmargin -white 2 | pnmtile 144 120 | cksum
+# should produce: 3147800256 51855
+# Above input image is a "wall" with 12x10 "windows".
+
+# pnmremap -mapfile ${ibmttl_pam} testimg.ppm | cksum
+# should produce : 452672747 101517
diff --git a/test/pamcrater.test b/test/pamcrater.test
index 1d182208..cc937731 100755
--- a/test/pamcrater.test
+++ b/test/pamcrater.test
@@ -1,13 +1,21 @@
 #! /bin/bash
 # This script tests: pamcrater pamshadedrelief
-# Also requires: pamslice pamvalidate
+# Also requires: pamstack pamvalidate pamcut pamflip
 
   alias pamcrater="${PBM_TESTPREFIX}pamcrater"
-  alias pamslice="${PBM_TESTPREFIX}pamshadedrelief"
-  alias pamslice="${PBM_BINPREFIX}pamslice"
-  alias pamvalidate="${PBM_TESTPREFIX}pamvalidate"
+  alias pamshadedrelief="${PBM_TESTPREFIX}pamshadedrelief"
+  alias pamstack="${PBM_BINPREFIX}pamstack"
+  alias pamvalidate="${PBM_BINPREFIX}pamvalidate"
+  alias pamcut="${PBM_BINPREFIX}pamcut"
+  alias pamflip="${PBM_BINPREFIX}pamflip"
+
   shopt -s expand_aliases
 
+# We use the undocumented --test and --radius options of pamcrater.
+# pamcrater --test --radius=N
+# The above draws a single crater of radius N.
+# The resulting image should be symmetric.
+
 tmpdir=${tmpdir:-/tmp}
 
 test_pam=${tmpdir}/test.pam
@@ -29,11 +37,11 @@ pamstack ${test10_pam} ${test50_pam} ${test100_pam} ${test150_pam} |
 
 for i in 1 10 70
   do
-    ( pamslice -row=$((128 + $i))  ${test_pam} | cksum &&
-      pamslice -row=$((128 - $i))  ${test_pam} | cksum &&
-      pamslice -col=$((128 + $i))  ${test_pam} | cksum &&
-      pamslice -col=$((128 - $i))  ${test_pam} | cksum
-    ) | uniq -c | awk '{print $1}'
+  ( pamcut -top=$((128 + $i)) -height=1 ${test_pam} | cksum &&
+    pamcut -top=$((128 - $i)) -height=1 ${test_pam} | cksum &&
+    pamcut -left=$((128 + $i)) -width=1 ${test_pam} | pamflip -xy | cksum &&
+    pamcut -left=$((128 - $i)) -width=1 ${test_pam} | pamflip -xy | cksum
+  ) | uniq -c | awk '{print $1}'
   done
 
 rm ${test_pam} ${test10_pam} ${test50_pam}
@@ -42,12 +50,12 @@ rm ${test_pam} ${test10_pam} ${test50_pam}
 
 pamshadedrelief ${test100_pam} > ${testshaded_pam}
 
-( pamslice -row=$((128 + 12))  ${testshaded_pam} | cksum &&
-  pamslice -row=$((128 - 12))  ${testshaded_pam} | cksum &&
-  pamslice -row=$((128 + 31))  ${testshaded_pam} | cksum &&
-  pamslice -row=$((128 - 31))  ${testshaded_pam} | cksum &&
-  pamslice -row=$((128 + 99))  ${testshaded_pam} | cksum &&
-  pamslice -row=$((128 - 99))  ${testshaded_pam} | cksum
+( pamcut -top=$((128 + 12)) -height=1  ${testshaded_pam} | cksum &&
+  pamcut -top=$((128 - 12)) -height=1  ${testshaded_pam} | cksum &&
+  pamcut -top=$((128 + 31)) -height=1  ${testshaded_pam} | cksum &&
+  pamcut -top=$((128 - 31)) -height=1  ${testshaded_pam} | cksum &&
+  pamcut -top=$((128 + 99)) -height=1  ${testshaded_pam} | cksum &&
+  pamcut -top=$((128 - 99)) -height=1  ${testshaded_pam} | cksum
 ) | uniq -c | awk '{print $1}'
 
 rm ${testshaded_pam} ${test100_pam}
diff --git a/test/pamenlarge.ok b/test/pamenlarge.ok
index 055262c9..a2408871 100644
--- a/test/pamenlarge.ok
+++ b/test/pamenlarge.ok
@@ -1,4 +1,4 @@
 3424505894 913236
 3763267672 304422
 3342398172 297
-237488670 3133413
+398497872 6806
diff --git a/test/pamenlarge.test b/test/pamenlarge.test
index 8f9e3c70..ced156dd 100755
--- a/test/pamenlarge.test
+++ b/test/pamenlarge.test
@@ -1,8 +1,11 @@
 #! /bin/bash
 # This script tests: pamenlarge
-# Also requires: pamchannel
+# Also requires: pamchannel pamseq pamtopnm
 
   alias pamenlarge="${PBM_TESTPREFIX}pamenlarge"
+  alias pamchannel="${PBM_TESTPREFIX}pamchannel"
+  alias pamseq="${PBM_TESTPREFIX}pamseq"
+  alias pamchannel="${PBM_TESTPREFIX}pamchannel"
   shopt -s expand_aliases
 
 # Test 1.  Should print 3424505894 913236
@@ -12,5 +15,5 @@ pamchannel -infile=testimg.ppm -tupletype="GRAYSCALE" 0 | pamtopnm | \
   pamenlarge 3 | cksum
 # Test 3.  Should print 3342398172 297
 pamenlarge 3 testgrid.pbm | cksum
-# Test 4.  Should print 237488670 3133413
-pamenlarge 3 -plain testimg.ppm | cksum
+# Test 4.  Should print 398497872 6806
+pamseq 3 4 | pamtopnm -assume | pamenlarge 3 -plain | cksum
diff --git a/test/png-roundtrip.test b/test/png-roundtrip.test
index 223103c8..dc05420a 100755
--- a/test/png-roundtrip.test
+++ b/test/png-roundtrip.test
@@ -6,8 +6,6 @@
   alias pnmtopng="${PBM_TESTPREFIX}pnmtopng"
   shopt -s expand_aliases
 
-## Fails because .ok not set yet.
-
 # Test 1.  Should print 1926073387 101484 18 times
 for flags in "" -interlace \
   -gamma=.45 \
diff --git a/test/ppmchange-roundtrip.test b/test/ppmchange-roundtrip.test
index a357870e..071c0b93 100755
--- a/test/ppmchange-roundtrip.test
+++ b/test/ppmchange-roundtrip.test
@@ -13,5 +13,5 @@ pnminvert | ppmtopgm | \
 pgmtopbm -th -val=0.5 | cksum
 
 ppmchange  black white white black testgrid.pbm | \
-ppmchange  black white white black -plain  | \
+ppmchange  black white white black | \
 ppmtopgm | pgmtopbm -th -val=0.5 | cksum
diff --git a/test/ppmchange.ok b/test/ppmchange.ok
new file mode 100644
index 00000000..130c3c45
--- /dev/null
+++ b/test/ppmchange.ok
@@ -0,0 +1,4 @@
+22488533 203
+1008787190 613
+3885709071 613
+2101746192 613
diff --git a/test/ppmchange.test b/test/ppmchange.test
new file mode 100755
index 00000000..9805be0a
--- /dev/null
+++ b/test/ppmchange.test
@@ -0,0 +1,63 @@
+#! /bin/bash
+# This script tests: ppmchange
+# Also requires: ppmrainbow pgmramp
+
+  alias ppmchange="${PBM_TESTPREFIX}ppmchange"
+  alias ppmrainbow="${PBM_BINPREFIX}ppmrainbow"
+  alias pgmramp="${PBM_BINPREFIX}pgmramp"
+  shopt -s expand_aliases
+
+#  Failure message
+## If this test fails and ppmchange-roundtrip.test succeeds,
+## the probably cause is a problem with one of the options of
+## ppmchange: -closeness or -remainder.
+
+tmpdir=${tmpdir:-/tmp}
+rainbow_ppm=${tmpdir}/rainbow.ppm
+
+# Explicit values for intermediate colors: rgb.txt may be defining them
+# in unusual ways.
+
+brown=rgb:67/43/00
+cyan=rgb:00/ff/ff
+yellow=rgb:ff/ff/00
+gray=rgb:7f/7f/7f
+
+
+# Test 1. Should print 811868957 60
+pgmramp -lr 8 8 | ppmchange black black  white white  $gray $gray \
+  -close=10 -remainder=blue | cksum
+
+
+# Test 2. Should print 1008787190 613
+
+ppmrainbow -tmpdir=$tmpdir -width=200 -height=1 red green blue | \
+  tee ${rainbow_ppm} | \
+  ppmchange red $brown   green $brown   blue $brown | cksum
+
+
+# Test 3. Should print 3885709071 613
+
+ppmchange red $brown   green $cyan   blue $yellow \
+  -closeness=25 ${rainbow_ppm} | cksum
+
+
+# Test 4. Should print 2101746192 613
+
+ppmchange red rgb:64/00/01 rgb:00/ff/00 rgb:00/32/02 blue blue \
+  -remainder=black -closeness=25 ${rainbow_ppm} | cksum
+
+rm ${rainbow_ppm}
+
+
+# cksum ${rainbow_ppm}
+# 1983174784 613 rainbow.ppm
+
+# ppmchange red rgb:64/00/01 rgb:00/ff/00 rgb:00/32/02 blue blue \
+#   -remainder=black -closeness=25  ${rainbow_ppm} | \
+#   pphist -sort=rgb -noheader
+#
+#     0     0     0	    0	     75 
+#     0     0   255	   29	     42 
+#     0    50     2	   30	     42 
+#   100     0     1	   30	     41 
diff --git a/test/ppmmix.test b/test/ppmmix.test
index 25e35f0e..9a54143f 100755
--- a/test/ppmmix.test
+++ b/test/ppmmix.test
@@ -19,12 +19,9 @@ tmpdir=${tmpdir:-/tmp}
 a1_pgm=${tmpdir}/a1.pgm
 a2_pgm=${tmpdir}/a2.pgm
 
-pbmmake -g 8 8 | \
- pgmtopgm > ${a1_pgm} &&
-pbmmake -g 2 2 | pamenlarge 4 | \
- pgmtopgm > ${a2_pgm} &&
-ppmmix 0.75 ${a1_pgm} ${a2_pgm} -plain | \
- ppmtopgm | pamdepth 3 -plain &&
+pbmmake -g 8 8 | pgmtopgm > ${a1_pgm} &&
+pbmmake -g 2 2 | pamenlarge 4 | pgmtopgm > ${a2_pgm} &&
+ppmmix 0.75 ${a1_pgm} ${a2_pgm} | ppmtopgm | pamdepth 3 -plain &&
 rm ${a1_pgm} ${a2_pgm}
 
 # Mix image with itself.
diff --git a/test/symmetry.test b/test/symmetry.test
index 5f09e91e..596b67b2 100755
--- a/test/symmetry.test
+++ b/test/symmetry.test
@@ -1,10 +1,11 @@
 #! /bin/bash
-# This script tests: pgmramp pamgauss pgmkernel pbmpscale
+# This script tests: pgmramp pamgauss pgmkernel pbmmake pbmpscale
 # Also requires: pamflip
 
   alias pgmramp="${PBM_TESTPREFIX}pgmramp"
   alias pamgauss="${PBM_TESTPREFIX}pamgauss"
   alias pgmkernel="${PBM_TESTPREFIX}pgmkernel"
+  alias pbmmake="${PBM_TESTPREFIX}pbmmake"
   alias pbmpscale="${PBM_TESTPREFIX}pbmpscale"
   alias pamflip="${PBM_BINPREFIX}pamflip"
   shopt -s expand_aliases