Skip to content

Commit

Permalink
Cleanup remquo test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Rinzii committed Mar 13, 2024
1 parent eb9c197 commit 81c40e5
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions test/basic/remquo_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@
#include <limits>



constexpr double get_ccm_rem(double x, double y)
{
int quotient {0};
double remainder = ccm::remquo(x, y, &quotient); // remainder = 1
double remainder = ccm::remquo(x, y, &quotient);
return remainder;
}

Expand All @@ -31,20 +30,20 @@ constexpr int get_ccm_quo(double x, double y)
double get_std_rem(double x, double y)
{
int quotient {0};
double remainder = std::remquo(x, y, &quotient); // remainder = 1
double remainder = std::remquo(x, y, &quotient);
return remainder;
}

int get_std_quo(double x, double y)
{
int quotient {0};
std::remquo(x, y, &quotient); // remainder = 1
std::remquo(x, y, &quotient);
return quotient;
}


TEST(CcmathBasicTests, Remquo)
{
// Test that remquo can be uses in a static_assert
constexpr double sa_x = -7.0, sa_y = 2.0;
constexpr int sa_quotient = get_ccm_quo(sa_x, sa_y); // quotient = -4
constexpr double sa_remainder = get_ccm_rem(sa_x, sa_y); // remainder = 1
Expand Down Expand Up @@ -81,8 +80,6 @@ TEST(CcmathBasicTests, Remquo)
EXPECT_EQ(didCcmLeftNegativeInfinityReturnNan, didStdLeftNegativeInfinityReturnNan);
EXPECT_EQ(get_ccm_quo(-std::numeric_limits<double>::infinity(), 2.0), get_std_quo(-std::numeric_limits<double>::infinity(), 2.0));



// Test with NaN
bool isCcmLeftNanNegative = (std::signbit(get_ccm_rem(std::numeric_limits<double>::quiet_NaN(), 2.0)) == true && std::isnan(get_ccm_rem(std::numeric_limits<double>::quiet_NaN(), 2.0)) == true); // NOLINT
bool isStdLeftNanNegative = (std::signbit(get_std_rem(std::numeric_limits<double>::quiet_NaN(), 2.0)) == true && std::isnan(get_std_rem(std::numeric_limits<double>::quiet_NaN(), 2.0)) == true); // NOLINT
Expand All @@ -101,5 +98,5 @@ TEST(CcmathBasicTests, Remquo)
EXPECT_EQ(didCcmLeftNegativeNanReturnNan, didStdLeftNegativeNanReturnNan);
EXPECT_EQ(get_ccm_quo(-std::numeric_limits<double>::quiet_NaN(), 2.0), get_std_quo(-std::numeric_limits<double>::quiet_NaN(), 2.0));


// TODO: Add more test cases for remquo.
}

0 comments on commit 81c40e5

Please sign in to comment.