Esempio n. 1
0
  @Test
  public void testGetAndSetUnsignedShort() throws Exception {
    WrappedByteBuffer buf = new WrappedByteBuffer();
    buf.putUnsignedShort(0);
    buf.putUnsignedShort(65535);
    buf.putUnsignedShort(65536);
    buf.putUnsignedShort(-1);

    buf.flip();
    assertEquals(0, buf.getUnsignedShort());
    assertEquals(65535, buf.getUnsignedShort());
    assertEquals(0, buf.getUnsignedShort());
    assertEquals(65535, buf.getUnsignedShort());

    buf.rewind();
    buf.putUnsignedShortAt(0, 121);
    buf.putUnsignedShortAt(2, 122);
    assertEquals(121, buf.getUnsignedShortAt(0));
    assertEquals(122, buf.getUnsignedShortAt(2));
  }
Esempio n. 2
0
 @Test(expected = BufferUnderflowException.class)
 public void testGetAndSetGetUnsignedShortException3() {
   WrappedByteBuffer buf = WrappedByteBuffer.allocate(0);
   buf.getUnsignedShort();
 }