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