use of java.nio.DoubleBuffer in project es6draft by anba.
the class TypedArrayFunctions method asDoubleBuffer.
private static final DoubleBuffer asDoubleBuffer(ArrayBuffer buffer, int byteOffset, int length) {
ByteBuffer data = byteBuffer(buffer);
int byteLength = Double.BYTES * length;
data.limit(byteOffset + byteLength).position(byteOffset);
DoubleBuffer view = data.asDoubleBuffer();
data.clear();
return view;
}
use of java.nio.DoubleBuffer in project es6draft by anba.
the class TypedArrayFunctions method asDoubleBuffer.
private static final DoubleBuffer asDoubleBuffer(TypedArrayObject typedArray) {
ByteBuffer data = byteBuffer(typedArray);
int byteOffset = byteOffset(typedArray);
int byteLength = byteLength(typedArray);
data.limit(byteOffset + byteLength).position(byteOffset);
DoubleBuffer view = data.asDoubleBuffer();
data.clear();
return view;
}
use of java.nio.DoubleBuffer in project j2objc by google.
the class WrappedDoubleBufferTest method testWrappedDoubleuffer_IllegalArg.
/**
* @tests java.nio.CharBuffer#allocate(char[],int,int)
*/
public void testWrappedDoubleuffer_IllegalArg() {
double[] array = new double[20];
try {
DoubleBuffer.wrap(array, -1, 0);
// $NON-NLS-1$
fail("Should throw Exception");
} catch (IndexOutOfBoundsException e) {
// expected
}
try {
DoubleBuffer.wrap(array, 21, 0);
// $NON-NLS-1$
fail("Should throw Exception");
} catch (IndexOutOfBoundsException e) {
// expected
}
try {
DoubleBuffer.wrap(array, 0, -1);
// $NON-NLS-1$
fail("Should throw Exception");
} catch (IndexOutOfBoundsException e) {
// expected
}
try {
DoubleBuffer.wrap(array, 0, 21);
// $NON-NLS-1$
fail("Should throw Exception");
} catch (IndexOutOfBoundsException e) {
// expected
}
try {
DoubleBuffer.wrap(array, Integer.MAX_VALUE, 1);
// $NON-NLS-1$
fail("Should throw Exception");
} catch (IndexOutOfBoundsException e) {
// expected
}
try {
DoubleBuffer.wrap(array, 1, Integer.MAX_VALUE);
// $NON-NLS-1$
fail("Should throw Exception");
} catch (IndexOutOfBoundsException e) {
// expected
}
try {
DoubleBuffer.wrap((double[]) null, -1, 0);
// $NON-NLS-1$
fail("Should throw NPE");
} catch (NullPointerException e) {
}
DoubleBuffer buf = DoubleBuffer.wrap(array, 2, 16);
assertEquals(buf.position(), 2);
assertEquals(buf.limit(), 18);
assertEquals(buf.capacity(), 20);
}
use of java.nio.DoubleBuffer in project j2objc by google.
the class ReadOnlyDoubleBufferTest method testPutDoubleBuffer.
public void testPutDoubleBuffer() {
DoubleBuffer other = DoubleBuffer.allocate(1);
try {
buf.put(other);
// $NON-NLS-1$
fail("Should throw ReadOnlyBufferException");
} catch (ReadOnlyBufferException e) {
// expected
}
try {
buf.put((DoubleBuffer) null);
// $NON-NLS-1$
fail("Should throw ReadOnlyBufferException");
} catch (ReadOnlyBufferException e) {
// expected
}
try {
buf.put(buf);
// $NON-NLS-1$
fail("Should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// expected
}
}
use of java.nio.DoubleBuffer in project j2objc by google.
the class ReadOnlyDoubleBufferTest method testHashCode.
public void testHashCode() {
DoubleBuffer duplicate = buf.duplicate();
assertEquals(buf.hashCode(), duplicate.hashCode());
}
Aggregations