diff --git a/include/boost/contract.hpp b/include/boost/contract.hpp index bdf3647..fcb729f 100644 --- a/include/boost/contract.hpp +++ b/include/boost/contract.hpp @@ -29,8 +29,6 @@ // TODO: Should C++11 move preserve class invariants at exit and/or on throw? Maybe not because after move no other public member can be called (but dtor can... so dtor should not check inv at that time...). If so, users could use an internal moved_ data member to guard class invariant checking and set that after the move operation... How can I program C++11 move operations with this lib? Should I used boost::contract::function instead of public_function? (But probably not because that does not subcontract and does not check inv at entry...) -// TODO: What shall I do with unions? Can/shall I contract them? Double check which members C++11 unions can have (ctor, dtor, etc?). - // TODO: Document that there is a MSVC 2010 bug for which lambdas cannot be used in template constructor intialization list (this was fixed in MSVC 2013). Therefore, an external (static member) function must be used (possibly with bind and cref) to program constructor preconditions on MSVC 2010 instead of using lambdas. // TODO: Document that users could program (scoped) locks at top of function definitions and before the contract code so to deal with contracts in multi-threaded situations. Would these locks need to be recursive for virtual calls? Test that... diff --git a/include/boost/contract/constructor.hpp b/include/boost/contract/constructor.hpp index fea0f92..5362a30 100644 --- a/include/boost/contract/constructor.hpp +++ b/include/boost/contract/constructor.hpp @@ -32,6 +32,7 @@ set_old_postcondition<> constructor(C* obj) { #endif } +// TODO: Document that constructor_precondition for unions must be called at the very beginning of ctor body before `boost::contract::guard c = ...` (because unions cannot have base classes, not even in C++11). template // tparam avoids multiple instance of same base in user code. class constructor_precondition { // Copyable (no data). public: diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index f41681d..de52783 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -30,9 +30,9 @@ test-suite constructor [ subdir-run-aliased constructor : decl_exit_inv_mid ] [ subdir-run-aliased constructor : decl_exit_inv_none ] - [ subdir-run-aliased constructor : bases ] + [ subdir-run-aliased constructor : contracts ] [ subdir-run-aliased constructor : access ] - [ subdir-run-aliased constructor : no_contracts ] + [ subdir-run-aliased constructor : ifdef_contracts ] [ subdir-run-aliased constructor : body_throw ] [ subdir-run-aliased constructor : old_throw ] @@ -66,9 +66,9 @@ test-suite destructor # No decl_exit_inv_... for destructors. - [ subdir-run-aliased destructor : bases ] + [ subdir-run-aliased destructor : contracts ] [ subdir-run-aliased destructor : access ] - [ subdir-run-aliased destructor : no_contracts ] + [ subdir-run-aliased destructor : ifdef_contracts ] [ subdir-run-aliased destructor : body_throw ] [ subdir-run-aliased destructor : old_throw ] @@ -108,15 +108,17 @@ test-suite public_function [ subdir-run-aliased public_function : decl_exit_inv_mid ] [ subdir-run-aliased public_function : decl_exit_inv_none ] - [ subdir-run-aliased public_function : bases ] - [ subdir-run-aliased public_function : bases_virtual ] - [ subdir-run-aliased public_function : bases_branch ] - [ subdir-run-aliased public_function : bases_sparse ] - [ subdir-run-aliased public_function : bases_protected ] - [ subdir-compile-fail public_function : bases_protected_error ] + [ subdir-run-aliased public_function : contracts ] + + [ subdir-run-aliased public_function : virtual ] + [ subdir-run-aliased public_function : virtual_branch ] + [ subdir-run-aliased public_function : virtual_sparse ] + + [ subdir-run-aliased public_function : protected ] + [ subdir-compile-fail public_function : protected_error ] [ subdir-run-aliased public_function : access ] - [ subdir-run-aliased public_function : no_contracts ] + [ subdir-run-aliased public_function : ifdef_contracts ] [ subdir-run-aliased public_function : body_throw ] [ subdir-run-aliased public_function : old_throw ] @@ -143,6 +145,11 @@ test-suite public_function [ subdir-run-aliased public_function : static_old_throw ] [ subdir-run-aliased public_function : static_no_contracts ] ; + +test-suite union +: + [ subdir-run-aliased union : contracts ] +; test-suite invariant : @@ -155,21 +162,21 @@ test-suite invariant [ subdir-run-aliased invariant : decl_const ] [ subdir-run-aliased invariant : decl_nothing ] - [ subdir-compile-fail invariant : static_inv_mutable_error ] - [ subdir-run-aliased invariant : static_inv_mutable_permissive ] - [ subdir-compile-fail invariant : static_inv_const_error ] - [ subdir-run-aliased invariant : static_inv_const_permissive ] - [ subdir-compile-fail invariant : static_inv_volatile_error ] - [ subdir-run-aliased invariant : static_inv_volatile_permissive ] - [ subdir-compile-fail invariant : static_inv_cv_error ] - [ subdir-run-aliased invariant : static_inv_cv_permissive ] + [ subdir-compile-fail invariant : static_mutable_error ] + [ subdir-run-aliased invariant : static_mutable_permissive ] + [ subdir-compile-fail invariant : static_const_error ] + [ subdir-run-aliased invariant : static_const_permissive ] + [ subdir-compile-fail invariant : static_volatile_error ] + [ subdir-run-aliased invariant : static_volatile_permissive ] + [ subdir-compile-fail invariant : static_cv_error ] + [ subdir-run-aliased invariant : static_cv_permissive ] - [ subdir-compile-fail invariant : inv_static_error ] - [ subdir-run-aliased invariant : inv_static_permissive ] - [ subdir-compile-fail invariant : inv_mutable_error ] - [ subdir-run-aliased invariant : inv_mutable_permissive ] - [ subdir-compile-fail invariant : inv_volatile_error ] - [ subdir-run-aliased invariant : inv_volatile_permissive ] + [ subdir-compile-fail invariant : static_error ] + [ subdir-run-aliased invariant : static_permissive ] + [ subdir-compile-fail invariant : mutable_error ] + [ subdir-run-aliased invariant : mutable_permissive ] + [ subdir-compile-fail invariant : volatile_error ] + [ subdir-run-aliased invariant : volatile_permissive ] ; test-suite function @@ -180,8 +187,8 @@ test-suite function [ subdir-run-aliased function : decl_post_all ] [ subdir-run-aliased function : decl_post_none ] - [ subdir-run-aliased function : func ] - [ subdir-run-aliased function : no_contracts ] + [ subdir-run-aliased function : contracts ] + [ subdir-run-aliased function : ifdef_contracts ] [ subdir-run-aliased function : body_throw ] [ subdir-run-aliased function : old_throw ] diff --git a/test/constructor/bases.cpp b/test/constructor/contracts.cpp similarity index 100% rename from test/constructor/bases.cpp rename to test/constructor/contracts.cpp diff --git a/test/constructor/no_contracts.cpp b/test/constructor/ifdef_contracts.cpp similarity index 100% rename from test/constructor/no_contracts.cpp rename to test/constructor/ifdef_contracts.cpp diff --git a/test/destructor/bases.cpp b/test/destructor/contracts.cpp similarity index 100% rename from test/destructor/bases.cpp rename to test/destructor/contracts.cpp diff --git a/test/destructor/no_contracts.cpp b/test/destructor/ifdef_contracts.cpp similarity index 100% rename from test/destructor/no_contracts.cpp rename to test/destructor/ifdef_contracts.cpp diff --git a/test/function/func.cpp b/test/function/contracts.cpp similarity index 100% rename from test/function/func.cpp rename to test/function/contracts.cpp diff --git a/test/function/no_contracts.cpp b/test/function/ifdef_contracts.cpp similarity index 100% rename from test/function/no_contracts.cpp rename to test/function/ifdef_contracts.cpp diff --git a/test/invariant/inv_mutable.hpp b/test/invariant/mutable.hpp similarity index 100% rename from test/invariant/inv_mutable.hpp rename to test/invariant/mutable.hpp diff --git a/test/invariant/inv_mutable_error.cpp b/test/invariant/mutable_error.cpp similarity index 78% rename from test/invariant/inv_mutable_error.cpp rename to test/invariant/mutable_error.cpp index eadd11b..ab0f9bf 100644 --- a/test/invariant/inv_mutable_error.cpp +++ b/test/invariant/mutable_error.cpp @@ -2,5 +2,5 @@ // Test compiler error when invariant() not declared const. #undef BOOST_CONTRACT_PERMISSIVE -#include "inv_mutable.hpp" +#include "mutable.hpp" diff --git a/test/invariant/inv_mutable_permissive.cpp b/test/invariant/mutable_permissive.cpp similarity index 80% rename from test/invariant/inv_mutable_permissive.cpp rename to test/invariant/mutable_permissive.cpp index 74fcedd..0b812fa 100644 --- a/test/invariant/inv_mutable_permissive.cpp +++ b/test/invariant/mutable_permissive.cpp @@ -2,5 +2,5 @@ // Test no error if permissive even if invariant() not declared const. #define BOOST_CONTRACT_PERMISSIVE -#include "inv_mutable.hpp" +#include "mutable.hpp" diff --git a/test/invariant/inv_static.hpp b/test/invariant/static.hpp similarity index 100% rename from test/invariant/inv_static.hpp rename to test/invariant/static.hpp diff --git a/test/invariant/static_inv_const.hpp b/test/invariant/static_const.hpp similarity index 100% rename from test/invariant/static_inv_const.hpp rename to test/invariant/static_const.hpp diff --git a/test/invariant/static_inv_const_error.cpp b/test/invariant/static_const_error.cpp similarity index 71% rename from test/invariant/static_inv_const_error.cpp rename to test/invariant/static_const_error.cpp index b9a37a1..0264ed7 100644 --- a/test/invariant/static_inv_const_error.cpp +++ b/test/invariant/static_const_error.cpp @@ -2,5 +2,5 @@ // Test error if static inv declared const. #undef BOOST_CONTRACT_PERMISSIVE -#include "static_inv_const.hpp" +#include "static_const.hpp" diff --git a/test/invariant/static_inv_const_permissive.cpp b/test/invariant/static_const_permissive.cpp similarity index 76% rename from test/invariant/static_inv_const_permissive.cpp rename to test/invariant/static_const_permissive.cpp index 64048d2..0d1f814 100644 --- a/test/invariant/static_inv_const_permissive.cpp +++ b/test/invariant/static_const_permissive.cpp @@ -2,5 +2,5 @@ // Test no error if permissive even when static inv declared const. #define BOOST_CONTRACT_PERMISSIVE -#include "static_inv_const.hpp" +#include "static_const.hpp" diff --git a/test/invariant/static_inv_cv.hpp b/test/invariant/static_cv.hpp similarity index 100% rename from test/invariant/static_inv_cv.hpp rename to test/invariant/static_cv.hpp diff --git a/test/invariant/static_inv_cv_error.cpp b/test/invariant/static_cv_error.cpp similarity index 72% rename from test/invariant/static_inv_cv_error.cpp rename to test/invariant/static_cv_error.cpp index fd96e82..c693601 100644 --- a/test/invariant/static_inv_cv_error.cpp +++ b/test/invariant/static_cv_error.cpp @@ -2,5 +2,5 @@ // Test error if static inv declared cv. #undef BOOST_CONTRACT_PERMISSIVE -#include "static_inv_cv.hpp" +#include "static_cv.hpp" diff --git a/test/invariant/static_inv_cv_permissive.cpp b/test/invariant/static_cv_permissive.cpp similarity index 77% rename from test/invariant/static_inv_cv_permissive.cpp rename to test/invariant/static_cv_permissive.cpp index acbdfb7..6c6dbce 100644 --- a/test/invariant/static_inv_cv_permissive.cpp +++ b/test/invariant/static_cv_permissive.cpp @@ -2,5 +2,5 @@ // Test no error if permissive even when static inv declared cv. #define BOOST_CONTRACT_PERMISSIVE -#include "static_inv_cv.hpp" +#include "static_cv.hpp" diff --git a/test/invariant/inv_static_error.cpp b/test/invariant/static_error.cpp similarity index 77% rename from test/invariant/inv_static_error.cpp rename to test/invariant/static_error.cpp index 8888829..54778d4 100644 --- a/test/invariant/inv_static_error.cpp +++ b/test/invariant/static_error.cpp @@ -2,5 +2,5 @@ // Test compiler error if invariant() declared static. #undef BOOST_CONTRACT_PERMISSIVE -#include "inv_static.hpp" +#include "static.hpp" diff --git a/test/invariant/static_inv_mutable.hpp b/test/invariant/static_mutable.hpp similarity index 100% rename from test/invariant/static_inv_mutable.hpp rename to test/invariant/static_mutable.hpp diff --git a/test/invariant/static_inv_mutable_error.cpp b/test/invariant/static_mutable_error.cpp similarity index 70% rename from test/invariant/static_inv_mutable_error.cpp rename to test/invariant/static_mutable_error.cpp index f962e4e..2c5eecf 100644 --- a/test/invariant/static_inv_mutable_error.cpp +++ b/test/invariant/static_mutable_error.cpp @@ -2,5 +2,5 @@ // Test error if static inv declared mutable. #undef BOOST_CONTRACT_PERMISSIVE -#include "static_inv_mutable.hpp" +#include "static_mutable.hpp" diff --git a/test/invariant/static_inv_mutable_permissive.cpp b/test/invariant/static_mutable_permissive.cpp similarity index 75% rename from test/invariant/static_inv_mutable_permissive.cpp rename to test/invariant/static_mutable_permissive.cpp index 8839580..5285a28 100644 --- a/test/invariant/static_inv_mutable_permissive.cpp +++ b/test/invariant/static_mutable_permissive.cpp @@ -2,5 +2,5 @@ // Test error if permissive even when static inv declared mutable. #define BOOST_CONTRACT_PERMISSIVE -#include "static_inv_mutable.hpp" +#include "static_mutable.hpp" diff --git a/test/invariant/inv_static_permissive.cpp b/test/invariant/static_permissive.cpp similarity index 81% rename from test/invariant/inv_static_permissive.cpp rename to test/invariant/static_permissive.cpp index 04864e7..5901c44 100644 --- a/test/invariant/inv_static_permissive.cpp +++ b/test/invariant/static_permissive.cpp @@ -2,5 +2,5 @@ // Test no compiler error if permissive even when invariant() declared static. #define BOOST_CONTRACT_PERMISSIVE -#include "inv_static.hpp" +#include "static.hpp" diff --git a/test/invariant/static_inv_volatile.hpp b/test/invariant/static_volatile.hpp similarity index 100% rename from test/invariant/static_inv_volatile.hpp rename to test/invariant/static_volatile.hpp diff --git a/test/invariant/static_inv_volatile_error.cpp b/test/invariant/static_volatile_error.cpp similarity index 70% rename from test/invariant/static_inv_volatile_error.cpp rename to test/invariant/static_volatile_error.cpp index 935f54f..39d645f 100644 --- a/test/invariant/static_inv_volatile_error.cpp +++ b/test/invariant/static_volatile_error.cpp @@ -2,5 +2,5 @@ // Test error if static inv declared volatile. #undef BOOST_CONTRACT_PERMISSIVE -#include "static_inv_volatile.hpp" +#include "static_volatile.hpp" diff --git a/test/invariant/static_inv_volatile_permissive.cpp b/test/invariant/static_volatile_permissive.cpp similarity index 75% rename from test/invariant/static_inv_volatile_permissive.cpp rename to test/invariant/static_volatile_permissive.cpp index 4f36503..aeda94b 100644 --- a/test/invariant/static_inv_volatile_permissive.cpp +++ b/test/invariant/static_volatile_permissive.cpp @@ -2,5 +2,5 @@ // Test error if permissive even when static inv declared volatile. #define BOOST_CONTRACT_PERMISSIVE -#include "static_inv_volatile.hpp" +#include "static_volatile.hpp" diff --git a/test/invariant/inv_volatile.hpp b/test/invariant/volatile.cpp similarity index 100% rename from test/invariant/inv_volatile.hpp rename to test/invariant/volatile.cpp diff --git a/test/invariant/inv_volatile_error.cpp b/test/invariant/volatile_error.cpp similarity index 75% rename from test/invariant/inv_volatile_error.cpp rename to test/invariant/volatile_error.cpp index be4f8ab..dd7b866 100644 --- a/test/invariant/inv_volatile_error.cpp +++ b/test/invariant/volatile_error.cpp @@ -2,5 +2,5 @@ // Test error if non-static inv declared volatile. #undef BOOST_CONTRACT_PERMISSIVE -#include "inv_volatile.hpp" +#include "volatile.hpp" diff --git a/test/invariant/inv_volatile_permissive.cpp b/test/invariant/volatile_permissive.cpp similarity index 80% rename from test/invariant/inv_volatile_permissive.cpp rename to test/invariant/volatile_permissive.cpp index 7b584cc..53ac9f5 100644 --- a/test/invariant/inv_volatile_permissive.cpp +++ b/test/invariant/volatile_permissive.cpp @@ -2,5 +2,5 @@ // Test no error if permissive even when non-static inv declared volatile. #define BOOST_CONTRACT_PERMISSIVE -#include "inv_volatile.hpp" +#include "volatile.hpp" diff --git a/test/public_function/bases.cpp b/test/public_function/contracts.cpp similarity index 99% rename from test/public_function/bases.cpp rename to test/public_function/contracts.cpp index 2bebeed..571f216 100644 --- a/test/public_function/bases.cpp +++ b/test/public_function/contracts.cpp @@ -1,7 +1,7 @@ // Test public member function subcontracting. -#include "bases.hpp" +#include "contracts.hpp" #include #include #include diff --git a/test/public_function/bases.hpp b/test/public_function/contracts.hpp similarity index 98% rename from test/public_function/bases.hpp rename to test/public_function/contracts.hpp index 0b43498..3df0162 100644 --- a/test/public_function/bases.hpp +++ b/test/public_function/contracts.hpp @@ -1,6 +1,6 @@ -#ifndef BOOST_CONTRACT_TEST_PUBLIC_FUNCTION_BASES_HPP_ -#define BOOST_CONTRACT_TEST_PUBLIC_FUNCTION_BASES_HPP_ +#ifndef BOOST_CONTRACT_TEST_PUBLIC_FUNCTION_CONTRACTS_HPP_ +#define BOOST_CONTRACT_TEST_PUBLIC_FUNCTION_CONTRACTS_HPP_ // Test public member function subcontracting (also with old and return values). diff --git a/test/public_function/no_contracts.cpp b/test/public_function/ifdef_contracts.cpp similarity index 100% rename from test/public_function/no_contracts.cpp rename to test/public_function/ifdef_contracts.cpp diff --git a/test/public_function/bases_protected.cpp b/test/public_function/protected.cpp similarity index 100% rename from test/public_function/bases_protected.cpp rename to test/public_function/protected.cpp diff --git a/test/public_function/bases_protected_error.cpp b/test/public_function/protected_error.cpp similarity index 100% rename from test/public_function/bases_protected_error.cpp rename to test/public_function/protected_error.cpp diff --git a/test/public_function/bases_virtual.cpp b/test/public_function/virtual.cpp similarity index 99% rename from test/public_function/bases_virtual.cpp rename to test/public_function/virtual.cpp index e029a2c..10752b9 100644 --- a/test/public_function/bases_virtual.cpp +++ b/test/public_function/virtual.cpp @@ -1,7 +1,7 @@ // Test public function subcontracting via virtual functions. -#include "bases.hpp" +#include "contracts.hpp" #include #include #include diff --git a/test/public_function/bases_branch.cpp b/test/public_function/virtual_branch.cpp similarity index 99% rename from test/public_function/bases_branch.cpp rename to test/public_function/virtual_branch.cpp index 8d50693..c41bf4f 100644 --- a/test/public_function/bases_branch.cpp +++ b/test/public_function/virtual_branch.cpp @@ -1,7 +1,7 @@ // Test public function subcontracting from middle branch of inheritance tree. -#include "bases.hpp" +#include "contracts.hpp" #include #include diff --git a/test/public_function/bases_sparse.cpp b/test/public_function/virtual_sparse.cpp similarity index 100% rename from test/public_function/bases_sparse.cpp rename to test/public_function/virtual_sparse.cpp diff --git a/test/union/contracts.cpp b/test/union/contracts.cpp new file mode 100644 index 0000000..6da943d --- /dev/null +++ b/test/union/contracts.cpp @@ -0,0 +1,211 @@ + +// Test contracts for unions. + +#include "../detail/oteststream.hpp" +#include +#include +#include +#include +#include +#include +#include + +boost::contract::test::detail::oteststream out; + +union u { + int i; + double d; + + static void static_invariant() { out << "u::static_inv" << std::endl; } + void invariant() const { out << "u::inv" << std::endl; } + + u() { + boost::contract::constructor_precondition pre( + [] { out << "u::ctor::pre" << std::endl; } + ); + boost::contract::guard c = boost::contract::constructor(this) + .old([] { out << "u::ctor::old" << std::endl; }) + .postcondition([] { out << "u::ctor::post" << std::endl; }) + ; + out << "u::ctor::body" << std::endl; + } + + ~u() { + boost::contract::guard c = boost::contract::destructor(this) + .old([] { out << "u::dtor::old" << std::endl; }) + .postcondition([] { out << "u::dtor::post" << std::endl; }) + ; + out << "u::dtor::body" << std::endl; + } + + void f() { + boost::contract::guard c = boost::contract::public_function(this) + .precondition([] { out << "u::f::pre" << std::endl; }) + .old([] { out << "u::f::old" << std::endl; }) + .postcondition([] { out << "u::f::post" << std::endl; }) + ; + out << "u::f::body" << std::endl; + } + + static void s() { + boost::contract::guard c = boost::contract::public_function() + .precondition([] { out << "u::s::pre" << std::endl; }) + .old([] { out << "u::s::old" << std::endl; }) + .postcondition([] { out << "u::s::post" << std::endl; }) + ; + out << "u::s::body" << std::endl; + } + +protected: + void g() { + boost::contract::guard c = boost::contract::function() + .precondition([] { out << "u::g::pre" << std::endl; }) + .old([] { out << "u::g::old" << std::endl; }) + .postcondition([] { out << "u::g::post" << std::endl; }) + ; + out << "u::g::body" << std::endl; + } + + friend void call_g(u& me) { me.g(); } + +private: + void h() { + boost::contract::guard c = boost::contract::function() + .precondition([] { out << "u::h::pre" << std::endl; }) + .old([] { out << "u::h::old" << std::endl; }) + .postcondition([] { out << "u::h::post" << std::endl; }) + ; + out << "u::h::body" << std::endl; + } + + friend void call_h(u& me) { me.h(); } +}; + +int main() { + std::ostringstream ok; + + { + out.str(""); + u uu; + ok.str(""); ok + #ifndef BOOST_CONTRACT_NO_PRECONDITIONS + << "u::ctor::pre" << std::endl + #endif + #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS + << "u::static_inv" << std::endl + #endif + #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS + << "u::ctor::old" << std::endl + #endif + << "u::ctor::body" << std::endl + #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS + << "u::static_inv" << std::endl + << "u::inv" << std::endl + #endif + #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS + << "u::ctor::post" << std::endl + #endif + ; + BOOST_TEST(out.eq(ok.str())); + + out.str(""); + uu.f(); + ok.str(""); ok + #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS + << "u::static_inv" << std::endl + << "u::inv" << std::endl + #endif + #ifndef BOOST_CONTRACT_NO_PRECONDITIONS + << "u::f::pre" << std::endl + #endif + #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS + << "u::f::old" << std::endl + #endif + << "u::f::body" << std::endl + #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS + << "u::static_inv" << std::endl + << "u::inv" << std::endl + #endif + #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS + << "u::f::post" << std::endl + #endif + ; + BOOST_TEST(out.eq(ok.str())); + + out.str(""); + uu.s(); + ok.str(""); ok + #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS + << "u::static_inv" << std::endl + #endif + #ifndef BOOST_CONTRACT_NO_PRECONDITIONS + << "u::s::pre" << std::endl + #endif + #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS + << "u::s::old" << std::endl + #endif + << "u::s::body" << std::endl + #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS + << "u::static_inv" << std::endl + #endif + #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS + << "u::s::post" << std::endl + #endif + ; + BOOST_TEST(out.eq(ok.str())); + + out.str(""); + call_g(uu); + ok.str(""); ok + #ifndef BOOST_CONTRACT_NO_PRECONDITIONS + << "u::g::pre" << std::endl + #endif + #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS + << "u::g::old" << std::endl + #endif + << "u::g::body" << std::endl + #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS + << "u::g::post" << std::endl + #endif + ; + BOOST_TEST(out.eq(ok.str())); + + out.str(""); + call_h(uu); + ok.str(""); ok + #ifndef BOOST_CONTRACT_NO_PRECONDITIONS + << "u::h::pre" << std::endl + #endif + #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS + << "u::h::old" << std::endl + #endif + << "u::h::body" << std::endl + #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS + << "u::h::post" << std::endl + #endif + ; + BOOST_TEST(out.eq(ok.str())); + + out.str(""); + } // Call destructor. + ok.str(""); ok + #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS + << "u::static_inv" << std::endl + << "u::inv" << std::endl + #endif + #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS + << "u::dtor::old" << std::endl + #endif + << "u::dtor::body" << std::endl + #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS + << "u::static_inv" << std::endl + #endif + #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS + << "u::dtor::post" << std::endl + #endif + ; + BOOST_TEST(out.eq(ok.str())); + + return boost::report_errors(); +} +