Home | History | Annotate | Download | only in tests
      1 #include <math.h>
      2 
      3 #include <minitest/minitest.h>
      4 
      5 TEST(math, sizeof_long_double) {
      6 #ifdef __ANDROID__
      7 #  ifdef __LP64__
      8     EXPECT_EQ(16U, sizeof(long double));
      9 #  else
     10     EXPECT_EQ(8U, sizeof(long double));
     11 #  endif
     12 #endif
     13 }
     14 
     15 TEST(math, nexttoward) {
     16     double x = 2.0;
     17     EXPECT_EQ(x, nexttoward(x, (long double)x));
     18     EXPECT_GT(x, nexttoward(x, (long double)(x * 2.)));
     19     EXPECT_LT(x, nexttoward(x, (long double)(x - 1.0)));
     20 }
     21 
     22 TEST(math, nexttowardf) {
     23     float x = 2.0;
     24     EXPECT_EQ(x, nexttowardf(x, (long double)x));
     25     EXPECT_GT(x, nexttowardf(x, (long double)(x * 2.)));
     26     EXPECT_LT(x, nexttowardf(x, (long double)(x - 1.0)));
     27 }
     28 
     29 TEST(math, nexttowardl) {
     30     long double x = 2.0;
     31     EXPECT_EQ(x, nexttowardl(x, x));
     32     EXPECT_GT(x, nexttowardl(x, x * 2.));
     33     EXPECT_LT(x, nexttowardl(x, x - 1.0));
     34 }
     35 
     36 // These functions are not exported on x86 before API level 18!
     37 TEST(math, scalbln) {
     38     EXPECT_EQ(16., scalbln(2.0, (long int)3));
     39 }
     40 
     41 TEST(math, scalblnf) {
     42     EXPECT_EQ((float)16., scalblnf((float)2.0, (long int)3));
     43 }
     44 
     45 TEST(math, scalblnl) {
     46     EXPECT_EQ((long double)16., scalblnl((long double)2.0, (long int)3));
     47 }
     48