Code example for CharBuffer

Methods: capacity, clear, compareTo

0
        assertEquals(buf.position(), readonly.position());
        assertEquals(buf.limit(), readonly.limit());
        assertEquals(buf.isDirect(), readonly.isDirect());
        assertEquals(buf.order(), readonly.order());
        assertEquals(buf.capacity(), readonly.capacity());
        assertContentEquals(buf, readonly);
 
        // readonly's position, mark, and limit should be independent to buf 
        readonly.reset();
        assertEquals(readonly.position(), originalPosition);
        readonly.clear();
        assertEquals(buf.position(), buf.limit());
        buf.reset();
        assertEquals(buf.position(), originalPosition);
    } 
 
    @TestTargetNew( 
        level = TestLevel.PARTIAL_COMPLETE, 
        notes = "", 
        method = "compact", 
        args = {} 
    ) 
    @AndroidOnly("fails on RI. See comment below") 
    public void testCompact() { 
        // case: buffer is full 
        buf.clear();
        buf.mark();
        loadTestData1(buf);
        CharBuffer ret = buf.compact();
        assertSame(ret, buf);
        assertEquals(buf.position(), buf.capacity());