Is there any good way to unit test destructors? Like say I have a class like this (contrived) example:
class X
{
private:
    int *x;
public:
    X()
    {
         x = new int;
    }
    ~X()
    {
         delete x;
    }
    int *getX() {return x;}
    const int *getX() const {return x;}
};
Is there any good way to unit test this to make sure x gets deleted without cluttering up my hpp file with #ifdef TESTs or breaking encapsulation? The main problem that I'm seeing is that it's difficult to tell if x really got deleted, especially because the object is out of scope at the time the destructor is called.
 
     
     
     
     
     
     
    