use of java.nio.BufferOverflowException in project robovm by robovm.
the class ByteBufferTest method testPutbyteArray.
/*
* Class under test for java.nio.ByteBuffer put(byte[])
*/
public void testPutbyteArray() {
byte[] array = new byte[1];
if (buf.isReadOnly()) {
try {
buf.put(array);
//$NON-NLS-1$
fail("Should throw Exception");
} catch (ReadOnlyBufferException e) {
// expected
}
return;
}
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
assertEquals(buf.position(), i);
array[0] = (byte) i;
ByteBuffer ret = buf.put(array);
assertEquals(buf.get(i), (byte) i);
assertSame(ret, buf);
}
try {
buf.put(array);
//$NON-NLS-1$
fail("Should throw Exception");
} catch (BufferOverflowException e) {
// expected
}
try {
buf.put((byte[]) null);
//$NON-NLS-1$
fail("Should throw Exception");
} catch (NullPointerException e) {
// expected
}
}
use of java.nio.BufferOverflowException in project robovm by robovm.
the class LongBufferTest method testPutLongBuffer.
/*
* Class under test for java.nio.LongBuffer put(java.nio.LongBuffer)
*/
public void testPutLongBuffer() {
LongBuffer other = LongBuffer.allocate(buf.capacity());
try {
buf.put(buf);
//$NON-NLS-1$
fail("Should throw Exception");
} catch (IllegalArgumentException e) {
// expected
}
try {
buf.put(LongBuffer.allocate(buf.capacity() + 1));
//$NON-NLS-1$
fail("Should throw Exception");
} catch (BufferOverflowException e) {
// expected
}
try {
buf.flip();
buf.put((LongBuffer) null);
//$NON-NLS-1$
fail("Should throw Exception");
} catch (NullPointerException e) {
// expected
}
loadTestData2(other);
other.clear();
buf.clear();
LongBuffer ret = buf.put(other);
assertEquals(other.position(), other.capacity());
assertEquals(buf.position(), buf.capacity());
assertContentEquals(other, buf);
assertSame(ret, buf);
}
use of java.nio.BufferOverflowException in project robovm by robovm.
the class FloatBufferTest method testPutFloatBuffer.
/*
* Class under test for java.nio.FloatBuffer put(java.nio.FloatBuffer)
*/
public void testPutFloatBuffer() {
FloatBuffer other = FloatBuffer.allocate(buf.capacity());
try {
buf.put(buf);
//$NON-NLS-1$
fail("Should throw Exception");
} catch (IllegalArgumentException e) {
// expected
}
try {
buf.put(FloatBuffer.allocate(buf.capacity() + 1));
//$NON-NLS-1$
fail("Should throw Exception");
} catch (BufferOverflowException e) {
// expected
}
try {
buf.flip();
buf.put((FloatBuffer) null);
//$NON-NLS-1$
fail("Should throw Exception");
} catch (NullPointerException e) {
// expected
}
buf.clear();
loadTestData2(other);
other.clear();
buf.clear();
FloatBuffer ret = buf.put(other);
assertEquals(other.position(), other.capacity());
assertEquals(buf.position(), buf.capacity());
assertContentEquals(other, buf);
assertSame(ret, buf);
}
use of java.nio.BufferOverflowException in project robovm by robovm.
the class IntBufferTest method testPutint.
/*
* Class under test for java.nio.IntBuffer put(int)
*/
public void testPutint() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
assertEquals(buf.position(), i);
IntBuffer ret = buf.put((int) i);
assertEquals(buf.get(i), (int) i);
assertSame(ret, buf);
}
try {
buf.put(0);
//$NON-NLS-1$
fail("Should throw Exception");
} catch (BufferOverflowException e) {
// expected
}
}
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);
}
Aggregations