Exemplo n.º 1
0
  /*
   * Int tests
   */
  @Test
  public void testGetAndSetInt() throws Exception {
    // cant test for numbers outside range as putint accepts int and
    // hence java doesnt allow values outside range -2147483648 to 2147483647 to be set to
    // valriables
    // hence no test case for assertFalse for numbers outside -2147483648 to 2147483647
    WrappedByteBuffer buf = new WrappedByteBuffer();
    int b1 = -2147483648;
    int b2 = 2147483647;
    int b3 = 32768;
    int b4 = 128;
    int b5 = 128;
    buf.putInt(b1);
    buf.putInt(b2);
    buf.putInt(b3);

    buf.flip();
    assertEquals(b1, buf.getInt());
    assertEquals(b2, buf.getInt());
    buf.rewind();
    buf.putIntAt(0, b4);
    buf.putIntAt(4, b5);
    assertEquals(b4, buf.getIntAt(0));
    assertEquals(b5, buf.getIntAt(4));
  }
Exemplo n.º 2
0
 @Test(expected = IndexOutOfBoundsException.class)
 public void testGetAndSetPutIntAtException2() {
   WrappedByteBuffer buf = new WrappedByteBuffer();
   buf.putIntAt(129, 121);
 }