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 missing contract check declaration gives run-time error.
10 #ifndef BOOST_CONTRACT_ON_MISSING_CHECK_DECL
11 #error "build must define ON_MISSING_CHECK_DECL=`{ throw err(); }`"
14 #include <boost/contract/function.hpp>
15 #include <boost/contract/check.hpp>
16 #include <boost/detail/lightweight_test.hpp>
19 boost::contract::check c = boost::contract::function() // Test this is OK.
26 boost::contract::function() // Test no `check c = ...` errors.
31 #if !defined(BOOST_CONTRACT_NO_PRECONDITIONS) || \
32 !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \
33 !defined(BOOST_CONTRACT_NO_INVARIANTS)
34 BOOST_TEST(false); // Error, must throw.
37 // OK, threw as expected.
39 BOOST_TEST(false); // Error, unexpected throw.
41 return boost::report_errors();