13
13
#include < limits>
14
14
15
15
16
-
17
16
constexpr double get_ccm_rem (double x, double y)
18
17
{
19
18
int quotient {0 };
20
- double remainder = ccm::remquo (x, y, "ient); // remainder = 1
19
+ double remainder = ccm::remquo (x, y, "ient);
21
20
return remainder;
22
21
}
23
22
@@ -31,20 +30,20 @@ constexpr int get_ccm_quo(double x, double y)
31
30
double get_std_rem (double x, double y)
32
31
{
33
32
int quotient {0 };
34
- double remainder = std::remquo (x, y, "ient); // remainder = 1
33
+ double remainder = std::remquo (x, y, "ient);
35
34
return remainder;
36
35
}
37
36
38
37
int get_std_quo (double x, double y)
39
38
{
40
39
int quotient {0 };
41
- std::remquo (x, y, "ient); // remainder = 1
40
+ std::remquo (x, y, "ient);
42
41
return quotient;
43
42
}
44
43
45
-
46
44
TEST (CcmathBasicTests, Remquo)
47
45
{
46
+ // Test that remquo can be uses in a static_assert
48
47
constexpr double sa_x = -7.0 , sa_y = 2.0 ;
49
48
constexpr int sa_quotient = get_ccm_quo (sa_x, sa_y); // quotient = -4
50
49
constexpr double sa_remainder = get_ccm_rem (sa_x, sa_y); // remainder = 1
@@ -81,8 +80,6 @@ TEST(CcmathBasicTests, Remquo)
81
80
EXPECT_EQ (didCcmLeftNegativeInfinityReturnNan, didStdLeftNegativeInfinityReturnNan);
82
81
EXPECT_EQ (get_ccm_quo (-std::numeric_limits<double >::infinity (), 2.0 ), get_std_quo (-std::numeric_limits<double >::infinity (), 2.0 ));
83
82
84
-
85
-
86
83
// Test with NaN
87
84
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
88
85
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
@@ -101,5 +98,5 @@ TEST(CcmathBasicTests, Remquo)
101
98
EXPECT_EQ (didCcmLeftNegativeNanReturnNan, didStdLeftNegativeNanReturnNan);
102
99
EXPECT_EQ (get_ccm_quo (-std::numeric_limits<double >::quiet_NaN (), 2.0 ), get_std_quo (-std::numeric_limits<double >::quiet_NaN (), 2.0 ));
103
100
104
-
101
+ // TODO: Add more test cases for remquo.
105
102
}
0 commit comments