mirror of
https://github.com/boostorg/contract.git
synced 2026-02-27 04:52:22 +00:00
added .except(...), renamed old_ptr_noncopyable to old_ptr_if_copyable, and renamed OLDOF to OLD
This commit is contained in:
41
test/specify/missing_check_decl.cpp
Normal file
41
test/specify/missing_check_decl.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
// Copyright (C) 2008-2016 Lorenzo Caminiti
|
||||
// Distributed under the Boost Software License, Version 1.0 (see accompanying
|
||||
// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt).
|
||||
// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html
|
||||
|
||||
// Test missing contract check declaration gives run-time error.
|
||||
|
||||
struct err {};
|
||||
#define BOOST_CONTRACT_ON_MISSING_CHECK_DECL { throw err(); }
|
||||
|
||||
#include <boost/contract/function.hpp>
|
||||
#include <boost/contract/check.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
int main() {
|
||||
boost::contract::check c = boost::contract::function() // Test this is OK.
|
||||
.precondition([] {})
|
||||
.old([] {})
|
||||
.postcondition([] {})
|
||||
;
|
||||
|
||||
try {
|
||||
boost::contract::function() // Test no `check c = ...` errors.
|
||||
.precondition([] {})
|
||||
.old([] {})
|
||||
.postcondition([] {})
|
||||
;
|
||||
#if !defined(BOOST_CONTRACT_NO_PRECONDITIONS) || \
|
||||
!defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \
|
||||
!defined(BOOST_CONTRACT_NO_INVARIANTS)
|
||||
BOOST_TEST(false); // Error, must throw.
|
||||
#endif
|
||||
} catch(err const&) {
|
||||
// OK, threw as expected.
|
||||
} catch(...) {
|
||||
BOOST_TEST(false); // Error, unexpected throw.
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user