Some reformating

This commit is contained in:
Phil Nash 2012-05-08 07:59:54 +01:00
parent 6f1543b1b1
commit 40b161adea

View File

@ -26,39 +26,25 @@ namespace Catch
namespace Detail namespace Detail
{ {
struct NonStreamable struct NonStreamable {
{ template<typename T> NonStreamable( const T& ){}
template<typename T>
NonStreamable( const T& )
{
}
}; };
// If the type does not have its own << overload for ostream then // If the type does not have its own << overload for ostream then
// this one will be used instead // this one will be used instead
inline std::ostream& operator << ( std::ostream& ss, NonStreamable ) inline std::ostream& operator << ( std::ostream& ss, NonStreamable ){
{ return ss << "{?}";
ss << "{?}";
return ss;
} }
template<typename T> template<typename T>
inline std::string makeString inline std::string makeString( const T& value ) {
(
const T& value
)
{
std::ostringstream oss; std::ostringstream oss;
oss << value; oss << value;
return oss.str(); return oss.str();
} }
template<typename T> template<typename T>
inline std::string makeString inline std::string makeString( T* p ) {
(
T* p
)
{
if( !p ) if( !p )
return INTERNAL_CATCH_STRINGIFY( NULL ); return INTERNAL_CATCH_STRINGIFY( NULL );
std::ostringstream oss; std::ostringstream oss;
@ -67,11 +53,7 @@ namespace Detail
} }
template<typename T> template<typename T>
inline std::string makeString inline std::string makeString( const T* p ) {
(
const T* p
)
{
if( !p ) if( !p )
return INTERNAL_CATCH_STRINGIFY( NULL ); return INTERNAL_CATCH_STRINGIFY( NULL );
std::ostringstream oss; std::ostringstream oss;
@ -81,33 +63,18 @@ namespace Detail
}// end namespace Detail }// end namespace Detail
///////////////////////////////////////////////////////////////////////////////
template<typename T> template<typename T>
std::string toString std::string toString( const T& value ) {
(
const T& value
)
{
return Detail::makeString( value ); return Detail::makeString( value );
} }
// Shortcut overloads // Shortcut overloads
/////////////////////////////////////////////////////////////////////////////// inline std::string toString( const std::string& value ) {
inline std::string toString
(
const std::string& value
)
{
return "\"" + value + "\""; return "\"" + value + "\"";
} }
/////////////////////////////////////////////////////////////////////////////// inline std::string toString( const std::wstring& value ) {
inline std::string toString
(
const std::wstring& value
)
{
std::ostringstream oss; std::ostringstream oss;
oss << "\""; oss << "\"";
for(size_t i = 0; i < value.size(); ++i ) for(size_t i = 0; i < value.size(); ++i )
@ -116,41 +83,21 @@ inline std::string toString
return oss.str(); return oss.str();
} }
/////////////////////////////////////////////////////////////////////////////// inline std::string toString( const char* const value ) {
inline std::string toString
(
const char* const value
)
{
return value ? Catch::toString( std::string( value ) ) : std::string( "{null string}" ); return value ? Catch::toString( std::string( value ) ) : std::string( "{null string}" );
} }
/////////////////////////////////////////////////////////////////////////////// inline std::string toString( char* const value ) {
inline std::string toString
(
char* const value
)
{
return Catch::toString( static_cast<const char*>( value ) ); return Catch::toString( static_cast<const char*>( value ) );
} }
/////////////////////////////////////////////////////////////////////////////// inline std::string toString( int value ) {
inline std::string toString
(
int value
)
{
std::ostringstream oss; std::ostringstream oss;
oss << value; oss << value;
return oss.str(); return oss.str();
} }
/////////////////////////////////////////////////////////////////////////////// inline std::string toString( unsigned int value ) {
inline std::string toString
(
unsigned int value
)
{
std::ostringstream oss; std::ostringstream oss;
if( value > 8192 ) if( value > 8192 )
oss << "0x" << std::hex << value; oss << "0x" << std::hex << value;
@ -159,12 +106,7 @@ inline std::string toString
return oss.str(); return oss.str();
} }
/////////////////////////////////////////////////////////////////////////////// inline std::string toString( unsigned long value ) {
inline std::string toString
(
unsigned long value
)
{
std::ostringstream oss; std::ostringstream oss;
if( value > 8192 ) if( value > 8192 )
oss << "0x" << std::hex << value; oss << "0x" << std::hex << value;
@ -173,32 +115,19 @@ inline std::string toString
return oss.str(); return oss.str();
} }
/////////////////////////////////////////////////////////////////////////////// inline std::string toString( const double value ) {
inline std::string toString
(
const double value
)
{
std::ostringstream oss; std::ostringstream oss;
oss << value; oss << value;
return oss.str(); return oss.str();
} }
/////////////////////////////////////////////////////////////////////////////// inline std::string toString( bool value ) {
inline std::string toString
(
bool value
)
{
return value ? "true" : "false"; return value ? "true" : "false";
} }
struct TestFailureException struct TestFailureException{};
{ struct DummyExceptionType_DontUse{};
};
struct DummyExceptionType_DontUse
{
};
struct STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison; struct STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison;
class MutableResultInfo : public ResultInfo class MutableResultInfo : public ResultInfo