about summary refs log tree commit diff
path: root/test/ppmpat.test
diff options
context:
space:
mode:
Diffstat (limited to 'test/ppmpat.test')
-rwxr-xr-xtest/ppmpat.test149
1 files changed, 62 insertions, 87 deletions
diff --git a/test/ppmpat.test b/test/ppmpat.test
index 0a6127ca..00f8421e 100755
--- a/test/ppmpat.test
+++ b/test/ppmpat.test
@@ -1,107 +1,82 @@
-#! /bin/bash
+#! /bin/sh
 # This script tests: ppmpat
 # Also requires:
 
-# Test 1. Should print: 4008533639 781
-echo "Test 1"
-ppmpat -g2 --color=rgb:32/0d/b7,rgb:31/58/a3 16 16 | cksum
+echo "Test 1. Should print: 4008533639 781"
+ppmpat -gingham2 \
+       -color=rgb:32/0d/b7,rgb:31/58/a3 16 16 | cksum
 
-# Test 2. Should print: 3805937800 9613
-echo "Test 2"
-ppmpat -g3 --color=rgb:32/0d/b7,rgb:31/58/a3,rgb:e9/5e/d4 64 50 | cksum
+echo "Test 2. Should print: 738714211 781"
+ppmpat -g2 -mesh \
+       --color=rgb:32/0d/b7,rgb:31/58/a3 16 16 | cksum
 
-# Test 3. Should print: 2698433077 1549
-echo "Test 3"
-ppmpat -madras --color=rgb:32/0d/b7,rgb:31/58/a3,rgb:e9/5e/d4 32 16 | cksum
+echo "Test 3. Should print: 3805937800 9613"
+ppmpat -gingham3 \
+       -color=rgb:32/0d/b7,rgb:31/58/a3,rgb:e9/5e/d4 64 50 | cksum
 
-# Test 4. Should print: 3705929501 781
-echo "Test 4"
+echo "Test 4. Should print: 1586690955 9613"
+ppmpat -g3 -mesh \
+       -color=rgb:32/0d/b7,rgb:31/58/a3,rgb:e9/5e/d4 64 50 | cksum
+
+echo "Test 5. Should print: 2698433077 1549"
+ppmpat -madras \
+       --color=rgb:32/0d/b7,rgb:31/58/a3,rgb:e9/5e/d4 32 16 | cksum
+
+echo "Test 6. Should print: 1526189097 1549"
+ppmpat -madras -mesh \
+       --color=rgb:32/0d/b7,rgb:31/58/a3,rgb:e9/5e/d4 32 16 | cksum
+
+echo "Test 7. Should print: 3705929501 781"
 ppmpat -tartan --color=rgb:32/0d/b7,rgb:31/58/a3,rgb:e9/5e/d4 16 16 | cksum
 
-# Test 5. Should print: 3057513592 661
-echo "Test 5"
+echo "Test 8. Should print: 1996587666 781"
+ppmpat -tartan -mesh \
+       --color=rgb:32/0d/b7,rgb:31/58/a3,rgb:e9/5e/d4 16 16 | cksum
+
+echo "Test 9. Should print: 3057513592 661"
 ppmpat -argyle1 --color=rgb:ff/ff/ff,rgb:ff/0/0 12 18 | cksum
 
-# Test 6. Should print: 1861389287 661
-echo "Test 6"
+echo "Test 10. Should print: 1861389287 661"
 ppmpat -argyle2 --color=rgb:00/00/00,rgb:ff/80/80,rgb:e0/e0/e0 12 18 | cksum
 
-# Test 7.
 echo "Test Invalid"
 
-tmpdir=${tmpdir:-/tmp}
-test_out=${tmpdir}/test_out
-
-echo 1>&2
-echo "Invalid command-line argument combinations." 1>&2
-echo "Error messages should appear below the line." 1>&2
-echo "-----------------------------------------------------------" 1>&2
-
-ppmpat -g2 -g3 10 10 > ${test_out} || \
-   echo -n "Expected failure 1"; test -s ${test_out}; echo " "$?
-ppmpat -madras -tartan 10 10 > ${test_out} || \
-   echo -n "Expected failure 2"; test -s ${test_out}; echo " "$?
-ppmpat -poles -squig 10 10 > ${test_out} || \
-   echo -n "Expected failure 3"; test -s ${test_out}; echo " "$?
-ppmpat -camo -anticamo 10 10 > ${test_out} || \
-   echo -n "Expected failure 4"; test -s ${test_out}; echo " "$?
-ppmpat -argyle1 -argyle2 10 10 > ${test_out} || \
-   echo -n "Expected failure 5"; test -s ${test_out}; echo " "$?
-
-ppmpat 10 10 > ${test_out} || \
-   echo -n "Expected failure 6"; test -s ${test_out}; echo " "$?
-ppmpat -g2 10 > ${test_out} || \
-   echo -n "Expected failure 7"; test -s ${test_out}; echo " "$?
-ppmpat -g2 10 10 10 > ${test_out} || \
-   echo -n "Expected failure 8"; test -s ${test_out}; echo " "$?
-ppmpat -g2 10 > ${test_out} || \
-   echo -n "Expected failure 9"; test -s ${test_out}; echo " "$?
+. ${srcdir}/test-invalid.inc
+
+invCmd "ppmpat -g2 -g3 10 10"
+invCmd "ppmpat -madras -tartan 10 10"
+invCmd "ppmpat -poles -squig 10 10"
+invCmd "ppmpat -camo -anticamo 10 10"
+invCmd "ppmpat -argyle1 -argyle2 10 10"
+invCmd "ppmpat 10 10"
+invCmd "ppmpat -g2 10"
+invCmd "ppmpat -g2 10 10 10"
+invCmd "ppmpat -g2 10"
 
 clist1="-color=rgb:00/00/00"
 clist2="-color=rgb:00/00/00,rgb:00/00/ff"
 clist3="-color=rgb:00/00/00,rgb:00/00/ff,rgb:00/ff/ff"
 clist4="-color=rgb:00/00/00,rgb:00/00/ff,rgb:00/ff/ff,rgb:ff/ff/ff"
 
