Allow direct use of math_ldbl.h in testsuite.
[glibc.git] / sysdeps / ieee754 / ldbl-96 / test-totalorderl-ldbl-96.c
blob4e01f15aa9c4364ed7ac2adaa893a3b777ee82ab
1 /* Test totalorderl and totalordermagl for ldbl-96.
2 Copyright (C) 2016-2017 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 #include <float.h>
20 #include <math.h>
21 #include <math_ldbl.h>
22 #include <stdbool.h>
23 #include <stdint.h>
24 #include <stdio.h>
26 static const uint64_t tests[] =
28 0, 1, 0x4000000000000000ULL, 0x4000000000000001ULL,
29 0x7fffffffffffffffULL
32 static int
33 do_test (void)
35 int result = 0;
37 if (LDBL_MIN_EXP == -16382)
38 for (size_t i = 0; i < sizeof (tests) / sizeof (tests[0]); i++)
40 long double ldx, ldy, ldnx, ldny;
41 /* Verify that the high bit of the mantissa is ignored for
42 infinities and NaNs for the M68K variant of this
43 format. */
44 SET_LDOUBLE_WORDS (ldx, 0x7fff,
45 tests[i] >> 32, tests[i] & 0xffffffffULL);
46 SET_LDOUBLE_WORDS (ldy, 0x7fff,
47 (tests[i] >> 32) | 0x80000000,
48 tests[i] & 0xffffffffULL);
49 SET_LDOUBLE_WORDS (ldnx, 0xffff,
50 tests[i] >> 32, tests[i] & 0xffffffffULL);
51 SET_LDOUBLE_WORDS (ldny, 0xffff,
52 (tests[i] >> 32) | 0x80000000,
53 tests[i] & 0xffffffffULL);
54 bool to1 = totalorderl (ldx, ldy);
55 bool to2 = totalorderl (ldy, ldx);
56 bool to3 = totalorderl (ldnx, ldny);
57 bool to4 = totalorderl (ldny, ldnx);
58 if (to1 && to2 && to3 && to4)
59 printf ("PASS: test %zu\n", i);
60 else
62 printf ("FAIL: test %zu\n", i);
63 result = 1;
65 to1 = totalordermagl (ldx, ldy);
66 to2 = totalordermagl (ldy, ldx);
67 to3 = totalordermagl (ldnx, ldny);
68 to4 = totalordermagl (ldny, ldnx);
69 if (to1 && to2 && to3 && to4)
70 printf ("PASS: test %zu (totalordermagl)\n", i);
71 else
73 printf ("FAIL: test %zu (totalordermagl)\n", i);
74 result = 1;
78 return result;
81 #define TEST_FUNCTION do_test ()
82 #include "../test-skeleton.c"