Fixed null string reporting issue

This commit is contained in:
Phil Nash 2011-02-23 20:02:18 +00:00
parent 331188f6b3
commit 8087f5738c
2 changed files with 22 additions and 3 deletions

View File

@ -105,3 +105,14 @@ TEST_CASE( "./succeeding/Misc/stdout,stderr", "Sends stuff to stdout and stderr"
std::cerr << "An error"; std::cerr << "An error";
} }
const char* makeString( bool makeNull )
{
return makeNull ? NULL : "valid string";
}
TEST_CASE( "./succeeding/Misc/null strings", "" )
{
REQUIRE( makeString( false ) != static_cast<char*>(NULL));
REQUIRE( makeString( true ) == static_cast<char*>(NULL));
}

View File

@ -105,15 +105,23 @@ inline std::string toString
{ {
return value; return value;
} }
///////////////////////////////////////////////////////////////////////////////
inline std::string toString
(
const char* const value
)
{
return value ? "'" + std::string( value ) + "'" : std::string( "{null string}" );
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
inline std::string toString inline std::string toString
( (
const char* value char* const value
) )
{ {
return value; return toString( static_cast<const char* const>( value ) );
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
inline std::string toString inline std::string toString