?????嵥 11. ??????????????????????

[arpan@tintin] ./a.out
Running 1 test case...
sq.cpp(18): error in "test": difference between f1{567.010132} and
result * result{567.010193} exceeds 1e-07
*** 1 failure detected in test suite "floatingTest"

???????????????????????????????? double ?? float ??????????BOOST_CHECK_CLOSE_FRACTION ???????????????????????????????е??????????????????????? — ?????? float?????? double???? ?嵥 12 ?У???? f1 ?? double???? result ?? float???????????????

?????嵥 12. ????BOOST_CHECK_CLOSE_FRACTION ??????????????????????

[arpan@tintin] g++ sq.cpp -I/u/c/lib/boost
/u/c/lib/boost/boost/test/test_tools.hpp:
In function
`bool boost::test_tools::tt_detail::check_frwd(Pred??
const boost::unit_test::lazy_ostream&??
boost::test_tools::const_string?? size_t??
boost::test_tools::tt_detail::tool_level??
boost::test_tools::tt_detail::check_type??
const Arg0&?? const char*??
const Arg1&?? const char*?? const Arg2&?? const char*)
[with Pred = boost::test_tools::check_is_close_t?? Arg0 = double??
Arg1 = float?? Arg2 = boost::test_tools::fraction_tolerance_t<double>]':
sq.cpp:18:   instantiated from here
/u/c/lib/boost/boost/test/test_tools.hpp:523: error: no match for call to
`(boost::test_tools::check_is_close_t) (const double&?? const float&??
const boost::test_tools::fraction_tolerance_t<double>&)'

???????????????

????Boost ?????????? Boolean ?????????????????????????????????? — ???磬?ж??????б????????????????????????????????????????????????Ч??????????????? BOOST_CHECK ????ж????????顣????????????? C ??????????б???????ж?????飺??????е??????????????? 1???????麯????????? boost::test_tools::predicate_result ??????嵥 13 ??????????????

?????嵥 13. ??? Boost ??????????????????

#define BOOST_TEST_MODULE example
#include <boost/test/included/unit_test.hpp>
boost::test_tools::predicate_result validate_list(std::list<int>& L1)
{
std::list<int>::iterator it1 = L1.begin( );
for (; it1 != L1.end( ); ++it1)
{
if (*it1 <= 1) return false;
}
return true;
}
BOOST_AUTO_TEST_SUITE ( test )
BOOST_AUTO_TEST_CASE( test )
{
std::list<int>& list1 = user_defined_func( );
BOOST_CHECK( validate_list(list1) );
}
BOOST_AUTO_TEST_SUITE_END( )

????predicate_result ?????????????????????????????? Boolean ???????? validate_list ?????????????????????????????????????????С?

??????????????? Boost ????????????????BOOST_CHECK_PREDICATE ???????????????????? predicate_result????????????е?????????????? BOOST_CHECK_PREDICATE ?????????????????嵥 14 ??????? ?嵥 13 ????????????????????validate_result ??????????????? Boolean??

?????嵥 14. BOOST_CHECK_PREDICATE ??

#define BOOST_TEST_MODULE example
#include <boost/test/included/unit_test.hpp>
bool validate_list(std::list<int>& L1)
{
std::list<int>::iterator it1 = L1.begin( );
for (; it1 != L1.end( ); ++it1)
{
if (*it1 <= 1) return false;
}
return true;
}
BOOST_AUTO_TEST_SUITE ( test )
BOOST_AUTO_TEST_CASE( test )
{
std::list<int>& list1 = user_defined_func( );
BOOST_CHECK_PREDICATE( validate_list?? list1 );
}
BOOST_AUTO_TEST_SUITE_END( )

?????????????а?????????????

?????????????????а???????????????????ж??????????????????????? BOOST_AUTO_TEST_SUITE... BOOST_AUTO_TEST_SUITE_END ???嵥 15 ????????????????ж??????????????????????л???????????????? –log_level=test_suite ??????п???г????? ?嵥 16 ?п????????????????????????????????????????п???????