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
|
#! /bin/sh
# This script tests: pamarith
# Also requires: ppmpat pnminvert pamfile pbmmake pgmmake pamcut
tmpdir=${tmpdir:-/tmp}
input1_ppm=${tmpdir}/input1.ppm
inputm_ppm=${tmpdir}/inputm.ppm
input2_ppm=${tmpdir}/input2.ppm
echo "Test 1"
ppmpat -tartan -color=rgb:00/80/ff,rgb:80/ff/00,rgb:ff/00/80 \
8 8 > ${input1_ppm}
ppmpat -tartan -color=rgb:00/80/ff,rgb:80/ff/00,rgb:ff/00/80 \
-mesh 8 8 > ${inputm_ppm}
ppmpat -tartan -color=rgb:80/ff/00,rgb:ff/00/80,rgb:00/80/ff \
8 8 > ${input2_ppm}
pamarith -compare -plain ${input1_ppm} ${input1_ppm} | \
uniq -c | sed -e 's/^ *//' -e 's/ /:/'
pamarith -compare -plain ${input1_ppm} ${inputm_ppm} | \
uniq -c | sed -e 's/^ *//' -e 's/ /:/'
pamarith -compare -plain ${input1_ppm} ${input2_ppm} | \
uniq -c | sed -e 's/^ *//' -e 's/ /:/'
echo "Test 2"
pamarith -equal -plain ${input1_ppm} ${input1_ppm} | \
uniq -c | sed -e 's/^ *//' -e 's/ /:/'
pamarith -equal -plain ${input1_ppm} ${inputm_ppm} | \
uniq -c | sed -e 's/^ *//' -e 's/ /:/'
pamarith -equal -plain ${input1_ppm} ${input2_ppm} | \
uniq -c | sed -e 's/^ *//' -e 's/ /:/'
rm ${input1_ppm} ${inputm_ppm} ${input2_ppm}
echo "Test 3"
input3_pbm=${tmpdir}/input3.pbm
pamcut maze.pbm -left=0 -top=0 -width=35 -height=33 > ${input3_pbm}
pamarith -equal -plain ${input3_pbm} ${input3_pbm} | \
uniq -c | sed -e 's/^ *//' -e 's/ /:/'
pnminvert ${input3_pbm} | pamarith -equal -plain ${input3_pbm} - | \
uniq -c | sed -e 's/^ *//' -e 's/ /:/'
xysize=$(pamfile -size testgrid.pbm)
pbmmake -w ${xysize} | pamarith -equal -plain testgrid.pbm - | \
awk '{printf("%s%c",$0, NR<3 || NR%2==0 ? "\n" : " ")}' |
uniq -c | sed -e 's/^ *//' -e 's/ /:/'
pbmmake -b ${xysize} | pamarith -equal -plain testgrid.pbm - | \
awk '{printf("%s%c",$0, NR<3 || NR%2==0 ? "\n" : " ")}' |
uniq -c | sed -e 's/^ *//' -e 's/ /:/'
echo "Test 4"
pamarith -compare -plain ${input3_pbm} ${input3_pbm} | \
uniq -c | sed -e 's/^ *//' -e 's/ /:/'
pnminvert testgrid.pbm | pamarith -compare -plain testgrid.pbm - | \
awk '{printf("%s%c",$0, NR<4 || NR%2==1 ? "\n" : " ")}' |
uniq -c | sed -e 's/^ *//' -e 's/ /:/'
pbmmake -w ${xysize} | pamarith -compare -plain testgrid.pbm - | \
awk '{printf("%s%c",$0, NR<4 || NR%2==1 ? "\n" : " ")}' |
uniq -c | sed -e 's/^ *//' -e 's/ /:/'
pbmmake -b ${xysize} | pamarith -compare -plain testgrid.pbm - | \
awk '{printf("%s%c",$0, NR<4 || NR%2==1 ? "\n" : " ")}' |
uniq -c | sed -e 's/^ *//' -e 's/ /:/'
rm ${input3_pbm}
echo "Test 5"
# -closeness
input40_pgm=${tmpdir}/input40.pgm
input50_pgm=${tmpdir}/input50.pgm
pgmmake -maxval=99 0.40 7 3 > ${input40_pgm}
pgmmake -maxval=99 0.50 7 3 > ${input50_pgm}
echo "Should produce 1285449498 54 four times"
pamarith -equal -plain ${input40_pgm} ${input40_pgm} | cksum
pamarith -equal -plain -closeness=10.2 ${input40_pgm} ${input50_pgm} | cksum
pamarith -equal -plain -closeness=11 ${input40_pgm} ${input50_pgm} | cksum
pamarith -equal -plain -closeness=90 ${input40_pgm} ${input50_pgm} | cksum
echo "Should produce 244506188 54 twice"
pamarith -equal -plain ${input40_pgm} ${input50_pgm} | cksum
pamarith -equal -plain -closeness=09 ${input40_pgm} ${input50_pgm} | cksum
rm ${input40_pgm} ${input50_pgm}
|