Пример #1
0
  @Test
  public void testGetAndSetUnsigned() throws Exception {
    WrappedByteBuffer buf = new WrappedByteBuffer();
    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() {
   WrappedByteBuffer buf = new WrappedByteBuffer();
   buf.putUnsignedAt(129, 121);
 }