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
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="\\psf\Host\TwoBlueCubes\Dev\GitHub\Catch"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
@ -202,10 +203,18 @@
|
||||
RelativePath="..\..\..\ExceptionTests.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\GeneratorTests.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\MessageTests.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\MiscTests.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
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( 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
|
||||
{
|
||||
class NonCopyable
|
||||
@ -54,12 +63,16 @@ namespace Catch
|
||||
}
|
||||
}
|
||||
|
||||
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))
|
||||
#else
|
||||
#define ATTRIBUTE_NORETURN
|
||||
#endif
|
||||
|
||||
#define CATCH_INTERNAL_ERROR( msg ) throwLogicError( msg, __FILE__, __LINE__ );
|
||||
|
||||
#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
|
||||
(
|
||||
@ -164,7 +173,7 @@ public:
|
||||
}
|
||||
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() );
|
||||
acceptResult( ResultWas::ThrewException );
|
||||
}
|
||||
catch( std::string& msg )
|
||||
{
|
||||
acceptMessage( msg );
|
||||
acceptResult( ResultWas::ThrewException );
|
||||
}
|
||||
catch( const char* msg )
|
||||
{
|
||||
acceptMessage( msg );
|
||||
acceptResult( ResultWas::ThrewException );
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
acceptMessage( "unknown exception" );
|
||||
|
Loading…
Reference in New Issue
Block a user