1
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
6
7// Test all derived and base classes without postconditions.
8
9#define BOOST_CONTRACT_TEST_NO_A_POST
10#define BOOST_CONTRACT_TEST_NO_B_POST
11#define BOOST_CONTRACT_TEST_NO_C_POST
12#include "decl.hpp"
13
14#include <boost/detail/lightweight_test.hpp>
15#include <sstream>
16
17int main() {
18 std::ostringstream ok; ok // Test nothing fails.
19 #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
20 << "a::static_inv" << std::endl
21 << "a::inv" << std::endl
22 #endif
23 #ifndef BOOST_CONTRACT_NO_OLDS
24 << "a::dtor::old" << std::endl
25 #endif
26 << "a::dtor::body" << std::endl
27 #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
28 << "a::static_inv" << std::endl
29 #endif
30
31 #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
32 << "b::static_inv" << std::endl
33 << "b::inv" << std::endl
34 #endif
35 #ifndef BOOST_CONTRACT_NO_OLDS
36 << "b::dtor::old" << std::endl
37 #endif
38 << "b::dtor::body" << std::endl
39 #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
40 << "b::static_inv" << std::endl
41 #endif
42
43 #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
44 << "c::static_inv" << std::endl
45 << "c::inv" << std::endl
46 #endif
47 #ifndef BOOST_CONTRACT_NO_OLDS
48 << "c::dtor::old" << std::endl
49 #endif
50 << "c::dtor::body" << std::endl
51 #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
52 << "c::static_inv" << std::endl
53 #endif
54 ;
55
56 a_post = true;
57 b_post = true;
58 c_post = true;
59 {
60 a aa;
61 out.str(s: "");
62 }
63 BOOST_TEST(out.eq(ok.str()));
64
65 a_post = false;
66 b_post = true;
67 c_post = true;
68 {
69 a aa;
70 out.str(s: "");
71 }
72 BOOST_TEST(out.eq(ok.str()));
73
74 a_post = true;
75 b_post = false;
76 c_post = true;
77 {
78 a aa;
79 out.str(s: "");
80 }
81 BOOST_TEST(out.eq(ok.str()));
82
83 a_post = true;
84 b_post = true;
85 c_post = false;
86 {
87 a aa;
88 out.str(s: "");
89 }
90 BOOST_TEST(out.eq(ok.str()));
91
92 a_post = false;
93 b_post = false;
94 c_post = false;
95 {
96 a aa;
97 out.str(s: "");
98 }
99 BOOST_TEST(out.eq(ok.str()));
100
101 return boost::report_errors();
102}
103
104

source code of boost/libs/contract/test/destructor/decl_post_none.cpp