Mercurial > gnulib
annotate tests/test-ceilf1.c @ 40231:9b3c79fdfe0b
strtod: fix clash with strtold
Problem reported for RHEL 5 by Jesse Caldwell (Bug#34817).
* lib/strtod.c (compute_minus_zero, minus_zero):
Simplify by remving the macro / external variable,
and having just a function. User changed. This avoids
the need for an external variable that might clash.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Mon, 11 Mar 2019 16:40:29 -0700 |
parents | b06060465f09 |
children |
rev | line source |
---|---|
9334
094611565479
Rename tests/test-ceilf.c to tests/test-ceilf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
1 /* Test of rounding towards positive infinity. |
40057
b06060465f09
maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents:
19484
diff
changeset
|
2 Copyright (C) 2007-2019 Free Software Foundation, Inc. |
9334
094611565479
Rename tests/test-ceilf.c to tests/test-ceilf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3 |
094611565479
Rename tests/test-ceilf.c to tests/test-ceilf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
4 This program is free software: you can redistribute it and/or modify |
094611565479
Rename tests/test-ceilf.c to tests/test-ceilf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
5 it under the terms of the GNU General Public License as published by |
094611565479
Rename tests/test-ceilf.c to tests/test-ceilf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
6 the Free Software Foundation; either version 3 of the License, or |
094611565479
Rename tests/test-ceilf.c to tests/test-ceilf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
7 (at your option) any later version. |
094611565479
Rename tests/test-ceilf.c to tests/test-ceilf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
8 |
094611565479
Rename tests/test-ceilf.c to tests/test-ceilf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
9 This program is distributed in the hope that it will be useful, |
094611565479
Rename tests/test-ceilf.c to tests/test-ceilf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
094611565479
Rename tests/test-ceilf.c to tests/test-ceilf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
094611565479
Rename tests/test-ceilf.c to tests/test-ceilf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
12 GNU General Public License for more details. |
094611565479
Rename tests/test-ceilf.c to tests/test-ceilf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
13 |
094611565479
Rename tests/test-ceilf.c to tests/test-ceilf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
14 You should have received a copy of the GNU General Public License |
19190 | 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
9334
094611565479
Rename tests/test-ceilf.c to tests/test-ceilf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
16 |
094611565479
Rename tests/test-ceilf.c to tests/test-ceilf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
17 /* Written by Bruno Haible <bruno@clisp.org>, 2007. */ |
094611565479
Rename tests/test-ceilf.c to tests/test-ceilf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
18 |
094611565479
Rename tests/test-ceilf.c to tests/test-ceilf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
19 #include <config.h> |
094611565479
Rename tests/test-ceilf.c to tests/test-ceilf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
20 |
094611565479
Rename tests/test-ceilf.c to tests/test-ceilf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
21 #include <math.h> |
094611565479
Rename tests/test-ceilf.c to tests/test-ceilf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
22 |
12489 | 23 #include "signature.h" |
24 SIGNATURE_CHECK (ceilf, float, (float)); | |
25 | |
10264
ebb7ea0c94e8
Rename isnand.h to isnand-nolibm.h, similarly for isnanf.h.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9889
diff
changeset
|
26 #include "isnanf-nolibm.h" |
13834
108bbfd6f03b
frexp, tests: work around ICC bug with -zero
Eric Blake <eblake@redhat.com>
parents:
12559
diff
changeset
|
27 #include "minus-zero.h" |
15595
328819af1c02
Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
28 #include "infinity.h" |
9854
baba3b346ab2
Use macros NaNf, NaNd, NaNl instead of NAN.
Bruno Haible <bruno@clisp.org>
parents:
9850
diff
changeset
|
29 #include "nan.h" |
12496
a48d3d749ca5
Refactor common macros used in tests.
Bruno Haible <bruno@clisp.org>
parents:
12489
diff
changeset
|
30 #include "macros.h" |
9334
094611565479
Rename tests/test-ceilf.c to tests/test-ceilf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
31 |
13839
9f1a04b1a802
ceil, floor: avoid spurious failure with icc
Eric Blake <eblake@redhat.com>
parents:
13835
diff
changeset
|
32 /* If IEEE compliance was not requested, the ICC compiler inlines its |
9f1a04b1a802
ceil, floor: avoid spurious failure with icc
Eric Blake <eblake@redhat.com>
parents:
13835
diff
changeset
|
33 own ceilf assembly that turns -0.0f to 0.0f; but that is a correct |
9f1a04b1a802
ceil, floor: avoid spurious failure with icc
Eric Blake <eblake@redhat.com>
parents:
13835
diff
changeset
|
34 result when IEEE is not enforced. To avoid spurious failure, we |
9f1a04b1a802
ceil, floor: avoid spurious failure with icc
Eric Blake <eblake@redhat.com>
parents:
13835
diff
changeset
|
35 have to provide this dummy function in order to outsmart ICC's |
9f1a04b1a802
ceil, floor: avoid spurious failure with icc
Eric Blake <eblake@redhat.com>
parents:
13835
diff
changeset
|
36 inlining, and call our ceilf through a function pointer. */ |
9f1a04b1a802
ceil, floor: avoid spurious failure with icc
Eric Blake <eblake@redhat.com>
parents:
13835
diff
changeset
|
37 static float |
9f1a04b1a802
ceil, floor: avoid spurious failure with icc
Eric Blake <eblake@redhat.com>
parents:
13835
diff
changeset
|
38 dummy (float f) |
9f1a04b1a802
ceil, floor: avoid spurious failure with icc
Eric Blake <eblake@redhat.com>
parents:
13835
diff
changeset
|
39 { |
9f1a04b1a802
ceil, floor: avoid spurious failure with icc
Eric Blake <eblake@redhat.com>
parents:
13835
diff
changeset
|
40 return 0; |
9f1a04b1a802
ceil, floor: avoid spurious failure with icc
Eric Blake <eblake@redhat.com>
parents:
13835
diff
changeset
|
41 } |
9f1a04b1a802
ceil, floor: avoid spurious failure with icc
Eric Blake <eblake@redhat.com>
parents:
13835
diff
changeset
|
42 |
9334
094611565479
Rename tests/test-ceilf.c to tests/test-ceilf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
43 int |
13839
9f1a04b1a802
ceil, floor: avoid spurious failure with icc
Eric Blake <eblake@redhat.com>
parents:
13835
diff
changeset
|
44 main (int argc, char **argv _GL_UNUSED) |
9334
094611565479
Rename tests/test-ceilf.c to tests/test-ceilf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
45 { |
13839
9f1a04b1a802
ceil, floor: avoid spurious failure with icc
Eric Blake <eblake@redhat.com>
parents:
13835
diff
changeset
|
46 float (*my_ceilf) (float) = argc ? ceilf : dummy; |
9f1a04b1a802
ceil, floor: avoid spurious failure with icc
Eric Blake <eblake@redhat.com>
parents:
13835
diff
changeset
|
47 |
9334
094611565479
Rename tests/test-ceilf.c to tests/test-ceilf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
48 /* Zero. */ |
13839
9f1a04b1a802
ceil, floor: avoid spurious failure with icc
Eric Blake <eblake@redhat.com>
parents:
13835
diff
changeset
|
49 ASSERT (my_ceilf (0.0f) == 0.0f); |
9f1a04b1a802
ceil, floor: avoid spurious failure with icc
Eric Blake <eblake@redhat.com>
parents:
13835
diff
changeset
|
50 ASSERT (my_ceilf (minus_zerof) == 0.0f); |
9334
094611565479
Rename tests/test-ceilf.c to tests/test-ceilf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
51 /* Positive numbers. */ |
13839
9f1a04b1a802
ceil, floor: avoid spurious failure with icc
Eric Blake <eblake@redhat.com>
parents:
13835
diff
changeset
|
52 ASSERT (my_ceilf (0.3f) == 1.0f); |
9f1a04b1a802
ceil, floor: avoid spurious failure with icc
Eric Blake <eblake@redhat.com>
parents:
13835
diff
changeset
|
53 ASSERT (my_ceilf (0.7f) == 1.0f); |
9f1a04b1a802
ceil, floor: avoid spurious failure with icc
Eric Blake <eblake@redhat.com>
parents:
13835
diff
changeset
|
54 ASSERT (my_ceilf (1.0f) == 1.0f); |
9f1a04b1a802
ceil, floor: avoid spurious failure with icc
Eric Blake <eblake@redhat.com>
parents:
13835
diff
changeset
|
55 ASSERT (my_ceilf (1.001f) == 2.0f); |
9f1a04b1a802
ceil, floor: avoid spurious failure with icc
Eric Blake <eblake@redhat.com>
parents:
13835
diff
changeset
|
56 ASSERT (my_ceilf (1.5f) == 2.0f); |
9f1a04b1a802
ceil, floor: avoid spurious failure with icc
Eric Blake <eblake@redhat.com>
parents:
13835
diff
changeset
|
57 ASSERT (my_ceilf (1.999f) == 2.0f); |
9f1a04b1a802
ceil, floor: avoid spurious failure with icc
Eric Blake <eblake@redhat.com>
parents:
13835
diff
changeset
|
58 ASSERT (my_ceilf (2.0f) == 2.0f); |
9f1a04b1a802
ceil, floor: avoid spurious failure with icc
Eric Blake <eblake@redhat.com>
parents:
13835
diff
changeset
|
59 ASSERT (my_ceilf (65535.99f) == 65536.0f); |
9f1a04b1a802
ceil, floor: avoid spurious failure with icc
Eric Blake <eblake@redhat.com>
parents:
13835
diff
changeset
|
60 ASSERT (my_ceilf (65536.0f) == 65536.0f); |
9f1a04b1a802
ceil, floor: avoid spurious failure with icc
Eric Blake <eblake@redhat.com>
parents:
13835
diff
changeset
|
61 ASSERT (my_ceilf (2.341e31f) == 2.341e31f); |
9334
094611565479
Rename tests/test-ceilf.c to tests/test-ceilf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
62 /* Negative numbers. */ |
13839
9f1a04b1a802
ceil, floor: avoid spurious failure with icc
Eric Blake <eblake@redhat.com>
parents:
13835
diff
changeset
|
63 ASSERT (my_ceilf (-0.3f) == 0.0f); |
9f1a04b1a802
ceil, floor: avoid spurious failure with icc
Eric Blake <eblake@redhat.com>
parents:
13835
diff
changeset
|
64 ASSERT (my_ceilf (-0.7f) == 0.0f); |
9f1a04b1a802
ceil, floor: avoid spurious failure with icc
Eric Blake <eblake@redhat.com>
parents:
13835
diff
changeset
|
65 ASSERT (my_ceilf (-1.0f) == -1.0f); |
9f1a04b1a802
ceil, floor: avoid spurious failure with icc
Eric Blake <eblake@redhat.com>
parents:
13835
diff
changeset
|
66 ASSERT (my_ceilf (-1.5f) == -1.0f); |
9f1a04b1a802
ceil, floor: avoid spurious failure with icc
Eric Blake <eblake@redhat.com>
parents:
13835
diff
changeset
|
67 ASSERT (my_ceilf (-1.999f) == -1.0f); |
9f1a04b1a802
ceil, floor: avoid spurious failure with icc
Eric Blake <eblake@redhat.com>
parents:
13835
diff
changeset
|
68 ASSERT (my_ceilf (-2.0f) == -2.0f); |
9f1a04b1a802
ceil, floor: avoid spurious failure with icc
Eric Blake <eblake@redhat.com>
parents:
13835
diff
changeset
|
69 ASSERT (my_ceilf (-65535.99f) == -65535.0f); |
9f1a04b1a802
ceil, floor: avoid spurious failure with icc
Eric Blake <eblake@redhat.com>
parents:
13835
diff
changeset
|
70 ASSERT (my_ceilf (-65536.0f) == -65536.0f); |
9f1a04b1a802
ceil, floor: avoid spurious failure with icc
Eric Blake <eblake@redhat.com>
parents:
13835
diff
changeset
|
71 ASSERT (my_ceilf (-2.341e31f) == -2.341e31f); |
9334
094611565479
Rename tests/test-ceilf.c to tests/test-ceilf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
72 /* Infinite numbers. */ |
15595
328819af1c02
Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
73 ASSERT (my_ceilf (Infinityf ()) == Infinityf ()); |
328819af1c02
Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
74 ASSERT (my_ceilf (- Infinityf ()) == - Infinityf ()); |
9334
094611565479
Rename tests/test-ceilf.c to tests/test-ceilf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
75 /* NaNs. */ |
13839
9f1a04b1a802
ceil, floor: avoid spurious failure with icc
Eric Blake <eblake@redhat.com>
parents:
13835
diff
changeset
|
76 ASSERT (isnanf (my_ceilf (NaNf ()))); |
9334
094611565479
Rename tests/test-ceilf.c to tests/test-ceilf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
77 |
094611565479
Rename tests/test-ceilf.c to tests/test-ceilf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
78 return 0; |
094611565479
Rename tests/test-ceilf.c to tests/test-ceilf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
79 } |