[libc-commits] [libc] d599ed4 - [libc][NFC] Use ASSERT_FP_EQ to comapre NaN values in tests.
Siva Chandra Reddy via libc-commits
libc-commits at lists.llvm.org
Thu Dec 17 23:19:25 PST 2020
Author: Siva Chandra Reddy
Date: 2020-12-17T23:16:26-08:00
New Revision: d599ed49b355f1481bf8b22774e1a902352c9766
URL: https://github.com/llvm/llvm-project/commit/d599ed49b355f1481bf8b22774e1a902352c9766
DIFF: https://github.com/llvm/llvm-project/commit/d599ed49b355f1481bf8b22774e1a902352c9766.diff
LOG: [libc][NFC] Use ASSERT_FP_EQ to comapre NaN values in tests.
This is a continuation of the previous CL which did a similar change in
other tests. To elaborate a little about why we need this - under C++
compilation with headers not from LLVM libc, libraries like libc++ and
libstdc++ provide their own math.h which undefine macros like `isnan`
and provide the overloaded C++ isnan functions which return a boolean
value instead of an integer value returned by the isnan macro.
Added:
Modified:
libc/test/src/math/FDimTest.h
libc/test/src/math/RemQuoTest.h
libc/test/src/math/fmax_test.cpp
libc/test/src/math/fmaxf_test.cpp
libc/test/src/math/fmaxl_test.cpp
libc/test/src/math/fmin_test.cpp
libc/test/src/math/fminf_test.cpp
libc/test/src/math/fminl_test.cpp
Removed:
################################################################################
diff --git a/libc/test/src/math/FDimTest.h b/libc/test/src/math/FDimTest.h
index f052dc382f16..4b95427b113b 100644
--- a/libc/test/src/math/FDimTest.h
+++ b/libc/test/src/math/FDimTest.h
@@ -26,7 +26,7 @@ class FDimTestTemplate : public __llvm_libc::testing::Test {
EXPECT_FP_EQ(nan, func(negZero, nan));
EXPECT_FP_EQ(nan, func(nan, T(-1.2345)));
EXPECT_FP_EQ(nan, func(T(1.2345), nan));
- EXPECT_NE(isnan(func(nan, nan)), 0);
+ EXPECT_FP_EQ(func(nan, nan), nan);
}
void testInfArg(FuncPtr func) {
diff --git a/libc/test/src/math/RemQuoTest.h b/libc/test/src/math/RemQuoTest.h
index 29fcdb83b6a2..66f2f0956348 100644
--- a/libc/test/src/math/RemQuoTest.h
+++ b/libc/test/src/math/RemQuoTest.h
@@ -38,27 +38,27 @@ class RemQuoTestTemplate : public __llvm_libc::testing::Test {
y = T(1.0);
x = inf;
- EXPECT_NE(isnan(func(x, y, "ient)), 0);
+ EXPECT_FP_EQ(nan, func(x, y, "ient));
x = negInf;
- EXPECT_NE(isnan(func(x, y, "ient)), 0);
+ EXPECT_FP_EQ(nan, func(x, y, "ient));
x = T(1.0);
y = zero;
- EXPECT_NE(isnan(func(x, y, "ient)), 0);
+ EXPECT_FP_EQ(nan, func(x, y, "ient));
y = negZero;
- EXPECT_NE(isnan(func(x, y, "ient)), 0);
+ EXPECT_FP_EQ(nan, func(x, y, "ient));
y = nan;
x = T(1.0);
- EXPECT_NE(isnan(func(x, y, "ient)), 0);
+ EXPECT_FP_EQ(nan, func(x, y, "ient));
y = T(1.0);
x = nan;
- EXPECT_NE(isnan(func(x, y, "ient)), 0);
+ EXPECT_FP_EQ(nan, func(x, y, "ient));
x = nan;
y = nan;
- EXPECT_NE(isnan(func(x, y, "ient)), 0);
+ EXPECT_FP_EQ(nan, func(x, y, "ient));
x = zero;
y = T(1.0);
diff --git a/libc/test/src/math/fmax_test.cpp b/libc/test/src/math/fmax_test.cpp
index b84db3003cc6..4be7e0208dc7 100644
--- a/libc/test/src/math/fmax_test.cpp
+++ b/libc/test/src/math/fmax_test.cpp
@@ -23,7 +23,7 @@ TEST(FmaxTest, NaNArg) {
EXPECT_FP_EQ(-0.0, __llvm_libc::fmax(-0.0, aNaN));
EXPECT_FP_EQ(-1.2345, __llvm_libc::fmax(aNaN, -1.2345));
EXPECT_FP_EQ(1.2345, __llvm_libc::fmax(1.2345, aNaN));
- EXPECT_NE(isnan(__llvm_libc::fmax(aNaN, aNaN)), 0);
+ EXPECT_FP_EQ(aNaN, __llvm_libc::fmax(aNaN, aNaN));
}
TEST(FmaxTest, InfArg) {
diff --git a/libc/test/src/math/fmaxf_test.cpp b/libc/test/src/math/fmaxf_test.cpp
index 7d6661cb4b8b..812dd4c8e5af 100644
--- a/libc/test/src/math/fmaxf_test.cpp
+++ b/libc/test/src/math/fmaxf_test.cpp
@@ -23,7 +23,7 @@ TEST(FmaxfTest, NaNArg) {
EXPECT_FP_EQ(-0.0f, __llvm_libc::fmaxf(-0.0f, aNaN));
EXPECT_FP_EQ(-1.2345f, __llvm_libc::fmaxf(aNaN, -1.2345f));
EXPECT_FP_EQ(1.2345f, __llvm_libc::fmaxf(1.2345f, aNaN));
- EXPECT_NE(isnan(__llvm_libc::fmaxf(aNaN, aNaN)), 0);
+ EXPECT_FP_EQ(aNaN, __llvm_libc::fmaxf(aNaN, aNaN));
}
TEST(FmaxfTest, InfArg) {
diff --git a/libc/test/src/math/fmaxl_test.cpp b/libc/test/src/math/fmaxl_test.cpp
index 72f7636cb0eb..6eac0095c62a 100644
--- a/libc/test/src/math/fmaxl_test.cpp
+++ b/libc/test/src/math/fmaxl_test.cpp
@@ -23,7 +23,7 @@ TEST(FmaxlTest, NaNArg) {
EXPECT_FP_EQ(-0.0L, __llvm_libc::fmaxl(-0.0L, aNaN));
EXPECT_FP_EQ(-1.2345L, __llvm_libc::fmaxl(aNaN, -1.2345L));
EXPECT_FP_EQ(1.2345L, __llvm_libc::fmaxl(1.2345L, aNaN));
- EXPECT_NE(isnan(__llvm_libc::fmaxl(aNaN, aNaN)), 0);
+ EXPECT_FP_EQ(aNaN, __llvm_libc::fmaxl(aNaN, aNaN));
}
TEST(FmaxlTest, InfArg) {
diff --git a/libc/test/src/math/fmin_test.cpp b/libc/test/src/math/fmin_test.cpp
index 5deaa857c1f2..6782e8cb9e80 100644
--- a/libc/test/src/math/fmin_test.cpp
+++ b/libc/test/src/math/fmin_test.cpp
@@ -23,7 +23,7 @@ TEST(FminTest, NaNArg) {
EXPECT_FP_EQ(-0.0, __llvm_libc::fmin(-0.0, aNaN));
EXPECT_FP_EQ(-1.2345, __llvm_libc::fmin(aNaN, -1.2345));
EXPECT_FP_EQ(1.2345, __llvm_libc::fmin(1.2345, aNaN));
- EXPECT_NE(isnan(__llvm_libc::fmin(aNaN, aNaN)), 0);
+ EXPECT_FP_EQ(aNaN, __llvm_libc::fmin(aNaN, aNaN));
}
TEST(FminTest, InfArg) {
diff --git a/libc/test/src/math/fminf_test.cpp b/libc/test/src/math/fminf_test.cpp
index d9a01dd506d8..f7c16e57702b 100644
--- a/libc/test/src/math/fminf_test.cpp
+++ b/libc/test/src/math/fminf_test.cpp
@@ -23,7 +23,7 @@ TEST(FminfTest, NaNArg) {
EXPECT_FP_EQ(-0.0f, __llvm_libc::fminf(-0.0f, aNaN));
EXPECT_FP_EQ(-1.2345f, __llvm_libc::fminf(aNaN, -1.2345f));
EXPECT_FP_EQ(1.2345f, __llvm_libc::fminf(1.2345f, aNaN));
- EXPECT_NE(isnan(__llvm_libc::fminf(aNaN, aNaN)), 0);
+ EXPECT_FP_EQ(aNaN, __llvm_libc::fminf(aNaN, aNaN));
}
TEST(FminfTest, InfArg) {
diff --git a/libc/test/src/math/fminl_test.cpp b/libc/test/src/math/fminl_test.cpp
index 75200b1212e5..289c3957e3c1 100644
--- a/libc/test/src/math/fminl_test.cpp
+++ b/libc/test/src/math/fminl_test.cpp
@@ -23,7 +23,7 @@ TEST(FminlTest, NaNArg) {
EXPECT_FP_EQ(-0.0L, __llvm_libc::fminl(-0.0L, aNaN));
EXPECT_FP_EQ(-1.2345L, __llvm_libc::fminl(aNaN, -1.2345L));
EXPECT_FP_EQ(1.2345L, __llvm_libc::fminl(1.2345L, aNaN));
- EXPECT_NE(isnan(__llvm_libc::fminl(aNaN, aNaN)), 0);
+ EXPECT_FP_EQ(aNaN, __llvm_libc::fminl(aNaN, aNaN));
}
TEST(FminlTest, InfArg) {
More information about the libc-commits
mailing list