예제 #1
0
  @Test
  public void testGetAndSetUnsignedShort() throws Exception {
    DynamicByteBuffer buf = new DynamicByteBuffer();
    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));
  }
예제 #2
0
 @Test(expected = IndexOutOfBoundsException.class)
 public void testGetAndSetGetUnsignedShortAtException4() {
   DynamicByteBuffer buf = new DynamicByteBuffer();
   buf.getUnsignedShortAt(128);
 }