]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/test/test_policy_9.cpp
bump version to 18.2.4-pve3
[ceph.git] / ceph / src / boost / libs / math / test / test_policy_9.cpp
1 #define BOOST_TEST_MAIN
2 // Copyright John Maddock 2007.
3
4 // Use, modification and distribution are subject to the
5 // Boost Software License, Version 1.0.
6 // (See accompanying file LICENSE_1_0.txt
7 // or copy at http://www.boost.org/LICENSE_1_0.txt)
8
9 #include <boost/math/policies/policy.hpp>
10 #include <boost/math/policies/error_handling.hpp>
11 #include <boost/math/tools/precision.hpp>
12
13 template <class T>
14 constexpr int consume_constexpr(const T&)
15 { return 0; }
16
17 void test()
18 {
19 using namespace boost::math::policies;
20 using namespace boost;
21
22 #if !defined(BOOST_NO_CXX11_CONSTEXPR) && !defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) && !defined(BOOST_MATH_DISABLE_CONSTEXPR)
23
24 constexpr auto p1 = make_policy();
25 constexpr auto p2 = make_policy(promote_double<false>());
26 constexpr auto p3 = make_policy(domain_error<user_error>(), pole_error<user_error>(), overflow_error<user_error>(), underflow_error<user_error>(),
27 denorm_error<user_error>(), evaluation_error<user_error>(), rounding_error<user_error>(), indeterminate_result_error<user_error>());
28 constexpr auto p4 = make_policy(promote_float<false>(), promote_double<false>(), assert_undefined<true>(), discrete_quantile<real>(),
29 digits10<10>(), max_series_iterations<100>(), max_root_iterations<20>());
30 constexpr auto p5 = make_policy(digits2<20>());
31
32 constexpr int d = digits<double, policy<> >() + digits_base10<double, policy<> >();
33 constexpr unsigned long s = get_max_series_iterations<policy<> >();
34 constexpr unsigned long r = get_max_root_iterations<policy<> >();
35
36 constexpr double ep = get_epsilon<double, policy<> >();
37 constexpr double ep2 = get_epsilon<double, policy<digits10<7> > >();
38
39 constexpr auto p6 = make_policy(domain_error<ignore_error>(), pole_error<ignore_error>(), overflow_error<ignore_error>(), underflow_error<ignore_error>(),
40 denorm_error<ignore_error>(), evaluation_error<ignore_error>(), rounding_error<ignore_error>(), indeterminate_result_error<ignore_error>());
41
42 constexpr double r1 = raise_domain_error<double>("foo", "Out of range", 0.0, p6);
43 constexpr double r2 = raise_pole_error<double>("func", "msg", 0.0, p6);
44 constexpr double r3 = raise_overflow_error<double>("func", "msg", p6);
45 constexpr double r4 = raise_overflow_error("func", "msg", 0.0, p6);
46 constexpr double r5 = raise_underflow_error<double>("func", "msg", p6);
47 constexpr double r6 = raise_denorm_error("func", "msg", 0.0, p6);
48 constexpr double r7 = raise_evaluation_error("func", "msg", 0.0, p6);
49 constexpr float r8 = raise_rounding_error("func", "msg", 0.0, 0.0f, p6);
50 constexpr float r9 = raise_indeterminate_result_error("func", "msg", 0.0, 0.0f, p6);
51
52 consume_constexpr(p1);
53 consume_constexpr(p2);
54 consume_constexpr(p3);
55 consume_constexpr(p4);
56 consume_constexpr(p5);
57 consume_constexpr(p6);
58 consume_constexpr(d);
59 consume_constexpr(s);
60 consume_constexpr(r);
61 consume_constexpr(ep);
62 consume_constexpr(ep2);
63 consume_constexpr(r1);
64 consume_constexpr(r2);
65 consume_constexpr(r3);
66 consume_constexpr(r4);
67 consume_constexpr(r5);
68 consume_constexpr(r6);
69 consume_constexpr(r7);
70 consume_constexpr(r8);
71 consume_constexpr(r9);
72
73 #endif
74
75 #ifndef BOOST_NO_CXX11_NOEXCEPT
76
77 static_assert(noexcept(make_policy()), "This expression should be noexcept");
78 static_assert(noexcept(make_policy(promote_double<false>())), "This expression should be noexcept");
79 static_assert(noexcept(make_policy(domain_error<user_error>(), pole_error<user_error>(), overflow_error<user_error>(), underflow_error<user_error>(),
80 denorm_error<user_error>(), evaluation_error<user_error>(), rounding_error<user_error>(), indeterminate_result_error<user_error>())), "This expression should be noexcept");
81 static_assert(noexcept(make_policy(promote_float<false>(), promote_double<false>(), assert_undefined<true>(), discrete_quantile<boost::math::policies::real>(),
82 digits10<10>(), max_series_iterations<100>(), max_root_iterations<20>())), "This expression should be noexcept");
83
84 static_assert(noexcept(digits<double, policy<> >() + digits_base10<double, policy<> >()), "This expression should be noexcept");
85 static_assert(noexcept(get_max_series_iterations<policy<> >()), "This expression should be noexcept");
86 static_assert(noexcept(get_max_root_iterations<policy<> >()), "This expression should be noexcept");
87
88 static_assert(noexcept(get_epsilon<double, policy<> >()), "This expression should be noexcept");
89
90 #endif
91
92 } // BOOST_AUTO_TEST_CASE( test_main )
93
94
95