haf / expecto

A smooth testing lib for F#. APIs made for humans! Strong testing methodologies for everyone!
Apache License 2.0
663 stars 96 forks source link

Add new more generic version of close in Expect #413

Open rahicks26 opened 3 years ago

rahicks26 commented 3 years ago

Currently, there is easy to check if two floats are close to each other, but it would be nice to add some new methods that extend this method and maybe a few other float specific to work with more types such as decimal and UoMs.

/// Rough v1.  Need to look at the other methods to make it compatible.
let inline close v1 v2 epsilon =
    let diff = (v1 - v2)
    let delta = abs diff
    delta < epsilon
rahicks26 commented 3 years ago

Would love to do a PR for something like this if it would be helpful.

haf commented 3 years ago

@rahicks26 Yes it would be helpful. :)

rahicks26 commented 3 years ago

Awesome I did a bit of a POC Friday. Should have a PR up around the end of this week.