Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMartin Hořeňovský2026-01-08 14:35:05 +0100
committerMartin Hořeňovský2026-01-11 14:53:08 +0100
commit2580eadc4230eedf1b66841bdd27a8aacc2412a5 (patch)
treeba8508f3ab737c0b9d11a2fd5c33d0bdbfcd457e
parentb59f4f352291a89c4a3fe1488eeccbddeea85625 (diff)
downloadcatch3-2580eadc4230eedf1b66841bdd27a8aacc2412a5.tar.gz
Add UNSCOPED_CAPTURE
Closes #2954 Closes #3010
-rw-r--r--docs/configuration.md2
-rw-r--r--docs/logging.md33
-rw-r--r--src/catch2/catch_message.cpp16
-rw-r--r--src/catch2/catch_message.hpp38
-rw-r--r--src/catch2/interfaces/catch_interfaces_capture.hpp1
-rw-r--r--src/catch2/internal/catch_run_context.cpp13
-rw-r--r--tests/ExtraTests/X01-PrefixedMacros.cpp1
-rw-r--r--tests/ExtraTests/X02-DisabledMacros.cpp2
-rw-r--r--tests/SelfTest/Baselines/automake.sw.approved.txt1
-rw-r--r--tests/SelfTest/Baselines/automake.sw.multi.approved.txt1
-rw-r--r--tests/SelfTest/Baselines/compact.sw.approved.txt5
-rw-r--r--tests/SelfTest/Baselines/compact.sw.multi.approved.txt5
-rw-r--r--tests/SelfTest/Baselines/console.std.approved.txt17
-rw-r--r--tests/SelfTest/Baselines/console.sw.approved.txt27
-rw-r--r--tests/SelfTest/Baselines/console.sw.multi.approved.txt27
-rw-r--r--tests/SelfTest/Baselines/junit.sw.approved.txt14
-rw-r--r--tests/SelfTest/Baselines/junit.sw.multi.approved.txt14
-rw-r--r--tests/SelfTest/Baselines/sonarqube.sw.approved.txt11
-rw-r--r--tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt11
-rw-r--r--tests/SelfTest/Baselines/tap.sw.approved.txt4
-rw-r--r--tests/SelfTest/Baselines/tap.sw.multi.approved.txt4
-rw-r--r--tests/SelfTest/Baselines/teamcity.sw.approved.txt3
-rw-r--r--tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt3
-rw-r--r--tests/SelfTest/Baselines/xml.sw.approved.txt27
-rw-r--r--tests/SelfTest/Baselines/xml.sw.multi.approved.txt27
-rw-r--r--tests/SelfTest/UsageTests/Message.tests.cpp10
26 files changed, 264 insertions, 53 deletions
diff --git a/docs/configuration.md b/docs/configuration.md
index 527a3f82..35867104 100644
--- a/docs/configuration.md
+++ b/docs/configuration.md
@@ -29,7 +29,7 @@ with the same name.
## Prefixing Catch macros
CATCH_CONFIG_PREFIX_ALL // Prefix all macros with CATCH_
- CATCH_CONFIG_PREFIX_MESSAGES // Prefix only INFO, UNSCOPED_INFO, WARN and CAPTURE
+ CATCH_CONFIG_PREFIX_MESSAGES // Prefix only message macros ((UNSCOPED_)INFO, WARN, (UNSCOPED_)CAPTURE)
To keep test code clean and uncluttered Catch uses short macro names (e.g. ```TEST_CASE``` and ```REQUIRE```). Occasionally these may conflict with identifiers from platform headers or the system under test. In this case the above identifier can be defined. This will cause all the Catch user macros to be prefixed with ```CATCH_``` (e.g. ```CATCH_TEST_CASE``` and ```CATCH_REQUIRE```).
diff --git a/docs/logging.md b/docs/logging.md
index 1da97749..371c80ad 100644
--- a/docs/logging.md
+++ b/docs/logging.md
@@ -26,19 +26,22 @@ started" and "Section B", while the third one will only report "Test case
started" as the extra info.
-## Logging without local scope
+## Logging outside of current scope
-> [Introduced](https://github.com/catchorg/Catch2/issues/1522) in Catch2 2.7.0.
+> `UNSCOPED_INFO` was [introduced](https://github.com/catchorg/Catch2/issues/1522) in Catch2 2.7.0.
-`UNSCOPED_INFO` is similar to `INFO` with two key differences:
+> `UNSCOPED_CAPTURE` was introduced in Catch2 X.Y.Z.
-- Lifetime of an unscoped message is not tied to its own scope.
-- An unscoped message can be reported by the first following assertion only, regardless of the result of that assertion.
+The `UNSCOPED_X` macros are similar to their plain `X` macro counterparts,
+with two key differences:
-In other words, lifetime of `UNSCOPED_INFO` is limited by the following assertion (or by the end of test case/section, whichever comes first) whereas lifetime of `INFO` is limited by its own scope.
+- The lifetime of an unscoped message is not tied to its own scope.
+- An unscoped message can be reported by the first following assertion only, regardless of the result of that assertion.
-These differences make this macro useful for reporting information from helper functions or inner scopes. An example:
+In other words, the `UNSCOPED_X` macros are useful to add extra information
+to the next assertion, e.g. from helper functions or inner scopes.
+An example:
```cpp
void print_some_info() {
UNSCOPED_INFO("Info from helper");
@@ -83,9 +86,16 @@ Second info
Second unscoped info
```
+Note that unscoped messages are not passed between test cases, even if
+there were no assertions between them.
+
+
## Streaming macros
-All these macros allow heterogeneous sequences of values to be streaming using the insertion operator (```<<```) in the same way that std::ostream, std::cout, etc support it.
+Apart from `CAPTURE` (and its close sibling, `UNSCOPED_CAPTURE`), message
+macros support gradual streaming of messages and values in the same way
+that the standard streams do.
+
E.g.:
```c++
@@ -99,9 +109,6 @@ These macros come in three forms:
The message is logged to a buffer, but only reported with next assertions that are logged. This allows you to log contextual information in case of failures which is not shown during a successful test run (for the console reporter, without -s). Messages are removed from the buffer at the end of their scope, so may be used, for example, in loops.
-_Note that in Catch2 2.x.x `INFO` can be used without a trailing semicolon as there is a trailing semicolon inside macro.
-This semicolon will be removed with next major version. It is highly advised to use a trailing semicolon after `INFO` macro._
-
**UNSCOPED_INFO(** _message expression_ **)**
> [Introduced](https://github.com/catchorg/Catch2/issues/1522) in Catch2 2.7.0.
@@ -128,6 +135,10 @@ AS `FAIL`, but does not abort the test
**CAPTURE(** _expression1_, _expression2_, ... **)**
+**UNSCOPED_CAPTURE(** _expression1_, _expression2_, ... **)**
+
+> `UNSCOPED_CAPTURE` was introduced in Catch2 X.Y.Z.
+
Sometimes you just want to log a value of variable, or expression. For
convenience, we provide the `CAPTURE` macro, that can take a variable,
or an expression, and prints out that variable/expression and its value
diff --git a/src/catch2/catch_message.cpp b/src/catch2/catch_message.cpp
index dc7d5678..870651e3 100644
--- a/src/catch2/catch_message.cpp
+++ b/src/catch2/catch_message.cpp
@@ -38,7 +38,9 @@ namespace Catch {
Capturer::Capturer( StringRef macroName,
SourceLineInfo const& lineInfo,
ResultWas::OfType resultType,
- StringRef names ) {
+ StringRef names,
+ bool isScoped):
+ m_isScoped(isScoped) {
auto trimmed = [&] (size_t start, size_t end) {
while (names[start] == ',' || isspace(static_cast<unsigned char>(names[start]))) {
++start;
@@ -99,15 +101,21 @@ namespace Catch {
}
Capturer::~Capturer() {
assert( m_captured == m_messages.size() );
- for (auto const& message : m_messages) {
- IResultCapture::popScopedMessage( message.sequence );
+ if ( m_isScoped ) {
+ for ( auto const& message : m_messages ) {
+ IResultCapture::popScopedMessage( message.sequence );
+ }
}
}
void Capturer::captureValue( size_t index, std::string const& value ) {
assert( index < m_messages.size() );
m_messages[index].message += value;
- IResultCapture::pushScopedMessage( CATCH_MOVE( m_messages[index] ) );
+ if ( m_isScoped ) {
+ IResultCapture::pushScopedMessage( CATCH_MOVE( m_messages[index] ) );
+ } else {
+ IResultCapture::addUnscopedMessage( CATCH_MOVE( m_messages[index] ) );
+ }
m_captured++;
}
diff --git a/src/catch2/catch_message.hpp b/src/catch2/catch_message.hpp
index 44b07476..9e868516 100644
--- a/src/catch2/catch_message.hpp
+++ b/src/catch2/catch_message.hpp
@@ -64,8 +64,9 @@ namespace Catch {
class Capturer {
std::vector<MessageInfo> m_messages;
size_t m_captured = 0;
+ bool m_isScoped = false;
public:
- Capturer( StringRef macroName, SourceLineInfo const& lineInfo, ResultWas::OfType resultType, StringRef names );
+ Capturer( StringRef macroName, SourceLineInfo const& lineInfo, ResultWas::OfType resultType, StringRef names, bool isScoped );
Capturer(Capturer const&) = delete;
Capturer& operator=(Capturer const&) = delete;
@@ -97,11 +98,12 @@ namespace Catch {
} while( false )
///////////////////////////////////////////////////////////////////////////////
-#define INTERNAL_CATCH_CAPTURE( varName, macroName, ... ) \
- Catch::Capturer varName( macroName##_catch_sr, \
- CATCH_INTERNAL_LINEINFO, \
- Catch::ResultWas::Info, \
- #__VA_ARGS__##_catch_sr ); \
+#define INTERNAL_CATCH_CAPTURE( varName, macroName, scopedCapture, ... ) \
+ Catch::Capturer varName( macroName##_catch_sr, \
+ CATCH_INTERNAL_LINEINFO, \
+ Catch::ResultWas::Info, \
+ #__VA_ARGS__##_catch_sr, \
+ scopedCapture ); \
varName.captureValues( 0, __VA_ARGS__ )
///////////////////////////////////////////////////////////////////////////////
@@ -118,28 +120,32 @@ namespace Catch {
#define CATCH_INFO( msg ) INTERNAL_CATCH_INFO( "CATCH_INFO", msg )
#define CATCH_UNSCOPED_INFO( msg ) INTERNAL_CATCH_UNSCOPED_INFO( "CATCH_UNSCOPED_INFO", msg )
#define CATCH_WARN( msg ) INTERNAL_CATCH_MSG( "CATCH_WARN", Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, msg )
- #define CATCH_CAPTURE( ... ) INTERNAL_CATCH_CAPTURE( INTERNAL_CATCH_UNIQUE_NAME(capturer), "CATCH_CAPTURE", __VA_ARGS__ )
+ #define CATCH_CAPTURE( ... ) INTERNAL_CATCH_CAPTURE( INTERNAL_CATCH_UNIQUE_NAME(capturer), "CATCH_CAPTURE", true, __VA_ARGS__ )
+ #define CATCH_UNSCOPED_CAPTURE( ... ) INTERNAL_CATCH_CAPTURE( INTERNAL_CATCH_UNIQUE_NAME(capturer), "CATCH_UNSCOPED_CAPTURE", false, __VA_ARGS__ )
#elif defined(CATCH_CONFIG_PREFIX_MESSAGES) && defined(CATCH_CONFIG_DISABLE)
- #define CATCH_INFO( msg ) (void)(0)
- #define CATCH_UNSCOPED_INFO( msg ) (void)(0)
- #define CATCH_WARN( msg ) (void)(0)
- #define CATCH_CAPTURE( ... ) (void)(0)
+ #define CATCH_INFO( msg ) (void)(0)
+ #define CATCH_UNSCOPED_INFO( msg ) (void)(0)
+ #define CATCH_WARN( msg ) (void)(0)
+ #define CATCH_CAPTURE( ... ) (void)(0)
+ #define CATCH_UNSCOPED_CAPTURE( ... ) (void)(0)
#elif !defined(CATCH_CONFIG_PREFIX_MESSAGES) && !defined(CATCH_CONFIG_DISABLE)
#define INFO( msg ) INTERNAL_CATCH_INFO( "INFO", msg )
#define UNSCOPED_INFO( msg ) INTERNAL_CATCH_UNSCOPED_INFO( "UNSCOPED_INFO", msg )
#define WARN( msg ) INTERNAL_CATCH_MSG( "WARN", Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, msg )
- #define CAPTURE( ... ) INTERNAL_CATCH_CAPTURE( INTERNAL_CATCH_UNIQUE_NAME(capturer), "CAPTURE", __VA_ARGS__ )
+ #define CAPTURE( ... ) INTERNAL_CATCH_CAPTURE( INTERNAL_CATCH_UNIQUE_NAME(capturer), "CAPTURE", true, __VA_ARGS__ )
+ #define UNSCOPED_CAPTURE( ... ) INTERNAL_CATCH_CAPTURE( INTERNAL_CATCH_UNIQUE_NAME(capturer), "UNSCOPED_CAPTURE", false, __VA_ARGS__ )
#elif !defined(CATCH_CONFIG_PREFIX_MESSAGES) && defined(CATCH_CONFIG_DISABLE)
- #define INFO( msg ) (void)(0)
- #define UNSCOPED_INFO( msg ) (void)(0)
- #define WARN( msg ) (void)(0)
- #define CAPTURE( ... ) (void)(0)
+ #define INFO( msg ) (void)(0)
+ #define UNSCOPED_INFO( msg ) (void)(0)
+ #define WARN( msg ) (void)(0)
+ #define CAPTURE( ... ) (void)(0)
+ #define UNSCOPED_CAPTURE( ... ) (void)(0)
#endif // end of user facing macro declarations
diff --git a/src/catch2/interfaces/catch_interfaces_capture.hpp b/src/catch2/interfaces/catch_interfaces_capture.hpp
index 4e27a985..79062cad 100644
--- a/src/catch2/interfaces/catch_interfaces_capture.hpp
+++ b/src/catch2/interfaces/catch_interfaces_capture.hpp
@@ -65,6 +65,7 @@ namespace Catch {
static void pushScopedMessage( MessageInfo&& message );
static void popScopedMessage( unsigned int messageId );
+ static void addUnscopedMessage( MessageInfo&& message );
static void emplaceUnscopedMessage( MessageBuilder&& builder );
virtual void handleFatalErrorCondition( StringRef message ) = 0;
diff --git a/src/catch2/internal/catch_run_context.cpp b/src/catch2/internal/catch_run_context.cpp
index d63f19ac..5e5f95a4 100644
--- a/src/catch2/internal/catch_run_context.cpp
+++ b/src/catch2/internal/catch_run_context.cpp
@@ -211,13 +211,16 @@ namespace Catch {
// we only keep around the raw msg ids.
~MessageHolder() = default;
+ void addUnscopedMessage( MessageInfo&& info ) {
+ repairUnscopedMessageInvariant();
+ unscoped_ids.push_back( info.sequence );
+ messages.push_back( CATCH_MOVE( info ) );
+ }
void addUnscopedMessage(MessageBuilder&& builder) {
- repairUnscopedMessageInvariant();
MessageInfo info( CATCH_MOVE( builder.m_info ) );
info.message = builder.m_stream.str();
- unscoped_ids.push_back( info.sequence );
- messages.push_back( CATCH_MOVE( info ) );
+ addUnscopedMessage( CATCH_MOVE( info ) );
}
void addScopedMessage(MessageInfo&& info) {
@@ -894,6 +897,10 @@ namespace Catch {
Detail::g_messageHolder().addUnscopedMessage( CATCH_MOVE( builder ) );
}
+ void IResultCapture::addUnscopedMessage( MessageInfo&& message ) {
+ Detail::g_messageHolder().addUnscopedMessage( CATCH_MOVE( message ) );
+ }
+
void seedRng(IConfig const& config) {
sharedRng().seed(config.rngSeed());
}
diff --git a/tests/ExtraTests/X01-PrefixedMacros.cpp b/tests/ExtraTests/X01-PrefixedMacros.cpp
index d1c246ec..d2d05528 100644
--- a/tests/ExtraTests/X01-PrefixedMacros.cpp
+++ b/tests/ExtraTests/X01-PrefixedMacros.cpp
@@ -67,6 +67,7 @@ CATCH_TEST_CASE("PrefixedMacros") {
int i = 1;
CATCH_CAPTURE( i );
CATCH_CAPTURE( i, i + 1 );
+ CATCH_UNSCOPED_CAPTURE( i + 2, i + 3 );
CATCH_DYNAMIC_SECTION("Dynamic section: " << i) {
CATCH_FAIL_CHECK( "failure" );
}
diff --git a/tests/ExtraTests/X02-DisabledMacros.cpp b/tests/ExtraTests/X02-DisabledMacros.cpp
index 231adfb0..0c051acc 100644
--- a/tests/ExtraTests/X02-DisabledMacros.cpp
+++ b/tests/ExtraTests/X02-DisabledMacros.cpp
@@ -48,6 +48,7 @@ TEST_CASE( "Disabled Macros" ) {
CAPTURE( 1 );
CAPTURE( 1, "captured" );
+ UNSCOPED_CAPTURE( 3 );
REQUIRE_THAT( 1,
Catch::Matchers::Predicate( []( int ) { return false; } ) );
@@ -68,6 +69,7 @@ TEST_CASE_PERSISTENT_FIXTURE( DisabledFixture, "Disabled Persistent Fixture" ) {
CAPTURE( 1 );
CAPTURE( 1, "captured" );
+ UNSCOPED_CAPTURE( 3 );
REQUIRE_THAT( 1,
Catch::Matchers::Predicate( []( int ) { return false; } ) );
diff --git a/tests/SelfTest/Baselines/automake.sw.approved.txt b/tests/SelfTest/Baselines/automake.sw.approved.txt
index 6b0ac614..05c6384b 100644
--- a/tests/SelfTest/Baselines/automake.sw.approved.txt
+++ b/tests/SelfTest/Baselines/automake.sw.approved.txt
@@ -299,6 +299,7 @@ Message from section two
:test-result: PASS Trim strings
:test-result: PASS Type conversions of RangeEquals and similar
:test-result: FAIL Unexpected exceptions can be translated
+:test-result: FAIL Unscoped capture outlives scope
:test-result: PASS Upcasting special member functions
:test-result: PASS Usage of AllMatch range matcher
:test-result: PASS Usage of AllTrue range matcher
diff --git a/tests/SelfTest/Baselines/automake.sw.multi.approved.txt b/tests/SelfTest/Baselines/automake.sw.multi.approved.txt
index 54d1c58f..75c116d5 100644
--- a/tests/SelfTest/Baselines/automake.sw.multi.approved.txt
+++ b/tests/SelfTest/Baselines/automake.sw.multi.approved.txt
@@ -292,6 +292,7 @@
:test-result: PASS Trim strings
:test-result: PASS Type conversions of RangeEquals and similar
:test-result: FAIL Unexpected exceptions can be translated
+:test-result: FAIL Unscoped capture outlives scope
:test-result: PASS Upcasting special member functions
:test-result: PASS Usage of AllMatch range matcher
:test-result: PASS Usage of AllTrue range matcher
diff --git a/tests/SelfTest/Baselines/compact.sw.approved.txt b/tests/SelfTest/Baselines/compact.sw.approved.txt
index 29a1017c..ea8d519a 100644
--- a/tests/SelfTest/Baselines/compact.sw.approved.txt
+++ b/tests/SelfTest/Baselines/compact.sw.approved.txt
@@ -2205,6 +2205,7 @@ MatchersRanges.tests.cpp:<line number>: passed: a, UnorderedRangeEquals( b ) for
MatchersRanges.tests.cpp:<line number>: passed: vector_a, RangeEquals( array_a_plus_1, close_enough ) for: { 1, 2, 3 } elements are { 2, 3, 4 }
MatchersRanges.tests.cpp:<line number>: passed: vector_a, UnorderedRangeEquals( array_a_plus_1, close_enough ) for: { 1, 2, 3 } unordered elements are { 2, 3, 4 }
Exception.tests.cpp:<line number>: failed: unexpected exception with message: '3.14000000000000012'
+Message.tests.cpp:<line number>: failed: false with 3 messages: 'i := 1' and 'j := 2' and 'i + j := 3'
UniquePtr.tests.cpp:<line number>: passed: bptr->i == 3 for: 3 == 3
UniquePtr.tests.cpp:<line number>: passed: bptr->i == 3 for: 3 == 3
MatchersRanges.tests.cpp:<line number>: passed: data, AllMatch(SizeIs(5)) for: { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } all match has size == 5
@@ -2894,7 +2895,7 @@ InternalBenchmark.tests.cpp:<line number>: passed: med == 18. for: 18.0 == 18.0
InternalBenchmark.tests.cpp:<line number>: passed: q3 == 23. for: 23.0 == 23.0
Misc.tests.cpp:<line number>: passed:
Misc.tests.cpp:<line number>: passed:
-test cases: 436 | 317 passed | 95 failed | 6 skipped | 18 failed as expected
-assertions: 2309 | 2110 passed | 157 failed | 42 failed as expected
+test cases: 437 | 317 passed | 96 failed | 6 skipped | 18 failed as expected
+assertions: 2311 | 2110 passed | 158 failed | 43 failed as expected
diff --git a/tests/SelfTest/Baselines/compact.sw.multi.approved.txt b/tests/SelfTest/Baselines/compact.sw.multi.approved.txt
index 5e9a32c7..dbfab609 100644
--- a/tests/SelfTest/Baselines/compact.sw.multi.approved.txt
+++ b/tests/SelfTest/Baselines/compact.sw.multi.approved.txt
@@ -2198,6 +2198,7 @@ MatchersRanges.tests.cpp:<line number>: passed: a, UnorderedRangeEquals( b ) for
MatchersRanges.tests.cpp:<line number>: passed: vector_a, RangeEquals( array_a_plus_1, close_enough ) for: { 1, 2, 3 } elements are { 2, 3, 4 }
MatchersRanges.tests.cpp:<line number>: passed: vector_a, UnorderedRangeEquals( array_a_plus_1, close_enough ) for: { 1, 2, 3 } unordered elements are { 2, 3, 4 }
Exception.tests.cpp:<line number>: failed: unexpected exception with message: '3.14000000000000012'
+Message.tests.cpp:<line number>: failed: false with 3 messages: 'i := 1' and 'j := 2' and 'i + j := 3'
UniquePtr.tests.cpp:<line number>: passed: bptr->i == 3 for: 3 == 3
UniquePtr.tests.cpp:<line number>: passed: bptr->i == 3 for: 3 == 3
MatchersRanges.tests.cpp:<line number>: passed: data, AllMatch(SizeIs(5)) for: { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } all match has size == 5
@@ -2883,7 +2884,7 @@ InternalBenchmark.tests.cpp:<line number>: passed: med == 18. for: 18.0 == 18.0
InternalBenchmark.tests.cpp:<line number>: passed: q3 == 23. for: 23.0 == 23.0
Misc.tests.cpp:<line number>: passed:
Misc.tests.cpp:<line number>: passed:
-test cases: 436 | 317 passed | 95 failed | 6 skipped | 18 failed as expected
-assertions: 2309 | 2110 passed | 157 failed | 42 failed as expected
+test cases: 437 | 317 passed | 96 failed | 6 skipped | 18 failed as expected
+assertions: 2311 | 2110 passed | 158 failed | 43 failed as expected
diff --git a/tests/SelfTest/Baselines/console.std.approved.txt b/tests/SelfTest/Baselines/console.std.approved.txt
index 8c7f79da..7de7b1f9 100644
--- a/tests/SelfTest/Baselines/console.std.approved.txt
+++ b/tests/SelfTest/Baselines/console.std.approved.txt
@@ -1204,6 +1204,19 @@ due to unexpected exception with message:
3.14000000000000012
-------------------------------------------------------------------------------
+Unscoped capture outlives scope
+-------------------------------------------------------------------------------
+Message.tests.cpp:<line number>
+...............................................................................
+
+Message.tests.cpp:<line number>: FAILED:
+ REQUIRE( false )
+with messages:
+ i := 1
+ j := 2
+ i + j := 3
+
+-------------------------------------------------------------------------------
Vector Approx matcher -- failing
Empty and non empty vectors are not approx equal
-------------------------------------------------------------------------------
@@ -1730,6 +1743,6 @@ due to unexpected exception with message:
Why would you throw a std::string?
===============================================================================
-test cases: 436 | 335 passed | 76 failed | 7 skipped | 18 failed as expected
-assertions: 2288 | 2110 passed | 136 failed | 42 failed as expected
+test cases: 437 | 335 passed | 76 failed | 7 skipped | 19 failed as expected
+assertions: 2289 | 2110 passed | 136 failed | 43 failed as expected
diff --git a/tests/SelfTest/Baselines/console.sw.approved.txt b/tests/SelfTest/Baselines/console.sw.approved.txt
index d6e61ff6..ab18d08c 100644
--- a/tests/SelfTest/Baselines/console.sw.approved.txt
+++ b/tests/SelfTest/Baselines/console.sw.approved.txt
@@ -14325,6 +14325,29 @@ due to unexpected exception with message:
3.14000000000000012
-------------------------------------------------------------------------------
+Unscoped capture outlives scope
+ A
+-------------------------------------------------------------------------------
+Message.tests.cpp:<line number>
+...............................................................................
+
+
+No assertions in section 'A'
+
+-------------------------------------------------------------------------------
+Unscoped capture outlives scope
+-------------------------------------------------------------------------------
+Message.tests.cpp:<line number>
+...............................................................................
+
+Message.tests.cpp:<line number>: FAILED:
+ REQUIRE( false )
+with messages:
+ i := 1
+ j := 2
+ i + j := 3
+
+-------------------------------------------------------------------------------
Upcasting special member functions
Move constructor
-------------------------------------------------------------------------------
@@ -19349,6 +19372,6 @@ Misc.tests.cpp:<line number>
Misc.tests.cpp:<line number>: PASSED:
===============================================================================
-test cases: 436 | 317 passed | 95 failed | 6 skipped | 18 failed as expected
-assertions: 2309 | 2110 passed | 157 failed | 42 failed as expected
+test cases: 437 | 317 passed | 96 failed | 6 skipped | 18 failed as expected
+assertions: 2311 | 2110 passed | 158 failed | 43 failed as expected
diff --git a/tests/SelfTest/Baselines/console.sw.multi.approved.txt b/tests/SelfTest/Baselines/console.sw.multi.approved.txt
index 9bd865da..05d6eb6c 100644
--- a/tests/SelfTest/Baselines/console.sw.multi.approved.txt
+++ b/tests/SelfTest/Baselines/console.sw.multi.approved.txt
@@ -14318,6 +14318,29 @@ due to unexpected exception with message:
3.14000000000000012
-------------------------------------------------------------------------------
+Unscoped capture outlives scope
+ A
+-------------------------------------------------------------------------------
+Message.tests.cpp:<line number>
+...............................................................................
+
+
+No assertions in section 'A'
+
+-------------------------------------------------------------------------------
+Unscoped capture outlives scope
+-------------------------------------------------------------------------------
+Message.tests.cpp:<line number>
+...............................................................................
+
+Message.tests.cpp:<line number>: FAILED:
+ REQUIRE( false )
+with messages:
+ i := 1
+ j := 2
+ i + j := 3
+
+-------------------------------------------------------------------------------
Upcasting special member functions
Move constructor
-------------------------------------------------------------------------------
@@ -19338,6 +19361,6 @@ Misc.tests.cpp:<line number>
Misc.tests.cpp:<line number>: PASSED:
===============================================================================
-test cases: 436 | 317 passed | 95 failed | 6 skipped | 18 failed as expected
-assertions: 2309 | 2110 passed | 157 failed | 42 failed as expected
+test cases: 437 | 317 passed | 96 failed | 6 skipped | 18 failed as expected
+assertions: 2311 | 2110 passed | 158 failed | 43 failed as expected
diff --git a/tests/SelfTest/Baselines/junit.sw.approved.txt b/tests/SelfTest/Baselines/junit.sw.approved.txt
index 24d16a96..10523416 100644
--- a/tests/SelfTest/Baselines/junit.sw.approved.txt
+++ b/tests/SelfTest/Baselines/junit.sw.approved.txt
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuitesloose text artifact
>
- <testsuite name="<exe-name>" errors="17" failures="140" skipped="12" tests="2321" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
+ <testsuite name="<exe-name>" errors="17" failures="141" skipped="12" tests="2323" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<properties>
<property name="random-seed" value="1"/>
<property name="filters" value="&quot;*&quot; ~[!nonportable] ~[!benchmark] ~[approvals]"/>
@@ -1694,6 +1694,18 @@ FAILED:
at Exception.tests.cpp:<line number>
</error>
</testcase>
+ <testcase classname="<exe-name>.global" name="Unscoped capture outlives scope" time="{duration}" status="run">
+ <skipped message="TEST_CASE tagged with !mayfail"/>
+ <failure message="false" type="REQUIRE">
+FAILED:
+ REQUIRE( false )
+i := 1
+j := 2
+i + j := 3
+at Message.tests.cpp:<line number>
+ </failure>
+ </testcase>
+ <testcase classname="<exe-name>.global" name="Unscoped capture outlives scope/A" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Upcasting special member functions" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Upcasting special member functions/Move constructor" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Upcasting special member functions/move assignment" time="{duration}" status="run"/>
diff --git a/tests/SelfTest/Baselines/junit.sw.multi.approved.txt b/tests/SelfTest/Baselines/junit.sw.multi.approved.txt
index 21e6a885..2199b7f7 100644
--- a/tests/SelfTest/Baselines/junit.sw.multi.approved.txt
+++ b/tests/SelfTest/Baselines/junit.sw.multi.approved.txt
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
- <testsuite name="<exe-name>" errors="17" failures="140" skipped="12" tests="2321" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
+ <testsuite name="<exe-name>" errors="17" failures="141" skipped="12" tests="2323" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<properties>
<property name="random-seed" value="1"/>
<property name="filters" value="&quot;*&quot; ~[!nonportable] ~[!benchmark] ~[approvals]"/>
@@ -1693,6 +1693,18 @@ FAILED:
at Exception.tests.cpp:<line number>
</error>
</testcase>
+ <testcase classname="<exe-name>.global" name="Unscoped capture outlives scope" time="{duration}" status="run">
+ <skipped message="TEST_CASE tagged with !mayfail"/>
+ <failure message="false" type="REQUIRE">
+FAILED:
+ REQUIRE( false )
+i := 1
+j := 2
+i + j := 3
+at Message.tests.cpp:<line number>
+ </failure>
+ </testcase>
+ <testcase classname="<exe-name>.global" name="Unscoped capture outlives scope/A" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Upcasting special member functions" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Upcasting special member functions/Move constructor" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Upcasting special member functions/move assignment" time="{duration}" status="run"/>
diff --git a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt
index 184bdf71..27dc2cdd 100644
--- a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt
+++ b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt
@@ -1833,6 +1833,17 @@ at Message.tests.cpp:<line number>
<testCase name="Standard output from all sections is reported/one" duration="{duration}"/>
<testCase name="Standard output from all sections is reported/two" duration="{duration}"/>
<testCase name="The NO_FAIL macro reports a failure but does not fail the test" duration="{duration}"/>
+ <testCase name="Unscoped capture outlives scope" duration="{duration}">
+ <skipped message="REQUIRE(false)">
+FAILED:
+ REQUIRE( false )
+i := 1
+j := 2
+i + j := 3
+at Message.tests.cpp:<line number>
+ </skipped>
+ </testCase>
+ <testCase name="Unscoped capture outlives scope/A" duration="{duration}"/>
<testCase name="just failure" duration="{duration}">
<failure message="FAIL()">
FAILED:
diff --git a/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt
index c7dc1ce0..93e3bcc8 100644
--- a/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt
+++ b/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt
@@ -1832,6 +1832,17 @@ at Message.tests.cpp:<line number>