]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/contract/test/constructor/decl_post_mid.cpp
2 // Copyright (C) 2008-2018 Lorenzo Caminiti
3 // Distributed under the Boost Software License, Version 1.0 (see accompanying
4 // file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt).
5 // See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html
7 // Test only middle base class with postconditions.
9 #define BOOST_CONTRACT_TEST_NO_A_POST
10 #undef BOOST_CONTRACT_TEST_NO_B_POST
11 #define BOOST_CONTRACT_TEST_NO_C_POST
14 #include <boost/detail/lightweight_test.hpp>
19 std::ostringstream ok
; ok
20 #ifndef BOOST_CONTRACT_NO_PRECONDITIONS
21 << "a::ctor::pre" << std::endl
22 << "b::ctor::pre" << std::endl
23 << "c::ctor::pre" << std::endl
26 #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
27 << "c::static_inv" << std::endl
29 #ifndef BOOST_CONTRACT_NO_OLDS
30 << "c::ctor::old" << std::endl
32 << "c::ctor::body" << std::endl
33 #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
34 << "c::static_inv" << std::endl
35 << "c::inv" << std::endl
38 #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
39 << "b::static_inv" << std::endl
41 #ifndef BOOST_CONTRACT_NO_OLDS
42 << "b::ctor::old" << std::endl
44 << "b::ctor::body" << std::endl
45 #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
46 << "b::static_inv" << std::endl
47 << "b::inv" << std::endl
49 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
50 << "b::ctor::post" << std::endl
57 std::ostringstream ok
; ok
58 #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
59 << "a::static_inv" << std::endl
61 #ifndef BOOST_CONTRACT_NO_OLDS
62 << "a::ctor::old" << std::endl
64 << "a::ctor::body" << std::endl
65 #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
66 << "a::static_inv" << std::endl
67 << "a::inv" << std::endl
73 struct err
{}; // Global decl so visible in MSVC10 lambdas.
76 std::ostringstream ok
;
84 ok
.str(""); ok
// Test nothing failed.
88 BOOST_TEST(out
.eq(ok
.str()));
91 boost::contract::set_postcondition_failure(
92 [] (boost::contract::from
) { throw err(); });
102 << ok_a() // Test no a::ctor::post so no failure.
104 BOOST_TEST(out
.eq(ok
.str()));
113 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
115 } catch(err
const&) {
118 << ok_cb() // Test b::ctor::post failed.
119 #ifdef BOOST_CONTRACT_NO_POSTCONDITIONS
123 BOOST_TEST(out
.eq(ok
.str()));
124 } catch(...) { BOOST_TEST(false); }
133 << ok_cb() // Test no c::ctor::post so no failure.
136 BOOST_TEST(out
.eq(ok
.str()));
145 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
147 } catch(err
const&) {
150 << ok_cb() // Test b::ctor::post failed (as all did).
151 #ifdef BOOST_CONTRACT_NO_POSTCONDITIONS
155 BOOST_TEST(out
.eq(ok
.str()));
156 } catch(...) { BOOST_TEST(false); }
158 return boost::report_errors();