getloadavg: Remove support for Sony NEWS.
[gnulib.git] / tests / test-xstrtol.sh
blob5425bc79dc2a95cfebb119ecc9762306e10a4fef
1 #!/bin/sh
2 : ${srcdir=.}
3 . "$srcdir/init.sh"; path_prepend_ .
5 too_big=99999999999999999999999999999999999999999999999999999999999999999999
6 result=0
8 # test xstrtol
9 test-xstrtol 1 >> out 2>&1 || result=1
10 test-xstrtol -1 >> out 2>&1 || result=1
11 test-xstrtol 1k >> out 2>&1 || result=1
12 test-xstrtol ${too_big}h >> out 2>&1 && result=1
13 test-xstrtol $too_big >> out 2>&1 && result=1
14 test-xstrtol x >> out 2>&1 && result=1
15 test-xstrtol 9x >> out 2>&1 && result=1
16 test-xstrtol 010 >> out 2>&1 || result=1
17 # suffix without integer is valid
18 test-xstrtol MiB >> out 2>&1 || result=1
19 test-xstrtol 1bB >> out 2>&1 && result=1
21 # test xstrtoul
22 test-xstrtoul 1 >> out 2>&1 || result=1
23 test-xstrtoul -1 >> out 2>&1 && result=1
24 test-xstrtoul 1k >> out 2>&1 || result=1
25 test-xstrtoul ${too_big}h >> out 2>&1 && result=1
26 test-xstrtoul $too_big >> out 2>&1 && result=1
27 test-xstrtoul x >> out 2>&1 && result=1
28 test-xstrtoul 9x >> out 2>&1 && result=1
29 test-xstrtoul 010 >> out 2>&1 || result=1
30 test-xstrtoul MiB >> out 2>&1 || result=1
31 test-xstrtoul 1bB >> out 2>&1 && result=1
33 # Find out how to remove carriage returns from output. Solaris /usr/ucb/tr
34 # does not understand '\r'.
35 if echo solaris | tr -d '\r' | grep solais > /dev/null; then
36 cr='\015'
37 else
38 cr='\r'
41 # normalize output
42 LC_ALL=C tr -d "$cr" < out > k
43 mv k out
45 # compare expected output
46 cat > expected <<EOF
47 1->1 ()
48 -1->-1 ()
49 1k->1024 ()
50 invalid suffix in X argument '${too_big}h'
51 X argument '$too_big' too large
52 invalid X argument 'x'
53 invalid suffix in X argument '9x'
54 010->8 ()
55 MiB->1048576 ()
56 invalid suffix in X argument '1bB'
57 1->1 ()
58 invalid X argument '-1'
59 1k->1024 ()
60 invalid suffix in X argument '${too_big}h'
61 X argument '$too_big' too large
62 invalid X argument 'x'
63 invalid suffix in X argument '9x'
64 010->8 ()
65 MiB->1048576 ()
66 invalid suffix in X argument '1bB'
67 EOF
69 compare expected out || result=1
71 Exit $result