1 2 // no #include guard 3 4 // Copyright (C) 2008-2018 Lorenzo Caminiti 5 // Distributed under the Boost Software License, Version 1.0 (see accompanying 6 // file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). 7 // See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html 8 9 #include <boost/contract/check.hpp> 10 #include <boost/contract/core/exception.hpp> 11 #include <boost/detail/lightweight_test.hpp> 12 13 struct err {}; // Global decl so visible in MSVC10 lambdas. 14 main()15int main() { 16 boost::contract::set_check_failure([] { throw err(); }); 17 18 bool threw = false; 19 try { 20 #ifdef BOOST_CONTRACT_TEST_ERROR 21 BOOST_CONTRACT_CHECK_AUDIT( 22 BOOST_CONTRACT_TEST_ERROR_expected_undeclared_identifier); 23 #else 24 BOOST_CONTRACT_CHECK_AUDIT(false); 25 #endif 26 } catch(err const&) { threw = true; } 27 28 #if defined(BOOST_CONTRACT_AUDITS) && !defined(BOOST_CONTRACT_NO_CHECKS) 29 BOOST_TEST(threw); 30 #else 31 BOOST_TEST(!threw); 32 #endif 33 34 return boost::report_errors(); 35 } 36 37