Code example for CharBuffer

Methods: length, subSequence, toString

0
            buf.put(array, 2, array.length);
            fail("Should throw Exception"); //$NON-NLS-1$ 
        } catch (IndexOutOfBoundsException e) {
            // expected 
        } 
        try { 
            buf.put(array, Integer.MAX_VALUE, 1);
            fail("Should throw Exception"); //$NON-NLS-1$ 
        } catch (IndexOutOfBoundsException e) {
            // expected 
        } 
        try { 
            buf.put(array, 1, Integer.MAX_VALUE);
            fail("Should throw Exception"); //$NON-NLS-1$ 
        } catch (IndexOutOfBoundsException e) {
            // expected 
        } 
        assertEquals(buf.position(), 0);
 
        loadTestData2(array, 0, array.length);
        CharBuffer ret = buf.put(array, 0, array.length);
        assertEquals(buf.position(), buf.capacity());
        assertContentEquals(buf, array, 0, array.length);
        assertSame(ret, buf);
    } 
 
    /* 
     * Class under test for java.nio.CharBuffer put(java.nio.CharBuffer) 
     */ 
    @TestTargetNew( 
        level = TestLevel.PARTIAL_COMPLETE, 
        notes = "Doesn't verify ReadOnlyBufferException.", 
        method = "put", 
        args = {java.nio.CharBuffer.class}
    ) 
    public void testPutCharBuffer() { 
        CharBuffer other = CharBuffer.allocate(buf.capacity());
 
        try { 
            buf.put((CharBuffer) null);
            fail("Should throw Exception"); //$NON-NLS-1$