1 /* $NetBSD: t_floatunditf.c,v 1.6 2014/11/04 00:20:19 justin Exp $ */
4 * Copyright (c) 2014 The NetBSD Foundation, Inc.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
33 #ifdef __HAVE_LONG_DOUBLE
38 { 0xffffffffffffffffULL
, 0xf.fffffffffffffffp
+60L },
39 { 0xfffffffffffffffeULL
, 0xf.ffffffffffffffep
+60L },
40 { 0xfffffffffffffffdULL
, 0xf.ffffffffffffffdp
+60L },
41 { 0xfffffffffffffffcULL
, 0xf.ffffffffffffffcp
+60L },
42 { 0x7fffffffffffffffULL
, 0xf.ffffffffffffffep
+59L },
43 { 0x3fffffffffffffffULL
, 0xf.ffffffffffffffcp
+58L },
44 { 0x1fffffffffffffffULL
, 0xf.ffffffffffffff8p
+57L },
45 { 0xfffffffffffffffULL
, 0xf.ffffffffffffffp
+56L },
46 { 0x7ffffffffffffffULL
, 0xf.fffffffffffffep
+55L },
47 { 0x3ffffffffffffffULL
, 0xf.fffffffffffffcp
+54L },
48 { 0x1ffffffffffffffULL
, 0xf.fffffffffffff8p
+53L },
49 { 0xffffffffffffffULL
, 0xf.fffffffffffffp
+52L },
50 { 0x7fffffffffffffULL
, 0xf.ffffffffffffep
+51L },
51 { 0x3fffffffffffffULL
, 0xf.ffffffffffffcp
+50L },
52 { 0x1fffffffffffffULL
, 0xf.ffffffffffff8p
+49L },
53 { 0xfffffffffffffULL
, 0xf.ffffffffffffp
+48L },
54 { 0x7ffffffffffffULL
, 0xf.fffffffffffep
+47L },
55 { 0x3ffffffffffffULL
, 0xf.fffffffffffcp
+46L },
56 { 0x1ffffffffffffULL
, 0xf.fffffffffff8p
+45L },
57 { 0xffffffffffffULL
, 0xf.fffffffffffp
+44L },
58 { 0x7fffffffffffULL
, 0xf.ffffffffffep
+43L },
59 { 0x3fffffffffffULL
, 0xf.ffffffffffcp
+42L },
60 { 0x1fffffffffffULL
, 0xf.ffffffffff8p
+41L },
61 { 0xfffffffffffULL
, 0xf.ffffffffffp
+40L },
62 { 0x7ffffffffffULL
, 0xf.fffffffffep
+39L },
63 { 0x3ffffffffffULL
, 0xf.fffffffffcp
+38L },
64 { 0x1ffffffffffULL
, 0xf.fffffffff8p
+37L },
65 { 0xffffffffffULL
, 0xf.fffffffffp
+36L },
66 { 0x7fffffffffULL
, 0xf.ffffffffep
+35L },
67 { 0x3fffffffffULL
, 0xf.ffffffffcp
+34L },
68 { 0x1fffffffffULL
, 0xf.ffffffff8p
+33L },
69 { 0xfffffffffULL
, 0xf.ffffffffp
+32L },
70 { 0x7ffffffffULL
, 0xf.fffffffep
+31L },
71 { 0x3ffffffffULL
, 0xf.fffffffcp
+30L },
72 { 0x1ffffffffULL
, 0xf.fffffff8p
+29L },
73 { 0xffffffffULL
, 0xf.fffffffp
+28L },
74 { 0x7fffffffULL
, 0xf.ffffffep
+27L },
75 { 0x3fffffffULL
, 0xf.ffffffcp
+26L },
76 { 0x1fffffffULL
, 0xf.ffffff8p
+25L },
77 { 0xfffffffULL
, 0xf.ffffffp
+24L },
78 { 0x7ffffffULL
, 0xf.fffffep
+23L },
79 { 0x3ffffffULL
, 0xf.fffffcp
+22L },
80 { 0x1ffffffULL
, 0xf.fffff8p
+21L },
81 { 0xffffffULL
, 0xf.fffffp
+20L },
82 { 0x7fffffULL
, 0xf.ffffep
+19L },
83 { 0x3fffffULL
, 0xf.ffffcp
+18L },
84 { 0x1fffffULL
, 0xf.ffff8p
+17L },
85 { 0xfffffULL
, 0xf.ffffp
+16L },
86 { 0x7ffffULL
, 0xf.fffep
+15L },
87 { 0x3ffffULL
, 0xf.fffcp
+14L },
88 { 0x1ffffULL
, 0xf.fff8p
+13L },
89 { 0xffffULL
, 0xf.fffp
+12L },
90 { 0x7fffULL
, 0xf.ffep
+11L },
91 { 0x3fffULL
, 0xf.ffcp
+10L },
92 { 0x1fffULL
, 0xf.ff8p
+9L },
93 { 0xfffULL
, 0xf.ffp
+8L },
94 { 0x7ffULL
, 0xf.fep
+7L },
95 { 0x3ffULL
, 0xf.fcp
+6L },
96 { 0x1ffULL
, 0xf.f8p
+5L },
97 { 0xffULL
, 0xf.fp
+4L },
98 { 0x7fULL
, 0xf.ep
+3L },
99 { 0x3fULL
, 0xf.cp
+2L },
100 { 0x1fULL
, 0xf.8p
+1L },
109 ATF_TC_HEAD(floatunditf
, tc
)
111 atf_tc_set_md_var(tc
, "descr",
112 "Verify that uint64 -> long double conversion works");
115 ATF_TC_BODY(floatunditf
, tc
)
117 #ifndef __HAVE_LONG_DOUBLE
118 atf_tc_skip("Requires long double support");
122 for (i
= 0; i
< __arraycount(testcases
); ++i
)
124 testcases
[i
].ld
== (long double)testcases
[i
].u64
,
125 "#%zu: expected %.20Lf, got %.20Lf\n", i
,
127 (long double)testcases
[i
].u64
);
133 ATF_TP_ADD_TC(tp
, floatunditf
);
134 return atf_no_error();