-# These patterns require exactly 2 colors 
-ppmpat -gingham2 ${clist1} 10 10 > ${test_out} || \
-   echo -n "Expected failure 10"; test -s ${test_out}; echo " "$?
-ppmpat -argyle1  ${clist1} 10 10 > ${test_out} || \
-   echo -n "Expected failure 11"; test -s ${test_out}; echo " "$?
-ppmpat -gingham2 ${clist3} 10 10 > ${test_out} || \
-   echo -n "Expected failure 12"; test -s ${test_out}; echo " "$?
-ppmpat -argyle1  ${clist3} 10 10 > ${test_out} || \
-   echo -n "Expected failure 13"; test -s ${test_out}; echo " "$?
-
-# These require exactly 3 colors 
-ppmpat -gingham3 ${clist2} 10 10 > ${test_out} || \
-   echo -n "Expected failure 14"; test -s ${test_out}; echo " "$?
-ppmpat -argyle2  ${clist2} 10 10 > ${test_out} || \
-   echo -n "Expected failure 15"; test -s ${test_out}; echo " "$?
-ppmpat -madras   ${clist2} 10 10 > ${test_out} || \
-   echo -n "Expected failure 16"; test -s ${test_out}; echo " "$?
-ppmpat -tartan   ${clist2} 10 10 > ${test_out} || \
-   echo -n "Expected failure 17"; test -s ${test_out}; echo " "$?
-ppmpat -gingham3 ${clist4} 10 10 > ${test_out} || \
-   echo -n "Expected failure 18"; test -s ${test_out}; echo " "$?
-ppmpat -argyle2  ${clist4} 10 10 > ${test_out} || \
-   echo -n "Expected failure 19"; test -s ${test_out}; echo " "$?
-ppmpat -madras   ${clist4} 10 10 > ${test_out} || \
-   echo -n "Expected failure 20"; test -s ${test_out}; echo " "$?
-ppmpat -tartan   ${clist4} 10 10 > ${test_out} || \
-   echo -n "Expected failure 21"; test -s ${test_out}; echo " "$?
-
-# These require at least 3 colors 
-ppmpat -squig    ${clist2} 10 10 > ${test_out} || \
-   echo -n "Expected failure 22"; test -s ${test_out}; echo " "$?
-ppmpat -camo     ${clist2} 10 10 > ${test_out} || \
-   echo -n "Expected failure 23"; test -s ${test_out}; echo " "$?
-ppmpat -anticamo ${clist2} 10 10 > ${test_out} || \
-   echo -n "Expected failure 24"; test -s ${test_out}; echo " "$?
-
-# The squig pattern has an aspect ratio restriction 
-ppmpat -squig ${clist3} 10 250  > ${test_out} || \
-   echo -n "Expected failure 25"; test -s ${test_out}; echo " "$?
-ppmpat -squig ${clist3} 500 20  > ${test_out} || \
-   echo -n "Expected failure 26"; test -s ${test_out}; echo " "$?
-
-rm ${test_out}
+# These patterns require exactly 2 colors
+invCmd "ppmpat -gingham2 ${clist1} 10 10"
+invCmd "ppmpat -argyle1  ${clist1} 10 10"
+invCmd "ppmpat -gingham2 ${clist3} 10 10"
+invCmd "ppmpat -argyle1  ${clist3} 10 10"
+
+# These require exactly 3 colors
+invCmd "ppmpat -gingham3 ${clist2} 10 10"
+invCmd "ppmpat -argyle2  ${clist2} 10 10"
+invCmd "ppmpat -madras   ${clist2} 10 10"
+invCmd "ppmpat -tartan   ${clist2} 10 10"
+invCmd "ppmpat -gingham3 ${clist4} 10 10"
+invCmd "ppmpat -argyle2  ${clist4} 10 10"
+invCmd "ppmpat -madras   ${clist4} 10 10"
+invCmd "ppmpat -tartan   ${clist4} 10 10"
+invCmd "ppmpat -squig    ${clist2} 10 10"
+invCmd "ppmpat -camo     ${clist2} 10 10"
+invCmd "ppmpat -anticamo ${clist2} 10 10"
+
+# The squig pattern has an aspect ratio restriction
+invCmd "ppmpat -squig ${clist3} 10 250"
+invCmd "ppmpat -squig ${clist3} 500 20"