Assert Info reset need to also reset result disposition to normal to handle uncaught exception correctly (#2723)

* AssertionEnd does not reset the assertion info yet. That is done after populateReaction. And reset assertion info would also reset the result disposition to normal, so that any uncaught exception would be reported as failure

* Approving test output changes due to added unit tests

* Unit tests to throw std::runtime_error instead of std::exception

* Add a unit test to test incomplete assertion handler

---------

Co-authored-by: Ross <ross.tang@gfo-x.com>
This commit is contained in:
rosstang
2023-08-08 04:07:31 +08:00
committed by GitHub
parent b593be2116
commit cd60a0301c
21 changed files with 445 additions and 20 deletions

View File

@@ -7143,6 +7143,17 @@ with messages:
current counter 10
i := 10
-------------------------------------------------------------------------------
Incomplete AssertionHandler
-------------------------------------------------------------------------------
AssertionHandler.tests.cpp:<line number>
...............................................................................
AssertionHandler.tests.cpp:<line number>: FAILED:
REQUIRE( Dummy )
due to unexpected exception with message:
Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE
-------------------------------------------------------------------------------
Inequality checks that should fail
-------------------------------------------------------------------------------
@@ -12522,6 +12533,34 @@ Misc.tests.cpp:<line number>: FAILED - but was ok:
Misc.tests.cpp:<line number>: FAILED:
-------------------------------------------------------------------------------
Testing checked-if 4
-------------------------------------------------------------------------------
Misc.tests.cpp:<line number>
...............................................................................
Misc.tests.cpp:<line number>: PASSED:
CHECKED_ELSE( true )
Misc.tests.cpp:<line number>: FAILED:
{Unknown expression after the reported line}
due to unexpected exception with message:
Uncaught exception should fail!
-------------------------------------------------------------------------------
Testing checked-if 5
-------------------------------------------------------------------------------
Misc.tests.cpp:<line number>
...............................................................................
Misc.tests.cpp:<line number>: FAILED - but was ok:
CHECKED_ELSE( false )
Misc.tests.cpp:<line number>: FAILED:
{Unknown expression after the reported line}
due to unexpected exception with message:
Uncaught exception should fail!
-------------------------------------------------------------------------------
The NO_FAIL macro reports a failure but does not fail the test
-------------------------------------------------------------------------------
@@ -18232,6 +18271,6 @@ Misc.tests.cpp:<line number>
Misc.tests.cpp:<line number>: PASSED:
===============================================================================
test cases: 409 | 308 passed | 84 failed | 6 skipped | 11 failed as expected
assertions: 2225 | 2048 passed | 145 failed | 32 failed as expected
test cases: 412 | 308 passed | 84 failed | 6 skipped | 14 failed as expected
assertions: 2229 | 2049 passed | 145 failed | 35 failed as expected