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);
}
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
}
}
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
}
}
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
}
}
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);
}
Aggregations