blob: 2271974e24105ddce719ce2f4c7aa76007c1482f (
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
#! /bin/bash
# This script tests: pamfunc
# Also requires: pamseq pamtopnm
tmpdir=${tmpdir:-/tmp}
input_pgm=${tmpdir}/input.pgm
echo "Test 1"
pamseq 1 15 | pamtopnm -assume > ${input_pgm}
pamtopnm -plain ${input_pgm} | tr '\n' ' '; echo
pamfunc -adder=3 -plain ${input_pgm} | tr '\n' ' '; echo
pamfunc -subtractor=3 -plain ${input_pgm} | tr '\n' ' '; echo
pamfunc -multiplier=3 -plain ${input_pgm} | tr '\n' ' '; echo
pamfunc -divisor=2 -plain ${input_pgm} | tr '\n' ' '; echo
pamfunc -max=6 -plain ${input_pgm} | tr '\n' ' '; echo
pamfunc -min=5 -plain ${input_pgm} | tr '\n' ' '; echo
pamfunc -shiftleft 1 -plain ${input_pgm} | tr '\n' ' '; echo
pamfunc -shiftright 1 -plain ${input_pgm} | tr '\n' ' '; echo
pamfunc -shiftleft 1 ${input_pgm} | pamfunc -shiftright 1 -plain | \
tr '\n' ' '; echo
pamfunc -shiftright 1 ${input_pgm} | pamfunc -shiftleft 1 -plain | \
tr '\n' ' '; echo
echo "Test 2 (-changemaxval)"
pamfunc -divisor 2 -changemaxval ${input_pgm} -plain | \
tr '\n' ' '; echo
pamfunc -multiplier 0.25 -changemaxval ${input_pgm} -plain | \
tr '\n' ' '; echo
rm ${input_pgm}
echo "Test 3: Should print 1926073387 101484 eight times"
cat testimg.ppm | cksum
pamfunc -not testimg.ppm | pamfunc -not | cksum
pamfunc -andmask 0xff testimg.ppm | cksum
pamfunc -ormask 0x00 testimg.ppm | cksum
pamfunc -xormask 0x00 testimg.ppm | cksum
pamfunc -xormask 0xff testimg.ppm | pamfunc -xormask 0xff | cksum
pamfunc -shiftleft 0 testimg.ppm | cksum
pamfunc -shiftright 0 testimg.ppm | cksum
echo "Test 4: Should print 2425386270 41 six times"
cat testgrid.pbm | cksum
pamfunc -andmask 0x1 testgrid.pbm | cksum
pamfunc -ormask 0x0 testgrid.pbm | cksum
pamfunc -xormask 0x1 testgrid.pbm | pamfunc -xormask 0x1 | cksum
pamfunc -shiftleft 0 testgrid.pbm | cksum
pamfunc -shiftright 0 testgrid.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 Error: Should print 0 then 1 twenty-four times"
output_ppm=${tmpdir}/output.ppm
for fn in "-multiplier" "-multiplier=-1" \
"-divisor" "-divisor=-20" \
"-adder" "-adder 0.5" "-subtractor" "-subtractor 0.1" \
"-multiplier=1 -divisor=2" "-adder=2 -subtractor=3" \
"-min" "-max" "-andmask" "-ormask" "-xormask" "-not 1" \
"-min=1 -max=2" "-andmask=1 -ormask=0" "-andmask=0xffff" \
"-shiftleft" "-shiftright" "-changemaxval" \
"-shiftleft=1 -shiftright=1" \
"-multiplier=0.5 -changemaxval=65535"
do
# uncomment to debug
# echo ${fn}
pamfunc ${fn} testimg.ppm > ${output_ppm}
test $? -eq 1 -o $? -eq 99
echo $?
test -s ${output_ppm}
echo $?
done
|