Fluentassertions: BeApproximately and PositiveInfinity, NegativeInfinity

Created on 18 Mar 2020  路  4Comments  路  Source: fluentassertions/fluentassertions

When comparing the special infinity values (PositiveInfinity / NegativeInfinity) with NumericAssertionExtensions.BeApproximately(). I get an unexpected result. The following test fails:

// Arrange
double value = double.PositiveInfinity;

// Act
Action act = () => value.Should().BeApproximately(double.PositiveInfinity, 0.1);

// Assert
act.Should().NotThrow();

This is the same for float.

However, the inverse behaves as expected, with the following test passing.

// Arrange
double value = double.PositiveInfinity;

// Act
Action act = () => value.Should().NotBeApproximately(double.PositiveInfinity, 0.1);

// Assert
act.Should().Throw();

I could reproduce it as a test on the current version on the development branch. I will create a corresponding pull-request, to fix this.

bug

Most helpful comment

@dennisdoomen and @jnyrup: Thanks for all your help and this great project. Next contribution will be better quality. I already looked at help wanted cases for the next milestone.

All 4 comments

@dennisdoomen This can be closed now?

@FabianNitsche FYI: if you write "this fixes #1270" in a PR on Github, the issue is automatically closed when the PR gets merged.

@dennisdoomen and @jnyrup: Thanks for all your help and this great project. Next contribution will be better quality. I already looked at help wanted cases for the next milestone.

Oh crap. Forgot to update the release notes md.

Was this page helpful?
0 / 5 - 0 ratings