diff --git a/Number_types/test/Number_types/Gmpq.cpp b/Number_types/test/Number_types/Gmpq.cpp index f0b694e3785..f4d84e490d7 100644 --- a/Number_types/test/Number_types/Gmpq.cpp +++ b/Number_types/test/Number_types/Gmpq.cpp @@ -36,6 +36,20 @@ void test_overflow_to_interval(const NT&) } } +template +void test_underflow_to_interval(const NT&) +{ + NT q0 = std::numeric_limits::denorm_min(); + NT q1 = q0 / 2; + NT q2 = q1 * 3; + CGAL::Interval_nt<> i1 = CGAL::to_interval(q1); + CGAL::Interval_nt<> i2 = CGAL::to_interval(q2); + assert(i1.inf() <= q1); + assert(i1.sup() >= q1); + assert(i2.inf() <= q2); + assert(i2.sup() >= q2); +} + void test_overflow_to_double() { std::cout << "Tests if to_double(Gmpq) overflows or not." << std::endl; @@ -263,10 +277,12 @@ int main() { test_overflow_to_double(); test_overflow_to_interval(Gmpz()); test_overflow_to_interval(Gmpq()); + test_underflow_to_interval(Gmpq()); #ifdef CGAL_USE_GMPXX test_overflow_to_interval(mpz_class()); test_overflow_to_interval(mpq_class()); + test_underflow_to_interval(mpq_class()); #endif // test operators Gmpq/Gmpfr (added by Luis)