mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Refactoring
git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@136 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
parent
3109a228f0
commit
8a34752a83
6 changed files with 35 additions and 33 deletions
|
|
@ -212,10 +212,6 @@
|
||||||
RelativePath="..\..\src\libraries\turtle\object.hpp"
|
RelativePath="..\..\src\libraries\turtle\object.hpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\..\src\libraries\turtle\orderable.hpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\src\libraries\turtle\placeholder.hpp"
|
RelativePath="..\..\src\libraries\turtle\placeholder.hpp"
|
||||||
>
|
>
|
||||||
|
|
@ -228,6 +224,10 @@
|
||||||
RelativePath="..\..\src\libraries\turtle\sequence.hpp"
|
RelativePath="..\..\src\libraries\turtle\sequence.hpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\src\libraries\turtle\sequenceable.hpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\src\libraries\turtle\type_name.hpp"
|
RelativePath="..\..\src\libraries\turtle\type_name.hpp"
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@
|
||||||
ProgramDataBaseFileName="$(IntDir)/$(ProjectName).pdb"
|
ProgramDataBaseFileName="$(IntDir)/$(ProjectName).pdb"
|
||||||
WarningLevel="4"
|
WarningLevel="4"
|
||||||
SuppressStartupBanner="true"
|
SuppressStartupBanner="true"
|
||||||
|
Detect64BitPortabilityProblems="true"
|
||||||
DebugInformationFormat="3"
|
DebugInformationFormat="3"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
|
|
@ -135,6 +136,7 @@
|
||||||
ProgramDataBaseFileName="$(IntDir)/$(ProjectName).pdb"
|
ProgramDataBaseFileName="$(IntDir)/$(ProjectName).pdb"
|
||||||
WarningLevel="4"
|
WarningLevel="4"
|
||||||
SuppressStartupBanner="true"
|
SuppressStartupBanner="true"
|
||||||
|
Detect64BitPortabilityProblems="true"
|
||||||
DebugInformationFormat="3"
|
DebugInformationFormat="3"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ namespace mock
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
class expectation_base : private orderable
|
class expectation_base : private sequenceable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
expectation_base()
|
expectation_base()
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ namespace detail
|
||||||
virtual bool is_valid() const = 0;
|
virtual bool is_valid() const = 0;
|
||||||
|
|
||||||
// Verify invocation
|
// Verify invocation
|
||||||
|
// returns false if the verification fails
|
||||||
virtual bool verify() const = 0;
|
virtual bool verify() const = 0;
|
||||||
|
|
||||||
friend inline std::ostream& operator<<( std::ostream& s, const invocation& i )
|
friend inline std::ostream& operator<<( std::ostream& s, const invocation& i )
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
#ifndef MOCK_SEQUENCE_HPP_INCLUDED
|
#ifndef MOCK_SEQUENCE_HPP_INCLUDED
|
||||||
#define MOCK_SEQUENCE_HPP_INCLUDED
|
#define MOCK_SEQUENCE_HPP_INCLUDED
|
||||||
|
|
||||||
#include "orderable.hpp"
|
#include "sequenceable.hpp"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
|
@ -20,50 +20,49 @@ namespace mock
|
||||||
public:
|
public:
|
||||||
~sequence()
|
~sequence()
|
||||||
{
|
{
|
||||||
for( elements_it it = elements_.begin();
|
for( orderables_it it = orderables_.begin();
|
||||||
it != elements_.end(); ++it )
|
it != orderables_.end(); ++it )
|
||||||
(*it)->remove( *this );
|
(*it)->remove( *this );
|
||||||
for( elements_it it = called_.begin();
|
for( orderables_it it = called_.begin();
|
||||||
it != called_.end(); ++it )
|
it != called_.end(); ++it )
|
||||||
(*it)->remove( *this );
|
(*it)->remove( *this );
|
||||||
}
|
}
|
||||||
|
|
||||||
void add( detail::orderable& e )
|
void add( detail::sequenceable& o )
|
||||||
{
|
{
|
||||||
elements_.push_back( &e );
|
orderables_.push_back( &o );
|
||||||
}
|
}
|
||||||
void remove( detail::orderable& e )
|
void remove( detail::sequenceable& o )
|
||||||
{
|
{
|
||||||
elements_.erase( std::remove( elements_.begin(),
|
orderables_.erase( std::remove( orderables_.begin(),
|
||||||
elements_.end(), &e ), elements_.end() );
|
orderables_.end(), &o ), orderables_.end() );
|
||||||
called_.erase( std::remove( called_.begin(),
|
called_.erase( std::remove( called_.begin(),
|
||||||
called_.end(), &e ), called_.end() );
|
called_.end(), &o ), called_.end() );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_valid( const detail::orderable& e ) const
|
bool is_valid( const detail::sequenceable& o ) const
|
||||||
{
|
{
|
||||||
return std::find( called_.begin(), called_.end(), &e )
|
return std::find( called_.begin(), called_.end(), &o )
|
||||||
== called_.end();
|
== called_.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
void call( const detail::orderable& e )
|
void call( const detail::sequenceable& o )
|
||||||
{
|
{
|
||||||
elements_it it =
|
orderables_it it =
|
||||||
std::find( elements_.begin(), elements_.end(), &e );
|
std::find( orderables_.begin(), orderables_.end(), &o );
|
||||||
if( it != elements_.end() )
|
if( it != orderables_.end() )
|
||||||
{
|
{
|
||||||
std::copy( elements_.begin(), it,
|
std::copy( orderables_.begin(), it,
|
||||||
std::back_inserter( called_ ) );
|
std::back_inserter( called_ ) );
|
||||||
elements_.erase( elements_.begin(), it );
|
orderables_.erase( orderables_.begin(), it );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::vector< detail::orderable* > elements_type;
|
typedef std::vector< detail::sequenceable* > orderables_type;
|
||||||
typedef elements_type::iterator elements_it;
|
typedef orderables_type::iterator orderables_it;
|
||||||
|
|
||||||
elements_type elements_;
|
orderables_type orderables_, called_;
|
||||||
elements_type called_;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef MOCK_ORDERABLE_HPP_INCLUDED
|
#ifndef MOCK_SEQUENCEABLE_HPP_INCLUDED
|
||||||
#define MOCK_ORDERABLE_HPP_INCLUDED
|
#define MOCK_SEQUENCEABLE_HPP_INCLUDED
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
|
|
@ -15,11 +15,11 @@ namespace mock
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
class orderable
|
class sequenceable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
orderable() {}
|
sequenceable() {}
|
||||||
virtual ~orderable() {}
|
virtual ~sequenceable() {}
|
||||||
|
|
||||||
virtual void remove( sequence& s ) = 0;
|
virtual void remove( sequence& s ) = 0;
|
||||||
};
|
};
|
||||||
|
|
@ -27,4 +27,4 @@ namespace detail
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // #ifndef MOCK_ORDERABLE_HPP_INCLUDED
|
#endif // #ifndef MOCK_SEQUENCEABLE_HPP_INCLUDED
|
||||||
Loading…
Add table
Add a link
Reference in a new issue