Open
Description
Referring to https://docs.nunit.org/articles/nunit/writing-tests/constraints/RangeConstraint.html, the documentation misses information on whether from...to also allows a negative range, e.g. from 0 to -10. Why can this be important? Sometimes an assertion needs a tolerance, e.g. Is.InRange(data.Length, (data.Length + (int)(Math.Round(data.Length * tolerance))))
where tolerance
can be a positive or negative value. From the documentation it is not clear whether this can possibly work, or wether to
must be a value larger than from
. Only looking at the code (or decompiling) reveals:
if (from.CompareTo(to) > 0)
{
throw new ArgumentException("from must be less than to");
}
(NUnit 2.6.4.14350)
I personally would prefer that InRange
allowed positive and negative ranges.
And in any case, documentation thereof should be improved.
Metadata
Metadata
Assignees
Labels
No labels