[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.
GitOrigin-RevId: d599ed49b355f1481bf8b22774e1a902352c9766
diff --git a/test/src/math/FDimTest.h b/test/src/math/FDimTest.h
index f052dc3..4b95427 100644
--- a/test/src/math/FDimTest.h
+++ b/test/src/math/FDimTest.h
@@ -26,7 +26,7 @@
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/test/src/math/RemQuoTest.h b/test/src/math/RemQuoTest.h
index 29fcdb8..66f2f09 100644
--- a/test/src/math/RemQuoTest.h
+++ b/test/src/math/RemQuoTest.h
@@ -38,27 +38,27 @@
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/test/src/math/fmax_test.cpp b/test/src/math/fmax_test.cpp
index b84db30..4be7e02 100644
--- a/test/src/math/fmax_test.cpp
+++ b/test/src/math/fmax_test.cpp
@@ -23,7 +23,7 @@
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/test/src/math/fmaxf_test.cpp b/test/src/math/fmaxf_test.cpp
index 7d6661c..812dd4c 100644
--- a/test/src/math/fmaxf_test.cpp
+++ b/test/src/math/fmaxf_test.cpp
@@ -23,7 +23,7 @@
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/test/src/math/fmaxl_test.cpp b/test/src/math/fmaxl_test.cpp
index 72f7636..6eac009 100644
--- a/test/src/math/fmaxl_test.cpp
+++ b/test/src/math/fmaxl_test.cpp
@@ -23,7 +23,7 @@
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/test/src/math/fmin_test.cpp b/test/src/math/fmin_test.cpp
index 5deaa85..6782e8c 100644
--- a/test/src/math/fmin_test.cpp
+++ b/test/src/math/fmin_test.cpp
@@ -23,7 +23,7 @@
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/test/src/math/fminf_test.cpp b/test/src/math/fminf_test.cpp
index d9a01dd..f7c16e5 100644
--- a/test/src/math/fminf_test.cpp
+++ b/test/src/math/fminf_test.cpp
@@ -23,7 +23,7 @@
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/test/src/math/fminl_test.cpp b/test/src/math/fminl_test.cpp
index 75200b1..289c395 100644
--- a/test/src/math/fminl_test.cpp
+++ b/test/src/math/fminl_test.cpp
@@ -23,7 +23,7 @@
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) {