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