blob: 51e6153255e2d0f31c63aec78aa8654f0c1a5aab (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#! /bin/sh
# This script tests: pnmindex
# Also requires: pamcat pamscale pbmtext pnmcolormap pnmindex
# Also requires: pnminvert pnmquant pnmremap
echo "Test 1. Should print 3391481002 889"
pnmindex maze.pbm | cksum
echo "Test 2. Should print 1998876959 5290 twice"
pnmindex maze.pbm maze.pbm maze.pbm maze.pbm maze.pbm maze.pbm | cksum
pnmindex -noquant maze.pbm maze.pbm maze.pbm maze.pbm maze.pbm maze.pbm | cksum
echo "Test 3. Should print 3099638253 5290"
pnmindex -black maze.pbm maze.pbm maze.pbm maze.pbm maze.pbm maze.pbm | cksum
echo "Test 4. Should print 1397700642 3160"
pnmindex -size 20 -across=3 testgrid.pbm testgrid.pbm testgrid.pbm \
testgrid.pbm testgrid.pbm testgrid.pbm | cksum
echo "Test 5. Should print 2303488589 28514"
pnmindex testimg.ppm | cksum
echo "Test 6. Should print 1706277976 100455"
pnmindex -size 50 -across=2 testimg.ppm testimg.ppm testimg.ppm \
testimg.ppm testimg.ppm testimg.ppm | cksum
echo "Test 7. Should print 801388440 100455"
pnmindex -size 50 -across=2 -noquant testimg.ppm testimg.ppm testimg.ppm \
testimg.ppm testimg.ppm testimg.ppm | cksum
echo "Test Invalid"
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"
|