mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-04 05:09:53 +01:00
parent
c887d1a167
commit
06548a5b61
@ -105,6 +105,9 @@ namespace Matchers {
|
|||||||
|
|
||||||
namespace StdString {
|
namespace StdString {
|
||||||
|
|
||||||
|
inline std::string makeString( const std::string& str ) { return str; }
|
||||||
|
inline std::string makeString( const char* str ) { return str ? std::string( str ) : std::string(); }
|
||||||
|
|
||||||
struct Equals : MatcherImpl<Equals, std::string> {
|
struct Equals : MatcherImpl<Equals, std::string> {
|
||||||
Equals( const std::string& str ) : m_str( str ){}
|
Equals( const std::string& str ) : m_str( str ){}
|
||||||
Equals( const Equals& other ) : m_str( other.m_str ){}
|
Equals( const Equals& other ) : m_str( other.m_str ){}
|
||||||
@ -196,10 +199,30 @@ namespace Matchers {
|
|||||||
return Impl::Generic::AnyOf<ExpressionT>().add( m1 ).add( m2 ).add( m3 );
|
return Impl::Generic::AnyOf<ExpressionT>().add( m1 ).add( m2 ).add( m3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Impl::StdString::Equals Equals( const std::string& str ){ return Impl::StdString::Equals( str ); }
|
inline Impl::StdString::Equals Equals( const std::string& str ) {
|
||||||
inline Impl::StdString::Contains Contains( const std::string& substr ){ return Impl::StdString::Contains( substr ); }
|
return Impl::StdString::Equals( str );
|
||||||
inline Impl::StdString::StartsWith StartsWith( const std::string& substr ){ return Impl::StdString::StartsWith( substr ); }
|
}
|
||||||
inline Impl::StdString::EndsWith EndsWith( const std::string& substr ){ return Impl::StdString::EndsWith( substr ); }
|
inline Impl::StdString::Equals Equals( const char* str ) {
|
||||||
|
return Impl::StdString::Equals( Impl::StdString::makeString( str ) );
|
||||||
|
}
|
||||||
|
inline Impl::StdString::Contains Contains( const std::string& substr ) {
|
||||||
|
return Impl::StdString::Contains( substr );
|
||||||
|
}
|
||||||
|
inline Impl::StdString::Contains Contains( const char* substr ) {
|
||||||
|
return Impl::StdString::Contains( Impl::StdString::makeString( substr ) );
|
||||||
|
}
|
||||||
|
inline Impl::StdString::StartsWith StartsWith( const std::string& substr ) {
|
||||||
|
return Impl::StdString::StartsWith( substr );
|
||||||
|
}
|
||||||
|
inline Impl::StdString::StartsWith StartsWith( const char* substr ) {
|
||||||
|
return Impl::StdString::StartsWith( Impl::StdString::makeString( substr ) );
|
||||||
|
}
|
||||||
|
inline Impl::StdString::EndsWith EndsWith( const std::string& substr ) {
|
||||||
|
return Impl::StdString::EndsWith( substr );
|
||||||
|
}
|
||||||
|
inline Impl::StdString::EndsWith EndsWith( const char* substr ) {
|
||||||
|
return Impl::StdString::EndsWith( Impl::StdString::makeString( substr ) );
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Matchers
|
} // namespace Matchers
|
||||||
|
|
||||||
|
@ -235,10 +235,10 @@ TEST_CASE("./failing/matchers/Equals", "")
|
|||||||
{
|
{
|
||||||
CHECK_THAT( testStringForMatching(), Equals( "something else" ) );
|
CHECK_THAT( testStringForMatching(), Equals( "something else" ) );
|
||||||
}
|
}
|
||||||
//TEST_CASE("string", "Equals with NULL")
|
TEST_CASE("string", "Equals with NULL")
|
||||||
//{
|
{
|
||||||
// REQUIRE_THAT("", Equals(NULL));
|
REQUIRE_THAT("", Equals(NULL));
|
||||||
//}
|
}
|
||||||
TEST_CASE("./succeeding/matchers/AllOf", "")
|
TEST_CASE("./succeeding/matchers/AllOf", "")
|
||||||
{
|
{
|
||||||
CHECK_THAT( testStringForMatching(), AllOf( Catch::Contains( "string" ), Catch::Contains( "abc" ) ) );
|
CHECK_THAT( testStringForMatching(), AllOf( Catch::Contains( "string" ), Catch::Contains( "abc" ) ) );
|
||||||
|
Loading…
Reference in New Issue
Block a user