Skip to content

Commit 1e58c15

Browse files
author
giraffedata
committed
Add tests
git-svn-id: https://svn.code.sf.net/p/netpbm/code/trunk@3854 9d0c8265-081b-0410-96cb-a4ca84ce46f8
1 parent 70b5a42 commit 1e58c15

19 files changed

+422
-27
lines changed

test/Test-Order

+9
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,16 @@ pamtopdbimg.test
120120
pbmtog3.test
121121
411toppm.test
122122
eyuvtoppm.test
123+
rawtoppm.test
123124

124125
pbm-misc-converters.test
125126

126127
# Miscellaneous utility tests
127128

128129
ppmdfont.test
130+
pamfix.test
131+
pamvalidate.test
132+
pamexec.test
129133

130134
# Round-trip tests : editors
131135

@@ -145,6 +149,10 @@ enlarge-reduce-roundtrip.test
145149
cut-cat-roundtrip.test
146150
pamhue-roundtrip.test
147151

152+
# Round-trip tests: miscellaneous utility
153+
154+
pamexec-roundtrip.test
155+
148156
# Round-trip tests : lossless converters
149157

150158
ppmtoarbtxt-roundtrip.test
@@ -179,6 +187,7 @@ pi3-roundtrip.test
179187
pict-roundtrip.test
180188
png-roundtrip.test
181189
png-roundtrip2.test
190+
pj-roundtrip.test
182191
ps-roundtrip.test
183192
ps-flate-roundtrip.test
184193
ps-alt-roundtrip.test

test/pamendian-roundtrip.ok

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Test 1: Should print '0 0 0 : 0'
2+
0 0 0 : 0
3+
Test 2 should print echo '0 0 0 0 0 : 0'
4+
0 0 0 0 0 : 0

test/pamendian-roundtrip.test

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#! /bin/bash
2+
# This script tests: pamendian
3+
# Also requires: pamdepth pgmtopbm pamseq
4+
5+
echo "Test 1: Should print '0 0 0 : 0'"
6+
7+
tmpdir=${tmpdir:-/tmp}
8+
test0_pam=${tmpdir}/test0.pam
9+
10+
pamseq 1 65535 > ${test0_pam}
11+
pamendian < ${test0_pam} | pamendian |\
12+
cmp -s ${test0_pam} -
13+
echo ${PIPESTATUS[@]} ":" $?
14+
15+
rm ${test0_pam}
16+
17+
18+
echo "Test 2 should print echo '0 0 0 0 0 : 0'"
19+
20+
pamdepth 65535 testgrid.pbm | pamendian | pamendian | \
21+
pgmtopbm -th -val=0.5 | cmp -s - testgrid.pbm
22+
echo ${PIPESTATUS[@]} ":" $?

test/pamexec-roundtrip.ok

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Test 1: should print stdin: PPM RAW 17 22 3 255 RGB six times
2+
stdin: PPM RAW 17 22 3 255 RGB
3+
stdin: PPM RAW 17 22 3 255 RGB
4+
stdin: PPM RAW 17 22 3 255 RGB
5+
stdin: PPM RAW 17 22 3 255 RGB
6+
stdin: PPM RAW 17 22 3 255 RGB
7+
stdin: PPM RAW 17 22 3 255 RGB
8+
Test 2: should print '0 0 : 0' twice
9+
0 0 : 0
10+
0 0 : 0

test/pamexec-roundtrip.test

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#! /bin/bash
2+
# This script tests: pamexec
3+
# Also requires: ppmpat ppmmake pamfile
4+
5+
tmpdir=${tmpdir:-/tmp}
6+
test_ppm=${tmpdir}/test_ppm
7+
8+
echo "Test 1: should print stdin: PPM RAW 17 22 3 255 RGB six times"
9+
10+
( ppmmake rgb:0/255/127 17 22
11+
ppmpat -g2 --color=rgb:143/188/143,rgb:161/161/161 17 22
12+
ppmpat -g3 --color=rgb:224/255/255,rgb:255/130/171,rgb:255/48/48 17 22
13+
ppmpat -madras --color=rgb:181/181/181,rgb:51/62/99,rgb:205/193/197 17 22
14+
ppmpat -tartan --color=rgb:238/233/191,rgb:84/84/84,rgb:255/160/122 17 22
15+
ppmpat -argyle2 --color=rgb:205/104/57,rgb:119/136/153,rgb:255/255/255 17 22
16+
) | tee ${test_ppm} | pamfile -all -machine
17+
18+
echo "Test 2: should print '0 0 : 0' twice"
19+
20+
pamexec "ppmtoppm " ${test_ppm} | cmp -s ${test_ppm} -
21+
echo ${PIPESTATUS[@]} ":" $?
22+
pamexec "cat " ${test_ppm} | cmp -s ${test_ppm} -
23+
echo ${PIPESTATUS[@]} ":" $?
24+
25+
rm ${test_ppm}

