-
Notifications
You must be signed in to change notification settings - Fork 10.6k
added general floating point near comparison #2077
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
Conversation
This should fix some issues with MSVC
|
Please also add unit test with clearly reproducible behaviour |
- Fixed order of includes
- Better way to ensure ADL for std::fabs
- Added unit test for EXPECT_NEAR/ASSERT_NEAR for long double and a
"custom real" type
|
I added unit tests which test EXPECT_NEAR/ASSERT_NEAR for long double and a "custom real" type |
Co-Authored-By: helloworld922 <helloworld922@gmail.com>
Implemented suggestions for custom_real class
|
Just to give you an update, during internal testing this change breaks a number of existing tests. it nay be a while before I can get to it |
|
Can we rename the functions and the commit to be more general? Maybe call it "ordered type near comparison". I would like to be able to compare types that define a comparison operator. For example: |
|
Closing , looks abandoned |
|
Your last message to me was to wait on you to fix internal testing, specifically "it may be a while before I can get to it" Has this issue with internal testing been resolved? |
|
Apologies, I did not make it clear. The internal testing with existing millions of tests blocks this change in this form. |
|
What needs to be modified with this commit so this type of change could be pulled? |
|
This is a great question. How can this change be moved forward? It would fix a pretty frustrating oversight in the design of |
|
Any news on this? |
|
Let me suggest a way forward based on my admittedly imperfect information. 🙂 It seems very likely to me that if If I'm right, the blocking tests are the equivalent of "behaviour which depends on a bug". If so, then to fix this situation, we need to remove the dependency on the bug. One way to do this would be for Google to add another macro which preserves the current behaviour---say, Other repositories "in the wild" may also depend on this bug, and this patch would break them. I think this is OK because it would only break them when they consciously choose to upgrade their googletest version. It's very common to need to deal with slight behaviour changes when upgrading to a new version of a dependency. @gennadiycivil (as previous participant in this thread) and @mattcalabrese-google (as assignee of #890): WDYT about this analysis, and the approach I suggest? Have I missed anything important? Let's see if we can figure out a way forward. |
|
Failing that I suggest introducing a new macro such as EXPECT_APPROX or some other name with the more logical behaviour. |
|
I like that solution, especially if @gennadiycivil, @mattcalabrese-google: we now have two viable solutions that can unblock this work.
Are you folks able to weigh in on which of these approaches you would prefer? |
|
Hi! Friendly ping. 🙂 I appreciate that folks are surely busy, but I thought I'd check in to see if we can move the conversation forward.
Thanks! |
|
Hi! Happy 2024. Can @gennadiycivil, @mattcalabrese-google, or anyone else at Google please respond to the discussion starting in this comment? |
|
For folks who have been following the conversation here, where it has mainly been taking place: I decided to put my latest ping on the issue page #890, because an open issue is a better place for conversation than a (temporarily? 🙏) closed PR. 🙂 |
The EXPECT_NEAR and ASSERT_NEAR macros expect double parameters, which potentially means loss of precision or for types with greater accuracy than double, or compile errors for types not implicitly convertible to double (gcc/intel quad precision long double, Boost.MultiPrecision, etc.).
This is essentially the same fix as the patch I submitted in issue #890. I fixed a problem where I called the wrong absolute value funciton (abs vs. fabs).
Side note: I don't know why the original bug report was closed without comment.