Skip to content

Commit dccfa61

Browse files
author
giraffedata
committed
Add tests for Ppmchange, Pambackground miscellaneous other refinements
git-svn-id: https://svn.code.sf.net/p/netpbm/code/trunk@2314 9d0c8265-081b-0410-96cb-a4ca84ce46f8
1 parent 3491ece commit dccfa61

13 files changed

+152
-32
lines changed

test/Test-Order

+2
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ pamflip2.test
5555
pamenlarge.test
5656
pnminvert.test
5757
pamchannel.test
58+
ppmchange.test
59+
pambackground.test
5860

5961
pbmpscale.test
6062
pnmremap1.test

test/gif-roundtrip.test

+2-3
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,15 @@ test_grn=${tmpdir}/testimg.grn
2727
test_blu=${tmpdir}/testimg.blu
2828
out_red=${tmpdir}/out.red
2929
out_grn=${tmpdir}/out.grn
30-
out_blu=${tmpdir}/out.blu
30+
#out_blu=${tmpdir}/out.blu
3131

3232
pamtogif ${test_red} | giftopnm > ${out_red} &&
3333
pamtogif ${test_grn} | giftopnm > ${out_grn} &&
3434
pamtogif ${test_blu} | giftopnm | \
3535
rgb3toppm ${out_red} ${out_grn} - | \
3636
cksum
3737

38-
rm ${test_ppm} ${test_grn} ${test_blu} \
39-
${out_red} ${out_grn} ${out_blu}
38+
rm ${test_ppm} ${test_grn} ${test_blu} ${out_red} ${out_grn}
4039

4140

4241
# Test 2. Should produce 1571496937 33838

test/pambackground.ok

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2155020792 451
2+
2514682516 33871
3+
2667595257 17328

test/pambackground.test

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#! /bin/bash
2+
# This script tests: pambackground
3+
# Also requires: pamgradient pamseq pbmmake pnmmargin pnmremap pnmtile
4+
5+
alias pambackground="${PBM_TESTPREFIX}pambackground"
6+
alias pamgradient="${PBM_BINPREFIX}pamgradient"
7+
alias pamseq="${PBM_BINPREFIX}pamseq"
8+
alias pbmmake="${PBM_BINPREFIX}pbmmake"
9+
alias pnmmargin="${PBM_BINPREFIX}pnmmargin"
10+
alias pnmremap="${PBM_BINPREFIX}pnmremap"
11+
alias pnmtile="${PBM_BINPREFIX}pnmtile"
12+
shopt -s expand_aliases
13+
14+
tmpdir=${tmpdir:-/tmp}
15+
16+
# Test 1.
17+
# Should produce: 2155020792 451
18+
pbmmake -g 23 11 | pnmmargin -black 2 | pambackground | cksum
19+
20+
21+
# Test 2.
22+
# Should produce: 2514682516 33871
23+
ibmttl_pam=${tmpdir}/ibmttl.pam
24+
25+
pamseq 3 1 > ${ibmttl_pam} && \
26+
pnmremap -quiet -mapfile ${ibmttl_pam} testimg.ppm | pambackground | cksum
27+
rm ${ibmttl_pam}
28+
29+
30+
# Test 3.
31+
# Should produce: 2667595257 17328
32+
pamgradient rgb:01/01/01 rgb:ff/7f/00 rgb:00/ff/7f rgb:fe/fe/fe 10 10 | \
33+
pnmmargin -white 2 | pnmtile 144 120 | pambackground | cksum
34+
35+
36+
# pamgradient rgb:01/01/01 rgb:ff/7f/00 rgb:00/ff/7f rgb:fe/fe/fe 10 10 | \
37+
# pnmmargin -white 2 | pnmtile 144 120 | cksum
38+
# should produce: 3147800256 51855
39+
# Above input image is a "wall" with 12x10 "windows".
40+
41+
# pnmremap -mapfile ${ibmttl_pam} testimg.ppm | cksum
42+
# should produce : 452672747 101517

test/pamcrater.test

+23-15
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
#! /bin/bash
22
# This script tests: pamcrater pamshadedrelief
3-
# Also requires: pamslice pamvalidate
3+
# Also requires: pamstack pamvalidate pamcut pamflip
44

55
alias pamcrater="${PBM_TESTPREFIX}pamcrater"
6-
alias pamslice="${PBM_TESTPREFIX}pamshadedrelief"
7-
alias pamslice="${PBM_BINPREFIX}pamslice"
8-
alias pamvalidate="${PBM_TESTPREFIX}pamvalidate"
6+
alias pamshadedrelief="${PBM_TESTPREFIX}pamshadedrelief"
7+
alias pamstack="${PBM_BINPREFIX}pamstack"
8+
alias pamvalidate="${PBM_BINPREFIX}pamvalidate"
9+
alias pamcut="${PBM_BINPREFIX}pamcut"
10+
alias pamflip="${PBM_BINPREFIX}pamflip"
11+
912
shopt -s expand_aliases
1013

