]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/contract/test/specify/pre_old_post_except.cpp
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
7 // Test specifying pre, old, post, and except (same if not free func).
9 #include "../detail/oteststream.hpp"
10 #include <boost/contract/function.hpp>
11 #include <boost/contract/check.hpp>
12 #include <boost/detail/lightweight_test.hpp>
15 boost::contract::test::detail::oteststream out
;
18 boost::contract::check c
= boost::contract::function()
19 .precondition([] { out
<< "f::pre" << std::endl
; })
20 .old([] { out
<< "f::old" << std::endl
; })
21 .postcondition([] { out
<< "f::post" << std::endl
; })
22 .except([] { out
<< "f::except" << std::endl
; })
24 out
<< "f::body" << std::endl
;
28 std::ostringstream ok
;
34 #ifndef BOOST_CONTRACT_NO_PRECONDITIONS
35 << "f::pre" << std::endl
37 #ifndef BOOST_CONTRACT_NO_OLDS
38 << "f::old" << std::endl
40 << "f::body" << std::endl
41 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
42 << "f::post" << std::endl
45 BOOST_TEST(out
.eq(ok
.str()));
47 return boost::report_errors();