Skip to content

Commit 86f4765

Browse files
author
giraffedata
committed
Add tests for pamrestack, pamshuffle; rename testimg.ppm work file; correct errors in 'also requires' entries
git-svn-id: https://svn.code.sf.net/p/netpbm/code/trunk@4347 9d0c8265-081b-0410-96cb-a4ca84ce46f8
1 parent 761d7c0 commit 86f4765

23 files changed

+323
-71
lines changed

test/Test-Order

+2
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ pambackground.test
8383
pnmpad-reportonly.test
8484
pnmpaste-pbm.test
8585

86+
pamrestack.test
87+
pamshuffle.test
8688
ppmshift.test
8789
ppmspread.test
8890

test/all-in-place.ok

+2
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ pamtopdbimg: ok
109109
pamtopfm: ok
110110
pamtopng: ok
111111
pamtopnm: ok
112+
pamtoqoi: ok
112113
pamtosrf: ok
113114
pamtosvg: ok
114115
pamtotga: ok
@@ -302,6 +303,7 @@ ppmtv: ok
302303
ppmwheel: ok
303304
psidtopgm: ok
304305
pstopnm: ok
306+
qoitopam: ok
305307
qrttoppm: ok
306308
rasttopnm: ok
307309
rawtopgm: ok

test/all-in-place.test

+2
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ ordinary_testprogs="\
151151
pamtopfm \
152152
pamtopng \
153153
pamtopnm \
154+
pamtoqoi \
154155
pamtosrf \
155156
pamtosvg \
156157
pamtotga \
@@ -344,6 +345,7 @@ ordinary_testprogs="\
344345
ppmwheel \
345346
psidtopgm \
346347
pstopnm \
348+
qoitopam \
347349
qrttoppm \
348350
rasttopnm \
349351
rawtopgm \

test/channel-stack-roundtrip.test

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#! /bin/sh
2-
# This script tests: pamchanel pamstack
3-
# Also requires: pamtopam pamstack pamtopnm
2+
# This script tests: pamchannel pamstack
3+
# Also requires: pamtopam pamtopnm
44

55
tmpdir=${tmpdir:-/tmp}
66
r_pam=${tmpdir}/testimg_r.pam

test/gif-roundtrip.test

+32-32
Original file line numberDiff line numberDiff line change
@@ -10,40 +10,40 @@ tmpdir=${tmpdir:-/tmp}
1010

1111
echo "Test 1. Should print 1926073387 101484"
1212

13-
test_ppm=${tmpdir}/testimg.ppm
13+
rose_ppm=${tmpdir}/rose.ppm
1414

15-
cp testimg.ppm ${tmpdir} &&
16-
ppmtorgb3 ${test_ppm}
15+
cp testimg.ppm ${rose_ppm} &&
16+
ppmtorgb3 ${rose_ppm}
1717

18-
test_red=${tmpdir}/testimg.red
19-
test_grn=${tmpdir}/testimg.grn
20-
test_blu=${tmpdir}/testimg.blu
18+
rose_red=${tmpdir}/rose.red
19+
rose_grn=${tmpdir}/rose.grn
20+
rose_blu=${tmpdir}/rose.blu
2121
out_red=${tmpdir}/out.red
2222
out_grn=${tmpdir}/out.grn
2323
#out_blu=${tmpdir}/out.blu
2424

25-
pamtogif ${test_red} | giftopnm > ${out_red} &&
26-
pamtogif ${test_grn} | giftopnm > ${out_grn} &&
27-
pamtogif ${test_blu} | giftopnm | \
25+
pamtogif ${rose_red} | giftopnm > ${out_red} &&
26+
pamtogif ${rose_grn} | giftopnm > ${out_grn} &&
27+
pamtogif ${rose_blu} | giftopnm | \
2828
rgb3toppm ${out_red} ${out_grn} - | \
2929
cksum
3030

31-
rm ${test_ppm} ${test_grn} ${test_blu} ${out_red} ${out_grn}
31+
rm ${rose_ppm} ${rose_grn} ${rose_blu} ${out_red} ${out_grn}
3232

3333
echo "Test 2. Should produce 1571496937 33838 six times"
3434

35-
test_gif=${tmpdir}/testimg.gif
35+
rose_gif=${tmpdir}/rose.gif
3636

