mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Removed dependency to Boost.Algorithm
git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@185 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
parent
2b5385be40
commit
6095fa1dee
2 changed files with 33 additions and 3 deletions
|
|
@ -13,7 +13,6 @@
|
|||
#include "format.hpp"
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/preprocessor/stringize.hpp>
|
||||
|
||||
namespace mock
|
||||
|
|
@ -82,7 +81,6 @@ namespace mock
|
|||
MOCK_CONSTRAINT( greater, actual > expected_ )
|
||||
MOCK_CONSTRAINT( less_equal, actual <= expected_ )
|
||||
MOCK_CONSTRAINT( greater_equal, actual >= expected_ )
|
||||
MOCK_CONSTRAINT( contain, boost::algorithm::contains( actual, expected_ ) )
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
|
@ -161,6 +159,23 @@ namespace detail
|
|||
}
|
||||
Expected* expected_;
|
||||
};
|
||||
|
||||
template< typename Expected >
|
||||
struct contain
|
||||
{
|
||||
explicit contain( const Expected& expected )
|
||||
: expected_( expected )
|
||||
{}
|
||||
bool operator()( const std::string& actual ) const
|
||||
{
|
||||
return actual.find( expected_ ) != std::string::npos;
|
||||
}
|
||||
friend std::ostream& operator<<( std::ostream& s, const contain& n )
|
||||
{
|
||||
return s << "contain ( " << mock::format( n.expected_ ) << " )";
|
||||
}
|
||||
Expected expected_;
|
||||
};
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
|
|
@ -178,6 +193,11 @@ namespace detail
|
|||
{
|
||||
return detail::assign< T >( t );
|
||||
}
|
||||
template< typename T >
|
||||
constraint< detail::contain< T > > contain( T t )
|
||||
{
|
||||
return detail::contain< T >( t );
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
constraint< T > call( T t )
|
||||
|
|
|
|||
|
|
@ -178,8 +178,18 @@ BOOST_AUTO_TEST_CASE( evaluate )
|
|||
BOOST_CHECK( ! mock::evaluate.f_( &return_false ) );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( contain )
|
||||
BOOST_AUTO_TEST_CASE( contain_with_const_char_ptr )
|
||||
{
|
||||
BOOST_CHECK( mock::contain( "string" ).f_( "this is a string" ) );
|
||||
BOOST_CHECK( mock::contain( "string" ).f_( std::string( "this is a string" ) ) );
|
||||
BOOST_CHECK( ! mock::contain( "not found" ).f_( "this is a string" ) );
|
||||
BOOST_CHECK( ! mock::contain( "not found" ).f_( std::string( "this is a string" ) ) );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( contain_with_strings )
|
||||
{
|
||||
BOOST_CHECK( mock::contain( std::string( "string" ) ).f_( "this is a string" ) );
|
||||
BOOST_CHECK( mock::contain( std::string( "string" ) ).f_( std::string( "this is a string" ) ) );
|
||||
BOOST_CHECK( ! mock::contain( std::string( "not found" ) ).f_( "this is a string" ) );
|
||||
BOOST_CHECK( ! mock::contain( std::string( "not found" ) ).f_( std::string( "this is a string" ) ) );
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue