Home | History | Annotate | Download | only in Unit
      1 //===------------ gttf2_test.c - Test __gttf2------------------------------===//
      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 __gttf2 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 
     20 int __gttf2(long double a, long double b);
     21 
     22 int test__gttf2(long double a, long double b, enum EXPECTED_RESULT expected)
     23 {
     24     int x = __gttf2(a, b);
     25     int ret = compareResultCMP(x, expected);
     26 
     27     if (ret){
     28         printf("error in test__gttf2(%.20Lf, %.20Lf) = %d, "
     29                "expected %s\n", a, b, x, expectedStr(expected));
     30     }
     31     return ret;
     32 }
     33 
     34 char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
     35 
     36 #endif
     37 
     38 int main()
     39 {
     40 #if __LP64__ && __LDBL_MANT_DIG__ == 113
     41     // NaN
     42     if (test__gttf2(makeQNaN128(),
     43                     0x1.234567890abcdef1234567890abcp+3L,
     44                     LESS_EQUAL_0))
     45         return 1;
     46     // <
     47     // exp
     48     if (test__gttf2(0x1.234567890abcdef1234567890abcp-3L,
     49                     0x1.234567890abcdef1234567890abcp+3L,
     50                     LESS_EQUAL_0))
     51         return 1;
     52     // mantissa
     53     if (test__gttf2(0x1.234567890abcdef1234567890abcp+3L,
     54                     0x1.334567890abcdef1234567890abcp+3L,
     55                     LESS_EQUAL_0))
     56         return 1;
     57     // sign
     58     if (test__gttf2(-0x1.234567890abcdef1234567890abcp+3L,
     59                     0x1.234567890abcdef1234567890abcp+3L,
     60                     LESS_EQUAL_0))
     61         return 1;
     62     // ==
     63     if (test__gttf2(0x1.234567890abcdef1234567890abcp+3L,
     64                     0x1.234567890abcdef1234567890abcp+3L,
     65                     LESS_EQUAL_0))
     66         return 1;
     67     // >
     68     // exp
     69     if (test__gttf2(0x1.234567890abcdef1234567890abcp+3L,
     70                     0x1.234567890abcdef1234567890abcp-3L,
     71                     GREATER_0))
     72         return 1;
     73     // mantissa
     74     if (test__gttf2(0x1.334567890abcdef1234567890abcp+3L,
     75                     0x1.234567890abcdef1234567890abcp+3L,
     76                     GREATER_0))
     77         return 1;
     78     // sign
     79     if (test__gttf2(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