mirror of
https://github.com/boostorg/contract.git
synced 2026-01-27 06:42:20 +00:00
39 lines
773 B
C++
39 lines
773 B
C++
|
|
#include "aux_/oteststream.hpp"
|
|
#include <boost/contract/free_function.hpp>
|
|
#include <boost/detail/lightweight_test.hpp>
|
|
#include <sstream>
|
|
|
|
// Test free-function.
|
|
|
|
boost::contract::aux::test::oteststream out;
|
|
|
|
void f() {
|
|
boost::contract::type c = boost::contract::free_function()
|
|
.precondition([&] () {
|
|
out << "f::pre" << std::endl;
|
|
})
|
|
.postcondition([&] () {
|
|
out << "f::post" << std::endl;
|
|
})
|
|
;
|
|
out << "f::body" << std::endl;
|
|
}
|
|
|
|
int main() {
|
|
std::ostringstream ok;
|
|
|
|
out.str("");
|
|
f();
|
|
ok.str("");
|
|
ok
|
|
<< "f::pre" << std::endl
|
|
<< "f::body" << std::endl
|
|
<< "f::post" << std::endl
|
|
;
|
|
BOOST_TEST(out.check(ok.str()));
|
|
|
|
return boost::report_errors();
|
|
}
|
|
|