Code example for FieldPosition

Methods: hashCode, setBeginIndex, setEndIndex

0
public class OldFieldPositionTest extends junit.framework.TestCase { 
 
    public void test_hashCode() { 
        // Test for method int java.text.FieldPosition.hashCode() 
        FieldPosition fpos1 = new FieldPosition(1); 
        FieldPosition fpos2 = new FieldPosition(1); 
        assertTrue("test 1: hash codes are not equal for equal objects.", 
                fpos1.hashCode() == fpos2.hashCode()); 
        fpos1.setBeginIndex(5); 
        fpos1.setEndIndex(110); 
        assertTrue("test 2: hash codes are equal for non equal objects.", 
                fpos1.hashCode() != fpos2.hashCode()); 
        fpos2.setBeginIndex(5); 
        fpos2.setEndIndex(110); 
        assertTrue("test 3: hash codes are not equal for equal objects.", 
                fpos1.hashCode() == fpos2.hashCode()); 
 
        FieldPosition fpos3 = new FieldPosition( 
                DateFormat.Field.DAY_OF_WEEK_IN_MONTH); 
 
        assertTrue("test 4: hash codes are equal for non equal objects.", 
                fpos2.hashCode() != fpos3.hashCode()); 
    } 
 
    public void test_setBeginIndexI() { 
        // Test for method void java.text.FieldPosition.setBeginIndex(int) 
        FieldPosition fpos = new FieldPosition(1);