On Sat, 14 Aug 2010 23:49:18 -0400, Jonathan M Davis <[email protected]> wrote:

and I wanted to test to make sure that func() couldn't be called with any int greater or equal to 8, what would I do? The best that I can think of is to catch
an AssertError and ignore it. e.g.

unittest
{
    try
    {
        func(8);
        assert(0);
    }
    catch(AssertionError ae)
    {}
}

BTW, I just realized, this code doesn't test anything. You want something like this:

unittest
{
   bool caughtAssert = false;
   try
   {
      func(8);
   }
   catch(AssertionError ae)
   {
      caughtAssert = true;
   }
   assert(caughtAssert);
}

-Steve

Reply via email to