openat: don’t close (-1)
[gnulib.git] / tests / test-xstrtoll.sh
blobb8d235adced4d11adedd5b8447404f07d39fd2e0
1 #!/bin/sh
2 : "${srcdir=.}"
3 . "$srcdir/init.sh"; path_prepend_ .
5 too_big=99999999999999999999999999999999999999999999999999999999999999999999
6 result=0
8 # test xstrtoll
9 ${CHECKER} test-xstrtoll 1 >> out 2>&1 || result=1
10 ${CHECKER} test-xstrtoll -1 >> out 2>&1 || result=1
11 ${CHECKER} test-xstrtoll 1k >> out 2>&1 || result=1
12 ${CHECKER} test-xstrtoll ${too_big}h >> out 2>&1 && result=1
13 ${CHECKER} test-xstrtoll $too_big >> out 2>&1 && result=1
14 ${CHECKER} test-xstrtoll x >> out 2>&1 && result=1
15 ${CHECKER} test-xstrtoll 9x >> out 2>&1 && result=1
16 ${CHECKER} test-xstrtoll 010 >> out 2>&1 || result=1
17 # suffix without integer is valid
18 ${CHECKER} test-xstrtoll MiB >> out 2>&1 || result=1
20 # test xstrtoull
21 ${CHECKER} test-xstrtoull 1 >> out 2>&1 || result=1
22 ${CHECKER} test-xstrtoull -1 >> out 2>&1 && result=1
23 ${CHECKER} test-xstrtoull 1k >> out 2>&1 || result=1
24 ${CHECKER} test-xstrtoull ${too_big}h >> out 2>&1 && result=1
25 ${CHECKER} test-xstrtoull $too_big >> out 2>&1 && result=1
26 ${CHECKER} test-xstrtoull x >> out 2>&1 && result=1
27 ${CHECKER} test-xstrtoull 9x >> out 2>&1 && result=1
28 ${CHECKER} test-xstrtoull 010 >> out 2>&1 || result=1
29 ${CHECKER} test-xstrtoull MiB >> out 2>&1 || result=1
31 # Find out how to remove carriage returns from output. Solaris /usr/ucb/tr
32 # does not understand '\r'.
33 if echo solaris | tr -d '\r' | grep solais > /dev/null; then
34 cr='\015'
35 else
36 cr='\r'
39 # normalize output
40 LC_ALL=C tr -d "$cr" < out > k
41 mv k out
43 # compare expected output
44 cat > expected <<EOF
45 1->1 ()
46 -1->-1 ()
47 1k->1024 ()
48 invalid suffix in X argument '${too_big}h'
49 X argument '$too_big' too large
50 invalid X argument 'x'
51 invalid suffix in X argument '9x'
52 010->8 ()
53 MiB->1048576 ()
54 1->1 ()
55 invalid X argument '-1'
56 1k->1024 ()
57 invalid suffix in X argument '${too_big}h'
58 X argument '$too_big' too large
59 invalid X argument 'x'
60 invalid suffix in X argument '9x'
61 010->8 ()
62 MiB->1048576 ()
63 EOF
65 compare expected out || result=1
67 # Other misc tests.
68 ${CHECKER} test-xstrtoll || result=1
70 Exit $result