[llvm-branch-commits] [libc] 0524da6 - [libc][NFC] Use ASSERT_FP_EQ to comapre NaN values in tests.

Siva Chandra Reddy via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Dec 15 23:54:26 PST 2020


Author: Siva Chandra Reddy
Date: 2020-12-15T23:48:54-08:00
New Revision: 0524da67b448dcce6569fae0f54c10f208c2dc56

URL: https://github.com/llvm/llvm-project/commit/0524da67b448dcce6569fae0f54c10f208c2dc56
DIFF: https://github.com/llvm/llvm-project/commit/0524da67b448dcce6569fae0f54c10f208c2dc56.diff

LOG: [libc][NFC] Use ASSERT_FP_EQ to comapre NaN values in tests.

Added: 
    

Modified: 
    libc/test/src/math/LdExpTest.h
    libc/test/src/math/ceil_test.cpp
    libc/test/src/math/ceilf_test.cpp
    libc/test/src/math/ceill_test.cpp
    libc/test/src/math/floor_test.cpp
    libc/test/src/math/floorf_test.cpp
    libc/test/src/math/floorl_test.cpp
    libc/test/src/math/round_test.cpp
    libc/test/src/math/roundf_test.cpp
    libc/test/src/math/roundl_test.cpp
    libc/test/src/math/trunc_test.cpp
    libc/test/src/math/truncf_test.cpp
    libc/test/src/math/truncl_test.cpp

Removed: 
    


################################################################################
diff  --git a/libc/test/src/math/LdExpTest.h b/libc/test/src/math/LdExpTest.h
index ebc2cd32f73a..b4be06bdaad7 100644
--- a/libc/test/src/math/LdExpTest.h
+++ b/libc/test/src/math/LdExpTest.h
@@ -44,7 +44,7 @@ class LdExpTestTemplate : public __llvm_libc::testing::Test {
       ASSERT_FP_EQ(negZero, func(negZero, exp));
       ASSERT_FP_EQ(inf, func(inf, exp));
       ASSERT_FP_EQ(negInf, func(negInf, exp));
-      ASSERT_NE(isnan(func(nan, exp)), 0);
+      ASSERT_FP_EQ(nan, func(nan, exp));
     }
   }
 

