@Test
public void testPeekToLengthEndNotReached() throws Exception {

  FakeDataSource testDataSource = new FakeDataSource();
  testDataSource
      .getDataSet()
      .newDefaultData()
      .appendReadData(Arrays.copyOfRange(TEST_DATA, 0, 3))
      .appendReadData(Arrays.copyOfRange(TEST_DATA, 3, 6))
      .appendReadData(Arrays.copyOfRange(TEST_DATA, 6, 9));
  testDataSource.open(new DataSpec(Uri.parse(TEST_URI)));
  ExtractorInput input = new DefaultExtractorInput(testDataSource, 0, C.LENGTH_UNSET);
  byte[] target = new byte[TEST_DATA.length];
  int offset = 2;
  int length = 4;
  int bytesPeeked = ExtractorUtil.peekToLength(input, target, offset, length);
  assertThat(bytesPeeked).isEqualTo(length);
  assertThat(input.getPeekPosition()).isEqualTo(length);
  assertThat(Arrays.copyOfRange(target, offset, offset + length))
      .isEqualTo(Arrays.copyOf(TEST_DATA, length));
}