about summary refs log tree commit diff
path: root/test/pamcat1.test
blob: fb8e39cd57985e569dc7554922693aea1b21c4a3 (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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
#! /bin/sh
# This script tests: pamcat
# Also requires: pbmmake pgmmake ppmmake pamseq pamrestack

tmpdir=${tmpdir:-/tmp}
check10x10_pbm=${tmpdir}/check10x10.pbm
check40x10_pbm=${tmpdir}/check40x10.pbm
check10x30_pbm=${tmpdir}/check10x30.pbm

gray5x5_pgm=${tmpdir}/gray5x5.pgm
gray10x5_pgm=${tmpdir}/gray10x5.pgm
gray5x25_pgm=${tmpdir}/gray5x25.pgm

yellow4x5_ppm=${tmpdir}/yellow4x5.ppm
yellow16x5_ppm=${tmpdir}/yellow16x5.ppm
yellow4x15_ppm=${tmpdir}/yellow4x15.ppm

seq2_4h_pam=${tmpdir}/seq2_4h.pam
seq2_4h4_pam=${tmpdir}/seq2_4h4.pam
seq2_4v_pam=${tmpdir}/seq2_4v.pam
seq2_4v3_pam=${tmpdir}/seq2_4v3.pam


echo "Test 1.  Should print 15135078 29, then 0 fourteen times"

pbmmake -g 10 10 | tee ${check10x10_pbm} | cksum
for opt in "-leftright" "-lr" "-lr -jtop" "-lr -jcenter" "-lr -jbottom" \
    "-lr -white" "-lr -black" \
    "-topbottom" "-tb" "-tb -jleft"  "-tb -jcenter" "-tb --jright" \
    "-tb -white" "-tb -black"
  do
  pamcat ${opt} ${check10x10_pbm} | cmp -s ${check10x10_pbm} - ; echo $?
  done


echo "Test 2.  Should print 1957849403 59, 0 six times, 1 once"
pbmmake -g 40 10 | tee ${check40x10_pbm} | cksum
for opt in "-leftright" "-lr -jtop" "-lr -jcenter" "-lr -jbottom" \
    "-lr -white" "-lr -black" \
    "-tb"
  do
  pamcat ${opt} ${check10x10_pbm} ${check10x10_pbm} \
         ${check10x10_pbm} ${check10x10_pbm} | \
  cmp -s ${check40x10_pbm} - ; echo $?
  done


echo "Test 3.  Should print 2673197404 69, 0 six times, 1 once"
pbmmake -g 10 30 | tee ${check10x30_pbm} | cksum
for opt in "-topbottom" "-tb -jleft"  "-tb -jcenter" "-tb --jright" \
    "-tb -white" "-tb -black" \
    "-lr"
  do
  pamcat ${opt} ${check10x10_pbm} ${check10x10_pbm} ${check10x10_pbm} |\
  cmp -s ${check10x30_pbm} - ; echo $? 	
  done

rm ${check10x10_pbm} ${check40x10_pbm} ${check10x30_pbm}


echo "Test 4.  Should print 2285402562 36, then 0 twelve times"

pgmmake 0.125 5 5 | tee ${gray5x5_pgm} | cksum
for opt in "-leftright" "-lr -jtop" "-lr -jcenter" "-lr -jbottom" \
    "-lr -white" "-lr -black" \
    "-topbottom" "-tb -jleft"  "-tb -jcenter" "-tb --jright" \
    "-tb -white" "-tb -black"
  do
  pamcat ${opt} ${gray5x5_pgm} | cmp -s ${gray5x5_pgm} - ; echo $?
  done


echo "Test 5.  Should print 1836757613 62, 0 six times, 1 once"
pgmmake 0.125 10 5 | tee ${gray10x5_pgm} | cksum
for opt in "-leftright" "-lr -jtop" "-lr -jcenter" "-lr -jbottom" \
    "-lr -white" "-lr -black" \
    "-tb"
  do
  pamcat ${opt} ${gray5x5_pgm} ${gray5x5_pgm} |\
  cmp -s ${gray10x5_pgm} - ; echo $?
  done


echo "Test 6.  Should print 3601245348 137, 0 six times, 1 once"
pgmmake 0.125 5 25 | tee ${gray5x25_pgm} | cksum
for opt in "-topbottom" "-tb -jleft"  "-tb -jcenter" "-tb --jright" \
    "-tb -white" "-tb -black" \
    "-lr"
  do
  pamcat ${opt} ${gray5x5_pgm} ${gray5x5_pgm} ${gray5x5_pgm} \
	 ${gray5x5_pgm} ${gray5x5_pgm} |\
  cmp -s ${gray5x25_pgm} - ; echo $?
  done


rm ${gray5x5_pgm} ${gray10x5_pgm} ${gray5x25_pgm}


echo "Test 7.  Should print 1572996771 71, then 0 twelve times"
ppmmake rgb:255/255/1 4 5 | tee ${yellow4x5_ppm} | cksum
for opt in "-leftright" "-lr -jtop" "-lr -jcenter" "-lr -jbottom" \
    "-lr -white" "-lr -black" \
    "-topbottom" "-tb -jleft"  "-tb -jcenter" "-tb --jright" \
    "-tb -white" "-tb -black"
  do
  pamcat ${opt} ${yellow4x5_ppm} |\
  cmp -s ${yellow4x5_ppm} - ; echo $?
  done


echo "Test 8.  Should print 270413826 252, 0 six times, 1 once"
ppmmake rgb:255/255/1 16 5 | tee ${yellow16x5_ppm} | cksum
for opt in "-leftright" "-lr -jtop" "-lr -jcenter" "-lr -jbottom" \
    "-lr -white" "-lr -black" \
    "-tb"
  do
  pamcat ${opt} ${yellow4x5_ppm} ${yellow4x5_ppm} \
         ${yellow4x5_ppm} ${yellow4x5_ppm} |\
  cmp -s ${yellow16x5_ppm} - ; echo $?
  done


echo "Test 9.  Should print 2942772630 192, 0 six times, 1 once"
ppmmake rgb:255/255/1 4 15 | tee ${yellow4x15_ppm} | cksum
for opt in "-topbottom" "-tb -jleft"  "-tb -jcenter" "-tb --jright" \
    "-tb -white" "-tb -black" \
    "-lr"
  do
  pamcat ${opt} ${yellow4x5_ppm} ${yellow4x5_ppm} ${yellow4x5_ppm} |\
  cmp -s ${yellow4x15_ppm} - ; echo $?
  done

rm ${yellow4x5_ppm} ${yellow16x5_ppm} ${yellow4x15_ppm}


echo "Test 10.  Should print 2700536985 95, then 0 twelve times"
pamseq 2 4 | tee ${seq2_4h_pam} | cksum
for opt in "-leftright" "-lr -jtop" "-lr -jcenter" "-lr -jbottom" \
    "-lr -white" "-lr -black" \
    "-topbottom" "-tb -jleft"  "-tb -jcenter" "-tb --jright" \
    "-tb -white" "-tb -black"
  do
  pamcat ${opt} ${seq2_4h_pam}  |\
  cmp -s ${seq2_4h_pam} - ; echo $?
  done


echo "Test 11.  Should print 2193235886 195, 0 eight times, 1 once"
pamrestack -width=1 ${seq2_4h_pam} | tee ${seq2_4v_pam} |\
  pamenlarge -xscale=3 |\
  tee ${seq2_4v3_pam} | cksum
pamcat -lr ${seq2_4v_pam} ${seq2_4v_pam} | pamcat -lr - ${seq2_4v_pam} |\
  cmp -s ${seq2_4v3_pam} - ; echo $?
pamcat -lr ${seq2_4v_pam} | pamcat -lr - ${seq2_4v_pam}  ${seq2_4v_pam} |\
  cmp -s ${seq2_4v3_pam} - ; echo $?
for opt in "-leftright" "-lr -jtop" "-lr -jcenter" "-lr -jbottom" \
    "-lr -white" "-lr -black" \
    "-topbottom"
  do
  pamcat ${opt} ${seq2_4v_pam} ${seq2_4v_pam} ${seq2_4v_pam} |\
  cmp -s ${seq2_4v3_pam} - ; echo $?
  done


echo "Test 12.  Should print 2773166369 245, 0 nine times, 1 once"
pamenlarge -yscale 4 ${seq2_4h_pam} | tee ${seq2_4h4_pam} | cksum
pamcat -tb ${seq2_4h_pam} |\
    pamcat -tb - ${seq2_4h_pam} ${seq2_4h_pam} ${seq2_4h_pam} |\
    cmp -s ${seq2_4h4_pam} - ; echo $?
pamcat -tb ${seq2_4h_pam} ${seq2_4h_pam} |\
    pamcat -tb - ${seq2_4h_pam} ${seq2_4h_pam} |\
    cmp -s ${seq2_4h4_pam} - ; echo $?
pamcat -tb ${seq2_4h_pam} ${seq2_4h_pam} ${seq2_4h_pam}|\
    pamcat -tb - ${seq2_4h_pam} |\
    cmp -s ${seq2_4h4_pam} - ; echo $?
for opt in "-topbottom" "-tb -jleft"  "-tb -jcenter" "-tb --jright" \
    "-tb -white" "-tb -black" \
    "-leftright"
  do
  pamcat ${opt} ${seq2_4h_pam} ${seq2_4h_pam} ${seq2_4h_pam} ${seq2_4h_pam} |\
  cmp -s ${seq2_4h4_pam} - ; echo $?
  done

rm ${seq2_4h_pam} ${seq2_4v_pam} ${seq2_4v3_pam} ${seq2_4h4_pam}



echo "Test Invalid"

. ./test-invalid.inc

# direction not specified
invCmd "pamcat testgrid.pbm testimg.ppm"

# both directions specified
invCmd "pamcat -topbottom -leftright testgrid.pbm testimg.ppm"

# both pad colors specified
invCmd "pamcat -topbottom -white -black testgrid.pbm testimg.ppm"
invCmd "pamcat -lr -jtop -jbottom testgrid.pbm testimg.ppm"
invCmd "pamcat -lr -jtop -jcenter testgrid.pbm testimg.ppm"
invCmd "pamcat -lr -jcenter -jbottom testgrid.pbm testimg.ppm"
invCmd "pamcat -tb -jleft -jright testgrid.pbm testimg.ppm"
invCmd "pamcat -tb -jleft -jcenter testgrid.pbm testimg.ppm"
invCmd "pamcat -tb -jcenter -jright testgrid.pbm testimg.ppm"
invCmd "pamcat -lr -jleft    testgrid.pbm testimg.ppm"
invCmd "pamcat -lr -jright   testgrid.pbm testimg.ppm"
invCmd "pamcat -tb -jtop     testgrid.pbm testimg.ppm"
invCmd "pamcat -tb -jbottom  testgrid.pbm testimg.ppm"

# more than one input image from standard input
cat testgrid.pbm | pamcat -lr - - testimg.ppm > ${test_out} || \
  printf "Expected failure 14 "
  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
  rm -f ${test_out}