Пример #1
0
  /*
   * 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);
  }
Пример #2
0
 @Test(expected = IndexOutOfBoundsException.class)
 public void testGetAndSetPutShortAtException2() {
   WrappedByteBuffer buf = new WrappedByteBuffer();
   buf.putShortAt(129, (short) 121);
 }