File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed
main/java/org/assertj/core/data
test/java/org/assertj/core/data Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ public boolean equals(Object object) {
5858
5959 @ Override
6060 public int hashCode () {
61- return Objects .hash (key , value );
61+ return Objects .hashCode (key ) ^ Objects . hashCode ( value );
6262 }
6363
6464 @ Override
Original file line number Diff line number Diff line change 1616import static org .assertj .core .api .BDDAssertions .then ;
1717import static org .assertj .core .data .MapEntry .entry ;
1818
19+ import java .util .Objects ;
20+
1921import org .junit .jupiter .api .Test ;
22+ import org .junit .jupiter .params .ParameterizedTest ;
23+ import org .junit .jupiter .params .provider .CsvSource ;
2024
2125import nl .jqno .equalsverifier .EqualsVerifier ;
2226
2327/**
24- * Tests for {@link MapEntry}.
25- *
2628 * @author Alex Ruiz
2729 */
2830class MapEntry_Test {
@@ -34,6 +36,23 @@ void should_honor_equals_contract() {
3436 .verify ();
3537 }
3638
39+ @ ParameterizedTest
40+ @ CsvSource ({
41+ "name, Yoda" ,
42+ " , Yoda" ,
43+ "name, " ,
44+ " , " ,
45+ })
46+ void should_honor_Entry_hashCode_contract (String key , String value ) {
47+ // GIVEN
48+ MapEntry <String , String > underTest = entry (key , value );
49+ int expected = Objects .hashCode (key ) ^ Objects .hashCode (value );
50+ // WHEN
51+ int result = underTest .hashCode ();
52+ // THEN
53+ then (result ).isEqualTo (expected );
54+ }
55+
3756 @ Test
3857 void setValue_should_fail () {
3958 // GIVEN
You can’t perform that action at this time.
0 commit comments