]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/contract/test/public_function/static.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 public static member function contracts.
9 #include "../detail/oteststream.hpp"
10 #include <boost/contract/base_types.hpp>
11 #include <boost/contract/public_function.hpp>
12 #include <boost/contract/check.hpp>
13 #include <boost/detail/lightweight_test.hpp>
16 boost::contract::test::detail::oteststream out
;
19 static void static_invariant() { out
<< "b::static_inv" << std::endl
; }
20 void invariant() const { out
<< "b::inv" << std::endl
; }
23 boost::contract::check c
= boost::contract::public_function
<b
>()
24 .precondition([] { out
<< "b::f::pre" << std::endl
; })
25 .old([] { out
<< "b::f::old" << std::endl
; })
26 .postcondition([] { out
<< "b::f::post" << std::endl
; })
28 out
<< "b::f::body" << std::endl
;
33 #define BASES public b
36 typedef BOOST_CONTRACT_BASE_TYPES(BASES
) base_types
;
39 static void static_invariant() { out
<< "a::static_inv" << std::endl
; }
40 void invariant() const { out
<< "a::inv" << std::endl
; }
43 boost::contract::check c
= boost::contract::public_function
<a
>()
44 .precondition([] { out
<< "a::f::pre" << std::endl
; })
45 .old([] { out
<< "a::f::old" << std::endl
; })
46 .postcondition([] { out
<< "a::f::post" << std::endl
; })
48 out
<< "a::f::body" << std::endl
;
53 std::ostringstream ok
;
58 // Static so no object thus only static inv, plus never virtual so subst
59 // principle does not apply and no subcontracting.
60 #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
61 << "a::static_inv" << std::endl
63 #ifndef BOOST_CONTRACT_NO_PRECONDITIONS
64 << "a::f::pre" << std::endl
66 #ifndef BOOST_CONTRACT_NO_OLDS
67 << "a::f::old" << std::endl
69 << "a::f::body" << std::endl
70 #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
71 << "a::static_inv" << std::endl
73 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
74 // No old call here because not base object.
75 << "a::f::post" << std::endl
78 BOOST_TEST(out
.eq(ok
.str()));
80 return boost::report_errors();