about summary refs log tree commit diff
path: root/test/pbmtext.test
blob: 0a177270e4118357b9b790f8e81b72f06016d8dc (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
#! /bin/bash
# This script tests: pbmtext
# Also requires: pamfile

tmpdir=${tmpdir:-/tmp}

# Test 1:

pbmtext UNIX Philosophy: Do one thing and do it well. | cksum
echo -n "UNIX Philosophy: Do one thing and do it well." | pbmtext | cksum

pbmtext -builtin fixed \
    For truth is always strange. Stranger than fiction. Lord Byron | cksum
echo -n "For truth is always strange. Stranger than fiction. Lord Byron" | \
    pbmtext -builtin fixed | cksum


text="The quick brown fog jumps over the lazy docs."

# Test 2:

for flags in "" "-nom" "-builtin fixed"
do
echo $text | pbmtext $flags | cksum
done

temp_pbm=${tmpdir}/temp.pbm


# Test 3: Check if image is produced unaltered when -width is specified
# Should print 1028079028 967 twice, then 1305436978 1018 twice

for flags in "" "-builtin fixed"
do
pbmtext ${flags} ${text} | tee ${temp_pbm} | cksum
width=`pamfile ${temp_pbm} | awk '$2=="PBM" && NR==1 { w=$4}; END {print w}' `
pbmtext ${flags} -width=$width $text | cksum
rm ${temp_pbm}
done


# Test 3: Should print 1647614653 2027 twice
# Note: backslashes inserted in 3 locations in the rectange to make
# possible input as a here document.

fontRectangle_txt=${tmpdir}/fontRectangle.txt
font_pbm=${tmpdir}/font.pbm

cat > ${fontRectangle_txt} << EOF
M ",/^_[\`jpqy| M

/  !"#$%&'()*+ /
< ,-./01234567 <
> 89:;<=>?@ABC >
@ DEFGHIJKLMNO @
_ PQRSTUVWXYZ[ _
{ \\]^_\`abcdefg {
} hijklmnopqrs }
~ tuvwxyz{|}~  ~

M ",/^_[\`jpqy| M
EOF

cat ${fontRectangle_txt} | pbmtext -nom -builtin fixed | tee ${font_pbm} | \
cksum
cat ${fontRectangle_txt} | pbmtext -nom -font ${font_pbm} | cksum

rm ${fontRectangle_txt} ${font_pbm}