annotate tests/test-strtoimax.c @ 40231:9b3c79fdfe0b

strtod: fix clash with strtold Problem reported for RHEL 5 by Jesse Caldwell (Bug#34817). * lib/strtod.c (compute_minus_zero, minus_zero): Simplify by remving the macro / external variable, and having just a function. User changed. This avoids the need for an external variable that might clash.
author Paul Eggert <eggert@cs.ucla.edu>
date Mon, 11 Mar 2019 16:40:29 -0700
parents b06060465f09
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15552
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /*
40057
b06060465f09 maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents: 19484
diff changeset
2 * Copyright (C) 2011-2019 Free Software Foundation, Inc.
15552
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3 *
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 * This program is free software: you can redistribute it and/or modify
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6 * the Free Software Foundation; either version 3 of the License, or
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 * (at your option) any later version.
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8 *
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 * This program is distributed in the hope that it will be useful,
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 * GNU General Public License for more details.
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13 *
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
19190
9759915b2aca all: prefer https: URLs
Paul Eggert <eggert@cs.ucla.edu>
parents: 18626
diff changeset
15 * along with this program. If not, see <https://www.gnu.org/licenses/>. */
15552
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 #include <config.h>
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19 #include <inttypes.h>
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21 #include "signature.h"
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22 #ifndef strtoimax
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23 SIGNATURE_CHECK (strtoimax, intmax_t, (const char *, char **, int));
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24 #endif
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26 #include <errno.h>
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28 #include "macros.h"
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30 int
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31 main (void)
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32 {
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33 /* Subject sequence empty or invalid. */
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34 {
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35 const char input[] = "";
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36 char *ptr;
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37 intmax_t result;
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38 errno = 0;
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
39 result = strtoimax (input, &ptr, 10);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
40 ASSERT (result == 0);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41 ASSERT (ptr == input);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42 ASSERT (errno == 0 || errno == EINVAL);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
43 }
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
44 {
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
45 const char input[] = " ";
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
46 char *ptr;
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
47 intmax_t result;
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
48 errno = 0;
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49 result = strtoimax (input, &ptr, 10);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
50 ASSERT (result == 0);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
51 ASSERT (ptr == input);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52 ASSERT (errno == 0 || errno == EINVAL);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53 }
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54 {
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55 const char input[] = " +";
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
56 char *ptr;
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
57 intmax_t result;
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
58 errno = 0;
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
59 result = strtoimax (input, &ptr, 10);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
60 ASSERT (result == 0);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
61 ASSERT (ptr == input);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
62 ASSERT (errno == 0 || errno == EINVAL);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
63 }
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
64 {
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
65 const char input[] = " -";
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
66 char *ptr;
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
67 intmax_t result;
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
68 errno = 0;
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
69 result = strtoimax (input, &ptr, 10);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
70 ASSERT (result == 0);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
71 ASSERT (ptr == input);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
72 ASSERT (errno == 0 || errno == EINVAL);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
73 }
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
74
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
75 /* Simple integer values. */
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
76 {
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
77 const char input[] = "0";
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
78 char *ptr;
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
79 intmax_t result;
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
80 errno = 0;
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
81 result = strtoimax (input, &ptr, 10);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
82 ASSERT (result == 0);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
83 ASSERT (ptr == input + 1);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
84 ASSERT (errno == 0);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
85 }
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
86 {
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
87 const char input[] = "+0";
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
88 char *ptr;
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
89 intmax_t result;
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
90 errno = 0;
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
91 result = strtoimax (input, &ptr, 10);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
92 ASSERT (result == 0);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
93 ASSERT (ptr == input + 2);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
94 ASSERT (errno == 0);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
95 }
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
96 {
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
97 const char input[] = "-0";
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
98 char *ptr;
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
99 intmax_t result;
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
100 errno = 0;
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
101 result = strtoimax (input, &ptr, 10);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
102 ASSERT (result == 0);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
103 ASSERT (ptr == input + 2);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
104 ASSERT (errno == 0);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
105 }
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
106 {
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
107 const char input[] = "23";
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
108 char *ptr;
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
109 intmax_t result;
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
110 errno = 0;
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
111 result = strtoimax (input, &ptr, 10);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
112 ASSERT (result == 23);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
113 ASSERT (ptr == input + 2);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
114 ASSERT (errno == 0);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
115 }
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
116 {
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
117 const char input[] = " 23";
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
118 char *ptr;
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
119 intmax_t result;
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
120 errno = 0;
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
121 result = strtoimax (input, &ptr, 10);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
122 ASSERT (result == 23);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
123 ASSERT (ptr == input + 3);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
124 ASSERT (errno == 0);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
125 }
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
126 {
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
127 const char input[] = "+23";
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
128 char *ptr;
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
129 intmax_t result;
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
130 errno = 0;
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
131 result = strtoimax (input, &ptr, 10);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
132 ASSERT (result == 23);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
133 ASSERT (ptr == input + 3);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
134 ASSERT (errno == 0);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
135 }
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
136 {
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
137 const char input[] = "-23";
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
138 char *ptr;
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
139 intmax_t result;
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
140 errno = 0;
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
141 result = strtoimax (input, &ptr, 10);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
142 ASSERT (result == -23);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
143 ASSERT (ptr == input + 3);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
144 ASSERT (errno == 0);
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
145 }
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
146
16230
f9e137049132 strtoimax: Work around AIX 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
147 /* Large integer values. */
f9e137049132 strtoimax: Work around AIX 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
148 {
f9e137049132 strtoimax: Work around AIX 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
149 const char input[] = "2147483647";
f9e137049132 strtoimax: Work around AIX 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
150 char *ptr;
f9e137049132 strtoimax: Work around AIX 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
151 intmax_t result;
f9e137049132 strtoimax: Work around AIX 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
152 errno = 0;
f9e137049132 strtoimax: Work around AIX 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
153 result = strtoimax (input, &ptr, 10);
f9e137049132 strtoimax: Work around AIX 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
154 ASSERT (result == 2147483647);
f9e137049132 strtoimax: Work around AIX 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
155 ASSERT (ptr == input + 10);
f9e137049132 strtoimax: Work around AIX 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
156 ASSERT (errno == 0);
f9e137049132 strtoimax: Work around AIX 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
157 }
f9e137049132 strtoimax: Work around AIX 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
158 {
f9e137049132 strtoimax: Work around AIX 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
159 const char input[] = "-2147483648";
f9e137049132 strtoimax: Work around AIX 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
160 char *ptr;
f9e137049132 strtoimax: Work around AIX 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
161 intmax_t result;
f9e137049132 strtoimax: Work around AIX 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
162 errno = 0;
f9e137049132 strtoimax: Work around AIX 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
163 result = strtoimax (input, &ptr, 10);
f9e137049132 strtoimax: Work around AIX 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
164 ASSERT (result == -2147483647 - 1);
f9e137049132 strtoimax: Work around AIX 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
165 ASSERT (ptr == input + 11);
f9e137049132 strtoimax: Work around AIX 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
166 ASSERT (errno == 0);
f9e137049132 strtoimax: Work around AIX 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
167 }
f9e137049132 strtoimax: Work around AIX 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
168 if (sizeof (intmax_t) > sizeof (int))
f9e137049132 strtoimax: Work around AIX 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
169 {
f9e137049132 strtoimax: Work around AIX 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
170 const char input[] = "4294967295";
f9e137049132 strtoimax: Work around AIX 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
171 char *ptr;
f9e137049132 strtoimax: Work around AIX 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
172 intmax_t result;
f9e137049132 strtoimax: Work around AIX 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
173 errno = 0;
f9e137049132 strtoimax: Work around AIX 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
174 result = strtoimax (input, &ptr, 10);
f9e137049132 strtoimax: Work around AIX 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
175 ASSERT (result == (intmax_t) 65535 * (intmax_t) 65537);
f9e137049132 strtoimax: Work around AIX 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
176 ASSERT (ptr == input + 10);
f9e137049132 strtoimax: Work around AIX 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
177 ASSERT (errno == 0);
f9e137049132 strtoimax: Work around AIX 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
178 }
f9e137049132 strtoimax: Work around AIX 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
179
15552
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
180 return 0;
3f606c806be7 Tests for module 'strtoimax'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
181 }