Code example for ParsePosition

Methods: hashCode, setIndex

0
 
    ParsePosition pp = new ParsePosition(Integer.MAX_VALUE);
 
    public void test_hashCode() { 
        // Test for method int java.text.ParsePosition.hashCode() 
        ParsePosition pp1 = new ParsePosition(0);
        ParsePosition pp2 = new ParsePosition(0);
        assertTrue("hashCode returns non equal hash codes for equal objects.",
                pp1.hashCode() == pp2.hashCode());
        pp1.setIndex(Integer.MAX_VALUE);
        assertTrue("hashCode returns equal hash codes for non equal objects.",
                pp1.hashCode() != pp2.hashCode());
    } 
 
    public void test_getErrorIndex() { 
        // Test for method int java.text.ParsePosition.getErrorIndex() 
        pp.setErrorIndex(56);
        assertEquals("getErrorIndex failed.", 56, pp.getErrorIndex());
        pp.setErrorIndex(Integer.MAX_VALUE);
        assertEquals("getErrorIndex failed.", Integer.MAX_VALUE,
                pp.getErrorIndex());