mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Fix
git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@64 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
parent
b3ece38963
commit
a11d327318
3 changed files with 22 additions and 4 deletions
|
|
@ -10,7 +10,6 @@
|
|||
#define MOCK_NODE_HPP_INCLUDED
|
||||
|
||||
#include "verifiable.hpp"
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <functional>
|
||||
#include <algorithm>
|
||||
#include <ostream>
|
||||
|
|
@ -19,7 +18,7 @@
|
|||
|
||||
namespace mock
|
||||
{
|
||||
class node : private boost::noncopyable
|
||||
class node : protected verifiable
|
||||
{
|
||||
public:
|
||||
void add( verifiable& e )
|
||||
|
|
@ -31,7 +30,7 @@ namespace mock
|
|||
v_.erase( std::remove( v_.begin(), v_.end(), &e ), v_.end() );
|
||||
}
|
||||
|
||||
bool verify() const
|
||||
virtual bool verify() const
|
||||
{
|
||||
bool valid = true;
|
||||
for( verifiables_cit it = v_.begin(); it != v_.end(); ++it )
|
||||
|
|
@ -39,7 +38,7 @@ namespace mock
|
|||
valid = false;
|
||||
return valid;
|
||||
}
|
||||
void reset()
|
||||
virtual void reset()
|
||||
{
|
||||
std::for_each( v_.begin(), v_.end(),
|
||||
std::mem_fun( &verifiable::reset ) );
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#define MOCK_OBJECT_HPP_INCLUDED
|
||||
|
||||
#include "node.hpp"
|
||||
#include "root.hpp"
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
|
|
@ -51,6 +52,15 @@ namespace mock
|
|||
class object_impl : public node
|
||||
{
|
||||
public:
|
||||
object_impl()
|
||||
{
|
||||
root.add( *this );
|
||||
}
|
||||
virtual ~object_impl()
|
||||
{
|
||||
root.remove( *this );
|
||||
}
|
||||
|
||||
std::string name_;
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -41,6 +41,15 @@ BOOST_AUTO_TEST_CASE( verifying_an_object_containing_a_failing_expectation_fails
|
|||
BOOST_CHECK( ! o.verify() );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( verifying_all_objects_with_one_of_them_containing_a_failing_expectation_fails )
|
||||
{
|
||||
mock::object o;
|
||||
mock::expectation< void(), silent_error > e;
|
||||
o.set_parent( e );
|
||||
e.expect().once();
|
||||
BOOST_CHECK( ! mock::verify() );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( resetting_an_object_containing_a_failing_expectation_and_verifying_it_succeeds )
|
||||
{
|
||||
mock::object o;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue