about summary refs log tree commit diff
path: root/test/symmetry.test
blob: 52ba6388c99605dcac6c47ba70a0b7e833642389 (plain) (blame)
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
93
94
95
96
97
98
99
100
101
#! /bin/bash
# This script tests: pgmramp pamgauss pgmkernel pbmmake pbmpscale
# Also requires: pamflip


# All tests print "ok" upon success, cksum results otherwise.
# The "$3>0" is a kludge for preventing false positives with empty files.

# All test images are square and have the symmetries of the square (Dih4).
# The sole exception is ell.pgm which is a rectangle (Dih2, also called
# "Klein four-group".)

# Example symmetric square PGM image:
# P2
# 5 5
# 6
# 1 2 3 2 1
# 2 4 5 4 2
# 3 5 6 5 3
# 2 4 5 4 2
# 1 2 3 2 1

## Failure with this test indicates that a generator or editor which
## should produce symmetric output images isn't doing so.

tmpdir=${tmpdir:-/tmp}

# Test 1.
rect_pgm=${tmpdir}/rect.pgm

pgmramp -rect 31 31 > ${rect_pgm}

( for op in -null -tb -lr -r90
    do pamflip $op ${rect_pgm} | cksum
    done ) | uniq -c | \
  awk '$1==4 && $3>0 { print "ok"; exit }; { print }'

rm ${rect_pgm}

# Test 2.
circle_pgm=${tmpdir}/circle.pgm
pgmramp -ell 63 63 > ${circle_pgm}

( for op in -null -tb -lr -r90
    do pamflip $op ${circle_pgm} | cksum
    done ) | uniq -c | \
  awk '$1==4 && $3>0 { print "ok"; exit }; { print }'

rm ${circle_pgm}

# Test 3.  Should print "ok" 7 times
gauss_pgm=${tmpdir}/gauss.pgm
for size in 3 4 5 8 13 21 25
do
pamgauss -sigma=0.1 -tupletype=GRAYSCALE $size $size > ${gauss_pgm}

( for op in -null -tb -lr -r90
    do pamflip $op ${gauss_pgm} | cksum
    done ) | uniq -c | \
  awk '$1==4 && $3>0 { print "ok"; exit }; { print }'

rm ${gauss_pgm}
done


# Test 4.
kernel_pgm=${tmpdir}/kernel.pgm
pgmkernel 15 15 > ${kernel_pgm}

( for op in -null -tb -lr -r90
    do pamflip $op ${kernel_pgm} | cksum
    done ) | uniq -c | \
  awk '$1==4 && $3>0 { print "ok"; exit }; { print }'

rm ${kernel_pgm}

# Test 5.
# Should print "ok" 7 times.
pscale_pbm=${tmpdir}/pscale.pbm
for size in `seq 1 7`
do
pbmmake -g 5 5 | pbmpscale $size > ${pscale_pbm}

( for op in -null -tb -lr -r90
    do pamflip $op ${pscale_pbm} | cksum
    done ) | uniq -c | \
  awk '$1==4 && $3>0 { print "ok"; exit }; { print }'

rm ${pscale_pbm}
done

# Test 6.
ell_pgm=${tmpdir}/ell.pgm
pgmramp -ell 101 33 > ${ell_pgm}

( for op in -null -tb -lr
  do pamflip $op ${ell_pgm} | cksum
  done ) | uniq -c | \
  awk '$1==3 && $3>0 { print "ok"; exit }; { print }'

rm ${ell_pgm}