  @Test
  public void testIncremental() {

    ReserveBuffer buffer = new ReserveBuffer(16);
    byte[] input = new byte[1];

    for (int i=0;i<16;i++) {
      input[0] = (byte)i;
      byte[] result = buffer.update(input, 0, 1);
      assertEquals(0, result.length);
    }

    byte[] largeInput = new byte[16];
    Arrays.fill(largeInput, (byte)16);

    byte[] result = buffer.update(largeInput, 0, largeInput.length);
    assertEquals(16, result.length);

    for (int i=0;i<result.length;i++) {
      assertEquals(i, result[i]);
    }

    Arrays.fill(largeInput, (byte)17);

    result = buffer.update(largeInput, 0, largeInput.length);
    assertEquals(16, result.length);

    for (int i=0;i<result.length;i++) {
      assertEquals(16, result[i]);
    }
  }