Skip to content

Commit 339a887

Browse files
committed
Add 64-bit decimal type testing
1 parent 39af8f9 commit 339a887

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

test/test_dpd_conversions.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ using namespace boost::decimal;
1111
template <typename T>
1212
T roundtrip(T val)
1313
{
14-
const auto bits {to_dpd(val)};
14+
const auto bits {to_dpd<T>(val)};
1515
return from_dpd<T>(bits);
1616
}
1717

@@ -41,9 +41,12 @@ void test()
4141
template <typename T>
4242
void test_float_range()
4343
{
44+
using float_type = std::conditional_t<std::is_same<T, decimal32>::value ||
45+
std::is_same<T, decimal32_fast>::value, float, double>;
46+
4447
std::mt19937_64 rng(42);
45-
std::uniform_real_distribution<float> dist(std::numeric_limits<float>::min(),
46-
std::numeric_limits<float>::max());
48+
std::uniform_real_distribution<float_type> dist(std::numeric_limits<float_type>::min(),
49+
std::numeric_limits<float_type>::max());
4750

4851
for (std::size_t i {}; i < 1024; ++i)
4952
{
@@ -61,5 +64,11 @@ int main()
6164
test_float_range<decimal32>();
6265
test_float_range<decimal32_fast>();
6366

67+
test<decimal64>();
68+
test<decimal64_fast>();
69+
70+
test_float_range<decimal64>();
71+
test_float_range<decimal64_fast>();
72+
6473
return boost::report_errors();
6574
}

0 commit comments

Comments
 (0)