Is there a standard and/or acceptable way to make sure that pre-conditions,
post-conditions, or invariants _fail_ when running unit tests? That is, lets
say
I had a function like this
void func(int x)
in
{
assert(x < 8);
}
body
{
//...
}
and I wanted to test to make sure that func() cou
Jonathan M Davis wrote:
> Is there a standard and/or acceptable way to make sure that pre-conditions,
> post-conditions, or invariants _fail_ when running unit tests? That is, lets
> say I had a function like this
>
> void func(int x)
> in
> {
> assert(x < 8);
> }
> body
> {
> //...
> }
>
On Sat, 14 Aug 2010 23:49:18 -0400, Jonathan M Davis
wrote:
Is there a standard and/or acceptable way to make sure that
pre-conditions,
post-conditions, or invariants _fail_ when running unit tests? That is,
lets say
I had a function like this
void func(int x)
in
{
assert(x < 8);
}
b
On Monday, August 16, 2010 05:43:08 Steven Schveighoffer wrote:
> On Sat, 14 Aug 2010 23:49:18 -0400, Jonathan M Davis
>
> wrote:
> > Is there a standard and/or acceptable way to make sure that
> > pre-conditions,
> > post-conditions, or invariants _fail_ when running unit tests? That is,
> > let
On Mon, 16 Aug 2010 12:57:22 -0400, Jonathan M Davis
wrote:
Ideally, unit tests and contracts would be simple. However, I do believe
that
there is some value in verifying that you wrote you contracts correctly.
Ideally, you could use a wrapper function/template to call the function
to
ver
On Sat, 14 Aug 2010 23:49:18 -0400, Jonathan M Davis
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
{
On Monday, August 16, 2010 14:36:13 Steven Schveighoffer wrote:
> On Sat, 14 Aug 2010 23:49:18 -0400, Jonathan M Davis
>
> 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
> > t
Steven Schveighoffer wrote:
> On Mon, 16 Aug 2010 12:57:22 -0400, Jonathan M Davis
> wrote:
>> Of greater value is testing that normal exceptions are thrown when
>> they're
>> supposed to - especially for bad input. Testing that is essentially
>> the same as
>> testing for AssertErrors except th
On Monday, August 16, 2010 14:46:47 Ali Çehreli wrote:
> I've used the same. :) We should have something like ensure_throws:
>
>ensure_throws!SpecificException(functionThatShouldThrow(badInput));
>
> Perhaps some of the existing unit test libraries already have that.
http://d.puremagic.com/i