Skip to content

Commit db3e924

Browse files
committed
Test larger range of values
1 parent 4d595b8 commit db3e924

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/test_dpd_conversions.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,28 @@ void test()
3838
BOOST_TEST(isnan(roundtrip(-std::numeric_limits<T>::signaling_NaN())));
3939
}
4040

41+
template <typename T>
42+
void test_float_range()
43+
{
44+
std::mt19937_64 rng(42);
45+
std::uniform_real_distribution<float> dist(std::numeric_limits<float>::min(),
46+
std::numeric_limits<float>::max());
47+
48+
for (std::size_t i {}; i < 1024; ++i)
49+
{
50+
const T val {dist(rng)};
51+
const T return_val {roundtrip(val)};
52+
BOOST_TEST_EQ(val, return_val);
53+
}
54+
}
55+
4156
int main()
4257
{
4358
test<decimal32>();
4459
test<decimal32_fast>();
4560

61+
test_float_range<decimal32>();
62+
test_float_range<decimal32_fast>();
63+
4664
return boost::report_errors();
4765
}

0 commit comments

Comments
 (0)