1 //===--------------- extenddftf2_test.c - Test __extenddftf2 --------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file tests __extenddftf2 for the compiler_rt library.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include <stdio.h>
15
16 #if __LDBL_MANT_DIG__ == 113
17
18 #include "fp_test.h"
19
20 long double __extenddftf2(double a);
21
test__extenddftf2(double a,uint64_t expectedHi,uint64_t expectedLo)22 int test__extenddftf2(double a, uint64_t expectedHi, uint64_t expectedLo)
23 {
24 long double x = __extenddftf2(a);
25 int ret = compareResultLD(x, expectedHi, expectedLo);
26
27 if (ret){
28 printf("error in test__extenddftf2(%f) = %.20Lf, "
29 "expected %.20Lf\n", a, x, fromRep128(expectedHi, expectedLo));
30 }
31 return ret;
32 }
33
34 char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
35
36 #endif
37
main()38 int main()
39 {
40 #if __LDBL_MANT_DIG__ == 113
41 // qNaN
42 if (test__extenddftf2(makeQNaN64(),
43 UINT64_C(0x7fff800000000000),
44 UINT64_C(0x0)))
45 return 1;
46 // NaN
47 if (test__extenddftf2(makeNaN64(UINT64_C(0x7100000000000)),
48 UINT64_C(0x7fff710000000000),
49 UINT64_C(0x0)))
50 return 1;
51 // inf
52 if (test__extenddftf2(makeInf64(),
53 UINT64_C(0x7fff000000000000),
54 UINT64_C(0x0)))
55 return 1;
56 // zero
57 if (test__extenddftf2(0.0, UINT64_C(0x0), UINT64_C(0x0)))
58 return 1;
59
60 if (test__extenddftf2(0x1.23456789abcdefp+5,
61 UINT64_C(0x400423456789abcd),
62 UINT64_C(0xf000000000000000)))
63 return 1;
64 if (test__extenddftf2(0x1.edcba987654321fp-9,
65 UINT64_C(0x3ff6edcba9876543),
66 UINT64_C(0x2000000000000000)))
67 return 1;
68 if (test__extenddftf2(0x1.23456789abcdefp+45,
69 UINT64_C(0x402c23456789abcd),
70 UINT64_C(0xf000000000000000)))
71 return 1;
72 if (test__extenddftf2(0x1.edcba987654321fp-45,
73 UINT64_C(0x3fd2edcba9876543),
74 UINT64_C(0x2000000000000000)))
75 return 1;
76
77 #else
78 printf("skipped\n");
79
80 #endif
81 return 0;
82 }
83