-
Notifications
You must be signed in to change notification settings - Fork 50
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
Allow comparing zero for DurationWithThreshold #240
Comments
Thank you for raising this issue!
The way this is expected to be used is:
If it returned Does that seems reasonable to you? Do you have a use case that doesn't work? At the very least I think this detail should be included in the godoc for this function. So I'll leave this issue open to track adding to the godoc comment. |
Thank you for the response and consideration about the docs! I'm wondering about the following [empty] test case.
We need to check if both of the values are 0 before passing to gocmp to avoid the zero comparison, but it's a little bit weird to me. |
That is an interesting example. In this example you wouldn't ever need to use Generally Can you help me understand the real world use case? Are you testing code that may or may not run, so the duration is either One option for handling this would be to add another field to the test case struct:; struct {
lhs *ObjectWithDuration
rhs *ObjectWithDuration
cmpOpts []cmp.Option
} Then you could use the |
I found
DurationWithThreshold
returns false if both of the values are zero.https://github.com/gotestyourself/gotest.tools/pull/62/files#diff-d952cf5be65334da619358823c8ff4669961b0d9a30e85d542caad125beac4c6R20
I guess if both of them are zero, we should return true to compare all test cases in the consistent way.
What do you think?
The text was updated successfully, but these errors were encountered: