about summary refs log tree commit diff
path: root/test/pnmquantall.test
blob: 4c1bb77f6aa0162edda84322a8bac25ce213fc91 (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
#! /bin/bash
# This script tests: pnmquantall
# Also requires: ppmtorgb3 pgmhist pnmcat

tmpdir=${tmpdir:-/tmp}
test_ppm=${tmpdir}/testimg.ppm

cp testimg.ppm ${tmpdir} &&
ppmtorgb3 ${test_ppm}

test_red=${tmpdir}/testimg.red
test_grn=${tmpdir}/testimg.grn
test_blu=${tmpdir}/testimg.blu

pnmquantall 20 ${test_red} ${test_grn} ${test_blu}

for i in ${test_red} ${test_grn} ${test_blu}
do
cat $i | cksum
done

# Should print 1

pnmcat ${test_red} ${test_grn} ${test_blu} -tb | \
    pgmhist -m | awk '$2>0 {s++}; END { print (s<=20) }'


tmpdir=${tmpdir:-/tmp}
test_out=${tmpdir}/test_out

echo 1>&2
echo "Invalid command-line argument combinations." 1>&2
echo "Error messages should appear below the line." 1>&2
echo "-----------------------------------------------------------" 1>&2

pnmquantall -ext xx 0 ${test_red} ${test_grn} ${test_blu} || \
   echo "Expected failure 1"
rm ${test_red}xx ${test_grn}xx ${test_blu}xx || \
   echo "Expected failure 1.rm"
pnmquantall -ext xx 1 ${test_red} ${test_grn} ${test_blu} || \
   echo "Expected failure 2"
rm ${test_red}xx ${test_grn}xx ${test_blu}xx || \
   echo "Expected failure 2.rm"
pnmquantall -ext xx 2 || \
   echo "Expected failure 3"

rm ${test_red} ${test_grn} ${test_blu} ${test_ppm}