mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-02 05:15:39 +02:00
report file/ line of section of unexpected exception is thrown
This commit is contained in:
@@ -33,6 +33,8 @@ namespace Catch
|
||||
virtual bool sectionStarted
|
||||
( const std::string& name,
|
||||
const std::string& description,
|
||||
const std::string& filename,
|
||||
std::size_t line,
|
||||
std::size_t& successes,
|
||||
std::size_t& failures
|
||||
) = 0;
|
||||
|
@@ -360,6 +360,8 @@ namespace Catch
|
||||
{
|
||||
do
|
||||
{
|
||||
m_currentResult.setFileAndLine( m_runningTest->getTestCaseInfo().getFilename(),
|
||||
m_runningTest->getTestCaseInfo().getLine() );
|
||||
runCurrentTest( redirectedCout, redirectedCerr );
|
||||
}
|
||||
while( m_runningTest->hasUntestedSections() );
|
||||
@@ -459,14 +461,20 @@ namespace Catch
|
||||
virtual bool sectionStarted
|
||||
(
|
||||
const std::string& name,
|
||||
const std::string& description,
|
||||
const std::string& description,
|
||||
const std::string& filename,
|
||||
std::size_t line,
|
||||
std::size_t& successes,
|
||||
std::size_t& failures
|
||||
)
|
||||
{
|
||||
if( !m_runningTest->addSection( name ) )
|
||||
std::ostringstream oss;
|
||||
oss << filename << ":" << line;
|
||||
|
||||
if( !m_runningTest->addSection( oss.str() ) )
|
||||
return false;
|
||||
|
||||
m_currentResult.setFileAndLine( filename, line );
|
||||
m_reporter->StartSection( name, description );
|
||||
successes = m_successes;
|
||||
failures = m_failures;
|
||||
@@ -553,8 +561,6 @@ namespace Catch
|
||||
m_runningTest->reset();
|
||||
StreamRedirect coutRedir( std::cout, redirectedCout );
|
||||
StreamRedirect cerrRedir( std::cerr, redirectedCerr );
|
||||
m_currentResult.setFileAndLine( m_runningTest->getTestCaseInfo().getFilename(),
|
||||
m_runningTest->getTestCaseInfo().getLine() );
|
||||
m_runningTest->getTestCaseInfo().invoke();
|
||||
m_runningTest->ranToCompletion();
|
||||
}
|
||||
|
@@ -26,10 +26,12 @@ namespace Catch
|
||||
Section
|
||||
(
|
||||
const std::string& name,
|
||||
const std::string& description
|
||||
const std::string& description,
|
||||
const std::string& filename,
|
||||
std::size_t line
|
||||
)
|
||||
: m_name( name ),
|
||||
m_sectionIncluded( Hub::getResultCapture().sectionStarted( name, description, m_successes, m_failures ) )
|
||||
m_sectionIncluded( Hub::getResultCapture().sectionStarted( name, description, filename, line, m_successes, m_failures ) )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -50,6 +52,7 @@ namespace Catch
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
std::string m_name;
|
||||
std::size_t m_successes;
|
||||
std::size_t m_failures;
|
||||
@@ -58,6 +61,7 @@ namespace Catch
|
||||
|
||||
} // end namespace Catch
|
||||
|
||||
#define INTERNAL_CATCH_SECTION( name, desc ) if( Catch::Section INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::Section( name, desc ) )
|
||||
#define INTERNAL_CATCH_SECTION( name, desc ) \
|
||||
if( Catch::Section INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::Section( name, desc, __FILE__, __LINE__ ) )
|
||||
|
||||
#endif // TWOBLUECUBES_CATCH_SECTION_HPP_INCLUDED
|
||||
|
Reference in New Issue
Block a user