mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
FlacMetadataReaderTest: replace @Test(expected =) by assertThrows
Using @Test(expected=...) is discouraged, since the test will pass if any statement in the test method throws the expected exception. PiperOrigin-RevId: 291338224
This commit is contained in:
parent
9cd49120a0
commit
e8da2f9d43
1 changed files with 11 additions and 7 deletions
|
|
@ -16,6 +16,7 @@
|
||||||
package com.google.android.exoplayer2.extractor;
|
package com.google.android.exoplayer2.extractor;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
import static org.junit.Assert.assertThrows;
|
||||||
|
|
||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
@ -161,11 +162,11 @@ public class FlacMetadataReaderTest {
|
||||||
assertThat(input.getPeekPosition()).isEqualTo(input.getPosition());
|
assertThat(input.getPeekPosition()).isEqualTo(input.getPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = ParserException.class)
|
@Test
|
||||||
public void readStreamMarker_invalidData_throwsException() throws Exception {
|
public void readStreamMarker_invalidData_throwsException() throws Exception {
|
||||||
ExtractorInput input = buildExtractorInput("mp3/bear.mp3");
|
ExtractorInput input = buildExtractorInput("mp3/bear.mp3");
|
||||||
|
|
||||||
FlacMetadataReader.readStreamMarker(input);
|
assertThrows(ParserException.class, () -> FlacMetadataReader.readStreamMarker(input));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -297,15 +298,18 @@ public class FlacMetadataReaderTest {
|
||||||
assertThat(input.getPeekPosition()).isEqualTo(input.getPosition());
|
assertThat(input.getPeekPosition()).isEqualTo(input.getPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void readMetadataBlock_nonStreamInfoBlockWithNullStreamMetadata_throwsException()
|
public void readMetadataBlock_nonStreamInfoBlockWithNullStreamMetadata_throwsException()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
ExtractorInput input = buildExtractorInput("flac/bear.flac");
|
ExtractorInput input = buildExtractorInput("flac/bear.flac");
|
||||||
// Skip to seek table block.
|
// Skip to seek table block.
|
||||||
input.skipFully(FlacConstants.STREAM_MARKER_SIZE + FlacConstants.STREAM_INFO_BLOCK_SIZE);
|
input.skipFully(FlacConstants.STREAM_MARKER_SIZE + FlacConstants.STREAM_INFO_BLOCK_SIZE);
|
||||||
|
|
||||||
FlacMetadataReader.readMetadataBlock(
|
assertThrows(
|
||||||
input, new FlacStreamMetadataHolder(/* flacStreamMetadata= */ null));
|
IllegalArgumentException.class,
|
||||||
|
() ->
|
||||||
|
FlacMetadataReader.readMetadataBlock(
|
||||||
|
input, new FlacStreamMetadataHolder(/* flacStreamMetadata= */ null)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -379,12 +383,12 @@ public class FlacMetadataReaderTest {
|
||||||
assertThat(result).isEqualTo(0xFFF8);
|
assertThat(result).isEqualTo(0xFFF8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = ParserException.class)
|
@Test
|
||||||
public void getFrameStartMarker_invalidData_throwsException() throws Exception {
|
public void getFrameStartMarker_invalidData_throwsException() throws Exception {
|
||||||
ExtractorInput input = buildExtractorInput("flac/bear.flac");
|
ExtractorInput input = buildExtractorInput("flac/bear.flac");
|
||||||
|
|
||||||
// Input position is incorrect.
|
// Input position is incorrect.
|
||||||
FlacMetadataReader.getFrameStartMarker(input);
|
assertThrows(ParserException.class, () -> FlacMetadataReader.getFrameStartMarker(input));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ExtractorInput buildExtractorInput(String file) throws IOException {
|
private static ExtractorInput buildExtractorInput(String file) throws IOException {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue