public void test_getPutByteArrayWithOffsetAndLength(){
  final int size=200;
  final IDataRecord buf=new FixedByteArrayBuffer(size);
  assertEquals((byte)0,buf.getByte(0));
  assertEquals((byte)0,buf.getByte(size - 1));
  final int pos=1;
  for (int i=0; i < LIMIT; i++) {
    final byte[] expected=new byte[r.nextInt(size - 2)];
    final int off=(expected.length / 2 == 0 ? 0 : r.nextInt(expected.length / 2));
    final int len=(expected.length == 0 ? 0 : r.nextInt(expected.length - off));
    r.nextBytes(expected);
    buf.put(pos,expected,off,len);
    assertEquals(0,BytesUtil.compareBytesWithLenAndOffset(off,len,expected,pos,len,buf.array()));
    final int dstoff=r.nextInt(10);
    final byte[] actual=new byte[expected.length + dstoff];
    buf.get(pos,actual,dstoff,expected.length);
    assertEquals(0,BytesUtil.compareBytesWithLenAndOffset(off,len,expected,dstoff,len,actual));
  }
  assertEquals((byte)0,buf.getByte(0));
  assertEquals((byte)0,buf.getByte(pos + size - 2));
}

public void test_getPutByteArrayWithOffsetAndLength ( ) { final int size = 200 ; final IDataRecord buf = new FixedByteArrayBuffer ( size ) ; assertEquals ( ( byte ) 0 , buf . getByte ( 0 ) ) ; assertEquals ( ( byte ) 0 , buf . getByte ( size - 1 ) ) ; final int pos = 1 ; for ( int i = 0 ; i < LIMIT ; i ++ ) { final byte [ ] expected = new byte [ r . nextInt ( size - 2 ) ] ; final int off = ( expected . length / 2 == 0 ? 0 : r . nextInt ( expected . length / 2 ) ) ; final int len = ( expected . length == 0 ? 0 : r . nextInt ( expected . length - off ) ) ; r . nextBytes ( expected ) ; buf . put ( pos , expected , off , len ) ; assertEquals ( 0 , BytesUtil . compareBytesWithLenAndOffset ( off , len , expected , pos , len , buf . array ( ) ) ) ; final int dstoff = r . nextInt ( 10 ) ; final byte [ ] actual = new byte [ expected . length + dstoff ] ; buf . get ( pos , actual , dstoff , expected . length ) ; assertEquals ( 0 , BytesUtil . compareBytesWithLenAndOffset ( off , len , expected , dstoff , len , actual ) ) ; } assertEquals ( ( byte ) 0 , buf . getByte ( 0 ) ) ; assertEquals ( ( byte ) 0 , buf . getByte ( pos + size - 2 ) ) ; }
test of the bulk get / put byte [ ] methods which accept a slice into the caller ' s array .