14+
# We use the undocumented --test and --radius options of pamcrater.
15+
# pamcrater --test --radius=N
16+
# The above draws a single crater of radius N.
17+
# The resulting image should be symmetric.
18+
1119
tmpdir=${tmpdir:-/tmp}
1220

1321
test_pam=${tmpdir}/test.pam
@@ -29,11 +37,11 @@ pamstack ${test10_pam} ${test50_pam} ${test100_pam} ${test150_pam} |
2937

3038
for i in 1 10 70
3139
do
32-
( pamslice -row=$((128 + $i)) ${test_pam} | cksum &&
33-
pamslice -row=$((128 - $i)) ${test_pam} | cksum &&
34-
pamslice -col=$((128 + $i)) ${test_pam} | cksum &&
35-
pamslice -col=$((128 - $i)) ${test_pam} | cksum
36-
) | uniq -c | awk '{print $1}'
40+
( pamcut -top=$((128 + $i)) -height=1 ${test_pam} | cksum &&
41+
pamcut -top=$((128 - $i)) -height=1 ${test_pam} | cksum &&
42+
pamcut -left=$((128 + $i)) -width=1 ${test_pam} | pamflip -xy | cksum &&
43+
pamcut -left=$((128 - $i)) -width=1 ${test_pam} | pamflip -xy | cksum
44+
) | uniq -c | awk '{print $1}'
3745
done
3846

3947
rm ${test_pam} ${test10_pam} ${test50_pam}
@@ -42,12 +50,12 @@ rm ${test_pam} ${test10_pam} ${test50_pam}
4250

4351
pamshadedrelief ${test100_pam} > ${testshaded_pam}
4452

