Search in sources :

Example 31 with BufferOverflowException

use of java.nio.BufferOverflowException in project robovm by robovm.

the class IntBufferTest method testPutIntBuffer.

/*
     * Class under test for java.nio.IntBuffer put(java.nio.IntBuffer)
     */
public void testPutIntBuffer() {
    IntBuffer other = IntBuffer.allocate(buf.capacity());
    try {
        buf.put(buf);
        //$NON-NLS-1$
        fail("Should throw Exception");
    } catch (IllegalArgumentException e) {
    // expected
    }
    try {
        buf.put(IntBuffer.allocate(buf.capacity() + 1));
        //$NON-NLS-1$
        fail("Should throw Exception");
    } catch (BufferOverflowException e) {
    // expected
    }
    try {
        buf.flip();
        buf.put((IntBuffer) null);
        //$NON-NLS-1$
        fail("Should throw Exception");
    } catch (NullPointerException e) {
    // expected
    }
    loadTestData2(other);
    other.clear();
    buf.clear();
    IntBuffer ret = buf.put(other);
    assertEquals(other.position(), other.capacity());
    assertEquals(buf.position(), buf.capacity());
    assertContentEquals(other, buf);
    assertSame(ret, buf);
}
Also used : IntBuffer(java.nio.IntBuffer) BufferOverflowException(java.nio.BufferOverflowException)

Example 32 with BufferOverflowException

use of java.nio.BufferOverflowException in project robovm by robovm.

the class CharBufferTest method testPutchar.

/*
	 * Class under test for java.nio.CharBuffer put(char)
	 */
public void testPutchar() {
    buf.clear();
    for (int i = 0; i < buf.capacity(); i++) {
        assertEquals(buf.position(), i);
        CharBuffer ret = buf.put((char) i);
        assertEquals(buf.get(i), (char) i);
        assertSame(ret, buf);
    }
    try {
        buf.put((char) 0);
        //$NON-NLS-1$
        fail("Should throw Exception");
    } catch (BufferOverflowException e) {
    // expected
    }
}
Also used : CharBuffer(java.nio.CharBuffer) BufferOverflowException(java.nio.BufferOverflowException)

Example 33 with BufferOverflowException

use of java.nio.BufferOverflowException in project robovm by robovm.

the class CharBufferTest method testPutString.

public void testPutString() {
    String str = " ";
    buf.clear();
    for (int i = 0; i < buf.capacity(); i++) {
        assertEquals(buf.position(), i);
        str = "" + (char) i;
        CharBuffer ret = buf.put(str);
        assertEquals(buf.get(i), (char) i);
        assertSame(ret, buf);
    }
    try {
        buf.put(str);
        //$NON-NLS-1$
        fail("Should throw Exception");
    } catch (BufferOverflowException e) {
    // expected
    }
    try {
        buf.put((String) null);
        //$NON-NLS-1$
        fail("Should throw Exception");
    } catch (NullPointerException e) {
    // expected
    }
}
Also used : CharBuffer(java.nio.CharBuffer) BufferOverflowException(java.nio.BufferOverflowException)

Example 34 with BufferOverflowException

use of java.nio.BufferOverflowException in project robovm by robovm.

the class DoubleBufferTest method testPutdouble.

/*
     * Class under test for java.nio.DoubleBuffer put(double)
     */
public void testPutdouble() {
    buf.clear();
    for (int i = 0; i < buf.capacity(); i++) {
        assertEquals(buf.position(), i);
        DoubleBuffer ret = buf.put((double) i);
        assertEquals(buf.get(i), (double) i, 0.0);
        assertSame(ret, buf);
    }
    try {
        buf.put(0);
        //$NON-NLS-1$
        fail("Should throw Exception");
    } catch (BufferOverflowException e) {
    // expected
    }
}
Also used : DoubleBuffer(java.nio.DoubleBuffer) BufferOverflowException(java.nio.BufferOverflowException)

Example 35 with BufferOverflowException

use of java.nio.BufferOverflowException in project robovm by robovm.

the class DoubleBufferTest method testPutDoubleBuffer.

/*
     * Class under test for java.nio.DoubleBuffer put(java.nio.DoubleBuffer)
     */
public void testPutDoubleBuffer() {
    DoubleBuffer other = DoubleBuffer.allocate(buf.capacity());
    try {
        buf.put(buf);
        //$NON-NLS-1$
        fail("Should throw Exception");
    } catch (IllegalArgumentException e) {
    // expected
    }
    try {
        buf.put(DoubleBuffer.allocate(buf.capacity() + 1));
        //$NON-NLS-1$
        fail("Should throw Exception");
    } catch (BufferOverflowException e) {
    // expected
    }
    loadTestData2(other);
    other.clear();
    buf.clear();
    DoubleBuffer ret = buf.put(other);
    assertEquals(other.position(), other.capacity());
    assertEquals(buf.position(), buf.capacity());
    assertContentEquals(other, buf);
    assertSame(ret, buf);
}
Also used : DoubleBuffer(java.nio.DoubleBuffer) BufferOverflowException(java.nio.BufferOverflowException)

Aggregations

BufferOverflowException (java.nio.BufferOverflowException)78 ByteBuffer (java.nio.ByteBuffer)27 ShortBufferException (javax.crypto.ShortBufferException)10 CharBuffer (java.nio.CharBuffer)9 ShortBuffer (java.nio.ShortBuffer)7 Test (org.junit.Test)7 FloatBuffer (java.nio.FloatBuffer)6 IntBuffer (java.nio.IntBuffer)6 IOException (java.io.IOException)5 BufferUnderflowException (java.nio.BufferUnderflowException)5 ReadOnlyBufferException (java.nio.ReadOnlyBufferException)5 IpPrefix (android.net.IpPrefix)4 Inet6Address (java.net.Inet6Address)4 DoubleBuffer (java.nio.DoubleBuffer)4 LongBuffer (java.nio.LongBuffer)4 MappedByteBuffer (java.nio.MappedByteBuffer)4 Pointer (com.cetsoft.imcache.offheap.bytebuffer.Pointer)2 EOFException (java.io.EOFException)2 CoderResult (java.nio.charset.CoderResult)2 JSONObject (org.json_voltpatches.JSONObject)2