Skip to content

Commit 3799614

Browse files
author
giraffedata
committed
new tests
git-svn-id: https://svn.code.sf.net/p/netpbm/code/trunk@3949 9d0c8265-081b-0410-96cb-a4ca84ce46f8
1 parent 9c45283 commit 3799614

11 files changed

+747
-12
lines changed

test/Test-Order

+6-1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ ppmdim.test
9292
pnmshear.test
9393
pgmbentley.test
9494

95+
pamfunc.test
96+
pamarith.test
97+
9598
pamenlarge.test
9699
pamenlarge-pbm.test
97100

@@ -150,9 +153,10 @@ enlarge-reduce-roundtrip.test
150153
cut-cat-roundtrip.test
151154
pamhue-roundtrip.test
152155

153-
# Round-trip tests: miscellaneous utility
156+
# Round-trip tests: miscellaneous utilities
154157

155158
pamexec-roundtrip.test
159+
channel-stack-roundtrip.test
156160

157161
# Round-trip tests : lossless converters
158162

@@ -203,6 +207,7 @@ tiff-flate-lzw-roundtrip.test
203207
utahrle-roundtrip.test
204208
wbmp-roundtrip.test
205209
winicon-roundtrip.test
210+
winicon-roundtrip2.test
206211
xbm-roundtrip.test
207212
xpm-roundtrip.test
208213
xv-roundtrip.test

test/channel-stack-roundtrip.ok

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Test 1: should print 1873848880 101532 twice, then 0
2+
1873848880 101532
3+
1873848880 101532
4+
1873848880 101532
5+
1873848880 101532
6+
1873848880 101532
7+
0
8+
Test 2: Should print 447072062 33892 three times
9+
447072062 33892
10+
447072062 33892
11+
447072062 33892

test/channel-stack-roundtrip.test

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#! /bin/bash
2+
# This script tests: pamchanel pamstack
3+
# Also requires: pamtopam pamstack pamtopnm
4+
5+
tmpdir=${tmpdir:-/tmp}
6+
r_pam=${tmpdir}/testimg_r.pam
7+
g_pam=${tmpdir}/testimg_g.pam
8+
b_pam=${tmpdir}/testimg_b.pam
9+
rgb_pam=${tmpdir}/testimg_rgb.pam
10+
11+
echo "Test 1: should print 1873848880 101532 twice, then 0"
12+
13+
pamchannel -tupletype="GRAYSCALE" -infile testimg.ppm 0 > ${r_pam}
14+
pamchannel -tupletype="GRAYSCALE" -infile testimg.ppm 1 > ${g_pam}
15+
pamchannel -tupletype="GRAYSCALE" -infile testimg.ppm 2 > ${b_pam}
16+
17+
pamtopam < testimg.ppm | pamstack -tupletype="RGB" - | cksum
18+
pamstack ${r_pam} ${g_pam} | \
19+
pamstack -tupletype="RGB" - ${b_pam} | cksum
20+
pamstack ${r_pam} | \
21+
pamstack -tupletype="RGB" - ${g_pam} ${b_pam} | cksum
22+
pamstack ${r_pam} ${b_pam} ${g_pam} ${b_pam} ${b_pam} ${b_pam} | \
23+
pamchannel -tupletype="RGB" 0 2 4 | cksum
24+
pamstack -tupletype="RGB" ${r_pam} ${g_pam} ${b_pam} | tee ${rgb_pam} | cksum
25+
pamtopnm ${rgb_pam} | cmp - testimg.ppm
26+
echo $?
27+
28+
echo "Test 2: Should print 447072062 33892 three times"
29+
30+
cat ${r_pam} | cksum
31+
pamstack -tupletype="GRAYSCALE" ${r_pam} | cksum
32+
pamstack ${r_pam} | pamchannel -tupletype="GRAYSCALE" 0 | cksum
33+
34+
rm ${r_pam} ${g_pam} ${b_pam} ${rgb_pam}

test/pamarith.ok

