]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/strtoll/tst.strtoll.d
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / cddl / contrib / opensolaris / cmd / dtrace / test / tst / common / strtoll / tst.strtoll.d
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11
12 /*
13  * Copyright (c) 2012, Joyent, Inc. All rights reserved.
14  */
15
16 /*
17  * ASSERTION:
18  *   Test the strtoll() subroutine.
19  *
20  * SECTION: Actions and Subroutines/strtoll()
21  */
22
23 #pragma D option quiet
24
25 BEGIN
26 {
27
28         /* minimum base (2) and maximum base (36): */
29         printf("%d\n", strtoll("0", 2));
30         printf("%d\n", strtoll("1", 36));
31
32         /* simple tests: */
33         printf("%d\n", strtoll("0x20", 16));
34         printf("%d\n", strtoll("-32", 10));
35         printf("%d\n", strtoll("010", 8));
36         printf("%d\n", strtoll("101010", 2));
37
38         /* INT64_MIN and INT64_MAX: */
39         printf("%d\n", strtoll("9223372036854775807"));
40         printf("%d\n", strtoll("-9223372036854775808"));
41         printf("%d\n", strtoll("0777777777777777777777", 8));
42         printf("%d\n", strtoll("-01000000000000000000000", 8));
43
44         /* wrapping: */
45         printf("%d\n", strtoll("1000000000000000000000", 8));
46         printf("%d\n", strtoll("-1000000000000000000001", 8));
47
48         /* hex without prefix: */
49         printf("%d\n", strtoll("baddcafe", 16));
50
51         /* stopping at first out-of-base character: */
52         printf("%d\n", strtoll("12j", 10));
53         printf("%d\n", strtoll("102", 2));
54
55         /* base 36: */
56         printf("%d\n", strtoll("-0DTrace4EverZ", 36));
57
58         /* base 10 is assumed: */
59         printf("%d\n", strtoll("1985"));
60         printf("%d\n", strtoll("-2012"));
61
62         /* empty string: */
63         printf("%d\n", strtoll(""));
64
65         exit(0);
66 }