Example #1
0
int main ()
{
  try
  {
    // DefaultImpl
    //
    {
      Impl* a (new Impl);

      postcondition (a->refcount_value () == 1);

      a->remove_ref ();
    }

    // ~DefaultImpl
    //
    {
      Impl* a (new Impl);
      a->remove_ref ();
    }

    // add_ref
    //
    {
      Impl* a (new Impl);

      a->add_ref ();

      postcondition (a->refcount_value () == 2);

      a->remove_ref ();
      a->remove_ref ();
    }


    // remove_ref
    //
    {
      bool destroyed (false);
      Impl* a (new Impl (destroyed));

      a->add_ref ();
      a->remove_ref ();

      postcondition (destroyed == false && a->refcount_value () == 1);

      a->remove_ref ();

      postcondition (destroyed == true);
    }


    // refcount_value
    //
    {
      Impl* a (new Impl);

      postcondition (a->refcount_value () == 1);
    }

    // lock_i
    //
    {
      Impl* a (new Impl);
      a->lock ();
    }
  }
  catch (...)
  {
    return -1;
  }
}