about summary refs log tree commit diff
path: root/test
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2023-03-25 00:45:40 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2023-03-25 00:45:40 +0000
commit59588cf8aa12fd79214e937e6a9597630443c4a8 (patch)
treed73b31a0c2f7c7be4a69f8a8e84e00dd39c432b5 /test
parentdaf778ac40755a73086f64c20730e24d237b6759 (diff)
downloadnetpbm-mirror-59588cf8aa12fd79214e937e6a9597630443c4a8.tar.gz
netpbm-mirror-59588cf8aa12fd79214e937e6a9597630443c4a8.tar.xz
netpbm-mirror-59588cf8aa12fd79214e937e6a9597630443c4a8.zip
promote Development to Advanced
git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@4539 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'test')
-rw-r--r--test/Test-Order1
-rwxr-xr-xtest/ilbm-roundtrip.test20
-rw-r--r--test/pbmtextps-dump.ok25
-rwxr-xr-xtest/pbmtextps-dump.test64
-rw-r--r--test/pbmtextps.ok4
-rwxr-xr-xtest/pbmtextps.test10
-rw-r--r--test/pnmcolormap.ok24
-rwxr-xr-xtest/pnmcolormap.test31
-rw-r--r--test/pnmcolormap2.ok9
-rwxr-xr-xtest/pnmcolormap2.test55
10 files changed, 229 insertions, 14 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/ilbm-roundtrip.test b/test/ilbm-roundtrip.test
index e7a1a4e5..3d7d63ef 100755
--- a/test/ilbm-roundtrip.test
+++ b/test/ilbm-roundtrip.test
@@ -33,7 +33,25 @@ rm ${test_ppm}
 
 echo "Test 5.  Should print 482756572 101484 twice"
 mapfile=${tmpdir}/mapfile
-pnmcolormap 32 testimg.ppm > ${mapfile}
+
+# The following was produced by running "pnmcolormap -plain 32 testimg.ppm"
+# We use a prefabricated mapfile because pnmcolormap is known to
+# produce slightly different output on different systems.
+
+cat > ${mapfile} << EOF
+P3
+32 1
+255
+106 82 80 46 43 34 128 62 46 189 68 63 209 41 43 209 65 46 241 62 72
+ 240 189 195 
+122 142 103 92 131 68 159 129 188 177 205 195 96 132 107 193 150 107
+ 242 253 238 241 73 108 
+121 75 67 182 67 47 98 88 48 237 36 47 66 45 42 68 84 43 182 45 41
+ 70 77 67 
+96 45 45 237 62 47 150 59 41 189 76 103 48 69 31 52 68 52 48 45 51
+ 105 80 130 
+EOF
+
 ppmtoilbm -map ${mapfile} testimg.ppm | ilbmtoppm | tee ${test_ppm} | cksum
 ppmtoilbm -map ${mapfile} ${test_ppm} | ilbmtoppm | cksum
 
diff --git a/test/pbmtextps-dump.ok b/test/pbmtextps-dump.ok
index 9fe3b2ea..11a4c5fd 100644
--- a/test/pbmtextps-dump.ok
+++ b/test/pbmtextps-dump.ok
@@ -43,6 +43,13 @@ Test 1
 -stroke 1
 < /pensize -1.000000 def
 > /pensize 1.000000 def
+Test 2
+30 31 32 20 41 42 43 2d 78 79 7a 2e
+1
+303132204142432d78797a2e
+1
+<303132 20 414243 2d 78797a 2e>
+1
 Test Invalid
 Expected failure 1 (-fontsize) 1
 Expected failure 2 (-fontsize 0) 1
@@ -62,4 +69,20 @@ Expected failure 15 (-descent) 1
 Expected failure 16 (-descent -1) 1
 Expected failure 17 (-stroke=A) 1
 Expected failure 18 (-pad -crop) 1
