about summary refs log tree commit diff
path: root/test/pambrighten.test
blob: 3e1a3eb1682a74f21185b8a7d99c0f0198515dfe (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
89
90
91
92
93
94
95
96
97
98
99
#! /bin/bash
# This script tests: pambrighten
# Also requires: pgmramp

tmpdir=${tmpdir:-/tmp}

input_ppm=${tmpdir}/input.ppm

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 
EOF

# Test 1

echo "Test 1"
pambrighten -v   0 -plain ${input_ppm}
pambrighten -v +10 -plain ${input_ppm}
pambrighten -v -10 -plain ${input_ppm}
pambrighten -v +100 -plain ${input_ppm}
pambrighten -v +200 -plain ${input_ppm}
pambrighten -v -100 -plain ${input_ppm}

echo "Test 2"
pambrighten -s -10 -plain ${input_ppm}
pambrighten -s -100 -plain ${input_ppm}

echo "Test 3: Output invariant"
pambrighten         -plain ${input_ppm}
pambrighten -v   0  -plain ${input_ppm}
pambrighten -s   0  -plain ${input_ppm}
pambrighten -s +10  -plain ${input_ppm}
pambrighten -s +100 -plain ${input_ppm}
pambrighten -s +200 -plain ${input_ppm}

rm ${input_ppm}

echo "Test 4: Should print 3990234518 268 six times"

input_pgm=${tmpdir}/input.pgm

pgmramp -lr 255 1 | tee ${input_pgm} | cksum
pambrighten -s -100 ${input_pgm} | cksum
pambrighten -s -10  ${input_pgm} | cksum
pambrighten -s +10  ${input_pgm} | cksum
pambrighten -s +100 ${input_pgm} | cksum
pambrighten -s +200 ${input_pgm} | cksum

rm ${input_pgm}


# Test 2
# These should all fail.

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}