annotate tests/test-truncf1.c @ 14079:97fc9a21a8fb

maint: update almost all copyright ranges to include 2011 Run the new "make update-copyright" rule.
author Jim Meyering <meyering@redhat.com>
date Sat, 01 Jan 2011 20:17:23 +0100
parents 84d7ae75b38f
children 328819af1c02
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9325
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* Test of rounding towards zero.
14079
97fc9a21a8fb maint: update almost all copyright ranges to include 2011
Jim Meyering <meyering@redhat.com>
parents: 13979
diff changeset
2 Copyright (C) 2007-2011 Free Software Foundation, Inc.
9325
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 This program is free software: you can redistribute it and/or modify
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6 the Free Software Foundation; either version 3 of the License, or
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 (at your option) any later version.
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 GNU General Public License for more details.
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 /* Written by Bruno Haible <bruno@clisp.org>, 2007. */
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19 #include <config.h>
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21 #include <math.h>
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22
12489
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents: 12421
diff changeset
23 #include "signature.h"
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents: 12421
diff changeset
24 SIGNATURE_CHECK (truncf, float, (float));
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents: 12421
diff changeset
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"
9854
baba3b346ab2 Use macros NaNf, NaNd, NaNl instead of NAN.
Bruno Haible <bruno@clisp.org>
parents: 9850
diff changeset
28 #include "nan.h"
12496
a48d3d749ca5 Refactor common macros used in tests.
Bruno Haible <bruno@clisp.org>
parents: 12489
diff changeset
29 #include "macros.h"
9325
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31 int
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32 main ()
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33 {
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34 /* Zero. */
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35 ASSERT (truncf (0.0f) == 0.0f);
13834
108bbfd6f03b frexp, tests: work around ICC bug with -zero
Eric Blake <eblake@redhat.com>
parents: 12559
diff changeset
36 ASSERT (truncf (minus_zerof) == 0.0f);
9325
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37 /* Positive numbers. */
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38 ASSERT (truncf (0.3f) == 0.0f);
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
39 ASSERT (truncf (0.7f) == 0.0f);
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
40 ASSERT (truncf (1.0f) == 1.0f);
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41 ASSERT (truncf (1.5f) == 1.0f);
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42 ASSERT (truncf (1.999f) == 1.0f);
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
43 ASSERT (truncf (2.0f) == 2.0f);
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
44 ASSERT (truncf (65535.99f) == 65535.0f);
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
45 ASSERT (truncf (65536.0f) == 65536.0f);
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
46 ASSERT (truncf (2.341e31f) == 2.341e31f);
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
47 /* Negative numbers. */
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
48 ASSERT (truncf (-0.3f) == 0.0f);
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49 ASSERT (truncf (-0.7f) == 0.0f);
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
50 ASSERT (truncf (-1.0f) == -1.0f);
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
51 ASSERT (truncf (-1.5f) == -1.0f);
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52 ASSERT (truncf (-1.999f) == -1.0f);
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53 ASSERT (truncf (-2.0f) == -2.0f);
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54 ASSERT (truncf (-65535.99f) == -65535.0f);
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55 ASSERT (truncf (-65536.0f) == -65536.0f);
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
56 ASSERT (truncf (-2.341e31f) == -2.341e31f);
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
57 /* Infinite numbers. */
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
58 ASSERT (truncf (1.0f / 0.0f) == 1.0f / 0.0f);
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
59 ASSERT (truncf (-1.0f / 0.0f) == -1.0f / 0.0f);
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
60 /* NaNs. */
9854
baba3b346ab2 Use macros NaNf, NaNd, NaNl instead of NAN.
Bruno Haible <bruno@clisp.org>
parents: 9850
diff changeset
61 ASSERT (isnanf (truncf (NaNf ())));
9325
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
62
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
63 return 0;
752dd5bd3fc6 Rename test-truncf.c to test-truncf1.c.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
64 }