Test construct and destruct counters match expected

This commit is contained in:
Josh Holtrop 2026-02-23 21:58:53 -05:00
parent 71b4bf14a0
commit 3fdb7c9bc6

View File

@ -1,9 +1,10 @@
#include <rcp.h> #include <rcp.h>
#include <cassert>
static int mybase_construct; static int mybase_construct;
static int mybase_destroy; static int mybase_destruct;
static int myderived_construct; static int myderived_construct;
static int myderived_destroy; static int myderived_destruct;
class MyBase : public root class MyBase : public root
{ {
@ -15,7 +16,7 @@ protected:
virtual ~MyBase() virtual ~MyBase()
{ {
mybase_destroy++; mybase_destruct++;
} }
public: public:
@ -32,7 +33,7 @@ protected:
virtual ~MyDerived() virtual ~MyDerived()
{ {
myderived_destroy++; myderived_destruct++;
} }
public: public:
@ -48,5 +49,9 @@ void t1()
int main(int argc, char * argv[]) int main(int argc, char * argv[])
{ {
t1(); t1();
assert(mybase_construct == 2);
assert(mybase_destruct == 2);
assert(myderived_construct == 1);
assert(myderived_destruct == 1);
return 0; return 0;
} }