trunctfdf2_test.c revision 1.1.1.1
1//===-------------- trunctfdf2_test.c - Test __trunctfdf2 -----------------===// 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 __trunctfdf2 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 20double __trunctfdf2(long double a); 21 22int test__trunctfdf2(long double a, uint64_t expected) 23{ 24 double x = __trunctfdf2(a); 25 int ret = compareResultD(x, expected); 26 27 if (ret) 28 { 29 printf("error in test__trunctfdf2(%.20Lf) = %lf, " 30 "expected %lf\n", a, x, fromRep64(expected)); 31 } 32 return ret; 33} 34 35char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0}; 36 37#endif 38 39int main() 40{ 41#if __LDBL_MANT_DIG__ == 113 42 // qNaN 43 if (test__trunctfdf2(makeQNaN128(), 44 UINT64_C(0x7ff8000000000000))) 45 return 1; 46 // NaN 47 if (test__trunctfdf2(makeNaN128(UINT64_C(0x810000000000)), 48 UINT64_C(0x7ff8100000000000))) 49 return 1; 50 // inf 51 if (test__trunctfdf2(makeInf128(), 52 UINT64_C(0x7ff0000000000000))) 53 return 1; 54 // zero 55 if (test__trunctfdf2(0.0L, UINT64_C(0x0))) 56 return 1; 57 58 if (test__trunctfdf2(0x1.af23456789bbaaab347645365cdep+5L, 59 UINT64_C(0x404af23456789bbb))) 60 return 1; 61 if (test__trunctfdf2(0x1.dedafcff354b6ae9758763545432p-9L, 62 UINT64_C(0x3f6dedafcff354b7))) 63 return 1; 64 if (test__trunctfdf2(0x1.2f34dd5f437e849b4baab754cdefp+4534L, 65 UINT64_C(0x7ff0000000000000))) 66 return 1; 67 if (test__trunctfdf2(0x1.edcbff8ad76ab5bf46463233214fp-435L, 68 UINT64_C(0x24cedcbff8ad76ab))) 69 return 1; 70 71#else 72 printf("skipped\n"); 73 74#endif 75 return 0; 76} 77