blob: 274cb8656aa336e8b30f609b4228732d461862ca (
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
#! /bin/sh
# This script tests: pamcut
# Also requires: pamfile pamcat pnmpad pnmcrop
tmpdir=${tmpdir:-/tmp}
left_ppm=${tmpdir}/left.ppm
right_ppm=${tmpdir}/right.ppm
top_ppm=${tmpdir}/top.ppm
bottom_ppm=${tmpdir}/bottom.ppm
padded_ppm=${tmpdir}/padded.ppm
echo "Test 1. Should print 1926073387 101484 six times"
testimg_ppm_sum=`cksum < testimg.ppm`
echo ${testimg_ppm_sum}
imgsize=$(pamfile -size testimg.ppm)
width=$(echo ${imgsize} | cut -d " " -f 1)
height=$(echo ${imgsize} | cut -d " " -f 2)
for i in 0 1 128 224 225
do
pamcut -left=$((i+1)) testimg.ppm > ${right_ppm}
pamcut -right=$i testimg.ppm > ${left_ppm}
pamcat -lr ${left_ppm} ${right_ppm} | \
pamcut -left=0 -width=${width} | cksum
rm ${left_ppm} ${right_ppm}
done
echo "Test 2. Should print 3891261972 202953 1926073387 101484 six times"
# Padding added to right.
pnmpad -right=${width} -black testimg.ppm | cksum | tr '\n' ' '
echo ${testimg_ppm_sum}
for border in 0 1 128 224 225
do
pamcut -left=$((${border}+1)) -width=${width} -pad testimg.ppm > ${right_ppm}
pamcut -right=${border} -width=${width} -pad testimg.ppm > ${left_ppm}
pamcat -lr ${left_ppm} ${right_ppm} ${left_ppm} | \
pamcut -left=$((${width}-${border}-1)) -width=$((${width}*2)) | \
tee ${padded_ppm} | cksum | tr '\n' ' '
pnmcrop -black -right ${padded_ppm} | cksum
rm ${left_ppm} ${right_ppm} ${padded_ppm}
done
echo "Test 3. Should print 1926073387 101484 five times"
echo ${testimg_ppm_sum}
for border in 0 1 70 147
do
pamcut -top=$((${border}+1)) testimg.ppm > ${bottom_ppm}
pamcut -bottom=${border} testimg.ppm > ${top_ppm}
pamcat -tb ${top_ppm} ${bottom_ppm} | \
pamcut -top=0 -height=${height} | cksum
rm ${top_ppm} ${bottom_ppm}
done
echo "Test 4. Should print 26789469 202953 1926073387 101484 five times"
# Padding added to bottom.
pnmpad -bottom=${height} -black testimg.ppm | cksum | tr '\n' ' '
echo ${testimg_ppm_sum}
for border in 0 1 70 147
do
pamcut -top=$((${border}+1)) -height=${height} -pad testimg.ppm \
> ${bottom_ppm}
pamcut -bottom=${border} -height=${height} -pad testimg.ppm > ${top_ppm}
pamcat -tb ${top_ppm} ${bottom_ppm} ${top_ppm} | \
pamcut -top=$((${height}-${border}-1)) -height=$((${height}*2)) | \
tee ${padded_ppm} | cksum | tr '\n' ' 'cksum
pnmcrop -black -bottom ${padded_ppm} | cksum
rm ${top_ppm} ${bottom_ppm} ${padded_ppm}
done
left_pbm=${tmpdir}/left.pbm
right_pbm=${tmpdir}/right.pbm
top_pbm=${tmpdir}/top.pbm
bottom_pbm=${tmpdir}/bottom.pbm
padded_pbm=${tmpdir}/padded.pbm
echo "Test 5. Should print 281226646 481 six times"
maze_pbm_sum=`cksum < maze.pbm`
echo ${maze_pbm_sum}
imgsize=$(pamfile -size maze.pbm)
width=$(echo ${imgsize} | cut -d " " -f 1)
height=$(echo ${imgsize} | cut -d " " -f 2)
for i in 0 1 10 30 50
do
pamcut -left=$((i+1)) maze.pbm > ${right_ppm}
pamcut -right=$i maze.pbm > ${left_ppm}
pamcat -lr ${left_ppm} ${right_ppm} | \
pamcut -left=0 -width=${width} | cksum
rm ${left_ppm} ${right_ppm}
done
echo "Test 6. Should print 1748767123 895 281226646 481 six times"
# Padding added to right.
pnmpad -right=${width} -black maze.pbm | cksum | tr '\n' ' '
echo ${maze_pbm_sum}
for border in 0 1 10 30 50
do
pamcut -left=$((${border}+1)) -width=${width} -pad maze.pbm > ${right_ppm}
pamcut -right=${border} -width=${width} -pad maze.pbm > ${left_ppm}
pamcat -lr ${left_ppm} ${right_ppm} ${left_ppm} | \
pamcut -left=$((${width}-${border}-1)) -width=$((${width}*2)) | \
tee ${padded_ppm} | cksum | tr '\n' ' '
pnmcrop -black -right ${padded_ppm} | cksum
rm ${left_ppm} ${right_ppm} ${padded_ppm}
done
echo "Test 7. Should print 281226646 481 seven times"
echo ${maze_pbm_sum}
for border in 0 1 12 21 31 44
do
pamcut -top=$((${border}+1)) maze.pbm > ${bottom_ppm}
pamcut -bottom=${border} maze.pbm > ${top_ppm}
pamcat -tb ${top_ppm} ${bottom_ppm} | \
pamcut -top=0 -height=${height} | cksum
rm ${top_ppm} ${bottom_ppm}
done
echo "Test 8. Should print 1346655680 954 281226646 481 five times"
# Padding added to bottom.
pnmpad -bottom=${height} -black maze.pbm | cksum | tr '\n' ' '
echo ${maze_pbm_sum}
for border in 0 1 10 50
do
pamcut -top=$((${border}+1)) -height=${height} -pad maze.pbm > ${bottom_ppm}
pamcut -bottom=${border} -height=${height} -pad maze.pbm > ${top_ppm}
pamcat -tb ${top_ppm} ${bottom_ppm} ${top_ppm} | \
pamcut -top=$((${height}-${border}-1)) -height=$((${height}*2)) | \
tee ${padded_ppm} | cksum | tr '\n' ' 'cksum
pnmcrop -black -bottom ${padded_ppm} | cksum
rm ${top_ppm} ${bottom_ppm} ${padded_ppm}
done
|