use of java.nio.DoubleBuffer 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.DoubleBuffer 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);
}
use of java.nio.DoubleBuffer in project robovm by robovm.
the class DoubleBufferTest method testSlice.
public void testSlice() {
assertTrue(buf.capacity() > 5);
buf.position(1);
buf.limit(buf.capacity() - 1);
DoubleBuffer slice = buf.slice();
assertEquals(buf.isReadOnly(), slice.isReadOnly());
assertEquals(buf.isDirect(), slice.isDirect());
assertEquals(buf.order(), slice.order());
assertEquals(slice.position(), 0);
assertEquals(slice.limit(), buf.remaining());
assertEquals(slice.capacity(), buf.remaining());
try {
slice.reset();
//$NON-NLS-1$
fail("Should throw Exception");
} catch (InvalidMarkException e) {
// expected
}
// FIXME:
if (!slice.isReadOnly()) {
loadTestData1(slice);
assertContentLikeTestData1(buf, 1, 0, slice.capacity());
buf.put(2, 500);
assertEquals(slice.get(1), 500, 0.0);
}
}
use of java.nio.DoubleBuffer in project robovm by robovm.
the class DoubleBufferTest method testPutdoubleArray.
/*
* Class under test for java.nio.DoubleBuffer put(double[])
*/
public void testPutdoubleArray() {
double[] array = new double[1];
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
assertEquals(buf.position(), i);
array[0] = (double) i;
DoubleBuffer ret = buf.put(array);
assertEquals(buf.get(i), (double) i, 0.0);
assertSame(ret, buf);
}
try {
buf.put(array);
//$NON-NLS-1$
fail("Should throw Exception");
} catch (BufferOverflowException e) {
// expected
}
}
use of java.nio.DoubleBuffer in project robovm by robovm.
the class DoubleBufferTest method testGetdoubleArray.
/*
* Class under test for java.nio.DoubleBuffer get(double[])
*/
public void testGetdoubleArray() {
double[] array = new double[1];
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
assertEquals(buf.position(), i);
DoubleBuffer ret = buf.get(array);
assertEquals(array[0], buf.get(i), 0.01);
assertSame(ret, buf);
}
try {
buf.get(array);
//$NON-NLS-1$
fail("Should throw Exception");
} catch (BufferUnderflowException e) {
// expected
}
}
Aggregations