about summary refs log tree commit diff
path: root/test/ppmshift.test
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2023-06-28 17:29:32 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2023-06-28 17:29:32 +0000
commit23ce26f64c34e30951ad9ade2151552ed77e7357 (patch)
treed73b31a0c2f7c7be4a69f8a8e84e00dd39c432b5 /test/ppmshift.test
parent1b6e51a266008348ad93ed8b6ac9ec91b5024fea (diff)
downloadnetpbm-mirror-23ce26f64c34e30951ad9ade2151552ed77e7357.tar.gz
netpbm-mirror-23ce26f64c34e30951ad9ade2151552ed77e7357.tar.xz
netpbm-mirror-23ce26f64c34e30951ad9ade2151552ed77e7357.zip
promote Advanced to Stable
git-svn-id: http://svn.code.sf.net/p/netpbm/code/stable@4558 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'test/ppmshift.test')
-rwxr-xr-xtest/ppmshift.test42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/ppmshift.test b/test/ppmshift.test
new file mode 100755
index 00000000..fff193b3
--- /dev/null
+++ b/test/ppmshift.test
@@ -0,0 +1,42 @@
+#! /bin/bash
+# This script tests: ppmshift
+# Also requires: pgmtoppm
+
+echo "Test 1. Should print: 3705777303 101484"
+ppmshift -seed=1 10 testimg.ppm | cksum
+
+echo "Test 2. Should print: 202790723 685"
+ppmshift -seed=1 1 testgrid.pbm | cksum
+
+echo "Test 3. Should print: 0 0 : 0"
+ppmshift -seed=1 0 testimg.ppm | cmp -s - testimg.ppm
+  echo ${PIPESTATUS[@]} ":" $?
+
+tmpdir=${tmpdir:-/tmp}
+test0_ppm=${tmpdir}/test0.ppm
+test14_ppm=${tmpdir}/test14.ppm
+
+pgmtoppm < maze.pbm > ${test0_ppm}
+
+echo "Test 4.  Should print: 0 0 : 0"
+  ppmshift -seed=2 0 maze.pbm | cmp -s - ${test0_ppm}
+    echo ${PIPESTATUS[@]} ":" $?
+
+ppmshift -seed=2 14 maze.pbm > ${test14_ppm}
+
+for i in 1 15 16 20 1000
+  do
+  echo "Test 5. ("$i") Should print: 1 twice"
+  ppmshift -seed=2 $i maze.pbm | cmp -s - ${test0_ppm}
+    echo $?
+  ppmshift -seed=2 $i maze.pbm | cmp -s - ${test14_ppm}
+    echo $?
+  done
+
+# In Test 5 the image files are not supposed to match.
+# When cmp finds a difference, it may terminate and stop reading input from
+# the pipe at that point.  This may cause a "broken pipe" exception; however
+# this does not always happen.  The broken pipe shows up as a non-zero value
+# for ${PIPESTATUS[0]}.
+
+rm ${test0_ppm} ${test14_ppm}