Skip to content
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

equals() and hashCode() contract testing matcher #79

Open
lemonboston opened this issue Nov 9, 2017 · 0 comments
Open

equals() and hashCode() contract testing matcher #79

lemonboston opened this issue Nov 9, 2017 · 0 comments
Labels

Comments

@lemonboston
Copy link

A Matcher that test equals() in both directions and also compares hashCode() could come useful when testing equals() and hashCode() implementations.
In fact, most rules from the contract, except the transitiveness could be checked in the the Matcher:

It is reflexive: for any non-null reference value x, x.equals(x) should return true.
It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
For any non-null reference value x, x.equals(null) should return false.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant