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@473 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
parent
39009f6e52
commit
37572bf825
2 changed files with 63 additions and 67 deletions
|
|
@ -21,4 +21,57 @@ namespace mock
|
|||
};
|
||||
} // mock
|
||||
|
||||
#define MOCK_UNARY_CONSTRAINT(N,Expr) \
|
||||
namespace detail \
|
||||
{ \
|
||||
struct N \
|
||||
{ \
|
||||
template< typename Actual > \
|
||||
bool operator()( const Actual& actual ) const \
|
||||
{ \
|
||||
return Expr; \
|
||||
} \
|
||||
friend std::ostream& operator<<( std::ostream& s, const N& ) \
|
||||
{ \
|
||||
return s << BOOST_STRINGIZE(N); \
|
||||
} \
|
||||
}; \
|
||||
} \
|
||||
template<> \
|
||||
struct constraint< detail::N > \
|
||||
{ \
|
||||
constraint() \
|
||||
{} \
|
||||
detail::N f_; \
|
||||
}; \
|
||||
const constraint< detail::N > N;
|
||||
|
||||
#define MOCK_BINARY_CONSTRAINT(N,Expr) \
|
||||
namespace detail \
|
||||
{ \
|
||||
template< typename Expected > \
|
||||
struct N \
|
||||
{ \
|
||||
explicit N( const Expected& expected ) \
|
||||
: expected_( expected ) \
|
||||
{} \
|
||||
template< typename Actual > \
|
||||
bool operator()( const Actual& actual ) const \
|
||||
{ \
|
||||
return Expr; \
|
||||
} \
|
||||
friend std::ostream& operator<<( std::ostream& s, const N& n ) \
|
||||
{ \
|
||||
return s << BOOST_STRINGIZE(N) \
|
||||
<< "( " << mock::format( n.expected_ ) << " )"; \
|
||||
} \
|
||||
Expected expected_; \
|
||||
}; \
|
||||
} \
|
||||
template< typename T > \
|
||||
constraint< detail::N< T > > N( T t ) \
|
||||
{ \
|
||||
return detail::N< T >( t ); \
|
||||
}
|
||||
|
||||
#endif // MOCK_CONSTRAINT_HPP_INCLUDED
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue