use of java.nio.BufferOverflowException in project robovm by robovm.
the class LongBufferTest method testPutlongArrayintint.
/*
* Class under test for java.nio.LongBuffer put(long[], int, int)
*/
public void testPutlongArrayintint() {
buf.clear();
long[] array = new long[buf.capacity()];
try {
buf.put(new long[buf.capacity() + 1], 0, buf.capacity() + 1);
//$NON-NLS-1$
fail("Should throw Exception");
} catch (BufferOverflowException e) {
// expected
}
assertEquals(buf.position(), 0);
try {
buf.put(array, -1, array.length);
//$NON-NLS-1$
fail("Should throw Exception");
} catch (IndexOutOfBoundsException e) {
// expected
}
try {
buf.put(array, array.length + 1, 0);
//$NON-NLS-1$
fail("Should throw Exception");
} catch (IndexOutOfBoundsException e) {
// expected
}
buf.put(array, array.length, 0);
assertEquals(buf.position(), 0);
try {
buf.put(array, 0, -1);
//$NON-NLS-1$
fail("Should throw Exception");
} catch (IndexOutOfBoundsException e) {
// expected
}
try {
buf.put(array, 2, array.length);
//$NON-NLS-1$
fail("Should throw Exception");
} catch (IndexOutOfBoundsException e) {
// expected
}
try {
buf.put((long[]) null, 0, -1);
//$NON-NLS-1$
fail("Should throw Exception");
} catch (NullPointerException e) {
// expected
}
try {
buf.put(array, 2, array.length);
//$NON-NLS-1$
fail("Should throw Exception");
} catch (IndexOutOfBoundsException e) {
// expected
}
try {
buf.put(array, Integer.MAX_VALUE, 1);
//$NON-NLS-1$
fail("Should throw Exception");
} catch (IndexOutOfBoundsException e) {
// expected
}
try {
buf.put(array, 1, Integer.MAX_VALUE);
//$NON-NLS-1$
fail("Should throw Exception");
} catch (BufferOverflowException expected) {
} catch (IndexOutOfBoundsException expected) {
}
assertEquals(buf.position(), 0);
loadTestData2(array, 0, array.length);
LongBuffer ret = buf.put(array, 0, array.length);
assertEquals(buf.position(), buf.capacity());
assertContentEquals(buf, array, 0, array.length);
assertSame(ret, buf);
}
use of java.nio.BufferOverflowException in project robovm by robovm.
the class ShortBufferTest method testPutshort.
/*
* Class under test for java.nio.ShortBuffer put(short)
*/
public void testPutshort() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
assertEquals(buf.position(), i);
ShortBuffer ret = buf.put((short) i);
assertEquals(buf.get(i), (short) i);
assertSame(ret, buf);
}
try {
buf.put((short) 0);
//$NON-NLS-1$
fail("Should throw Exception");
} catch (BufferOverflowException e) {
// expected
}
}
use of java.nio.BufferOverflowException in project robovm by robovm.
the class ShortBufferTest method testPutShortBuffer.
/*
* Class under test for java.nio.ShortBuffer put(java.nio.ShortBuffer)
*/
public void testPutShortBuffer() {
ShortBuffer other = ShortBuffer.allocate(buf.capacity());
try {
buf.put(buf);
//$NON-NLS-1$
fail("Should throw Exception");
} catch (IllegalArgumentException e) {
// expected
}
try {
buf.put(ShortBuffer.allocate(buf.capacity() + 1));
//$NON-NLS-1$
fail("Should throw Exception");
} catch (BufferOverflowException e) {
// expected
}
try {
buf.flip();
buf.put((ShortBuffer) null);
//$NON-NLS-1$
fail("Should throw Exception");
} catch (NullPointerException e) {
// expected
}
loadTestData2(other);
other.clear();
buf.clear();
ShortBuffer 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 ByteBufferTest method testPutbyteArrayintint.
/*
* Class under test for java.nio.ByteBuffer put(byte[], int, int)
*/
public void testPutbyteArrayintint() {
buf.clear();
byte[] array = new byte[buf.capacity()];
if (buf.isReadOnly()) {
try {
buf.put(array, 0, array.length);
//$NON-NLS-1$
fail("Should throw Exception");
} catch (ReadOnlyBufferException e) {
// expected
}
return;
}
try {
buf.put(new byte[buf.capacity() + 1], 0, buf.capacity() + 1);
//$NON-NLS-1$
fail("Should throw Exception");
} catch (BufferOverflowException e) {
// expected
}
assertEquals(buf.position(), 0);
try {
buf.put(array, -1, array.length);
//$NON-NLS-1$
fail("Should throw Exception");
} catch (IndexOutOfBoundsException e) {
// expected
}
try {
buf.put(array, array.length + 1, 0);
//$NON-NLS-1$
fail("Should throw Exception");
} catch (IndexOutOfBoundsException e) {
// expected
}
buf.put(array, array.length, 0);
assertEquals(buf.position(), 0);
try {
buf.put(array, 0, -1);
//$NON-NLS-1$
fail("Should throw Exception");
} catch (IndexOutOfBoundsException e) {
// expected
}
try {
buf.put(array, 2, array.length);
//$NON-NLS-1$
fail("Should throw Exception");
} catch (IndexOutOfBoundsException e) {
// expected
}
try {
buf.put(array, 2, Integer.MAX_VALUE);
//$NON-NLS-1$
fail("Should throw Exception");
} catch (IndexOutOfBoundsException e) {
// expected
}
try {
buf.put(array, Integer.MAX_VALUE, 1);
//$NON-NLS-1$
fail("Should throw Exception");
} catch (IndexOutOfBoundsException e) {
// expected
}
try {
buf.put((byte[]) null, 2, Integer.MAX_VALUE);
//$NON-NLS-1$
fail("Should throw Exception");
} catch (NullPointerException e) {
// expected
}
assertEquals(buf.position(), 0);
loadTestData2(array, 0, array.length);
ByteBuffer ret = buf.put(array, 0, array.length);
assertEquals(buf.position(), buf.capacity());
assertContentEquals(buf, array, 0, array.length);
assertSame(ret, buf);
}
use of java.nio.BufferOverflowException in project robovm by robovm.
the class CharBufferTest method testPutcharArrayintint.
/*
* Class under test for java.nio.CharBuffer put(char[], int, int)
*/
public void testPutcharArrayintint() {
buf.clear();
char[] array = new char[buf.capacity()];
try {
buf.put((char[]) null, 0, 1);
//$NON-NLS-1$
fail("Should throw NullPointerException");
} catch (NullPointerException e) {
// expected
}
try {
buf.put(new char[buf.capacity() + 1], 0, buf.capacity() + 1);
//$NON-NLS-1$
fail("Should throw Exception");
} catch (BufferOverflowException e) {
// expected
}
assertEquals(buf.position(), 0);
try {
buf.put(array, -1, array.length);
//$NON-NLS-1$
fail("Should throw Exception");
} catch (IndexOutOfBoundsException e) {
// expected
}
try {
buf.put(array, array.length + 1, 0);
//$NON-NLS-1$
fail("Should throw Exception");
} catch (IndexOutOfBoundsException e) {
// expected
}
buf.put(array, array.length, 0);
assertEquals(buf.position(), 0);
try {
buf.put(array, 0, -1);
//$NON-NLS-1$
fail("Should throw Exception");
} catch (IndexOutOfBoundsException e) {
// expected
}
try {
buf.put((char[]) null, 0, -1);
//$NON-NLS-1$
fail("Should throw Exception");
} catch (NullPointerException e) {
// expected
}
try {
buf.put(array, 2, array.length);
//$NON-NLS-1$
fail("Should throw Exception");
} catch (IndexOutOfBoundsException e) {
// expected
}
try {
buf.put(array, Integer.MAX_VALUE, 1);
//$NON-NLS-1$
fail("Should throw Exception");
} catch (IndexOutOfBoundsException e) {
// expected
}
try {
buf.put(array, 1, Integer.MAX_VALUE);
//$NON-NLS-1$
fail("Should throw Exception");
} catch (BufferOverflowException expected) {
} catch (IndexOutOfBoundsException 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);
}
Aggregations