Made hashCode() implement satisfy the Object.hashCode() contract, i.e., a.equals(b) implies a.hashCode() == b.hashCode()

Former-commit-id: 9f347a57b740b572d2d6a9a9e523de44e384773e
This commit is contained in:
Dale Visser
2015-06-24 14:41:20 -04:00
parent d76799cfd0
commit e8353089f3
3 changed files with 19 additions and 5 deletions

View File

@@ -19,6 +19,7 @@ package org.owasp.dependencycheck.dependency;
import org.junit.Test;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
/**
*
@@ -53,6 +54,14 @@ public class EvidenceTest {
assertTrue(instance.equals(that8));
}
@Test
public void testHashcodeContract() throws Exception {
final Evidence titleCase = new Evidence("Manifest", "Implementation-Title", "Spring Framework", Confidence.HIGH);
final Evidence lowerCase = new Evidence("manifest", "implementation-title", "spring framework", Confidence.HIGH);
assertThat(titleCase, is(equalTo(lowerCase)));
assertThat(titleCase.hashCode(), is(equalTo(lowerCase.hashCode())));
}
/**
* Test of compareTo method, of class Evidence.
*/