usleep tests: Avoid failure due to known Cygwin 3.5.3 bug.
[gnulib.git] / tests / test-math.c
blobd33ec7e5e22506c0f7af2357bc779eb4b74aa92c
1 /* Test of <math.h> substitute.
2 Copyright (C) 2007-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 <math.h>
23 #ifndef NAN
24 # error NAN should be defined
25 choke me
26 #endif
28 #ifndef HUGE_VALF
29 # error HUGE_VALF should be defined
30 choke me
31 #endif
33 #ifndef HUGE_VAL
34 # error HUGE_VAL should be defined
35 choke me
36 #endif
38 #ifndef HUGE_VALL
39 # error HUGE_VALL should be defined
40 choke me
41 #endif
43 #ifndef FP_ILOGB0
44 # error FP_ILOGB0 should be defined
45 choke me
46 #endif
48 #ifndef FP_ILOGBNAN
49 # error FP_ILOGBNAN should be defined
50 choke me
51 #endif
53 #if 0
54 /* Check that NAN expands into a constant expression. */
55 static float n = NAN;
56 #endif
58 #include <limits.h>
60 #include "macros.h"
62 /* Compare two numbers with ==.
63 This is a separate function because IRIX 6.5 "cc -O" miscompiles an
64 'x == x' test. */
65 static int
66 numeric_equalf (float x, float y)
68 return x == y;
70 static int
71 numeric_equald (double x, double y)
73 return x == y;
75 static int
76 numeric_equall (long double x, long double y)
78 return x == y;
81 int
82 main (void)
84 double d = NAN;
85 double zero = 0.0;
86 ASSERT (!numeric_equald (d, d));
88 d = HUGE_VAL;
89 ASSERT (numeric_equald (d, 1.0 / zero));
91 ASSERT (numeric_equalf (HUGE_VALF, HUGE_VALF + HUGE_VALF));
93 ASSERT (numeric_equald (HUGE_VAL, HUGE_VAL + HUGE_VAL));
95 ASSERT (numeric_equall (HUGE_VALL, HUGE_VALL + HUGE_VALL));
97 /* Check the value of FP_ILOGB0. */
98 ASSERT (FP_ILOGB0 == INT_MIN || FP_ILOGB0 == - INT_MAX);
100 /* Check the value of FP_ILOGBNAN. */
101 ASSERT (FP_ILOGBNAN == INT_MIN || FP_ILOGBNAN == INT_MAX);
103 return test_exit_status;