public void testBufferFieldReadChangedToNULL() { if (!Platform.HAS_BUFFERS) return; BufferStructure bs = new BufferStructure(); bs.buffer = ByteBuffer.allocateDirect(16); bs.dbuffer = ((ByteBuffer) bs.buffer).asDoubleBuffer(); bs.read(); assertNull("Structure Buffer field should be set null", bs.buffer); assertNull("Structure DoubleBuffer field should be set null", bs.dbuffer); }
public void testBufferFieldReadUnchanged() { if (!Platform.HAS_BUFFERS) return; BufferStructure bs = new BufferStructure(); Buffer b = ByteBuffer.allocateDirect(16); bs.buffer = b; bs.dbuffer = ((ByteBuffer) bs.buffer).asDoubleBuffer(); bs.write(); bs.read(); assertEquals("Buffer field should be unchanged", b, bs.buffer); }
public void testBufferFieldReadChanged() { if (!Platform.HAS_BUFFERS) return; BufferStructure bs = new BufferStructure(); if (Pointer.SIZE == 4) { bs.getPointer().setInt(0, 0x1); } else { bs.getPointer().setLong(0, 0x1); } try { bs.read(); fail("Structure read should fail if Buffer pointer was set"); } catch (IllegalStateException e) { } bs.buffer = ByteBuffer.allocateDirect(16); try { bs.read(); fail("Structure read should fail if Buffer pointer has changed"); } catch (IllegalStateException e) { } }