Documentation of the InRange constraint does not mention whether from...to also allows negative ranges, e.g. from 0 to -10
Nobody has claimed this yet.
- Dominant language
- Dockerfile
- Stars
- 600
- Forks
- 158
- Avg merge
- 16h 8m
- Merged PRs (30d)
- 21
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read the RangeConstraint documentation at the linked RangeConstraint.html page and compare it with the shown InRange behavior that rejects values when from is greater than to. Clarify whether negative ranges are supported and document the expected ordering, including the tolerance example; done means the page answers this unambiguously.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100