truth
truth copied to clipboard
Test IterableSubject methods on objects that don't implement hashCode()
Such objects are at least a little evil, but they exist in one or two Google-internal projects. If we currently support this, then we should continue to do so, or at least we should have a test that lets us know that we're breaking it so that we don't do so by mistake.
By "don't implement hashCode()
", I was thinking more of classes that implement it by throwing UnsupportedOperationException
. But I just realized that the particular case I was worse, overriding equals()
but not hashCode()
. But I suppose that a test for the UnsupportedOperationException
will test that, too, for better or for worse.
We just got a report internally that failing tests still call hashCode
here:
https://github.com/google/truth/blob/f149531ce3b6e69f68344ac016b4980f9a10744c/core/src/main/java/com/google/common/truth/SubjectUtils.java#L267
I wonder if we could get away with using an ArrayListMultimap
(which I don't think would use hashCode
) instead of a HashMultimap
?
[Update: I did that.]