37-
cat ${test_red} | cksum
38-
pamtogif ${test_red} | giftopnm | cksum
39-
pamtogif -interlace ${test_red} | giftopnm | cksum
40-
pamtogif -noclear ${test_red} | giftopnm | cksum
41-
pamtogif -sort ${test_red} | tee ${test_gif} | \
37+
cat ${rose_red} | cksum
38+
pamtogif ${rose_red} | giftopnm | cksum
39+
pamtogif -interlace ${rose_red} | giftopnm | cksum
40+
pamtogif -noclear ${rose_red} | giftopnm | cksum
41+
pamtogif -sort ${rose_red} | tee ${rose_gif} | \
4242
giftopnm | cksum
43-
echo "junk" >> ${test_gif} && \
44-
giftopnm -image=1 -quitearly ${test_gif} | cksum
43+
echo "junk" >> ${rose_gif} && \
44+
giftopnm -image=1 -quitearly ${rose_gif} | cksum
4545

46-
rm ${test_gif} ${test_red}
46+
rm ${rose_gif} ${rose_red}
4747

4848
echo "Test 3. Should produce 281226646 481 six times"
4949
# maze.pbm is too small for -noclear to take effect
@@ -78,7 +78,7 @@ echo ""
7878
echo "Test 5. Should produce: N : 0 0 0 0 : 0 , N : 0 0 0 0 : 0"
7979
echo "(N=238, 239, 240, 241, 255, 256, 257, 4030, 4031, 4097)"
8080

81-
test_pgm=${tmpdir}/testimg.pgm
81+
rose_pgm=${tmpdir}/rose.pgm
8282

8383
# The following awk scripts produce a PGM file with no repeated
8484
# sequences. Obviously this cannot be compressed at all; the codes
@@ -114,14 +114,14 @@ awk -v maxval=${maxval} 'BEGIN \
114114

115115
for size in 238 239 240 241 255 256 257
116116
do
117-
pamcut -height=${size} ${test257_pgm} > ${test_pgm} &&
118-
pamtogif -verbose ${test_pgm} | giftopnm | pamdepth ${maxval} | \
119-
cmp - ${test_pgm}
117+
pamcut -height=${size} ${test257_pgm} > ${rose_pgm} &&
118+
pamtogif -verbose ${rose_pgm} | giftopnm | pamdepth ${maxval} | \
119+
cmp - ${rose_pgm}
120120
echo -n ${size} ":" ${PIPESTATUS[@]} ":" $? ", "
121-
pamtogif -nolzw -verbose ${test_pgm} | giftopnm | pamdepth ${maxval} | \
122-
cmp - ${test_pgm}
121+
pamtogif -nolzw -verbose ${rose_pgm} | giftopnm | pamdepth ${maxval} | \
122+
cmp - ${rose_pgm}
123123
echo ${size} ":" ${PIPESTATUS[@]} ":" $?
124-
rm ${test_pgm}
124+
rm ${rose_pgm}
125125
done
126126

127127
rm ${test257_pgm}
@@ -144,16 +144,16 @@ awk -v maxval=${maxval} 'BEGIN \
144144

145145
for size in 4030 4031 4097
146146
do
147-
pamcut -height ${size} ${test4097_pgm} > ${test_pgm} &&
148-
pamtogif -verbose ${test_pgm} | giftopnm | pamdepth ${maxval} | \
149-
cmp - ${test_pgm}
147+
pamcut -height ${size} ${test4097_pgm} > ${rose_pgm} &&
148+
pamtogif -verbose ${rose_pgm} | giftopnm | pamdepth ${maxval} | \
149+
cmp - ${rose_pgm}
150150
# pamdepth ${maxval} is necessary because
151151
# giftopnm output is maxval 255
152152
echo -n ${size} ":" ${PIPESTATUS[@]} ":" $? ", "
153-
pamtogif -nolzw ${test_pgm} | giftopnm | pamdepth ${maxval} | \
154-
cmp - ${test_pgm}
153+
pamtogif -nolzw ${rose_pgm} | giftopnm | pamdepth ${maxval} | \
154+
cmp - ${rose_pgm}
155155
echo ${size} ":" ${PIPESTATUS[@]} ":" $?
156-
rm ${test_pgm}
156+
rm ${rose_pgm}
157157
done
158158

159159
rm ${test4097_pgm}

test/pamflip-pbm-roundtrip.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#! /bin/sh
22
# This script tests: pamflip
3-
# Also requires: ppmpat pamseq pamtopnm
3+
# Also requires: pbmmake pbmnoise
44

55
tmpdir=${tmpdir:-/tmp}
66
dot_pbm=${tmpdir}/dot.pbm

test/pamhue.test

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pamseq -tupletype=RGB 3 1 | pamdepth 255 | pamhue -huechange=60 | \
1616

1717
echo "Test 3"
1818
# pamhue has no effect on monotone images
19-
# Should print 281226646 481 twice
19+
# Should print 0 0 : 0 twice
2020

2121
pamhue -huechange=45 maze.pbm | cmp -s - maze.pbm
2222
echo ${PIPESTATUS[@]} ":" $?
@@ -25,7 +25,7 @@ pamhue -huechange=180 maze.pbm | cmp -s - maze.pbm
2525

2626
echo "Test 4"
2727
# spinning the color wheel by multiples of 360 leaves the image unchanged
28-
# Should print 1926073387 101484 twice
28+
# Should print 0 0 : 0 twice
2929

3030
pamhue -huechange=0 testimg.ppm | cmp -s - testimg.ppm
3131
echo ${PIPESTATUS[@]} ":" $?

test/pamrecolor.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#! /bin/sh
22
# This script tests: pamrecolor
3-
# Also requires: ppmtopgm pgmmake
3+
# Also requires: pgmmake
44

55
tmpdir=${tmpdir:-/tmp}
66
base_pgm=${tmpdir}/base.pgm

test/pamrestack.ok

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
Test 1.
2+
P2
3+
24 1
4+
7
5+
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
6+
P2
7+
10 3
8+
7
9+
0 1 2 3 4 5 6 7 0 1
10+
2 3 4 5 6 7 0 1 2 3
11+
4 5 6 7 0 0 0 0 0 0
12+
P2
13+
10 2
14+
7
15+
0 1 2 3 4 5 6 7 0 1
16+
2 3 4 5 6 7 0 1 2 3
17+
P2
18+
4 6
19+
7
20+
0 1 2 3
21+
4 5 6 7
22+
0 1 2 3
23+
4 5 6 7
24+
0 1 2 3
25+
4 5 6 7
26+
P2
27+
12 2
28+
7
29+
0 1 2 3 4 5 6 7 0 1 2 3
30+
4 5 6 7 0 1 2 3 4 5 6 7
31+
Test 2. Should print 0 twelve times
32+
0
33+
0
34+
0
35+
0
36+
0
37+
0
38+
0
39+
0
40+
0
41+
0
42+
0
43+
0
44+
Test 3. Should produce 3141273448 431 fifteen times
45+
3141273448 431
46+
3141273448 431
47+
3141273448 431
48+
3141273448 431
49+
3141273448 431
50+
3141273448 431
51+
3141273448 431
52+
3141273448 431
53+
3141273448 431
54+
3141273448 431
55+
3141273448 431
56+
3141273448 431
57+
3141273448 431
58+
3141273448 431
59+
3141273448 431
60+
Test 4. Should produce 1768948962 101484 twice
61+
1768948962 101484
62+
1768948962 101484
63+
Test Invalid.
64+
Expected failure 1 1
65+
Expected failure 2 1
66+
Expected failure 3 1
67+
Expected failure 4 1
68+
Expected failure 5 1