-Expected failure 19 (-font="") 1
+Expected failure 19 (-asciihex <a>) 1
+Expected failure 20 (-asciihex ) 1
+Expected failure 21 (-asciihex <53756c667572) 1
+Expected failure 22 (-asciihex 53756c667572>) 1
+Expected failure 23 (-asciihex <5375<6c667572>) 1
+Expected failure 24 (-asciihex <53756c>667572>) 1
+Expected failure 25 (-ascii85 <~@<6O!FD5W(~) 1
+Expected failure 26 (-ascii85 ~@<6O!FD5W(~>) 1
+Expected failure 27 (-ascii85 <~@<6O<~!FD5W(~>) 1
+Expected failure 28 (-ascii85 <~@<6O~>!FD5W(~>) 1
+Expected failure 29 (-ascii85 <~@<6O!FD5W(~~>) 1
+Expected failure 30 (-ascii85 v) 1
+Expected failure 31 (-ascii85 y) 1
+Expected failure 32 (-ascii85 1z) 1
+Expected failure 33 (-ascii85 z1z) 1
+Expected failure 34 (-ascii85 <~0123z~>) 1
+Expected failure 35 (-font="") 1
diff --git a/test/pbmtextps-dump.test b/test/pbmtextps-dump.test
index 3b3fbadd..82856f7e 100755
--- a/test/pbmtextps-dump.test
+++ b/test/pbmtextps-dump.test
@@ -6,15 +6,15 @@
 # Ghostscript is not required.
 
 tmpdir=${tmpdir:-/tmp}
-text_pbm=${tmpdir}/text.pbm
-text_ps=${tmpdir}/text.ps
+text1_ps=${tmpdir}/text1.ps
+text2_ps=${tmpdir}/text2.ps
 
 text="UNIX Philosophy: Do one thing and do it well."
 
 # Test 1:
 echo "Test 1"
 
-pbmtextps -dump-ps ${text} > ${text_ps}
+pbmtextps -dump-ps ${text} > ${text1_ps}
 
 # Font name is random sequence of alphanumerical characters.
 # Should not match any real name.
@@ -34,10 +34,28 @@ for flag in \
   "-stroke 1"
   do
   echo ${flag}
-  pbmtextps -dump-ps ${flag} ${text} | diff ${text_ps} - | grep "^[<>]"
+  pbmtextps -dump-ps ${flag} ${text} | diff ${text1_ps} - | grep "^[<>]"
   done
 
-rm ${text_ps}
+rm ${text1_ps}
+
+
+# Test 2:
+echo "Test 2"
+
+pbmtextps -dump-ps "012 ABC-xyz." > ${text2_ps}
+
+for hextext in \
+  "30 31 32  20	 41 42 43  2d	78 79 7a  2e" \
+  "303132204142432d78797a2e" \
+  "<303132 20 414243 2d 78797a 2e>" 
+  do
+  echo ${hextext}
+  pbmtextps -dump-ps -asciihex ${hextext} | diff ${text2_ps} - | grep "^[<>]"
+  echo $?
+  done
+
+rm ${text2_ps}
 
 
 echo "Test Invalid"
@@ -69,7 +87,7 @@ for error_flag in \
   "-descent" \
   "-descent -1" \
   "-stroke=A" \
-  "-pad -crop" 
+  "-pad -crop"
   do
     pbmtextps ${error_flag} -dump-ps ${text} >${test_out} || \
     printf "Expected failure $n (${error_flag})";
@@ -78,6 +96,40 @@ for error_flag in \
     n=$((n + 1))
   done
 
+for asciihex_string in \
+  "<a>" \
+  "" \
+  "<53756c667572" \
+  "53756c667572>" \
+  "<5375<6c667572>" \
+  "<53756c>667572>"
+  do
+    pbmtextps -dump-ps -asciihex ${asciihex_string} >${test_out} || \
+    printf "Expected failure $n (-asciihex ${asciihex_string})";
+    test -s ${test_out}; echo " "$?
+    rm -f ${test_out}
+    n=$((n + 1))
+  done
+
+for ascii85_string in \
+  '<~@<6O!FD5W(~'\
+  '~@<6O!FD5W(~>'\
+  "<~@<6O<~!FD5W(~>"\
+  "<~@<6O~>!FD5W(~>"\
+  "<~@<6O!FD5W(~~>"\
+  "v"\
+  "y"\
+  "1z"\
+  "z1z"\
+  "<~0123z~>"
+  do
+    pbmtextps -dump-ps -ascii85 ${ascii85_string} >${test_out} || \
+    printf "Expected failure $n (-ascii85 ${ascii85_string})";
+    test -s ${test_out}; echo " "$?
+    rm -f ${test_out}
+    n=$((n + 1))
+  done
+
   pbmtextps -font="" -dump-ps ${text} >${test_out} || \
   printf "Expected failure $n (-font=\"\")";
   test -s ${test_out}; echo " "$?
diff --git a/test/pbmtextps.ok b/test/pbmtextps.ok
index d407cb0a..2063ac4a 100644
--- a/test/pbmtextps.ok
+++ b/test/pbmtextps.ok
@@ -4,7 +4,9 @@ Test 1.  Should print 0 five times.
 0
 0
 0
-Test 2.  Should print P1 1 1 0 three times
+Test 2.  Should print P1 1 1 0 five times
+P1 1 1 0 
+P1 1 1 0 
 P1 1 1 0 
 P1 1 1 0 
 P1 1 1 0 
diff --git a/test/pbmtextps.test b/test/pbmtextps.test
index 975f960c..55f3f96a 100755
--- a/test/pbmtextps.test
+++ b/test/pbmtextps.test
@@ -24,7 +24,7 @@ pbmtextps -descent=2 ${text} | cmp -s - ${text_pbm}
 rm ${text_pbm}
 
 
-echo "Test 2.  Should print P1 1 1 0 three times"
+echo "Test 2.  Should print P1 1 1 0 five times"
 # blank images
 
 pbmtextps " " | pnmcrop -plain -blank-image=minimize |\
@@ -32,7 +32,11 @@ pbmtextps " " | pnmcrop -plain -blank-image=minimize |\
 pbmtextps -fontsize=12   " " | pnmcrop -plain -blank-image=minimize |\
   tr '\n' ' ' ; echo
 pbmtextps -resolution=50 " " | pnmcrop -plain -blank-image=minimize |\
-  tr '\n' ' ' ; echo 
+  tr '\n' ' ' ; echo
+pbmtextps -asciihex "20" | pnmcrop -plain -blank-image=minimize |\
+  tr '\n' ' ' ; echo
+pbmtextps -ascii85  "+9" | pnmcrop -plain -blank-image=minimize |\
+  tr '\n' ' ' ; echo
 
 
 
@@ -49,5 +53,3 @@ pbmtextps "+" | pnmcrop -left -right | pbmminkowski | grep "eulerchi"
 pbmtextps "+" | pnmcrop | pbmminkowski | grep "eulerchi"
 
 pbmtextps "o" | pnmcrop | pbmminkowski | grep "eulerchi"
-
-
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}