mirror of
https://github.com/boostorg/contract.git
synced 2026-02-27 04:52:22 +00:00
29 lines
695 B
C++
29 lines
695 B
C++
|
|
// Test missing contract guard gives run-time error.
|
|
|
|
struct err {};
|
|
#define BOOST_CONTRACT_ON_MISSING_GUARD { throw err(); }
|
|
|
|
#include <boost/contract/function.hpp>
|
|
#include <boost/contract/guard.hpp>
|
|
|
|
int main() {
|
|
boost::contract::guard c = boost::contract::function() // Test this is OK.
|
|
.precondition([] {})
|
|
.old([] {})
|
|
.postcondition([] {})
|
|
;
|
|
|
|
try {
|
|
boost::contract::function() // Test no `guard c = ...` errors.
|
|
.precondition([] {})
|
|
.old([] {})
|
|
.postcondition([] {})
|
|
;
|
|
return 1;
|
|
} catch(err const&) { return 0; } // Test missing guard threw.
|
|
catch(...) { return 2; }
|
|
return 3;
|
|
}
|
|
|