test_policy_7.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright John Maddock 2007.
  2. // Use, modification and distribution are subject to the
  3. // Boost Software License, Version 1.0.
  4. // (See accompanying file LICENSE_1_0.txt
  5. // or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. #include <boost/math/policies/policy.hpp>
  7. #include <boost/type_traits/is_same.hpp>
  8. #define BOOST_TEST_MAIN
  9. #include <boost/test/unit_test.hpp> // for test_main
  10. #include <iostream>
  11. template <class P1, class P2>
  12. bool check_same(const P1&, const P2&)
  13. {
  14. if(!boost::is_same<P1, P2>::value)
  15. {
  16. std::cout << "P1 = " << typeid(P1).name() << std::endl;
  17. std::cout << "P2 = " << typeid(P2).name() << std::endl;
  18. }
  19. return boost::is_same<P1, P2>::value;
  20. }
  21. BOOST_AUTO_TEST_CASE( test_main )
  22. {
  23. using namespace boost::math::policies;
  24. using namespace boost;
  25. BOOST_CHECK(check_same(make_policy(), policy<>()));
  26. BOOST_CHECK(check_same(make_policy(denorm_error<ignore_error>()), normalise<policy<denorm_error<ignore_error> > >::type()));
  27. BOOST_CHECK(check_same(make_policy(digits2<20>()), normalise<policy<digits2<20> > >::type()));
  28. BOOST_CHECK(check_same(make_policy(promote_float<false>()), normalise<policy<promote_float<false> > >::type()));
  29. BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>()), normalise<policy<domain_error<ignore_error> > >::type()));
  30. BOOST_CHECK(check_same(make_policy(pole_error<ignore_error>()), normalise<policy<pole_error<ignore_error> > >::type()));
  31. BOOST_CHECK(check_same(make_policy(indeterminate_result_error<ignore_error>()), normalise<policy<indeterminate_result_error<ignore_error> > >::type()));
  32. } // BOOST_AUTO_TEST_CASE( test_main )