title: Unit testing destructors?
body: <p>Is there any good way to unit test destructors?  Like say I have a class like this (contrived) example:</p>
  
  <pre><code>class X
  {
  private:
      int *x;
  
  public:
      X()
      {
           x = new int;
      }
  
      ~X()
      {
           delete x;
      }
  
      int *getX() {return x;}
      const int *getX() const {return x;}
  };
  </code></pre>
  
  <p>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.</p>