Re: [Boost-users] [BULK] Re: [Test] redirecting unit test report
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Gennadiy Rozental Sent: Monday, August 22, 2005 10:26 PM To: boost-users@lists.boost.org Subject: [BULK] Re: [Boost-users] [Test] redirecting unit test report Importance: Low
#include <iostream>
class global_fixure { public: global_fixure() { pointer() = this; } virtual void setup() = 0; virtual void teardown() = 0;
static global_fixure*& pointer() { static global_fixure* p = 0; return p; }
protected: ~global_fixure() {} };
Why isnt the destructor virtual? Is it because you will never have an instance of this class? What happens if delete a_global_fixture; is called? [snipped some stuff] All this could be avoided if you go the route of BOOST_ASSERT in that you can define hooks via some free standing functions.
class global_fixure { public: global_fixure() { pointer() = this; } virtual void setup() = 0; virtual void teardown() = 0;
static global_fixure*& pointer() { static global_fixure* p = 0; return p; }
protected: ~global_fixure() {} };
Why isnt the destructor virtual? Is it because you will never have an instance of this class?
Because instances of global_fixure aren't supposed to be destructed through abstract pointer. Which is reinforced by protected destructor.
What happens if delete a_global_fixture; is called?
Nothing. Or rather it wont compile.
[snipped some stuff]
All this could be avoided if you go the route of BOOST_ASSERT in that you can define hooks via some free standing functions.
What could be avoided and how an alternative would look like? Gennadiy
participants (2)
-
Gennadiy Rozental
-
Sohail Somani