about summary refs log tree commit diff
path: root/test
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2023-03-01 18:31:30 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2023-03-01 18:31:30 +0000
commit2e2fed8ed6fce2036a3875be6cd54ebaffe0aa03 (patch)
treed55cff43bec8d8e9af977fd0c531834fdc778edb /test
parentfa07134d248fcdbc208dacf41897c190ac6b802a (diff)
downloadnetpbm-mirror-2e2fed8ed6fce2036a3875be6cd54ebaffe0aa03.tar.gz
netpbm-mirror-2e2fed8ed6fce2036a3875be6cd54ebaffe0aa03.tar.xz
netpbm-mirror-2e2fed8ed6fce2036a3875be6cd54ebaffe0aa03.zip
new tests for 'pnmcolormap'
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@4507 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'test')
-rw-r--r--test/Test-Order1
-rw-r--r--test/pnmcolormap.ok24
-rwxr-xr-xtest/pnmcolormap.test31
-rw-r--r--test/pnmcolormap2.ok9
-rwxr-xr-xtest/pnmcolormap2.test55
5 files changed, 119 insertions, 1 deletions
diff --git a/test/Test-Order b/test/Test-Order
index 6aab22bd..16eeaf8e 100644
--- a/test/Test-Order
+++ b/test/Test-Order
@@ -51,6 +51,7 @@ pbmminkowski.test
 pgmminkowski.test
 
 pnmcolormap.test
+pnmcolormap2.test
 
 # Basic (internal) converter tests
 
diff --git a/test/pnmcolormap.ok b/test/pnmcolormap.ok
index 126dfea4..0c6f0d71 100644
--- a/test/pnmcolormap.ok
+++ b/test/pnmcolormap.ok
@@ -1,12 +1,36 @@
+Test 1.
 P1
 2 1
 10
+
 P1
 2 1
 10
+
 P1
 2 1
 10
+
+Test 2.
+P3
+3 1
+255
+0 0 255 64 0 191 128 0 128 
+
+P3
+2 2
+255
+0 0 255 64 0 191 
+128 0 128 128 0 128 
+
+Test 3.
+ok
+ok
+ok
+ok
+ok
+
+Test Invalid.
 Expected failure 1 1
 Expected failure 2 1
 Expected failure 3 1
diff --git a/test/pnmcolormap.test b/test/pnmcolormap.test
index 1a7ec266..11d47385 100755
--- a/test/pnmcolormap.test
+++ b/test/pnmcolormap.test
@@ -1,10 +1,39 @@
 #! /bin/sh
 # This script tests: pnmcolormap
-# Also requires:
+# Also requires: ppmpat
+
+echo "Test 1."
 
 pnmcolormap -plain -sort 2 maze.pbm
+echo
 pnmcolormap -plain -sort -square 2 maze.pbm
+echo
 pnmcolormap -plain -sort all maze.pbm
+echo
+tmpdir=${tmpdir:-/tmp}
+tartan_ppm=${tmpdir}/tartan.ppm
+
+echo "Test 2."
+
+ppmpat -tartan -color="rgb:00/00/ff,rgb:00/80/ff,rgb:80/00/80" 20 20 |\
+    tee ${tartan_ppm} | pnmcolormap -plain -sort all
+echo
+pnmcolormap -plain -sort -square all ${tartan_ppm}
+rm ${tartan_ppm}
+echo
+echo "Test 3."
+# Explicitly specify default options.  Output should not vary.
+
+map=${tmpdir}/map.ppm
+
+pnmcolormap 64 testimg.ppm > ${map} && echo ok || echo bad
+test -s ${map} && echo ok || echo bad
+pnmcolormap -center 64 testimg.ppm | cmp -s ${map} - && echo ok || echo bad
+pnmcolormap -spreadbrightness 64 testimg.ppm | cmp -s ${map} - && echo ok || echo bad
+pnmcolormap -splitpixelct 64 testimg.ppm | cmp -s ${map} - && echo ok || echo bad
+rm ${map}
+echo
+echo "Test Invalid."
 
 echo 1>&2
 echo "Invalid command-line arguments." 1>&2
diff --git a/test/pnmcolormap2.ok b/test/pnmcolormap2.ok
new file mode 100644
index 00000000..2eab38b8
--- /dev/null
+++ b/test/pnmcolormap2.ok
@@ -0,0 +1,9 @@
+Test.  Should print 'match' eight times.
+match
+match
+match
+match
+match
+match
+match
+match
diff --git a/test/pnmcolormap2.test b/test/pnmcolormap2.test
new file mode 100755
index 00000000..bb870e7f
--- /dev/null
+++ b/test/pnmcolormap2.test
@@ -0,0 +1,55 @@
+#! /bin/sh
+# This script tests: pnmcolormap
+# Also requires: pnmremap pnmpsnr
+
+tmpdir=${tmpdir:-/tmp}
+map=${tmpdir}/map.ppm
+
+echo "Test.  Should print 'match' eight times."
+# Threshold values (targetN=xx.xx) here were produced by calculating
+# the S/N ratio with reduced colors.
+
+# colors in following tests / colors for calculating threshold
+# 100 /  90
+# 200 / 180
+#  30 /  25
+
+pnmcolormap 100 testimg.ppm > ${map}
+pnmremap -mapfile=${map} testimg.ppm |\
+  pnmpsnr -target1=33.42 -target2=35.14 -target3=34.35 testimg.ppm -
+rm ${map}
+
+pnmcolormap -meancolor 100 testimg.ppm > ${map}
+pnmremap -mapfile=${map} testimg.ppm |\
+  pnmpsnr -target1=34.91 -target2=36.86 -target3=35.84 testimg.ppm -
+rm ${map}
+
+pnmcolormap -meanpixel 100 testimg.ppm > ${map}
+pnmremap -mapfile=${map} testimg.ppm |\
+  pnmpsnr -target1=34.95 -target2=36.77 -target3=35.81 testimg.ppm -
+rm ${map}
+
+pnmcolormap -spreadluminosity 100 testimg.ppm > ${map}
+pnmremap -mapfile=${map} testimg.ppm |\
+  pnmpsnr -target1=33.71 -target2=32.91 -target3=33.93 testimg.ppm -
+rm ${map}
+
+pnmcolormap -splitcolorct 100 testimg.ppm > ${map}
+pnmremap -mapfile=${map} testimg.ppm |\
+  pnmpsnr -target1=33.97 -target2=35.34 -target3=34.23 testimg.ppm -
+rm ${map}
+
+pnmcolormap -splitspread 100 testimg.ppm > ${map}
+pnmremap -mapfile=${map} testimg.ppm |\
+  pnmpsnr -target1=32.98 -target2=35.06 -target3=33.19 testimg.ppm -
+rm ${map}
+
+pnmcolormap 200 testimg.ppm > ${map}
+pnmremap -mapfile=${map} testimg.ppm |\
+  pnmpsnr -target1=36.14 -target2=36.87 -target3=36.79 testimg.ppm -
+rm ${map}
+
+pnmcolormap 30 testimg.ppm > ${map}
+pnmremap -mapfile=${map} testimg.ppm |\
+  pnmpsnr -target1=28.53 -target2=31.62 -target3=29.99 testimg.ppm -
+rm ${map}