+149
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
Test 1
2+
P2
3+
16 2
4+
15
5+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
6+
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
7+
-add
8+
P2 16 1 15 2 3 4 5 6 7 8 9 10 11 12 13 14 15 15 15
9+
1927712885 59
10+
1927712885 59
11+
1927712885 59
12+
-subtract
13+
P2 16 1 15 0 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13
14+
622443613 59
15+
622443613 59
16+
622443613 59
17+
-multiply
18+
P2 16 1 15 0 0 0 0 1 1 1 1 1 1 1 1 2 2 2 2
19+
1589721418 59
20+
1589721418 59
21+
1589721418 59
22+
-divide
23+
P2 16 1 15 0 8 15 15 15 15 15 15 15 15 15 15 15 15 15 15
24+
321546811 59
25+
321546811 59
26+
321546811 59
27+
-difference
28+
P2 16 1 15 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13
29+
590140907 59
30+
590140907 59
31+
590140907 59
32+
-minimum
33+
P2 16 1 15 0 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2
34+
3746423180 59
35+
3746423180 59
36+
3746423180 59
37+
-maximum
38+
P2 16 1 15 2 2 2 3 4 5 6 7 8 9 10 11 12 13 14 15
39+
201376294 59
40+
201376294 59
41+
201376294 59
42+
-mean
43+
P2 16 1 15 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9
44+
1456675831 59
45+
1456675831 59
46+
1456675831 59
47+
-compare
48+
P2 16 1 2 0 0 1 2 2 2 2 2 2 2 2 2 2 2 2 2
49+
196115582 58
50+
196115582 58
51+
196115582 58
52+
-and
53+
P2 16 1 15 0 0 2 2 0 0 2 2 0 0 2 2 0 0 2 2
54+
3660405045 59
55+
3660405045 59
56+
3660405045 59
57+
-or
58+
P2 16 1 15 2 3 2 3 6 7 6 7 10 11 10 11 14 15 14 15
59+
157317791 59
60+
157317791 59
61+
157317791 59
62+
-nand
63+
P2 16 1 15 15 15 13 13 15 15 13 13 15 15 13 13 15 15 13 13
64+
1625584307 59
65+
1625584307 59
66+
1625584307 59
67+
-nor
68+
P2 16 1 15 13 12 13 12 9 8 9 8 5 4 5 4 1 0 1 0
69+
3014218009 59
70+
3014218009 59
71+
3014218009 59
72+
-xor
73+
P2 16 1 15 2 3 0 1 6 7 4 5 10 11 8 9 14 15 12 13
74+
3227090877 59
75+
3227090877 59
76+
3227090877 59
77+
-shiftleft
78+
P2 16 1 15 0 4 8 12 0 4 8 12 0 4 8 12 0 4 8 12
79+
952940636 59
80+
952940636 59
81+
952940636 59
82+
-shiftright
83+
P2 16 1 15 0 0 0 0 1 1 1 1 2 2 2 2 3 3 3 3
84+
2898922266 59
85+
2898922266 59
86+
2898922266 59
87+
Test 2 (input = output)
88+
cksum is 2425386270 41 or 2921940274 59
89+
input image
90+
2425386270 41
91+
-minimum
92+
2425386270 41
93+
-maximum
94+
2425386270 41
95+
-mean
96+
2425386270 41
97+
-and
98+
2425386270 41
99+
-or
100+
2425386270 41
101+
input image
102+
2921940274 59
103+
-minimum
104+
2921940274 59
105+
-maximum
106+
2921940274 59
107+
-mean
108+
2921940274 59
109+
-and
110+
2921940274 59
111+
-or
112+
2921940274 59
113+
Test 3 (blank output)
114+
cksum is 2817549367 41 or 320101399 59
115+
-subtract
116+
2817549367 41
117+
-difference
118+
2817549367 41
119+
-xor
120+
2817549367 41
121+
-subtract
122+
320101399 59
123+
-difference
124+
320101399 59
125+
-xor
126+
320101399 59
127+
Test Error: Should print 1 twenty-two times
128+
1
129+
1
130+
1
131+
1
132+
1
133+
1
134+
1
135+
1
136+
1
137+
1
138+
1
139+
1
140+
1
141+
1
142+
1
143+
1
144+
1
145+
1
146+
1
147+
1
148+
1
149+
1

