about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2023-12-20 18:23:03 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2023-12-20 18:23:03 +0000
commit263667943f9ec1ef9b36e6c8c01ead8ae297b82e (patch)
treebd271307881dacc8cc9c724668b4ef116b8d0635
parent438200b35edf73d72af852fbc581d7bc4ab2db31 (diff)
downloadnetpbm-mirror-263667943f9ec1ef9b36e6c8c01ead8ae297b82e.tar.gz
netpbm-mirror-263667943f9ec1ef9b36e6c8c01ead8ae297b82e.tar.xz
netpbm-mirror-263667943f9ec1ef9b36e6c8c01ead8ae297b82e.zip
Add pnmindex.ok, update pnmindex.test
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@4817 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--test/pnmindex.ok28
-rw-r--r--test/pnmindex.test55
2 files changed, 66 insertions, 17 deletions
diff --git a/test/pnmindex.ok b/test/pnmindex.ok
new file mode 100644
index 00000000..15d01639
--- /dev/null
+++ b/test/pnmindex.ok
@@ -0,0 +1,28 @@
+Test 1. Should print 3391481002 889
+3391481002 889
+Test 2. Should print 1998876959 5290 twice
+1998876959 5290
+1998876959 5290
+Test 3. Should print 3099638253 5290
+3099638253 5290
+Test 4. Should print 1397700642 3160
+1397700642 3160
+Test 5. Should print 2303488589 28514
+2303488589 28514
+Test 6. Should print 1706277976 100455
+1706277976 100455
+Test 7. Should print 801388440 100455
+801388440 100455
+Test Invalid
+Expected failure 1 (no output)
+Expected failure 2 (no output)
+Expected failure 3 (no output)
+Expected failure 4 (no output)
+Expected failure 5 (no output)
+Expected failure 6 (no output)
+Expected failure 7 (no output)
+Expected failure 8 (no output)
+Expected failure 9 (no output)
+Expected failure 10 (no output)
+Expected failure 11 (no output)
+Expected failure 12 (no output)
diff --git a/test/pnmindex.test b/test/pnmindex.test
index 5dc85b70..51e61532 100644
--- a/test/pnmindex.test
+++ b/test/pnmindex.test
@@ -1,15 +1,33 @@
 #! /bin/sh
 # This script tests: pnmindex
-# Also requires:
+# Also requires: pamcat pamscale pbmtext pnmcolormap pnmindex
+# Also requires: pnminvert pnmquant pnmremap 
 
-pnmindex maze.pbm maze.pbm maze.pbm maze.pbm maze.pbm maze.pbm | cksum
+echo "Test 1. Should print 3391481002 889"
+pnmindex maze.pbm | cksum
 
-pnmindex -white -noquant maze.pbm maze.pbm maze.pbm maze.pbm maze.pbm maze.pbm | cksum
+echo "Test 2. Should print 1998876959 5290 twice"
+pnmindex maze.pbm maze.pbm maze.pbm maze.pbm maze.pbm maze.pbm | cksum
+pnmindex -noquant maze.pbm maze.pbm maze.pbm maze.pbm maze.pbm maze.pbm | cksum
 
+echo "Test 3. Should print 3099638253 5290"
 pnmindex -black maze.pbm maze.pbm maze.pbm maze.pbm maze.pbm maze.pbm | cksum
 
-pnmindex -size 20 -accross=3 testgrid.pbm testgrid.pbm testgrid.pbm \
-                             testgrid.pbm testgrid.pbm testgrid.pbm | cksum
+echo "Test 4. Should print 1397700642 3160"
+pnmindex -size 20 -across=3 testgrid.pbm testgrid.pbm testgrid.pbm \
+         testgrid.pbm testgrid.pbm testgrid.pbm | cksum
+
+echo "Test 5. Should print 2303488589 28514"
+pnmindex testimg.ppm | cksum
+
+echo "Test 6. Should print 1706277976 100455"
+pnmindex -size 50 -across=2 testimg.ppm testimg.ppm testimg.ppm \
+         testimg.ppm testimg.ppm testimg.ppm | cksum
+
+echo "Test 7. Should print 801388440 100455"
+pnmindex -size 50 -across=2 -noquant testimg.ppm testimg.ppm testimg.ppm \
+         testimg.ppm testimg.ppm testimg.ppm | cksum
+
 
 echo "Test Invalid"
 
@@ -17,23 +35,26 @@ test_out=${tmpdir}/test_out
 n=1
 
 # define function
-invcmd $1 > ${test_out} || \
+invalidCmd () { $1 > ${test_out} && printf "Unexpected success $n " || \
   printf "Expected failure $n "
-  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
+  test -s ${test_out} && echo "(unexpected output)" || echo "(no output)"
   rm -f ${test_out}
-  n=$(($n +1)); }
+  n=$(($n + 1)); }
 
 echo 1>&2
 echo "Invalid command-line arguments." 1>&2
 echo "Error messages should appear below the line." 1>&2
 echo "-----------------------------------------------------------" 1>&2
 
-invcmd "pnmindex -size -1 testgrid.pbm"
-invcmd "pnmindex -size 0  testgrid.pbm"
-invcmd "pnmindex -size    testgrid.pbm"
-invcmd "pnmindex -across -1 testgrid.pbm"
-invcmd "pnmindex -across 0  testgrid.pbm"
-invcmd "pnmindex -across    testgrid.pbm"
-invcmd "pnmindex -quant -1 testgrid.pbm"
-invcmd "pnmindex -quant 0  testgrid.pbm"
-invcmd "pnmindex testgrid.pbm /dev/null"
+invalidCmd "pnmindex -size -1 testgrid.pbm"
+invalidCmd "pnmindex -size  0 testgrid.pbm"
+invalidCmd "pnmindex -size    testgrid.pbm"
+invalidCmd "pnmindex -across -1 testgrid.pbm"
+invalidCmd "pnmindex -across  0 testgrid.pbm"
+invalidCmd "pnmindex -across    testgrid.pbm"
+invalidCmd "pnmindex -colors -1 testgrid.pbm"
+invalidCmd "pnmindex -colors  0 testgrid.pbm"
+invalidCmd "pnmindex -colors    testgrid.pbm"
+invalidCmd "pnmindex -quant -noquant testgrid.pbm"
+invalidCmd "pnmindex -colors 100 -noquant testgrid.pbm"
+invalidCmd "pnmindex"