Пример #1
0
  @Test
  public void testGetAndSetPut() throws Exception {
    DynamicByteBuffer buf = new DynamicByteBuffer();
    byte b1 = (byte) -128;
    byte b2 = (byte) 127;
    byte b3 = (byte) 128;
    byte b4 = (byte) 12;
    byte b5 = (byte) 13;
    buf.put(b1);
    buf.put(b2);
    buf.put(b3);
    buf.flip();

    assertEquals(b1, buf.get());
    assertEquals(b2, buf.get());
    assertEquals(b3, buf.get());

    buf.putAt(0, b4);
    buf.putAt(1, b5);
    assertEquals(b4, buf.getAt(0));
    assertEquals(b5, buf.getAt(1));
  }
Пример #2
0
 @Test(expected = IndexOutOfBoundsException.class)
 public void testGetAndSetPutAtException2() {
   DynamicByteBuffer buf = new DynamicByteBuffer();
   buf.putAt(129, (byte) 121);
 }