mirror of
https://github.com/boostorg/contract.git
synced 2026-02-26 16:42:19 +00:00
added .except(...), renamed old_ptr_noncopyable to old_ptr_if_copyable, and renamed OLDOF to OLD
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "../detail/oteststream.hpp"
|
||||
#include <boost/contract/function.hpp>
|
||||
#include <boost/contract/guard.hpp>
|
||||
#include <boost/contract/check.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <sstream>
|
||||
|
||||
@@ -17,10 +17,11 @@ boost::contract::test::detail::oteststream out;
|
||||
struct err {};
|
||||
|
||||
void f() {
|
||||
boost::contract::guard c = boost::contract::function()
|
||||
.precondition([&] { out << "f::pre" << std::endl; })
|
||||
.old([&] { out << "f::old" << std::endl; })
|
||||
.postcondition([&] { out << "f::post" << std::endl; })
|
||||
boost::contract::check c = boost::contract::function()
|
||||
.precondition([] { out << "f::pre" << std::endl; })
|
||||
.old([] { out << "f::old" << std::endl; })
|
||||
.postcondition([] { out << "f::post" << std::endl; })
|
||||
.except([] { out << "f::except" << std::endl; })
|
||||
;
|
||||
out << "f::body" << std::endl;
|
||||
throw err(); // Test body throws.
|
||||
@@ -42,6 +43,9 @@ int main() {
|
||||
<< "f::old" << std::endl
|
||||
#endif
|
||||
<< "f::body" << std::endl // Test this threw.
|
||||
#ifndef BOOST_CONTRACT_NO_EXCEPTS
|
||||
<< "f::except" << std::endl;
|
||||
#endif
|
||||
;
|
||||
BOOST_TEST(out.eq(ok.str()));
|
||||
} catch(...) { BOOST_TEST(false); }
|
||||
|
||||
Reference in New Issue
Block a user