File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 88
99using namespace boost ::decimal;
1010
11+ template <typename T>
12+ T roundtrip (T val)
13+ {
14+ const auto bits {to_dpd (val)};
15+ return from_dpd<T>(bits);
16+ }
17+
1118template <typename T>
1219void test ()
1320{
@@ -18,10 +25,17 @@ void test()
1825 for (std::size_t i {}; i < 1024 ; ++i)
1926 {
2027 const T val {dist (rng)};
21- const auto bits {to_dpd (val)};
22- const T return_val {from_dpd<T>(bits)};
28+ const T return_val {roundtrip (val)};
2329 BOOST_TEST_EQ (val, return_val);
2430 }
31+
32+ // Non-finite values
33+ BOOST_TEST (isinf (roundtrip (std::numeric_limits<T>::infinity ())));
34+ BOOST_TEST (isinf (roundtrip (-std::numeric_limits<T>::infinity ())));
35+ BOOST_TEST (isnan (roundtrip (std::numeric_limits<T>::quiet_NaN ())));
36+ BOOST_TEST (isnan (roundtrip (-std::numeric_limits<T>::quiet_NaN ())));
37+ BOOST_TEST (isnan (roundtrip (std::numeric_limits<T>::signaling_NaN ())));
38+ BOOST_TEST (isnan (roundtrip (-std::numeric_limits<T>::signaling_NaN ())));
2539}
2640
2741int main ()
You can’t perform that action at this time.
0 commit comments