-
Notifications
You must be signed in to change notification settings - Fork 75
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
MapFactory vs single-value enums #166
Comments
Seem a fix a-la #157 should do :) |
Thanks for reporting this! I'll take a look and try to fix it. I agree with @Stephan202 that the approach in #157 is likely the way to go. I'll fix it for List too, while I'm at it :). Just out of curiosity: what's your use case for having a map with only one key-value pair? Seems like a simple variable would do :). (I'm glad you enjoyed my blog post about the enums!) |
I just joined this project, and found out some people were using a hashCode() and equals() verification framework developed in-house, whereas others were using jqno.EqualsVerifier. Upon comparing code, I thought EqualsVerifier covered more stuff, so I attempted to change all verification to use this instead. That's how I found this in issue, with one of the classes that was being tested by the other framework. As for why it looks like this, I'm half-guessing, but it looks like this enum is something that could be extended with more values in the future. |
Thanks for the context :). |
What steps will reproduce the problem?
See code.
What is the code that triggers this problem?
What error message or stack trace does EqualsVerifier give?
java.lang.AssertionError: Significant fields: equals does not use myMap, or it is stateless.
For more information, go to: http://www.jqno.nl/equalsverifier/errormessages
at nl.jqno.equalsverifier.EqualsVerifier.handleError(EqualsVerifier.java:355)
at nl.jqno.equalsverifier.EqualsVerifier.verify(EqualsVerifier.java:341)
What did you expect?
I expected the test to pass, since myMap is part of equals() -- equals() and hashCode() were auto-generated in Eclipse.
Which version of EqualsVerifier are you using?
2.2
Please provide any additional information below.
It seems the problem lies in MapFactory class, when it creates the red and black Maps. Since it only uses black objects as values, it relies on red and black keys being different. But there is only one value in the enum, and therefore the red and black keys become the same object as well, giving 2 identical Maps.
(I haven't attempted to hack the enum to give it an additional value, though that would surely solve my problem... ;) Thank you for that interesting read.)
The text was updated successfully, but these errors were encountered: