about summary refs log tree commit diff
path: root/test/pbmclean.test
blob: 5eba68e04d2a36bb835c57d88212762124690bd6 (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
#! /bin/sh
# This script tests: pbmclean
# Also requires: pbmmake pbmpage pbmtext pnmmargin pnmpad


tmpdir=${tmpdir:-/tmp}
test_pbm=${tmpdir}/test.pbm
sheet_pbm=${tmpdir}/sheet.pbm

echo "Test 1"

pbmmake -g 3 3 | pnmmargin -black 2 > ${test_pbm}

for n in 1 2 3 4 5 6 7 8
  do
  pbmclean -min=${n} -black -plain ${test_pbm}
  done

rm ${test_pbm}


echo "Test 2"

# Should print 760076056 4210813
pbmpage 1 | pbmclean -black | cksum


echo "Test 3"

pbmtext -dump-sheet > ${sheet_pbm}
for n in 1 2 3 4 5 6 7 8 9 10
  do
  pbmclean -min=${n} -extended  ${sheet_pbm} | cksum
  done

rm ${sheet_pbm}

echo "Test Invalid"

test_out=${tmpdir}/test_out

echo 1>&2
echo "Invalid command-line argument combination." 1>&2
echo "An error message should appear below the line." 1>&2
echo "-----------------------------------------------------------" 1>&2

# overspecification
pbmclean -black -white -min=1 -extended testgrid.pbm > ${test_out} || \
  printf "Expected failure 1"
  test -s ${test_out}; echo " "$?
  rm -f ${test_out}

# note that without -extended the above is valid.