From 0524da67b448dcce6569fae0f54c10f208c2dc56 Mon Sep 17 00:00:00 2001 From: Siva Chandra Reddy Date: Tue, 15 Dec 2020 23:44:44 -0800 Subject: [PATCH] [libc][NFC] Use ASSERT_FP_EQ to comapre NaN values in tests. --- libc/test/src/math/LdExpTest.h | 2 +- libc/test/src/math/ceil_test.cpp | 3 +-- libc/test/src/math/ceilf_test.cpp | 3 +-- libc/test/src/math/ceill_test.cpp | 3 +-- libc/test/src/math/floor_test.cpp | 3 +-- libc/test/src/math/floorf_test.cpp | 3 +-- libc/test/src/math/floorl_test.cpp | 3 +-- libc/test/src/math/round_test.cpp | 3 +-- libc/test/src/math/roundf_test.cpp | 3 +-- libc/test/src/math/roundl_test.cpp | 3 +-- libc/test/src/math/trunc_test.cpp | 3 +-- libc/test/src/math/truncf_test.cpp | 3 +-- libc/test/src/math/truncl_test.cpp | 3 +-- 13 files changed, 13 insertions(+), 25 deletions(-) diff --git a/libc/test/src/math/LdExpTest.h b/libc/test/src/math/LdExpTest.h index ebc2cd3..b4be06b 100644 --- a/libc/test/src/math/LdExpTest.h +++ b/libc/test/src/math/LdExpTest.h @@ -44,7 +44,7 @@ public: 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 1537227..6019ce5 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 aa3ea73..9f4cc74 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 b33d317..89ff954 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 35f107a..5421bb0 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 e6bc974..f545de2 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 cad5c70..16f6309 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 defa22a..4ab248a 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 2665e81..b08c7ef 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 ff33c07..18f36cb 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 89fa17d..58020df 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 bd44ce7..3d5c5e3 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 3c70a3a..f00d0c3 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) { -- 2.7.4