test/pamexec.ok

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Test 1 : Should print 10 stdin: PBM RAW 21 24 1 1 BLACKANDWHITE twice
2+
10 stdin: PBM RAW 21 24 1 1 BLACKANDWHITE
3+
10 stdin: PBM RAW 21 24 1 1 BLACKANDWHITE
4+
Test 2: Should print 1791121103 989 twice
5+
1791121103 989
6+
1791121103 989
7+
Test 3: Should print 2983705297 810 twice
8+
2983705297 810
9+
2983705297 810
10+
Test Invalid: Should not print anything

test/pamexec.test

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#! /bin/bash
2+
# This script tests: pamexec
3+
# Also requires: pbmtext pamfile pbmminkowski pbmtog3 g3topbm
4+
5+
tmpdir=${tmpdir:-/tmp}
6+
test_pbm=${tmpdir}/test.pbm
7+
combined_pbm=${tmpdir}/combined.pbm
8+
9+
for i in `seq 0 9`; do echo $i | pbmtext -builtin=fixed > ${test_pbm}$i; done
10+
cat ${test_pbm}[0123456789] > ${combined_pbm}
11+
12+
echo "Test 1 : Should print 10 stdin: PBM RAW 21 24 1 1 BLACKANDWHITE twice"
13+
14+
cat ${combined_pbm} | pamfile -all -mach | uniq -c
15+
pamexec "pamfile -mach" ${combined_pbm} | uniq -c
16+
17+
echo "Test 2: Should print 1791121103 989 twice"
18+
19+
for i in `seq 0 9`; do pbmminkowski ${test_pbm}$i ; done | cksum
20+
pamexec "pbmminkowski" ${combined_pbm} | cksum
21+
22+
rm ${test_pbm}[0123456789]
23+
24+
echo "Test 3: Should print 2983705297 810 twice"
25+
26+
pamexec "pbmtog3 -no | g3topbm" ${combined_pbm} | cksum
27+
cat ${combined_pbm} | cksum
28+
29+
echo "Invalid command" 1>&2
30+
echo "Errors message should appear below the line." 1>&2
31+
echo "-----------------------------------------------------------" 1>&2
32+
33+
echo "Test Invalid: Should not print anything"
34+
35+
pamexec "false" ${combined_pbm}
36+
pamexec "pamfile | false" ${combined_pbm}
37+
38+
rm ${combined_pbm}

test/pamfix.ok

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
Test 1
2+
P1
3+
5 5
4+
01010
5+
10101
6+
01010
7+
10101
8+
01010
9+
P1
10+
5 4
11+
01010
12+
10101
13+
01010
14+
00001
15+
P1
16+
5 4
17+
01010
18+
10101
19+
01010
20+
00001
21+
P1
22+
5 1
23+
01010
24+
Test 2
25+
P2
26+
3 3
27+
7
28+
0 1 2
29+
3 4 5
30+
6 7 0
31+
P2
32+
3 2
33+
7
34+
0 1 2
35+
3 4 5
36+
P2
37+
3 2
38+
7
39+
0 1 2
40+
3 4 5
41+
P2
42+
3 3
43+
8
44+
0 1 2
45+
3 4 5
46+
6 7 8
47+
P2
48+
3 3
49+
7
50+
0 1 2
51+
3 4 5
52+
6 7 7
53+
P2
54+
3 3
55+
8
56+
0 1 2
57+
3 4 8
58+
0 0 0
59+
P2
60+
3 3
61+
7
62+
0 1 2
63+
3 4 7
64+
0 0 0
65+
Test invalid
66+
Expected failure 1 1
67+
Expected failure 2 1
68+
Expected failure 3 1

