diff options
Diffstat (limited to 'luni/src/test/java/libcore/java/lang/reflect/ConstructorTest.java')
-rw-r--r-- | luni/src/test/java/libcore/java/lang/reflect/ConstructorTest.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/luni/src/test/java/libcore/java/lang/reflect/ConstructorTest.java b/luni/src/test/java/libcore/java/lang/reflect/ConstructorTest.java index ed98794..51ddfc0 100644 --- a/luni/src/test/java/libcore/java/lang/reflect/ConstructorTest.java +++ b/luni/src/test/java/libcore/java/lang/reflect/ConstructorTest.java @@ -72,6 +72,24 @@ public final class ConstructorTest extends TestCase { assertEquals(2, constructor.getParameterTypes().length); } + public void testEqualConstructorEqualsAndHashCode() throws Exception { + Constructor<?> c1 = ConstructorTestHelper.class.getConstructor(); + Constructor<?> c2 = ConstructorTestHelper.class.getConstructor(); + assertEquals(c1, c2); + assertEquals(c1.hashCode(), c2.hashCode()); + } + + public void testHashCodeSpec() throws Exception { + Constructor<?> c1 = ConstructorTestHelper.class.getConstructor(); + assertEquals(ConstructorTestHelper.class.getName().hashCode(), c1.hashCode()); + } + + public void testDifferentConstructorEqualsAndHashCode() throws Exception { + Constructor<?> c1 = ConstructorTestHelper.class.getConstructor(); + Constructor<?> c2 = ConstructorTestHelper.class.getConstructor(Object.class); + assertFalse(c1.equals(c2)); + } + static class ConstructorTestHelper { public ConstructorTestHelper() throws IndexOutOfBoundsException { } public ConstructorTestHelper(Object o) { } |