Feature request: Compare floats and have NaN be true
Description
When I take
CHECK(floating_value1 == floating_value2);
it would be nice to have a way to say "have the check pass if the values are equal or the floats are both NaN".
If you're using C++11 or higher, you can use std::isnan() defined in the standard cmath header, like so:
CHECK((v1 == v2) || (std::isnan(v1) && std::isnan(v2));
I would do as suggested above.
You can also implement a custom wrapper type around float that have the desired non-standard behavior for equals.
BUT, I am very curious why one would even do this to begin with. Having NaN == NaN means that two completely different computations will compare equal. This implies that whenever you compare the result from two computations that fail they will pass your tests... this is usually not what you want.
Closing due to existing workaround.