about summary refs log tree commit diff
path: root/test/pamflip-roundtrip.test
blob: 6103f6fb0049c20f37a785e85b63bd84385a2731 (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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#! /bin/sh
# This script tests: pamflip
# Also requires: ppmpat pamseq pamtopnm

tmpdir=${tmpdir:-/tmp}
tartan_ppm=${tmpdir}/test.ppm
test1_pgm=${tmpdir}/test1.pgm
test2_pgm=${tmpdir}/test2.pgm
dot_ppm=${tmpdir}/dot.ppm

echo "Test 1.  Should print 1988581932 2989 fifteen times"

ppmpat -tartan -mesh \
       -color=rgb:0/0/0,rgb:ff/00/ff,rgb:80/90/20 31 32 > ${tartan_ppm}

pamflip -null ${tartan_ppm} | cksum
pamflip -lr ${tartan_ppm} | pamflip -lr | cksum
pamflip -tb ${tartan_ppm} | pamflip -tb | cksum
pamflip -r180 ${tartan_ppm} | \
  pamflip -r180 | cksum
pamflip -xy ${tartan_ppm} | pamflip -xy | cksum
pamflip -r90 ${tartan_ppm} | pamflip -r90 | \
  pamflip -r90 | pamflip -r90 | cksum
pamflip -r270 ${tartan_ppm} | pamflip -r270 | \
  pamflip -r270 | pamflip -r270 | cksum
pamflip -xform=leftright ${tartan_ppm} | pamflip -leftright | cksum
pamflip -xform=topbottom ${tartan_ppm} | pamflip -topbottom | cksum
pamflip -xform=transpose ${tartan_ppm} | pamflip -transpose | cksum
pamflip -xform=leftright,leftright ${tartan_ppm} | cksum
pamflip -xform=topbottom,topbottom ${tartan_ppm} | cksum
pamflip -xform=transpose,transpose ${tartan_ppm} | cksum
pamflip -tb ${tartan_ppm} | pamflip -lr | \
  pamflip -xform=leftright,topbottom | cksum
pamflip -tb ${tartan_ppm} | pamflip -lr | pamflip -xy | \
  pamflip -xform=leftright,topbottom,transpose | cksum

rm ${tartan_ppm}

pamseq 1 15 | pamtopnm -assume > ${test1_pgm}

echo "Test 2.  Should print 2729474106 27 nine times"

pamflip -null ${test1_pgm} | cksum
pamflip -lr ${test1_pgm} | pamflip -lr | cksum
pamflip -tb ${test1_pgm} | pamflip -tb | cksum
pamflip -r180 ${test1_pgm} | pamflip -r180 | cksum
pamflip -xy ${test1_pgm} | pamflip -xy | cksum
pamflip -r90 ${test1_pgm} | pamflip -r270 | cksum
pamflip -r270 ${test1_pgm} | pamflip -r90 | cksum
pamflip -r90 ${test1_pgm} | pamflip -r90 | \
  pamflip -r90 | pamflip -r90 | cksum
pamflip -r270 ${test1_pgm} | pamflip -r270 | \
  pamflip -r270 | pamflip -r270 | cksum

pamflip -r180 ${test1_pgm} > ${test2_pgm}
rm ${test1_pgm}

echo "Test 3.  Should print 1849343241 27 nine times"

pamflip -null ${test2_pgm} | cksum
pamflip -lr ${test2_pgm} | pamflip -lr | cksum
pamflip -tb ${test2_pgm} | pamflip -tb | cksum
pamflip -r180 ${test2_pgm} | pamflip -r180 | cksum
pamflip -xy ${test2_pgm} | pamflip -xy | cksum
pamflip -r90 ${test2_pgm} | pamflip -r270 | cksum
pamflip -r270 ${test2_pgm} | pamflip -r90 | cksum
pamflip -r90 ${test2_pgm} | pamflip -r90 | \
    pamflip -r90 | pamflip -r90 | cksum
pamflip -r270 ${test2_pgm} | pamflip -r270 | \
    pamflip -r270 | pamflip -r270 | cksum

rm ${test2_pgm}

cat > ${dot_ppm} <<EOF
P3
1 1
65535
1 10000 65535
EOF

echo "Test 4.  Should print a single pixel PPM image maxval 65535 in "
echo "plain (ascii) format; then print 2434897823 19 fifteen times"

pamflip -null -plain ${dot_ppm}

# These are not round-trip
pamflip -null ${dot_ppm} | cksum
pamflip -lr ${dot_ppm} | cksum
pamflip -tb ${dot_ppm} | cksum
pamflip -xy ${dot_ppm} | cksum
pamflip -r90 ${dot_ppm} | cksum
pamflip -r180 ${dot_ppm} | cksum
pamflip -r270 ${dot_ppm} | cksum

pamflip -lr ${dot_ppm} | pamflip -lr | cksum
pamflip -tb ${dot_ppm} | pamflip -tb | cksum
pamflip -r180 ${dot_ppm} | pamflip -r180 | cksum
pamflip -xy ${dot_ppm} | pamflip -xy | cksum
pamflip -r90 ${dot_ppm} | pamflip -r270 | cksum
pamflip -r270 ${dot_ppm} | pamflip -r90 | cksum
pamflip -r90 ${dot_ppm} | pamflip -r90 | pamflip -r90 | pamflip -r90 | cksum
pamflip -r270 ${dot_ppm} | pamflip -r270 | \
    pamflip -r270 | pamflip -r270 | cksum

rm ${dot_ppm}

echo "Test 5.  Should print 281226646 481 seven times"

pamflip -null maze.pbm | cksum
pamflip -lr maze.pbm | pamflip -lr | cksum
pamflip -tb maze.pbm | pamflip -tb | cksum
pamflip -r180 maze.pbm | pamflip -r180 | cksum
pamflip -xy maze.pbm | pamflip -xy | cksum
pamflip -r90 maze.pbm | pamflip -r90 | pamflip -r90 | pamflip -r90 | cksum
pamflip -r270 maze.pbm | pamflip -r270 | pamflip -r270 | pamflip -r270 | cksum