2 #ifndef BOOST_CONTRACT_TEST_LIB_A_INLINED_HPP_
3 #define BOOST_CONTRACT_TEST_LIB_A_INLINED_HPP_
5 // Copyright (C) 2008-2018 Lorenzo Caminiti
6 // Distributed under the Boost Software License, Version 1.0 (see accompanying
7 // file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt).
8 // See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html
11 #include <boost/contract.hpp> // All headers so test ODR for entire lib.
13 #ifdef BOOST_CONTRACT_HEADER_ONLY
14 #define BOOST_CONTRACT_TEST_LIB_A_DECLINLINE inline
16 #define BOOST_CONTRACT_TEST_LIB_A_DECLINLINE /* nothing */
19 BOOST_CONTRACT_TEST_LIB_A_DECLINLINE
20 void a::static_invariant() {
21 using boost::contract::test::detail::out;
22 out("a::static_inv\n");
25 BOOST_CONTRACT_TEST_LIB_A_DECLINLINE
26 void a::invariant() const {
27 using boost::contract::test::detail::out;
31 BOOST_CONTRACT_TEST_LIB_A_DECLINLINE
33 using boost::contract::test::detail::out;
35 boost::contract::old_ptr<x_type> old_x =
36 BOOST_CONTRACT_OLDOF(x_type::eval(x));
37 boost::contract::check c = boost::contract::public_function(this)
38 // Capturing [&] so out() visible in MSVC10 lambdas.
39 .precondition([&] { out("a::f::pre\n"); })
40 .old([&] { out("a::f::old\n"); })
43 BOOST_CONTRACT_ASSERT(x.value == -old_x->value);
44 BOOST_CONTRACT_ASSERT(result == old_x->value);
53 BOOST_CONTRACT_TEST_LIB_A_DECLINLINE
54 void a::disable_pre_failure() {
55 using boost::contract::test::detail::out;
56 boost::contract::set_precondition_failure([] (boost::contract::from)
57 { out("a::pre_failure\n"); });
60 BOOST_CONTRACT_TEST_LIB_A_DECLINLINE
61 void a::disable_post_failure() {
62 using boost::contract::test::detail::out;
63 boost::contract::set_postcondition_failure([] (boost::contract::from)
64 { out("a::post_failure\n"); });
67 BOOST_CONTRACT_TEST_LIB_A_DECLINLINE
68 void a::disable_entry_inv_failure() {
69 using boost::contract::test::detail::out;
70 boost::contract::set_entry_invariant_failure([] (boost::contract::from)
71 { out("a::entry_inv_failure\n"); });
74 BOOST_CONTRACT_TEST_LIB_A_DECLINLINE
75 void a::disable_exit_inv_failure() {
76 using boost::contract::test::detail::out;
77 boost::contract::set_exit_invariant_failure([] (boost::contract::from)
78 { out("a::exit_inv_failure\n"); });
81 BOOST_CONTRACT_TEST_LIB_A_DECLINLINE
82 void a::disable_inv_failure() {
83 using boost::contract::test::detail::out;
84 boost::contract::set_invariant_failure([] (boost::contract::from)
85 { out("a::inv_failure\n"); });
88 BOOST_CONTRACT_TEST_LIB_A_DECLINLINE
89 void a::disable_failure() {
90 using boost::contract::test::detail::out;
91 boost::contract::set_precondition_failure(
92 boost::contract::set_postcondition_failure(
93 boost::contract::set_except_failure(
94 boost::contract::set_old_failure(
95 boost::contract::set_invariant_failure(
96 [] (boost::contract::from) { out("a::failure\n"); }
100 #endif // #include guard