Search in sources :

Example 96 with FloatBuffer

use of java.nio.FloatBuffer in project robovm by robovm.

the class FloatBufferTest method testDuplicate.

public void testDuplicate() {
    buf.clear();
    buf.mark();
    buf.position(buf.limit());
    // duplicate's contents should be the same as buf
    FloatBuffer duplicate = buf.duplicate();
    assertNotSame(buf, duplicate);
    assertEquals(buf.position(), duplicate.position());
    assertEquals(buf.limit(), duplicate.limit());
    assertEquals(buf.isReadOnly(), duplicate.isReadOnly());
    assertEquals(buf.isDirect(), duplicate.isDirect());
    assertEquals(buf.order(), duplicate.order());
    assertContentEquals(buf, duplicate);
    // duplicate's position, mark, and limit should be independent to buf
    duplicate.reset();
    assertEquals(duplicate.position(), 0);
    duplicate.clear();
    assertEquals(buf.position(), buf.limit());
    buf.reset();
    assertEquals(buf.position(), 0);
    // duplicate share the same content with buf
    if (!duplicate.isReadOnly()) {
        loadTestData1(buf);
        assertContentEquals(buf, duplicate);
        loadTestData2(duplicate);
        assertContentEquals(buf, duplicate);
    }
}
Also used : FloatBuffer(java.nio.FloatBuffer)

Example 97 with FloatBuffer

use of java.nio.FloatBuffer 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);
}
Also used : FloatBuffer(java.nio.FloatBuffer) BufferOverflowException(java.nio.BufferOverflowException)

Example 98 with FloatBuffer

use of java.nio.FloatBuffer in project robovm by robovm.

the class FloatBufferTest method testPutintfloat.

/*
     * Class under test for java.nio.FloatBuffer put(int, float)
     */
public void testPutintfloat() {
    buf.clear();
    for (int i = 0; i < buf.capacity(); i++) {
        assertEquals(buf.position(), 0);
        FloatBuffer ret = buf.put(i, (float) i);
        assertEquals(buf.get(i), (float) i, 0.0);
        assertSame(ret, buf);
    }
    try {
        buf.put(-1, 0);
        //$NON-NLS-1$
        fail("Should throw Exception");
    } catch (IndexOutOfBoundsException e) {
    // expected
    }
    try {
        buf.put(buf.limit(), 0);
        //$NON-NLS-1$
        fail("Should throw Exception");
    } catch (IndexOutOfBoundsException e) {
    // expected
    }
}
Also used : FloatBuffer(java.nio.FloatBuffer)

Example 99 with FloatBuffer

use of java.nio.FloatBuffer in project robovm by robovm.

the class FloatBufferTest method testPutfloat.

/*
     * Class under test for java.nio.FloatBuffer put(float)
     */
public void testPutfloat() {
    buf.clear();
    for (int i = 0; i < buf.capacity(); i++) {
        assertEquals(buf.position(), i);
        FloatBuffer ret = buf.put((float) i);
        assertEquals(buf.get(i), (float) i, 0.0);
        assertSame(ret, buf);
    }
    try {
        buf.put(0);
        //$NON-NLS-1$
        fail("Should throw Exception");
    } catch (BufferOverflowException e) {
    // expected
    }
}
Also used : FloatBuffer(java.nio.FloatBuffer) BufferOverflowException(java.nio.BufferOverflowException)

Example 100 with FloatBuffer

use of java.nio.FloatBuffer in project robovm by robovm.

the class FloatBufferTest method testEquals.

public void testEquals() {
    // equal to self
    assertTrue(buf.equals(buf));
    FloatBuffer readonly = buf.asReadOnlyBuffer();
    assertTrue(buf.equals(readonly));
    FloatBuffer duplicate = buf.duplicate();
    assertTrue(buf.equals(duplicate));
    // always false, if type mismatch
    assertFalse(buf.equals(Boolean.TRUE));
    assertTrue(buf.capacity() > 5);
    buf.limit(buf.capacity()).position(0);
    readonly.limit(readonly.capacity()).position(1);
    assertFalse(buf.equals(readonly));
    buf.limit(buf.capacity() - 1).position(0);
    duplicate.limit(duplicate.capacity()).position(0);
    assertFalse(buf.equals(duplicate));
}
Also used : FloatBuffer(java.nio.FloatBuffer)

Aggregations

FloatBuffer (java.nio.FloatBuffer)287 ByteBuffer (java.nio.ByteBuffer)82 IntBuffer (java.nio.IntBuffer)43 ShortBuffer (java.nio.ShortBuffer)39 Vector3f (com.jme3.math.Vector3f)27 VertexBuffer (com.jme3.scene.VertexBuffer)27 DoubleBuffer (java.nio.DoubleBuffer)17 IndexBuffer (com.jme3.scene.mesh.IndexBuffer)16 LongBuffer (java.nio.LongBuffer)10 Mesh (com.jme3.scene.Mesh)9 CharBuffer (java.nio.CharBuffer)9 FrameBuffer2D (androidx.media.filterfw.FrameBuffer2D)8 OutputPort (androidx.media.filterfw.OutputPort)7 Matrix4f (com.jme3.math.Matrix4f)7 Buffer (java.nio.Buffer)7 TempVars (com.jme3.util.TempVars)6 IOException (java.io.IOException)6 BufferOverflowException (java.nio.BufferOverflowException)6 BufferUnderflowException (java.nio.BufferUnderflowException)6 ArrayList (java.util.ArrayList)6