test/pamrestack.test

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#! /bin/sh
2+
# This script tests: pamrestack
3+
# Also requires: pamfile pamflip pgmramp pnmcrop pnminvert
4+
5+
tmpdir=${tmpdir:-/tmp}
6+
ramp_pgm=${tmpdir}/ramp.pgm
7+
ramp2_pgm=${tmpdir}/ramp2.pgm
8+
maze_singlerow_pbm=${tmpdir}/maze_singlerow.pbm
9+
maze_inverted_pbm=${tmpdir}/maze_inverted.pbm
10+
11+
echo "Test 1."
12+
13+
pgmramp -lr -maxval=7 8 3 | tee ${ramp_pgm} | pamrestack -plain
14+
pamrestack -width=10 -trim=fill -plain ${ramp_pgm}
15+
pamrestack -width=10 -trim=crop -plain ${ramp_pgm}
16+
pamrestack -width=4 -trim=fill -plain ${ramp_pgm}
17+
pamrestack -width=12 -trim=fill -plain ${ramp_pgm}
18+
19+
echo "Test 2. Should print 0 twelve times"
20+
21+
for width in 2 4 5 8 12 24
22+
do
23+
pamrestack -width=${width} -trim=crop ${ramp_pgm} > ${ramp2_pgm}
24+
for flag in "-trim=crop" "-trim=fill"
25+
do
26+
pamrestack -width=${width} ${flag} ${ramp2_pgm} | cmp -s - ${ramp2_pgm}
27+
echo $?
28+
done
29+
done
30+
31+
rm ${ramp_pgm} ${ramp2_pgm}
32+
33+
echo "Test 3. Should produce 3141273448 431 fifteen times"
34+
35+
# Invert maze.pbm because the lower right corner is black
36+
37+
pixels=`pamfile -size maze.pbm | awk '{print $1 * $2}'`
38+
39+
pnminvert maze.pbm | tee ${maze_inverted_pbm} | \
40+
pamrestack | tee ${maze_singlerow_pbm} | pnmcrop -right -black | cksum
41+
for width in 1 2 3 100 1000 ${pixels} $((pixels -1))
42+
do
43+
pamrestack -width=${width} ${maze_inverted_pbm} | pamrestack | \
44+
pnmcrop -right -black | cksum
45+
pamrestack -width=${width} ${maze_singlerow_pbm} | \
46+
pamrestack | pnmcrop -right -black | cksum
47+
done
48+
49+
rm ${maze_inverted_pbm} ${maze_singlerow_pbm}
50+
51+
echo "Test 4. Should produce 1768948962 101484 twice"
52+
53+
pamrestack -width=1 testimg.ppm | pamflip -ccw | cksum
54+
pamrestack \
55+
-width=`pamfile -size testimg.ppm | cut -d " " -f2` testimg.ppm | \
56+
pamrestack | cksum
57+
58+
test_out=${tmpdir}/test_out
59+
echo "Test Invalid."
60+
61+
echo 1>&2
62+
echo "Invalid command-line argument combinations." 1>&2
63+
echo "Error messages should appear below the line." 1>&2
64+
echo "-----------------------------------------------------------" 1>&2
65+
66+
pamrestack testgrid.pbm maze.pbm > ${test_out} || \
67+
echo -n "Expected failure 1"
68+
test -s ${test_out}; echo " "$?
69+
rm -f ${test_out}
70+
71+
pamrestack -abort \
72+
-width=$((pixels * 2 + 1 )) maze.pbm > ${test_out} || \
73+
echo -n "Expected failure 2"
74+
test -s ${test_out}; echo " "$?
75+
rm -f ${test_out}
76+
77+
pamrestack -crop \
78+
-width=$((pixels * 2 + 1)) maze.pbm > ${test_out} || \
79+
echo -n "Expected failure 3"
80+
test -s ${test_out}; echo " "$?
81+
rm -f ${test_out}
82+
83+
pamrestack -width=0 maze.pbm > ${test_out} || \
84+
echo -n "Expected failure 4"
85+
test -s ${test_out}; echo " "$?
86+
rm -f ${test_out}
87+
88+
pamrestack -width maze.pbm > ${test_out} || \
89+
echo -n "Expected failure 5"
90+
test -s ${test_out}; echo " "$?
91+
rm -f ${test_out}

test/pamscale-filters1.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#! /bin/bash
22
# This script tests: pamscale pamenlarge
3-
# Also requires: pamvalidate pnmpsnr
3+
# Also requires: pamfile pamvalidate pnmpsnr
44

55
tmpdir=${tmpdir:-/tmp}
66
enlarge_ppm=${tmpdir}/enlarge.ppm

test/pamscale-filters2.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#! /bin/bash
22
# This script tests: pamscale pamstretch pamstretch-gen
3-
# Also requires: pamvalidate pnmpsnr
3+
# Also requires: pamfile pamvalidate pnmpsnr
44

55
tmpdir=${tmpdir:-/tmp}
66
stretch_ppm=${tmpdir}/stretch.ppm

test/pamscale-filters3.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#! /bin/bash
22
# This script tests: pamscale pamstretch pamstretch-gen
3-
# Also requires: pamvalidate pnmpsnr
3+
# Also requires: pamfile pamvalidate pnmpsnr
44

55
tmpdir=${tmpdir:-/tmp}
66
stretch_ppm=${tmpdir}/stretch.ppm

0 commit comments

Comments
 (0)