Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

# testthat 3.2.3

* Fixed an issue preventing compilation from succeeding due to
deprecation / removal of `std::uncaught_exception()`. (@kevinushey, #2047)

* Fixed an issue where `expect_no_error(1)` was failing (#2037).

* Fixed an issue where calling `skip()` outside of an active test could
Expand Down
13 changes: 11 additions & 2 deletions inst/include/testthat/vendor/catch.h
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,15 @@

namespace Catch {

inline bool HasUncaughtException()
{
#if __cplusplus >= 202002L
return std::uncaught_exceptions() > 0;
#else
return std::uncaught_exception();
#endif
}

struct IConfig;

struct CaseSensitive { enum Choice {
Expand Down Expand Up @@ -8379,7 +8388,7 @@ namespace Catch {
{}

ScopedMessage::~ScopedMessage() {
if ( !std::uncaught_exception() ){
if ( !HasUncaughtException() ){
getResultCapture().popScopedMessage(m_info);
}
}
Expand Down Expand Up @@ -8702,7 +8711,7 @@ namespace Catch {
Section::~Section() {
if( m_sectionIncluded ) {
SectionEndInfo endInfo( m_info, m_assertions, m_timer.getElapsedSeconds() );
if( std::uncaught_exception() )
if( HasUncaughtException() )
getResultCapture().sectionEndedEarly( endInfo );
else
getResultCapture().sectionEnded( endInfo );
Expand Down
Loading