public void test_keyBuilder_ensureCapacity03(){
  Random r=new Random();
  byte[] expected=new byte[20];
  r.nextBytes(expected);
  KeyBuilder keyBuilder=new KeyBuilder(20,expected);
  assertEquals(20,keyBuilder.len());
  assertNotNull(keyBuilder.array());
  assertTrue(expected == keyBuilder.array());
  keyBuilder.ensureCapacity(30);
  assertEquals(20,keyBuilder.len());
  assertEquals(30,keyBuilder.array().length);
  assertEquals(0,BytesUtil.compareBytesWithLenAndOffset(0,expected.length,expected,0,expected.length,keyBuilder.array()));
  for (int i=21; i < 30; i++) {
    assertEquals(0,keyBuilder.array()[i]);
  }
}

public void test_keyBuilder_ensureCapacity03 ( ) { Random r = new Random ( ) ; byte [ ] expected = new byte [ 20 ] ; r . nextBytes ( expected ) ; KeyBuilder keyBuilder = new KeyBuilder ( 20 , expected ) ; assertEquals ( 20 , keyBuilder . len ( ) ) ; assertNotNull ( keyBuilder . array ( ) ) ; assertTrue ( expected == keyBuilder . array ( ) ) ; keyBuilder . ensureCapacity ( 30 ) ; assertEquals ( 20 , keyBuilder . len ( ) ) ; assertEquals ( 30 , keyBuilder . array ( ) . length ) ; assertEquals ( 0 , BytesUtil . compareBytesWithLenAndOffset ( 0 , expected . length , expected , 0 , expected . length , keyBuilder . array ( ) ) ) ; for ( int i = 21 ; i < 30 ; i ++ ) { assertEquals ( 0 , keyBuilder . array ( ) [ i ] ) ; } }
verify that existing data is preserved if the capacity is extended .
