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

# This test requires an iso-8859-1 locale
# Skip this test if it is not available

LANG=C
LC_ALL=C
export LANG LC_ALL

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


locale_to_test="en_US.iso88591"  # Initial value
# Edit the above value if necessary
  
# Make a list of available locales which end in "iso88591"
locale -a | grep "\.iso88591$" > ${iso88591_locale_list}

# Hunt for a valid iso-8859-1 locale  
# Submit each candidate to a trial pbmtext run until one that works is
# encountered

i=0
until [ -z ${locale_to_test} ] || \
  echo "A" | LC_ALL=${locale_to_test} pbmtext -wchar > /dev/null
  do
    let i=$(($i+1));
    locale_to_test=`sed "$i"p -n  ${iso88591_locale_list}`;
  done;

rm ${iso88591_locale_list};
if [ -z  ${locale_to_test} ]
  then echo "No iso-8859-1 locale available." 1>&2
       echo "Skipping." 1>&2
       exit 80;
else
       echo "Testing with locale set to ${locale_to_test}" 1>&2
fi;

locale_for_test=${locale_to_test};


# Two rows
# Should print 2066913605 5110 twice
echo "Test 1"

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

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


# Two rows
# Should print 2858870527 192 twice

echo "Test 2"

awk 'BEGIN { for (i=32; i<=126;++i) printf("%c",i); print ""; \
             for (i=161;i<=255;++i) printf("%c",i); print "" }' | cksum

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