compiling all tests after some reorganization
This commit is contained in:
parent
ab26a9fcc6
commit
524d58ac9a
13
Jamroot
13
Jamroot
@ -1,6 +1,19 @@
|
||||
|
||||
import testing ;
|
||||
import os ;
|
||||
|
||||
rule subdir-run ( subdir : cpp_fname : requirements * )
|
||||
{
|
||||
run $(subdir)/$(cpp_fname).cpp : : : <include>$(subdir) $(requirements) :
|
||||
$(subdir)/$(cpp_fname) ;
|
||||
}
|
||||
|
||||
rule subdir-compile-fail ( subdir : cpp_fname : requirements * )
|
||||
{
|
||||
compile-fail $(subdir)/$(cpp_fname).cpp :
|
||||
<include>$(subdir) $(requirements) : $(subdir)/$(cpp_fname) ;
|
||||
}
|
||||
|
||||
if ! [ os.environ BOOST_ROOT ] {
|
||||
exit "Error: Set BOOST_ROOT environment variable to Boost root directory" ;
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <boost/config.hpp>
|
||||
#include <exception>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
|
||||
// TODO: Implement set_precondition/postcondition/invariant/entry_invariant/
|
||||
@ -24,10 +25,10 @@ struct assertion_failure : public std::exception {
|
||||
file_(""), line_(0), code_(code)
|
||||
{ init(); }
|
||||
|
||||
virtual ~assertion_failue() {}
|
||||
virtual ~assertion_failure() {}
|
||||
|
||||
// Return `assertion "XYZ" failed: file "ABC", line 123`.
|
||||
virtual char const* const what() const { return what_.c_str(); }
|
||||
virtual char const* what() const BOOST_NOEXCEPT { return what_.c_str(); }
|
||||
|
||||
char const* const file() const { return file_; }
|
||||
unsigned long line() const { return line_; }
|
||||
@ -35,13 +36,15 @@ struct assertion_failure : public std::exception {
|
||||
|
||||
private:
|
||||
void init() {
|
||||
what_ = "assertion";
|
||||
if(std::string(code_) != "") what_ += " \"" + code_ + "\"";
|
||||
what_ += " failed";
|
||||
std::ostringstream text;
|
||||
text.str("assertion");
|
||||
if(std::string(code_) != "") text << " \"" << code_ << "\"";
|
||||
text << " failed";
|
||||
if(std::string(file_) != "") {
|
||||
what_ += ": \"" + file_ + "\"";
|
||||
if(line != 0) what_ += ", line " + std::string(line_);
|
||||
text << ": \"" << file_ << "\"";
|
||||
if(line_ != 0) text << ", line " << line_;
|
||||
}
|
||||
what_ = text.str();
|
||||
}
|
||||
|
||||
char const* const file_;
|
||||
@ -53,9 +56,9 @@ private:
|
||||
struct precondition_failure : public assertion_failure {
|
||||
explicit precondition_failure(assertion_failure const& failure) :
|
||||
assertion_failure(failure) {
|
||||
what_ = "precondition " + assertion_failure::what();
|
||||
what_ = std::string("precondition ") + assertion_failure::what();
|
||||
}
|
||||
virtual char const* const what() const { return what_.c_str(); }
|
||||
virtual char const* what() const BOOST_NOEXCEPT { return what_.c_str(); }
|
||||
private:
|
||||
std::string what_;
|
||||
};
|
||||
@ -63,9 +66,9 @@ private:
|
||||
struct postcondition_failure : public assertion_failure {
|
||||
explicit postcondition_failure(assertion_failure const& failure) :
|
||||
assertion_failure(failure) {
|
||||
what_ = "postcondition " + assertion_failure::what();
|
||||
what_ = std::string("postcondition ") + assertion_failure::what();
|
||||
}
|
||||
virtual char const* const what() const { return what_.c_str(); }
|
||||
virtual char const* what() const BOOST_NOEXCEPT { return what_.c_str(); }
|
||||
private:
|
||||
std::string what_;
|
||||
};
|
||||
@ -75,9 +78,9 @@ struct invariant_failure : public assertion_failure {};
|
||||
struct entry_invariant_failure : public assertion_failure {
|
||||
explicit entry_invariant_failure(assertion_failure const& failure) :
|
||||
assertion_failure(failure) {
|
||||
what_ = "exit invariant " + assertion_failure::what();
|
||||
what_ = std::string("exit invariant ") + assertion_failure::what();
|
||||
}
|
||||
virtual char const* const what() const { return what_.c_str(); }
|
||||
virtual char const* what() const BOOST_NOEXCEPT { return what_.c_str(); }
|
||||
private:
|
||||
std::string what_;
|
||||
};
|
||||
@ -85,9 +88,9 @@ private:
|
||||
struct exit_invariant_failure : public assertion_failure {
|
||||
explicit exit_invariant_failure(assertion_failure const& failure) :
|
||||
assertion_failure(failure) {
|
||||
what_ = "exit invariant " + assertion_failure::what();
|
||||
what_ = std::string("exit invariant ") + assertion_failure::what();
|
||||
}
|
||||
virtual char const* const what() const { return what_.c_str(); }
|
||||
virtual char const* what() const BOOST_NOEXCEPT { return what_.c_str(); }
|
||||
private:
|
||||
std::string what_;
|
||||
};
|
||||
@ -112,7 +115,7 @@ namespace aux {
|
||||
void default_handler(from const) {
|
||||
try {
|
||||
throw;
|
||||
} catch(boost::contract::failure const& error) {
|
||||
} catch(boost::contract::assertion_failure const& error) {
|
||||
std::cerr << error.what() << std::endl;
|
||||
std::terminate();
|
||||
} catch(...) {
|
||||
@ -120,10 +123,10 @@ namespace aux {
|
||||
}
|
||||
}
|
||||
|
||||
failure_hander precondition_failure_handler = &default_handler;
|
||||
failure_hander postcondition_failure_handler = &default_handler;
|
||||
failure_hander entry_invariant_failure_handler = &default_handler;
|
||||
failure_hander exit_invariant_failure_handler = &default_handler;
|
||||
failure_handler precondition_failure_handler = &default_handler;
|
||||
failure_handler postcondition_failure_handler = &default_handler;
|
||||
failure_handler entry_invariant_failure_handler = &default_handler;
|
||||
failure_handler exit_invariant_failure_handler = &default_handler;
|
||||
}
|
||||
|
||||
failure_handler set_precondition_failure(failure_handler f)
|
||||
@ -164,3 +167,5 @@ void set_invariant_failure(failure_handler f) BOOST_NOEXCEPT_OR_NOTHROW {
|
||||
|
||||
} } // namespace
|
||||
|
||||
#endif // #include guard
|
||||
|
||||
|
@ -18,25 +18,20 @@ namespace boost {
|
||||
|
||||
namespace boost { namespace contract { namespace set {
|
||||
|
||||
class nothing {
|
||||
class nothing { // Allow (shallow ptr) copy for `auto c = ...`.
|
||||
public:
|
||||
// Allow to set nothing (neither precondition, nor postcondition).
|
||||
|
||||
private:
|
||||
explicit nothing(boost::shared_ptr<boost::contract::aux::check::pre_post>
|
||||
const contract) : contract_(contract) {}
|
||||
|
||||
/* implicit */ nothing(nothing const& other) : contract_(other.contract_) {}
|
||||
nothing& operator=(nothing const&) /* = delete */;
|
||||
nothing() /* = delete */;
|
||||
|
||||
boost::shared_ptr<boost::contract::aux::check::pre_post> contract_;
|
||||
|
||||
// Use friendship and deleted constructors to limit public API.
|
||||
|
||||
friend class boost::contract::type;
|
||||
friend class boost::contract::set::precondition_only;
|
||||
friend class boost::contract::set::postcondition_only;
|
||||
|
||||
explicit nothing(boost::shared_ptr<boost::contract::aux::check::pre_post>
|
||||
const contract) : contract_(contract) {}
|
||||
|
||||
boost::shared_ptr<boost::contract::aux::check::pre_post> contract_;
|
||||
};
|
||||
|
||||
} } } // namespace
|
||||
|
@ -24,7 +24,7 @@ namespace boost {
|
||||
|
||||
namespace boost { namespace contract { namespace set {
|
||||
|
||||
class postcondition_only {
|
||||
class postcondition_only { // Allow (shallow ptr) copy for `auto c = ...`.
|
||||
public:
|
||||
template<typename Postcondition>
|
||||
boost::contract::set::nothing postcondition(Postcondition const& f) {
|
||||
@ -33,18 +33,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
explicit postcondition_only(boost::shared_ptr<boost::contract::aux::
|
||||
check::pre_post> const contract) : contract_(contract) {}
|
||||
|
||||
/* implicit */ postcondition_only(postcondition_only const& other) :
|
||||
contract_(other.contract_) {}
|
||||
postcondition_only& operator=(postcondition_only const&) /* = delete */;
|
||||
postcondition_only() /* = delete */;
|
||||
|
||||
boost::shared_ptr<boost::contract::aux::check::pre_post> contract_;
|
||||
|
||||
// Use friendship and deleted constructors to limit public API.
|
||||
|
||||
friend class boost::contract::type;
|
||||
friend class boost::contract::set::precondition_postcondition;
|
||||
|
||||
@ -53,6 +42,11 @@ private:
|
||||
|
||||
template<class Class>
|
||||
friend postcondition_only boost::contract::destructor(Class* const);
|
||||
|
||||
explicit postcondition_only(boost::shared_ptr<boost::contract::aux::
|
||||
check::pre_post> const contract) : contract_(contract) {}
|
||||
|
||||
boost::shared_ptr<boost::contract::aux::check::pre_post> contract_;
|
||||
};
|
||||
|
||||
} } } // namespace
|
||||
|
@ -18,7 +18,7 @@ namespace boost {
|
||||
|
||||
namespace boost { namespace contract { namespace set {
|
||||
|
||||
class precondition_only {
|
||||
class precondition_only { // Allow (shallow ptr) copy for `auto c = ...`.
|
||||
public:
|
||||
template<typename Precondition>
|
||||
boost::contract::set::nothing precondition(Precondition const& f) {
|
||||
@ -27,20 +27,14 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
// Use friendship and deleted constructors to limit public API.
|
||||
friend class boost::contract::type;
|
||||
friend class boost::contract::set::precondition_postcondition;
|
||||
|
||||
explicit precondition_only(boost::shared_ptr<boost::contract::aux::
|
||||
check::pre_post> const contract) : contract_(contract) {}
|
||||
|
||||
/* implicit */ precondition_only(precondition_only const& other) :
|
||||
contract_(other.contract_) {}
|
||||
precondition_only& operator=(precondition_only const&) /* = delete */;
|
||||
precondition_only() /* = delete */;
|
||||
|
||||
boost::shared_ptr<boost::contract::aux::check::pre_post> contract_;
|
||||
|
||||
// Use friendship and deleted constructors to limit public API.
|
||||
|
||||
friend class boost::contract::type;
|
||||
friend class boost::contract::set::precondition_postcondition;
|
||||
};
|
||||
|
||||
} } } // namespace
|
||||
|
@ -43,7 +43,7 @@ namespace boost {
|
||||
|
||||
namespace boost { namespace contract { namespace set {
|
||||
|
||||
class precondition_postcondition {
|
||||
class precondition_postcondition { // Allow (shallow ptr) copy for auto c = ...
|
||||
public:
|
||||
template<typename Precondition>
|
||||
boost::contract::set::postcondition_only precondition(
|
||||
@ -60,19 +60,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
explicit precondition_postcondition(boost::shared_ptr<boost::contract::aux::
|
||||
check::pre_post> const contract) : contract_(contract) {}
|
||||
|
||||
/* implicit */ precondition_postcondition(precondition_postcondition const&
|
||||
other) : contract_(other.contract_) {}
|
||||
precondition_postcondition& operator=(precondition_postcondition const&)
|
||||
/* = delete */;
|
||||
precondition_postcondition() /* = delete */;
|
||||
|
||||
boost::shared_ptr<boost::contract::aux::check::pre_post> contract_;
|
||||
|
||||
// Use friendship and deleted constructors to limit public API.
|
||||
|
||||
friend class boost::contract::type;
|
||||
|
||||
template<class Itrospection, class Class, typename Function,
|
||||
@ -101,6 +89,11 @@ private:
|
||||
friend precondition_postcondition boost::contract::protected_member();
|
||||
friend precondition_postcondition boost::contract::private_member();
|
||||
friend precondition_postcondition boost::contract::free_function();
|
||||
|
||||
explicit precondition_postcondition(boost::shared_ptr<boost::contract::aux::
|
||||
check::pre_post> const contract) : contract_(contract) {}
|
||||
|
||||
boost::shared_ptr<boost::contract::aux::check::pre_post> contract_;
|
||||
};
|
||||
|
||||
} } } // namespace
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
namespace boost { namespace contract {
|
||||
|
||||
class type { // Must allow copy for `type c = ...` (shallow smart ptr copy).
|
||||
class type { // Allow (shallow ptr) copy for `type c = ...`.
|
||||
public:
|
||||
/* implicit */ type(boost::contract::set::precondition_postcondition const&
|
||||
c) : contract_(c.contract_) {}
|
||||
|
@ -1,26 +1,26 @@
|
||||
|
||||
import testing ;
|
||||
subdir-run function : constructor_bases ;
|
||||
subdir-run function : destructor_bases ;
|
||||
subdir-run function : public_member_bases_virtual ;
|
||||
subdir-run function : public_member_bases_static ;
|
||||
subdir-run function : protected_member_bases ;
|
||||
subdir-run function : private_member_bases ;
|
||||
subdir-run function : free_function ;
|
||||
|
||||
run base_types.cpp ;
|
||||
run has_bases.cpp ;
|
||||
run has_invariant.cpp ;
|
||||
run introspect.cpp ;
|
||||
subdir-run set : creation_set_post_nothing_comb ;
|
||||
subdir-compile-fail set : creation_set_post_post_error ;
|
||||
subdir-compile-fail set : creation_set_post_pre_error ;
|
||||
subdir-compile-fail set : creation_set_pre_error ;
|
||||
subdir-run set : function_set_pre_post_nothing_comb ;
|
||||
subdir-compile-fail set : function_set_post_post_error ;
|
||||
subdir-compile-fail set : function_set_post_pre_post_error ;
|
||||
subdir-compile-fail set : function_set_post_pre_pre_error ;
|
||||
subdir-compile-fail set : function_set_pre_post_post_error ;
|
||||
subdir-compile-fail set : function_set_pre_post_pre_error ;
|
||||
subdir-compile-fail set : function_set_pre_pre_error ;
|
||||
|
||||
run constructor_bases.cpp ;
|
||||
run destructor_bases.cpp ;
|
||||
|
||||
run public_member_bases_virtual.cpp ;
|
||||
run public_member_bases_static.cpp ;
|
||||
|
||||
run protected_member_bases.cpp ;
|
||||
run private_member_bases.cpp ;
|
||||
|
||||
run free_function/call.cpp ;
|
||||
run free_function/set.cpp ;
|
||||
compile-fail free_function/set_pre_pre_error.cpp ;
|
||||
compile-fail free_function/set_pre_post_pre_error.cpp ;
|
||||
compile-fail free_function/set_post_pre_pre_error.cpp ;
|
||||
compile-fail free_function/set_post_post_error.cpp ;
|
||||
compile-fail free_function/set_post_pre_post_error.cpp ;
|
||||
compile-fail free_function/set_pre_post_post_error.cpp ;
|
||||
subdir-run type_traits : introspect ;
|
||||
subdir-run type_traits : base_types ;
|
||||
subdir-run type_traits : has_bases ;
|
||||
subdir-run type_traits : has_invariant ;
|
||||
|
||||
|
@ -1,9 +0,0 @@
|
||||
|
||||
import testing ;
|
||||
|
||||
run with_bases.cpp ;
|
||||
run set.cpp ;
|
||||
compile-fail set_pre_error.cpp ;
|
||||
compile-fail set_post_pre_error.cpp ;
|
||||
compile-fail set_post_post_error.cpp ;
|
||||
|
@ -1,20 +0,0 @@
|
||||
|
||||
#include <boost/contract/constructor.hpp>
|
||||
#include <boost/contract/type.hpp>
|
||||
|
||||
// Test double post error.
|
||||
|
||||
struct a {
|
||||
explicit a() {
|
||||
boost::contract::type c = boost::contract::constructor(this)
|
||||
.postcondition([&] {})
|
||||
.postcondition([&] {})
|
||||
;
|
||||
}
|
||||
};
|
||||
|
||||
int main() {
|
||||
a aa;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,20 +0,0 @@
|
||||
|
||||
#include <boost/contract/constructor.hpp>
|
||||
#include <boost/contract/type.hpp>
|
||||
|
||||
// Test pre after post error (must use constructor_precondition instead).
|
||||
|
||||
struct a {
|
||||
explicit a() {
|
||||
boost::contract::type c = boost::contract::constructor(this)
|
||||
.postcondition([&] {})
|
||||
.precondition([&] {})
|
||||
;
|
||||
}
|
||||
};
|
||||
|
||||
int main() {
|
||||
a aa;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,19 +0,0 @@
|
||||
|
||||
#include <boost/contract/constructor.hpp>
|
||||
#include <boost/contract/type.hpp>
|
||||
|
||||
// Test pre error (must use constructor_precondition instead).
|
||||
|
||||
struct a {
|
||||
explicit a() {
|
||||
boost::contract::type c = boost::contract::constructor(this)
|
||||
.precondition([&] {})
|
||||
;
|
||||
}
|
||||
};
|
||||
|
||||
int main() {
|
||||
a aa;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,12 +0,0 @@
|
||||
|
||||
import testing ;
|
||||
|
||||
run call.cpp ;
|
||||
run set.cpp ;
|
||||
compile-fail set_pre_pre_error.cpp ;
|
||||
compile-fail set_pre_post_pre_error.cpp ;
|
||||
compile-fail set_post_pre_pre_error.cpp ;
|
||||
compile-fail set_post_post_error.cpp ;
|
||||
compile-fail set_post_pre_post_error.cpp ;
|
||||
compile-fail set_pre_post_post_error.cpp ;
|
||||
|
@ -1,12 +0,0 @@
|
||||
|
||||
#include <boost/contract/free_function.hpp>
|
||||
#include <boost/contract/type.hpp>
|
||||
|
||||
int main() {
|
||||
boost::contract::type c = boost::contract::free_function()
|
||||
.postcondition([&] {})
|
||||
.postcondition([&] {})
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,13 +0,0 @@
|
||||
|
||||
#include <boost/contract/free_function.hpp>
|
||||
#include <boost/contract/type.hpp>
|
||||
|
||||
int main() {
|
||||
boost::contract::type c = boost::contract::free_function()
|
||||
.postcondition([&] {})
|
||||
.precondition([&] {})
|
||||
.postcondition([&] {})
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,13 +0,0 @@
|
||||
|
||||
#include <boost/contract/free_function.hpp>
|
||||
#include <boost/contract/type.hpp>
|
||||
|
||||
int main() {
|
||||
boost::contract::type c = boost::contract::free_function()
|
||||
.postcondition([&] {})
|
||||
.precondition([&] {})
|
||||
.precondition([&] {})
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,13 +0,0 @@
|
||||
|
||||
#include <boost/contract/free_function.hpp>
|
||||
#include <boost/contract/type.hpp>
|
||||
|
||||
int main() {
|
||||
boost::contract::type c = boost::contract::free_function()
|
||||
.precondition([&] {})
|
||||
.postcondition([&] {})
|
||||
.postcondition([&] {})
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,13 +0,0 @@
|
||||
|
||||
#include <boost/contract/free_function.hpp>
|
||||
#include <boost/contract/type.hpp>
|
||||
|
||||
int main() {
|
||||
boost::contract::type c = boost::contract::free_function()
|
||||
.precondition([&] {})
|
||||
.postcondition([&] {})
|
||||
.precondition([&] {})
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,12 +0,0 @@
|
||||
|
||||
#include <boost/contract/free_function.hpp>
|
||||
#include <boost/contract/type.hpp>
|
||||
|
||||
int main() {
|
||||
boost::contract::type c = boost::contract::free_function()
|
||||
.precondition([&] {})
|
||||
.precondition([&] {})
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
#include "aux_/oteststream.hpp"
|
||||
#include "../aux_/oteststream.hpp"
|
||||
#include <boost/contract/destructor.hpp>
|
||||
#include <boost/contract/type.hpp>
|
||||
#include <boost/contract/base_types.hpp>
|
@ -1,5 +1,5 @@
|
||||
|
||||
#include "aux_/oteststream.hpp"
|
||||
#include "../aux_/oteststream.hpp"
|
||||
#include <boost/contract/private_member.hpp>
|
||||
#include <boost/contract/type.hpp>
|
||||
#include <boost/contract/base_types.hpp>
|
@ -1,5 +1,5 @@
|
||||
|
||||
#include "aux_/oteststream.hpp"
|
||||
#include "../aux_/oteststream.hpp"
|
||||
#include <boost/contract/protected_member.hpp>
|
||||
#include <boost/contract/type.hpp>
|
||||
#include <boost/contract/base_types.hpp>
|
@ -1,5 +1,5 @@
|
||||
|
||||
#include "aux_/oteststream.hpp"
|
||||
#include "../aux_/oteststream.hpp"
|
||||
#include <boost/contract/public_member.hpp>
|
||||
#include <boost/contract/type.hpp>
|
||||
#include <boost/contract/base_types.hpp>
|
@ -1,5 +1,5 @@
|
||||
|
||||
#include "aux_/oteststream.hpp"
|
||||
#include "../aux_/oteststream.hpp"
|
||||
#include <boost/contract/public_member.hpp>
|
||||
#include <boost/contract/type.hpp>
|
||||
#include <boost/contract/introspect.hpp>
|
@ -1,11 +1,11 @@
|
||||
|
||||
#include "../aux_/oteststream.hpp"
|
||||
#include <boost/contract/constructor.hpp>
|
||||
#include <boost/contract/type.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <sstream>
|
||||
|
||||
// Test all possible orders in which pre/post can be set.
|
||||
// Test post or nothing combinations that can be set for constructors
|
||||
// (destructors use same setter objects, so no need to test those too).
|
||||
|
||||
boost::contract::aux::test::oteststream out;
|
||||
|
||||
@ -14,7 +14,7 @@ struct nothing {
|
||||
static void static_invariant() { out << "static_inv" << std::endl; }
|
||||
|
||||
explicit nothing() {
|
||||
boost::contract::type c = boost::contract::constructor(this);
|
||||
auto c = boost::contract::constructor(this);
|
||||
out << "body" << std::endl;
|
||||
}
|
||||
};
|
||||
@ -28,7 +28,7 @@ struct pre_only : private boost::contract::constructor_precondition<pre_only> {
|
||||
out << "pre" << std::endl;
|
||||
})
|
||||
{
|
||||
boost::contract::type c = boost::contract::constructor(this);
|
||||
auto c = boost::contract::constructor(this);
|
||||
out << "body" << std::endl;
|
||||
}
|
||||
};
|
||||
@ -38,7 +38,7 @@ struct post_only {
|
||||
static void static_invariant() { out << "static_inv" << std::endl; }
|
||||
|
||||
explicit post_only() {
|
||||
boost::contract::type c = boost::contract::constructor(this)
|
||||
auto c = boost::contract::constructor(this)
|
||||
.postcondition([&] { out << "post" << std::endl; })
|
||||
;
|
||||
out << "body" << std::endl;
|
||||
@ -54,7 +54,7 @@ struct pre_post : private boost::contract::constructor_precondition<pre_post> {
|
||||
out << "pre" << std::endl;
|
||||
})
|
||||
{
|
||||
boost::contract::type c = boost::contract::constructor(this)
|
||||
auto c = boost::contract::constructor(this)
|
||||
.postcondition([&] { out << "post" << std::endl; })
|
||||
;
|
||||
out << "body" << std::endl;
|
20
test/set/creation_set_post_post_error.cpp
Normal file
20
test/set/creation_set_post_post_error.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
#include <boost/contract/constructor.hpp>
|
||||
|
||||
// Test post cannot be set twice for constructors
|
||||
// (destructors use same setter objects, so no need to test those too).
|
||||
|
||||
struct a {
|
||||
explicit a() {
|
||||
auto c = boost::contract::constructor(this)
|
||||
.postcondition([&] {})
|
||||
.postcondition([&] {}) // Error.
|
||||
;
|
||||
}
|
||||
};
|
||||
|
||||
int main() {
|
||||
a aa;
|
||||
return 0;
|
||||
}
|
||||
|
20
test/set/creation_set_post_pre_error.cpp
Normal file
20
test/set/creation_set_post_pre_error.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
#include <boost/contract/constructor.hpp>
|
||||
|
||||
// Test pre cannot be set (not even after post) for constructors
|
||||
// (destructors use same setter objects, so no need to test those too).
|
||||
|
||||
struct a {
|
||||
explicit a() {
|
||||
auto c = boost::contract::constructor(this)
|
||||
.postcondition([&] {})
|
||||
.precondition([&] {}) // Error.
|
||||
;
|
||||
}
|
||||
};
|
||||
|
||||
int main() {
|
||||
a aa;
|
||||
return 0;
|
||||
}
|
||||
|
19
test/set/creation_set_pre_error.cpp
Normal file
19
test/set/creation_set_pre_error.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
|
||||
#include <boost/contract/constructor.hpp>
|
||||
|
||||
// Test pre cannot be set for constructors
|
||||
// (destructors use same setter objects, so no need to test those too).
|
||||
|
||||
struct a {
|
||||
explicit a() {
|
||||
auto c = boost::contract::constructor(this)
|
||||
.precondition([&] {}) // Error.
|
||||
;
|
||||
}
|
||||
};
|
||||
|
||||
int main() {
|
||||
a aa;
|
||||
return 0;
|
||||
}
|
||||
|
14
test/set/function_set_post_post_error.cpp
Normal file
14
test/set/function_set_post_post_error.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
|
||||
#include <boost/contract/free_function.hpp>
|
||||
|
||||
// Test post cannot be set twice for free functions
|
||||
// (member functions use same setter objects, so no need to test those too).
|
||||
|
||||
int main() {
|
||||
auto c = boost::contract::free_function()
|
||||
.postcondition([&] {})
|
||||
.postcondition([&] {}) // Error.
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
|
15
test/set/function_set_post_pre_post_error.cpp
Normal file
15
test/set/function_set_post_pre_post_error.cpp
Normal file
@ -0,0 +1,15 @@
|
||||
|
||||
#include <boost/contract/free_function.hpp>
|
||||
|
||||
// Test post cannot be set twice (not even after pre) for free functions
|
||||
// (member functions use same setter objects, so no need to test those too).
|
||||
|
||||
int main() {
|
||||
auto c = boost::contract::free_function()
|
||||
.postcondition([&] {})
|
||||
.precondition([&] {})
|
||||
.postcondition([&] {}) // Error.
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
|
15
test/set/function_set_post_pre_pre_error.cpp
Normal file
15
test/set/function_set_post_pre_pre_error.cpp
Normal file
@ -0,0 +1,15 @@
|
||||
|
||||
#include <boost/contract/free_function.hpp>
|
||||
|
||||
// Test pre cannot be set twice (not even after post) for free functions
|
||||
// (member functions use same setter objects, so no need to test those too).
|
||||
|
||||
int main() {
|
||||
auto c = boost::contract::free_function()
|
||||
.postcondition([&] {})
|
||||
.precondition([&] {})
|
||||
.precondition([&] {}) // Error.
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,46 +1,43 @@
|
||||
|
||||
#include "../aux_/oteststream.hpp"
|
||||
#include <boost/contract/free_function.hpp>
|
||||
#include <boost/contract/type.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <sstream>
|
||||
|
||||
// Test pre and post, or nothing combinations that can be set for free functions
|
||||
// (member functions use same setter objects, so no need to test those too).
|
||||
|
||||
boost::contract::aux::test::oteststream out;
|
||||
|
||||
// Test free-function with neither pre nor post set.
|
||||
void nothing() {
|
||||
boost::contract::type c = boost::contract::free_function();
|
||||
auto c = boost::contract::free_function();
|
||||
out << "body" << std::endl;
|
||||
}
|
||||
|
||||
// Test free-function with only pre set.
|
||||
void pre_only() {
|
||||
boost::contract::type c = boost::contract::free_function()
|
||||
auto c = boost::contract::free_function()
|
||||
.precondition([&] { out << "pre" << std::endl; })
|
||||
;
|
||||
out << "body" << std::endl;
|
||||
}
|
||||
|
||||
// Test free-function with only post set.
|
||||
void post_only() {
|
||||
boost::contract::type c = boost::contract::free_function()
|
||||
auto c = boost::contract::free_function()
|
||||
.postcondition([&] { out << "post" << std::endl; })
|
||||
;
|
||||
out << "body" << std::endl;
|
||||
}
|
||||
|
||||
// Test free-function with pre set before post.
|
||||
void pre_post() {
|
||||
boost::contract::type c = boost::contract::free_function()
|
||||
auto c = boost::contract::free_function()
|
||||
.precondition([&] { out << "pre" << std::endl; })
|
||||
.postcondition([&] { out << "post" << std::endl; })
|
||||
;
|
||||
out << "body" << std::endl;
|
||||
}
|
||||
|
||||
// Test free-function with post set before pre.
|
||||
void post_pre() {
|
||||
boost::contract::type c = boost::contract::free_function()
|
||||
auto c = boost::contract::free_function()
|
||||
.postcondition([&] { out << "post" << std::endl; })
|
||||
.precondition([&] { out << "pre" << std::endl; })
|
||||
;
|
15
test/set/function_set_pre_post_post_error.cpp
Normal file
15
test/set/function_set_pre_post_post_error.cpp
Normal file
@ -0,0 +1,15 @@
|
||||
|
||||
#include <boost/contract/free_function.hpp>
|
||||
|
||||
// Test post cannot be set twice (not even after pre) for free functions
|
||||
// (member functions use same setter object, so no need to test those too).
|
||||
|
||||
int main() {
|
||||
auto c = boost::contract::free_function()
|
||||
.precondition([&] {})
|
||||
.postcondition([&] {})
|
||||
.postcondition([&] {}) // Error.
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
|
15
test/set/function_set_pre_post_pre_error.cpp
Normal file
15
test/set/function_set_pre_post_pre_error.cpp
Normal file
@ -0,0 +1,15 @@
|
||||
|
||||
#include <boost/contract/free_function.hpp>
|
||||
|
||||
// Test pre cannot be set twice (not even after post) for free functions
|
||||
// (member functions use same setter objects, so no need to test those too).
|
||||
|
||||
int main() {
|
||||
auto c = boost::contract::free_function()
|
||||
.precondition([&] {})
|
||||
.postcondition([&] {})
|
||||
.precondition([&] {}) // Error.
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
|
14
test/set/function_set_pre_pre_error.cpp
Normal file
14
test/set/function_set_pre_pre_error.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
|
||||
#include <boost/contract/free_function.hpp>
|
||||
|
||||
// Test pre cannot be set twice for free functions
|
||||
// (member functions use same setter objects, so no need to test those too).
|
||||
|
||||
int main() {
|
||||
auto c = boost::contract::free_function()
|
||||
.precondition([&] {})
|
||||
.precondition([&] {}) // Error.
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user