@Test
  public void testGetAndSetUnsignedInt() throws Exception {
    WrappedByteBuffer buf = new WrappedByteBuffer();
    long MAX_UNSIGNED_INT = 4294967295L;

    buf.putUnsignedInt(MAX_UNSIGNED_INT);
    buf.putUnsignedInt(1);
    buf.putUnsignedInt(0);
    buf.putUnsignedInt(-1);
    buf.putUnsignedInt(MAX_UNSIGNED_INT + 1);

    assertEquals(buf.position(), 20);

    buf.flip();

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

    assertEquals("test 1", MAX_UNSIGNED_INT, buf.getUnsignedInt());
    assertEquals("test 2", 1L, buf.getUnsignedInt());
    assertEquals("test 3", 0L, buf.getUnsignedInt());
    assertEquals("test 4", MAX_UNSIGNED_INT, buf.getUnsignedInt());
    assertEquals("test 5", 0L, buf.getUnsignedInt());

    assertEquals(buf.position(), 20);

    buf.putUnsignedIntAt(0, 121);
    buf.putUnsignedIntAt(4, 4000000000L);
    assertEquals(121L, (long) buf.getUnsignedIntAt(0));
    assertEquals(4000000000L, (long) buf.getUnsignedIntAt(4));

    assertEquals(buf.position(), 20);
  }
  @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);
  }
  /*
   * Short Tests
   */
  @Test
  public void testGetAndSetShort() throws Exception {
    WrappedByteBuffer buf = new WrappedByteBuffer();
    buf.putShort((short) 0);
    buf.putShort((short) 1);
    buf.putShort((short) 32767);
    buf.putShort((short) -32768);
    buf.flip();

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

    assertEquals((short) 0, buf.getShort());
    assertEquals((short) 1, buf.getShort());
    assertEquals((short) 32767, buf.getShort());
    assertEquals((short) -32768, buf.getShort());

    assertEquals(buf.position(), 8);

    buf.putShortAt(0, (short) 121);
    buf.putShortAt(2, (short) 1000);
    assertEquals((short) 121, buf.getShortAt(0));
    assertEquals((short) 1000, buf.getShortAt(2));

    assertEquals((int) buf.position(), 8);
  }
 @Test
 public void testByteBufferAllocate() {
   /* Invariant: 0 <= mark <= position <= limit <= capacity */
   WrappedByteBuffer buf = WrappedByteBuffer.allocate(0);
   // assertEquals(0, buf.mark());
   assertEquals(0, buf.position());
   assertEquals(0, buf.limit());
   assertEquals(0, buf.capacity());
 }
  @Test
  public void testBuffers() throws Exception {
    // tests reallocation of buffer automatically.
    String test1 = "Test1";
    String test2 = "Test2";
    WrappedByteBuffer buf1 = WrappedByteBuffer.wrap(test1.getBytes());
    WrappedByteBuffer buf2 = WrappedByteBuffer.wrap(test2.getBytes());
    buf1.get();
    buf1.get();

    int p = buf1.position();
    buf1.skip(buf1.remaining());
    buf1.putBuffer(buf2);
    buf1.flip();
    buf1.position(p);
    buf1 = buf1.slice();

    // TODO: should test actual contents of these buffers
    assertEquals(8, buf1.remaining());
  }