blob: 2ebee49fa31983d625eab36121b2aefdf98c96b7 (
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
|
#! /bin/sh
# This script tests: pamrestack
# Also requires: pamfile pamflip pgmramp pnmcrop pnminvert
tmpdir=${tmpdir:-/tmp}
ramp_pgm=${tmpdir}/ramp.pgm
ramp2_pgm=${tmpdir}/ramp2.pgm
maze_singlerow_pbm=${tmpdir}/maze_singlerow.pbm
maze_inverted_pbm=${tmpdir}/maze_inverted.pbm
echo "Test 1."
pgmramp -lr -maxval=7 8 3 | tee ${ramp_pgm} | pamrestack -plain
pamrestack -width=10 -trim=fill -plain ${ramp_pgm}
pamrestack -width=10 -trim=crop -plain ${ramp_pgm}
pamrestack -width=4 -trim=fill -plain ${ramp_pgm}
pamrestack -width=12 -trim=fill -plain ${ramp_pgm}
echo "Test 2. Should print 0 twelve times"
for width in 2 4 5 8 12 24
do
pamrestack -width=${width} -trim=crop ${ramp_pgm} > ${ramp2_pgm}
for flag in "-trim=crop" "-trim=fill"
do
pamrestack -width=${width} ${flag} ${ramp2_pgm} | cmp -s - ${ramp2_pgm}
echo $?
done
done
rm ${ramp_pgm} ${ramp2_pgm}
echo "Test 3. Should produce 3141273448 431 fifteen times"
# Invert maze.pbm because the lower right corner is black
pixels=`pamfile -size maze.pbm | awk '{print $1 * $2}'`
pnminvert maze.pbm | tee ${maze_inverted_pbm} | \
pamrestack | tee ${maze_singlerow_pbm} | pnmcrop -right -black | cksum
for width in 1 2 3 100 1000 ${pixels} $((pixels -1))
do
pamrestack -width=${width} ${maze_inverted_pbm} | pamrestack | \
pnmcrop -right -black | cksum
pamrestack -width=${width} ${maze_singlerow_pbm} | \
pamrestack | pnmcrop -right -black | cksum
done
rm ${maze_inverted_pbm} ${maze_singlerow_pbm}
echo "Test 4. Should produce 1768948962 101484 twice"
pamrestack -width=1 testimg.ppm | pamflip -ccw | cksum
pamrestack \
-width=`pamfile -size testimg.ppm | cut -d " " -f2` testimg.ppm | \
pamrestack | cksum
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 " "$?
rm -f ${test_out}
pamrestack -abort \
-width=$((pixels * 2 + 1 )) maze.pbm > ${test_out} || \
printf "Expected failure 2"
test -s ${test_out}; echo " "$?
rm -f ${test_out}
pamrestack -crop \
-width=$((pixels * 2 + 1)) maze.pbm > ${test_out} || \
printf "Expected failure 3"
test -s ${test_out}; echo " "$?
rm -f ${test_out}
pamrestack -width=0 maze.pbm > ${test_out} || \
printf "Expected failure 4"
test -s ${test_out}; echo " "$?
rm -f ${test_out}
pamrestack -width maze.pbm > ${test_out} || \
printf "Expected failure 5"
test -s ${test_out}; echo " "$?
rm -f ${test_out}
|