예제 #1
0
  @Test
  public void testGetAndSetUnsigned() throws Exception {
    DynamicByteBuffer buf = new DynamicByteBuffer();
    buf.putUnsigned(0);
    buf.putUnsigned(255);
    buf.putUnsigned(256);
    buf.putUnsigned(-1);
    buf.flip();

    assertEquals(buf.position(), 0);
    assertEquals(buf.limit(), 4);

    assertEquals(0, buf.getUnsigned());
    assertEquals(255, buf.getUnsigned());
    assertEquals(0, buf.getUnsigned());
    assertEquals(255, buf.getUnsigned());

    assertEquals(buf.position(), 4);

    buf.putUnsignedAt(0, 121);
    buf.putUnsignedAt(1, 122);
    assertEquals(121, buf.getUnsignedAt(0));
    assertEquals(122, buf.getUnsignedAt(1));

    assertEquals(buf.position(), 4);
  }
예제 #2
0
 @Test(expected = IndexOutOfBoundsException.class)
 public void testGetAndSetPutUnsignedAtException2() {
   DynamicByteBuffer buf = new DynamicByteBuffer();
   buf.putUnsignedAt(129, 121);
 }