37#include <boost/test/tools/floating_point_comparison.hpp>
38#include <boost/test/unit_test.hpp>
49 double adouble = std::numeric_limits<int>::max();
50 int aint = checked_cast<int>(adouble);
51 BOOST_CHECK_EQUAL(aint, adouble);
54 double adouble = std::numeric_limits<int>::min();
55 int aint = checked_cast<int>(adouble);
56 BOOST_CHECK_EQUAL(aint, adouble);
62 double adouble = std::numeric_limits<int>::max() + 1.0;
63 int aint = checked_cast<int>(adouble);
64 BOOST_CHECK_EQUAL(aint, adouble);
66 catch (std::runtime_error &e)
68 std::string errmss = e.what();
69 BOOST_CHECK_EQUAL(
"Level 0 assertion violation", errmss.substr(0, 27));
74 double adouble = std::numeric_limits<int>::min() - 1.0;
75 int aint = checked_cast<int>(adouble);
76 BOOST_CHECK_EQUAL(aint, adouble);
78 catch (std::runtime_error &e)
80 std::string errmss = e.what();
81 BOOST_CHECK_EQUAL(
"Level 0 assertion violation", errmss.substr(0, 27));
BOOST_AUTO_TEST_CASE(TestDoubleToInt)