letf2_test.c revision 2d1fdb26e458c4ddc04155c1d421bced3ba90cd0
1//===------------ letf2_test.c - Test __letf2------------------------------===// 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 __letf2 for the compiler_rt library. 11// 12//===----------------------------------------------------------------------===// 13 14#include <stdio.h> 15 16#if __LP64__ && __LDBL_MANT_DIG__ == 113 17 18#include "fp_test.h" 19 20int __letf2(long double a, long double b); 21 22int test__letf2(long double a, long double b, enum EXPECTED_RESULT expected) 23{ 24 int x = __letf2(a, b); 25 int ret = compareResultCMP(x, expected); 26 27 if (ret){ 28 printf("error in test__letf2(%.20Lf, %.20Lf) = %d, " 29 "expected %s\n", a, b, x, expectedStr(expected)); 30 } 31 return ret; 32} 33 34char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0}; 35 36#endif 37 38int main() 39{ 40#if __LP64__ && __LDBL_MANT_DIG__ == 113 41 // NaN 42 if (test__letf2(makeQNaN128(), 43 0x1.234567890abcdef1234567890abcp+3L, 44 GREATER_0)) 45 return 1; 46 // < 47 // exp 48 if (test__letf2(0x1.234567890abcdef1234567890abcp-3L, 49 0x1.234567890abcdef1234567890abcp+3L, 50 LESS_EQUAL_0)) 51 return 1; 52 // mantissa 53 if (test__letf2(0x1.234567890abcdef1234567890abcp+3L, 54 0x1.334567890abcdef1234567890abcp+3L, 55 LESS_EQUAL_0)) 56 return 1; 57 // sign 58 if (test__letf2(-0x1.234567890abcdef1234567890abcp+3L, 59 0x1.234567890abcdef1234567890abcp+3L, 60 LESS_EQUAL_0)) 61 return 1; 62 // == 63 if (test__letf2(0x1.234567890abcdef1234567890abcp+3L, 64 0x1.234567890abcdef1234567890abcp+3L, 65 LESS_EQUAL_0)) 66 return 1; 67 // > 68 // exp 69 if (test__letf2(0x1.234567890abcdef1234567890abcp+3L, 70 0x1.234567890abcdef1234567890abcp-3L, 71 GREATER_0)) 72 return 1; 73 // mantissa 74 if (test__letf2(0x1.334567890abcdef1234567890abcp+3L, 75 0x1.234567890abcdef1234567890abcp+3L, 76 GREATER_0)) 77 return 1; 78 // sign 79 if (test__letf2(0x1.234567890abcdef1234567890abcp+3L, 80 -0x1.234567890abcdef1234567890abcp+3L, 81 GREATER_0)) 82 return 1; 83 84#else 85 printf("skipped\n"); 86 87#endif 88 return 0; 89} 90