-
Notifications
You must be signed in to change notification settings - Fork 142
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
Compare collections of floating point values with tolerance #173
Comments
What about using per-unit tolerance with a decorator? |
This is our current work-around but limits the abilities. Imagine a test where you test matrix operations and first have to assert that some intermediate value (e.g. input, transposed matrix, ...) is exactly equal and then test the result of some calculation. Yes those can be put into separate unit tests, but maybe they are so closely related that one does not want to do this. |
@Flamefire there is a WIP branch for this: I'll try to make that for 1.73. |
Merged to master. |
@raffienficiaud I struggle to find documentation on the OP's proposal. What exactly is the solution to this problem that get merged? |
@Char-Aznable sorry for the late answer: now it is possible to combine both If we need more, let me know I'll open a ticket. |
Currently you can use either:
BOOST_TEST_REQUIRE( output == outputDesired, boost::test_tools::per_element() );
BOOST_TEST_REQUIRE( output == outputDesired, boost::test_tools::tolerance( 1e-12f ) );
But you cannot use both.
What is the preferred way to compare collections (e.g. vectors) of floating point values?
This is a common use case for testing numeric algorithms: Check results of optimized version vs. naive implementation.
The text was updated successfully, but these errors were encountered: