@@ -116,142 +116,68 @@ for image in maze.pbm ${input1_ppm}
116
116
117
117
rm ${input1_ppm}
118
118
119
- echo " Invalid command-line argument combinations." 1>&2
120
- echo " Error messages should appear below the line." 1>&2
121
- echo " -----------------------------------------------------------" 1>&2
122
-
123
119
echo " Test Invalid"
124
120
125
- test_out= ${tmpdir} /test_out
121
+ . ${srcdir} /test-invalid.inc
126
122
127
123
# multiple functions
128
124
129
- pamarith -add -subtract testimg.ppm testimg.ppm > ${test_out} || \
130
- printf " Expected failure 1 "
131
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
132
- rm -f ${test_out}
133
-
134
- pamarith -multiply -divide testimg.ppm testimg.ppm > ${test_out} || \
135
- printf " Expected failure 2 "
136
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
137
- rm -f ${test_out}
138
-
139
- pamarith -difference -minimum testimg.ppm testimg.ppm > ${test_out} || \
140
- printf " Expected failure 3 "
141
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
142
- rm -f ${test_out}
143
-
144
- pamarith -maximum -mean testimg.ppm testimg.ppm > ${test_out} || \
145
- printf " Expected failure 4 "
146
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
147
- rm -f ${test_out}
148
-
149
- pamarith -compare -and testimg.ppm testimg.ppm > ${test_out} || \
150
- printf " Expected failure 5 "
151
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
152
- rm -f ${test_out}
153
-
154
- pamarith -compare -equal testimg.ppm testimg.ppm > ${test_out} || \
155
- printf " Expected failure 6 "
156
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
157
- rm -f ${test_out}
158
-
159
- pamarith -or -nand testimg.ppm testimg.ppm > ${test_out} || \
160
- printf " Expected failure 7 "
161
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
162
- rm -f ${test_out}
163
-
164
- pamarith -nor -xor testimg.ppm testimg.ppm > ${test_out} || \
165
- printf " Expected failure 8 "
166
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
167
- rm -f ${test_out}
168
-
169
- pamarith -shiftleft -shiftright testimg.ppm testimg.ppm > ${test_out} || \
170
- printf " Expected failure 9 "
171
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
172
- rm -f ${test_out}
125
+ invCmd " pamarith -add -subtract testimg.ppm testimg.ppm"
126
+ invCmd " pamarith -multiply -divide testimg.ppm testimg.ppm"
127
+ invCmd " pamarith -difference -minimum testimg.ppm testimg.ppm"
128
+ invCmd " pamarith -maximum -mean testimg.ppm testimg.ppm"
129
+ invCmd " pamarith -compare -and testimg.ppm testimg.ppm"
130
+ invCmd " pamarith -compare -equal testimg.ppm testimg.ppm"
131
+ invCmd " pamarith -or -nand testimg.ppm testimg.ppm"
132
+ invCmd " pamarith -nor -xor testimg.ppm testimg.ppm"
133
+ invCmd " pamarith -shiftleft -shiftright testimg.ppm testimg.ppm"
173
134
174
135
# -add does not take a value
175
136
176
- pamarith -add=1 testimg.ppm testimg.ppm > ${test_out} || \
177
- printf " Expected failure 10 "
178
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
179
- rm -f ${test_out}
137
+ invCmd " pamarith -add=1 testimg.ppm testimg.ppm"
180
138
181
139
# No function
182
140
183
- pamarith -plain testimg.ppm testimg.ppm > ${test_out} || \
184
- printf " Expected failure 11 "
185
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
186
- rm -f ${test_out}
187
-
188
- pamarith testimg.ppm testimg.ppm > ${test_out} || \
189
- printf " Expected failure 12 "
190
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
191
- rm -f ${test_out}
141
+ invCmd " pamarith -plain testimg.ppm testimg.ppm"
142
+ invCmd " pamarith testimg.ppm testimg.ppm"
192
143
193
144
# Just one input image file
194
145
195
- pamarith -add testimg.ppm > ${test_out} || \
196
- printf " Expected failure 13 "
197
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
198
- rm -f ${test_out}
146
+ invCmd " pamarith -add testimg.ppm"
199
147
200
148
# No input image file
201
149
202
- pamarith -add > ${test_out} || \
203
- printf " Expected failure 14 "
204
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
205
- rm -f ${test_out}
150
+ invCmd " pamarith -add"
206
151
207
152
# Input images with different depth (number of planes)
208
153
209
- pamchannel -infile testimg.ppm 0 1 | \
210
- pamarith -add testimg.ppm - > ${test_out} || \
211
- printf " Expected failure 15 "
212
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
213
- rm -f ${test_out}
154
+ input1_pam=${tmpdir} /input1.pam
214
155
215
- # Input images with different x/y dimensions
156
+ pamchannel -infile testimg.ppm 0 1 > ${input1_pam}
157
+ invCmd " pamarith -add testimg.ppm ${input1_pam} "
158
+ rm ${input1_pam}
216
159
217
- pamarith -add testimg.ppm testgrid.pbm > ${test_out} || \
218
- printf " Expected failure 16 "
219
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
220
- rm -f ${test_out}
221
-
222
- pamenlarge -xscale=2 testgrid.pbm | \
223
- pamarith -add testgrid.pbm - > ${test_out} || \
224
- printf " Expected failure 17 "
225
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
226
- rm -f ${test_out}
160
+ # Input images with different x/y dimensions
227
161
228
- pamenlarge -yscale=3 testgrid.pbm | \
229
- pamarith -add testgrid.pbm - > ${test_out} || \
230
- printf " Expected failure 18 "
231
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
232
- rm -f ${test_out}
162
+ invCmd " pamarith -add testimg.ppm testgrid.pbm"
233
163
234
- # Invalid usage of -closeness
164
+ input1_pbm=${tmpdir} /input1.pbm
165
+ input2_pbm=${tmpdir} /input2.pbm
235
166
236
- pamarith -equal -closeness=100.1 testgrid.pbm > ${test_out} || \
237
- printf " Expected failure 19 "
238
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
239
- rm -f ${test_out}
167
+ pamenlarge -xscale=2 testgrid.pbm > ${input1_pbm}
168
+ invCmd " pamarith -add testgrid.pbm ${input1_pbm} "
169
+ rm ${input1_pbm}
240
170
241
- pamarith -equal -closeness=-10 testgrid.pbm > ${test_out} || \
242
- printf " Expected failure 20 "
243
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
244
- rm -f ${test_out}
171
+ pamenlarge -yscale=3 testgrid.pbm > ${input2_pbm}
172
+ invCmd " pamarith -add testgrid.pbm ${input2_pbm} "
173
+ rm ${input2_pbm}
245
174
246
- pamarith -closeness -equal testgrid.pbm > ${test_out} || \
247
- printf " Expected failure 21 "
248
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
249
- rm -f ${test_out}
175
+ # Invalid usage of -closeness
250
176
251
- pamarith -compare -closeness=10 testgrid.pbm > ${test_out} || \
252
- printf " Expected failure 22 "
253
- test -s ${test_out} && echo " unexpected output " || echo " (no output) "
254
- rm -f ${test_out}
177
+ invCmd " pamarith -equal -closeness=100.1 testgrid.pbm"
178
+ invCmd " pamarith -equal -closeness=-10 testgrid.pbm "
179
+ invCmd " pamarith -closeness -equal testgrid.pbm "
180
+ invCmd " pamarith -compare -closeness=10 testgrid.pbm "
255
181
256
182
# Bit string functions
257
183
# Create PGM test input
@@ -266,113 +192,37 @@ pgmmake -maxval=8191 1.0 3 1 > ${input5_pgm}
266
192
267
193
# Bit string functions - Maxval must match
268
194
269
- pamarith -and ${input3_pgm} ${input5_pgm} > ${test_out} || \
270
- printf " Expected failure 23 "
271
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
272
- rm -f ${test_out}
273
-
274
- pamarith -or ${input3_pgm} ${input5_pgm} > ${test_out} || \
275
- printf " Expected failure 24 "
276
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
277
- rm -f ${test_out}
278
-
279
- pamarith -nand ${input3_pgm} ${input5_pgm} > ${test_out} || \
280
- printf " Expected failure 25 "
281
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
282
- rm -f ${test_out}
283
-
284
- pamarith -nor ${input3_pgm} ${input5_pgm} > ${test_out} || \
285
- printf " Expected failure 26 "
286
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
287
- rm -f ${test_out}
288
-
289
- pamarith -xor ${input3_pgm} ${input5_pgm} > ${test_out} || \
290
- printf " Expected failure 27 "
291
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
292
- rm -f ${test_out}
195
+ invCmd " pamarith -and ${input3_pgm} ${input5_pgm} "
196
+ invCmd " pamarith -or ${input3_pgm} ${input5_pgm} "
197
+ invCmd " pamarith -nand ${input3_pgm} ${input5_pgm} "
198
+ invCmd " pamarith -nor ${input3_pgm} ${input5_pgm} "
199
+ invCmd " pamarith -xor ${input3_pgm} ${input5_pgm} "
293
200
294
201
# Bit string functions - Maxval must be 2^n -1
295
202
296
- pamarith -and ${input4_pgm} ${input4_pgm} > ${test_out} || \
297
- printf " Expected failure 28 "
298
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
299
- rm -f ${test_out}
300
-
301
- pamarith -or ${input4_pgm} ${input4_pgm} > ${test_out} || \
302
- printf " Expected failure 29 "
303
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
304
- rm -f ${test_out}
305
-
306
- pamarith -nand ${input4_pgm} ${input4_pgm} > ${test_out} || \
307
- printf " Expected failure 30 "
308
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
309
- rm -f ${test_out}
310
-
311
- pamarith -nor ${input4_pgm} ${input4_pgm} > ${test_out} || \
312
- printf " Expected failure 31 "
313
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
314
- rm -f ${test_out}
315
-
316
- pamarith -xor ${input4_pgm} ${input4_pgm} > ${test_out} || \
317
- printf " Expected failure 32 "
318
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
319
- rm -f ${test_out}
320
-
321
- pamarith -shiftleft ${input4_pgm} ${input4_pgm} > ${test_out} || \
322
- printf " Expected failure 33 "
323
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
324
- rm -f ${test_out}
325
-
326
- pamarith -shiftright ${input4_pgm} ${input4_pgm} > ${test_out} || \
327
- printf " Expected failure 34 "
328
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
329
- rm -f ${test_out}
203
+ invCmd " pamarith -and ${input4_pgm} ${input4_pgm} "
204
+ invCmd " pamarith -or ${input4_pgm} ${input4_pgm} "
205
+ invCmd " pamarith -nand ${input4_pgm} ${input4_pgm} "
206
+ invCmd " pamarith -nor ${input4_pgm} ${input4_pgm} "
207
+ invCmd " pamarith -xor ${input4_pgm} ${input4_pgm} "
208
+ invCmd " pamarith -shiftleft ${input4_pgm} ${input4_pgm} "
209
+ invCmd " pamarith -shiftright ${input4_pgm} ${input4_pgm} "
330
210
331
211
rm ${input3_pgm} ${input4_pgm} ${input5_pgm}
332
212
333
213
# Functions that do not allow more than two input images.
334
214
# Only the functions that are commutative and associative allow
335
215
# three or more inputs.
336
216
337
- pamarith -subtract testimg.ppm testimg.ppm testimg.ppm > ${test_out} || \
338
- printf " Expected failure 35 "
339
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
340
- rm -f ${test_out}
341
-
342
- pamarith -divide testimg.ppm testimg.ppm testimg.ppm > ${test_out} || \
343
- printf " Expected failure 36 "
344
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
345
- rm -f ${test_out}
346
-
347
- pamarith -compare testimg.ppm testimg.ppm testimg.ppm > ${test_out} || \
348
- printf " Expected failure 37 "
349
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
350
- rm -f ${test_out}
351
-
352
- pamarith -difference testimg.ppm testimg.ppm testimg.ppm > ${test_out} || \
353
- printf " Expected failure 38 "
354
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
355
- rm -f ${test_out}
356
-
357
- pamarith -shiftleft testimg.ppm testimg.ppm testimg.ppm > ${test_out} || \
358
- printf " Expected failure 39 "
359
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
360
- rm -f ${test_out}
361
-
362
- pamarith -shiftright testimg.ppm testimg.ppm testimg.ppm > ${test_out} || \
363
- printf " Expected failure 40 "
364
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
365
- rm -f ${test_out}
217
+ invCmd " pamarith -subtract testimg.ppm testimg.ppm testimg.ppm"
218
+ invCmd " pamarith -divide testimg.ppm testimg.ppm testimg.ppm"
219
+ invCmd " pamarith -compare testimg.ppm testimg.ppm testimg.ppm"
220
+ invCmd " pamarith -difference testimg.ppm testimg.ppm testimg.ppm"
221
+ invCmd " pamarith -shiftleft testimg.ppm testimg.ppm testimg.ppm"
222
+ invCmd " pamarith -shiftright testimg.ppm testimg.ppm testimg.ppm"
366
223
367
224
# Currently -equal and -mean do not allow more than two input images.
368
225
# These two cases should be removed once improvements are made.
369
226
370
- pamarith -equal testgrid.pbm testgrid.pbm testgrid.pbm > ${test_out} || \
371
- printf " Expected failure 41 "
372
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
373
- rm -f ${test_out}
374
-
375
- pamarith -mean testgrid.pbm testgrid.pbm testgrid.pbm > ${test_out} || \
376
- printf " Expected failure 42 "
377
- test -s ${test_out} && echo " unexpected output" || echo " (no output)"
378
- rm -f ${test_out}
227
+ invCmd " pamarith -equal testgrid.pbm testgrid.pbm testgrid.pbm"
228
+ invCmd " pamarith -mean testgrid.pbm testgrid.pbm testgrid.pbm"
0 commit comments