mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Added generator copy ctor to fix bug when NRVO is not used. Some exception handling improvements, too
This commit is contained in:
parent
6bfc1b6016
commit
331188f6b3
@ -41,6 +41,7 @@
|
|||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
|
AdditionalIncludeDirectories="\\psf\Host\TwoBlueCubes\Dev\GitHub\Catch"
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
@ -202,10 +203,18 @@
|
|||||||
RelativePath="..\..\..\ExceptionTests.cpp"
|
RelativePath="..\..\..\ExceptionTests.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\..\GeneratorTests.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\..\MessageTests.cpp"
|
RelativePath="..\..\..\MessageTests.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\..\MiscTests.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\..\TrickyTests.cpp"
|
RelativePath="..\..\..\TrickyTests.cpp"
|
||||||
>
|
>
|
||||||
|
@ -17,6 +17,15 @@
|
|||||||
#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line )
|
#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line )
|
||||||
#define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ )
|
#define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ )
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#define ATTRIBUTE_NORETURN __attribute__ ((noreturn))
|
||||||
|
#else
|
||||||
|
#define ATTRIBUTE_NORETURN
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
namespace Catch
|
namespace Catch
|
||||||
{
|
{
|
||||||
class NonCopyable
|
class NonCopyable
|
||||||
@ -53,13 +62,17 @@ namespace Catch
|
|||||||
delete it->second;
|
delete it->second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ATTRIBUTE_NORETURN
|
||||||
|
inline void throwLogicError( const std::string& message, const std::string& file, long line )
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << "Internal Catch error: '" << message << "' at: " << file << "(" << line << ")";
|
||||||
|
throw std::logic_error( oss.str() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#ifdef __GNUC__
|
|
||||||
#define ATTRIBUTE_NORETURN __attribute__ ((noreturn))
|
#define CATCH_INTERNAL_ERROR( msg ) throwLogicError( msg, __FILE__, __LINE__ );
|
||||||
#else
|
|
||||||
#define ATTRIBUTE_NORETURN
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_COMMON_H_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_COMMON_H_INCLUDED
|
||||||
|
|
||||||
|
@ -129,6 +129,15 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// *** Move semantics, similar to auto_ptr ***
|
||||||
|
CompositeGenerator( CompositeGenerator& other )
|
||||||
|
: m_fileInfo( other.m_fileInfo ),
|
||||||
|
m_totalSize( 0 )
|
||||||
|
{
|
||||||
|
move( other );
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
CompositeGenerator& setFileInfo
|
CompositeGenerator& setFileInfo
|
||||||
(
|
(
|
||||||
@ -164,7 +173,7 @@ public:
|
|||||||
}
|
}
|
||||||
index += generator->size();
|
index += generator->size();
|
||||||
}
|
}
|
||||||
throw "this should never happen!";
|
CATCH_INTERNAL_ERROR( "Indexed past end of generated range" );
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -596,6 +596,16 @@ namespace Catch
|
|||||||
acceptMessage( ex.what() );
|
acceptMessage( ex.what() );
|
||||||
acceptResult( ResultWas::ThrewException );
|
acceptResult( ResultWas::ThrewException );
|
||||||
}
|
}
|
||||||
|
catch( std::string& msg )
|
||||||
|
{
|
||||||
|
acceptMessage( msg );
|
||||||
|
acceptResult( ResultWas::ThrewException );
|
||||||
|
}
|
||||||
|
catch( const char* msg )
|
||||||
|
{
|
||||||
|
acceptMessage( msg );
|
||||||
|
acceptResult( ResultWas::ThrewException );
|
||||||
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
acceptMessage( "unknown exception" );
|
acceptMessage( "unknown exception" );
|
||||||
|
Loading…
Reference in New Issue
Block a user