Skip to content

Conversation

@jnyrup
Copy link
Member

@jnyrup jnyrup commented Sep 14, 2020

If a negative precision argument is provided, this innocent looking test

double value = 1.5;
value.Should().BeApproximately(value, -1);

fails with the slightly confusing failure message

Expected value to approximate 1.5 +/- -1.0, but 1.5 differed by 0.0.

Instead explicitly guard against negative precision.

Note:
NumericAssertionsExtensions.BeCloseTo for integer values uses a unsigned delta parameter to guard against negative values.

This fixes #1384

If a negative precision argument is provided this innocent looking test
```
double value = 1.5;
value.Should().BeApproximately(value, -1);
```

fails with the slightly confusing failure message
```
Expected value to approximate 1.5 +/- -1.0, but 1.5 differed by 0.0.
```
@jnyrup jnyrup requested a review from dennisdoomen September 14, 2020 20:40
@jnyrup jnyrup merged commit a882cd4 into fluentassertions:develop Sep 15, 2020
@jnyrup jnyrup deleted the negativePrecision branch September 16, 2020 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

How do you use BeApproximately with a value that changes in each iteration of a loop?

2 participants