test/pamfix.test

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#! /bin/bash
2+
# This script tests: pamfix
3+
# Also requires:
4+
5+
# Test 1.
6+
echo "Test 1"
7+
8+
pbmmake -g 5 5 | pamfix -truncate -plain
9+
10+
echo -e "P1\n5 5\n01010\n10101\n01010\n00001\n1" |\
11+
pamfix -truncate -plain
12+
13+
echo -e "P1\n5 5\n01010\n10101\n01010\n0000\n1" |\
14+
pamfix -truncate -plain
15+
16+
echo -e "P1\n5 5\n01010\n10102\n01010\n00001\n1" |\
17+
pamfix -truncate -plain
18+
19+
# Test 2
20+
21+
echo "Test 2"
22+
23+
echo -e "P2\n3 3\n7\n0 1 2\n3 4 5\n6 7 0" |\
24+
pamfix -truncate -plain
25+
26+
echo -e "P2\n3 3\n7\n0 1 2\n3 4 5\n6 7" |\
27+
pamfix -truncate -plain
28+
echo -e "P2\n3 3\n7\n0 1 2\n3 4 5\n6 7 8" |\
29+
pamfix -truncate -plain
30+
31+
echo -e "P2\n3 3\n7\n0 1 2\n3 4 5\n6 7 8" |\
32+
pamfix -change -plain
33+
34+
echo -e "P2\n3 3\n7\n0 1 2\n3 4 5\n6 7 8" |\
35+
pamfix -clip -plain
36+
37+
echo -e "P2\n3 3\n7\n0 1 2\n3 4 8\n0 0 0" |\
38+
pamfix -change -truncate -plain
39+
40+
echo -e "P2\n3 3\n7\n0 1 2\n3 4 8\n0 0 0" |\
41+
pamfix -clip -truncate -plain
42+
43+
# Test Invalid
44+
45+
echo "Test invalid"
46+
47+
test_out=${tmpdir}/test_out
48+
49+
echo 1>&2
50+
echo "Invalid command-line combination, invalid input" 1>&2
51+
echo "Error messages should appear below the line." 1>&2
52+
echo "-----------------------------------------------------------" 1>&2
53+
54+
echo -e "P2\n3 2\n7\n0 1 2\n6 7 8" | pamfix -change -clip > ${test_out} || \
55+
echo -n "Expected failure 1";
56+
test -s ${test_out}; echo " "$?
57+
58+
echo -e "P1\n5 5" | pamfix -truncate -plain > ${test_out} || \
59+
echo -n "Expected failure 2";
60+
test -s ${test_out}; echo " "$?
61+
62+
echo -e "P2\n3 3\255" | pamfix -truncate -plain > ${test_out} || \
63+
echo -n "Expected failure 3";
64+
test -s ${test_out}; echo " "$?
65+
66+
rm ${test_out}

test/pamvalidate.ok

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
valid
2+
P1
3+
5 5
4+
01010
5+
10101
6+
01010
7+
00000
8+
11111
9+
not valid: Should print 0 four times
10+
0
11+
0
12+
0
13+
0

test/pamvalidate.test

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#! /bin/bash
2+
# This script tests: pamvalidate
3+
# Also requires:
4+
5+
echo "valid"
6+
echo -e "P1\n5 5\n01010\n10101\n01010\n00000\n11111\n" | pamvalidate -plain
7+
8+
echo "not valid: Should print 0 four times"
9+
echo -e "P1\n5 5\n01010\n10101\n01010\n00000\n1111\n" | pamvalidate | wc -c
10+
11+
echo -e "P1\n5 5\n01010\n10102\n01010\n00001\n11111\n" | pamvalidate | wc -c
12+
13+
echo -e "P1\n5\n01010\n10101\n01010\n00000\n11111\n" | pamvalidate | wc -c
14+
15+
echo -e "P1\n5 5" | pamvalidate | wc -c
16+
17+

test/pbmtext-iso88591.ok

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Test 1
2-
3806607098 5110
3-
3806607098 5110
2+
2066913605 5110
3+
2066913605 5110
44
Test 2
55
2858870527 192
66
2858870527 192

test/pbmtext-iso88591.test

+5-13
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,13 @@
22
# This script tests: pbmtext
33
# Also requires:
44

5-
# This test requires the iconv command and an iso-8859-1 locale
6-
# Skip this test if they are not available
5+
# This test requires an iso-8859-1 locale
6+
# Skip this test if it is not available
77

88
LANG=C
99
LC_ALL=C
1010
export LANG LC_ALL
1111

12-
iconv /dev/null
13-
if [ $? -ne 0 ]
14-
then echo "iconv command not available." 1>&2
15-
echo "Skipping." 1>&2
16-
exit 80;
17-
fi
18-
1912
tmpdir=${tmpdir:-/tmp}
2013
iso88591_locale_list=${tmpdir}/iso88591_locale_list
2114

@@ -51,16 +44,15 @@ locale_for_test=${locale_to_test};
5144

5245

5346
# Two rows
54-
# Should print 3806607098 5110 twice
55-
47+
# Should print 2066913605 5110 twice
5648
echo "Test 1"
5749

5850
awk 'BEGIN { for (i=32; i<=126;++i) printf("%c",i); print ""; \
59-
for (i=160;i<=255;++i) printf("%c",i); }' | \
51+
for (i=161;i<=255;++i) printf("%c",i); }' | \
6052
pbmtext -builtin bdf | cksum
6153

6254
awk 'BEGIN { for (i=32; i<=126;++i) printf("%c",i); print ""; \
63-
for (i=160;i<=255;++i) printf("%c",i); }' | \
55+
for (i=161;i<=255;++i) printf("%c",i); }' | \
6456
LC_ALL=${locale_for_test} pbmtext -builtin bdf -wchar | cksum
6557

6658

test/pbmtext-utf8.ok

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Test 2
55
2920616515 2301
66
2920616515 2301
77
Test 3
8-
0 0 0 0 : 0
8+
0 0 0 : 0
99
Test 4
1010
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
1111
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~

0 commit comments

Comments
 (0)