audit.hpp 987 B

1234567891011121314151617181920212223242526272829303132
  1. // no #include guard
  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
  6. #include <boost/contract/assert.hpp>
  7. #include <boost/contract/core/exception.hpp>
  8. #include <boost/detail/lightweight_test.hpp>
  9. int main() {
  10. bool threw = false;
  11. try {
  12. #ifdef BOOST_CONTRACT_TEST_ERROR
  13. BOOST_CONTRACT_ASSERT_AUDIT(
  14. BOOST_CONTRACT_TEST_ERROR_expected_undeclared_identifier);
  15. #else
  16. BOOST_CONTRACT_ASSERT_AUDIT(false);
  17. #endif
  18. } catch(boost::contract::assertion_failure const&) { threw = true; }
  19. #if defined(BOOST_CONTRACT_AUDITS) && !defined(BOOST_CONTRACT_NO_ALL)
  20. BOOST_TEST(threw);
  21. #else
  22. BOOST_TEST(!threw);
  23. #endif
  24. return boost::report_errors();
  25. }