Skip to content

Commit a9aae9b

Browse files
committed
Add non-finite values testing and generation
1 parent 9452cc1 commit a9aae9b

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/random_gccdecimal32_math.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,31 @@ void random_mixed_division(T lower, T upper)
470470
*/
471471
}
472472

473+
void force_nonfinite()
474+
{
475+
// INF
476+
gcc_decimal32 val1 {1'000'000};
477+
478+
for (int i {}; i < 1000; ++i)
479+
{
480+
val1 *= val1;
481+
}
482+
483+
std::uint32_t bits {};
484+
std::memcpy(&bits, &val1, sizeof(std::uint32_t));
485+
486+
BOOST_TEST(isinf(val1));
487+
488+
// NAN
489+
val1 = 10;
490+
val1 /= gcc_decimal32{0};
491+
bits = 0U;
492+
493+
std::memcpy(&bits, &val1, sizeof(std::uint32_t));
494+
495+
BOOST_TEST(!isfinite(val1));
496+
}
497+
473498
int main()
474499
{
475500
// Values that won't exceed the range of the significand
@@ -590,6 +615,8 @@ int main()
590615
spot_random_mixed_addition(-653573LL, 1391401LL);
591616
spot_random_mixed_addition(894090LL, -1886315LL);
592617

618+
force_nonfinite();
619+
593620
return boost::report_errors();
594621
}
595622

0 commit comments

Comments
 (0)