diff  --git a/libc/test/src/math/ceil_test.cpp b/libc/test/src/math/ceil_test.cpp
index 1537227d3180..6019ce5a8337 100644
--- a/libc/test/src/math/ceil_test.cpp
+++ b/libc/test/src/math/ceil_test.cpp
@@ -26,8 +26,7 @@ TEST(CeilTest, SpecialNumbers) {
   EXPECT_FP_EQ(inf, __llvm_libc::ceil(inf));
   EXPECT_FP_EQ(negInf, __llvm_libc::ceil(negInf));
 
-  ASSERT_NE(isnan(aNaN), 0);
-  ASSERT_NE(isnan(__llvm_libc::ceil(aNaN)), 0);
+  EXPECT_FP_EQ(aNaN, __llvm_libc::ceil(aNaN));
 }
 
 TEST(CeilTest, RoundedNumbers) {

diff  --git a/libc/test/src/math/ceilf_test.cpp b/libc/test/src/math/ceilf_test.cpp
index aa3ea73f0352..9f4cc74d249a 100644
--- a/libc/test/src/math/ceilf_test.cpp
+++ b/libc/test/src/math/ceilf_test.cpp
@@ -26,8 +26,7 @@ TEST(CeilfTest, SpecialNumbers) {
   EXPECT_FP_EQ(inf, __llvm_libc::ceilf(inf));
   EXPECT_FP_EQ(negInf, __llvm_libc::ceilf(negInf));
 
-  ASSERT_NE(isnan(aNaN), 0);
-  ASSERT_NE(isnan(__llvm_libc::ceilf(aNaN)), 0);
+  EXPECT_FP_EQ(aNaN, __llvm_libc::ceilf(aNaN));
 }
 
 TEST(CeilfTest, RoundedNumbers) {

diff  --git a/libc/test/src/math/ceill_test.cpp b/libc/test/src/math/ceill_test.cpp
index b33d317e0ac6..89ff9542bec1 100644
--- a/libc/test/src/math/ceill_test.cpp
+++ b/libc/test/src/math/ceill_test.cpp
@@ -26,8 +26,7 @@ TEST(CeillTest, SpecialNumbers) {
   EXPECT_FP_EQ(inf, __llvm_libc::ceill(inf));
   EXPECT_FP_EQ(negInf, __llvm_libc::ceill(negInf));
 
-  ASSERT_NE(isnan(aNaN), 0);
-  ASSERT_NE(isnan(__llvm_libc::ceill(aNaN)), 0);
+  EXPECT_FP_EQ(aNaN, __llvm_libc::ceill(aNaN));
 }
 
 TEST(CeillTest, RoundedNumbers) {

diff  --git a/libc/test/src/math/floor_test.cpp b/libc/test/src/math/floor_test.cpp
index 35f107a918cc..5421bb00dfaa 100644
--- a/libc/test/src/math/floor_test.cpp
+++ b/libc/test/src/math/floor_test.cpp
@@ -26,8 +26,7 @@ TEST(FloorTest, SpecialNumbers) {
   EXPECT_FP_EQ(inf, __llvm_libc::floor(inf));
   EXPECT_FP_EQ(negInf, __llvm_libc::floor(negInf));
 
-  ASSERT_NE(isnan(aNaN), 0);
-  ASSERT_NE(isnan(__llvm_libc::floor(aNaN)), 0);
+  EXPECT_FP_EQ(aNaN, __llvm_libc::floor(aNaN));
 }
 
 TEST(FloorTest, RoundedNumbers) {

diff  --git a/libc/test/src/math/floorf_test.cpp b/libc/test/src/math/floorf_test.cpp
index e6bc974f1fc8..f545de2941ba 100644
--- a/libc/test/src/math/floorf_test.cpp
+++ b/libc/test/src/math/floorf_test.cpp
@@ -26,8 +26,7 @@ TEST(FloorfTest, SpecialNumbers) {
   EXPECT_FP_EQ(inf, __llvm_libc::floorf(inf));
   EXPECT_FP_EQ(negInf, __llvm_libc::floorf(negInf));
 
-  ASSERT_NE(isnan(aNaN), 0);
-  ASSERT_NE(isnan(__llvm_libc::floorf(aNaN)), 0);
+  EXPECT_FP_EQ(aNaN, __llvm_libc::floorf(aNaN));
 }
 
 TEST(FloorfTest, RoundedNumbers) {

diff  --git a/libc/test/src/math/floorl_test.cpp b/libc/test/src/math/floorl_test.cpp
index cad5c70c2f5b..16f630967f76 100644
--- a/libc/test/src/math/floorl_test.cpp
+++ b/libc/test/src/math/floorl_test.cpp
@@ -26,8 +26,7 @@ TEST(FloorlTest, SpecialNumbers) {
   EXPECT_FP_EQ(inf, __llvm_libc::floorl(inf));
   EXPECT_FP_EQ(negInf, __llvm_libc::floorl(negInf));
 
-  ASSERT_NE(isnan(aNaN), 0);
-  ASSERT_NE(isnan(__llvm_libc::floorl(aNaN)), 0);
+  EXPECT_FP_EQ(aNaN, __llvm_libc::floorl(aNaN));
 }
 
 TEST(FloorlTest, RoundedNumbers) {

diff  --git a/libc/test/src/math/round_test.cpp b/libc/test/src/math/round_test.cpp
index defa22a05d44..4ab248a2349c 100644
--- a/libc/test/src/math/round_test.cpp
+++ b/libc/test/src/math/round_test.cpp
@@ -26,8 +26,7 @@ TEST(RoundTest, SpecialNumbers) {
   EXPECT_FP_EQ(inf, __llvm_libc::round(inf));
   EXPECT_FP_EQ(negInf, __llvm_libc::round(negInf));
 
-  ASSERT_NE(isnan(aNaN), 0);
-  ASSERT_NE(isnan(__llvm_libc::round(aNaN)), 0);
+  EXPECT_FP_EQ(aNaN, __llvm_libc::round(aNaN));
 }
 
 TEST(RoundTest, RoundedNumbers) {

diff  --git a/libc/test/src/math/roundf_test.cpp b/libc/test/src/math/roundf_test.cpp
index 2665e81e54c1..b08c7effcb1f 100644
--- a/libc/test/src/math/roundf_test.cpp
+++ b/libc/test/src/math/roundf_test.cpp
@@ -26,8 +26,7 @@ TEST(RoundfTest, SpecialNumbers) {
   EXPECT_FP_EQ(inf, __llvm_libc::roundf(inf));
   EXPECT_FP_EQ(negInf, __llvm_libc::roundf(negInf));
 
-  ASSERT_NE(isnan(aNaN), 0);
-  ASSERT_NE(isnan(__llvm_libc::roundf(aNaN)), 0);
+  EXPECT_FP_EQ(aNaN, __llvm_libc::roundf(aNaN));
 }
 
 TEST(RoundfTest, RoundedNumbers) {

diff  --git a/libc/test/src/math/roundl_test.cpp b/libc/test/src/math/roundl_test.cpp
index ff33c071b3b6..18f36cb52091 100644
--- a/libc/test/src/math/roundl_test.cpp
+++ b/libc/test/src/math/roundl_test.cpp
@@ -26,8 +26,7 @@ TEST(RoundlTest, SpecialNumbers) {
   EXPECT_FP_EQ(inf, __llvm_libc::roundl(inf));
   EXPECT_FP_EQ(negInf, __llvm_libc::roundl(negInf));
 
-  ASSERT_NE(isnan(aNaN), 0);
-  ASSERT_NE(isnan(__llvm_libc::roundl(aNaN)), 0);
+  EXPECT_FP_EQ(aNaN, __llvm_libc::roundl(aNaN));
 }
 
 TEST(RoundlTest, RoundedNumbers) {

diff  --git a/libc/test/src/math/trunc_test.cpp b/libc/test/src/math/trunc_test.cpp
index 89fa17d9010f..58020df53406 100644
--- a/libc/test/src/math/trunc_test.cpp
+++ b/libc/test/src/math/trunc_test.cpp
@@ -26,8 +26,7 @@ TEST(TruncTest, SpecialNumbers) {
   EXPECT_FP_EQ(inf, __llvm_libc::trunc(inf));
   EXPECT_FP_EQ(negInf, __llvm_libc::trunc(negInf));
 
-  ASSERT_NE(isnan(aNaN), 0);
-  ASSERT_NE(isnan(__llvm_libc::trunc(aNaN)), 0);
+  EXPECT_FP_EQ(aNaN, __llvm_libc::trunc(aNaN));
 }
 
 TEST(TruncTest, RoundedNumbers) {

diff  --git a/libc/test/src/math/truncf_test.cpp b/libc/test/src/math/truncf_test.cpp
index bd44ce7b1226..3d5c5e3fc6bd 100644
--- a/libc/test/src/math/truncf_test.cpp
+++ b/libc/test/src/math/truncf_test.cpp
@@ -26,8 +26,7 @@ TEST(TruncfTest, SpecialNumbers) {
   EXPECT_FP_EQ(inf, __llvm_libc::truncf(inf));
   EXPECT_FP_EQ(negInf, __llvm_libc::truncf(negInf));
 
-  ASSERT_NE(isnan(aNaN), 0);
-  ASSERT_NE(isnan(__llvm_libc::truncf(aNaN)), 0);
+  EXPECT_FP_EQ(aNaN, __llvm_libc::truncf(aNaN));
 }
 
 TEST(TruncfTest, RoundedNumbers) {

diff  --git a/libc/test/src/math/truncl_test.cpp b/libc/test/src/math/truncl_test.cpp
index 3c70a3a1593b..f00d0c375d7a 100644
--- a/libc/test/src/math/truncl_test.cpp
+++ b/libc/test/src/math/truncl_test.cpp
@@ -26,8 +26,7 @@ TEST(TrunclTest, SpecialNumbers) {
   EXPECT_FP_EQ(inf, __llvm_libc::truncl(inf));
   EXPECT_FP_EQ(negInf, __llvm_libc::truncl(negInf));
 
-  ASSERT_NE(isnan(aNaN), 0);
-  ASSERT_NE(isnan(__llvm_libc::truncl(aNaN)), 0);
+  EXPECT_FP_EQ(aNaN, __llvm_libc::truncl(aNaN));
 }
 
 TEST(TrunclTest, RoundedNumbers) {


        


More information about the llvm-branch-commits mailing list