@Test
public void testShort() {
for (ByteOrder bo : new ByteOrder[] { ByteOrder.BIG_ENDIAN, ByteOrder.LITTLE_ENDIAN }) {
ByteBuffer bb = (ByteBuffer) ByteBuffer.allocate(3).order(bo).putShort((short) 12345).rewind();
IoBuffer ioBuffer = IoBuffer.wrap(bb).order(bo);
assertEquals(3, ioBuffer.capacity());
ioBuffer.extend(1);
ioBuffer.position(2);
assertEquals(4, ioBuffer.capacity());
ioBuffer.putShort((short) -23456);
ioBuffer.rewind();
assertEquals(12345, ioBuffer.getShort());
assertEquals(-23456, ioBuffer.getShort());
ioBuffer.rewind();
ioBuffer.putShort(1, (short) 12345);
assertEquals((short) 12345, ioBuffer.getShort(1));
try {
ioBuffer.putShort(3, (short) 1);
fail("Not enough place on the buffer");
} catch (BufferUnderflowException e) {
}
try {
ioBuffer.getShort(3);
fail("Not enough place on the buffer");
} catch (BufferUnderflowException e) {
}
}
}