about summary refs log tree commit diff
path: root/test/pamshuffle.test
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2022-06-24 04:36:14 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2022-06-24 04:36:14 +0000
commit5bcb369386d617631627a4fb086ff6ab80ffa157 (patch)
treeb2f6cae56a948d3897c1ed6452f870ffc8c832de /test/pamshuffle.test
parent5991a720c260e171c145d035014609f18cb2eaf3 (diff)
downloadnetpbm-mirror-5bcb369386d617631627a4fb086ff6ab80ffa157.tar.gz
netpbm-mirror-5bcb369386d617631627a4fb086ff6ab80ffa157.tar.xz
netpbm-mirror-5bcb369386d617631627a4fb086ff6ab80ffa157.zip
Promote Development release to Advanced, version 10.99.00
git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@4358 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'test/pamshuffle.test')
-rwxr-xr-xtest/pamshuffle.test67
1 files changed, 67 insertions, 0 deletions
diff --git a/test/pamshuffle.test b/test/pamshuffle.test
new file mode 100755
index 00000000..5582ce3b
--- /dev/null
+++ b/test/pamshuffle.test
@@ -0,0 +1,67 @@
+#! /bin/sh
+# This script tests: pamshuffle
+# Also requires: pamseq pamrestack pgmhist ppmhist pnmpsnr
+
+tmpdir=${tmpdir:-/tmp}
+seq_pam=${tmpdir}/seq.pam
+seq16_pam=${tmpdir}/seq16.pam
+
+out1_pam=${tmpdir}/out1.pam
+
+echo "Test 1.  Should print 1081361896 1432 five times"
+
+pgmhist -machine maze.pbm | cksum
+pamshuffle -randomseed=1 maze.pbm | pgmhist -machine | cksum
+pamshuffle -randomseed=2 maze.pbm | pgmhist -machine | cksum
+pamshuffle -column -randomseed=3 maze.pbm | pgmhist -machine | cksum
+pamrestack maze.pbm | pamshuffle -randomseed=3 | pgmhist -machine | cksum
+
+echo "Test 2.  Should print 1936883899 143517 four times"
+
+pamseq -tupletype="RGB" 3 15 > ${seq_pam}
+
+ppmhist -map ${seq_pam} | cksum
+pamshuffle -randomseed=2 ${seq_pam} | ppmhist -map | cksum
+pamrestack -width=16 -trim=abort ${seq_pam} | tee ${seq16_pam} | \
+  ppmhist -map | cksum
+pamshuffle -column -randomseed=3 ${seq16_pam} | ppmhist -map | cksum
+
+echo "Test 3.  Should print nomatch three times"
+
+pamshuffle -randomseed=$((100 +i)) ${seq16_pam} > ${out1_pam}
+pamshuffle -randomseed=${i} ${seq16_pam} | \
+pnmpsnr -target=14.0 ${out1_pam} -
+rm ${seq_pam} ${seq16_pam} ${out1_pam}
+
+pamshuffle -randomseed=$((100 +i)) testimg.ppm > ${out1_pam}
+pamshuffle -randomseed=${i} testimg.ppm | \
+  pnmpsnr -target=14.0 ${out1_pam} -
+rm ${out1_pam}
+
+pamshuffle -randomseed=$((100 +i)) -column testimg.ppm > ${out1_pam}
+pamshuffle -randomseed=${i} -column testimg.ppm | \
+  pnmpsnr -target=14.0 ${out1_pam} -
+rm ${out1_pam}
+
+test_out=${tmpdir}/test_out
+echo "Test Invalid."
+
+echo 1>&2
+echo "Invalid command-line argument combinations." 1>&2
+echo "Error messages should appear below the line." 1>&2
+echo "-----------------------------------------------------------" 1>&2
+
+pamshuffle testimg.ppm testgrid.pbm > ${test_out} || \
+  echo -n "Expected failure 1"
+  test -s ${test_out}; echo " "$?
+  rm -f ${test_out}
+
+pamshuffle -randomseed -column testgrid.pbm > ${test_out} || \
+  echo -n "Expected failure 2"
+  test -s ${test_out}; echo " "$?
+  rm -f ${test_out}
+
+pamshuffle -randomseed=null testgrid.pbm > ${test_out} || \
+  echo -n "Expected failure 3"
+  test -s ${test_out}; echo " "$?
+  rm -f ${test_out}