]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/contract/test/function/ifdef.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 contract compilation on/off.
9 #include "../detail/oteststream.hpp"
10 #include <boost/contract/core/config.hpp>
11 #ifndef BOOST_CONTRACT_NO_FUNCTIONS
12 #include <boost/contract/function.hpp>
13 #include <boost/contract/check.hpp>
14 #include <boost/contract/old.hpp>
16 #include <boost/detail/lightweight_test.hpp>
19 boost::contract::test::detail::oteststream out
;
22 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
23 boost::contract::old_ptr
<int> old_x
= BOOST_CONTRACT_OLDOF(x
);
25 #ifndef BOOST_CONTRACT_NO_FUNCTIONS
26 boost::contract::check c
= boost::contract::function()
27 #ifndef BOOST_CONTRACT_NO_PRECONDITIONS
28 .precondition([] { out
<< "f::pre" << std::endl
; })
30 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
31 .old([] { out
<< "f::old" << std::endl
; })
32 .postcondition([] { out
<< "f::post" << std::endl
; })
36 out
<< "f::body" << std::endl
;
40 std::ostringstream ok
;
44 #ifndef BOOST_CONTRACT_NO_PRECONDITIONS
45 << "f::pre" << std::endl
47 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
48 << "f::old" << std::endl
50 << "f::body" << std::endl
51 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
52 << "f::post" << std::endl
55 BOOST_TEST(out
.eq(ok
.str()));
56 return boost::report_errors();