am 001815ed: Merge "Reset enviroment for math_tests"
				
					
				
			* commit '001815ed197280409d08e9622890e7462c6e6831': Reset enviroment for math_tests
This commit is contained in:
		@@ -53,6 +53,8 @@ template<typename T> inline int test_capture_isinf(const T in) {
 | 
				
			|||||||
#include <limits.h>
 | 
					#include <limits.h>
 | 
				
			||||||
#include <stdint.h>
 | 
					#include <stdint.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <private/ScopeGuard.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
float float_subnormal() {
 | 
					float float_subnormal() {
 | 
				
			||||||
  union {
 | 
					  union {
 | 
				
			||||||
    float f;
 | 
					    float f;
 | 
				
			||||||
@@ -760,6 +762,10 @@ TEST(math, erfcl) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TEST(math, lrint) {
 | 
					TEST(math, lrint) {
 | 
				
			||||||
 | 
					  auto guard = create_scope_guard([]() {
 | 
				
			||||||
 | 
					    fesetenv(FE_DFL_ENV);
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  fesetround(FE_UPWARD); // lrint/lrintf/lrintl obey the rounding mode.
 | 
					  fesetround(FE_UPWARD); // lrint/lrintf/lrintl obey the rounding mode.
 | 
				
			||||||
  ASSERT_EQ(1235, lrint(1234.01));
 | 
					  ASSERT_EQ(1235, lrint(1234.01));
 | 
				
			||||||
  ASSERT_EQ(1235, lrintf(1234.01f));
 | 
					  ASSERT_EQ(1235, lrintf(1234.01f));
 | 
				
			||||||
@@ -780,6 +786,10 @@ TEST(math, lrint) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TEST(math, rint) {
 | 
					TEST(math, rint) {
 | 
				
			||||||
 | 
					  auto guard = create_scope_guard([]() {
 | 
				
			||||||
 | 
					    fesetenv(FE_DFL_ENV);
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  fesetround(FE_UPWARD); // rint/rintf/rintl obey the rounding mode.
 | 
					  fesetround(FE_UPWARD); // rint/rintf/rintl obey the rounding mode.
 | 
				
			||||||
  feclearexcept(FE_ALL_EXCEPT); // rint/rintf/rintl do set the FE_INEXACT flag.
 | 
					  feclearexcept(FE_ALL_EXCEPT); // rint/rintf/rintl do set the FE_INEXACT flag.
 | 
				
			||||||
  ASSERT_EQ(1234.0, rint(1234.0));
 | 
					  ASSERT_EQ(1234.0, rint(1234.0));
 | 
				
			||||||
@@ -806,6 +816,9 @@ TEST(math, rint) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TEST(math, nearbyint) {
 | 
					TEST(math, nearbyint) {
 | 
				
			||||||
 | 
					  auto guard = create_scope_guard([]() {
 | 
				
			||||||
 | 
					    fesetenv(FE_DFL_ENV);
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
  fesetround(FE_UPWARD); // nearbyint/nearbyintf/nearbyintl obey the rounding mode.
 | 
					  fesetround(FE_UPWARD); // nearbyint/nearbyintf/nearbyintl obey the rounding mode.
 | 
				
			||||||
  feclearexcept(FE_ALL_EXCEPT); // nearbyint/nearbyintf/nearbyintl don't set the FE_INEXACT flag.
 | 
					  feclearexcept(FE_ALL_EXCEPT); // nearbyint/nearbyintf/nearbyintl don't set the FE_INEXACT flag.
 | 
				
			||||||
  ASSERT_EQ(1234.0, nearbyint(1234.0));
 | 
					  ASSERT_EQ(1234.0, nearbyint(1234.0));
 | 
				
			||||||
@@ -832,6 +845,9 @@ TEST(math, nearbyint) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TEST(math, lround) {
 | 
					TEST(math, lround) {
 | 
				
			||||||
 | 
					  auto guard = create_scope_guard([]() {
 | 
				
			||||||
 | 
					    fesetenv(FE_DFL_ENV);
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
  fesetround(FE_UPWARD); // lround ignores the rounding mode.
 | 
					  fesetround(FE_UPWARD); // lround ignores the rounding mode.
 | 
				
			||||||
  ASSERT_EQ(1234, lround(1234.01));
 | 
					  ASSERT_EQ(1234, lround(1234.01));
 | 
				
			||||||
  ASSERT_EQ(1234, lroundf(1234.01f));
 | 
					  ASSERT_EQ(1234, lroundf(1234.01f));
 | 
				
			||||||
@@ -839,6 +855,9 @@ TEST(math, lround) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TEST(math, llround) {
 | 
					TEST(math, llround) {
 | 
				
			||||||
 | 
					  auto guard = create_scope_guard([]() {
 | 
				
			||||||
 | 
					    fesetenv(FE_DFL_ENV);
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
  fesetround(FE_UPWARD); // llround ignores the rounding mode.
 | 
					  fesetround(FE_UPWARD); // llround ignores the rounding mode.
 | 
				
			||||||
  ASSERT_EQ(1234L, llround(1234.01));
 | 
					  ASSERT_EQ(1234L, llround(1234.01));
 | 
				
			||||||
  ASSERT_EQ(1234L, llroundf(1234.01f));
 | 
					  ASSERT_EQ(1234L, llroundf(1234.01f));
 | 
				
			||||||
@@ -933,6 +952,9 @@ TEST(math, fdiml) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TEST(math, round) {
 | 
					TEST(math, round) {
 | 
				
			||||||
 | 
					  auto guard = create_scope_guard([]() {
 | 
				
			||||||
 | 
					    fesetenv(FE_DFL_ENV);
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
  fesetround(FE_TOWARDZERO); // round ignores the rounding mode and always rounds away from zero.
 | 
					  fesetround(FE_TOWARDZERO); // round ignores the rounding mode and always rounds away from zero.
 | 
				
			||||||
  ASSERT_DOUBLE_EQ(1.0, round(0.5));
 | 
					  ASSERT_DOUBLE_EQ(1.0, round(0.5));
 | 
				
			||||||
  ASSERT_DOUBLE_EQ(-1.0, round(-0.5));
 | 
					  ASSERT_DOUBLE_EQ(-1.0, round(-0.5));
 | 
				
			||||||
@@ -943,6 +965,9 @@ TEST(math, round) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TEST(math, roundf) {
 | 
					TEST(math, roundf) {
 | 
				
			||||||
 | 
					  auto guard = create_scope_guard([]() {
 | 
				
			||||||
 | 
					    fesetenv(FE_DFL_ENV);
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
  fesetround(FE_TOWARDZERO); // roundf ignores the rounding mode and always rounds away from zero.
 | 
					  fesetround(FE_TOWARDZERO); // roundf ignores the rounding mode and always rounds away from zero.
 | 
				
			||||||
  ASSERT_FLOAT_EQ(1.0f, roundf(0.5f));
 | 
					  ASSERT_FLOAT_EQ(1.0f, roundf(0.5f));
 | 
				
			||||||
  ASSERT_FLOAT_EQ(-1.0f, roundf(-0.5f));
 | 
					  ASSERT_FLOAT_EQ(-1.0f, roundf(-0.5f));
 | 
				
			||||||
@@ -953,6 +978,9 @@ TEST(math, roundf) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TEST(math, roundl) {
 | 
					TEST(math, roundl) {
 | 
				
			||||||
 | 
					  auto guard = create_scope_guard([]() {
 | 
				
			||||||
 | 
					    fesetenv(FE_DFL_ENV);
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
  fesetround(FE_TOWARDZERO); // roundl ignores the rounding mode and always rounds away from zero.
 | 
					  fesetround(FE_TOWARDZERO); // roundl ignores the rounding mode and always rounds away from zero.
 | 
				
			||||||
  ASSERT_DOUBLE_EQ(1.0L, roundl(0.5L));
 | 
					  ASSERT_DOUBLE_EQ(1.0L, roundl(0.5L));
 | 
				
			||||||
  ASSERT_DOUBLE_EQ(-1.0L, roundl(-0.5L));
 | 
					  ASSERT_DOUBLE_EQ(-1.0L, roundl(-0.5L));
 | 
				
			||||||
@@ -963,6 +991,9 @@ TEST(math, roundl) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TEST(math, trunc) {
 | 
					TEST(math, trunc) {
 | 
				
			||||||
 | 
					  auto guard = create_scope_guard([]() {
 | 
				
			||||||
 | 
					    fesetenv(FE_DFL_ENV);
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
  fesetround(FE_UPWARD); // trunc ignores the rounding mode and always rounds toward zero.
 | 
					  fesetround(FE_UPWARD); // trunc ignores the rounding mode and always rounds toward zero.
 | 
				
			||||||
  ASSERT_DOUBLE_EQ(1.0, trunc(1.5));
 | 
					  ASSERT_DOUBLE_EQ(1.0, trunc(1.5));
 | 
				
			||||||
  ASSERT_DOUBLE_EQ(-1.0, trunc(-1.5));
 | 
					  ASSERT_DOUBLE_EQ(-1.0, trunc(-1.5));
 | 
				
			||||||
@@ -973,6 +1004,9 @@ TEST(math, trunc) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TEST(math, truncf) {
 | 
					TEST(math, truncf) {
 | 
				
			||||||
 | 
					  auto guard = create_scope_guard([]() {
 | 
				
			||||||
 | 
					    fesetenv(FE_DFL_ENV);
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
  fesetround(FE_UPWARD); // truncf ignores the rounding mode and always rounds toward zero.
 | 
					  fesetround(FE_UPWARD); // truncf ignores the rounding mode and always rounds toward zero.
 | 
				
			||||||
  ASSERT_FLOAT_EQ(1.0f, truncf(1.5f));
 | 
					  ASSERT_FLOAT_EQ(1.0f, truncf(1.5f));
 | 
				
			||||||
  ASSERT_FLOAT_EQ(-1.0f, truncf(-1.5f));
 | 
					  ASSERT_FLOAT_EQ(-1.0f, truncf(-1.5f));
 | 
				
			||||||
@@ -983,6 +1017,9 @@ TEST(math, truncf) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TEST(math, truncl) {
 | 
					TEST(math, truncl) {
 | 
				
			||||||
 | 
					  auto guard = create_scope_guard([]() {
 | 
				
			||||||
 | 
					    fesetenv(FE_DFL_ENV);
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
  fesetround(FE_UPWARD); // truncl ignores the rounding mode and always rounds toward zero.
 | 
					  fesetround(FE_UPWARD); // truncl ignores the rounding mode and always rounds toward zero.
 | 
				
			||||||
  ASSERT_DOUBLE_EQ(1.0L, truncl(1.5L));
 | 
					  ASSERT_DOUBLE_EQ(1.0L, truncl(1.5L));
 | 
				
			||||||
  ASSERT_DOUBLE_EQ(-1.0L, truncl(-1.5L));
 | 
					  ASSERT_DOUBLE_EQ(-1.0L, truncl(-1.5L));
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -196,7 +196,7 @@ class StringTestState {
 | 
				
			|||||||
  const size_t MAX_LEN;
 | 
					  const size_t MAX_LEN;
 | 
				
			||||||
  Character *ptr, *ptr1, *ptr2;
 | 
					  Character *ptr, *ptr1, *ptr2;
 | 
				
			||||||
  size_t n;
 | 
					  size_t n;
 | 
				
			||||||
  int len[ITER + 1];
 | 
					  size_t len[ITER + 1];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 private:
 | 
					 private:
 | 
				
			||||||
  static size_t alignments[];
 | 
					  static size_t alignments[];
 | 
				
			||||||
@@ -212,7 +212,7 @@ class StringTestState {
 | 
				
			|||||||
    n = 0;
 | 
					    n = 0;
 | 
				
			||||||
    len[n++] = 0;
 | 
					    len[n++] = 0;
 | 
				
			||||||
    for (size_t i = 1; i < ITER; ++i) {
 | 
					    for (size_t i = 1; i < ITER; ++i) {
 | 
				
			||||||
      int l = (int) exp(log((double) MAX_LEN) * i / ITER);
 | 
					      size_t l = static_cast<size_t>(exp(log(static_cast<double>(MAX_LEN)) * i / ITER));
 | 
				
			||||||
      if (l != len[n - 1]) {
 | 
					      if (l != len[n - 1]) {
 | 
				
			||||||
        len[n++] = l;
 | 
					        len[n++] = l;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
@@ -430,7 +430,7 @@ TEST(string, strchr) {
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
      state.ptr1[state.len[i] - 1] = '\0';
 | 
					      state.ptr1[state.len[i] - 1] = '\0';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      int pos = random() % state.MAX_LEN;
 | 
					      size_t pos = random() % state.MAX_LEN;
 | 
				
			||||||
      char* expected;
 | 
					      char* expected;
 | 
				
			||||||
      if (pos >= state.len[i] - 1) {
 | 
					      if (pos >= state.len[i] - 1) {
 | 
				
			||||||
        if (seek_char == 0) {
 | 
					        if (seek_char == 0) {
 | 
				
			||||||
@@ -457,7 +457,7 @@ TEST(string, strcmp) {
 | 
				
			|||||||
      state.ptr1[state.len[i] - 1] = '\0';
 | 
					      state.ptr1[state.len[i] - 1] = '\0';
 | 
				
			||||||
      state.ptr2[state.len[i] - 1] = '\0';
 | 
					      state.ptr2[state.len[i] - 1] = '\0';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      int pos = 1 + (random() % (state.MAX_LEN - 1));
 | 
					      size_t pos = 1 + (random() % (state.MAX_LEN - 1));
 | 
				
			||||||
      int actual;
 | 
					      int actual;
 | 
				
			||||||
      int expected;
 | 
					      int expected;
 | 
				
			||||||
      if (pos >= state.len[i] - 1) {
 | 
					      if (pos >= state.len[i] - 1) {
 | 
				
			||||||
@@ -540,7 +540,7 @@ TEST(string, strlcat) {
 | 
				
			|||||||
      state.ptr2[state.MAX_LEN - 1] = '\0';
 | 
					      state.ptr2[state.MAX_LEN - 1] = '\0';
 | 
				
			||||||
      memcpy(state.ptr, state.ptr2, state.MAX_LEN + state.len[i]);
 | 
					      memcpy(state.ptr, state.ptr2, state.MAX_LEN + state.len[i]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      int pos = random() % state.MAX_LEN;
 | 
					      size_t pos = random() % state.MAX_LEN;
 | 
				
			||||||
      memset(state.ptr1, '\3', pos);
 | 
					      memset(state.ptr1, '\3', pos);
 | 
				
			||||||
      state.ptr1[pos] = '\0';
 | 
					      state.ptr1[pos] = '\0';
 | 
				
			||||||
      if (pos < state.len[i]) {
 | 
					      if (pos < state.len[i]) {
 | 
				
			||||||
@@ -625,7 +625,7 @@ TEST(string, strncmp) {
 | 
				
			|||||||
      state.ptr1[state.len[i] - 1] = '\0';
 | 
					      state.ptr1[state.len[i] - 1] = '\0';
 | 
				
			||||||
      state.ptr2[state.len[i] - 1] = '\0';
 | 
					      state.ptr2[state.len[i] - 1] = '\0';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      int pos = 1 + (random() % (state.MAX_LEN - 1));
 | 
					      size_t pos = 1 + (random() % (state.MAX_LEN - 1));
 | 
				
			||||||
      int actual;
 | 
					      int actual;
 | 
				
			||||||
      int expected;
 | 
					      int expected;
 | 
				
			||||||
      if (pos >= state.len[i] - 1) {
 | 
					      if (pos >= state.len[i] - 1) {
 | 
				
			||||||
@@ -735,7 +735,7 @@ TEST(string, strrchr) {
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
      state.ptr1[state.len[i] - 1] = '\0';
 | 
					      state.ptr1[state.len[i] - 1] = '\0';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      int pos = random() % state.MAX_LEN;
 | 
					      size_t pos = random() % state.MAX_LEN;
 | 
				
			||||||
      char* expected;
 | 
					      char* expected;
 | 
				
			||||||
      if (pos >= state.len[i] - 1) {
 | 
					      if (pos >= state.len[i] - 1) {
 | 
				
			||||||
        if (seek_char == 0) {
 | 
					        if (seek_char == 0) {
 | 
				
			||||||
@@ -760,7 +760,7 @@ TEST(string, memchr) {
 | 
				
			|||||||
    for (state.BeginIterations(); state.HasNextIteration(); state.NextIteration()) {
 | 
					    for (state.BeginIterations(); state.HasNextIteration(); state.NextIteration()) {
 | 
				
			||||||
      memset(state.ptr1, ~seek_char, state.len[i]);
 | 
					      memset(state.ptr1, ~seek_char, state.len[i]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      int pos = random() % state.MAX_LEN;
 | 
					      size_t pos = random() % state.MAX_LEN;
 | 
				
			||||||
      char* expected;
 | 
					      char* expected;
 | 
				
			||||||
      if (pos >= state.len[i]) {
 | 
					      if (pos >= state.len[i]) {
 | 
				
			||||||
        expected = NULL;
 | 
					        expected = NULL;
 | 
				
			||||||
@@ -789,7 +789,7 @@ TEST(string, memrchr) {
 | 
				
			|||||||
    for (state.BeginIterations(); state.HasNextIteration(); state.NextIteration()) {
 | 
					    for (state.BeginIterations(); state.HasNextIteration(); state.NextIteration()) {
 | 
				
			||||||
      memset(state.ptr1, ~seek_char, state.len[i]);
 | 
					      memset(state.ptr1, ~seek_char, state.len[i]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      int pos = random() % state.MAX_LEN;
 | 
					      size_t pos = random() % state.MAX_LEN;
 | 
				
			||||||
      char* expected;
 | 
					      char* expected;
 | 
				
			||||||
      if (pos >= state.len[i]) {
 | 
					      if (pos >= state.len[i]) {
 | 
				
			||||||
        expected = NULL;
 | 
					        expected = NULL;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user