Re: Asserting that a value is within an interval
"Chris Wright" <[email protected]> Sat, 2 Aug 2008 09:48:07 -0400
| Newsgroups | gmane.comp.windows.dotnet.nunit.user |
|---|---|
| Message-ID | <[email protected]> |
2008/8/2 Simone Busoli <[email protected]>: > Didn't know that, but it's there for doubles and floats only. What version of nunit are you using? I have the source for 2.4.8, and it seems to support ints explicitly. There are overloads for int, uint, ulong, long, double, and decimal, each of which uses the tolerance, if there is one. And I just tested with 2.4.7, which handled it as expected. > On Sat, Aug 2, 2008 at 3:26 PM, Chris Wright <[email protected]> wrote: >> >> 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=/