about summary refs log tree commit diff
path: root/test/g3-roundtrip.test
blob: f35c4935170f5854b72c0edb6cfe757b8afe220e (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
#! /bin/bash
# This script tests: g3topbm pbmtog3
# Also requires: pamfile pnmcrop pbmmake pbmpage pnmpad pamenlarge

tmpdir=${tmpdir:-/tmp}
complete256_pbm=${tmpdir}/complete256.pbm
widew_pbm=${tmpdir}/widew.pbm
wideb_pbm=${tmpdir}/wideb.pbm
page_pbm=${tmpdir}/page.pbm
pagemax_pbm=${tmpdir}/pagemax.pbm

echo "Test 1.  Should print 0 0 0 : 0 or 0 0 0 0 : 0 total three times"

width=$(pamfile -size maze.pbm | cut -d" " -f1)

pbmtog3 -nofixedwidth maze.pbm | \
g3topbm -width=${width} | cmp -s - maze.pbm
echo ${PIPESTATUS[@]} ":" $?

pbmtog3 -nofixedwidth -reversebits maze.pbm | \
g3topbm -width=${width} -reversebits | cmp -s - maze.pbm
echo ${PIPESTATUS[@]} ":" $?

pbmtog3 maze.pbm | \
g3topbm  | pnmcrop -white -right -bottom | \
 cmp -s - maze.pbm ; echo ${PIPESTATUS[@]} ":" $?


echo "Test 2.  Should print 0 0 0 : 0 or 0 0 0 0 : 0 total seven times"
echo "then 1777627284 265, 2985378006 3135, 3651878552 3135"

# works with gawk and mawk
# produce all possible 8-bit patterns

LC_ALL=C awk 'BEGIN { print "P4";         # header
                      print "8 256";
                      for (i=0;i<256;++i) # raster
                           printf("%c",i) }' > ${complete256_pbm}

pbmtog3 -nofixedwidth  ${complete256_pbm} | g3topbm -width=8 | \
 cmp -s - ${complete256_pbm} ; echo ${PIPESTATUS[@]} ":" $?

pbmtog3 -reverse -nofixedwidth ${complete256_pbm} | \
g3topbm -reversebits -width=8 | \
 cmp -s - ${complete256_pbm} ; echo ${PIPESTATUS[@]} ":" $?

pbmtog3 -align8 ${complete256_pbm} | \
g3topbm -width=1728 | pnmcrop -white -right | \
 cmp -s - ${complete256_pbm} ; echo ${PIPESTATUS[@]} ":" $?

pbmtog3 -align16 ${complete256_pbm} | \
g3topbm -width=1728 | pnmcrop -white -right | \
 cmp -s - ${complete256_pbm} ; echo ${PIPESTATUS[@]} ":" $?

pbmmake -w 5000 5 > ${widew_pbm}
pbmtog3 -nofixedwidth ${widew_pbm} | g3topbm | \
 cmp -s - ${widew_pbm} ; echo ${PIPESTATUS[@]} ":" $?

pbmtog3 -nofixedwidth ${widew_pbm} | \
g3topbm -width=5000 | \
 cmp -s - ${widew_pbm} ; echo ${PIPESTATUS[@]} ":" $?

pbmmake -b 5000 5 > ${wideb_pbm}
pbmtog3 -nofixedwidth ${wideb_pbm} | g3topbm | \
 cmp -s - ${wideb_pbm} ; echo ${PIPESTATUS[@]} ":" $?

cat ${complete256_pbm} | cksum
cat ${wideb_pbm} | cksum
cat ${widew_pbm} | cksum

rm ${complete256_pbm} ${wideb_pbm} ${widew_pbm}


echo "Test 3.  Should print 0 0 0 : 0 twice"
echo "then 356688157 17399694 twice"

pbmpage 3 -a4 | pamenlarge 2 > ${page_pbm}
pbmtog3 -nofixedwidth  ${page_pbm} | g3topbm | \
 cmp -s - ${page_pbm} ; echo ${PIPESTATUS[@]} ":" $?

pnmpad -width=1000 -height=1400 ${page_pbm} > ${pagemax_pbm}
pbmtog3 -nofixedwidth  ${pagemax_pbm} | g3topbm  | \
 cmp -s - ${pagemax_pbm} ; echo ${PIPESTATUS[@]} ":" $?

cat ${page_pbm} | cksum
cat ${pagemax_pbm} | cksum

rm ${page_pbm} ${pagemax_pbm}