Re: Asserting that a value is within an interval

"Chris Wright" <[email protected]> Sat, 2 Aug 2008 09:26:08 -0400
Newsgroups gmane.comp.windows.dotnet.nunit.user
Message-ID <[email protected]>
2008/8/2 Simone Busoli <[email protected]>:
> Hello, I would like to do something like:
>
> int a = 3;
> int b = 5;
>
> Assert.That(a, Is.InRangeOf(2).From(b));
>
> which means that b - 2 <= a <= b + 2.

Assert.That(a, Is.EqualTo(b).Within(2));

Quite useful when you're using floating point numbers due to rounding error.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/