about summary refs log tree commit diff
path: root/test/cut-cat-roundtrip.test
blob: 95ee5279eeff585af7bf1c66d86d7d431c8d088b (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
116
117
118
119
120
121
122
123
124
125
126
127
128
#! /bin/bash
# This script tests: pamcut
# Also requires: pnmcat pnmpad

tmpdir=${tmpdir:-/tmp}
quant_ppm=${tmpdir}/quant.ppm

right_pbm=${tmpdir}/right.pbm
left_pbm=${tmpdir}/left.pbm
right_ppm=${tmpdir}/right.ppm
left_ppm=${tmpdir}/left.ppm
bottom_pbm=${tmpdir}/bottom.pbm
top_pbm=${tmpdir}/top.pbm
bottom_ppm=${tmpdir}/bottom.ppm
top_ppm=${tmpdir}/top.ppm


# Test 1.  Should print 1926073387 101484 six times
echo Test 1.

cat testimg.ppm | cksum
for i in 0 1 128 224 225
  do
  pamcut -left=$((i+1)) testimg.ppm > ${right_ppm}
  pamcut -right=$i      testimg.ppm > ${left_ppm}
  pnmcat -lr ${left_ppm} ${right_ppm} | \
    pamcut -left=0 -width=227| cksum
  rm ${left_ppm} ${right_ppm}
  done


# Test 2.  Should print 3891261972 202953 six times
# Not roundtrip.  Padding added to right.
echo Test 2.

pnmpad -right=227 -black testimg.ppm | cksum
for i in  0 1 128 224 225
  do
  pamcut -left=$((i+1)) -width=227 -pad testimg.ppm > ${right_ppm}
  pamcut -right=$i      -width=227 -pad testimg.ppm > ${left_ppm}
  pnmcat -lr ${left_ppm} ${right_ppm} ${left_ppm} | \
    pamcut -left=$((227-i-1))  -width=$((227*2)) | cksum
  rm ${left_ppm} ${right_ppm}
  done


# Test 3.  Should print 1926073387 101484 five times
echo Test 3.

cat testimg.ppm | cksum
for i in 0 1 70 147
  do
  pamcut -top=$((i+1)) testimg.ppm > ${bottom_ppm}
  pamcut -bottom=$i    testimg.ppm > ${top_ppm}
  pnmcat -tb ${top_ppm} ${bottom_ppm} | \
    pamcut -top=0 -height=149 | cksum
  rm ${top_ppm} ${bottom_ppm}
  done

# Test 4.  Should print 26789469 202953 five times
# Not roundtrip.  Padding added to bottom.
echo Test 4.

pnmpad -bottom=149 -black testimg.ppm | cksum
for i in 0 1 70 147
  do
  pamcut -top=$((i+1)) -height=149 -pad testimg.ppm > ${bottom_ppm}
  pamcut -bottom=$i    -height=149 -pad testimg.ppm > ${top_ppm}
  pnmcat -tb ${top_ppm} ${bottom_ppm} ${top_ppm} | \
    pamcut -top=$((149-i-1))  -height=$((149*2)) | cksum
  rm ${top_ppm} ${bottom_ppm}
  done

# Test 5.  Should print 2425386270 41 fourteen times
echo Test 5.

cat testgrid.pbm | cksum
for i in `seq 0 12`
  do
  pamcut -left=$((i+1)) testgrid.pbm > ${right_pbm}
  pamcut -right=$i      testgrid.pbm > ${left_pbm}
  pnmcat -lr ${left_pbm} ${right_pbm} | \
    pamcut -left=0 -width=14 | cksum
  rm ${left_pbm} ${right_pbm}
  done


# Test 6.  Should print 1887700557 73 fifteen times
# Not roundtrip.  Padding added to right.
echo Test 6.

pnmpad -right=14 -black testgrid.pbm | cksum
for i in `seq 0 13`
  do
  pamcut -left=$((i+1)) -width=14 -pad testgrid.pbm > ${right_pbm}
  pamcut -right=$i      -width=14 -pad testgrid.pbm > ${left_pbm}
  pnmcat -lr ${left_pbm} ${right_pbm} ${left_pbm} | \
    pamcut -left=$((14-i-1)) -width=28 | cksum
  rm ${left_pbm} ${right_pbm}
  done

# Test 7.  Should print 2425386270 41 sixteen times
echo Test 7.

cat testgrid.pbm | cksum
for i in `seq 0 14`
  do
  pamcut -top=$((i+1)) testgrid.pbm > ${bottom_pbm}
  pamcut -bottom=$i    testgrid.pbm > ${top_pbm}
  pnmcat -tb ${top_pbm} ${bottom_pbm} | \
    pamcut -top=0 -height=16 | cksum
  rm ${top_pbm} ${bottom_pbm}
  done

# Test 8.  Should print 3221289196 73 seventeen times
# Not roundtrip.  Padding added to bottom.
echo Test 8.

pnmpad -bottom=16 -black testgrid.pbm | cksum
for i in `seq 0 15`
  do
  pamcut -top=$((i+1)) -height=16 -pad testgrid.pbm > ${bottom_pbm}
  pamcut -bottom=$i    -height=16 -pad testgrid.pbm > ${top_pbm}
  pnmcat -tb ${top_pbm} ${bottom_pbm} ${top_pbm} | \
    pamcut -top=$((16-i-1)) -height=32 | cksum
  rm ${top_pbm} ${bottom_pbm}
  done