Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace assert! macros with macros from approx crate #278

Closed
4 tasks done
stefan-k opened this issue Dec 16, 2022 · 2 comments · Fixed by #404
Closed
4 tasks done

Replace assert! macros with macros from approx crate #278

stefan-k opened this issue Dec 16, 2022 · 2 comments · Fixed by #404
Labels
good first issue Good for newcomers

Comments

@stefan-k
Copy link
Member

stefan-k commented Dec 16, 2022

Currently most assertions in the argmin-math tests use the assert! macro, which is somewhat inconvenient for comparing floats. It would be great if those were replaced with the assert macros of the approx crate.

Status

@rpopplewell
Copy link
Contributor

So for the sake of clarity we're looking for this sort of change for all tests hit by cargo test -p argmin-math right?

// Old
// assert!(((a as $t - res.re) as f64).abs() < std::f64::EPSILON);
// assert!(((-b as $t - res.im) as f64).abs() < std::f64::EPSILON);

// New
assert_relative_eq!(a as f64, res.re as f64, epsilon = std::f64::EPSILON);
assert_relative_eq!(-b as f64, res.im as f64, epsilon = std::f64::EPSILON);

@stefan-k
Copy link
Member Author

Yes, this is correct! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants