Code example for Field

Methods: equals

0
        level = TestLevel.COMPLETE, 
        notes = "", 
        method = "equals", 
        args = {java.lang.Object.class}
    ) 
    public void test_equalsLjava_lang_Object() { 
        // Test for method boolean 
        // java.lang.reflect.Field.equals(java.lang.Object) 
        TestField x = new TestField();
        Field f = null;
        try { 
            f = x.getClass().getDeclaredField("shortField");
        } catch (Exception e) {
            fail("Exception during getType test : " + e.getMessage());
        } 
        try { 
            assertTrue("Same Field returned false", f.equals(f));
            assertTrue("Inherited Field returned false", f.equals(x.getClass()
                    .getDeclaredField("shortField")));
            assertTrue("Identical Field from different class returned true", !f
                    .equals(A.class.getDeclaredField("shortField")));