Closed souhailelk closed 2 years ago
I like the idea and would most definitely welcome a PR.
Thank you, I'll prepare a P.R.
Hello,
When will you generate a new package version with this feature?
I just did. See 6.1.0.
I just did. See 6.1.0.
Thank you.
We would like to add a new feature while comparing two json objects containing floating numbers as values. We would like to compare the floating numbers with some margin of error.
Let’s take an example:
jsonA
andjsonB
two json objects that contain as values floating numbers with 9 decimal values.Thus, this unit test fails because
json1
andjsonB
are differents at the ninth decimal value. We would like to be able to considerjsonA
andJsonB
equal if their floating numbers values are equal at the eighth decimal value.So, we want to have a feature that allows us to control the approximate equality of floating numbers. Like for instance something like this for absolute tolerance:
jsonA.Should().BeEquivalentTo(jsonB, options => options.Using<double>(d => d.Subject.Should().BeApproximately(d.Expectation, 1e-8, false)).WhenTypeIs<double>());
And for relative tolerance:
jsonA.Should().BeEquivalentTo(jsonB, options => options.Using<double>(d => d.Subject.Should().BeApproximately(d.Expectation, 1e-8, true)).WhenTypeIs<double>());
note : We will be happy to contribute adding this feature by a pull request 😀.