mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-03 22:05:39 +02:00
Only track the last line info in RunContext
There were only two places where we used the full `AssertionInfo` instance in `m_lastAssertionInfo`: 1) when reporting unexpected exception from running a test case 2) when reporting fatal error because in those two places we do not have access to a real instance of `AssertionInfo`, but we still need to send one to the reporters. As a bonus, in both of these places we were already constructing a fake-ish assertion info, by using the last encountered source location, but dummying out the other information. Instead, we only keep track of the last encountered source location, and construct the dummy `AssertionInfo` on-demand. This finishes the set of refactoring around `m_lastAssertionInfo` in `RunContext` and improves the performance of running assertions by ~5% in both Debug and Release mode. -------------- Note that this change also causes small difference in output. It could be avoided by having an invalidation flag and tracking where the information would be invalidated before, but the difference includes more precise line location for unexpected errors (both exceptions and fatals), so I prefer the new output.
This commit is contained in:
@@ -84,8 +84,8 @@ Matchers.tests.cpp:<line number>: passed: smallest_non_zero, WithinULP( -smalles
|
||||
Matchers.tests.cpp:<line number>: passed: smallest_non_zero, !WithinULP( -smallest_non_zero, 1 ) for: 0.0 not is within 1 ULPs of -4.9406564584124654e-324 ([-9.8813129168249309e-324, -0.0000000000000000e+00])
|
||||
Matchers.tests.cpp:<line number>: passed: smallest_non_zero, WithinULP( -smallest_non_zero, 2 ) for: 0.0f is within 2 ULPs of -1.40129846e-45f ([-4.20389539e-45, 1.40129846e-45])
|
||||
Matchers.tests.cpp:<line number>: passed: smallest_non_zero, !WithinULP( -smallest_non_zero, 1 ) for: 0.0f not is within 1 ULPs of -1.40129846e-45f ([-2.80259693e-45, -0.00000000e+00])
|
||||
Generators.tests.cpp:<line number>: failed: unexpected exception with message: 'failure to init'
|
||||
Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'answer := 42' with 1 message: 'expected exception'
|
||||
Generators.tests.cpp:<line number>: failed: unexpected exception with message: 'failure to init'; expression was: {Unknown expression after the reported line}
|
||||
Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'answer := 42'; expression was: {Unknown expression after the reported line} with 1 message: 'expected exception'
|
||||
Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'answer := 42'; expression was: thisThrows() with 1 message: 'expected exception'
|
||||
Exception.tests.cpp:<line number>: passed: thisThrows() with 1 message: 'answer := 42'
|
||||
Compilation.tests.cpp:<line number>: passed: 42 == f for: 42 == {?}
|
||||
@@ -2392,7 +2392,7 @@ Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'u
|
||||
Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'expected exception'; expression was: thisThrows() == 0
|
||||
Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'expected exception'; expression was: thisThrows() == 0
|
||||
Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'expected exception'; expression was: thisThrows() == 0
|
||||
Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'unexpected exception'
|
||||
Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'unexpected exception'; expression was: {Unknown expression after the reported line}
|
||||
Tricky.tests.cpp:<line number>: passed:
|
||||
Tricky.tests.cpp:<line number>: passed:
|
||||
Tricky.tests.cpp:<line number>: passed:
|
||||
|
Reference in New Issue
Block a user