Mercurial > hg > octave-nkf > gnulib-hg
annotate tests/test-vasnprintf-posix.c @ 9309:bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 07 Oct 2007 19:14:58 +0200 |
parents | 42e2847583f9 |
children | 6d73d8d1aecb |
rev | line source |
---|---|
8336
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
1 /* Test of POSIX compatible vasnprintf() and asnprintf() functions. |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
2 Copyright (C) 2007 Free Software Foundation, Inc. |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8919
diff
changeset
|
4 This program is free software: you can redistribute it and/or modify |
8336
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
5 it under the terms of the GNU General Public License as published by |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8919
diff
changeset
|
6 the Free Software Foundation; either version 3 of the License, or |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8919
diff
changeset
|
7 (at your option) any later version. |
8336
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
8 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
9 This program is distributed in the hope that it will be useful, |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
12 GNU General Public License for more details. |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
13 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
14 You should have received a copy of the GNU General Public License |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8919
diff
changeset
|
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
8336
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
16 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
17 /* Written by Bruno Haible <bruno@clisp.org>, 2007. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
18 |
8891
633babea5f62
Unconditionally include <config.h> in unit tests.
Eric Blake <ebb9@byu.net>
parents:
8870
diff
changeset
|
19 #include <config.h> |
8336
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
20 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
21 #include "vasnprintf.h" |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
22 |
8919
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
23 #include <float.h> |
8336
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
24 #include <stdarg.h> |
8354
81b3f885ff9d
Include <stddef.h>, for ptrdiff_t.
Bruno Haible <bruno@clisp.org>
parents:
8344
diff
changeset
|
25 #include <stddef.h> |
8754 | 26 #include <stdio.h> |
8336
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
27 #include <stdint.h> |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
28 #include <stdlib.h> |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
29 #include <string.h> |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
30 |
8834 | 31 #define SIZEOF(array) (sizeof (array) / sizeof (array[0])) |
8754 | 32 #define ASSERT(expr) \ |
33 do \ | |
34 { \ | |
35 if (!(expr)) \ | |
36 { \ | |
37 fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ | |
38 abort (); \ | |
39 } \ | |
40 } \ | |
41 while (0) | |
8336
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
42 |
8543
e1fdf02d5cdc
Work around a DEC C compiler bug.
Bruno Haible <bruno@clisp.org>
parents:
8354
diff
changeset
|
43 /* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */ |
e1fdf02d5cdc
Work around a DEC C compiler bug.
Bruno Haible <bruno@clisp.org>
parents:
8354
diff
changeset
|
44 #ifdef __DECC |
e1fdf02d5cdc
Work around a DEC C compiler bug.
Bruno Haible <bruno@clisp.org>
parents:
8354
diff
changeset
|
45 static double |
e1fdf02d5cdc
Work around a DEC C compiler bug.
Bruno Haible <bruno@clisp.org>
parents:
8354
diff
changeset
|
46 NaN () |
e1fdf02d5cdc
Work around a DEC C compiler bug.
Bruno Haible <bruno@clisp.org>
parents:
8354
diff
changeset
|
47 { |
e1fdf02d5cdc
Work around a DEC C compiler bug.
Bruno Haible <bruno@clisp.org>
parents:
8354
diff
changeset
|
48 static double zero = 0.0; |
e1fdf02d5cdc
Work around a DEC C compiler bug.
Bruno Haible <bruno@clisp.org>
parents:
8354
diff
changeset
|
49 return zero / zero; |
e1fdf02d5cdc
Work around a DEC C compiler bug.
Bruno Haible <bruno@clisp.org>
parents:
8354
diff
changeset
|
50 } |
e1fdf02d5cdc
Work around a DEC C compiler bug.
Bruno Haible <bruno@clisp.org>
parents:
8354
diff
changeset
|
51 #else |
e1fdf02d5cdc
Work around a DEC C compiler bug.
Bruno Haible <bruno@clisp.org>
parents:
8354
diff
changeset
|
52 # define NaN() (0.0 / 0.0) |
e1fdf02d5cdc
Work around a DEC C compiler bug.
Bruno Haible <bruno@clisp.org>
parents:
8354
diff
changeset
|
53 #endif |
e1fdf02d5cdc
Work around a DEC C compiler bug.
Bruno Haible <bruno@clisp.org>
parents:
8354
diff
changeset
|
54 |
8852
df0b5e8ea770
Avoid test failures on platforms where -0.0 and 0.0 are identical.
Bruno Haible <bruno@clisp.org>
parents:
8850
diff
changeset
|
55 /* The SGI MIPS floating-point format does not distinguish 0.0 and -0.0. */ |
df0b5e8ea770
Avoid test failures on platforms where -0.0 and 0.0 are identical.
Bruno Haible <bruno@clisp.org>
parents:
8850
diff
changeset
|
56 static int |
df0b5e8ea770
Avoid test failures on platforms where -0.0 and 0.0 are identical.
Bruno Haible <bruno@clisp.org>
parents:
8850
diff
changeset
|
57 have_minus_zero () |
df0b5e8ea770
Avoid test failures on platforms where -0.0 and 0.0 are identical.
Bruno Haible <bruno@clisp.org>
parents:
8850
diff
changeset
|
58 { |
df0b5e8ea770
Avoid test failures on platforms where -0.0 and 0.0 are identical.
Bruno Haible <bruno@clisp.org>
parents:
8850
diff
changeset
|
59 static double plus_zero = 0.0; |
df0b5e8ea770
Avoid test failures on platforms where -0.0 and 0.0 are identical.
Bruno Haible <bruno@clisp.org>
parents:
8850
diff
changeset
|
60 static double minus_zero = -0.0; |
df0b5e8ea770
Avoid test failures on platforms where -0.0 and 0.0 are identical.
Bruno Haible <bruno@clisp.org>
parents:
8850
diff
changeset
|
61 return memcmp (&plus_zero, &minus_zero, sizeof (double)) != 0; |
df0b5e8ea770
Avoid test failures on platforms where -0.0 and 0.0 are identical.
Bruno Haible <bruno@clisp.org>
parents:
8850
diff
changeset
|
62 } |
df0b5e8ea770
Avoid test failures on platforms where -0.0 and 0.0 are identical.
Bruno Haible <bruno@clisp.org>
parents:
8850
diff
changeset
|
63 |
8919
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
64 /* Representation of an 80-bit 'long double' as an initializer for a sequence |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
65 of 'unsigned int' words. */ |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
66 #ifdef WORDS_BIGENDIAN |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
67 # define LDBL80_WORDS(exponent,manthi,mantlo) \ |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
68 { ((unsigned int) (exponent) << 16) | ((unsigned int) (manthi) >> 16), \ |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
69 ((unsigned int) (manthi) << 16) | (unsigned int) (mantlo) >> 16), \ |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
70 (unsigned int) (mantlo) << 16 \ |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
71 } |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
72 #else |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
73 # define LDBL80_WORDS(exponent,manthi,mantlo) \ |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
74 { mantlo, manthi, exponent } |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
75 #endif |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
76 |
8834 | 77 static int |
78 strmatch (const char *pattern, const char *string) | |
79 { | |
80 if (strlen (pattern) != strlen (string)) | |
81 return 0; | |
82 for (; *pattern != '\0'; pattern++, string++) | |
83 if (*pattern != '*' && *string != *pattern) | |
84 return 0; | |
85 return 1; | |
86 } | |
87 | |
8865
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8857
diff
changeset
|
88 /* Test whether string[start_index..end_index-1] is a valid textual |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8857
diff
changeset
|
89 representation of NaN. */ |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8857
diff
changeset
|
90 static int |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8857
diff
changeset
|
91 strisnan (const char *string, size_t start_index, size_t end_index, int uppercase) |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8857
diff
changeset
|
92 { |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8857
diff
changeset
|
93 if (start_index < end_index) |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8857
diff
changeset
|
94 { |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8857
diff
changeset
|
95 if (string[start_index] == '-') |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8857
diff
changeset
|
96 start_index++; |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8857
diff
changeset
|
97 if (start_index + 3 <= end_index |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8857
diff
changeset
|
98 && memcmp (string + start_index, uppercase ? "NAN" : "nan", 3) == 0) |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8857
diff
changeset
|
99 { |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8857
diff
changeset
|
100 start_index += 3; |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8857
diff
changeset
|
101 if (start_index == end_index |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8857
diff
changeset
|
102 || (string[start_index] == '(' && string[end_index - 1] == ')')) |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8857
diff
changeset
|
103 return 1; |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8857
diff
changeset
|
104 } |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8857
diff
changeset
|
105 } |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8857
diff
changeset
|
106 return 0; |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8857
diff
changeset
|
107 } |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8857
diff
changeset
|
108 |
8336
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
109 static void |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
110 test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
111 { |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
112 char buf[8]; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
113 int size; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
114 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
115 /* Test return value convention. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
116 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
117 for (size = 0; size <= 8; size++) |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
118 { |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
119 size_t length = size; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
120 char *result = my_asnprintf (NULL, &length, "%d", 12345); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
121 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
122 ASSERT (strcmp (result, "12345") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
123 ASSERT (length == 5); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
124 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
125 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
126 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
127 for (size = 0; size <= 8; size++) |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
128 { |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
129 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
130 char *result; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
131 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
132 memcpy (buf, "DEADBEEF", 8); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
133 length = size; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
134 result = my_asnprintf (buf, &length, "%d", 12345); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
135 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
136 ASSERT (strcmp (result, "12345") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
137 ASSERT (length == 5); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
138 if (size < 6) |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
139 ASSERT (result != buf); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
140 ASSERT (memcmp (buf + size, "DEADBEEF" + size, 8 - size) == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
141 if (result != buf) |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
142 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
143 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
144 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
145 /* Test support of size specifiers as in C99. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
146 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
147 { |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
148 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
149 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
150 my_asnprintf (NULL, &length, "%ju %d", (uintmax_t) 12345671, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
151 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
152 ASSERT (strcmp (result, "12345671 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
153 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
154 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
155 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
156 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
157 { |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
158 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
159 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
160 my_asnprintf (NULL, &length, "%zu %d", (size_t) 12345672, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
161 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
162 ASSERT (strcmp (result, "12345672 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
163 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
164 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
165 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
166 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
167 { |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
168 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
169 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
170 my_asnprintf (NULL, &length, "%tu %d", (ptrdiff_t) 12345673, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
171 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
172 ASSERT (strcmp (result, "12345673 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
173 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
174 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
175 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
176 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
177 { |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
178 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
179 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
180 my_asnprintf (NULL, &length, "%Lg %d", (long double) 1.5, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
181 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
182 ASSERT (strcmp (result, "1.5 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
183 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
184 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
185 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
186 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
187 /* Test the support of the 'a' and 'A' conversion specifier for hexadecimal |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
188 output of floating-point numbers. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
189 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
190 { /* A positive number. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
191 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
192 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
193 my_asnprintf (NULL, &length, "%a %d", 3.1416015625, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
194 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
195 ASSERT (strcmp (result, "0x1.922p+1 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
196 || strcmp (result, "0x3.244p+0 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
197 || strcmp (result, "0x6.488p-1 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
198 || strcmp (result, "0xc.91p-2 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
199 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
200 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
201 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
202 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
203 { /* A negative number. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
204 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
205 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
206 my_asnprintf (NULL, &length, "%A %d", -3.1416015625, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
207 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
208 ASSERT (strcmp (result, "-0X1.922P+1 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
209 || strcmp (result, "-0X3.244P+0 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
210 || strcmp (result, "-0X6.488P-1 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
211 || strcmp (result, "-0XC.91P-2 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
212 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
213 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
214 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
215 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
216 { /* Positive zero. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
217 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
218 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
219 my_asnprintf (NULL, &length, "%a %d", 0.0, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
220 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
221 ASSERT (strcmp (result, "0x0p+0 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
222 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
223 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
224 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
225 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
226 { /* Negative zero. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
227 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
228 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
229 my_asnprintf (NULL, &length, "%a %d", -0.0, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
230 ASSERT (result != NULL); |
8852
df0b5e8ea770
Avoid test failures on platforms where -0.0 and 0.0 are identical.
Bruno Haible <bruno@clisp.org>
parents:
8850
diff
changeset
|
231 if (have_minus_zero ()) |
df0b5e8ea770
Avoid test failures on platforms where -0.0 and 0.0 are identical.
Bruno Haible <bruno@clisp.org>
parents:
8850
diff
changeset
|
232 ASSERT (strcmp (result, "-0x0p+0 33") == 0); |
8336
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
233 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
234 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
235 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
236 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
237 { /* Positive infinity. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
238 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
239 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
240 my_asnprintf (NULL, &length, "%a %d", 1.0 / 0.0, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
241 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
242 ASSERT (strcmp (result, "inf 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
243 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
244 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
245 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
246 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
247 { /* Negative infinity. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
248 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
249 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
250 my_asnprintf (NULL, &length, "%a %d", -1.0 / 0.0, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
251 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
252 ASSERT (strcmp (result, "-inf 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
253 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
254 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
255 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
256 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
257 { /* NaN. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
258 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
259 char *result = |
8543
e1fdf02d5cdc
Work around a DEC C compiler bug.
Bruno Haible <bruno@clisp.org>
parents:
8354
diff
changeset
|
260 my_asnprintf (NULL, &length, "%a %d", NaN (), 33, 44, 55); |
8336
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
261 ASSERT (result != NULL); |
8850
d1fe16dfbfee
Avoid test failures on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents:
8839
diff
changeset
|
262 ASSERT (strlen (result) >= 3 + 3 |
8865
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8857
diff
changeset
|
263 && strisnan (result, 0, strlen (result) - 3, 0) |
8850
d1fe16dfbfee
Avoid test failures on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents:
8839
diff
changeset
|
264 && strcmp (result + strlen (result) - 3, " 33") == 0); |
8336
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
265 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
266 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
267 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
268 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
269 { /* Rounding near the decimal point. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
270 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
271 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
272 my_asnprintf (NULL, &length, "%.0a %d", 1.5, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
273 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
274 ASSERT (strcmp (result, "0x2p+0 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
275 || strcmp (result, "0x3p-1 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
276 || strcmp (result, "0x6p-2 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
277 || strcmp (result, "0xcp-3 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
278 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
279 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
280 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
281 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
282 { /* Rounding with precision 0. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
283 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
284 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
285 my_asnprintf (NULL, &length, "%.0a %d", 1.51, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
286 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
287 ASSERT (strcmp (result, "0x2p+0 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
288 || strcmp (result, "0x3p-1 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
289 || strcmp (result, "0x6p-2 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
290 || strcmp (result, "0xcp-3 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
291 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
292 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
293 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
294 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
295 { /* Rounding with precision 1. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
296 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
297 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
298 my_asnprintf (NULL, &length, "%.1a %d", 1.51, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
299 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
300 ASSERT (strcmp (result, "0x1.8p+0 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
301 || strcmp (result, "0x3.0p-1 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
302 || strcmp (result, "0x6.1p-2 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
303 || strcmp (result, "0xc.1p-3 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
304 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
305 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
306 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
307 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
308 { /* Rounding with precision 2. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
309 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
310 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
311 my_asnprintf (NULL, &length, "%.2a %d", 1.51, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
312 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
313 ASSERT (strcmp (result, "0x1.83p+0 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
314 || strcmp (result, "0x3.05p-1 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
315 || strcmp (result, "0x6.0ap-2 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
316 || strcmp (result, "0xc.14p-3 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
317 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
318 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
319 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
320 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
321 { /* Rounding with precision 3. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
322 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
323 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
324 my_asnprintf (NULL, &length, "%.3a %d", 1.51, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
325 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
326 ASSERT (strcmp (result, "0x1.829p+0 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
327 || strcmp (result, "0x3.052p-1 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
328 || strcmp (result, "0x6.0a4p-2 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
329 || strcmp (result, "0xc.148p-3 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
330 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
331 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
332 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
333 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
334 { /* Rounding can turn a ...FFF into a ...000. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
335 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
336 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
337 my_asnprintf (NULL, &length, "%.3a %d", 1.49999, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
338 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
339 ASSERT (strcmp (result, "0x1.800p+0 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
340 || strcmp (result, "0x3.000p-1 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
341 || strcmp (result, "0x6.000p-2 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
342 || strcmp (result, "0xc.000p-3 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
343 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
344 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
345 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
346 |
8344
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8336
diff
changeset
|
347 { /* Rounding can turn a ...FFF into a ...000. |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8336
diff
changeset
|
348 This shows a MacOS X 10.3.9 (Darwin 7.9) bug. */ |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8336
diff
changeset
|
349 size_t length; |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8336
diff
changeset
|
350 char *result = |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8336
diff
changeset
|
351 my_asnprintf (NULL, &length, "%.1a %d", 1.999, 33, 44, 55); |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8336
diff
changeset
|
352 ASSERT (result != NULL); |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8336
diff
changeset
|
353 ASSERT (strcmp (result, "0x1.0p+1 33") == 0 |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8336
diff
changeset
|
354 || strcmp (result, "0x2.0p+0 33") == 0 |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8336
diff
changeset
|
355 || strcmp (result, "0x4.0p-1 33") == 0 |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8336
diff
changeset
|
356 || strcmp (result, "0x8.0p-2 33") == 0); |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8336
diff
changeset
|
357 ASSERT (length == strlen (result)); |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8336
diff
changeset
|
358 free (result); |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8336
diff
changeset
|
359 } |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8336
diff
changeset
|
360 |
8336
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
361 { /* Width. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
362 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
363 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
364 my_asnprintf (NULL, &length, "%10a %d", 1.75, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
365 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
366 ASSERT (strcmp (result, " 0x1.cp+0 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
367 || strcmp (result, " 0x3.8p-1 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
368 || strcmp (result, " 0x7p-2 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
369 || strcmp (result, " 0xep-3 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
370 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
371 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
372 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
373 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
374 { /* Small precision. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
375 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
376 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
377 my_asnprintf (NULL, &length, "%.10a %d", 1.75, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
378 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
379 ASSERT (strcmp (result, "0x1.c000000000p+0 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
380 || strcmp (result, "0x3.8000000000p-1 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
381 || strcmp (result, "0x7.0000000000p-2 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
382 || strcmp (result, "0xe.0000000000p-3 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
383 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
384 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
385 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
386 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
387 { /* Large precision. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
388 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
389 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
390 my_asnprintf (NULL, &length, "%.50a %d", 1.75, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
391 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
392 ASSERT (strcmp (result, "0x1.c0000000000000000000000000000000000000000000000000p+0 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
393 || strcmp (result, "0x3.80000000000000000000000000000000000000000000000000p-1 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
394 || strcmp (result, "0x7.00000000000000000000000000000000000000000000000000p-2 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
395 || strcmp (result, "0xe.00000000000000000000000000000000000000000000000000p-3 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
396 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
397 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
398 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
399 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
400 { /* FLAG_LEFT. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
401 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
402 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
403 my_asnprintf (NULL, &length, "%-10a %d", 1.75, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
404 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
405 ASSERT (strcmp (result, "0x1.cp+0 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
406 || strcmp (result, "0x3.8p-1 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
407 || strcmp (result, "0x7p-2 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
408 || strcmp (result, "0xep-3 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
409 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
410 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
411 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
412 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
413 { /* FLAG_SHOWSIGN. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
414 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
415 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
416 my_asnprintf (NULL, &length, "%+a %d", 1.75, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
417 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
418 ASSERT (strcmp (result, "+0x1.cp+0 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
419 || strcmp (result, "+0x3.8p-1 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
420 || strcmp (result, "+0x7p-2 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
421 || strcmp (result, "+0xep-3 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
422 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
423 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
424 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
425 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
426 { /* FLAG_SPACE. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
427 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
428 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
429 my_asnprintf (NULL, &length, "% a %d", 1.75, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
430 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
431 ASSERT (strcmp (result, " 0x1.cp+0 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
432 || strcmp (result, " 0x3.8p-1 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
433 || strcmp (result, " 0x7p-2 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
434 || strcmp (result, " 0xep-3 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
435 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
436 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
437 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
438 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
439 { /* FLAG_ALT. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
440 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
441 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
442 my_asnprintf (NULL, &length, "%#a %d", 1.75, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
443 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
444 ASSERT (strcmp (result, "0x1.cp+0 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
445 || strcmp (result, "0x3.8p-1 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
446 || strcmp (result, "0x7.p-2 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
447 || strcmp (result, "0xe.p-3 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
448 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
449 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
450 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
451 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
452 { /* FLAG_ALT. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
453 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
454 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
455 my_asnprintf (NULL, &length, "%#a %d", 1.0, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
456 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
457 ASSERT (strcmp (result, "0x1.p+0 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
458 || strcmp (result, "0x2.p-1 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
459 || strcmp (result, "0x4.p-2 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
460 || strcmp (result, "0x8.p-3 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
461 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
462 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
463 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
464 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
465 { /* FLAG_ZERO with finite number. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
466 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
467 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
468 my_asnprintf (NULL, &length, "%010a %d", 1.75, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
469 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
470 ASSERT (strcmp (result, "0x001.cp+0 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
471 || strcmp (result, "0x003.8p-1 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
472 || strcmp (result, "0x00007p-2 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
473 || strcmp (result, "0x0000ep-3 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
474 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
475 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
476 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
477 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
478 { /* FLAG_ZERO with infinite number. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
479 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
480 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
481 my_asnprintf (NULL, &length, "%010a %d", 1.0 / 0.0, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
482 ASSERT (result != NULL); |
8662
023aa5c883a7
Guard against FreeBSD 6.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
8648
diff
changeset
|
483 /* "0000000inf 33" is not a valid result; see |
023aa5c883a7
Guard against FreeBSD 6.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
8648
diff
changeset
|
484 <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */ |
023aa5c883a7
Guard against FreeBSD 6.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
8648
diff
changeset
|
485 ASSERT (strcmp (result, " inf 33") == 0); |
8336
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
486 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
487 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
488 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
489 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
490 { /* FLAG_ZERO with NaN. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
491 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
492 char *result = |
8870
4e1f2ea486b4
Allow for a longer printed representation of NaN.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
493 my_asnprintf (NULL, &length, "%050a %d", NaN (), 33, 44, 55); |
8336
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
494 ASSERT (result != NULL); |
8662
023aa5c883a7
Guard against FreeBSD 6.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
8648
diff
changeset
|
495 /* "0000000nan 33" is not a valid result; see |
023aa5c883a7
Guard against FreeBSD 6.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
8648
diff
changeset
|
496 <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */ |
8870
4e1f2ea486b4
Allow for a longer printed representation of NaN.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
497 ASSERT (strlen (result) == 50 + 3 |
8865
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8857
diff
changeset
|
498 && strisnan (result, strspn (result, " "), strlen (result) - 3, 0) |
8850
d1fe16dfbfee
Avoid test failures on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents:
8839
diff
changeset
|
499 && strcmp (result + strlen (result) - 3, " 33") == 0); |
8336
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
500 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
501 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
502 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
503 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
504 { /* A positive number. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
505 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
506 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
507 my_asnprintf (NULL, &length, "%La %d", 3.1416015625L, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
508 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
509 ASSERT (strcmp (result, "0x1.922p+1 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
510 || strcmp (result, "0x3.244p+0 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
511 || strcmp (result, "0x6.488p-1 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
512 || strcmp (result, "0xc.91p-2 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
513 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
514 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
515 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
516 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
517 { /* A negative number. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
518 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
519 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
520 my_asnprintf (NULL, &length, "%LA %d", -3.1416015625L, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
521 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
522 ASSERT (strcmp (result, "-0X1.922P+1 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
523 || strcmp (result, "-0X3.244P+0 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
524 || strcmp (result, "-0X6.488P-1 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
525 || strcmp (result, "-0XC.91P-2 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
526 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
527 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
528 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
529 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
530 { /* Positive zero. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
531 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
532 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
533 my_asnprintf (NULL, &length, "%La %d", 0.0L, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
534 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
535 ASSERT (strcmp (result, "0x0p+0 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
536 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
537 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
538 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
539 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
540 { /* Negative zero. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
541 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
542 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
543 my_asnprintf (NULL, &length, "%La %d", -0.0L, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
544 ASSERT (result != NULL); |
8852
df0b5e8ea770
Avoid test failures on platforms where -0.0 and 0.0 are identical.
Bruno Haible <bruno@clisp.org>
parents:
8850
diff
changeset
|
545 if (have_minus_zero ()) |
df0b5e8ea770
Avoid test failures on platforms where -0.0 and 0.0 are identical.
Bruno Haible <bruno@clisp.org>
parents:
8850
diff
changeset
|
546 ASSERT (strcmp (result, "-0x0p+0 33") == 0); |
8336
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
547 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
548 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
549 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
550 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
551 { /* Positive infinity. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
552 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
553 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
554 my_asnprintf (NULL, &length, "%La %d", 1.0L / 0.0L, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
555 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
556 ASSERT (strcmp (result, "inf 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
557 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
558 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
559 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
560 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
561 { /* Negative infinity. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
562 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
563 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
564 my_asnprintf (NULL, &length, "%La %d", -1.0L / 0.0L, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
565 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
566 ASSERT (strcmp (result, "-inf 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
567 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
568 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
569 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
570 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
571 { /* NaN. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
572 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
573 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
574 my_asnprintf (NULL, &length, "%La %d", 0.0L / 0.0L, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
575 ASSERT (result != NULL); |
8850
d1fe16dfbfee
Avoid test failures on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents:
8839
diff
changeset
|
576 ASSERT (strlen (result) >= 3 + 3 |
8865
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8857
diff
changeset
|
577 && strisnan (result, 0, strlen (result) - 3, 0) |
8850
d1fe16dfbfee
Avoid test failures on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents:
8839
diff
changeset
|
578 && strcmp (result + strlen (result) - 3, " 33") == 0); |
8336
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
579 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
580 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
581 } |
8919
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
582 #if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
583 { /* Quiet NaN. */ |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
584 static union { unsigned int word[4]; long double value; } x = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
585 { LDBL80_WORDS (0xFFFF, 0xC3333333, 0x00000000) }; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
586 size_t length; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
587 char *result = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
588 my_asnprintf (NULL, &length, "%La %d", x.value, 33, 44, 55); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
589 ASSERT (result != NULL); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
590 ASSERT (strlen (result) >= 3 + 3 |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
591 && strisnan (result, 0, strlen (result) - 3, 0) |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
592 && strcmp (result + strlen (result) - 3, " 33") == 0); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
593 ASSERT (length == strlen (result)); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
594 free (result); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
595 } |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
596 { |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
597 /* Signalling NaN. */ |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
598 static union { unsigned int word[4]; long double value; } x = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
599 { LDBL80_WORDS (0xFFFF, 0x83333333, 0x00000000) }; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
600 size_t length; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
601 char *result = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
602 my_asnprintf (NULL, &length, "%La %d", x.value, 33, 44, 55); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
603 ASSERT (result != NULL); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
604 ASSERT (strlen (result) >= 3 + 3 |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
605 && strisnan (result, 0, strlen (result) - 3, 0) |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
606 && strcmp (result + strlen (result) - 3, " 33") == 0); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
607 ASSERT (length == strlen (result)); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
608 free (result); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
609 } |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
610 /* The isnanl function should recognize Pseudo-NaNs, Pseudo-Infinities, |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
611 Pseudo-Zeroes, Unnormalized Numbers, and Pseudo-Denormals, as defined in |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
612 Intel IA-64 Architecture Software Developer's Manual, Volume 1: |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
613 Application Architecture. |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
614 Table 5-2 "Floating-Point Register Encodings" |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
615 Figure 5-6 "Memory to Floating-Point Register Data Translation" |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
616 */ |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
617 { /* Pseudo-NaN. */ |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
618 static union { unsigned int word[4]; long double value; } x = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
619 { LDBL80_WORDS (0xFFFF, 0x40000001, 0x00000000) }; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
620 size_t length; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
621 char *result = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
622 my_asnprintf (NULL, &length, "%La %d", x.value, 33, 44, 55); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
623 ASSERT (result != NULL); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
624 ASSERT (strlen (result) >= 3 + 3 |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
625 && strisnan (result, 0, strlen (result) - 3, 0) |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
626 && strcmp (result + strlen (result) - 3, " 33") == 0); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
627 ASSERT (length == strlen (result)); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
628 free (result); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
629 } |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
630 { /* Pseudo-Infinity. */ |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
631 static union { unsigned int word[4]; long double value; } x = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
632 { LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) }; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
633 size_t length; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
634 char *result = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
635 my_asnprintf (NULL, &length, "%La %d", x.value, 33, 44, 55); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
636 ASSERT (result != NULL); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
637 ASSERT (strlen (result) >= 3 + 3 |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
638 && strisnan (result, 0, strlen (result) - 3, 0) |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
639 && strcmp (result + strlen (result) - 3, " 33") == 0); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
640 ASSERT (length == strlen (result)); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
641 free (result); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
642 } |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
643 { /* Pseudo-Zero. */ |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
644 static union { unsigned int word[4]; long double value; } x = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
645 { LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) }; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
646 size_t length; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
647 char *result = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
648 my_asnprintf (NULL, &length, "%La %d", x.value, 33, 44, 55); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
649 ASSERT (result != NULL); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
650 ASSERT (strlen (result) >= 3 + 3 |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
651 && strisnan (result, 0, strlen (result) - 3, 0) |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
652 && strcmp (result + strlen (result) - 3, " 33") == 0); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
653 ASSERT (length == strlen (result)); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
654 free (result); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
655 } |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
656 { /* Unnormalized number. */ |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
657 static union { unsigned int word[4]; long double value; } x = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
658 { LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) }; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
659 size_t length; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
660 char *result = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
661 my_asnprintf (NULL, &length, "%La %d", x.value, 33, 44, 55); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
662 ASSERT (result != NULL); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
663 ASSERT (strlen (result) >= 3 + 3 |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
664 && strisnan (result, 0, strlen (result) - 3, 0) |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
665 && strcmp (result + strlen (result) - 3, " 33") == 0); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
666 ASSERT (length == strlen (result)); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
667 free (result); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
668 } |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
669 { /* Pseudo-Denormal. */ |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
670 static union { unsigned int word[4]; long double value; } x = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
671 { LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) }; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
672 size_t length; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
673 char *result = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
674 my_asnprintf (NULL, &length, "%La %d", x.value, 33, 44, 55); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
675 ASSERT (result != NULL); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
676 ASSERT (strlen (result) >= 3 + 3 |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
677 && strisnan (result, 0, strlen (result) - 3, 0) |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
678 && strcmp (result + strlen (result) - 3, " 33") == 0); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
679 ASSERT (length == strlen (result)); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
680 free (result); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
681 } |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
682 #endif |
8336
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
683 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
684 { /* Rounding near the decimal point. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
685 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
686 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
687 my_asnprintf (NULL, &length, "%.0La %d", 1.5L, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
688 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
689 ASSERT (strcmp (result, "0x2p+0 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
690 || strcmp (result, "0x3p-1 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
691 || strcmp (result, "0x6p-2 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
692 || strcmp (result, "0xcp-3 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
693 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
694 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
695 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
696 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
697 { /* Rounding with precision 0. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
698 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
699 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
700 my_asnprintf (NULL, &length, "%.0La %d", 1.51L, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
701 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
702 ASSERT (strcmp (result, "0x2p+0 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
703 || strcmp (result, "0x3p-1 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
704 || strcmp (result, "0x6p-2 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
705 || strcmp (result, "0xcp-3 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
706 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
707 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
708 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
709 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
710 { /* Rounding with precision 1. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
711 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
712 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
713 my_asnprintf (NULL, &length, "%.1La %d", 1.51L, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
714 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
715 ASSERT (strcmp (result, "0x1.8p+0 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
716 || strcmp (result, "0x3.0p-1 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
717 || strcmp (result, "0x6.1p-2 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
718 || strcmp (result, "0xc.1p-3 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
719 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
720 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
721 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
722 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
723 { /* Rounding with precision 2. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
724 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
725 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
726 my_asnprintf (NULL, &length, "%.2La %d", 1.51L, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
727 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
728 ASSERT (strcmp (result, "0x1.83p+0 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
729 || strcmp (result, "0x3.05p-1 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
730 || strcmp (result, "0x6.0ap-2 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
731 || strcmp (result, "0xc.14p-3 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
732 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
733 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
734 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
735 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
736 { /* Rounding with precision 3. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
737 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
738 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
739 my_asnprintf (NULL, &length, "%.3La %d", 1.51L, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
740 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
741 ASSERT (strcmp (result, "0x1.829p+0 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
742 || strcmp (result, "0x3.052p-1 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
743 || strcmp (result, "0x6.0a4p-2 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
744 || strcmp (result, "0xc.148p-3 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
745 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
746 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
747 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
748 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
749 { /* Rounding can turn a ...FFF into a ...000. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
750 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
751 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
752 my_asnprintf (NULL, &length, "%.3La %d", 1.49999L, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
753 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
754 ASSERT (strcmp (result, "0x1.800p+0 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
755 || strcmp (result, "0x3.000p-1 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
756 || strcmp (result, "0x6.000p-2 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
757 || strcmp (result, "0xc.000p-3 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
758 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
759 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
760 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
761 |
8344
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8336
diff
changeset
|
762 { /* Rounding can turn a ...FFF into a ...000. |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8336
diff
changeset
|
763 This shows a MacOS X 10.3.9 (Darwin 7.9) bug and a |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8336
diff
changeset
|
764 glibc 2.4 bug <http://sourceware.org/bugzilla/show_bug.cgi?id=2908>. */ |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8336
diff
changeset
|
765 size_t length; |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8336
diff
changeset
|
766 char *result = |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8336
diff
changeset
|
767 my_asnprintf (NULL, &length, "%.1La %d", 1.999L, 33, 44, 55); |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8336
diff
changeset
|
768 ASSERT (result != NULL); |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8336
diff
changeset
|
769 ASSERT (strcmp (result, "0x1.0p+1 33") == 0 |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8336
diff
changeset
|
770 || strcmp (result, "0x2.0p+0 33") == 0 |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8336
diff
changeset
|
771 || strcmp (result, "0x4.0p-1 33") == 0 |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8336
diff
changeset
|
772 || strcmp (result, "0x8.0p-2 33") == 0); |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8336
diff
changeset
|
773 ASSERT (length == strlen (result)); |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8336
diff
changeset
|
774 free (result); |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8336
diff
changeset
|
775 } |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8336
diff
changeset
|
776 |
8336
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
777 { /* Width. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
778 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
779 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
780 my_asnprintf (NULL, &length, "%10La %d", 1.75L, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
781 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
782 ASSERT (strcmp (result, " 0x1.cp+0 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
783 || strcmp (result, " 0x3.8p-1 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
784 || strcmp (result, " 0x7p-2 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
785 || strcmp (result, " 0xep-3 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
786 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
787 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
788 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
789 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
790 { /* Small precision. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
791 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
792 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
793 my_asnprintf (NULL, &length, "%.10La %d", 1.75L, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
794 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
795 ASSERT (strcmp (result, "0x1.c000000000p+0 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
796 || strcmp (result, "0x3.8000000000p-1 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
797 || strcmp (result, "0x7.0000000000p-2 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
798 || strcmp (result, "0xe.0000000000p-3 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
799 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
800 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
801 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
802 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
803 { /* Large precision. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
804 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
805 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
806 my_asnprintf (NULL, &length, "%.50La %d", 1.75L, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
807 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
808 ASSERT (strcmp (result, "0x1.c0000000000000000000000000000000000000000000000000p+0 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
809 || strcmp (result, "0x3.80000000000000000000000000000000000000000000000000p-1 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
810 || strcmp (result, "0x7.00000000000000000000000000000000000000000000000000p-2 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
811 || strcmp (result, "0xe.00000000000000000000000000000000000000000000000000p-3 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
812 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
813 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
814 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
815 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
816 { /* FLAG_LEFT. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
817 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
818 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
819 my_asnprintf (NULL, &length, "%-10La %d", 1.75L, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
820 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
821 ASSERT (strcmp (result, "0x1.cp+0 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
822 || strcmp (result, "0x3.8p-1 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
823 || strcmp (result, "0x7p-2 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
824 || strcmp (result, "0xep-3 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
825 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
826 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
827 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
828 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
829 { /* FLAG_SHOWSIGN. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
830 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
831 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
832 my_asnprintf (NULL, &length, "%+La %d", 1.75L, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
833 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
834 ASSERT (strcmp (result, "+0x1.cp+0 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
835 || strcmp (result, "+0x3.8p-1 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
836 || strcmp (result, "+0x7p-2 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
837 || strcmp (result, "+0xep-3 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
838 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
839 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
840 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
841 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
842 { /* FLAG_SPACE. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
843 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
844 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
845 my_asnprintf (NULL, &length, "% La %d", 1.75L, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
846 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
847 ASSERT (strcmp (result, " 0x1.cp+0 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
848 || strcmp (result, " 0x3.8p-1 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
849 || strcmp (result, " 0x7p-2 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
850 || strcmp (result, " 0xep-3 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
851 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
852 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
853 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
854 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
855 { /* FLAG_ALT. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
856 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
857 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
858 my_asnprintf (NULL, &length, "%#La %d", 1.75L, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
859 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
860 ASSERT (strcmp (result, "0x1.cp+0 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
861 || strcmp (result, "0x3.8p-1 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
862 || strcmp (result, "0x7.p-2 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
863 || strcmp (result, "0xe.p-3 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
864 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
865 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
866 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
867 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
868 { /* FLAG_ALT. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
869 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
870 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
871 my_asnprintf (NULL, &length, "%#La %d", 1.0L, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
872 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
873 ASSERT (strcmp (result, "0x1.p+0 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
874 || strcmp (result, "0x2.p-1 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
875 || strcmp (result, "0x4.p-2 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
876 || strcmp (result, "0x8.p-3 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
877 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
878 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
879 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
880 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
881 { /* FLAG_ZERO with finite number. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
882 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
883 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
884 my_asnprintf (NULL, &length, "%010La %d", 1.75L, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
885 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
886 ASSERT (strcmp (result, "0x001.cp+0 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
887 || strcmp (result, "0x003.8p-1 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
888 || strcmp (result, "0x00007p-2 33") == 0 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
889 || strcmp (result, "0x0000ep-3 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
890 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
891 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
892 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
893 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
894 { /* FLAG_ZERO with infinite number. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
895 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
896 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
897 my_asnprintf (NULL, &length, "%010La %d", 1.0L / 0.0L, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
898 ASSERT (result != NULL); |
8662
023aa5c883a7
Guard against FreeBSD 6.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
8648
diff
changeset
|
899 /* "0000000inf 33" is not a valid result; see |
023aa5c883a7
Guard against FreeBSD 6.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
8648
diff
changeset
|
900 <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */ |
023aa5c883a7
Guard against FreeBSD 6.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
8648
diff
changeset
|
901 ASSERT (strcmp (result, " inf 33") == 0); |
8336
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
902 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
903 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
904 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
905 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
906 { /* FLAG_ZERO with NaN. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
907 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
908 char *result = |
8870
4e1f2ea486b4
Allow for a longer printed representation of NaN.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
909 my_asnprintf (NULL, &length, "%050La %d", 0.0L / 0.0L, 33, 44, 55); |
8336
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
910 ASSERT (result != NULL); |
8662
023aa5c883a7
Guard against FreeBSD 6.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
8648
diff
changeset
|
911 /* "0000000nan 33" is not a valid result; see |
023aa5c883a7
Guard against FreeBSD 6.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
8648
diff
changeset
|
912 <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */ |
8870
4e1f2ea486b4
Allow for a longer printed representation of NaN.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
913 ASSERT (strlen (result) == 50 + 3 |
8865
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8857
diff
changeset
|
914 && strisnan (result, strspn (result, " "), strlen (result) - 3, 0) |
8850
d1fe16dfbfee
Avoid test failures on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents:
8839
diff
changeset
|
915 && strcmp (result + strlen (result) - 3, " 33") == 0); |
8336
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
916 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
917 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
918 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
919 |
8684
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
920 /* Test the support of the %f format directive. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
921 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
922 { /* A positive number. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
923 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
924 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
925 my_asnprintf (NULL, &length, "%f %d", 12.75, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
926 ASSERT (result != NULL); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
927 ASSERT (strcmp (result, "12.750000 33") == 0); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
928 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
929 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
930 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
931 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
932 { /* A larger positive number. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
933 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
934 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
935 my_asnprintf (NULL, &length, "%f %d", 1234567.0, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
936 ASSERT (result != NULL); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
937 ASSERT (strcmp (result, "1234567.000000 33") == 0); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
938 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
939 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
940 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
941 |
8834 | 942 { /* Small and large positive numbers. */ |
943 static struct { double value; const char *string; } data[] = | |
944 { | |
945 { 1.234321234321234e-37, "0.000000" }, | |
946 { 1.234321234321234e-36, "0.000000" }, | |
947 { 1.234321234321234e-35, "0.000000" }, | |
948 { 1.234321234321234e-34, "0.000000" }, | |
949 { 1.234321234321234e-33, "0.000000" }, | |
950 { 1.234321234321234e-32, "0.000000" }, | |
951 { 1.234321234321234e-31, "0.000000" }, | |
952 { 1.234321234321234e-30, "0.000000" }, | |
953 { 1.234321234321234e-29, "0.000000" }, | |
954 { 1.234321234321234e-28, "0.000000" }, | |
955 { 1.234321234321234e-27, "0.000000" }, | |
956 { 1.234321234321234e-26, "0.000000" }, | |
957 { 1.234321234321234e-25, "0.000000" }, | |
958 { 1.234321234321234e-24, "0.000000" }, | |
959 { 1.234321234321234e-23, "0.000000" }, | |
960 { 1.234321234321234e-22, "0.000000" }, | |
961 { 1.234321234321234e-21, "0.000000" }, | |
962 { 1.234321234321234e-20, "0.000000" }, | |
963 { 1.234321234321234e-19, "0.000000" }, | |
964 { 1.234321234321234e-18, "0.000000" }, | |
965 { 1.234321234321234e-17, "0.000000" }, | |
966 { 1.234321234321234e-16, "0.000000" }, | |
967 { 1.234321234321234e-15, "0.000000" }, | |
968 { 1.234321234321234e-14, "0.000000" }, | |
969 { 1.234321234321234e-13, "0.000000" }, | |
970 { 1.234321234321234e-12, "0.000000" }, | |
971 { 1.234321234321234e-11, "0.000000" }, | |
972 { 1.234321234321234e-10, "0.000000" }, | |
973 { 1.234321234321234e-9, "0.000000" }, | |
974 { 1.234321234321234e-8, "0.000000" }, | |
975 { 1.234321234321234e-7, "0.000000" }, | |
976 { 1.234321234321234e-6, "0.000001" }, | |
977 { 1.234321234321234e-5, "0.000012" }, | |
978 { 1.234321234321234e-4, "0.000123" }, | |
979 { 1.234321234321234e-3, "0.001234" }, | |
980 { 1.234321234321234e-2, "0.012343" }, | |
981 { 1.234321234321234e-1, "0.123432" }, | |
982 { 1.234321234321234, "1.234321" }, | |
983 { 1.234321234321234e1, "12.343212" }, | |
984 { 1.234321234321234e2, "123.432123" }, | |
985 { 1.234321234321234e3, "1234.321234" }, | |
986 { 1.234321234321234e4, "12343.212343" }, | |
987 { 1.234321234321234e5, "123432.123432" }, | |
988 { 1.234321234321234e6, "1234321.234321" }, | |
989 { 1.234321234321234e7, "12343212.343212" }, | |
990 { 1.234321234321234e8, "123432123.432123" }, | |
991 { 1.234321234321234e9, "1234321234.321234" }, | |
992 { 1.234321234321234e10, "12343212343.2123**" }, | |
993 { 1.234321234321234e11, "123432123432.123***" }, | |
994 { 1.234321234321234e12, "1234321234321.23****" }, | |
995 { 1.234321234321234e13, "12343212343212.3*****" }, | |
996 { 1.234321234321234e14, "123432123432123.******" }, | |
997 { 1.234321234321234e15, "1234321234321234.000000" }, | |
998 { 1.234321234321234e16, "123432123432123**.000000" }, | |
999 { 1.234321234321234e17, "123432123432123***.000000" }, | |
1000 { 1.234321234321234e18, "123432123432123****.000000" }, | |
1001 { 1.234321234321234e19, "123432123432123*****.000000" }, | |
1002 { 1.234321234321234e20, "123432123432123******.000000" }, | |
1003 { 1.234321234321234e21, "123432123432123*******.000000" }, | |
1004 { 1.234321234321234e22, "123432123432123********.000000" }, | |
1005 { 1.234321234321234e23, "123432123432123*********.000000" }, | |
1006 { 1.234321234321234e24, "123432123432123**********.000000" }, | |
1007 { 1.234321234321234e25, "123432123432123***********.000000" }, | |
1008 { 1.234321234321234e26, "123432123432123************.000000" }, | |
1009 { 1.234321234321234e27, "123432123432123*************.000000" }, | |
1010 { 1.234321234321234e28, "123432123432123**************.000000" }, | |
1011 { 1.234321234321234e29, "123432123432123***************.000000" }, | |
1012 { 1.234321234321234e30, "123432123432123****************.000000" }, | |
1013 { 1.234321234321234e31, "123432123432123*****************.000000" }, | |
1014 { 1.234321234321234e32, "123432123432123******************.000000" }, | |
1015 { 1.234321234321234e33, "123432123432123*******************.000000" }, | |
1016 { 1.234321234321234e34, "123432123432123********************.000000" }, | |
1017 { 1.234321234321234e35, "123432123432123*********************.000000" }, | |
1018 { 1.234321234321234e36, "123432123432123**********************.000000" } | |
1019 }; | |
1020 size_t k; | |
1021 for (k = 0; k < SIZEOF (data); k++) | |
1022 { | |
1023 size_t length; | |
1024 char *result = | |
1025 my_asnprintf (NULL, &length, "%f", data[k].value); | |
1026 ASSERT (result != NULL); | |
1027 ASSERT (strmatch (data[k].string, result)); | |
1028 ASSERT (length == strlen (result)); | |
1029 free (result); | |
1030 } | |
1031 } | |
1032 | |
8684
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1033 { /* A negative number. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1034 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1035 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1036 my_asnprintf (NULL, &length, "%f %d", -0.03125, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1037 ASSERT (result != NULL); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1038 ASSERT (strcmp (result, "-0.031250 33") == 0); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1039 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1040 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1041 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1042 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1043 { /* Positive zero. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1044 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1045 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1046 my_asnprintf (NULL, &length, "%f %d", 0.0, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1047 ASSERT (result != NULL); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1048 ASSERT (strcmp (result, "0.000000 33") == 0); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1049 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1050 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1051 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1052 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1053 { /* Negative zero. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1054 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1055 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1056 my_asnprintf (NULL, &length, "%f %d", -0.0, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1057 ASSERT (result != NULL); |
8852
df0b5e8ea770
Avoid test failures on platforms where -0.0 and 0.0 are identical.
Bruno Haible <bruno@clisp.org>
parents:
8850
diff
changeset
|
1058 if (have_minus_zero ()) |
df0b5e8ea770
Avoid test failures on platforms where -0.0 and 0.0 are identical.
Bruno Haible <bruno@clisp.org>
parents:
8850
diff
changeset
|
1059 ASSERT (strcmp (result, "-0.000000 33") == 0); |
8684
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1060 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1061 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1062 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1063 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1064 { /* Positive infinity. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1065 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1066 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1067 my_asnprintf (NULL, &length, "%f %d", 1.0 / 0.0, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1068 ASSERT (result != NULL); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1069 ASSERT (strcmp (result, "inf 33") == 0 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1070 || strcmp (result, "infinity 33") == 0); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1071 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1072 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1073 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1074 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1075 { /* Negative infinity. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1076 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1077 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1078 my_asnprintf (NULL, &length, "%f %d", -1.0 / 0.0, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1079 ASSERT (result != NULL); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1080 ASSERT (strcmp (result, "-inf 33") == 0 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1081 || strcmp (result, "-infinity 33") == 0); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1082 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1083 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1084 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1085 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1086 { /* NaN. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1087 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1088 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1089 my_asnprintf (NULL, &length, "%f %d", NaN (), 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1090 ASSERT (result != NULL); |
8850
d1fe16dfbfee
Avoid test failures on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents:
8839
diff
changeset
|
1091 ASSERT (strlen (result) >= 3 + 3 |
8865
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8857
diff
changeset
|
1092 && strisnan (result, 0, strlen (result) - 3, 0) |
8850
d1fe16dfbfee
Avoid test failures on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents:
8839
diff
changeset
|
1093 && strcmp (result + strlen (result) - 3, " 33") == 0); |
8684
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1094 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1095 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1096 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1097 |
8804
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1098 { /* Width. */ |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1099 size_t length; |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1100 char *result = |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1101 my_asnprintf (NULL, &length, "%10f %d", 1.75, 33, 44, 55); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1102 ASSERT (result != NULL); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1103 ASSERT (strcmp (result, " 1.750000 33") == 0); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1104 ASSERT (length == strlen (result)); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1105 free (result); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1106 } |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1107 |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1108 { /* FLAG_LEFT. */ |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1109 size_t length; |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1110 char *result = |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1111 my_asnprintf (NULL, &length, "%-10f %d", 1.75, 33, 44, 55); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1112 ASSERT (result != NULL); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1113 ASSERT (strcmp (result, "1.750000 33") == 0); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1114 ASSERT (length == strlen (result)); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1115 free (result); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1116 } |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1117 |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1118 { /* FLAG_SHOWSIGN. */ |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1119 size_t length; |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1120 char *result = |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1121 my_asnprintf (NULL, &length, "%+f %d", 1.75, 33, 44, 55); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1122 ASSERT (result != NULL); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1123 ASSERT (strcmp (result, "+1.750000 33") == 0); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1124 ASSERT (length == strlen (result)); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1125 free (result); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1126 } |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1127 |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1128 { /* FLAG_SPACE. */ |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1129 size_t length; |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1130 char *result = |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1131 my_asnprintf (NULL, &length, "% f %d", 1.75, 33, 44, 55); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1132 ASSERT (result != NULL); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1133 ASSERT (strcmp (result, " 1.750000 33") == 0); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1134 ASSERT (length == strlen (result)); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1135 free (result); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1136 } |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1137 |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1138 { /* FLAG_ALT. */ |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1139 size_t length; |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1140 char *result = |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1141 my_asnprintf (NULL, &length, "%#f %d", 1.75, 33, 44, 55); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1142 ASSERT (result != NULL); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1143 ASSERT (strcmp (result, "1.750000 33") == 0); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1144 ASSERT (length == strlen (result)); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1145 free (result); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1146 } |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1147 |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1148 { /* FLAG_ALT. */ |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1149 size_t length; |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1150 char *result = |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1151 my_asnprintf (NULL, &length, "%#.f %d", 1.75, 33, 44, 55); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1152 ASSERT (result != NULL); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1153 ASSERT (strcmp (result, "2. 33") == 0); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1154 ASSERT (length == strlen (result)); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1155 free (result); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1156 } |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1157 |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1158 { /* FLAG_ZERO with finite number. */ |
8684
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1159 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1160 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1161 my_asnprintf (NULL, &length, "%015f %d", 1234.0, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1162 ASSERT (result != NULL); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1163 ASSERT (strcmp (result, "00001234.000000 33") == 0); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1164 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1165 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1166 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1167 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1168 { /* FLAG_ZERO with infinite number. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1169 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1170 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1171 my_asnprintf (NULL, &length, "%015f %d", -1.0 / 0.0, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1172 ASSERT (result != NULL); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1173 ASSERT (strcmp (result, " -inf 33") == 0 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1174 || strcmp (result, " -infinity 33") == 0); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1175 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1176 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1177 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1178 |
8804
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1179 { /* FLAG_ZERO with NaN. */ |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1180 size_t length; |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1181 char *result = |
8870
4e1f2ea486b4
Allow for a longer printed representation of NaN.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
1182 my_asnprintf (NULL, &length, "%050f %d", NaN (), 33, 44, 55); |
8804
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1183 ASSERT (result != NULL); |
8870
4e1f2ea486b4
Allow for a longer printed representation of NaN.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
1184 ASSERT (strlen (result) == 50 + 3 |
8865
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8857
diff
changeset
|
1185 && strisnan (result, strspn (result, " "), strlen (result) - 3, 0) |
8850
d1fe16dfbfee
Avoid test failures on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents:
8839
diff
changeset
|
1186 && strcmp (result + strlen (result) - 3, " 33") == 0); |
8804
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1187 ASSERT (length == strlen (result)); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1188 free (result); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1189 } |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1190 |
8684
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1191 { /* Precision. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1192 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1193 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1194 my_asnprintf (NULL, &length, "%.f %d", 1234.0, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1195 ASSERT (result != NULL); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1196 ASSERT (strcmp (result, "1234 33") == 0); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1197 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1198 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1199 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1200 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1201 { /* A positive number. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1202 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1203 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1204 my_asnprintf (NULL, &length, "%Lf %d", 12.75L, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1205 ASSERT (result != NULL); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1206 ASSERT (strcmp (result, "12.750000 33") == 0); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1207 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1208 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1209 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1210 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1211 { /* A larger positive number. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1212 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1213 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1214 my_asnprintf (NULL, &length, "%Lf %d", 1234567.0L, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1215 ASSERT (result != NULL); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1216 ASSERT (strcmp (result, "1234567.000000 33") == 0); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1217 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1218 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1219 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1220 |
8834 | 1221 { /* Small and large positive numbers. */ |
1222 static struct { long double value; const char *string; } data[] = | |
1223 { | |
1224 { 1.234321234321234e-37L, "0.000000" }, | |
1225 { 1.234321234321234e-36L, "0.000000" }, | |
1226 { 1.234321234321234e-35L, "0.000000" }, | |
1227 { 1.234321234321234e-34L, "0.000000" }, | |
1228 { 1.234321234321234e-33L, "0.000000" }, | |
1229 { 1.234321234321234e-32L, "0.000000" }, | |
1230 { 1.234321234321234e-31L, "0.000000" }, | |
1231 { 1.234321234321234e-30L, "0.000000" }, | |
1232 { 1.234321234321234e-29L, "0.000000" }, | |
1233 { 1.234321234321234e-28L, "0.000000" }, | |
1234 { 1.234321234321234e-27L, "0.000000" }, | |
1235 { 1.234321234321234e-26L, "0.000000" }, | |
1236 { 1.234321234321234e-25L, "0.000000" }, | |
1237 { 1.234321234321234e-24L, "0.000000" }, | |
1238 { 1.234321234321234e-23L, "0.000000" }, | |
1239 { 1.234321234321234e-22L, "0.000000" }, | |
1240 { 1.234321234321234e-21L, "0.000000" }, | |
1241 { 1.234321234321234e-20L, "0.000000" }, | |
1242 { 1.234321234321234e-19L, "0.000000" }, | |
1243 { 1.234321234321234e-18L, "0.000000" }, | |
1244 { 1.234321234321234e-17L, "0.000000" }, | |
1245 { 1.234321234321234e-16L, "0.000000" }, | |
1246 { 1.234321234321234e-15L, "0.000000" }, | |
1247 { 1.234321234321234e-14L, "0.000000" }, | |
1248 { 1.234321234321234e-13L, "0.000000" }, | |
1249 { 1.234321234321234e-12L, "0.000000" }, | |
1250 { 1.234321234321234e-11L, "0.000000" }, | |
1251 { 1.234321234321234e-10L, "0.000000" }, | |
1252 { 1.234321234321234e-9L, "0.000000" }, | |
1253 { 1.234321234321234e-8L, "0.000000" }, | |
1254 { 1.234321234321234e-7L, "0.000000" }, | |
1255 { 1.234321234321234e-6L, "0.000001" }, | |
1256 { 1.234321234321234e-5L, "0.000012" }, | |
1257 { 1.234321234321234e-4L, "0.000123" }, | |
1258 { 1.234321234321234e-3L, "0.001234" }, | |
1259 { 1.234321234321234e-2L, "0.012343" }, | |
1260 { 1.234321234321234e-1L, "0.123432" }, | |
1261 { 1.234321234321234L, "1.234321" }, | |
1262 { 1.234321234321234e1L, "12.343212" }, | |
1263 { 1.234321234321234e2L, "123.432123" }, | |
1264 { 1.234321234321234e3L, "1234.321234" }, | |
1265 { 1.234321234321234e4L, "12343.212343" }, | |
1266 { 1.234321234321234e5L, "123432.123432" }, | |
1267 { 1.234321234321234e6L, "1234321.234321" }, | |
1268 { 1.234321234321234e7L, "12343212.343212" }, | |
1269 { 1.234321234321234e8L, "123432123.432123" }, | |
1270 { 1.234321234321234e9L, "1234321234.321234" }, | |
1271 { 1.234321234321234e10L, "12343212343.2123**" }, | |
1272 { 1.234321234321234e11L, "123432123432.123***" }, | |
1273 { 1.234321234321234e12L, "1234321234321.23****" }, | |
1274 { 1.234321234321234e13L, "12343212343212.3*****" }, | |
1275 { 1.234321234321234e14L, "123432123432123.******" }, | |
1276 { 1.234321234321234e15L, "1234321234321234.000000" }, | |
1277 { 1.234321234321234e16L, "123432123432123**.000000" }, | |
1278 { 1.234321234321234e17L, "123432123432123***.000000" }, | |
1279 { 1.234321234321234e18L, "123432123432123****.000000" }, | |
1280 { 1.234321234321234e19L, "123432123432123*****.000000" }, | |
1281 { 1.234321234321234e20L, "123432123432123******.000000" }, | |
1282 { 1.234321234321234e21L, "123432123432123*******.000000" }, | |
1283 { 1.234321234321234e22L, "123432123432123********.000000" }, | |
1284 { 1.234321234321234e23L, "123432123432123*********.000000" }, | |
1285 { 1.234321234321234e24L, "123432123432123**********.000000" }, | |
1286 { 1.234321234321234e25L, "123432123432123***********.000000" }, | |
1287 { 1.234321234321234e26L, "123432123432123************.000000" }, | |
1288 { 1.234321234321234e27L, "123432123432123*************.000000" }, | |
1289 { 1.234321234321234e28L, "123432123432123**************.000000" }, | |
1290 { 1.234321234321234e29L, "123432123432123***************.000000" }, | |
1291 { 1.234321234321234e30L, "123432123432123****************.000000" }, | |
1292 { 1.234321234321234e31L, "123432123432123*****************.000000" }, | |
1293 { 1.234321234321234e32L, "123432123432123******************.000000" }, | |
1294 { 1.234321234321234e33L, "123432123432123*******************.000000" }, | |
1295 { 1.234321234321234e34L, "123432123432123********************.000000" }, | |
1296 { 1.234321234321234e35L, "123432123432123*********************.000000" }, | |
1297 { 1.234321234321234e36L, "123432123432123**********************.000000" } | |
1298 }; | |
1299 size_t k; | |
1300 for (k = 0; k < SIZEOF (data); k++) | |
1301 { | |
1302 size_t length; | |
1303 char *result = | |
1304 my_asnprintf (NULL, &length, "%Lf", data[k].value); | |
1305 ASSERT (result != NULL); | |
1306 ASSERT (strmatch (data[k].string, result)); | |
1307 ASSERT (length == strlen (result)); | |
1308 free (result); | |
1309 } | |
1310 } | |
1311 | |
8684
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1312 { /* A negative number. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1313 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1314 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1315 my_asnprintf (NULL, &length, "%Lf %d", -0.03125L, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1316 ASSERT (result != NULL); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1317 ASSERT (strcmp (result, "-0.031250 33") == 0); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1318 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1319 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1320 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1321 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1322 { /* Positive zero. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1323 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1324 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1325 my_asnprintf (NULL, &length, "%Lf %d", 0.0L, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1326 ASSERT (result != NULL); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1327 ASSERT (strcmp (result, "0.000000 33") == 0); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1328 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1329 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1330 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1331 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1332 { /* Negative zero. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1333 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1334 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1335 my_asnprintf (NULL, &length, "%Lf %d", -0.0L, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1336 ASSERT (result != NULL); |
8852
df0b5e8ea770
Avoid test failures on platforms where -0.0 and 0.0 are identical.
Bruno Haible <bruno@clisp.org>
parents:
8850
diff
changeset
|
1337 if (have_minus_zero ()) |
df0b5e8ea770
Avoid test failures on platforms where -0.0 and 0.0 are identical.
Bruno Haible <bruno@clisp.org>
parents:
8850
diff
changeset
|
1338 ASSERT (strcmp (result, "-0.000000 33") == 0); |
8684
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1339 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1340 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1341 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1342 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1343 { /* Positive infinity. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1344 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1345 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1346 my_asnprintf (NULL, &length, "%Lf %d", 1.0L / 0.0L, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1347 ASSERT (result != NULL); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1348 ASSERT (strcmp (result, "inf 33") == 0 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1349 || strcmp (result, "infinity 33") == 0); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1350 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1351 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1352 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1353 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1354 { /* Negative infinity. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1355 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1356 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1357 my_asnprintf (NULL, &length, "%Lf %d", -1.0L / 0.0L, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1358 ASSERT (result != NULL); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1359 ASSERT (strcmp (result, "-inf 33") == 0 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1360 || strcmp (result, "-infinity 33") == 0); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1361 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1362 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1363 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1364 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1365 { /* NaN. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1366 static long double zero = 0.0L; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1367 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1368 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1369 my_asnprintf (NULL, &length, "%Lf %d", zero / zero, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1370 ASSERT (result != NULL); |
8850
d1fe16dfbfee
Avoid test failures on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents:
8839
diff
changeset
|
1371 ASSERT (strlen (result) >= 3 + 3 |
8865
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8857
diff
changeset
|
1372 && strisnan (result, 0, strlen (result) - 3, 0) |
8850
d1fe16dfbfee
Avoid test failures on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents:
8839
diff
changeset
|
1373 && strcmp (result + strlen (result) - 3, " 33") == 0); |
8684
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1374 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1375 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1376 } |
8919
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1377 #if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1378 { /* Quiet NaN. */ |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1379 static union { unsigned int word[4]; long double value; } x = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1380 { LDBL80_WORDS (0xFFFF, 0xC3333333, 0x00000000) }; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1381 size_t length; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1382 char *result = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1383 my_asnprintf (NULL, &length, "%Lf %d", x.value, 33, 44, 55); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1384 ASSERT (result != NULL); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1385 ASSERT (strlen (result) >= 3 + 3 |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1386 && strisnan (result, 0, strlen (result) - 3, 0) |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1387 && strcmp (result + strlen (result) - 3, " 33") == 0); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1388 ASSERT (length == strlen (result)); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1389 free (result); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1390 } |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1391 { |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1392 /* Signalling NaN. */ |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1393 static union { unsigned int word[4]; long double value; } x = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1394 { LDBL80_WORDS (0xFFFF, 0x83333333, 0x00000000) }; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1395 size_t length; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1396 char *result = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1397 my_asnprintf (NULL, &length, "%Lf %d", x.value, 33, 44, 55); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1398 ASSERT (result != NULL); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1399 ASSERT (strlen (result) >= 3 + 3 |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1400 && strisnan (result, 0, strlen (result) - 3, 0) |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1401 && strcmp (result + strlen (result) - 3, " 33") == 0); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1402 ASSERT (length == strlen (result)); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1403 free (result); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1404 } |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1405 /* The isnanl function should recognize Pseudo-NaNs, Pseudo-Infinities, |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1406 Pseudo-Zeroes, Unnormalized Numbers, and Pseudo-Denormals, as defined in |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1407 Intel IA-64 Architecture Software Developer's Manual, Volume 1: |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1408 Application Architecture. |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1409 Table 5-2 "Floating-Point Register Encodings" |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1410 Figure 5-6 "Memory to Floating-Point Register Data Translation" |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1411 */ |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1412 { /* Pseudo-NaN. */ |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1413 static union { unsigned int word[4]; long double value; } x = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1414 { LDBL80_WORDS (0xFFFF, 0x40000001, 0x00000000) }; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1415 size_t length; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1416 char *result = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1417 my_asnprintf (NULL, &length, "%Lf %d", x.value, 33, 44, 55); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1418 ASSERT (result != NULL); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1419 ASSERT (strlen (result) >= 3 + 3 |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1420 && strisnan (result, 0, strlen (result) - 3, 0) |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1421 && strcmp (result + strlen (result) - 3, " 33") == 0); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1422 ASSERT (length == strlen (result)); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1423 free (result); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1424 } |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1425 { /* Pseudo-Infinity. */ |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1426 static union { unsigned int word[4]; long double value; } x = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1427 { LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) }; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1428 size_t length; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1429 char *result = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1430 my_asnprintf (NULL, &length, "%Lf %d", x.value, 33, 44, 55); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1431 ASSERT (result != NULL); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1432 ASSERT (strlen (result) >= 3 + 3 |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1433 && strisnan (result, 0, strlen (result) - 3, 0) |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1434 && strcmp (result + strlen (result) - 3, " 33") == 0); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1435 ASSERT (length == strlen (result)); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1436 free (result); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1437 } |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1438 { /* Pseudo-Zero. */ |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1439 static union { unsigned int word[4]; long double value; } x = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1440 { LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) }; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1441 size_t length; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1442 char *result = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1443 my_asnprintf (NULL, &length, "%Lf %d", x.value, 33, 44, 55); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1444 ASSERT (result != NULL); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1445 ASSERT (strlen (result) >= 3 + 3 |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1446 && strisnan (result, 0, strlen (result) - 3, 0) |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1447 && strcmp (result + strlen (result) - 3, " 33") == 0); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1448 ASSERT (length == strlen (result)); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1449 free (result); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1450 } |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1451 { /* Unnormalized number. */ |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1452 static union { unsigned int word[4]; long double value; } x = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1453 { LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) }; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1454 size_t length; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1455 char *result = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1456 my_asnprintf (NULL, &length, "%Lf %d", x.value, 33, 44, 55); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1457 ASSERT (result != NULL); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1458 ASSERT (strlen (result) >= 3 + 3 |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1459 && strisnan (result, 0, strlen (result) - 3, 0) |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1460 && strcmp (result + strlen (result) - 3, " 33") == 0); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1461 ASSERT (length == strlen (result)); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1462 free (result); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1463 } |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1464 { /* Pseudo-Denormal. */ |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1465 static union { unsigned int word[4]; long double value; } x = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1466 { LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) }; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1467 size_t length; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1468 char *result = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1469 my_asnprintf (NULL, &length, "%Lf %d", x.value, 33, 44, 55); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1470 ASSERT (result != NULL); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1471 ASSERT (strlen (result) >= 3 + 3 |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1472 && strisnan (result, 0, strlen (result) - 3, 0) |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1473 && strcmp (result + strlen (result) - 3, " 33") == 0); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1474 ASSERT (length == strlen (result)); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1475 free (result); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1476 } |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
1477 #endif |
8684
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1478 |
8804
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1479 { /* Width. */ |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1480 size_t length; |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1481 char *result = |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1482 my_asnprintf (NULL, &length, "%10Lf %d", 1.75L, 33, 44, 55); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1483 ASSERT (result != NULL); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1484 ASSERT (strcmp (result, " 1.750000 33") == 0); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1485 ASSERT (length == strlen (result)); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1486 free (result); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1487 } |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1488 |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1489 { /* FLAG_LEFT. */ |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1490 size_t length; |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1491 char *result = |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1492 my_asnprintf (NULL, &length, "%-10Lf %d", 1.75L, 33, 44, 55); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1493 ASSERT (result != NULL); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1494 ASSERT (strcmp (result, "1.750000 33") == 0); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1495 ASSERT (length == strlen (result)); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1496 free (result); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1497 } |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1498 |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1499 { /* FLAG_SHOWSIGN. */ |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1500 size_t length; |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1501 char *result = |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1502 my_asnprintf (NULL, &length, "%+Lf %d", 1.75L, 33, 44, 55); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1503 ASSERT (result != NULL); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1504 ASSERT (strcmp (result, "+1.750000 33") == 0); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1505 ASSERT (length == strlen (result)); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1506 free (result); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1507 } |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1508 |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1509 { /* FLAG_SPACE. */ |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1510 size_t length; |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1511 char *result = |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1512 my_asnprintf (NULL, &length, "% Lf %d", 1.75L, 33, 44, 55); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1513 ASSERT (result != NULL); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1514 ASSERT (strcmp (result, " 1.750000 33") == 0); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1515 ASSERT (length == strlen (result)); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1516 free (result); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1517 } |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1518 |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1519 { /* FLAG_ALT. */ |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1520 size_t length; |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1521 char *result = |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1522 my_asnprintf (NULL, &length, "%#Lf %d", 1.75L, 33, 44, 55); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1523 ASSERT (result != NULL); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1524 ASSERT (strcmp (result, "1.750000 33") == 0); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1525 ASSERT (length == strlen (result)); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1526 free (result); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1527 } |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1528 |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1529 { /* FLAG_ALT. */ |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1530 size_t length; |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1531 char *result = |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1532 my_asnprintf (NULL, &length, "%#.Lf %d", 1.75L, 33, 44, 55); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1533 ASSERT (result != NULL); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1534 ASSERT (strcmp (result, "2. 33") == 0); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1535 ASSERT (length == strlen (result)); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1536 free (result); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1537 } |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1538 |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1539 { /* FLAG_ZERO with finite number. */ |
8684
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1540 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1541 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1542 my_asnprintf (NULL, &length, "%015Lf %d", 1234.0L, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1543 ASSERT (result != NULL); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1544 ASSERT (strcmp (result, "00001234.000000 33") == 0); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1545 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1546 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1547 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1548 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1549 { /* FLAG_ZERO with infinite number. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1550 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1551 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1552 my_asnprintf (NULL, &length, "%015Lf %d", -1.0L / 0.0L, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1553 ASSERT (result != NULL); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1554 ASSERT (strcmp (result, " -inf 33") == 0 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1555 || strcmp (result, " -infinity 33") == 0); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1556 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1557 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1558 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1559 |
8804
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1560 { /* FLAG_ZERO with NaN. */ |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1561 static long double zero = 0.0L; |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1562 size_t length; |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1563 char *result = |
8870
4e1f2ea486b4
Allow for a longer printed representation of NaN.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
1564 my_asnprintf (NULL, &length, "%050Lf %d", zero / zero, 33, 44, 55); |
8804
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1565 ASSERT (result != NULL); |
8870
4e1f2ea486b4
Allow for a longer printed representation of NaN.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
1566 ASSERT (strlen (result) == 50 + 3 |
8865
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8857
diff
changeset
|
1567 && strisnan (result, strspn (result, " "), strlen (result) - 3, 0) |
8850
d1fe16dfbfee
Avoid test failures on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents:
8839
diff
changeset
|
1568 && strcmp (result + strlen (result) - 3, " 33") == 0); |
8804
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1569 ASSERT (length == strlen (result)); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1570 free (result); |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1571 } |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
1572 |
8684
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1573 { /* Precision. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1574 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1575 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1576 my_asnprintf (NULL, &length, "%.Lf %d", 1234.0L, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1577 ASSERT (result != NULL); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1578 ASSERT (strcmp (result, "1234 33") == 0); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1579 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1580 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1581 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1582 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1583 /* Test the support of the %F format directive. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1584 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1585 { /* A positive number. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1586 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1587 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1588 my_asnprintf (NULL, &length, "%F %d", 12.75, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1589 ASSERT (result != NULL); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1590 ASSERT (strcmp (result, "12.750000 33") == 0); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1591 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1592 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1593 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1594 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1595 { /* A larger positive number. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1596 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1597 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1598 my_asnprintf (NULL, &length, "%F %d", 1234567.0, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1599 ASSERT (result != NULL); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1600 ASSERT (strcmp (result, "1234567.000000 33") == 0); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1601 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1602 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1603 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1604 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1605 { /* A negative number. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1606 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1607 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1608 my_asnprintf (NULL, &length, "%F %d", -0.03125, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1609 ASSERT (result != NULL); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1610 ASSERT (strcmp (result, "-0.031250 33") == 0); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1611 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1612 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1613 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1614 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1615 { /* Positive zero. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1616 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1617 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1618 my_asnprintf (NULL, &length, "%F %d", 0.0, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1619 ASSERT (result != NULL); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1620 ASSERT (strcmp (result, "0.000000 33") == 0); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1621 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1622 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1623 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1624 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1625 { /* Negative zero. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1626 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1627 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1628 my_asnprintf (NULL, &length, "%F %d", -0.0, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1629 ASSERT (result != NULL); |
8852
df0b5e8ea770
Avoid test failures on platforms where -0.0 and 0.0 are identical.
Bruno Haible <bruno@clisp.org>
parents:
8850
diff
changeset
|
1630 if (have_minus_zero ()) |
df0b5e8ea770
Avoid test failures on platforms where -0.0 and 0.0 are identical.
Bruno Haible <bruno@clisp.org>
parents:
8850
diff
changeset
|
1631 ASSERT (strcmp (result, "-0.000000 33") == 0); |
8684
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1632 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1633 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1634 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1635 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1636 { /* Positive infinity. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1637 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1638 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1639 my_asnprintf (NULL, &length, "%F %d", 1.0 / 0.0, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1640 ASSERT (result != NULL); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1641 ASSERT (strcmp (result, "INF 33") == 0 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1642 || strcmp (result, "INFINITY 33") == 0); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1643 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1644 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1645 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1646 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1647 { /* Negative infinity. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1648 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1649 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1650 my_asnprintf (NULL, &length, "%F %d", -1.0 / 0.0, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1651 ASSERT (result != NULL); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1652 ASSERT (strcmp (result, "-INF 33") == 0 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1653 || strcmp (result, "-INFINITY 33") == 0); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1654 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1655 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1656 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1657 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1658 { /* NaN. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1659 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1660 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1661 my_asnprintf (NULL, &length, "%F %d", NaN (), 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1662 ASSERT (result != NULL); |
8850
d1fe16dfbfee
Avoid test failures on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents:
8839
diff
changeset
|
1663 ASSERT (strlen (result) >= 3 + 3 |
8865
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8857
diff
changeset
|
1664 && strisnan (result, 0, strlen (result) - 3, 1) |
8850
d1fe16dfbfee
Avoid test failures on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents:
8839
diff
changeset
|
1665 && strcmp (result + strlen (result) - 3, " 33") == 0); |
8684
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1666 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1667 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1668 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1669 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1670 { /* FLAG_ZERO. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1671 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1672 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1673 my_asnprintf (NULL, &length, "%015F %d", 1234.0, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1674 ASSERT (result != NULL); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1675 ASSERT (strcmp (result, "00001234.000000 33") == 0); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1676 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1677 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1678 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1679 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1680 { /* FLAG_ZERO with infinite number. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1681 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1682 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1683 my_asnprintf (NULL, &length, "%015F %d", -1.0 / 0.0, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1684 ASSERT (result != NULL); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1685 ASSERT (strcmp (result, " -INF 33") == 0 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1686 || strcmp (result, " -INFINITY 33") == 0); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1687 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1688 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1689 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1690 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1691 { /* Precision. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1692 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1693 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1694 my_asnprintf (NULL, &length, "%.F %d", 1234.0, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1695 ASSERT (result != NULL); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1696 ASSERT (strcmp (result, "1234 33") == 0); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1697 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1698 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1699 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1700 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1701 { /* A positive number. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1702 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1703 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1704 my_asnprintf (NULL, &length, "%LF %d", 12.75L, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1705 ASSERT (result != NULL); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1706 ASSERT (strcmp (result, "12.750000 33") == 0); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1707 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1708 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1709 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1710 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1711 { /* A larger positive number. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1712 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1713 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1714 my_asnprintf (NULL, &length, "%LF %d", 1234567.0L, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1715 ASSERT (result != NULL); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1716 ASSERT (strcmp (result, "1234567.000000 33") == 0); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1717 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1718 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1719 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1720 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1721 { /* A negative number. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1722 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1723 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1724 my_asnprintf (NULL, &length, "%LF %d", -0.03125L, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1725 ASSERT (result != NULL); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1726 ASSERT (strcmp (result, "-0.031250 33") == 0); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1727 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1728 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1729 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1730 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1731 { /* Positive zero. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1732 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1733 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1734 my_asnprintf (NULL, &length, "%LF %d", 0.0L, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1735 ASSERT (result != NULL); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1736 ASSERT (strcmp (result, "0.000000 33") == 0); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1737 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1738 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1739 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1740 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1741 { /* Negative zero. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1742 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1743 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1744 my_asnprintf (NULL, &length, "%LF %d", -0.0L, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1745 ASSERT (result != NULL); |
8852
df0b5e8ea770
Avoid test failures on platforms where -0.0 and 0.0 are identical.
Bruno Haible <bruno@clisp.org>
parents:
8850
diff
changeset
|
1746 if (have_minus_zero ()) |
df0b5e8ea770
Avoid test failures on platforms where -0.0 and 0.0 are identical.
Bruno Haible <bruno@clisp.org>
parents:
8850
diff
changeset
|
1747 ASSERT (strcmp (result, "-0.000000 33") == 0); |
8684
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1748 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1749 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1750 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1751 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1752 { /* Positive infinity. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1753 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1754 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1755 my_asnprintf (NULL, &length, "%LF %d", 1.0L / 0.0L, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1756 ASSERT (result != NULL); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1757 ASSERT (strcmp (result, "INF 33") == 0 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1758 || strcmp (result, "INFINITY 33") == 0); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1759 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1760 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1761 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1762 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1763 { /* Negative infinity. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1764 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1765 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1766 my_asnprintf (NULL, &length, "%LF %d", -1.0L / 0.0L, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1767 ASSERT (result != NULL); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1768 ASSERT (strcmp (result, "-INF 33") == 0 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1769 || strcmp (result, "-INFINITY 33") == 0); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1770 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1771 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1772 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1773 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1774 { /* NaN. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1775 static long double zero = 0.0L; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1776 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1777 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1778 my_asnprintf (NULL, &length, "%LF %d", zero / zero, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1779 ASSERT (result != NULL); |
8850
d1fe16dfbfee
Avoid test failures on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents:
8839
diff
changeset
|
1780 ASSERT (strlen (result) >= 3 + 3 |
8865
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8857
diff
changeset
|
1781 && strisnan (result, 0, strlen (result) - 3, 1) |
8850
d1fe16dfbfee
Avoid test failures on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents:
8839
diff
changeset
|
1782 && strcmp (result + strlen (result) - 3, " 33") == 0); |
8684
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1783 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1784 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1785 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1786 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1787 { /* FLAG_ZERO. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1788 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1789 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1790 my_asnprintf (NULL, &length, "%015LF %d", 1234.0L, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1791 ASSERT (result != NULL); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1792 ASSERT (strcmp (result, "00001234.000000 33") == 0); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1793 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1794 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1795 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1796 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1797 { /* FLAG_ZERO with infinite number. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1798 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1799 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1800 my_asnprintf (NULL, &length, "%015LF %d", -1.0L / 0.0L, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1801 ASSERT (result != NULL); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1802 ASSERT (strcmp (result, " -INF 33") == 0 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1803 || strcmp (result, " -INFINITY 33") == 0); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1804 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1805 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1806 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1807 |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1808 { /* Precision. */ |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1809 size_t length; |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1810 char *result = |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1811 my_asnprintf (NULL, &length, "%.LF %d", 1234.0L, 33, 44, 55); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1812 ASSERT (result != NULL); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1813 ASSERT (strcmp (result, "1234 33") == 0); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1814 ASSERT (length == strlen (result)); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1815 free (result); |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1816 } |
9ea5590b49d1
Add tests for %f and %F directives.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
1817 |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1818 /* Test the support of the %e format directive. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1819 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1820 { /* A positive number. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1821 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1822 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1823 my_asnprintf (NULL, &length, "%e %d", 12.75, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1824 ASSERT (result != NULL); |
8839
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
1825 ASSERT (strcmp (result, "1.275000e+01 33") == 0 |
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
1826 || strcmp (result, "1.275000e+001 33") == 0); |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1827 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1828 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1829 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1830 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1831 { /* A larger positive number. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1832 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1833 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1834 my_asnprintf (NULL, &length, "%e %d", 1234567.0, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1835 ASSERT (result != NULL); |
8839
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
1836 ASSERT (strcmp (result, "1.234567e+06 33") == 0 |
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
1837 || strcmp (result, "1.234567e+006 33") == 0); |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1838 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1839 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1840 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1841 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1842 { /* Small and large positive numbers. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1843 static struct { double value; const char *string; } data[] = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1844 { |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1845 { 1.234321234321234e-37, "1.234321e-37" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1846 { 1.234321234321234e-36, "1.234321e-36" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1847 { 1.234321234321234e-35, "1.234321e-35" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1848 { 1.234321234321234e-34, "1.234321e-34" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1849 { 1.234321234321234e-33, "1.234321e-33" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1850 { 1.234321234321234e-32, "1.234321e-32" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1851 { 1.234321234321234e-31, "1.234321e-31" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1852 { 1.234321234321234e-30, "1.234321e-30" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1853 { 1.234321234321234e-29, "1.234321e-29" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1854 { 1.234321234321234e-28, "1.234321e-28" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1855 { 1.234321234321234e-27, "1.234321e-27" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1856 { 1.234321234321234e-26, "1.234321e-26" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1857 { 1.234321234321234e-25, "1.234321e-25" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1858 { 1.234321234321234e-24, "1.234321e-24" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1859 { 1.234321234321234e-23, "1.234321e-23" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1860 { 1.234321234321234e-22, "1.234321e-22" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1861 { 1.234321234321234e-21, "1.234321e-21" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1862 { 1.234321234321234e-20, "1.234321e-20" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1863 { 1.234321234321234e-19, "1.234321e-19" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1864 { 1.234321234321234e-18, "1.234321e-18" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1865 { 1.234321234321234e-17, "1.234321e-17" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1866 { 1.234321234321234e-16, "1.234321e-16" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1867 { 1.234321234321234e-15, "1.234321e-15" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1868 { 1.234321234321234e-14, "1.234321e-14" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1869 { 1.234321234321234e-13, "1.234321e-13" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1870 { 1.234321234321234e-12, "1.234321e-12" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1871 { 1.234321234321234e-11, "1.234321e-11" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1872 { 1.234321234321234e-10, "1.234321e-10" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1873 { 1.234321234321234e-9, "1.234321e-09" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1874 { 1.234321234321234e-8, "1.234321e-08" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1875 { 1.234321234321234e-7, "1.234321e-07" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1876 { 1.234321234321234e-6, "1.234321e-06" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1877 { 1.234321234321234e-5, "1.234321e-05" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1878 { 1.234321234321234e-4, "1.234321e-04" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1879 { 1.234321234321234e-3, "1.234321e-03" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1880 { 1.234321234321234e-2, "1.234321e-02" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1881 { 1.234321234321234e-1, "1.234321e-01" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1882 { 1.234321234321234, "1.234321e+00" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1883 { 1.234321234321234e1, "1.234321e+01" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1884 { 1.234321234321234e2, "1.234321e+02" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1885 { 1.234321234321234e3, "1.234321e+03" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1886 { 1.234321234321234e4, "1.234321e+04" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1887 { 1.234321234321234e5, "1.234321e+05" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1888 { 1.234321234321234e6, "1.234321e+06" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1889 { 1.234321234321234e7, "1.234321e+07" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1890 { 1.234321234321234e8, "1.234321e+08" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1891 { 1.234321234321234e9, "1.234321e+09" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1892 { 1.234321234321234e10, "1.234321e+10" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1893 { 1.234321234321234e11, "1.234321e+11" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1894 { 1.234321234321234e12, "1.234321e+12" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1895 { 1.234321234321234e13, "1.234321e+13" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1896 { 1.234321234321234e14, "1.234321e+14" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1897 { 1.234321234321234e15, "1.234321e+15" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1898 { 1.234321234321234e16, "1.234321e+16" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1899 { 1.234321234321234e17, "1.234321e+17" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1900 { 1.234321234321234e18, "1.234321e+18" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1901 { 1.234321234321234e19, "1.234321e+19" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1902 { 1.234321234321234e20, "1.234321e+20" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1903 { 1.234321234321234e21, "1.234321e+21" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1904 { 1.234321234321234e22, "1.234321e+22" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1905 { 1.234321234321234e23, "1.234321e+23" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1906 { 1.234321234321234e24, "1.234321e+24" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1907 { 1.234321234321234e25, "1.234321e+25" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1908 { 1.234321234321234e26, "1.234321e+26" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1909 { 1.234321234321234e27, "1.234321e+27" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1910 { 1.234321234321234e28, "1.234321e+28" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1911 { 1.234321234321234e29, "1.234321e+29" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1912 { 1.234321234321234e30, "1.234321e+30" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1913 { 1.234321234321234e31, "1.234321e+31" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1914 { 1.234321234321234e32, "1.234321e+32" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1915 { 1.234321234321234e33, "1.234321e+33" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1916 { 1.234321234321234e34, "1.234321e+34" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1917 { 1.234321234321234e35, "1.234321e+35" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1918 { 1.234321234321234e36, "1.234321e+36" } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1919 }; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1920 size_t k; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1921 for (k = 0; k < SIZEOF (data); k++) |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1922 { |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1923 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1924 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1925 my_asnprintf (NULL, &length, "%e", data[k].value); |
8839
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
1926 const char *expected = data[k].string; |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1927 ASSERT (result != NULL); |
8839
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
1928 ASSERT (strcmp (result, expected) == 0 |
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
1929 /* Some implementations produce exponents with 3 digits. */ |
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
1930 || (strlen (result) == strlen (expected) + 1 |
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
1931 && memcmp (result, expected, strlen (expected) - 2) == 0 |
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
1932 && result[strlen (expected) - 2] == '0' |
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
1933 && strcmp (result + strlen (expected) - 1, |
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
1934 expected + strlen (expected) - 2) |
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
1935 == 0)); |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1936 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1937 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1938 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1939 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1940 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1941 { /* A negative number. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1942 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1943 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1944 my_asnprintf (NULL, &length, "%e %d", -0.03125, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1945 ASSERT (result != NULL); |
8839
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
1946 ASSERT (strcmp (result, "-3.125000e-02 33") == 0 |
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
1947 || strcmp (result, "-3.125000e-002 33") == 0); |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1948 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1949 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1950 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1951 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1952 { /* Positive zero. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1953 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1954 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1955 my_asnprintf (NULL, &length, "%e %d", 0.0, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1956 ASSERT (result != NULL); |
8839
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
1957 ASSERT (strcmp (result, "0.000000e+00 33") == 0 |
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
1958 || strcmp (result, "0.000000e+000 33") == 0); |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1959 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1960 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1961 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1962 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1963 { /* Negative zero. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1964 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1965 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1966 my_asnprintf (NULL, &length, "%e %d", -0.0, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1967 ASSERT (result != NULL); |
8852
df0b5e8ea770
Avoid test failures on platforms where -0.0 and 0.0 are identical.
Bruno Haible <bruno@clisp.org>
parents:
8850
diff
changeset
|
1968 if (have_minus_zero ()) |
df0b5e8ea770
Avoid test failures on platforms where -0.0 and 0.0 are identical.
Bruno Haible <bruno@clisp.org>
parents:
8850
diff
changeset
|
1969 ASSERT (strcmp (result, "-0.000000e+00 33") == 0 |
df0b5e8ea770
Avoid test failures on platforms where -0.0 and 0.0 are identical.
Bruno Haible <bruno@clisp.org>
parents:
8850
diff
changeset
|
1970 || strcmp (result, "-0.000000e+000 33") == 0); |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1971 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1972 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1973 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1974 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1975 { /* Positive infinity. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1976 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1977 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1978 my_asnprintf (NULL, &length, "%e %d", 1.0 / 0.0, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1979 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1980 ASSERT (strcmp (result, "inf 33") == 0 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1981 || strcmp (result, "infinity 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1982 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1983 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1984 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1985 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1986 { /* Negative infinity. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1987 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1988 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1989 my_asnprintf (NULL, &length, "%e %d", -1.0 / 0.0, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1990 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1991 ASSERT (strcmp (result, "-inf 33") == 0 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1992 || strcmp (result, "-infinity 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1993 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1994 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1995 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1996 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1997 { /* NaN. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1998 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
1999 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2000 my_asnprintf (NULL, &length, "%e %d", NaN (), 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2001 ASSERT (result != NULL); |
8850
d1fe16dfbfee
Avoid test failures on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents:
8839
diff
changeset
|
2002 ASSERT (strlen (result) >= 3 + 3 |
8865
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8857
diff
changeset
|
2003 && strisnan (result, 0, strlen (result) - 3, 0) |
8850
d1fe16dfbfee
Avoid test failures on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents:
8839
diff
changeset
|
2004 && strcmp (result + strlen (result) - 3, " 33") == 0); |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2005 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2006 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2007 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2008 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2009 { /* Width. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2010 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2011 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2012 my_asnprintf (NULL, &length, "%15e %d", 1.75, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2013 ASSERT (result != NULL); |
8839
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
2014 ASSERT (strcmp (result, " 1.750000e+00 33") == 0 |
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
2015 || strcmp (result, " 1.750000e+000 33") == 0); |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2016 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2017 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2018 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2019 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2020 { /* FLAG_LEFT. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2021 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2022 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2023 my_asnprintf (NULL, &length, "%-15e %d", 1.75, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2024 ASSERT (result != NULL); |
8839
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
2025 ASSERT (strcmp (result, "1.750000e+00 33") == 0 |
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
2026 || strcmp (result, "1.750000e+000 33") == 0); |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2027 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2028 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2029 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2030 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2031 { /* FLAG_SHOWSIGN. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2032 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2033 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2034 my_asnprintf (NULL, &length, "%+e %d", 1.75, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2035 ASSERT (result != NULL); |
8839
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
2036 ASSERT (strcmp (result, "+1.750000e+00 33") == 0 |
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
2037 || strcmp (result, "+1.750000e+000 33") == 0); |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2038 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2039 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2040 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2041 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2042 { /* FLAG_SPACE. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2043 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2044 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2045 my_asnprintf (NULL, &length, "% e %d", 1.75, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2046 ASSERT (result != NULL); |
8839
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
2047 ASSERT (strcmp (result, " 1.750000e+00 33") == 0 |
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
2048 || strcmp (result, " 1.750000e+000 33") == 0); |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2049 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2050 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2051 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2052 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2053 { /* FLAG_ALT. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2054 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2055 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2056 my_asnprintf (NULL, &length, "%#e %d", 1.75, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2057 ASSERT (result != NULL); |
8839
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
2058 ASSERT (strcmp (result, "1.750000e+00 33") == 0 |
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
2059 || strcmp (result, "1.750000e+000 33") == 0); |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2060 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2061 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2062 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2063 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2064 { /* FLAG_ALT. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2065 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2066 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2067 my_asnprintf (NULL, &length, "%#.e %d", 1.75, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2068 ASSERT (result != NULL); |
8839
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
2069 ASSERT (strcmp (result, "2.e+00 33") == 0 |
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
2070 || strcmp (result, "2.e+000 33") == 0); |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2071 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2072 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2073 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2074 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2075 { /* FLAG_ALT. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2076 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2077 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2078 my_asnprintf (NULL, &length, "%#.e %d", 9.75, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2079 ASSERT (result != NULL); |
8839
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
2080 ASSERT (strcmp (result, "1.e+01 33") == 0 |
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
2081 || strcmp (result, "1.e+001 33") == 0); |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2082 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2083 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2084 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2085 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2086 { /* FLAG_ZERO with finite number. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2087 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2088 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2089 my_asnprintf (NULL, &length, "%015e %d", 1234.0, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2090 ASSERT (result != NULL); |
8839
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
2091 ASSERT (strcmp (result, "0001.234000e+03 33") == 0 |
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
2092 || strcmp (result, "001.234000e+003 33") == 0); |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2093 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2094 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2095 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2096 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2097 { /* FLAG_ZERO with infinite number. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2098 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2099 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2100 my_asnprintf (NULL, &length, "%015e %d", -1.0 / 0.0, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2101 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2102 ASSERT (strcmp (result, " -inf 33") == 0 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2103 || strcmp (result, " -infinity 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2104 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2105 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2106 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2107 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2108 { /* FLAG_ZERO with NaN. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2109 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2110 char *result = |
8870
4e1f2ea486b4
Allow for a longer printed representation of NaN.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
2111 my_asnprintf (NULL, &length, "%050e %d", NaN (), 33, 44, 55); |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2112 ASSERT (result != NULL); |
8870
4e1f2ea486b4
Allow for a longer printed representation of NaN.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
2113 ASSERT (strlen (result) == 50 + 3 |
8865
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8857
diff
changeset
|
2114 && strisnan (result, strspn (result, " "), strlen (result) - 3, 0) |
8850
d1fe16dfbfee
Avoid test failures on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents:
8839
diff
changeset
|
2115 && strcmp (result + strlen (result) - 3, " 33") == 0); |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2116 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2117 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2118 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2119 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2120 { /* Precision. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2121 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2122 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2123 my_asnprintf (NULL, &length, "%.e %d", 1234.0, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2124 ASSERT (result != NULL); |
8839
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
2125 ASSERT (strcmp (result, "1e+03 33") == 0 |
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
2126 || strcmp (result, "1e+003 33") == 0); |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2127 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2128 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2129 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2130 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2131 { /* A positive number. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2132 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2133 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2134 my_asnprintf (NULL, &length, "%Le %d", 12.75L, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2135 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2136 ASSERT (strcmp (result, "1.275000e+01 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2137 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2138 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2139 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2140 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2141 { /* A larger positive number. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2142 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2143 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2144 my_asnprintf (NULL, &length, "%Le %d", 1234567.0L, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2145 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2146 ASSERT (strcmp (result, "1.234567e+06 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2147 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2148 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2149 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2150 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2151 { /* Small and large positive numbers. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2152 static struct { long double value; const char *string; } data[] = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2153 { |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2154 { 1.234321234321234e-37L, "1.234321e-37" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2155 { 1.234321234321234e-36L, "1.234321e-36" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2156 { 1.234321234321234e-35L, "1.234321e-35" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2157 { 1.234321234321234e-34L, "1.234321e-34" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2158 { 1.234321234321234e-33L, "1.234321e-33" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2159 { 1.234321234321234e-32L, "1.234321e-32" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2160 { 1.234321234321234e-31L, "1.234321e-31" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2161 { 1.234321234321234e-30L, "1.234321e-30" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2162 { 1.234321234321234e-29L, "1.234321e-29" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2163 { 1.234321234321234e-28L, "1.234321e-28" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2164 { 1.234321234321234e-27L, "1.234321e-27" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2165 { 1.234321234321234e-26L, "1.234321e-26" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2166 { 1.234321234321234e-25L, "1.234321e-25" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2167 { 1.234321234321234e-24L, "1.234321e-24" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2168 { 1.234321234321234e-23L, "1.234321e-23" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2169 { 1.234321234321234e-22L, "1.234321e-22" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2170 { 1.234321234321234e-21L, "1.234321e-21" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2171 { 1.234321234321234e-20L, "1.234321e-20" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2172 { 1.234321234321234e-19L, "1.234321e-19" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2173 { 1.234321234321234e-18L, "1.234321e-18" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2174 { 1.234321234321234e-17L, "1.234321e-17" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2175 { 1.234321234321234e-16L, "1.234321e-16" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2176 { 1.234321234321234e-15L, "1.234321e-15" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2177 { 1.234321234321234e-14L, "1.234321e-14" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2178 { 1.234321234321234e-13L, "1.234321e-13" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2179 { 1.234321234321234e-12L, "1.234321e-12" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2180 { 1.234321234321234e-11L, "1.234321e-11" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2181 { 1.234321234321234e-10L, "1.234321e-10" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2182 { 1.234321234321234e-9L, "1.234321e-09" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2183 { 1.234321234321234e-8L, "1.234321e-08" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2184 { 1.234321234321234e-7L, "1.234321e-07" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2185 { 1.234321234321234e-6L, "1.234321e-06" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2186 { 1.234321234321234e-5L, "1.234321e-05" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2187 { 1.234321234321234e-4L, "1.234321e-04" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2188 { 1.234321234321234e-3L, "1.234321e-03" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2189 { 1.234321234321234e-2L, "1.234321e-02" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2190 { 1.234321234321234e-1L, "1.234321e-01" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2191 { 1.234321234321234L, "1.234321e+00" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2192 { 1.234321234321234e1L, "1.234321e+01" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2193 { 1.234321234321234e2L, "1.234321e+02" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2194 { 1.234321234321234e3L, "1.234321e+03" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2195 { 1.234321234321234e4L, "1.234321e+04" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2196 { 1.234321234321234e5L, "1.234321e+05" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2197 { 1.234321234321234e6L, "1.234321e+06" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2198 { 1.234321234321234e7L, "1.234321e+07" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2199 { 1.234321234321234e8L, "1.234321e+08" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2200 { 1.234321234321234e9L, "1.234321e+09" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2201 { 1.234321234321234e10L, "1.234321e+10" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2202 { 1.234321234321234e11L, "1.234321e+11" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2203 { 1.234321234321234e12L, "1.234321e+12" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2204 { 1.234321234321234e13L, "1.234321e+13" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2205 { 1.234321234321234e14L, "1.234321e+14" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2206 { 1.234321234321234e15L, "1.234321e+15" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2207 { 1.234321234321234e16L, "1.234321e+16" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2208 { 1.234321234321234e17L, "1.234321e+17" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2209 { 1.234321234321234e18L, "1.234321e+18" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2210 { 1.234321234321234e19L, "1.234321e+19" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2211 { 1.234321234321234e20L, "1.234321e+20" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2212 { 1.234321234321234e21L, "1.234321e+21" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2213 { 1.234321234321234e22L, "1.234321e+22" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2214 { 1.234321234321234e23L, "1.234321e+23" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2215 { 1.234321234321234e24L, "1.234321e+24" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2216 { 1.234321234321234e25L, "1.234321e+25" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2217 { 1.234321234321234e26L, "1.234321e+26" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2218 { 1.234321234321234e27L, "1.234321e+27" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2219 { 1.234321234321234e28L, "1.234321e+28" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2220 { 1.234321234321234e29L, "1.234321e+29" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2221 { 1.234321234321234e30L, "1.234321e+30" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2222 { 1.234321234321234e31L, "1.234321e+31" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2223 { 1.234321234321234e32L, "1.234321e+32" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2224 { 1.234321234321234e33L, "1.234321e+33" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2225 { 1.234321234321234e34L, "1.234321e+34" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2226 { 1.234321234321234e35L, "1.234321e+35" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2227 { 1.234321234321234e36L, "1.234321e+36" } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2228 }; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2229 size_t k; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2230 for (k = 0; k < SIZEOF (data); k++) |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2231 { |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2232 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2233 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2234 my_asnprintf (NULL, &length, "%Le", data[k].value); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2235 ASSERT (result != NULL); |
8839
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
2236 ASSERT (strcmp (result, data[k].string) == 0); |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2237 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2238 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2239 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2240 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2241 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2242 { /* A negative number. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2243 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2244 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2245 my_asnprintf (NULL, &length, "%Le %d", -0.03125L, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2246 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2247 ASSERT (strcmp (result, "-3.125000e-02 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2248 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2249 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2250 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2251 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2252 { /* Positive zero. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2253 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2254 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2255 my_asnprintf (NULL, &length, "%Le %d", 0.0L, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2256 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2257 ASSERT (strcmp (result, "0.000000e+00 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2258 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2259 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2260 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2261 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2262 { /* Negative zero. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2263 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2264 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2265 my_asnprintf (NULL, &length, "%Le %d", -0.0L, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2266 ASSERT (result != NULL); |
8852
df0b5e8ea770
Avoid test failures on platforms where -0.0 and 0.0 are identical.
Bruno Haible <bruno@clisp.org>
parents:
8850
diff
changeset
|
2267 if (have_minus_zero ()) |
df0b5e8ea770
Avoid test failures on platforms where -0.0 and 0.0 are identical.
Bruno Haible <bruno@clisp.org>
parents:
8850
diff
changeset
|
2268 ASSERT (strcmp (result, "-0.000000e+00 33") == 0); |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2269 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2270 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2271 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2272 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2273 { /* Positive infinity. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2274 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2275 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2276 my_asnprintf (NULL, &length, "%Le %d", 1.0L / 0.0L, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2277 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2278 ASSERT (strcmp (result, "inf 33") == 0 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2279 || strcmp (result, "infinity 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2280 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2281 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2282 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2283 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2284 { /* Negative infinity. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2285 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2286 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2287 my_asnprintf (NULL, &length, "%Le %d", -1.0L / 0.0L, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2288 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2289 ASSERT (strcmp (result, "-inf 33") == 0 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2290 || strcmp (result, "-infinity 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2291 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2292 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2293 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2294 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2295 { /* NaN. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2296 static long double zero = 0.0L; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2297 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2298 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2299 my_asnprintf (NULL, &length, "%Le %d", zero / zero, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2300 ASSERT (result != NULL); |
8850
d1fe16dfbfee
Avoid test failures on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents:
8839
diff
changeset
|
2301 ASSERT (strlen (result) >= 3 + 3 |
8865
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8857
diff
changeset
|
2302 && strisnan (result, 0, strlen (result) - 3, 0) |
8850
d1fe16dfbfee
Avoid test failures on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents:
8839
diff
changeset
|
2303 && strcmp (result + strlen (result) - 3, " 33") == 0); |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2304 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2305 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2306 } |
8919
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2307 #if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2308 { /* Quiet NaN. */ |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2309 static union { unsigned int word[4]; long double value; } x = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2310 { LDBL80_WORDS (0xFFFF, 0xC3333333, 0x00000000) }; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2311 size_t length; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2312 char *result = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2313 my_asnprintf (NULL, &length, "%Le %d", x.value, 33, 44, 55); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2314 ASSERT (result != NULL); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2315 ASSERT (strlen (result) >= 3 + 3 |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2316 && strisnan (result, 0, strlen (result) - 3, 0) |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2317 && strcmp (result + strlen (result) - 3, " 33") == 0); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2318 ASSERT (length == strlen (result)); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2319 free (result); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2320 } |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2321 { |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2322 /* Signalling NaN. */ |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2323 static union { unsigned int word[4]; long double value; } x = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2324 { LDBL80_WORDS (0xFFFF, 0x83333333, 0x00000000) }; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2325 size_t length; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2326 char *result = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2327 my_asnprintf (NULL, &length, "%Le %d", x.value, 33, 44, 55); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2328 ASSERT (result != NULL); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2329 ASSERT (strlen (result) >= 3 + 3 |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2330 && strisnan (result, 0, strlen (result) - 3, 0) |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2331 && strcmp (result + strlen (result) - 3, " 33") == 0); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2332 ASSERT (length == strlen (result)); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2333 free (result); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2334 } |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2335 /* The isnanl function should recognize Pseudo-NaNs, Pseudo-Infinities, |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2336 Pseudo-Zeroes, Unnormalized Numbers, and Pseudo-Denormals, as defined in |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2337 Intel IA-64 Architecture Software Developer's Manual, Volume 1: |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2338 Application Architecture. |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2339 Table 5-2 "Floating-Point Register Encodings" |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2340 Figure 5-6 "Memory to Floating-Point Register Data Translation" |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2341 */ |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2342 { /* Pseudo-NaN. */ |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2343 static union { unsigned int word[4]; long double value; } x = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2344 { LDBL80_WORDS (0xFFFF, 0x40000001, 0x00000000) }; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2345 size_t length; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2346 char *result = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2347 my_asnprintf (NULL, &length, "%Le %d", x.value, 33, 44, 55); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2348 ASSERT (result != NULL); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2349 ASSERT (strlen (result) >= 3 + 3 |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2350 && strisnan (result, 0, strlen (result) - 3, 0) |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2351 && strcmp (result + strlen (result) - 3, " 33") == 0); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2352 ASSERT (length == strlen (result)); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2353 free (result); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2354 } |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2355 { /* Pseudo-Infinity. */ |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2356 static union { unsigned int word[4]; long double value; } x = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2357 { LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) }; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2358 size_t length; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2359 char *result = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2360 my_asnprintf (NULL, &length, "%Le %d", x.value, 33, 44, 55); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2361 ASSERT (result != NULL); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2362 ASSERT (strlen (result) >= 3 + 3 |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2363 && strisnan (result, 0, strlen (result) - 3, 0) |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2364 && strcmp (result + strlen (result) - 3, " 33") == 0); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2365 ASSERT (length == strlen (result)); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2366 free (result); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2367 } |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2368 { /* Pseudo-Zero. */ |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2369 static union { unsigned int word[4]; long double value; } x = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2370 { LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) }; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2371 size_t length; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2372 char *result = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2373 my_asnprintf (NULL, &length, "%Le %d", x.value, 33, 44, 55); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2374 ASSERT (result != NULL); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2375 ASSERT (strlen (result) >= 3 + 3 |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2376 && strisnan (result, 0, strlen (result) - 3, 0) |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2377 && strcmp (result + strlen (result) - 3, " 33") == 0); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2378 ASSERT (length == strlen (result)); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2379 free (result); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2380 } |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2381 { /* Unnormalized number. */ |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2382 static union { unsigned int word[4]; long double value; } x = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2383 { LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) }; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2384 size_t length; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2385 char *result = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2386 my_asnprintf (NULL, &length, "%Le %d", x.value, 33, 44, 55); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2387 ASSERT (result != NULL); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2388 ASSERT (strlen (result) >= 3 + 3 |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2389 && strisnan (result, 0, strlen (result) - 3, 0) |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2390 && strcmp (result + strlen (result) - 3, " 33") == 0); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2391 ASSERT (length == strlen (result)); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2392 free (result); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2393 } |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2394 { /* Pseudo-Denormal. */ |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2395 static union { unsigned int word[4]; long double value; } x = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2396 { LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) }; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2397 size_t length; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2398 char *result = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2399 my_asnprintf (NULL, &length, "%Le %d", x.value, 33, 44, 55); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2400 ASSERT (result != NULL); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2401 ASSERT (strlen (result) >= 3 + 3 |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2402 && strisnan (result, 0, strlen (result) - 3, 0) |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2403 && strcmp (result + strlen (result) - 3, " 33") == 0); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2404 ASSERT (length == strlen (result)); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2405 free (result); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2406 } |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
2407 #endif |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2408 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2409 { /* Width. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2410 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2411 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2412 my_asnprintf (NULL, &length, "%15Le %d", 1.75L, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2413 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2414 ASSERT (strcmp (result, " 1.750000e+00 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2415 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2416 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2417 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2418 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2419 { /* FLAG_LEFT. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2420 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2421 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2422 my_asnprintf (NULL, &length, "%-15Le %d", 1.75L, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2423 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2424 ASSERT (strcmp (result, "1.750000e+00 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2425 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2426 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2427 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2428 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2429 { /* FLAG_SHOWSIGN. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2430 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2431 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2432 my_asnprintf (NULL, &length, "%+Le %d", 1.75L, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2433 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2434 ASSERT (strcmp (result, "+1.750000e+00 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2435 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2436 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2437 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2438 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2439 { /* FLAG_SPACE. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2440 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2441 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2442 my_asnprintf (NULL, &length, "% Le %d", 1.75L, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2443 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2444 ASSERT (strcmp (result, " 1.750000e+00 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2445 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2446 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2447 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2448 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2449 { /* FLAG_ALT. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2450 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2451 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2452 my_asnprintf (NULL, &length, "%#Le %d", 1.75L, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2453 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2454 ASSERT (strcmp (result, "1.750000e+00 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2455 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2456 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2457 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2458 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2459 { /* FLAG_ALT. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2460 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2461 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2462 my_asnprintf (NULL, &length, "%#.Le %d", 1.75L, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2463 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2464 ASSERT (strcmp (result, "2.e+00 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2465 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2466 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2467 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2468 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2469 { /* FLAG_ALT. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2470 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2471 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2472 my_asnprintf (NULL, &length, "%#.Le %d", 9.75L, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2473 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2474 ASSERT (strcmp (result, "1.e+01 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2475 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2476 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2477 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2478 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2479 { /* FLAG_ZERO with finite number. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2480 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2481 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2482 my_asnprintf (NULL, &length, "%015Le %d", 1234.0L, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2483 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2484 ASSERT (strcmp (result, "0001.234000e+03 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2485 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2486 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2487 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2488 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2489 { /* FLAG_ZERO with infinite number. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2490 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2491 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2492 my_asnprintf (NULL, &length, "%015Le %d", -1.0L / 0.0L, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2493 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2494 ASSERT (strcmp (result, " -inf 33") == 0 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2495 || strcmp (result, " -infinity 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2496 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2497 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2498 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2499 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2500 { /* FLAG_ZERO with NaN. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2501 static long double zero = 0.0L; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2502 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2503 char *result = |
8870
4e1f2ea486b4
Allow for a longer printed representation of NaN.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
2504 my_asnprintf (NULL, &length, "%050Le %d", zero / zero, 33, 44, 55); |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2505 ASSERT (result != NULL); |
8870
4e1f2ea486b4
Allow for a longer printed representation of NaN.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
2506 ASSERT (strlen (result) == 50 + 3 |
8865
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8857
diff
changeset
|
2507 && strisnan (result, strspn (result, " "), strlen (result) - 3, 0) |
8850
d1fe16dfbfee
Avoid test failures on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents:
8839
diff
changeset
|
2508 && strcmp (result + strlen (result) - 3, " 33") == 0); |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2509 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2510 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2511 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2512 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2513 { /* Precision. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2514 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2515 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2516 my_asnprintf (NULL, &length, "%.Le %d", 1234.0L, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2517 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2518 ASSERT (strcmp (result, "1e+03 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2519 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2520 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2521 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2522 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2523 /* Test the support of the %g format directive. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2524 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2525 { /* A positive number. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2526 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2527 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2528 my_asnprintf (NULL, &length, "%g %d", 12.75, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2529 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2530 ASSERT (strcmp (result, "12.75 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2531 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2532 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2533 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2534 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2535 { /* A larger positive number. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2536 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2537 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2538 my_asnprintf (NULL, &length, "%g %d", 1234567.0, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2539 ASSERT (result != NULL); |
8839
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
2540 ASSERT (strcmp (result, "1.23457e+06 33") == 0 |
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
2541 || strcmp (result, "1.23457e+006 33") == 0); |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2542 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2543 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2544 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2545 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2546 { /* Small and large positive numbers. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2547 static struct { double value; const char *string; } data[] = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2548 { |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2549 { 1.234321234321234e-37, "1.23432e-37" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2550 { 1.234321234321234e-36, "1.23432e-36" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2551 { 1.234321234321234e-35, "1.23432e-35" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2552 { 1.234321234321234e-34, "1.23432e-34" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2553 { 1.234321234321234e-33, "1.23432e-33" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2554 { 1.234321234321234e-32, "1.23432e-32" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2555 { 1.234321234321234e-31, "1.23432e-31" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2556 { 1.234321234321234e-30, "1.23432e-30" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2557 { 1.234321234321234e-29, "1.23432e-29" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2558 { 1.234321234321234e-28, "1.23432e-28" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2559 { 1.234321234321234e-27, "1.23432e-27" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2560 { 1.234321234321234e-26, "1.23432e-26" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2561 { 1.234321234321234e-25, "1.23432e-25" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2562 { 1.234321234321234e-24, "1.23432e-24" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2563 { 1.234321234321234e-23, "1.23432e-23" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2564 { 1.234321234321234e-22, "1.23432e-22" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2565 { 1.234321234321234e-21, "1.23432e-21" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2566 { 1.234321234321234e-20, "1.23432e-20" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2567 { 1.234321234321234e-19, "1.23432e-19" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2568 { 1.234321234321234e-18, "1.23432e-18" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2569 { 1.234321234321234e-17, "1.23432e-17" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2570 { 1.234321234321234e-16, "1.23432e-16" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2571 { 1.234321234321234e-15, "1.23432e-15" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2572 { 1.234321234321234e-14, "1.23432e-14" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2573 { 1.234321234321234e-13, "1.23432e-13" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2574 { 1.234321234321234e-12, "1.23432e-12" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2575 { 1.234321234321234e-11, "1.23432e-11" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2576 { 1.234321234321234e-10, "1.23432e-10" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2577 { 1.234321234321234e-9, "1.23432e-09" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2578 { 1.234321234321234e-8, "1.23432e-08" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2579 { 1.234321234321234e-7, "1.23432e-07" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2580 { 1.234321234321234e-6, "1.23432e-06" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2581 { 1.234321234321234e-5, "1.23432e-05" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2582 { 1.234321234321234e-4, "0.000123432" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2583 { 1.234321234321234e-3, "0.00123432" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2584 { 1.234321234321234e-2, "0.0123432" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2585 { 1.234321234321234e-1, "0.123432" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2586 { 1.234321234321234, "1.23432" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2587 { 1.234321234321234e1, "12.3432" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2588 { 1.234321234321234e2, "123.432" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2589 { 1.234321234321234e3, "1234.32" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2590 { 1.234321234321234e4, "12343.2" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2591 { 1.234321234321234e5, "123432" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2592 { 1.234321234321234e6, "1.23432e+06" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2593 { 1.234321234321234e7, "1.23432e+07" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2594 { 1.234321234321234e8, "1.23432e+08" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2595 { 1.234321234321234e9, "1.23432e+09" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2596 { 1.234321234321234e10, "1.23432e+10" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2597 { 1.234321234321234e11, "1.23432e+11" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2598 { 1.234321234321234e12, "1.23432e+12" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2599 { 1.234321234321234e13, "1.23432e+13" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2600 { 1.234321234321234e14, "1.23432e+14" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2601 { 1.234321234321234e15, "1.23432e+15" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2602 { 1.234321234321234e16, "1.23432e+16" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2603 { 1.234321234321234e17, "1.23432e+17" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2604 { 1.234321234321234e18, "1.23432e+18" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2605 { 1.234321234321234e19, "1.23432e+19" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2606 { 1.234321234321234e20, "1.23432e+20" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2607 { 1.234321234321234e21, "1.23432e+21" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2608 { 1.234321234321234e22, "1.23432e+22" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2609 { 1.234321234321234e23, "1.23432e+23" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2610 { 1.234321234321234e24, "1.23432e+24" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2611 { 1.234321234321234e25, "1.23432e+25" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2612 { 1.234321234321234e26, "1.23432e+26" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2613 { 1.234321234321234e27, "1.23432e+27" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2614 { 1.234321234321234e28, "1.23432e+28" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2615 { 1.234321234321234e29, "1.23432e+29" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2616 { 1.234321234321234e30, "1.23432e+30" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2617 { 1.234321234321234e31, "1.23432e+31" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2618 { 1.234321234321234e32, "1.23432e+32" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2619 { 1.234321234321234e33, "1.23432e+33" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2620 { 1.234321234321234e34, "1.23432e+34" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2621 { 1.234321234321234e35, "1.23432e+35" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2622 { 1.234321234321234e36, "1.23432e+36" } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2623 }; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2624 size_t k; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2625 for (k = 0; k < SIZEOF (data); k++) |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2626 { |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2627 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2628 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2629 my_asnprintf (NULL, &length, "%g", data[k].value); |
8839
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
2630 const char *expected = data[k].string; |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2631 ASSERT (result != NULL); |
8839
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
2632 ASSERT (strcmp (result, expected) == 0 |
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
2633 /* Some implementations produce exponents with 3 digits. */ |
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
2634 || (expected[strlen (expected) - 4] == 'e' |
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
2635 && strlen (result) == strlen (expected) + 1 |
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
2636 && memcmp (result, expected, strlen (expected) - 2) == 0 |
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
2637 && result[strlen (expected) - 2] == '0' |
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
2638 && strcmp (result + strlen (expected) - 1, |
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
2639 expected + strlen (expected) - 2) |
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
2640 == 0)); |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2641 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2642 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2643 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2644 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2645 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2646 { /* A negative number. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2647 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2648 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2649 my_asnprintf (NULL, &length, "%g %d", -0.03125, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2650 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2651 ASSERT (strcmp (result, "-0.03125 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2652 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2653 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2654 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2655 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2656 { /* Positive zero. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2657 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2658 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2659 my_asnprintf (NULL, &length, "%g %d", 0.0, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2660 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2661 ASSERT (strcmp (result, "0 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2662 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2663 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2664 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2665 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2666 { /* Negative zero. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2667 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2668 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2669 my_asnprintf (NULL, &length, "%g %d", -0.0, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2670 ASSERT (result != NULL); |
8852
df0b5e8ea770
Avoid test failures on platforms where -0.0 and 0.0 are identical.
Bruno Haible <bruno@clisp.org>
parents:
8850
diff
changeset
|
2671 if (have_minus_zero ()) |
df0b5e8ea770
Avoid test failures on platforms where -0.0 and 0.0 are identical.
Bruno Haible <bruno@clisp.org>
parents:
8850
diff
changeset
|
2672 ASSERT (strcmp (result, "-0 33") == 0); |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2673 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2674 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2675 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2676 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2677 { /* Positive infinity. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2678 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2679 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2680 my_asnprintf (NULL, &length, "%g %d", 1.0 / 0.0, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2681 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2682 ASSERT (strcmp (result, "inf 33") == 0 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2683 || strcmp (result, "infinity 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2684 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2685 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2686 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2687 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2688 { /* Negative infinity. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2689 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2690 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2691 my_asnprintf (NULL, &length, "%g %d", -1.0 / 0.0, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2692 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2693 ASSERT (strcmp (result, "-inf 33") == 0 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2694 || strcmp (result, "-infinity 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2695 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2696 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2697 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2698 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2699 { /* NaN. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2700 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2701 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2702 my_asnprintf (NULL, &length, "%g %d", NaN (), 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2703 ASSERT (result != NULL); |
8850
d1fe16dfbfee
Avoid test failures on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents:
8839
diff
changeset
|
2704 ASSERT (strlen (result) >= 3 + 3 |
8865
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8857
diff
changeset
|
2705 && strisnan (result, 0, strlen (result) - 3, 0) |
8850
d1fe16dfbfee
Avoid test failures on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents:
8839
diff
changeset
|
2706 && strcmp (result + strlen (result) - 3, " 33") == 0); |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2707 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2708 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2709 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2710 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2711 { /* Width. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2712 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2713 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2714 my_asnprintf (NULL, &length, "%10g %d", 1.75, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2715 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2716 ASSERT (strcmp (result, " 1.75 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2717 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2718 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2719 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2720 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2721 { /* FLAG_LEFT. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2722 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2723 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2724 my_asnprintf (NULL, &length, "%-10g %d", 1.75, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2725 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2726 ASSERT (strcmp (result, "1.75 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2727 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2728 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2729 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2730 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2731 { /* FLAG_SHOWSIGN. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2732 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2733 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2734 my_asnprintf (NULL, &length, "%+g %d", 1.75, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2735 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2736 ASSERT (strcmp (result, "+1.75 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2737 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2738 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2739 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2740 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2741 { /* FLAG_SPACE. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2742 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2743 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2744 my_asnprintf (NULL, &length, "% g %d", 1.75, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2745 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2746 ASSERT (strcmp (result, " 1.75 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2747 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2748 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2749 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2750 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2751 { /* FLAG_ALT. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2752 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2753 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2754 my_asnprintf (NULL, &length, "%#g %d", 1.75, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2755 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2756 ASSERT (strcmp (result, "1.75000 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2757 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2758 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2759 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2760 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2761 { /* FLAG_ALT. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2762 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2763 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2764 my_asnprintf (NULL, &length, "%#.g %d", 1.75, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2765 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2766 ASSERT (strcmp (result, "2. 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2767 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2768 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2769 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2770 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2771 { /* FLAG_ALT. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2772 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2773 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2774 my_asnprintf (NULL, &length, "%#.g %d", 9.75, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2775 ASSERT (result != NULL); |
8839
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
2776 ASSERT (strcmp (result, "1.e+01 33") == 0 |
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
2777 || strcmp (result, "1.e+001 33") == 0); |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2778 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2779 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2780 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2781 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2782 { /* FLAG_ZERO with finite number. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2783 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2784 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2785 my_asnprintf (NULL, &length, "%010g %d", 1234.0, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2786 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2787 ASSERT (strcmp (result, "0000001234 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2788 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2789 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2790 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2791 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2792 { /* FLAG_ZERO with infinite number. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2793 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2794 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2795 my_asnprintf (NULL, &length, "%015g %d", -1.0 / 0.0, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2796 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2797 ASSERT (strcmp (result, " -inf 33") == 0 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2798 || strcmp (result, " -infinity 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2799 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2800 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2801 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2802 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2803 { /* FLAG_ZERO with NaN. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2804 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2805 char *result = |
8870
4e1f2ea486b4
Allow for a longer printed representation of NaN.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
2806 my_asnprintf (NULL, &length, "%050g %d", NaN (), 33, 44, 55); |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2807 ASSERT (result != NULL); |
8870
4e1f2ea486b4
Allow for a longer printed representation of NaN.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
2808 ASSERT (strlen (result) == 50 + 3 |
8865
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8857
diff
changeset
|
2809 && strisnan (result, strspn (result, " "), strlen (result) - 3, 0) |
8850
d1fe16dfbfee
Avoid test failures on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents:
8839
diff
changeset
|
2810 && strcmp (result + strlen (result) - 3, " 33") == 0); |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2811 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2812 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2813 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2814 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2815 { /* Precision. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2816 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2817 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2818 my_asnprintf (NULL, &length, "%.g %d", 1234.0, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2819 ASSERT (result != NULL); |
8839
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
2820 ASSERT (strcmp (result, "1e+03 33") == 0 |
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
2821 || strcmp (result, "1e+003 33") == 0); |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2822 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2823 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2824 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2825 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2826 { /* A positive number. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2827 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2828 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2829 my_asnprintf (NULL, &length, "%Lg %d", 12.75L, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2830 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2831 ASSERT (strcmp (result, "12.75 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2832 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2833 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2834 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2835 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2836 { /* A larger positive number. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2837 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2838 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2839 my_asnprintf (NULL, &length, "%Lg %d", 1234567.0L, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2840 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2841 ASSERT (strcmp (result, "1.23457e+06 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2842 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2843 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2844 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2845 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2846 { /* Small and large positive numbers. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2847 static struct { long double value; const char *string; } data[] = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2848 { |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2849 { 1.234321234321234e-37L, "1.23432e-37" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2850 { 1.234321234321234e-36L, "1.23432e-36" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2851 { 1.234321234321234e-35L, "1.23432e-35" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2852 { 1.234321234321234e-34L, "1.23432e-34" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2853 { 1.234321234321234e-33L, "1.23432e-33" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2854 { 1.234321234321234e-32L, "1.23432e-32" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2855 { 1.234321234321234e-31L, "1.23432e-31" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2856 { 1.234321234321234e-30L, "1.23432e-30" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2857 { 1.234321234321234e-29L, "1.23432e-29" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2858 { 1.234321234321234e-28L, "1.23432e-28" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2859 { 1.234321234321234e-27L, "1.23432e-27" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2860 { 1.234321234321234e-26L, "1.23432e-26" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2861 { 1.234321234321234e-25L, "1.23432e-25" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2862 { 1.234321234321234e-24L, "1.23432e-24" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2863 { 1.234321234321234e-23L, "1.23432e-23" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2864 { 1.234321234321234e-22L, "1.23432e-22" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2865 { 1.234321234321234e-21L, "1.23432e-21" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2866 { 1.234321234321234e-20L, "1.23432e-20" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2867 { 1.234321234321234e-19L, "1.23432e-19" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2868 { 1.234321234321234e-18L, "1.23432e-18" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2869 { 1.234321234321234e-17L, "1.23432e-17" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2870 { 1.234321234321234e-16L, "1.23432e-16" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2871 { 1.234321234321234e-15L, "1.23432e-15" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2872 { 1.234321234321234e-14L, "1.23432e-14" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2873 { 1.234321234321234e-13L, "1.23432e-13" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2874 { 1.234321234321234e-12L, "1.23432e-12" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2875 { 1.234321234321234e-11L, "1.23432e-11" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2876 { 1.234321234321234e-10L, "1.23432e-10" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2877 { 1.234321234321234e-9L, "1.23432e-09" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2878 { 1.234321234321234e-8L, "1.23432e-08" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2879 { 1.234321234321234e-7L, "1.23432e-07" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2880 { 1.234321234321234e-6L, "1.23432e-06" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2881 { 1.234321234321234e-5L, "1.23432e-05" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2882 { 1.234321234321234e-4L, "0.000123432" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2883 { 1.234321234321234e-3L, "0.00123432" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2884 { 1.234321234321234e-2L, "0.0123432" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2885 { 1.234321234321234e-1L, "0.123432" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2886 { 1.234321234321234L, "1.23432" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2887 { 1.234321234321234e1L, "12.3432" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2888 { 1.234321234321234e2L, "123.432" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2889 { 1.234321234321234e3L, "1234.32" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2890 { 1.234321234321234e4L, "12343.2" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2891 { 1.234321234321234e5L, "123432" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2892 { 1.234321234321234e6L, "1.23432e+06" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2893 { 1.234321234321234e7L, "1.23432e+07" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2894 { 1.234321234321234e8L, "1.23432e+08" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2895 { 1.234321234321234e9L, "1.23432e+09" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2896 { 1.234321234321234e10L, "1.23432e+10" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2897 { 1.234321234321234e11L, "1.23432e+11" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2898 { 1.234321234321234e12L, "1.23432e+12" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2899 { 1.234321234321234e13L, "1.23432e+13" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2900 { 1.234321234321234e14L, "1.23432e+14" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2901 { 1.234321234321234e15L, "1.23432e+15" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2902 { 1.234321234321234e16L, "1.23432e+16" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2903 { 1.234321234321234e17L, "1.23432e+17" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2904 { 1.234321234321234e18L, "1.23432e+18" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2905 { 1.234321234321234e19L, "1.23432e+19" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2906 { 1.234321234321234e20L, "1.23432e+20" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2907 { 1.234321234321234e21L, "1.23432e+21" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2908 { 1.234321234321234e22L, "1.23432e+22" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2909 { 1.234321234321234e23L, "1.23432e+23" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2910 { 1.234321234321234e24L, "1.23432e+24" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2911 { 1.234321234321234e25L, "1.23432e+25" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2912 { 1.234321234321234e26L, "1.23432e+26" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2913 { 1.234321234321234e27L, "1.23432e+27" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2914 { 1.234321234321234e28L, "1.23432e+28" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2915 { 1.234321234321234e29L, "1.23432e+29" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2916 { 1.234321234321234e30L, "1.23432e+30" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2917 { 1.234321234321234e31L, "1.23432e+31" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2918 { 1.234321234321234e32L, "1.23432e+32" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2919 { 1.234321234321234e33L, "1.23432e+33" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2920 { 1.234321234321234e34L, "1.23432e+34" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2921 { 1.234321234321234e35L, "1.23432e+35" }, |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2922 { 1.234321234321234e36L, "1.23432e+36" } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2923 }; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2924 size_t k; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2925 for (k = 0; k < SIZEOF (data); k++) |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2926 { |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2927 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2928 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2929 my_asnprintf (NULL, &length, "%Lg", data[k].value); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2930 ASSERT (result != NULL); |
8839
5efc1d668039
Accomodate for implementations that produce 3 exponent digits in %e and %g.
Bruno Haible <bruno@clisp.org>
parents:
8836
diff
changeset
|
2931 ASSERT (strcmp (result, data[k].string) == 0); |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2932 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2933 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2934 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2935 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2936 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2937 { /* A negative number. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2938 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2939 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2940 my_asnprintf (NULL, &length, "%Lg %d", -0.03125L, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2941 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2942 ASSERT (strcmp (result, "-0.03125 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2943 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2944 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2945 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2946 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2947 { /* Positive zero. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2948 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2949 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2950 my_asnprintf (NULL, &length, "%Lg %d", 0.0L, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2951 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2952 ASSERT (strcmp (result, "0 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2953 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2954 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2955 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2956 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2957 { /* Negative zero. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2958 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2959 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2960 my_asnprintf (NULL, &length, "%Lg %d", -0.0L, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2961 ASSERT (result != NULL); |
8852
df0b5e8ea770
Avoid test failures on platforms where -0.0 and 0.0 are identical.
Bruno Haible <bruno@clisp.org>
parents:
8850
diff
changeset
|
2962 if (have_minus_zero ()) |
df0b5e8ea770
Avoid test failures on platforms where -0.0 and 0.0 are identical.
Bruno Haible <bruno@clisp.org>
parents:
8850
diff
changeset
|
2963 ASSERT (strcmp (result, "-0 33") == 0); |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2964 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2965 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2966 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2967 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2968 { /* Positive infinity. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2969 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2970 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2971 my_asnprintf (NULL, &length, "%Lg %d", 1.0L / 0.0L, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2972 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2973 ASSERT (strcmp (result, "inf 33") == 0 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2974 || strcmp (result, "infinity 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2975 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2976 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2977 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2978 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2979 { /* Negative infinity. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2980 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2981 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2982 my_asnprintf (NULL, &length, "%Lg %d", -1.0L / 0.0L, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2983 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2984 ASSERT (strcmp (result, "-inf 33") == 0 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2985 || strcmp (result, "-infinity 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2986 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2987 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2988 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2989 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2990 { /* NaN. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2991 static long double zero = 0.0L; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2992 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2993 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2994 my_asnprintf (NULL, &length, "%Lg %d", zero / zero, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2995 ASSERT (result != NULL); |
8850
d1fe16dfbfee
Avoid test failures on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents:
8839
diff
changeset
|
2996 ASSERT (strlen (result) >= 3 + 3 |
8865
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8857
diff
changeset
|
2997 && strisnan (result, 0, strlen (result) - 3, 0) |
8850
d1fe16dfbfee
Avoid test failures on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents:
8839
diff
changeset
|
2998 && strcmp (result + strlen (result) - 3, " 33") == 0); |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
2999 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3000 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3001 } |
8919
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3002 #if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3003 { /* Quiet NaN. */ |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3004 static union { unsigned int word[4]; long double value; } x = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3005 { LDBL80_WORDS (0xFFFF, 0xC3333333, 0x00000000) }; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3006 size_t length; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3007 char *result = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3008 my_asnprintf (NULL, &length, "%Lg %d", x.value, 33, 44, 55); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3009 ASSERT (result != NULL); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3010 ASSERT (strlen (result) >= 3 + 3 |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3011 && strisnan (result, 0, strlen (result) - 3, 0) |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3012 && strcmp (result + strlen (result) - 3, " 33") == 0); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3013 ASSERT (length == strlen (result)); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3014 free (result); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3015 } |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3016 { |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3017 /* Signalling NaN. */ |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3018 static union { unsigned int word[4]; long double value; } x = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3019 { LDBL80_WORDS (0xFFFF, 0x83333333, 0x00000000) }; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3020 size_t length; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3021 char *result = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3022 my_asnprintf (NULL, &length, "%Lg %d", x.value, 33, 44, 55); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3023 ASSERT (result != NULL); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3024 ASSERT (strlen (result) >= 3 + 3 |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3025 && strisnan (result, 0, strlen (result) - 3, 0) |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3026 && strcmp (result + strlen (result) - 3, " 33") == 0); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3027 ASSERT (length == strlen (result)); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3028 free (result); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3029 } |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3030 /* The isnanl function should recognize Pseudo-NaNs, Pseudo-Infinities, |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3031 Pseudo-Zeroes, Unnormalized Numbers, and Pseudo-Denormals, as defined in |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3032 Intel IA-64 Architecture Software Developer's Manual, Volume 1: |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3033 Application Architecture. |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3034 Table 5-2 "Floating-Point Register Encodings" |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3035 Figure 5-6 "Memory to Floating-Point Register Data Translation" |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3036 */ |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3037 { /* Pseudo-NaN. */ |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3038 static union { unsigned int word[4]; long double value; } x = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3039 { LDBL80_WORDS (0xFFFF, 0x40000001, 0x00000000) }; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3040 size_t length; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3041 char *result = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3042 my_asnprintf (NULL, &length, "%Lg %d", x.value, 33, 44, 55); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3043 ASSERT (result != NULL); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3044 ASSERT (strlen (result) >= 3 + 3 |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3045 && strisnan (result, 0, strlen (result) - 3, 0) |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3046 && strcmp (result + strlen (result) - 3, " 33") == 0); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3047 ASSERT (length == strlen (result)); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3048 free (result); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3049 } |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3050 { /* Pseudo-Infinity. */ |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3051 static union { unsigned int word[4]; long double value; } x = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3052 { LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) }; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3053 size_t length; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3054 char *result = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3055 my_asnprintf (NULL, &length, "%Lg %d", x.value, 33, 44, 55); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3056 ASSERT (result != NULL); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3057 ASSERT (strlen (result) >= 3 + 3 |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3058 && strisnan (result, 0, strlen (result) - 3, 0) |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3059 && strcmp (result + strlen (result) - 3, " 33") == 0); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3060 ASSERT (length == strlen (result)); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3061 free (result); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3062 } |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3063 { /* Pseudo-Zero. */ |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3064 static union { unsigned int word[4]; long double value; } x = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3065 { LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) }; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3066 size_t length; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3067 char *result = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3068 my_asnprintf (NULL, &length, "%Lg %d", x.value, 33, 44, 55); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3069 ASSERT (result != NULL); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3070 ASSERT (strlen (result) >= 3 + 3 |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3071 && strisnan (result, 0, strlen (result) - 3, 0) |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3072 && strcmp (result + strlen (result) - 3, " 33") == 0); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3073 ASSERT (length == strlen (result)); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3074 free (result); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3075 } |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3076 { /* Unnormalized number. */ |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3077 static union { unsigned int word[4]; long double value; } x = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3078 { LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) }; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3079 size_t length; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3080 char *result = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3081 my_asnprintf (NULL, &length, "%Lg %d", x.value, 33, 44, 55); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3082 ASSERT (result != NULL); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3083 ASSERT (strlen (result) >= 3 + 3 |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3084 && strisnan (result, 0, strlen (result) - 3, 0) |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3085 && strcmp (result + strlen (result) - 3, " 33") == 0); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3086 ASSERT (length == strlen (result)); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3087 free (result); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3088 } |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3089 { /* Pseudo-Denormal. */ |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3090 static union { unsigned int word[4]; long double value; } x = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3091 { LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) }; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3092 size_t length; |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3093 char *result = |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3094 my_asnprintf (NULL, &length, "%Lg %d", x.value, 33, 44, 55); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3095 ASSERT (result != NULL); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3096 ASSERT (strlen (result) >= 3 + 3 |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3097 && strisnan (result, 0, strlen (result) - 3, 0) |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3098 && strcmp (result + strlen (result) - 3, " 33") == 0); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3099 ASSERT (length == strlen (result)); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3100 free (result); |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3101 } |
42e2847583f9
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
3102 #endif |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3103 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3104 { /* Width. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3105 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3106 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3107 my_asnprintf (NULL, &length, "%10Lg %d", 1.75L, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3108 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3109 ASSERT (strcmp (result, " 1.75 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3110 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3111 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3112 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3113 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3114 { /* FLAG_LEFT. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3115 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3116 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3117 my_asnprintf (NULL, &length, "%-10Lg %d", 1.75L, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3118 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3119 ASSERT (strcmp (result, "1.75 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3120 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3121 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3122 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3123 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3124 { /* FLAG_SHOWSIGN. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3125 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3126 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3127 my_asnprintf (NULL, &length, "%+Lg %d", 1.75L, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3128 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3129 ASSERT (strcmp (result, "+1.75 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3130 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3131 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3132 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3133 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3134 { /* FLAG_SPACE. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3135 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3136 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3137 my_asnprintf (NULL, &length, "% Lg %d", 1.75L, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3138 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3139 ASSERT (strcmp (result, " 1.75 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3140 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3141 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3142 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3143 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3144 { /* FLAG_ALT. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3145 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3146 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3147 my_asnprintf (NULL, &length, "%#Lg %d", 1.75L, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3148 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3149 ASSERT (strcmp (result, "1.75000 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3150 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3151 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3152 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3153 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3154 { /* FLAG_ALT. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3155 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3156 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3157 my_asnprintf (NULL, &length, "%#.Lg %d", 1.75L, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3158 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3159 ASSERT (strcmp (result, "2. 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3160 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3161 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3162 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3163 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3164 { /* FLAG_ALT. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3165 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3166 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3167 my_asnprintf (NULL, &length, "%#.Lg %d", 9.75L, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3168 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3169 ASSERT (strcmp (result, "1.e+01 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3170 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3171 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3172 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3173 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3174 { /* FLAG_ZERO with finite number. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3175 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3176 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3177 my_asnprintf (NULL, &length, "%010Lg %d", 1234.0L, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3178 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3179 ASSERT (strcmp (result, "0000001234 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3180 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3181 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3182 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3183 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3184 { /* FLAG_ZERO with infinite number. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3185 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3186 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3187 my_asnprintf (NULL, &length, "%015Lg %d", -1.0L / 0.0L, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3188 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3189 ASSERT (strcmp (result, " -inf 33") == 0 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3190 || strcmp (result, " -infinity 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3191 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3192 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3193 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3194 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3195 { /* FLAG_ZERO with NaN. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3196 static long double zero = 0.0L; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3197 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3198 char *result = |
8870
4e1f2ea486b4
Allow for a longer printed representation of NaN.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
3199 my_asnprintf (NULL, &length, "%050Lg %d", zero / zero, 33, 44, 55); |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3200 ASSERT (result != NULL); |
8870
4e1f2ea486b4
Allow for a longer printed representation of NaN.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
3201 ASSERT (strlen (result) == 50 + 3 |
8865
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8857
diff
changeset
|
3202 && strisnan (result, strspn (result, " "), strlen (result) - 3, 0) |
8850
d1fe16dfbfee
Avoid test failures on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents:
8839
diff
changeset
|
3203 && strcmp (result + strlen (result) - 3, " 33") == 0); |
8836
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3204 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3205 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3206 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3207 |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3208 { /* Precision. */ |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3209 size_t length; |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3210 char *result = |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3211 my_asnprintf (NULL, &length, "%.Lg %d", 1234.0L, 33, 44, 55); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3212 ASSERT (result != NULL); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3213 ASSERT (strcmp (result, "1e+03 33") == 0); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3214 ASSERT (length == strlen (result)); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3215 free (result); |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3216 } |
07084ab003b8
Add tests for %e and %g directives.
Bruno Haible <bruno@clisp.org>
parents:
8834
diff
changeset
|
3217 |
8336
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3218 /* Test the support of the %n format directive. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3219 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3220 { |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3221 int count = -1; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3222 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3223 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3224 my_asnprintf (NULL, &length, "%d %n", 123, &count, 33, 44, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3225 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3226 ASSERT (strcmp (result, "123 ") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3227 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3228 ASSERT (count == 4); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3229 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3230 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3231 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3232 /* Test the support of the POSIX/XSI format strings with positions. */ |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3233 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3234 { |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3235 size_t length; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3236 char *result = |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3237 my_asnprintf (NULL, &length, "%2$d %1$d", 33, 55); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3238 ASSERT (result != NULL); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3239 ASSERT (strcmp (result, "55 33") == 0); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3240 ASSERT (length == strlen (result)); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3241 free (result); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3242 } |
8803
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8754
diff
changeset
|
3243 |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8754
diff
changeset
|
3244 /* Test the support of the grouping flag. */ |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8754
diff
changeset
|
3245 |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8754
diff
changeset
|
3246 { |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8754
diff
changeset
|
3247 size_t length; |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8754
diff
changeset
|
3248 char *result = |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8754
diff
changeset
|
3249 my_asnprintf (NULL, &length, "%'d %d", 1234567, 99); |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8754
diff
changeset
|
3250 ASSERT (result != NULL); |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8754
diff
changeset
|
3251 ASSERT (result[strlen (result) - 1] == '9'); |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8754
diff
changeset
|
3252 ASSERT (length == strlen (result)); |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8754
diff
changeset
|
3253 free (result); |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8754
diff
changeset
|
3254 } |
8336
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3255 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3256 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3257 static char * |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3258 my_asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...) |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3259 { |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3260 va_list args; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3261 char *ret; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3262 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3263 va_start (args, format); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3264 ret = vasnprintf (resultbuf, lengthp, format, args); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3265 va_end (args); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3266 return ret; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3267 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3268 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3269 static void |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3270 test_vasnprintf () |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3271 { |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3272 test_function (my_asnprintf); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3273 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3274 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3275 static void |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3276 test_asnprintf () |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3277 { |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3278 test_function (asnprintf); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3279 } |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3280 |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3281 int |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3282 main (int argc, char *argv[]) |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3283 { |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3284 test_vasnprintf (); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3285 test_asnprintf (); |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3286 return 0; |
493708637f61
Tests for module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3287 } |