BOOST_CHECK_EQUAL(1.0, lexical_cast<double>('1')); BOOST_CHECK_THROW(lexical_cast<double>('A'), boost::bad_lexical_cast); BOOST_CHECK_EQUAL(1.0, lexical_cast<double>(1)); BOOST_CHECK_EQUAL(1.23, lexical_cast<double>(1.23)); BOOST_CHECK_CLOSE( (std::numeric_limits<double>::max)() / 2, lexical_cast<double>((std::numeric_limits<double>::max)() / 2), std::numeric_limits<double>::epsilon()); BOOST_CHECK_EQUAL(1.0, lexical_cast<double>(true)); BOOST_CHECK_EQUAL(0.0, lexical_cast<double>(false)); BOOST_CHECK_EQUAL(1.23, lexical_cast<double>("1.23")); BOOST_CHECK_THROW(lexical_cast<double>(""), boost::bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast<double>("Test"), boost::bad_lexical_cast); BOOST_CHECK_EQUAL(1.23, lexical_cast<double>(std::string("1.23")));
BOOST_CHECK_CLOSE(1.0, lexical_cast<double>('1'), (std::numeric_limits<double>::epsilon())); BOOST_CHECK_THROW(lexical_cast<double>('A'), bad_lexical_cast); BOOST_CHECK_CLOSE(1.0, lexical_cast<double>(1), (std::numeric_limits<double>::epsilon())); BOOST_CHECK_CLOSE(1.23, lexical_cast<double>(1.23), (std::numeric_limits<double>::epsilon())); BOOST_CHECK_CLOSE(1.234567890, 1.234567890, std::numeric_limits<double>::epsilon()); BOOST_CHECK_CLOSE(1.0, lexical_cast<double>(true), (std::numeric_limits<double>::epsilon())); BOOST_CHECK_CLOSE(0.0, lexical_cast<double>(false), (std::numeric_limits<double>::epsilon())); BOOST_CHECK_CLOSE(1.23, lexical_cast<double>("1.23"), (std::numeric_limits<double>::epsilon())); BOOST_CHECK_THROW(lexical_cast<double>(""), bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast<double>("Test"), bad_lexical_cast); BOOST_CHECK_CLOSE(1.23, lexical_cast<double>(std::string("1.23")), (std::numeric_limits<double>::epsilon()));
void test_conversion_to_double(){    BOOST_CHECK_EQUAL(1.0, lexical_cast<double>('1'));    BOOST_CHECK_THROW(lexical_cast<double>('A'), boost::bad_lexical_cast);    BOOST_CHECK_EQUAL(1.0, lexical_cast<double>(1));    BOOST_CHECK_EQUAL(1.23, lexical_cast<double>(1.23));    BOOST_CHECK_CLOSE(        (std::numeric_limits<double>::max)() / 2,        lexical_cast<double>((std::numeric_limits<double>::max)() / 2),        std::numeric_limits<double>::epsilon());    BOOST_CHECK_EQUAL(1.0, lexical_cast<double>(true));    BOOST_CHECK_EQUAL(0.0, lexical_cast<double>(false));    BOOST_CHECK_EQUAL(1.23, lexical_cast<double>("1.23"));    BOOST_CHECK_THROW(lexical_cast<double>(""), boost::bad_lexical_cast);    BOOST_CHECK_THROW(lexical_cast<double>("Test"), boost::bad_lexical_cast);    BOOST_CHECK_EQUAL(1.23, lexical_cast<double>(std::string("1.23")));    BOOST_CHECK_THROW(        lexical_cast<double>(std::string("")), boost::bad_lexical_cast);    BOOST_CHECK_THROW(        lexical_cast<double>(std::string("Test")), boost::bad_lexical_cast);}