Cap sillyness. Closes: #570815
[moreutils.git] / check-isutf8
blob83a4eed00f82e3bcc81856149b47cffc4091f9aa
1 #!/bin/bash
2 # Bash needed for the character encodings below.
4 # Run checks for ./isutf8.
6 # Lars Wirzenius <liw@iki.fi>
8 failed=0
10 check() {
11 printf "$2" | ./isutf8 -q
12 ret=$?
13 if [ $ret != $1 ]; then
14 echo "Failure:"
15 echo " input: $2"
16 echo " expected: $1"
17 echo " got: $ret"
18 failed=1
20 printf "$2" > check-isutf8.tmp.$$
21 ./isutf8 -q check-isutf8.tmp.$$
22 ret=$?
23 rm -f check-isutf8.tmp.$$
24 if [ $ret != $1 ]; then
25 echo "Failure (from file):"
26 echo " input: $2"
27 echo " expected: $1"
28 echo " got: $ret"
29 failed=1
33 check 0 ''
34 check 0 'a'
35 check 0 'ab'
36 check 0 '\xc2\xa9'
38 check 1 '\xc2'
39 check 1 '\xc2\x20'
40 check 1 '\x20\xc2'
41 check 1 '\300\200'
42 check 1 '\xed\xa0\x88\xed\xbd\x85' # UTF-16 surrogates
43 check 1 '\xef\xbf\xbe' # 0xFFFE
44 check 1 '\xef\xbf\xbf' # 0xFFFF
46 exit $failed