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 all derived and base classes without exit static invariants.
9 #define BOOST_CONTRACT_TEST_NO_A_STATIC_INV
10 #define BOOST_CONTRACT_TEST_NO_B_STATIC_INV
11 #define BOOST_CONTRACT_TEST_NO_C_STATIC_INV
14 #include <boost/preprocessor/control/iif.hpp>
15 #include <boost/detail/lightweight_test.hpp>
19 std::ostringstream ok
; ok
// Test nothing fails.
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_OLDS
27 << "c::ctor::old" << std::endl
29 << "c::ctor::body" << std::endl
30 #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
31 << "c::inv" << std::endl
33 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
34 << "c::ctor::post" << std::endl
37 #ifndef BOOST_CONTRACT_NO_OLDS
38 << "b::ctor::old" << std::endl
40 << "b::ctor::body" << std::endl
41 #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
42 << "b::inv" << std::endl
44 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
45 << "b::ctor::post" << std::endl
48 #ifndef BOOST_CONTRACT_NO_OLDS
49 << "a::ctor::old" << std::endl
51 << "a::ctor::body" << std::endl
52 #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
53 << "a::inv" << std::endl
55 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
56 << "a::ctor::post" << std::endl
60 #ifdef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
61 #define BOOST_CONTRACT_TEST_entry_inv 0
63 #define BOOST_CONTRACT_TEST_entry_inv 1
66 a_exit_static_inv
= true;
67 b_exit_static_inv
= true;
68 c_exit_static_inv
= true;
69 a_entering_static_inv
= b_entering_static_inv
= c_entering_static_inv
=
70 BOOST_PP_IIF(BOOST_CONTRACT_TEST_entry_inv
, true, false);
74 BOOST_TEST(out
.eq(ok
.str()));
77 a_exit_static_inv
= false;
78 b_exit_static_inv
= true;
79 c_exit_static_inv
= true;
80 a_entering_static_inv
= b_entering_static_inv
= c_entering_static_inv
=
81 BOOST_PP_IIF(BOOST_CONTRACT_TEST_entry_inv
, true, false);
85 BOOST_TEST(out
.eq(ok
.str()));
88 a_exit_static_inv
= true;
89 b_exit_static_inv
= false;
90 c_exit_static_inv
= true;
91 a_entering_static_inv
= b_entering_static_inv
= c_entering_static_inv
=
92 BOOST_PP_IIF(BOOST_CONTRACT_TEST_entry_inv
, true, false);
96 BOOST_TEST(out
.eq(ok
.str()));
99 a_exit_static_inv
= true;
100 b_exit_static_inv
= true;
101 c_exit_static_inv
= false;
102 a_entering_static_inv
= b_entering_static_inv
= c_entering_static_inv
=
103 BOOST_PP_IIF(BOOST_CONTRACT_TEST_entry_inv
, true, false);
107 BOOST_TEST(out
.eq(ok
.str()));
110 a_exit_static_inv
= false;
111 b_exit_static_inv
= false;
112 c_exit_static_inv
= false;
113 a_entering_static_inv
= b_entering_static_inv
= c_entering_static_inv
=
114 BOOST_PP_IIF(BOOST_CONTRACT_TEST_entry_inv
, true, false);
118 BOOST_TEST(out
.eq(ok
.str()));
121 return boost::report_errors();