Re: [Boost-users] boost test with assert()
Hello, Any ideas re this issue? Can the assert from <cassert> be caught somehow? Regards,
AMDG Hicham Mouline wrote:
Hello, Any ideas re this issue? Can the assert from <cassert> be caught somehow?
The easiest way to test for an assert is to compile the test as a separate executable and make sure that it aborts. In Christ, Steven Watanabe
Is it not possible to test that it aborts, and then control that and continue running the test suite? -----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Steven Watanabe Sent: 19 November 2008 19:15 To: boost-users@lists.boost.org Subject: Re: [Boost-users] boost test with assert() AMDG Hicham Mouline wrote:
Hello, Any ideas re this issue? Can the assert from <cassert> be caught somehow?
The easiest way to test for an assert is to compile the test as a separate executable and make sure that it aborts. In Christ, Steven Watanabe
AMDG Hicham Mouline wrote:
Is it not possible to test that it aborts, and then control that and continue running the test suite?
Even if you ignore the signal, you couldn't rely on the program being in a consistent state. In Christ, Steven Watanabe
Then it looks like I shouldn't catch the assert. Let me present the situation clearer, and see if I can change the underlying assert(). SimulationId simId = AddSimulation(...) SimulationId is an object designed to "enforce", in very simple usages, that whenever in a scope AddSimulation() is called, a RemoveSimulation(simId) is also called. RemoveSimulation clears a flag on simId, and simId destructor asserts that the flag is cleared And so the test looks like this: void SimulationIdTest::TestDestructorAfterAddRemoveSimulation() { ... SimulationId simId = AddSimulation(...); // I want to test here that the destructor asserts(false) } But this test is within a large test suite, and the asserts(false) should be caught Possibly, there is a nicer/cleaner way to test this? Regards, -----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Gennadiy Rozental Sent: 21 November 2008 19:23 To: boost-users@lists.boost.org Subject: Re: [Boost-users] boost test with assert() Hicham Mouline wrote:
Is it not possible to test that it aborts, and then control that and continue running the test suite? There is no safe way to continue after SIGABORT. Gennadiy
participants (3)
-
Gennadiy Rozental
-
Hicham Mouline
-
Steven Watanabe