45-
( pamslice -row=$((128 + 12)) ${testshaded_pam} | cksum &&
46-
pamslice -row=$((128 - 12)) ${testshaded_pam} | cksum &&
47-
pamslice -row=$((128 + 31)) ${testshaded_pam} | cksum &&
48-
pamslice -row=$((128 - 31)) ${testshaded_pam} | cksum &&
49-
pamslice -row=$((128 + 99)) ${testshaded_pam} | cksum &&
50-
pamslice -row=$((128 - 99)) ${testshaded_pam} | cksum
53+
( pamcut -top=$((128 + 12)) -height=1 ${testshaded_pam} | cksum &&
54+
pamcut -top=$((128 - 12)) -height=1 ${testshaded_pam} | cksum &&
55+
pamcut -top=$((128 + 31)) -height=1 ${testshaded_pam} | cksum &&
56+
pamcut -top=$((128 - 31)) -height=1 ${testshaded_pam} | cksum &&
57+
pamcut -top=$((128 + 99)) -height=1 ${testshaded_pam} | cksum &&
58+
pamcut -top=$((128 - 99)) -height=1 ${testshaded_pam} | cksum
5159
) | uniq -c | awk '{print $1}'
5260

5361
rm ${testshaded_pam} ${test100_pam}

test/pamenlarge.ok

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
3424505894 913236
22
3763267672 304422
33
3342398172 297
4-
237488670 3133413
4+
398497872 6806

test/pamenlarge.test

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
#! /bin/bash
22
# This script tests: pamenlarge
3-
# Also requires: pamchannel
3+
# Also requires: pamchannel pamseq pamtopnm
44

55
alias pamenlarge="${PBM_TESTPREFIX}pamenlarge"
6+
alias pamchannel="${PBM_TESTPREFIX}pamchannel"
7+
alias pamseq="${PBM_TESTPREFIX}pamseq"
8+
alias pamchannel="${PBM_TESTPREFIX}pamchannel"
69
shopt -s expand_aliases
710

811
# Test 1. Should print 3424505894 913236
@@ -12,5 +15,5 @@ pamchannel -infile=testimg.ppm -tupletype="GRAYSCALE" 0 | pamtopnm | \
1215
pamenlarge 3 | cksum
1316
# Test 3. Should print 3342398172 297
1417
pamenlarge 3 testgrid.pbm | cksum
15-
# Test 4. Should print 237488670 3133413
16-
pamenlarge 3 -plain testimg.ppm | cksum
18+
# Test 4. Should print 398497872 6806
19+
pamseq 3 4 | pamtopnm -assume | pamenlarge 3 -plain | cksum

test/png-roundtrip.test

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
alias pnmtopng="${PBM_TESTPREFIX}pnmtopng"
77
shopt -s expand_aliases
88

9-
## Fails because .ok not set yet.
10-
119
# Test 1. Should print 1926073387 101484 18 times
1210
for flags in "" -interlace \
1311
-gamma=.45 \

test/ppmchange-roundtrip.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ pnminvert | ppmtopgm | \
1313
pgmtopbm -th -val=0.5 | cksum
1414

1515
ppmchange black white white black testgrid.pbm | \
16-
ppmchange black white white black -plain | \
16+
ppmchange black white white black | \
1717
ppmtopgm | pgmtopbm -th -val=0.5 | cksum

test/ppmchange.ok

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
22488533 203
2+
1008787190 613
3+
3885709071 613
4+
2101746192 613

test/ppmchange.test

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#! /bin/bash
2+
# This script tests: ppmchange
3+
# Also requires: ppmrainbow pgmramp
4+
5+
alias ppmchange="${PBM_TESTPREFIX}ppmchange"
6+
alias ppmrainbow="${PBM_BINPREFIX}ppmrainbow"
7+
alias pgmramp="${PBM_BINPREFIX}pgmramp"
8+
shopt -s expand_aliases
9+
10+
# Failure message
11+
## If this test fails and ppmchange-roundtrip.test succeeds,
12+
## the probably cause is a problem with one of the options of
13+
## ppmchange: -closeness or -remainder.
14+
15+
tmpdir=${tmpdir:-/tmp}
16+
rainbow_ppm=${tmpdir}/rainbow.ppm
17+
18+
# Explicit values for intermediate colors: rgb.txt may be defining them
19+
# in unusual ways.
20+
21+
brown=rgb:67/43/00
22+
cyan=rgb:00/ff/ff
23+
yellow=rgb:ff/ff/00
24+
gray=rgb:7f/7f/7f
25+
26+
27+
# Test 1. Should print 811868957 60
28+
pgmramp -lr 8 8 | ppmchange black black white white $gray $gray \
29+
-close=10 -remainder=blue | cksum
30+
31+
32+
# Test 2. Should print 1008787190 613
33+
34+
ppmrainbow -tmpdir=$tmpdir -width=200 -height=1 red green blue | \
35+
tee ${rainbow_ppm} | \
36+
ppmchange red $brown green $brown blue $brown | cksum
37+
38+
39+
# Test 3. Should print 3885709071 613
40+
41+
ppmchange red $brown green $cyan blue $yellow \
42+
-closeness=25 ${rainbow_ppm} | cksum
43+
44+
45+
# Test 4. Should print 2101746192 613
46+
47+
ppmchange red rgb:64/00/01 rgb:00/ff/00 rgb:00/32/02 blue blue \
48+
-remainder=black -closeness=25 ${rainbow_ppm} | cksum
49+
50+
rm ${rainbow_ppm}
51+
52+
53+
# cksum ${rainbow_ppm}
54+
# 1983174784 613 rainbow.ppm
55+
56+
# ppmchange red rgb:64/00/01 rgb:00/ff/00 rgb:00/32/02 blue blue \
57+
# -remainder=black -closeness=25 ${rainbow_ppm} | \
58+
# pphist -sort=rgb -noheader
59+
#
60+
# 0 0 0 0 75
61+
# 0 0 255 29 42
62+
# 0 50 2 30 42
63+
# 100 0 1 30 41

test/ppmmix.test

+3-6
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,9 @@ tmpdir=${tmpdir:-/tmp}
1919
a1_pgm=${tmpdir}/a1.pgm
2020
a2_pgm=${tmpdir}/a2.pgm
2121

22-
pbmmake -g 8 8 | \
23-
pgmtopgm > ${a1_pgm} &&
24-
pbmmake -g 2 2 | pamenlarge 4 | \
25-
pgmtopgm > ${a2_pgm} &&
26-
ppmmix 0.75 ${a1_pgm} ${a2_pgm} -plain | \
27-
ppmtopgm | pamdepth 3 -plain &&
22+
pbmmake -g 8 8 | pgmtopgm > ${a1_pgm} &&
23+
pbmmake -g 2 2 | pamenlarge 4 | pgmtopgm > ${a2_pgm} &&
24+
ppmmix 0.75 ${a1_pgm} ${a2_pgm} | ppmtopgm | pamdepth 3 -plain &&
2825
rm ${a1_pgm} ${a2_pgm}
2926

3027
# Mix image with itself.

test/symmetry.test

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#! /bin/bash
2-
# This script tests: pgmramp pamgauss pgmkernel pbmpscale
2+
# This script tests: pgmramp pamgauss pgmkernel pbmmake pbmpscale
33
# Also requires: pamflip
44

55
alias pgmramp="${PBM_TESTPREFIX}pgmramp"
66
alias pamgauss="${PBM_TESTPREFIX}pamgauss"
77
alias pgmkernel="${PBM_TESTPREFIX}pgmkernel"
8+
alias pbmmake="${PBM_TESTPREFIX}pbmmake"
89
alias pbmpscale="${PBM_TESTPREFIX}pbmpscale"
910
alias pamflip="${PBM_BINPREFIX}pamflip"
1011
shopt -s expand_aliases

0 commit comments

Comments
 (0)