diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2024-01-14 19:05:28 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2024-01-14 19:05:28 +0000 |
commit | 49b0eb1a2a99dc82b81a9355bb7851db6423486a (patch) | |
tree | 23d3f3ff66a83e1968e648554a85c2f334302281 /test | |
parent | 771e1f9460d70eb92f07716f88d9caa95f86527a (diff) | |
download | netpbm-mirror-49b0eb1a2a99dc82b81a9355bb7851db6423486a.tar.gz netpbm-mirror-49b0eb1a2a99dc82b81a9355bb7851db6423486a.tar.xz netpbm-mirror-49b0eb1a2a99dc82b81a9355bb7851db6423486a.zip |
Factor out 'test invalid' checks
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@4837 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'test')
53 files changed, 506 insertions, 1832 deletions
diff --git a/test/Execute-Tests b/test/Execute-Tests index 3c231d98..c86121dc 100755 --- a/test/Execute-Tests +++ b/test/Execute-Tests @@ -50,7 +50,7 @@ esac # invoke, the list of tests to run ('Test-Order'), and *.ok files that # indicate the expected results of tests. -srcdir=$(dirname $0) +export srcdir=$(dirname $0) # Set tmpdir, which is used in some of the test scripts. By default # this is created by mktemp. The user can override and specify tmpdir, diff --git a/test/pamarith.test b/test/pamarith.test index 03ce7317..20c4039d 100755 --- a/test/pamarith.test +++ b/test/pamarith.test @@ -116,142 +116,68 @@ for image in maze.pbm ${input1_ppm} rm ${input1_ppm} -echo "Invalid command-line argument combinations." 1>&2 -echo "Error messages should appear below the line." 1>&2 -echo "-----------------------------------------------------------" 1>&2 - echo "Test Invalid" -test_out=${tmpdir}/test_out +. ${srcdir}/test-invalid.inc # multiple functions -pamarith -add -subtract testimg.ppm testimg.ppm > ${test_out} || \ - printf "Expected failure 1 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamarith -multiply -divide testimg.ppm testimg.ppm > ${test_out} || \ - printf "Expected failure 2 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamarith -difference -minimum testimg.ppm testimg.ppm > ${test_out} || \ - printf "Expected failure 3 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamarith -maximum -mean testimg.ppm testimg.ppm > ${test_out} || \ - printf "Expected failure 4 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamarith -compare -and testimg.ppm testimg.ppm > ${test_out} || \ - printf "Expected failure 5 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamarith -compare -equal testimg.ppm testimg.ppm > ${test_out} || \ - printf "Expected failure 6 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamarith -or -nand testimg.ppm testimg.ppm > ${test_out} || \ - printf "Expected failure 7 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamarith -nor -xor testimg.ppm testimg.ppm > ${test_out} || \ - printf "Expected failure 8 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamarith -shiftleft -shiftright testimg.ppm testimg.ppm > ${test_out} || \ - printf "Expected failure 9 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pamarith -add -subtract testimg.ppm testimg.ppm" +invCmd "pamarith -multiply -divide testimg.ppm testimg.ppm" +invCmd "pamarith -difference -minimum testimg.ppm testimg.ppm" +invCmd "pamarith -maximum -mean testimg.ppm testimg.ppm" +invCmd "pamarith -compare -and testimg.ppm testimg.ppm" +invCmd "pamarith -compare -equal testimg.ppm testimg.ppm" +invCmd "pamarith -or -nand testimg.ppm testimg.ppm" +invCmd "pamarith -nor -xor testimg.ppm testimg.ppm" +invCmd "pamarith -shiftleft -shiftright testimg.ppm testimg.ppm" # -add does not take a value -pamarith -add=1 testimg.ppm testimg.ppm > ${test_out} || \ - printf "Expected failure 10 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pamarith -add=1 testimg.ppm testimg.ppm" # No function -pamarith -plain testimg.ppm testimg.ppm > ${test_out} || \ - printf "Expected failure 11 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamarith testimg.ppm testimg.ppm > ${test_out} || \ - printf "Expected failure 12 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pamarith -plain testimg.ppm testimg.ppm" +invCmd "pamarith testimg.ppm testimg.ppm" # Just one input image file -pamarith -add testimg.ppm > ${test_out} || \ - printf "Expected failure 13 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pamarith -add testimg.ppm" # No input image file -pamarith -add > ${test_out} || \ - printf "Expected failure 14 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pamarith -add" # Input images with different depth (number of planes) -pamchannel -infile testimg.ppm 0 1 | \ - pamarith -add testimg.ppm - > ${test_out} || \ - printf "Expected failure 15 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +input1_pam=${tmpdir}/input1.pam -# Input images with different x/y dimensions +pamchannel -infile testimg.ppm 0 1 > ${input1_pam} +invCmd "pamarith -add testimg.ppm ${input1_pam}" +rm ${input1_pam} -pamarith -add testimg.ppm testgrid.pbm > ${test_out} || \ - printf "Expected failure 16 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamenlarge -xscale=2 testgrid.pbm | \ - pamarith -add testgrid.pbm - > ${test_out} || \ - printf "Expected failure 17 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +# Input images with different x/y dimensions -pamenlarge -yscale=3 testgrid.pbm | \ - pamarith -add testgrid.pbm - > ${test_out} || \ - printf "Expected failure 18 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pamarith -add testimg.ppm testgrid.pbm" -# Invalid usage of -closeness +input1_pbm=${tmpdir}/input1.pbm +input2_pbm=${tmpdir}/input2.pbm -pamarith -equal -closeness=100.1 testgrid.pbm > ${test_out} || \ - printf "Expected failure 19 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +pamenlarge -xscale=2 testgrid.pbm > ${input1_pbm} +invCmd "pamarith -add testgrid.pbm ${input1_pbm}" +rm ${input1_pbm} -pamarith -equal -closeness=-10 testgrid.pbm > ${test_out} || \ - printf "Expected failure 20 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +pamenlarge -yscale=3 testgrid.pbm > ${input2_pbm} +invCmd "pamarith -add testgrid.pbm ${input2_pbm}" +rm ${input2_pbm} -pamarith -closeness -equal testgrid.pbm > ${test_out} || \ - printf "Expected failure 21 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +# Invalid usage of -closeness -pamarith -compare -closeness=10 testgrid.pbm > ${test_out} || \ - printf "Expected failure 22 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pamarith -equal -closeness=100.1 testgrid.pbm" +invCmd "pamarith -equal -closeness=-10 testgrid.pbm" +invCmd "pamarith -closeness -equal testgrid.pbm" +invCmd "pamarith -compare -closeness=10 testgrid.pbm" # Bit string functions # Create PGM test input @@ -266,67 +192,21 @@ pgmmake -maxval=8191 1.0 3 1 > ${input5_pgm} # Bit string functions - Maxval must match -pamarith -and ${input3_pgm} ${input5_pgm} > ${test_out} || \ - printf "Expected failure 23 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamarith -or ${input3_pgm} ${input5_pgm} > ${test_out} || \ - printf "Expected failure 24 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamarith -nand ${input3_pgm} ${input5_pgm} > ${test_out} || \ - printf "Expected failure 25 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamarith -nor ${input3_pgm} ${input5_pgm} > ${test_out} || \ - printf "Expected failure 26 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamarith -xor ${input3_pgm} ${input5_pgm} > ${test_out} || \ - printf "Expected failure 27 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pamarith -and ${input3_pgm} ${input5_pgm}" +invCmd "pamarith -or ${input3_pgm} ${input5_pgm}" +invCmd "pamarith -nand ${input3_pgm} ${input5_pgm}" +invCmd "pamarith -nor ${input3_pgm} ${input5_pgm}" +invCmd "pamarith -xor ${input3_pgm} ${input5_pgm}" # Bit string functions - Maxval must be 2^n -1 -pamarith -and ${input4_pgm} ${input4_pgm} > ${test_out} || \ - printf "Expected failure 28 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamarith -or ${input4_pgm} ${input4_pgm} > ${test_out} || \ - printf "Expected failure 29 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamarith -nand ${input4_pgm} ${input4_pgm} > ${test_out} || \ - printf "Expected failure 30 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamarith -nor ${input4_pgm} ${input4_pgm} > ${test_out} || \ - printf "Expected failure 31 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamarith -xor ${input4_pgm} ${input4_pgm} > ${test_out} || \ - printf "Expected failure 32 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamarith -shiftleft ${input4_pgm} ${input4_pgm} > ${test_out} || \ - printf "Expected failure 33 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamarith -shiftright ${input4_pgm} ${input4_pgm} > ${test_out} || \ - printf "Expected failure 34 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pamarith -and ${input4_pgm} ${input4_pgm}" +invCmd "pamarith -or ${input4_pgm} ${input4_pgm}" +invCmd "pamarith -nand ${input4_pgm} ${input4_pgm}" +invCmd "pamarith -nor ${input4_pgm} ${input4_pgm}" +invCmd "pamarith -xor ${input4_pgm} ${input4_pgm}" +invCmd "pamarith -shiftleft ${input4_pgm} ${input4_pgm}" +invCmd "pamarith -shiftright ${input4_pgm} ${input4_pgm}" rm ${input3_pgm} ${input4_pgm} ${input5_pgm} @@ -334,45 +214,15 @@ rm ${input3_pgm} ${input4_pgm} ${input5_pgm} # Only the functions that are commutative and associative allow # three or more inputs. -pamarith -subtract testimg.ppm testimg.ppm testimg.ppm > ${test_out} || \ - printf "Expected failure 35 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamarith -divide testimg.ppm testimg.ppm testimg.ppm > ${test_out} || \ - printf "Expected failure 36 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamarith -compare testimg.ppm testimg.ppm testimg.ppm > ${test_out} || \ - printf "Expected failure 37 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamarith -difference testimg.ppm testimg.ppm testimg.ppm > ${test_out} || \ - printf "Expected failure 38 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamarith -shiftleft testimg.ppm testimg.ppm testimg.ppm > ${test_out} || \ - printf "Expected failure 39 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamarith -shiftright testimg.ppm testimg.ppm testimg.ppm > ${test_out} || \ - printf "Expected failure 40 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pamarith -subtract testimg.ppm testimg.ppm testimg.ppm" +invCmd "pamarith -divide testimg.ppm testimg.ppm testimg.ppm" +invCmd "pamarith -compare testimg.ppm testimg.ppm testimg.ppm" +invCmd "pamarith -difference testimg.ppm testimg.ppm testimg.ppm" +invCmd "pamarith -shiftleft testimg.ppm testimg.ppm testimg.ppm" +invCmd "pamarith -shiftright testimg.ppm testimg.ppm testimg.ppm" # Currently -equal and -mean do not allow more than two input images. # These two cases should be removed once improvements are made. -pamarith -equal testgrid.pbm testgrid.pbm testgrid.pbm > ${test_out} || \ - printf "Expected failure 41 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamarith -mean testgrid.pbm testgrid.pbm testgrid.pbm > ${test_out} || \ - printf "Expected failure 42 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pamarith -equal testgrid.pbm testgrid.pbm testgrid.pbm" +invCmd "pamarith -mean testgrid.pbm testgrid.pbm testgrid.pbm" diff --git a/test/pambrighten.ok b/test/pambrighten.ok index 6c58b4c9..8dc9e71e 100644 --- a/test/pambrighten.ok +++ b/test/pambrighten.ok @@ -78,19 +78,11 @@ Test 4: Should print 3990234518 268 six times 3990234518 268 3990234518 268 3990234518 268 -Test Error: Should print 1 six times -1 -1 -1 -1 -1 -1 -Test Error: Should print 99 followed by 1, four times -99 -1 -99 -1 -99 -1 -99 -1 +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) diff --git a/test/pambrighten.test b/test/pambrighten.test index 00e405dd..d79ad583 100755 --- a/test/pambrighten.test +++ b/test/pambrighten.test @@ -10,7 +10,7 @@ cat > ${input_ppm} << EOF P3 8 1 255 -0 0 0 0 0 100 0 100 0 0 100 100 100 0 0 100 0 100 100 100 0 100 100 100 +0 0 0 0 0 100 0 100 0 0 100 100 100 0 0 100 0 100 100 100 0 100 100 100 EOF # Test 1 @@ -50,50 +50,14 @@ pambrighten -s +200 ${input_pgm} | cksum rm ${input_pgm} +echo "Test Invalid" -# Test 2 -# These should all fail. +. ${srcdir}/test-invalid.inc -echo "Invalid command-line argument combinations." 1>&2 -echo "Error messages should appear below the line." 1>&2 -echo "-----------------------------------------------------------" 1>&2 - -echo "Test Error: Should print 1 six times" - -output_ppm=${tmpdir}/output.ppm - -pambrighten -v -120 testimg.ppm > ${output_ppm} -echo $? -test -s ${output_ppm} -echo $? -pambrighten -s -120 testimg.ppm > ${output_ppm} -echo $? -test -s ${output_ppm} -echo $? -pambrighten 10 testimg.ppm > ${output_ppm} -echo $? -test -s ${output_ppm} -echo $? - - -echo "Test Error: Should print 99 followed by 1, four times" - -pambrighten -s 1.20 testimg.ppm > ${output_ppm} -echo $? -test -s ${output_ppm} -echo $? -pambrighten -v 10.5 testimg.ppm > ${output_ppm} -echo $? -test -s ${output_ppm} -echo $? -pambrighten -v testimg.ppm > ${output_ppm} -echo $? -test -s ${output_ppm} -echo $? -pambrighten -s testimg.ppm > ${output_ppm} -echo $? -test -s ${output_ppm} -echo $? - - -rm -f ${output_ppm} +invCmd "pambrighten -v -120 testimg.ppm" +invCmd "pambrighten -s -120 testimg.ppm" +invCmd "pambrighten 10 testimg.ppm" +invCmd "pambrighten -s 1.20 testimg.ppm" +invCmd "pambrighten -v 10.5 testimg.ppm" +invCmd "pambrighten -v testimg.ppm" +invCmd "pambrighten -s testimg.ppm" diff --git a/test/pamcat1.test b/test/pamcat1.test index 902ef6d7..9480228c 100755 --- a/test/pamcat1.test +++ b/test/pamcat1.test @@ -187,82 +187,26 @@ rm ${seq2_4h_pam} ${seq2_4v_pam} ${seq2_4v3_pam} ${seq2_4h4_pam} echo "Test Invalid" -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 +. ${srcdir}/test-invalid.inc # direction not specified -pamcat testgrid.pbm testimg.ppm > ${test_out} || \ - printf "Expected failure 1 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pamcat testgrid.pbm testimg.ppm" # both directions specified -pamcat -topbottom -leftright testgrid.pbm testimg.ppm > ${test_out} || \ - printf "Expected failure 2 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pamcat -topbottom -leftright testgrid.pbm testimg.ppm" # both pad colors specified -pamcat -topbottom -white -black testgrid.pbm testimg.ppm > ${test_out} || \ - printf "Expected failure 3 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -# justification parameters overspecified -pamcat -lr -jtop -jbottom testgrid.pbm testimg.ppm > ${test_out} || \ - printf "Expected failure 4 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamcat -lr -jtop -jcenter testgrid.pbm testimg.ppm > ${test_out} || \ - printf "Expected failure 5 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamcat -lr -jcenter -jbottom testgrid.pbm testimg.ppm > ${test_out} || \ - printf "Expected failure 6 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamcat -tb -jleft -jright testgrid.pbm testimg.ppm > ${test_out} || \ - printf "Expected failure 7 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamcat -tb -jleft -jcenter testgrid.pbm testimg.ppm > ${test_out} || \ - printf "Expected failure 8 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamcat -tb -jcenter -jright testgrid.pbm testimg.ppm > ${test_out} || \ - printf "Expected failure 9 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -# justification parameter in the wrong direction -pamcat -lr -jleft testgrid.pbm testimg.ppm > ${test_out} || \ - printf "Expected failure 10 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamcat -lr -jright testgrid.pbm testimg.ppm > ${test_out} || \ - printf "Expected failure 11 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamcat -tb -jtop testgrid.pbm testimg.ppm > ${test_out} || \ - printf "Expected failure 12 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamcat -tb -jbottom testgrid.pbm testimg.ppm > ${test_out} || \ - printf "Expected failure 13 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pamcat -topbottom -white -black testgrid.pbm testimg.ppm" +invCmd "pamcat -lr -jtop -jbottom testgrid.pbm testimg.ppm" +invCmd "pamcat -lr -jtop -jcenter testgrid.pbm testimg.ppm" +invCmd "pamcat -lr -jcenter -jbottom testgrid.pbm testimg.ppm" +invCmd "pamcat -tb -jleft -jright testgrid.pbm testimg.ppm" +invCmd "pamcat -tb -jleft -jcenter testgrid.pbm testimg.ppm" +invCmd "pamcat -tb -jcenter -jright testgrid.pbm testimg.ppm" +invCmd "pamcat -lr -jleft testgrid.pbm testimg.ppm" +invCmd "pamcat -lr -jright testgrid.pbm testimg.ppm" +invCmd "pamcat -tb -jtop testgrid.pbm testimg.ppm" +invCmd "pamcat -tb -jbottom testgrid.pbm testimg.ppm" # more than one input image from standard input cat testgrid.pbm | pamcat -lr - - testimg.ppm > ${test_out} || \ diff --git a/test/pamchannel.test b/test/pamchannel.test index 2f772bf9..f3399343 100755 --- a/test/pamchannel.test +++ b/test/pamchannel.test @@ -41,17 +41,8 @@ test_out=${tmpdir}/test_out echo "Test Invalid" -pamchannel -infile testgrid.pbm 1 > ${test_out} || \ - printf "Expected failure 1 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamchannel -infile testimg.ppm 3 > ${test_out} || \ - printf "Expected failure 2 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamtopam testimg.ppm | pamchannel -infile=- 4 > ${test_out} || \ - printf "Expected failure 3 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +. ${srcdir}/test-invalid.inc + +invCmd "pamchannel -infile testgrid.pbm 1" +invCmd "pamchannel -infile testimg.ppm 3" +invCmd "pamtopam testimg.ppm | pamchannel -infile=- 4" diff --git a/test/pamcrater.test b/test/pamcrater.test index 1b4ffd54..5362bde3 100755 --- a/test/pamcrater.test +++ b/test/pamcrater.test @@ -52,33 +52,17 @@ pamshadedrelief ${test100_pam} > ${testshaded_pam} pamcut -top=$((128 - 99)) -height=1 ${testshaded_pam} | cksum ) | uniq -c | awk '{print $1}' -rm ${testshaded_pam} ${test100_pam} ${test150_pam} +rm ${testshaded_pam} ${test150_pam} echo "Test Invalid." 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 - -pamcrater -width 0 > ${test_out} || \ - printf "Expected failure 1 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamcrater -height 0 > ${test_out} || \ - printf "Expected failure 2 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamcrater -number 0 > ${test_out} || \ - printf "Expected failure 3 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamcrater -test -radius=10 | pamshadedrelief -gamma 0 > ${test_out} || \ - printf "Expected failure 4 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +. ${srcdir}/test-invalid.inc + +invCmd "pamcrater -width 0" +invCmd "pamcrater -height 0" +invCmd "pamcrater -number 0" +invCmd "pamshadedrelief -gamma 0 ${test100_pam}" + +rm ${test100_pam} diff --git a/test/pamcut.ok b/test/pamcut.ok index 60919865..3c490427 100644 --- a/test/pamcut.ok +++ b/test/pamcut.ok @@ -28,9 +28,9 @@ Expected failure 6 (no output) Expected failure 7 (no output) Expected failure 8 (no output) Expected failure 9 (no output) -Expected failure 6 (no output) Expected failure 10 (no output) Expected failure 11 (no output) Expected failure 12 (no output) Expected failure 13 (no output) Expected failure 14 (no output) +Expected failure 15 (no output) diff --git a/test/pamcut.test b/test/pamcut.test index 7cda5bce..7cbabf51 100755 --- a/test/pamcut.test +++ b/test/pamcut.test @@ -30,7 +30,7 @@ echo "Test 5. Should print 281226646 481 five times" mazesize=$(pamfile -size maze.pbm) width=$(echo ${mazesize} | cut -d " " -f 1) height=$(echo ${mazesize} | cut -d " " -f 2) - + pamcut -croptop 0 -cropleft 0 -cropbottom 0 -cropright 0 maze.pbm | \ cksum pamcut -top 0 -left 0 -bottom $((${height} -1)) -right $((${width} -1)) \ @@ -38,7 +38,7 @@ pamcut -top 0 -left 0 -bottom $((${height} -1)) -right $((${width} -1)) \ pamcut -top 0 -left 0 -bottom -1 -right -1 maze.pbm | cksum pamcut -top 0 -left 0 -width ${width} -height ${height} maze.pbm | cksum pamcut maze.pbm | cksum - + echo "Test 6. Should print 3412257956 129" pbmmake -g 50 50 | pamcut 5 5 30 30 | cksum @@ -46,89 +46,25 @@ pbmmake -g 50 50 | pamcut 5 5 30 30 | cksum 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 +. ${srcdir}/test-invalid.inc # overspecification -pamcut -left=1 -right=1 -width=14 testgrid.pbm > ${test_out} || \ - printf "Expected failure 1 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamcut -top=1 -bottom=1 -height=16 testgrid.pbm > ${test_out} || \ - printf "Expected failure 2 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamcut -right=1 -cropright=1 testgrid.pbm > ${test_out} || \ - printf "Expected failure 3 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamcut -top=1 -croptop=1 testgrid.pbm > ${test_out} || \ - printf "Expected failure 4 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamcut -bottom=1 -cropbottom=1 testgrid.pbm > ${test_out} || \ - printf "Expected failure 5 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamcut -left=1 -cropleft=1 testgrid.pbm > ${test_out} || \ - printf "Expected failure 6 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -# excessive cropping -pamcut -cropleft=7 -cropright=8 testgrid.pbm > ${test_out} || \ - printf "Expected failure 7 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamcut -left=7 -right=6 testgrid.pbm > ${test_out} || \ - printf "Expected failure 8 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamcut -croptop=8 -cropbottom=8 testgrid.pbm > ${test_out} || \ - printf "Expected failure 9 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamcut -top=10 -bottom=9 testgrid.pbm > ${test_out} || \ - printf "Expected failure 6 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pamcut -left=1 -right=1 -width=14 testgrid.pbm" +invCmd "pamcut -top=1 -bottom=1 -height=16 testgrid.pbm" +invCmd "pamcut -right=1 -cropright=1 testgrid.pbm" +invCmd "pamcut -top=1 -croptop=1 testgrid.pbm" +invCmd "pamcut -bottom=1 -cropbottom=1 testgrid.pbm" +invCmd "pamcut -left=1 -cropleft=1 testgrid.pbm" +invCmd "pamcut -cropleft=7 -cropright=8 testgrid.pbm" +invCmd "pamcut -left=7 -right=6 testgrid.pbm" +invCmd "pamcut -croptop=8 -cropbottom=8 testgrid.pbm" +invCmd "pamcut -top=10 -bottom=9 testgrid.pbm" # pad absent -pamcut -cropleft=1 -width=14 testgrid.pbm > ${test_out} || \ - printf "Expected failure 10 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamcut -croptop=1 -height=16 testgrid.pbm > ${test_out} || \ - printf "Expected failure 11 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pamcut -cropleft=1 -width=14 testgrid.pbm" +invCmd "pamcut -croptop=1 -height=16 testgrid.pbm" # legacy style: insufficient number of positional parameters -pamcut 5 testimg.ppm > ${test_out} || \ - printf "Expected failure 12 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamcut 5 4 testimg.ppm > ${test_out} || \ - printf "Expected failure 13 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamcut 5 5 30 testimg.ppm > ${test_out} || \ - printf "Expected failure 14 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pamcut 5 testimg.ppm" +invCmd "pamcut 5 4 testimg.ppm" +invCmd "pamcut 5 5 30 testimg.ppm" diff --git a/test/pamdepth.test b/test/pamdepth.test index d97992a1..e938a630 100755 --- a/test/pamdepth.test +++ b/test/pamdepth.test @@ -24,17 +24,7 @@ pamdepth 255 testimg.ppm | cmp -s - testimg.ppm # Test Invalid 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 +. ${srcdir}/test-invalid.inc -pamdepth 0 testgrid.pbm > ${test_out} || \ - printf "Expected failure 1 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamdepth 65536 testimg.ppm > ${test_out} || \ - printf "Expected failure 2 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pamdepth 0 testgrid.pbm" +invCmd "pamdepth 65536 testimg.ppm" diff --git a/test/pamditherbw.test b/test/pamditherbw.test index ea3e803f..76bcdbd7 100755 --- a/test/pamditherbw.test +++ b/test/pamditherbw.test @@ -39,71 +39,19 @@ pamditherbw -cluster8 ${test_red} | cksum echo "Test: Invalid" -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 - -pamditherbw -fs -atkinson ${test_red} > ${test_out} || \ - printf "Expected failure 1 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamditherbw -floyd -atkinson ${test_red} > ${test_out} || \ - printf "Expected failure 2 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamditherbw -dither8 -cluster3 ${test_red} > ${test_out} || \ - printf "Expected failure 3 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamditherbw -cluster3 -cluster4 ${test_red} > ${test_out} || \ - printf "Expected failure 4 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamditherbw -cluster3 -cluster8 ${test_red} > ${test_out} || \ - printf "Expected failure 5 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamditherbw -cluster4 -cluster8 ${test_red} > ${test_out} || \ - printf "Expected failure 6 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamditherbw -hilbert -threshold ${test_red} > ${test_out} || \ - printf "Expected failure 7 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamditherbw -clump=8 ${test_red} > ${test_out} || \ - printf "Expected failure 8 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamditherbw -fs -clump=8 ${test_red} > ${test_out} || \ - printf "Expected failure 9 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamditherbw -hilbert -clump=1 ${test_red} > ${test_out} || \ - printf "Expected failure 10 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamditherbw -th -value=-1 ${test_red} > ${test_out} || \ - printf "Expected failure 11 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamditherbw -th -value=1.1 ${test_red} > ${test_out} || \ - printf "Expected failure 12 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +. ${srcdir}/test-invalid.inc + +invCmd "pamditherbw -fs -atkinson ${test_red}" +invCmd "pamditherbw -floyd -atkinson ${test_red}" +invCmd "pamditherbw -dither8 -cluster3 ${test_red}" +invCmd "pamditherbw -cluster3 -cluster4 ${test_red}" +invCmd "pamditherbw -cluster3 -cluster8 ${test_red}" +invCmd "pamditherbw -cluster4 -cluster8 ${test_red}" +invCmd "pamditherbw -hilbert -threshold ${test_red}" +invCmd "pamditherbw -clump=8 ${test_red}" +invCmd "pamditherbw -fs -clump=8 ${test_red}" +invCmd "pamditherbw -hilbert -clump=1 ${test_red}" +invCmd "pamditherbw -th -value=-1 ${test_red}" +invCmd "pamditherbw -th -value=1.1 ${test_red}" rm ${test_red} diff --git a/test/pamfile.test b/test/pamfile.test index 7be061ef..d605326d 100755 --- a/test/pamfile.test +++ b/test/pamfile.test @@ -22,25 +22,13 @@ cat testgrid.pbm testimg.ppm testgrid.pbm | pamfile -machine 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 - -pamfile -size -machine testimg.ppm > ${test_out} || \ - printf "Expected failure 1 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamfile -count -machine testimg.ppm > ${test_out} || \ - printf "Expected failure 2 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -head -n1 testimg.ppm | pamfile > ${test_out} || \ - printf "Expected failure 3 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +. ${srcdir}/test-invalid.inc + +invCmd "pamfile -size -machine testimg.ppm" +invCmd "pamfile -count -machine testimg.ppm" + +head1_ppm=${tmpdir}/head1.ppm + +head -n1 testimg.ppm > ${head1_ppm} +invCmd "pamfile ${head1_ppm}" +rm ${head1_ppm} diff --git a/test/pamfind.test b/test/pamfind.test index e7c9707f..079e35f4 100755 --- a/test/pamfind.test +++ b/test/pamfind.test @@ -31,34 +31,11 @@ comm -12 ${sorted0_res} ${sorted1_res} | rm ${sorted0_res} ${sorted1_res} -# Test 4 - -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 - echo "Test Invalid" -pamfind -color=black -target=1,1,1 testimg.ppm > ${test_out} || \ - printf "Expected failure 1 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamfind -target=0,0 testimg.ppm > ${test_out} || \ - printf "Expected failure 2 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamfind -target=0,0,0,0 testimg.ppm > ${test_out} || \ - printf "Expected failure 3 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +. ${srcdir}/test-invalid.inc -pamfind testimg.ppm > ${test_out} || \ - printf "Expected failure 4 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pamfind -color=black -target=1,1,1 testimg.ppm" +invCmd "pamfind -target=0,0 testimg.ppm" +invCmd "pamfind -target=0,0,0,0 testimg.ppm" +invCmd "pamfind testimg.ppm" diff --git a/test/pamfunc.test b/test/pamfunc.test index 21f69247..b1b9edfc 100755 --- a/test/pamfunc.test +++ b/test/pamfunc.test @@ -84,130 +84,32 @@ pamfunc -xormask 0x1 maze.pbm | pamfunc -xormask 0x1 | cksum pamfunc -shiftleft 0 maze.pbm | cksum pamfunc -shiftright 0 maze.pbm | cksum -echo "Invalid command-line argument combinations." 1>&2 -echo "Error messages should appear below the line." 1>&2 -echo "-----------------------------------------------------------" 1>&2 echo "Test Invalid" -test_out=${tmpdir}/test_out - -pamfunc -multiplier testimg.ppm > ${test_out} || \ - printf "Expected failure 1 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamfunc -multiplier=-1 testimg.ppm > ${test_out} || \ - printf "Expected failure 2 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamfunc -divisor testimg.ppm > ${test_out} || \ - printf "Expected failure 3 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamfunc -divisor=-20 testimg.ppm > ${test_out} || \ - printf "Expected failure 4 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamfunc -adder testimg.ppm > ${test_out} || \ - printf "Expected failure 5 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamfunc -adder 0.5 testimg.ppm > ${test_out} || \ - printf "Expected failure 6 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamfunc -subtractor testimg.ppm > ${test_out} || \ - printf "Expected failure 7 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamfunc -subtractor 0.1 testimg.ppm > ${test_out} || \ - printf "Expected failure 8 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamfunc -multiplier=1 -divisor=2 testimg.ppm > ${test_out} || \ - printf "Expected failure 9 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamfunc -adder=2 -subtractor=3 testimg.ppm > ${test_out} || \ - printf "Expected failure 10 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamfunc -min testimg.ppm > ${test_out} || \ - printf "Expected failure 11 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamfunc -max testimg.ppm > ${test_out} || \ - printf "Expected failure 12 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamfunc -andmask testimg.ppm > ${test_out} || \ - printf "Expected failure 13 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamfunc -ormask testimg.ppm > ${test_out} || \ - printf "Expected failure 14 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamfunc -xormask testimg.ppm > ${test_out} || \ - printf "Expected failure 15 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamfunc -not 1 testimg.ppm > ${test_out} || \ - printf "Expected failure 16 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamfunc -min=1 -max=2 testimg.ppm > ${test_out} || \ - printf "Expected failure 17 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamfunc -andmask=1 -ormask=0 testimg.ppm > ${test_out} || \ - printf "Expected failure 18 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamfunc -andmask=0xffff testimg.ppm > ${test_out} || \ - printf "Expected failure 19 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamfunc -shiftleft testimg.ppm > ${test_out} || \ - printf "Expected failure 20 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamfunc -shiftright testimg.ppm > ${test_out} || \ - printf "Expected failure 21 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamfunc -changemaxval testimg.ppm > ${test_out} || \ - printf "Expected failure 22 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamfunc -shiftleft=1 -shiftright=1 testimg.ppm > ${test_out} || \ - printf "Expected failure 23 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamfunc -multiplier=0.5 -changemaxval=65535 testimg.ppm > ${test_out} || \ - printf "Expected failure 24 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +. ${srcdir}/test-invalid.inc + +invCmd "pamfunc -multiplier testimg.ppm" +invCmd "pamfunc -multiplier=-1 testimg.ppm" +invCmd "pamfunc -divisor testimg.ppm" +invCmd "pamfunc -divisor=-20 testimg.ppm" +invCmd "pamfunc -adder testimg.ppm" +invCmd "pamfunc -adder 0.5 testimg.ppm" +invCmd "pamfunc -subtractor testimg.ppm" +invCmd "pamfunc -subtractor 0.1 testimg.ppm" +invCmd "pamfunc -multiplier=1 -divisor=2 testimg.ppm" +invCmd "pamfunc -adder=2 -subtractor=3 testimg.ppm" +invCmd "pamfunc -min testimg.ppm" +invCmd "pamfunc -max testimg.ppm" +invCmd "pamfunc -andmask testimg.ppm" +invCmd "pamfunc -ormask testimg.ppm" +invCmd "pamfunc -xormask testimg.ppm" +invCmd "pamfunc -not 1 testimg.ppm" +invCmd "pamfunc -min=1 -max=2 testimg.ppm" +invCmd "pamfunc -andmask=1 -ormask=0 testimg.ppm" +invCmd "pamfunc -andmask=0xffff testimg.ppm" +invCmd "pamfunc -shiftleft testimg.ppm" +invCmd "pamfunc -shiftright testimg.ppm" +invCmd "pamfunc -changemaxval testimg.ppm" +invCmd "pamfunc -shiftleft=1 -shiftright=1 testimg.ppm" +invCmd "pamfunc -multiplier=0.5 -changemaxval=65535 testimg.ppm" diff --git a/test/pamgauss.ok b/test/pamgauss.ok index cc4d1465..98d97312 100644 --- a/test/pamgauss.ok +++ b/test/pamgauss.ok @@ -89,3 +89,6 @@ 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) diff --git a/test/pamgauss.test b/test/pamgauss.test index b15ccbf0..34b6630a 100755 --- a/test/pamgauss.test +++ b/test/pamgauss.test @@ -19,35 +19,13 @@ pamgauss 3 3 -sigma=0.5 -tupletype="GRAYSCALE" | pamfile 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 - -tmpdir=${tmpdir:-/tmp} -test_out=${tmpdir}/test_out - -pamgauss 3 3 > ${test_out} || \ - printf "Expected failure 1 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamgauss 3 3 -sigma=0 > ${test_out} || \ - printf "Expected failure 2 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamgauss 3 3 -sigma=-1.5 > ${test_out} || \ - printf "Expected failure 3 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamgauss 3 -sigma=0.5 > ${test_out} || \ - printf "Expected failure 4 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamgauss 3 3 3 -sigma=0.5 > ${test_out} || \ - printf "Expected failure 5 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +. ${srcdir}/test-invalid.inc + +invCmd "pamgauss -sigma=0.5 " +invCmd "pamgauss 0 5 -sigma=0.5 " +invCmd "pamgauss 5 0 -sigma=0.5" +invCmd "pamgauss 3 3 " +invCmd "pamgauss 3 3 -sigma=0 " +invCmd "pamgauss 3 3 -sigma=-1.5" +invCmd "pamgauss 3 -sigma=0.5 " +invCmd "pamgauss 3 3 3 -sigma=0.5 " diff --git a/test/pamhue.test b/test/pamhue.test index ca7a7d82..ce148a45 100755 --- a/test/pamhue.test +++ b/test/pamhue.test @@ -34,15 +34,6 @@ pamhue -huechange=360 testimg.ppm | cmp -s - testimg.ppm echo "Test Invalid" -tmpdir=${tmpdir:-/tmp} -test_out=${tmpdir}/test_out - -echo 1>&2 -echo "Omission of mandatory argument." 1>&2 -echo "An error message should appear below the line." 1>&2 -echo "-----------------------------------------------------------" 1>&2 - -pamhue testimg.ppm > ${test_out} || \ - printf "Expected failure 1 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +. ${srcdir}/test-invalid.inc + +invCmd "pamhue testimg.ppm " diff --git a/test/pamrecolor.test b/test/pamrecolor.test index 4d75f2cc..b5674776 100755 --- a/test/pamrecolor.test +++ b/test/pamrecolor.test @@ -16,47 +16,16 @@ echo "Test 2. Should produce 3500040755 101532 twice" pamrecolor --targetcolor=rgb:80/80/80 testimg.ppm | cksum pamrecolor --colorspace=ntsc --targetcolor=rgb:80/80/80 testimg.ppm | cksum +. ${srcdir}/test-invalid.inc -test_out=${tmpdir}/test_out truncated_file=${tmpdir}/truncated.txt echo P6 > ${truncated_file} -echo 1>&2 -echo "Invalid command-line argument combinations." 1>&2 -echo "Error messages should appear below the line." 1>&2 -echo "-----------------------------------------------------------" 1>&2 - -pamrecolor --targetcolor=rgb:00/11/22 \ - --colorfile=${base1_pgm} testimg.ppm > ${test_out} || \ - printf "Expected failure 1 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamrecolor --rmult=0.3 --gmult=0.3 --bmult=0.3 \ - --colorfile=${base1_pgm} testimg.ppm > ${test_out} || \ - printf "Expected failure 2 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamrecolor --colorspace=void \ - --targetcolor=rgb:80/80/80 testimg.ppm > ${test_out} || \ - printf "Expected failure 3 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamrecolor --targetcolor=vague testimg.ppm > ${test_out} || \ - printf "Expected failure 4 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamrecolor --colorfile=${truncated_file} testimg.ppm > ${test_out} || \ - printf "Expected failure 5 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamrecolor --rmult=0.2989 --gmult=0.5866 testimg.ppm > ${test_out} || \ - printf "Expected failure 6 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pamrecolor --targetcolor=rgb:00/11/22 --colorfile=${base_pgm} testimg.ppm" +invCmd "pamrecolor --rmult=0.3 --gmult=0.3 --bmult=0.3 --colorfile=${base_pgm} testimg.ppm" +invCmd "pamrecolor --colorspace=void --targetcolor=rgb:80/80/80 testimg.ppm" +invCmd "pamrecolor --targetcolor=vague testimg.ppm" +invCmd "pamrecolor --colorfile=${truncated_file} testimg.ppm" +invCmd "pamrecolor --rmult=0.2989 --gmult=0.5866 testimg.ppm" rm ${base_pgm} ${truncated_file} diff --git a/test/pamrestack.test b/test/pamrestack.test index 776fe91b..c91830e4 100755 --- a/test/pamrestack.test +++ b/test/pamrestack.test @@ -58,34 +58,10 @@ pamrestack \ 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 - -pamrestack testgrid.pbm maze.pbm > ${test_out} || \ - printf "Expected failure 1 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamrestack -abort \ - -width=$((pixels * 2 + 1 )) maze.pbm > ${test_out} || \ - printf "Expected failure 2 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamrestack -crop \ - -width=$((pixels * 2 + 1)) maze.pbm > ${test_out} || \ - printf "Expected failure 3 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamrestack -width=0 maze.pbm > ${test_out} || \ - printf "Expected failure 4 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamrestack -width maze.pbm > ${test_out} || \ - printf "Expected failure 5 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +. ${srcdir}/test-invalid.inc + +invCmd "pamrestack testgrid.pbm maze.pbm" +invCmd "pamrestack -abort -width=$((pixels * 2 + 1 )) maze.pbm" +invCmd "pamrestack -crop -width=$((pixels * 2 + 1)) maze.pbm" +invCmd "pamrestack -width=0 maze.pbm" +invCmd "pamrestack -width maze.pbm" diff --git a/test/pamscale-reportonly.test b/test/pamscale-reportonly.test index 2bf1030a..39745809 100755 --- a/test/pamscale-reportonly.test +++ b/test/pamscale-reportonly.test @@ -19,48 +19,13 @@ pamscale -reportonly -pixels=45000 testimg.ppm echo "Test Invalid" -tmpdir=${tmpdir:-/tmp} -test_out=${tmpdir}/test_out +. ${srcdir}/test-invalid.inc # Expected failure cases -echo 1>&2 -echo "Invalid command-line argument combinations." 1>&2 -echo "Error messages should appear below the line." 1>&2 -echo "-----------------------------------------------------------" 1>&2 - -pamscale -reportonly -xsize=640 -ysize=400 -xscale=2 testimg.ppm > \ - ${test_out} || \ - printf "Expected failure 1 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamscale -reportonly -xsize=640 -xscale=2 -yscale=3 testimg.ppm > \ - ${test_out} || \ - printf "Expected failure 2 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamscale -reportonly -xsize=640 -ysize=400 -pixels=200000 testimg.ppm \ - > ${test_out} || \ - printf "Expected failure 3 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamscale -reportonly -xsize=640 -ysize=400 -xysize 640 400 testimg.ppm \ - > ${test_out} || \ - printf "Expected failure 4 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamscale -reportonly -xsize=640 -ysize=400 -xyfit 640 400 testimg.ppm \ - > ${test_out} || \ - printf "Expected failure 5 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamscale -reportonly -xsize=640 -ysize=400 -xyfill 640 400 testimg.ppm \ - > ${test_out} || \ - printf "Expected failure 6 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pamscale -reportonly -xsize=640 -ysize=400 -xscale=2 testimg.ppm" +invCmd "pamscale -reportonly -xsize=640 -xscale=2 -yscale=3 testimg.ppm" +invCmd "pamscale -reportonly -xsize=640 -ysize=400 -pixels=200000 testimg.ppm" +invCmd "pamscale -reportonly -xsize=640 -ysize=400 -xysize 640 400 testimg.ppm" +invCmd "pamscale -reportonly -xsize=640 -ysize=400 -xyfit 640 400 testimg.ppm" +invCmd "pamscale -reportonly -xsize=640 -ysize=400 -xyfill 640 400 testimg.ppm" diff --git a/test/pamseq.test b/test/pamseq.test index 61fbfac7..894e8d6d 100755 --- a/test/pamseq.test +++ b/test/pamseq.test @@ -8,35 +8,14 @@ pamseq 1 255 | cksum 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 +. ${srcdir}/test-invalid.inc -tmpdir=${tmpdir:-/tmp} -test_out=${tmpdir}/test_out - -pamseq 1 > ${test_out} || \ - printf "Expected failure 1 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamseq 0 255 > ${test_out} || \ - printf "Expected failure 2 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamseq 3 0 > ${test_out} || \ - printf "Expected failure 3 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pamseq 1" +invCmd "pamseq 0 255" +invCmd "pamseq 3 0" +# Tupletype string length=256 c64="0123456789012345678901234567890123456789012345678901234567890123" c256=${c64}${c64}${c64}${c64} -# Tupletype string length=256 - -pamseq -tupletype="${c256}" 3 15 > ${test_out} || \ - printf "Expected failure 4 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pamseq -tupletype=${c256} 3 15" diff --git a/test/pamshuffle.test b/test/pamshuffle.test index 700631cb..371b65a5 100755 --- a/test/pamshuffle.test +++ b/test/pamshuffle.test @@ -46,22 +46,8 @@ 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 +. ${srcdir}/test-invalid.inc -pamshuffle testimg.ppm testgrid.pbm > ${test_out} || \ - printf "Expected failure 1 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamshuffle -randomseed -column testgrid.pbm > ${test_out} || \ - printf "Expected failure 2 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamshuffle -randomseed=null testgrid.pbm > ${test_out} || \ - printf "Expected failure 3 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pamshuffle testimg.ppm testgrid.pbm" +invCmd "pamshuffle -randomseed -column testgrid.pbm" +invCmd "pamshuffle -randomseed=null testgrid.pbm" diff --git a/test/pamstack.test b/test/pamstack.test index 7c375b12..6374c4bd 100755 --- a/test/pamstack.test +++ b/test/pamstack.test @@ -93,33 +93,16 @@ s2=$(pamstack -firstmaxval ${std_pgm} | pamfile) test "$s0" = "$s1" && echo "true" || echo "false" test "$s0" = "$s2" && echo "true" || echo "false" - + # Test Invalid 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 - -test_out=${tmpdir}/test_out - -pamstack testgrid.pbm testimg.ppm > ${test_out} || \ - printf "Expected failure 1 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamstack ${i1_pgm} ${std_pgm} > ${test_out} || \ - printf "Expected failure 2 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +. ${srcdir}/test-invalid.inc -pamstack -lcmmaxval -firstmaxval testgrid.pbm testgrid.pbm > ${test_out} || \ - printf "Expected failure 3 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pamstack testgrid.pbm testimg.ppm" +invCmd "pamstack ${i1_pgm} ${std_pgm}" +invCmd "pamstack -lcmmaxval -firstmaxval testgrid.pbm testgrid.pbm" - rm ${i1_pgm} ${i2_pgm} ${i7_pgm} ${i31_pgm} ${std_pgm} ${max_pgm} diff --git a/test/pamsumm.test b/test/pamsumm.test index 6fef5972..eb41ee36 100755 --- a/test/pamsumm.test +++ b/test/pamsumm.test @@ -26,30 +26,9 @@ for type in -sum -min -max -mean 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 - -pamsumm -sum -min testimg.ppm > ${test_out} || \ - printf "Expected failure 1 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamsumm -sum -max testimg.ppm > ${test_out} || \ - printf "Expected failure 2 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamsumm -mean -max testimg.ppm > ${test_out} || \ - printf "Expected failure 3 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pamsumm testimg.ppm > ${test_out} || \ - printf "Expected failure 4 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +. ${srcdir}/test-invalid.inc + +invCmd "pamsumm -sum -min testimg.ppm" +invCmd "pamsumm -sum -max testimg.ppm" +invCmd "pamsumm -mean -max testimg.ppm" +invCmd "pamsumm testimg.ppm" diff --git a/test/pamtable.ok b/test/pamtable.ok index 5d69ffb7..b63a74c2 100644 --- a/test/pamtable.ok +++ b/test/pamtable.ok @@ -122,5 +122,4 @@ Test 8 65535 0 0| 0 0 65535| 0 0 65535| 0 65535 0 Test Invalid -Should print: Expected failure (no output) -Expected failure (no output) +Expected failure 1 (no output) diff --git a/test/pamtable.test b/test/pamtable.test index 740b2199..d42187f9 100755 --- a/test/pamtable.test +++ b/test/pamtable.test @@ -46,17 +46,10 @@ for maxval in 9 10 9999 10000 65535 echo "Test Invalid" -test_out=${tmpdir}/test.out +. ${srcdir}/test-invalid.inc -echo 1>&2 -echo "Invalid command-line argument combinations." 1>&2 -echo "Error messages should appear below the line." 1>&2 -echo "-----------------------------------------------------------" 1>&2 +input1_pam=${tmpdir}/input1.pam -echo "Should print: Expected failure (no output)" - -pamseq -tupletype="void" 1 1 | pamtable -tuple -hex > \ - ${test_out} || \ - printf "Expected failure " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +pamseq -tupletype="void" 1 1 > ${input1_pam} +invCmd "pamtable -tuple -hex ${input1_pam}" +rm ${input1_pam} diff --git a/test/pbmclean.test b/test/pbmclean.test index 9d59a5a6..64ed6df0 100755 --- a/test/pbmclean.test +++ b/test/pbmclean.test @@ -37,17 +37,8 @@ rm ${sheet_pbm} echo "Test Invalid" -test_out=${tmpdir}/test_out - -echo 1>&2 -echo "Invalid command-line argument combination." 1>&2 -echo "An error message should appear below the line." 1>&2 -echo "-----------------------------------------------------------" 1>&2 +. ${srcdir}/test-invalid.inc # overspecification -pbmclean -black -white -min=1 -extended testgrid.pbm > ${test_out} || \ - printf "Expected failure 1 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - +invCmd "pbmclean -black -white -min=1 -extended testgrid.pbm" # note that without -extended the above is valid. diff --git a/test/pbmmake.test b/test/pbmmake.test index 52765747..32153f95 100755 --- a/test/pbmmake.test +++ b/test/pbmmake.test @@ -20,54 +20,17 @@ for size in 8 13 18 23 28 33 38 43 48 53 58 63 68 73 78 83 88 93 98 ( pbmmake -w ${size} ${size} ; pbmmake -b ${size} ${size} ; pbmmake -g ${size} ${size} ) | cksum - done +done 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 - -tmpdir=${tmpdir:-/tmp} -test_out=${tmpdir}/test_out - -pbmmake -b -w -plain 1 1 > ${test_out} || \ - printf "Expected failure 1 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pbmmake -b -g -plain 1 1 > ${test_out} || \ - printf "Expected failure 2 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pbmmake -white -gray -plain 1 1 > ${test_out} || \ - printf "Expected failure 3 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pbmmake -white -plain > ${test_out} || \ - printf "Expected failure 4 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pbmmake -white -plain 1 > ${test_out} || \ - printf "Expected failure 5 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pbmmake -white -plain 1 0 > ${test_out} || \ - printf "Expected failure 6 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pbmmake -white -plain 0 1 > ${test_out} || \ - printf "Expected failure 7 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +. ${srcdir}/test-invalid.inc -pbmmake -white -plain 1 1 1 > ${test_out} || \ - printf "Expected failure 8 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pbmmake -b -w -plain 1 1" +invCmd "pbmmake -b -g -plain 1 1" +invCmd "pbmmake -white -gray -plain 1 1" +invCmd "pbmmake -white -plain" +invCmd "pbmmake -white -plain 1" +invCmd "pbmmake -white -plain 1 0" +invCmd "pbmmake -white -plain 0 1" +invCmd 'pbmmake -white -plain 1 1 1' diff --git a/test/pbmnoise-parameters.ok b/test/pbmnoise-parameters.ok index d430f0f1..640b438d 100644 --- a/test/pbmnoise-parameters.ok +++ b/test/pbmnoise-parameters.ok @@ -16,7 +16,6 @@ Expected failure 14 (no output) Expected failure 15 (no output) Expected failure 16 (no output) Expected failure 17 (no output) -Expected failure 17 (no output) Expected failure 18 (no output) Expected failure 19 (no output) Expected failure 20 (no output) @@ -24,3 +23,6 @@ Expected failure 21 (no output) Expected failure 22 (no output) Expected failure 23 (no output) Expected failure 24 (no output) +Expected failure 25 (no output) +Expected failure 26 (no output) +Expected failure 27 (no output) diff --git a/test/pbmnoise-parameters.test b/test/pbmnoise-parameters.test index 0d9319cc..d0e04ebf 100755 --- a/test/pbmnoise-parameters.test +++ b/test/pbmnoise-parameters.test @@ -2,142 +2,42 @@ # This script tests: pbmnoise # Also requires: -echo "Invalid command-line argument combinations." 1>&2 -echo "Error messages should appear below the line." 1>&2 -echo "-----------------------------------------------------------" 1>&2 - echo "Test Invalid" -test_out=${tmpdir}/test_out +. ${srcdir}/test-invalid.inc # Invalid -ratio arguments -pbmnoise -ratio 100 100 > ${test_out} || \ - printf "Expected failure 1 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pbmnoise -ratio 0 1 100 > ${test_out} || \ - printf "Expected failure 2 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pbmnoise -ratio=1.1 100 100 > ${test_out} || \ - printf "Expected failure 3 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pbmnoise -ratio=-1 100 100 > ${test_out} || \ - printf "Expected failure 4 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pbmnoise -ratio=half 100 100 > ${test_out} || \ - printf "Expected failure 5 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pbmnoise -ratio=0/1/1 100 100 > ${test_out} || \ - printf "Expected failure 6 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pbmnoise -ratio=-1/2 100 100 > ${test_out} || \ - printf "Expected failure 7 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pbmnoise -ratio=1/0 100 100 > ${test_out} || \ - printf "Expected failure 8 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pbmnoise -ratio=/2 100 100 > ${test_out} || \ - printf "Expected failure 9 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pbmnoise -ratio=4/2 100 100 > ${test_out} || \ - printf "Expected failure 10 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pbmnoise -ratio=6/ 100 100 > ${test_out} || \ - printf "Expected failure 11 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pbmnoise -ratio=1.0/2.0 100 100 > ${test_out} || \ - printf "Expected failure 12 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -# denominator must be power of 2 -pbmnoise -ratio=3/9 100 100 > ${test_out} || \ - printf "Expected failure 13 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pbmnoise -ratio=a/2 100 100 > ${test_out} || \ - printf "Expected failure 14 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - - -pbmnoise -ratio=2/a 100 100 > ${test_out} || \ - printf "Expected failure 15 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pbmnoise -ratio=1/-2 100 100 > ${test_out} || \ - printf "Expected failure 16 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pbmnoise -ratio 100 100" +invCmd "pbmnoise -ratio 0 1 100" +invCmd "pbmnoise -ratio=1.1 100 100" +invCmd "pbmnoise -ratio=-1 100 100" +invCmd "pbmnoise -ratio=half 100 100" +invCmd "pbmnoise -ratio=0/1/1 100 100" +invCmd "pbmnoise -ratio=-1/2 100 100" +invCmd "pbmnoise -ratio=1/0 100 100" +invCmd "pbmnoise -ratio=/2 100 100" +invCmd "pbmnoise -ratio=4/2 100 100" +invCmd "pbmnoise -ratio=6/ 100 100" +invCmd "pbmnoise -ratio=1.0/2.0 100 100" + +# denominator must be power of 2 +invCmd "pbmnoise -ratio=3/9 100 100" +invCmd "pbmnoise -ratio=a/2 100 100" +invCmd "pbmnoise -ratio=2/a 100 100" +invCmd "pbmnoise -ratio=1/-2 100 100" # Denominator must be 65536 or less -pbmnoise -ratio=1/65537 100 100 > ${test_out} || \ - printf "Expected failure 17 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pbmnoise -ratio=1/131072 100 100 > ${test_out} || \ - printf "Expected failure 17 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pbmnoise -endian=large 100 100 > ${test_out} || \ - printf "Expected failure 18 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pbmnoise -randomseed 100 100 > ${test_out} || \ - printf "Expected failure 19 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pbmnoise -randomseed=-1 100 100 > ${test_out} || \ - printf "Expected failure 20 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pbmnoise -randomseed=0.1 100 100 > ${test_out} || \ - printf "Expected failure 21 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pbmnoise > ${test_out} || \ - printf "Expected failure 22 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pbmnoise 100 > ${test_out} || \ - printf "Expected failure 23 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pbmnoise 100 200 300 > ${test_out} || \ - printf "Expected failure 24 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - - +invCmd "pbmnoise -ratio=1/65537 100 100" +invCmd "pbmnoise -ratio=1/131072 100 100" + +# Other +invCmd "pbmnoise" +invCmd "pbmnoise 100" +invCmd "pbmnoise 100 0" +invCmd "pbmnoise 0 100" +invCmd "pbmnoise 100 200 300" +invCmd "pbmnoise -endian=large 100 100" +invCmd "pbmnoise -randomseed 100 100" +invCmd "pbmnoise -randomseed=-1 100 100" +invCmd "pbmnoise -randomseed=0.1 100 100" diff --git a/test/pbmpage.test b/test/pbmpage.test index ee3dc25c..9cb46e22 100755 --- a/test/pbmpage.test +++ b/test/pbmpage.test @@ -11,25 +11,9 @@ pbmpage -a4 2 | cksum 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 +. ${srcdir}/test-invalid.inc -tmpdir=${tmpdir:-/tmp} -test_out=${tmpdir}/test_out +invCmd "pbmpage -a3 1" +invCmd "pbmpage 0" +invCmd "pbmpage 4" -pbmpage -a3 1 > ${test_out} || \ - printf "Expected failure 1 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pbmpage 0 > ${test_out} || \ - printf "Expected failure 2 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pbmpage 4 > ${test_out} || \ - printf "Expected failure 3 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} diff --git a/test/pbmpscale.test b/test/pbmpscale.test index 65ab6467..b99561f6 100755 --- a/test/pbmpscale.test +++ b/test/pbmpscale.test @@ -25,27 +25,10 @@ pbmtext -nomargin "9" | pbmpscale 9 | cksum echo "Test 10. Should print 3327221668 2111" pbmtext -nomargin "10" | pbmpscale 10 | cksum -tmpdir=${tmpdir:-/tmp} -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 - -pbmpscale testgrid.pbm > ${test_out} || \ - printf "Expected failure 1 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pbmpscale 0 testgrid.pbm > ${test_out} || \ - printf "Expected failure 2 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +. ${srcdir}/test-invalid.inc -pbmpscale 2 3 testgrid.pbm > ${test_out} || \ - printf "Expected failure 3 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pbmpscale testgrid.pbm" +invCmd "pbmpscale 0 testgrid.pbm" +invCmd "pbmpscale 2 3 testgrid.pbm" diff --git a/test/pbmtopgm.test b/test/pbmtopgm.test index f2c5cf1f..19378bb6 100755 --- a/test/pbmtopgm.test +++ b/test/pbmtopgm.test @@ -9,30 +9,9 @@ pbmtopgm -plain 1 1 testgrid.pbm echo "Test Invalid" -tmpdir=${tmpdir:-/tmp} -test_out=${tmpdir}/test_out +. ${srcdir}/test-invalid.inc -echo 1>&2 -echo "Invalid command-line argument combinations." 1>&2 -echo "Error messages should appear below the line." 1>&2 -echo "-----------------------------------------------------------" 1>&2 - -pbmtopgm 5 0 testgrid.pbm > ${test_out} || \ - printf "Expected failure 1 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pbmtopgm 0 9 testgrid.pbm > ${test_out} || \ - printf "Expected failure 2 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pbmtopgm 15 5 testgrid.pbm > ${test_out} || \ - printf "Expected failure 3 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pbmtopgm 5 17 testgrid.pbm > ${test_out} || \ - printf "Expected failure 4 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pbmtopgm 5 0 testgrid.pbm" +invCmd "pbmtopgm 0 9 testgrid.pbm" +invCmd "pbmtopgm 15 5 testgrid.pbm" +invCmd "pbmtopgm 5 17 testgrid.pbm" diff --git a/test/pgmhist.test b/test/pgmhist.test index a47ab71e..5c458a57 100755 --- a/test/pgmhist.test +++ b/test/pgmhist.test @@ -26,30 +26,9 @@ pgmramp -lr 256 1 | pgmhist -machine -decile | \ 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 - -pgmhist -median -quartile testgrid.pbm > ${test_out} || \ - printf "Expected failure 1 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pgmhist -median -decile testgrid.pbm > ${test_out} || \ - printf "Expected failure 2 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pgmhist -quartile -decile testgrid.pbm > ${test_out} || \ - printf "Expected failure 3 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pgmhist testimg.ppm > ${test_out} || \ - printf "Expected failure 4 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +. ${srcdir}/test-invalid.inc + +invCmd "pgmhist -median -quartile testgrid.pbm" +invCmd "pgmhist -median -decile testgrid.pbm" +invCmd "pgmhist -quartile -decile testgrid.pbm" +invCmd "pgmhist testimg.ppm" diff --git a/test/pgmmake.ok b/test/pgmmake.ok index ac9b968c..9460162d 100644 --- a/test/pgmmake.ok +++ b/test/pgmmake.ok @@ -1,4 +1,16 @@ Test 1 +P2 +1 1 +255 +0 +P2 +1 1 +255 +255 +P2 +1 1 +2 +1 3662611538 2513 3109612402 5012 Test Invalid @@ -10,3 +22,4 @@ 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) diff --git a/test/pgmmake.test b/test/pgmmake.test index 80997d07..d8e248d4 100755 --- a/test/pgmmake.test +++ b/test/pgmmake.test @@ -4,56 +4,22 @@ echo "Test 1" +pgmmake -plain 0 1 1 +pgmmake -plain 1 1 1 +pgmmake -plain -maxval=2 0.5 1 1 pgmmake 1 50 50 | cksum pgmmake .2 50 100 -maxval=5 | cksum - 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 - -tmpdir=${tmpdir:-/tmp} -test_out=${tmpdir}/test_out - -pgmmake 100 5 5 > ${test_out} || \ - printf "Expected failure 1 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pgmmake 1.01 5 5 > ${test_out} || \ - printf "Expected failure 2 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pgmmake .5 5 > ${test_out} || \ - printf "Expected failure 3 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pgmmake .5 > ${test_out} || \ - printf "Expected failure 4 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pgmmake -maxval=5 5 5 > ${test_out} || \ - printf "Expected failure 5 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pgmmake -maxval=0 .5 5 5 > ${test_out} || \ - printf "Expected failure 6 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pgmmake -maxval=-1 .5 5 5 > ${test_out} || \ - printf "Expected failure 7 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pgmmake -maxval=65536 .5 5 5 > ${test_out} || \ - printf "Expected failure 8 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +. ${srcdir}/test-invalid.inc + +invCmd "pgmmake" +invCmd "pgmmake 100 5 5" +invCmd "pgmmake 1.01 5 5" +invCmd "pgmmake .5 5" +invCmd "pgmmake .5" +invCmd "pgmmake -maxval=5 5 5" +invCmd "pgmmake -maxval=0 .5 5 5" +invCmd "pgmmake -maxval=-1 .5 5 5" +invCmd "pgmmake -maxval=65536 .5 5 5" diff --git a/test/pgmnoise-parameters.ok b/test/pgmnoise-parameters.ok index 10a05cfa..1e321f00 100644 --- a/test/pgmnoise-parameters.ok +++ b/test/pgmnoise-parameters.ok @@ -1,5 +1,7 @@ +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) diff --git a/test/pgmnoise-parameters.test b/test/pgmnoise-parameters.test index 79c068d8..871aacf9 100755 --- a/test/pgmnoise-parameters.test +++ b/test/pgmnoise-parameters.test @@ -2,35 +2,13 @@ # This script tests: pgmnoise # Also requires: -tmpdir=${tmpdir:-/tmp} -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 +. ${srcdir}/test-invalid.inc -pgmnoise -maxval=255 -randomseed=1 > ${test_out} || \ - printf "Expected failure 1 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pgmnoise 100 -randomseed=1 > ${test_out} || \ - printf "Expected failure 2 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pgmnoise 100 0 -randomseed=1 > ${test_out} || \ - printf "Expected failure 3 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pgmnoise 0 100 -randomseed=1 > ${test_out} || \ - printf "Expected failure 4 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pgmnoise 100 100 100 -randomseed=1 > ${test_out} || \ - printf "Expected failure 5 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pgmnoise" +invCmd "pgmnoise -maxval=255 -randomseed=1" +invCmd "pgmnoise 100 -randomseed=1" +invCmd "pgmnoise 100 0 -randomseed=1" +invCmd "pgmnoise 0 100 -randomseed=1" +invCmd "pgmnoise 100 100 100 -randomseed=1" diff --git a/test/pgmramp.ok b/test/pgmramp.ok index 69e3a6e5..71f92b13 100644 --- a/test/pgmramp.ok +++ b/test/pgmramp.ok @@ -42,8 +42,10 @@ Test 2 Test 3 886972785 131087 Test Invalid -Expected failure: -lr -tb (no output) -Expected failure: -lr -rectangle (no output) -Expected failure: -rectangle -ellipse (no output) -Expected failure: insufficient parameters (no output) -Expected failure: excessive parameters (no output) +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) diff --git a/test/pgmramp.test b/test/pgmramp.test index d2e34885..84fe02ca 100755 --- a/test/pgmramp.test +++ b/test/pgmramp.test @@ -21,27 +21,16 @@ pgmramp -diagonal -maxval=510 256 256 | cksum 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 +. ${srcdir}/test-invalid.inc -tmpdir=${tmpdir:-/tmp} -test_out=${tmpdir}/test_out for combination in "-lr -tb" "-lr -rectangle" "-rectangle -ellipse" -do pgmramp $combination 10 10 > ${test_out} || \ - printf "Expected failure: $combination " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} -done + do + invCmd "pgmramp ${combination} 10 10" + done -pgmramp -lr 1 > ${test_out} || \ - printf "Expected failure: insufficient parameters " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pgmramp -lr 10 0" +invCmd "pgmramp -lr 0 10" +invCmd "pgmramp -lr 1" +invCmd "pgmramp -tb 1 1 1" -pgmramp -tb 1 1 1 > ${test_out} || \ - printf "Expected failure: excessive parameters " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} diff --git a/test/pnmcat.test b/test/pnmcat.test index 02fefd38..8779638b 100755 --- a/test/pnmcat.test +++ b/test/pnmcat.test @@ -59,7 +59,7 @@ cat ${diag_pgm} | pnmcat -tb -plain | sed 's/ *$//' rm ${diag_pgm} -pgmramp -diag 8 8 -maxval 7 | ppmtoppm > ${diag_ppm} +pgmramp -diag 8 8 -maxval 7 | ppmtoppm > ${diag_ppm} echo "Test 7. Should print 2097565808 394 twice" pnmcat -lr -black ${diag_ppm} ${diag_ppm} | tee ${diag2lr_ppm} | cksum @@ -70,7 +70,7 @@ pnmcat -tb ${diag_ppm} ${diag_ppm} | tee ${diag2tb_ppm} | cksum echo "Test 9. Should print 4288335051 586 three times" pnmcat -lr ${diag_ppm} ${diag_ppm} ${diag_ppm} | cksum -pnmcat -lr ${diag_ppm} ${diag2lr_ppm} | cksum +pnmcat -lr ${diag_ppm} ${diag2lr_ppm} | cksum cat ${diag2lr_ppm} | pnmcat -lr - ${diag_ppm} | cksum echo "Test 10. Should print 642720605 586 three times" @@ -100,82 +100,30 @@ rm ${diag_ppm} echo "Test Invalid" -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 +. ${srcdir}/test-invalid.inc # direction not specified -pnmcat testgrid.pbm testimg.ppm > ${test_out} || \ - printf "Expected failure 1 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pnmcat testgrid.pbm testimg.ppm" # both directions specified -pnmcat -topbottom -leftright testgrid.pbm testimg.ppm > ${test_out} || \ - printf "Expected failure 2 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pnmcat -topbottom -leftright testgrid.pbm testimg.ppm" # both pad colors specified -pnmcat -topbottom -white -black testgrid.pbm testimg.ppm > ${test_out} || \ - printf "Expected failure 3 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pnmcat -topbottom -white -black testgrid.pbm testimg.ppm" # justification parameters overspecified -pnmcat -lr -jtop -jbottom testgrid.pbm testimg.ppm > ${test_out} || \ - printf "Expected failure 4 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pnmcat -lr -jtop -jcenter testgrid.pbm testimg.ppm > ${test_out} || \ - printf "Expected failure 5 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pnmcat -lr -jcenter -jbottom testgrid.pbm testimg.ppm > ${test_out} || \ - printf "Expected failure 6 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pnmcat -tb -jleft -jright testgrid.pbm testimg.ppm > ${test_out} || \ - printf "Expected failure 7 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pnmcat -tb -jleft -jcenter testgrid.pbm testimg.ppm > ${test_out} || \ - printf "Expected failure 8 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pnmcat -tb -jcenter -jright testgrid.pbm testimg.ppm > ${test_out} || \ - printf "Expected failure 9 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pnmcat -lr -jtop -jbottom testgrid.pbm testimg.ppm" +invCmd "pnmcat -lr -jtop -jcenter testgrid.pbm testimg.ppm" +invCmd "pnmcat -lr -jcenter -jbottom testgrid.pbm testimg.ppm" +invCmd "pnmcat -tb -jleft -jright testgrid.pbm testimg.ppm" +invCmd "pnmcat -tb -jleft -jcenter testgrid.pbm testimg.ppm" +invCmd "pnmcat -tb -jcenter -jright testgrid.pbm testimg.ppm" # justification parameter in the wrong direction -pnmcat -lr -jleft testgrid.pbm testimg.ppm > ${test_out} || \ - printf "Expected failure 10 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pnmcat -lr -jright testgrid.pbm testimg.ppm > ${test_out} || \ - printf "Expected failure 11 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pnmcat -tb -jtop testgrid.pbm testimg.ppm > ${test_out} || \ - printf "Expected failure 12 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pnmcat -tb -jbottom testgrid.pbm testimg.ppm > ${test_out} || \ - printf "Expected failure 13 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pnmcat -lr -jleft testgrid.pbm testimg.ppm" +invCmd "pnmcat -lr -jright testgrid.pbm testimg.ppm" +invCmd "pnmcat -tb -jtop testgrid.pbm testimg.ppm" +invCmd "pnmcat -tb -jbottom testgrid.pbm testimg.ppm" # more than one input image from standard input cat testgrid.pbm | pnmcat -lr - - testimg.ppm > ${test_out} || \ diff --git a/test/pnmcolormap.test b/test/pnmcolormap.test index b34a0360..953dece3 100755 --- a/test/pnmcolormap.test +++ b/test/pnmcolormap.test @@ -32,49 +32,16 @@ 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 -echo "Error messages should appear below the line." 1>&2 -echo "-----------------------------------------------------------" 1>&2 - -tmpdir=${tmpdir:-/tmp} -test_out=${tmpdir}/test_out - -pnmcolormap 0 testimg.ppm > ${test_out} || \ - printf "Expected failure 1 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pnmcolormap -1 testimg.ppm > ${test_out} || \ - printf "Expected failure 2 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pnmcolormap 0.1 testimg.ppm > ${test_out} || \ - printf "Expected failure 3 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pnmcolormap -center -meancolor 16 testimg.ppm > ${test_out} || \ - printf "Expected failure 4 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pnmcolormap -center -meanpixel 16 testimg.ppm > ${test_out} || \ - printf "Expected failure 5 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pnmcolormap -meancolor -meanpixel 16 testimg.ppm > ${test_out} || \ - printf "Expected failure 6 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +. ${srcdir}/test-invalid.inc -pnmcolormap -spreadbrightness -spreadluminosity 16 \ - testimg.ppm > ${test_out} || \ - printf "Expected failure 7 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "pnmcolormap 0 testimg.ppm " +invCmd "pnmcolormap -1 testimg.ppm " +invCmd "pnmcolormap 0.1 testimg.ppm" +invCmd "pnmcolormap -center -meancolor 16 testimg.ppm " +invCmd "pnmcolormap -center -meanpixel 16 testimg.ppm " +invCmd "pnmcolormap -meancolor -meanpixel 16 testimg.ppm" +invCmd "pnmcolormap -spreadbrightness -spreadluminosity 16 testimg.ppm" diff --git a/test/pnmindex.test b/test/pnmindex.test index 51e61532..5b427da2 100755 --- a/test/pnmindex.test +++ b/test/pnmindex.test @@ -1,7 +1,7 @@ #! /bin/sh # This script tests: pnmindex # Also requires: pamcat pamscale pbmtext pnmcolormap pnmindex -# Also requires: pnminvert pnmquant pnmremap +# Also requires: pnminvert pnmquant pnmremap echo "Test 1. Should print 3391481002 889" pnmindex maze.pbm | cksum @@ -31,30 +31,17 @@ pnmindex -size 50 -across=2 -noquant testimg.ppm testimg.ppm testimg.ppm \ echo "Test Invalid" -test_out=${tmpdir}/test_out -n=1 - -# define function -invalidCmd () { $1 > ${test_out} && printf "Unexpected success $n " || \ - printf "Expected failure $n " - test -s ${test_out} && echo "(unexpected output)" || echo "(no output)" - rm -f ${test_out} - 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 - -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" +. ${srcdir}/test-invalid.inc + +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 -colors -1 testgrid.pbm" +invCmd "pnmindex -colors 0 testgrid.pbm" +invCmd "pnmindex -colors testgrid.pbm" +invCmd "pnmindex -quant -noquant testgrid.pbm" +invCmd "pnmindex -colors 100 -noquant testgrid.pbm" +invCmd "pnmindex" diff --git a/test/pnmpsnr.test b/test/pnmpsnr.test index efabe9aa..6ea05aed 100755 --- a/test/pnmpsnr.test +++ b/test/pnmpsnr.test @@ -27,32 +27,11 @@ pnmpsnr testimg.ppm testimg.ppm -target1=1000 -target2=1000 -target3=1000 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 - -pnmpsnr ${b_pbm} ${w_pbm} ${b_pbm} > ${test_out} || \ - printf "Expected failure 1 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pnmpsnr ${b_pbm} > ${test_out} || \ - printf "Expected failure 2 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pnmpsnr ${b_pbm} ${w_pbm} -target1=100 > ${test_out} || \ - printf "Expected failure 3 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pnmpsnr -machine > ${test_out} || \ - printf "Expected failure 4 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +. ${srcdir}/test-invalid.inc + +invCmd "pnmpsnr ${b_pbm} ${w_pbm} ${b_pbm} " +invCmd "pnmpsnr ${b_pbm} " +invCmd "pnmpsnr ${b_pbm} ${w_pbm} -target1=100" +invCmd "pnmpsnr -machine " rm ${b_pbm} ${w_pbm} diff --git a/test/pnmtile.test b/test/pnmtile.test index 74bae013..35addbec 100755 --- a/test/pnmtile.test +++ b/test/pnmtile.test @@ -21,29 +21,9 @@ echo ${PIPESTATUS[@]} ":" $? rm ${testimg2_ppm} ${testimg4_ppm} -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 - -pnmtile 100 testgrid.pbm > ${test_out} || \ - printf "Expected failure 1 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pnmtile 100 0 testgrid.pbm > ${test_out} || \ - printf "Expected failure 2 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pnmtile 0 100 testgrid.pbm > ${test_out} || \ - printf "Expected failure 3 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -pnmtile 100 100 100 testgrid.pbm > ${test_out} || \ - printf "Expected failure 4 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +. ${srcdir}/test-invalid.inc + +invCmd "pnmtile 100 testgrid.pbm" +invCmd "pnmtile 100 0 testgrid.pbm" +invCmd "pnmtile 0 100 testgrid.pbm" +invCmd "pnmtile 100 100 100 testgrid.pbm" diff --git a/test/ppmbrighten.ok b/test/ppmbrighten.ok index 3895dbd0..95c90d24 100644 --- a/test/ppmbrighten.ok +++ b/test/ppmbrighten.ok @@ -4,8 +4,6 @@ Test 2: Should print 295150171 101484 295150171 101484 Test 3: Should print 1 1 -Test Error: Should print 1 four times -1 -1 -1 -1 +Test Invalid +Expected failure 1 (no output) +Expected failure 2 (no output) diff --git a/test/ppmbrighten.test b/test/ppmbrighten.test index e346d1d0..8ae1d744 100755 --- a/test/ppmbrighten.test +++ b/test/ppmbrighten.test @@ -1,6 +1,6 @@ #! /bin/sh # This script tests: ppmbrighten -# Also requires: pnmnorm pambrighten pamsumm +# Also requires: pnmnorm pambrighten pamsumm # Failure message ## Ppmbrighten is sensitive to subtle differences in floating point math. @@ -20,22 +20,11 @@ echo "Test 3: Should print 1" ppmbrighten -v 100 -normalize testimg.ppm | pamsumm --mean | \ awk '{print ($NF > 132.0) && ($NF < 132.2)}' -echo "Invalid command-line argument combinations." 1>&2 -echo "Error messages should appear below the line." 1>&2 -echo "-----------------------------------------------------------" 1>&2 -echo "Test Error: Should print 1 four times" +echo "Test Invalid" -tmpdir=${tmpdir:-/tmp} -output_ppm=${tmpdir}/output.ppm +. ${srcdir}/test-invalid.inc -pambrighten -v -120 testimg.ppm > ${output_ppm} -echo $? -test -s ${output_ppm} -echo $? -pambrighten -s -120 testimg.ppm > ${output_ppm} -echo $? -test -s ${output_ppm} -echo $? +invCmd "pambrighten -v -120 testimg.ppm" +invCmd "pambrighten -s -120 testimg.ppm" -rm ${output_ppm} diff --git a/test/ppmforge-parameters.test b/test/ppmforge-parameters.test index ba436bf0..0525e7af 100755 --- a/test/ppmforge-parameters.test +++ b/test/ppmforge-parameters.test @@ -5,61 +5,31 @@ echo "Test 1: Should print 256 256" # Default size is 256 256 -ppmforge -night | pamfile -size +ppmforge -night -seed=1 | pamfile -size echo "Test 2: Should print 40 30" # Width is adjusted if not even # becomes 40 in this case -ppmforge -night -width=39 -height=30 | pamfile -size +ppmforge -night -seed=1 -width=39 -height=30 | pamfile -size echo "Test 3: Should print 90 90" # Width is adjusted if smaller than height # brought up to 90 in this case -ppmforge -night -width=80 -height=90 | pamfile -size +ppmforge -night -seed=1 -width=80 -height=90 | pamfile -size echo "Test Invalid" tmpdir=${tmpdir:-/tmp} test_out=${tmpdir}/test_out -echo 1>&2 -echo "Invalid command-line arguments." 1>&2 -echo "Error messages should appear below the line." 1>&2 -echo "-----------------------------------------------------------" 1>&2 +. ${srcdir}/test-invalid.inc -ppmforge -night -dimension=0 > ${test_out} || \ - printf "Expected failure 1 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -ppmforge -dimension=10 > ${test_out} || \ - printf "Expected failure 2 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -ppmforge -dimension=-1 > ${test_out} || \ - printf "Expected failure 3 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -ppmforge -clouds -mesh=1.99 > ${test_out} || \ - printf "Expected failure 4 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -ppmforge -clouds -power=0 > ${test_out} || \ - printf "Expected failure 5 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -ppmforge -ice=-1 > ${test_out} || \ - printf "Expected failure 6 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -ppmforge -glaciers=-1 > ${test_out} || \ - printf "Expected failure 7 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "ppmforge -seed=0 -night -dimension=0" +invCmd "ppmforge -seed=0 -dimension=10" +invCmd "ppmforge -seed=0 -dimension=-1" +invCmd "ppmforge -seed=0 -clouds -mesh=1.99" +invCmd "ppmforge -seed=0 -clouds -power=0" +invCmd "ppmforge -seed=0 -ice=-1" +invCmd "ppmforge -seed=0 -glaciers=-1" diff --git a/test/ppmhist.test b/test/ppmhist.test index 27ae9cea..1e814eb7 100755 --- a/test/ppmhist.test +++ b/test/ppmhist.test @@ -27,25 +27,8 @@ ppmpat -madras --color=rgb:00/00/00,rgb:31/58/a3,rgb:ff/ff/ff 25 25 | \ 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 - -ppmhist -hexcolor -float testimg.ppm > ${test_out} || \ - printf "Expected failure 1 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -ppmhist -hexcolor -map testimg.ppm > ${test_out} || \ - printf "Expected failure 2 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -ppmhist -float -map testimg.ppm > ${test_out} || \ - printf "Expected failure 3 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +. ${srcdir}/test-invalid.inc + +invCmd "ppmhist -hexcolor -float testimg.ppm" +invCmd "ppmhist -hexcolor -map testimg.ppm" +invCmd "ppmhist -float -map testimg.ppm" diff --git a/test/ppmmake.ok b/test/ppmmake.ok index 0231874f..e365bd9e 100644 --- a/test/ppmmake.ok +++ b/test/ppmmake.ok @@ -1,6 +1,14 @@ Test 1 +P3 +1 1 +5 +0 0 0 +P3 +1 1 +65535 +65535 65535 65535 2477651508 15012 -4294967295 0 +135932096 23 2378991101 7513 Test Invalid Expected failure 1 (no output) diff --git a/test/ppmmake.test b/test/ppmmake.test index fb7bf74a..295e0bf4 100755 --- a/test/ppmmake.test +++ b/test/ppmmake.test @@ -4,66 +4,24 @@ echo "Test 1" -ppmmake rgb:ff/80/80 50 100 -maxval=5 | cksum -ppmmake rgbi:0.5/1.0/0 2 | cksum +ppmmake -maxval=5 -plain rgb:00/00/00 1 1 +ppmmake -maxval=65535 -plain rgb:ff/ff/ff 1 1 +ppmmake -maxval=5 rgb:ff/80/80 50 100 | cksum +ppmmake rgbi:0.5/1.0/0 2 2 | cksum ppmmake red 50 50 | cksum 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 - -ppmmake rgb:gg/00/00 2 2 > ${test_out} || \ - printf "Expected failure 1 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -ppmmake rgb:ff/ff/00 2 > ${test_out} || \ - printf "Expected failure 2 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -ppmmake rgbi:1.1/0/0 2 2 > ${test_out} || \ - printf "Expected failure 3 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -ppmmake rgbi:1.0/.5 2 2 > ${test_out} || \ - printf "Expected failure 4 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -ppmmake rainbow 2 2 > ${test_out} || \ - printf "Expected failure 5 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -ppmmake 2 2 > ${test_out} || \ - printf "Expected failure 6 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -ppmmake blue -maxval=0 2 2 > ${test_out} || \ - printf "Expected failure 7 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -ppmmake blue -maxval=-1 2 2 > ${test_out} || \ - printf "Expected failure 8 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -ppmmake blue -maxval=65536 2 2 > ${test_out} || \ - printf "Expected failure 9 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -RGBDEF=/dev/null ppmmake red 2 2 > ${test_out} || \ - printf "Expected failure 10 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +. ${srcdir}/test-invalid.inc + +invCmd "ppmmake rgb:gg/00/00 2 2" +invCmd "ppmmake rgb:ff/ff/00 2" +invCmd "ppmmake rgbi:1.1/0/0 2 2" +invCmd "ppmmake rgbi:1.0/.5 2 2" +invCmd "ppmmake rainbow 2 2" +invCmd "ppmmake 2 2" +invCmd "ppmmake blue -maxval=0 2 2" +invCmd "ppmmake blue -maxval=-1 2 2" +invCmd "ppmmake blue -maxval=65536 2 2" +export RGBDEF=/dev/null +invCmd "ppmmake red 2 2" diff --git a/test/ppmpat.test b/test/ppmpat.test index 48c2460f..00f8421e 100755 --- a/test/ppmpat.test +++ b/test/ppmpat.test @@ -41,58 +41,17 @@ ppmpat -argyle2 --color=rgb:00/00/00,rgb:ff/80/80,rgb:e0/e0/e0 12 18 | cksum 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} || \ - printf "Expected failure 1 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -ppmpat -madras -tartan 10 10 > ${test_out} || \ - printf "Expected failure 2 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -ppmpat -poles -squig 10 10 > ${test_out} || \ - printf "Expected failure 3 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -ppmpat -camo -anticamo 10 10 > ${test_out} || \ - printf "Expected failure 4 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -ppmpat -argyle1 -argyle2 10 10 > ${test_out} || \ - printf "Expected failure 5 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -ppmpat 10 10 > ${test_out} || \ - printf "Expected failure 6 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -ppmpat -g2 10 > ${test_out} || \ - printf "Expected failure 7 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -ppmpat -g2 10 10 10 > ${test_out} || \ - printf "Expected failure 8 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -ppmpat -g2 10 > ${test_out} || \ - printf "Expected failure 9 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +. ${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" @@ -100,90 +59,24 @@ 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} || \ - printf "Expected failure 10 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -ppmpat -argyle1 ${clist1} 10 10 > ${test_out} || \ - printf "Expected failure 11 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -ppmpat -gingham2 ${clist3} 10 10 > ${test_out} || \ - printf "Expected failure 12 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -ppmpat -argyle1 ${clist3} 10 10 > ${test_out} || \ - printf "Expected failure 13 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +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 -ppmpat -gingham3 ${clist2} 10 10 > ${test_out} || \ - printf "Expected failure 14 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -ppmpat -argyle2 ${clist2} 10 10 > ${test_out} || \ - printf "Expected failure 15 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -ppmpat -madras ${clist2} 10 10 > ${test_out} || \ - printf "Expected failure 16 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -ppmpat -tartan ${clist2} 10 10 > ${test_out} || \ - printf "Expected failure 17 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -ppmpat -gingham3 ${clist4} 10 10 > ${test_out} || \ - printf "Expected failure 18 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -ppmpat -argyle2 ${clist4} 10 10 > ${test_out} || \ - printf "Expected failure 19 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -ppmpat -madras ${clist4} 10 10 > ${test_out} || \ - printf "Expected failure 20 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -ppmpat -tartan ${clist4} 10 10 > ${test_out} || \ - printf "Expected failure 21 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -# These require at least 3 colors -ppmpat -squig ${clist2} 10 10 > ${test_out} || \ - printf "Expected failure 22 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -ppmpat -camo ${clist2} 10 10 > ${test_out} || \ - printf "Expected failure 23 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -ppmpat -anticamo ${clist2} 10 10 > ${test_out} || \ - printf "Expected failure 24 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +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 -ppmpat -squig ${clist3} 10 250 > ${test_out} || \ - printf "Expected failure 25 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} - -ppmpat -squig ${clist3} 500 20 > ${test_out} || \ - printf "Expected failure 26 " - test -s ${test_out} && echo "unexpected output" || echo "(no output)" - rm -f ${test_out} +invCmd "ppmpat -squig ${clist3} 10 250" +invCmd "ppmpat -squig ${clist3} 500 20" diff --git a/test/test-invalid.inc b/test/test-invalid.inc new file mode 100644 index 00000000..e24cfd3f --- /dev/null +++ b/test/test-invalid.inc @@ -0,0 +1,16 @@ +echo 1>&2 +echo "Invalid command-line argument combination(s)." 1>&2 +echo "Error message(s) should appear below the line." 1>&2 +echo "-----------------------------------------------------------" 1>&2 + +tmpdir=${tmpdir:-/tmp} +test_out=${tmpdir}/test_out + +# define function +invCmd () { $1 > ${test_out} && \ + printf "Unexpected success ${testcnt} " || printf "Expected failure ${testcnt} " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + testcnt=$(($testcnt +1)); } + +testcnt=1 |