usleep tests: Avoid failure due to known Cygwin 3.5.3 bug.
[gnulib.git] / tests / test-stdio.c
blobb64948c943e440b0a60566aa14f8083639b68d2a
1 /* Test of <stdio.h> substitute.
2 Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 /* Written by Bruno Haible <bruno@clisp.org>, 2007. */
19 #include <config.h>
21 #include <stdio.h>
23 /* Check that the various SEEK_* macros are defined. */
24 int sk[] = { SEEK_CUR, SEEK_END, SEEK_SET };
26 /* Check that the _PRINTF_NAN_LEN_MAX macro is defined. */
27 int pnlm[] = { _PRINTF_NAN_LEN_MAX };
29 /* Check that NULL can be passed through varargs as a pointer type,
30 per POSIX 2008. */
31 static_assert (sizeof NULL == sizeof (void *));
33 /* Check that the types are all defined. */
34 fpos_t t1;
35 off_t t2;
36 size_t t3;
37 ssize_t t4;
38 va_list t5;
39 off64_t t6;
41 #include <string.h>
43 #include "signed-nan.h"
44 #include "signed-snan.h"
45 #include "macros.h"
47 int
48 main (void)
51 double value1;
52 char buf[64];
54 value1 = positive_NaNd();
55 sprintf (buf, "%g", value1);
56 ASSERT (strlen (buf) <= _PRINTF_NAN_LEN_MAX);
58 value1 = negative_NaNd();
59 sprintf (buf, "%g", value1);
60 ASSERT (strlen (buf) <= _PRINTF_NAN_LEN_MAX);
62 #if defined DBL_EXPBIT0_WORD && defined DBL_EXPBIT0_BIT
63 /* Check the value of _PRINTF_NAN_LEN_MAX. */
65 double value1;
66 memory_double value2;
67 char buf[64];
69 value1 = positive_SNaNd();
70 sprintf (buf, "%g", value1);
71 ASSERT (strlen (buf) <= _PRINTF_NAN_LEN_MAX);
73 value1 = negative_SNaNd();
74 sprintf (buf, "%g", value1);
75 ASSERT (strlen (buf) <= _PRINTF_NAN_LEN_MAX);
77 value2.value = positive_NaNd ();
78 #if DBL_EXPBIT0_BIT == 20
79 value2.word[DBL_EXPBIT0_WORD] ^= 0x54321;
80 #endif
81 sprintf (buf, "%g", value2.value);
82 ASSERT (strlen (buf) <= _PRINTF_NAN_LEN_MAX);
84 value2.value = negative_NaNd ();
85 #if DBL_EXPBIT0_BIT == 20
86 value2.word[DBL_EXPBIT0_WORD] ^= 0x54321;
87 #endif
88 sprintf (buf, "%g", value2.value);
89 ASSERT (strlen (buf) <= _PRINTF_NAN_LEN_MAX);
91 #endif
93 return test_exit_status;