mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Merge pull request #301 from bena/master
toString handles wchar_t raw strings
This commit is contained in:
commit
ee83a6f006
@ -154,6 +154,8 @@ std::string toString( std::string const& value );
|
||||
std::string toString( std::wstring const& value );
|
||||
std::string toString( const char* const value );
|
||||
std::string toString( char* const value );
|
||||
std::string toString( const wchar_t* const value );
|
||||
std::string toString( wchar_t* const value );
|
||||
std::string toString( int value );
|
||||
std::string toString( unsigned long value );
|
||||
std::string toString( unsigned int value );
|
||||
|
@ -84,6 +84,16 @@ std::string toString( char* const value ) {
|
||||
return Catch::toString( static_cast<const char*>( value ) );
|
||||
}
|
||||
|
||||
std::string toString( const wchar_t* const value )
|
||||
{
|
||||
return value ? Catch::toString( std::wstring(value) ) : std::string( "{null string}" );
|
||||
}
|
||||
|
||||
std::string toString( wchar_t* const value )
|
||||
{
|
||||
return Catch::toString( static_cast<const wchar_t*>( value ) );
|
||||
}
|
||||
|
||||
std::string toString( int value ) {
|
||||
std::ostringstream oss;
|
||||
oss << value;
|
||||
|
@ -356,3 +356,27 @@ TEST_CASE( "Tabs and newlines show in output", "[.][whitespace][failing]" ) {
|
||||
CHECK( s1 == s2 );
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE( "toString on const wchar_t const pointer returns the string contents", "[toString]" ) {
|
||||
const wchar_t * const s = L"wide load";
|
||||
std::string result = Catch::toString( s );
|
||||
CHECK( result == "\"wide load\"" );
|
||||
}
|
||||
|
||||
TEST_CASE( "toString on const wchar_t pointer returns the string contents", "[toString]" ) {
|
||||
const wchar_t * s = L"wide load";
|
||||
std::string result = Catch::toString( s );
|
||||
CHECK( result == "\"wide load\"" );
|
||||
}
|
||||
|
||||
TEST_CASE( "toString on wchar_t const pointer returns the string contents", "[toString]" ) {
|
||||
wchar_t * const s = L"wide load";
|
||||
std::string result = Catch::toString( s );
|
||||
CHECK( result == "\"wide load\"" );
|
||||
}
|
||||
|
||||
TEST_CASE( "toString on wchar_t returns the string contents", "[toString]" ) {
|
||||
wchar_t * s = L"wide load";
|
||||
std::string result = Catch::toString( s );
|
||||
CHECK( result == "\"wide load\"" );
|
||||
}
|
Loading…
Reference in New Issue
Block a user