about summary refs log tree commit diff
path: root/test/pamrestack.test
blob: c91830e4e7fa3bbe92ab73d9af4c4e08a6465b22 (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
#! /bin/sh
# This script tests: pamrestack
# Also requires: pamfile pamflip pgmramp pnmcrop pnminvert

tmpdir=${tmpdir:-/tmp}
ramp_pgm=${tmpdir}/ramp.pgm
ramp2_pgm=${tmpdir}/ramp2.pgm
maze_singlerow_pbm=${tmpdir}/maze_singlerow.pbm
maze_inverted_pbm=${tmpdir}/maze_inverted.pbm

echo "Test 1."

pgmramp -lr -maxval=7 8 3 | tee ${ramp_pgm} | pamrestack -plain
pamrestack -width=10 -trim=fill -plain ${ramp_pgm}
pamrestack -width=10 -trim=crop -plain ${ramp_pgm}
pamrestack -width=4 -trim=fill -plain ${ramp_pgm}
pamrestack -width=12 -trim=fill -plain ${ramp_pgm}

echo "Test 2.  Should print 0 twelve times"

for width in 2 4 5 8 12 24
do
    pamrestack -width=${width} -trim=crop ${ramp_pgm} > ${ramp2_pgm}
    for flag in "-trim=crop"  "-trim=fill"
    do
    pamrestack -width=${width} ${flag} ${ramp2_pgm} | cmp -s - ${ramp2_pgm}
    echo $?
    done
done

rm ${ramp_pgm} ${ramp2_pgm}

echo "Test 3.  Should produce 3141273448 431 fifteen times"

# Invert maze.pbm because the lower right corner is black

pixels=`pamfile -size maze.pbm | awk '{print $1 * $2}'`

pnminvert maze.pbm | tee ${maze_inverted_pbm} | \
  pamrestack | tee ${maze_singlerow_pbm} | pnmcrop -right -black | cksum
for width in 1 2 3 100 1000 ${pixels} $((pixels -1))
do
pamrestack -width=${width} ${maze_inverted_pbm} | pamrestack | \
  pnmcrop -right -black | cksum
pamrestack -width=${width} ${maze_singlerow_pbm} | \
  pamrestack | pnmcrop -right -black | cksum
done

rm ${maze_inverted_pbm} ${maze_singlerow_pbm}

echo "Test 4. Should produce 1768948962 101484 twice"

pamrestack -width=1 testimg.ppm | pamflip -ccw | cksum
pamrestack \
  -width=`pamfile -size testimg.ppm | cut -d " " -f2` testimg.ppm | \
  pamrestack | cksum

test_out=${tmpdir}/test_out
echo "Test Invalid."

. ${srcdir}/test-invalid.inc

invCmd "pamrestack testgrid.pbm maze.pbm"
invCmd "pamrestack -abort -width=$((pixels * 2 + 1 )) maze.pbm"
invCmd "pamrestack -crop -width=$((pixels * 2 + 1)) maze.pbm"
invCmd "pamrestack -width=0 maze.pbm"
invCmd "pamrestack -width maze.pbm"