@Test
public void testSplice() {

  writeTestData();
  sampleQueue.splice();
  // Splice should succeed, replacing the last 4 samples with the sample being written.
  long spliceSampleTimeUs = SAMPLE_TIMESTAMPS[4];
  writeFormat(FORMAT_SPLICED);
  writeSample(DATA, spliceSampleTimeUs, C.BUFFER_FLAG_KEY_FRAME);
  assertReadTestData(null, 0, 4);
  assertReadFormat(false, FORMAT_SPLICED);
  assertReadSample(spliceSampleTimeUs, true, /* isEncrypted= */ false, DATA, 0, DATA.length);
  assertReadEndOfStream(false);
}