about summary refs log tree commit diff
path: root/test/pgmtoppm.test
blob: d98418b8f35f4bd3fb9b470723890b21c82527a9 (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
129
130
131
132
133
134
135
136
137
138
139
#! /bin/sh
# This script tests: pgmtoppm
# Also requires: pamtopnm pnminvert pamseq pgmramp

tmpdir=${tmpdir:-/tmp}

echo "Test 1.  Should print 1767073524 779 twice, then 1676700883 779"

test_pgm=${tmpdir}/test.pgm
palette_pam=${tmpdir}/palette.pam
palette_ppm=${tmpdir}/palette.ppm

pgmramp -maxval=5 -lr 256 1 > ${test_pgm}

pgmtoppm green ${test_pgm} | cksum
pgmtoppm black-green ${test_pgm} | cksum
pgmtoppm yellow-blue ${test_pgm} | cksum


echo "Test 2.  Should print 718580145 779 twice"
pamseq 3 5 -tupletype=RGB | tee ${palette_pam} | pamtopnm > ${palette_ppm}
pgmtoppm -map=${palette_pam} ${test_pgm} | cksum
pgmtoppm -map=${palette_ppm} ${test_pgm} | cksum

rm ${palette_pam}

echo "Test 3.  Should print 718580145 779 twice"

pgmtoppm white-black ${test_pgm} | pnminvert | cksum
pnminvert ${test_pgm} | pgmtoppm white-black | cksum

rm ${test_pgm}

echo "Test 4.  Should print 829921912 685 seven times"

pgmtoppm white testgrid.pbm | cksum
pgmtoppm black-white testgrid.pbm | cksum
pgmtoppm rgb:ff/ff/ff testgrid.pbm | cksum
pgmtoppm -white=rgb-255:255/255/255 testgrid.pbm | cksum
pgmtoppm rgb:00/00/00-rgb:ff/ff/ff testgrid.pbm | cksum
pgmtoppm rgbi:0/0/0-rgbi:1/1/1 testgrid.pbm | cksum
pgmtoppm -black=rgb-255:0/0/0 -white=rgb-255:255/255/255 testgrid.pbm | cksum

echo "Test 5.  Should print 934505096 685 four times"

pgmtoppm white-black testgrid.pbm | cksum
pgmtoppm white testgrid.pbm | pnminvert| cksum
pnminvert testgrid.pbm | pgmtoppm black-white | cksum
pnminvert testgrid.pbm | pgmtoppm white | cksum

echo "Test 6. Should print 3083028153 685 three times"

pgmtoppm black testgrid.pbm | cksum
pgmtoppm black-black testgrid.pbm | cksum
pgmtoppm rgbi:0/0/0-rgbi:0/0/0 testgrid.pbm | cksum

echo "Test 7 Invalid"

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

pgmtoppm white testimg.ppm > \
  ${test_out} || \
  echo -n "Expected failure 1"
  test -s ${test_out}; echo " "$?
  rm -f ${test_out}

pgmtoppm -map=/dev/null testgrid.pbm > \
  ${test_out} || \
  echo -n "Expected failure 2"
  test -s ${test_out}; echo " "$?
  rm -f ${test_out}

pgmtoppm black white testgrid.pbm > \
  ${test_out} || \
  echo -n "Expected failure 3"
  test -s ${test_out}; echo " "$?
  rm -f ${test_out}

pgmtoppm hwite testgrid.pbm > \
  ${test_out} || \
  echo -n "Expected failure 4"
  test -s ${test_out}; echo " "$?
  rm -f ${test_out}

pgmtoppm off-color testgrid.pbm > \
  ${test_out} || \
  echo -n "Expected failure 5"
  test -s ${test_out}; echo " "$?
  rm -f ${test_out}

pgmtoppm rgb-255:7/7/7 testgrid.pbm > \
  ${test_out} || \
  echo -n "Expected failure 6"
  test -s ${test_out}; echo " "$?
  rm -f ${test_out}

pgmtoppm -black=black -white=white white testgrid.pbm > \
  ${test_out} || \
  echo -n "Expected failure 7"
  test -s ${test_out}; echo " "$?
  rm -f ${test_out}

pgmtoppm -black=rgb:0/0/0 -map=${palette_ppm} testgrid.pbm > \
  ${test_out} || \
  echo -n "Expected failure 8"
  test -s ${test_out}; echo " "$?
  rm -f ${test_out}

pgmtoppm -white=rgb:ff/ff/ff -map=${palette_ppm} testgrid.pbm > \
  ${test_out} || \
  echo -n "Expected failure 9"
  test -s ${test_out}; echo " "$?
  rm -f ${test_out}

pgmtoppm rgb:ff/ff/ff -map=${palette_ppm} testgrid.pbm > \
  ${test_out} || \
  echo -n "Expected failure 10"
  test -s ${test_out}; echo " "$?
  rm -f ${test_out}

pgmtoppm rgb:00/00/00-rgb:ff/ff/ff -map=${palette_ppm} testgrid.pbm > \
  ${test_out} || \
  echo -n "Expected failure 11"
  test -s ${test_out}; echo " "$?
  rm -f ${test_out}

#pgmtoppm rgb-255:7/7/7 testgrid.pbm > \
#  ${test_out} || \
#  echo -n "Expected failure 12"
#  test -s ${test_out}; echo " "$?
#  rm -f ${test_out}

rm -f ${palette_ppm}