test/pamarith.test

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
#! /bin/bash
2+
# This script tests: pamarith
3+
# Also requires: pamchannel pamseq pamtopnm pgmmake pnmcat rgb3toppm
4+
5+
tmpdir=${tmpdir:-/tmp}
6+
input1_pgm=${tmpdir}/input1.pgm
7+
input2_pgm=${tmpdir}/input2.pgm
8+
output_pgm=${tmpdir}/output.pgm
9+
input1_ppm=${tmpdir}/input1.ppm
10+
input2_ppm=${tmpdir}/input2.ppm
11+
12+
echo "Test 1"
13+
14+
pamseq 1 15 | pamtopnm -assume > ${input1_pgm}
15+
pgmmake -maxval 15 0.15 16 1 > ${input2_pgm}
16+
17+
rgb3toppm ${input1_pgm} ${input1_pgm} ${input1_pgm} > ${input1_ppm}
18+
rgb3toppm ${input2_pgm} ${input2_pgm} ${input2_pgm} > ${input2_ppm}
19+
20+
pnmcat -tb -plain ${input1_pgm} ${input2_pgm}
21+
22+
for fn in "-add" "-subtract" "-multiply" "-divide" "-difference" \
23+
"-minimum" "-maximum" "-mean" "-compare" \
24+
"-and" "-or" "-nand" "-nor" "-xor" \
25+
"-shiftleft" "-shiftright"
26+
do
27+
echo ${fn}
28+
pamarith ${fn} -plain ${input1_pgm} ${input2_pgm} | tr '\n' ' '; echo
29+
pamarith ${fn} ${input1_pgm} ${input2_pgm} > ${output_pgm}
30+
rgb3toppm ${output_pgm} ${output_pgm} ${output_pgm} | cksum
31+
pamarith ${fn} ${input1_ppm} ${input2_pgm} | cksum
32+
pamarith ${fn} ${input1_ppm} ${input2_ppm} | cksum
33+
done
34+
35+
rm ${input1_pgm} ${input2_pgm} ${output_pgm} ${input2_ppm}
36+
37+
echo "Test 2 (input = output)"
38+
echo "cksum is 2425386270 41 or 2921940274 59"
39+
40+
for image in testgrid.pbm ${input1_ppm}
41+
do
42+
echo "input image"
43+
cat ${image} | cksum
44+
for fn in "-minimum" "-maximum" "-mean" "-and" "-or"
45+
do
46+
echo ${fn}
47+
pamarith ${fn} ${image} ${image} | cksum
48+
done
49+
done
50+
51+
52+
echo "Test 3 (blank output)"
53+
echo "cksum is 2817549367 41 or 320101399 59"
54+
55+
for image in testgrid.pbm ${input1_ppm}
56+
do
57+
for fn in "-subtract" "-difference" "-xor"
58+
do
59+
echo ${fn}
60+
pamarith ${fn} ${image} ${image} | cksum
61+
done
62+
done
63+
64+
rm ${input1_ppm}
65+
66+
67+
echo "Invalid command-line argument combinations." 1>&2
68+
echo "Error messages should appear below the line." 1>&2
69+
echo "-----------------------------------------------------------" 1>&2
70+
71+
echo "Test Error: Should print 1 twenty-two times"
72+
73+
output_ppm=${tmpdir}/output.ppm
74+
75+
for option in "-add -subtract" \
76+
"-multiply -divide" \
77+
"-difference -minimum" \
78+
"-maximum -mean" \
79+
"-compare -and" \
80+
"-or -nand" \
81+
"-nor -xor" \
82+
"-shiftleft -shiftright"
83+
do
84+
pamarith ${option} testimg.ppm testimg.ppm > ${output_ppm}
85+
echo $?
86+
test -s ${output_ppm}
87+
echo $?
88+
done
89+
90+
pamarith -add testimg.ppm testimg.ppm testimg.ppm > ${output_ppm}
91+
echo $?
92+
test -s ${output_ppm}
93+
echo $?
94+
pamarith -add testimg.ppm testgrid.pbm > ${output_ppm}
95+
echo $?
96+
test -s ${output_ppm}
97+
echo $?
98+
pamchannel -infile testimg.ppm 0 1 | \
99+
pamarith -add testimg.ppm - > ${output_ppm}
100+
echo $?
101+
test -s ${output_ppm}
102+
echo $?
103+
104+
rm ${output_ppm}

0 commit comments

Comments
 (0)