Code example for Buffer

Methods: capacity, limit, position

0
        assertEquals(buf.position(), oldPosition);
        assertEquals(buf.limit(), oldLimit);
    } 
 
    public static void testCapacity(Buffer buf) {
        assertTrue(0 <= buf.position() && buf.position() <= buf.limit()
                && buf.limit() <= buf.capacity());
    } 
 
    public static void testClear(Buffer buf) {
        // save state 
        int oldPosition = buf.position();
        int oldLimit = buf.limit();
 
        Buffer ret = buf.clear();
        assertSame(ret, buf);
        assertEquals(buf.position(), 0);
        assertEquals(buf.limit(), buf.capacity());
        try { 
            buf.reset();
            fail("Should throw Exception"); //$NON-NLS-1$