aboutsummaryrefslogtreecommitdiff
path: root/guava-tests/test/com/google/common/io/ByteSourceTester.java
diff options
context:
space:
mode:
Diffstat (limited to 'guava-tests/test/com/google/common/io/ByteSourceTester.java')
-rw-r--r--guava-tests/test/com/google/common/io/ByteSourceTester.java21
1 files changed, 10 insertions, 11 deletions
diff --git a/guava-tests/test/com/google/common/io/ByteSourceTester.java b/guava-tests/test/com/google/common/io/ByteSourceTester.java
index fe10810f6..187c2d00a 100644
--- a/guava-tests/test/com/google/common/io/ByteSourceTester.java
+++ b/guava-tests/test/com/google/common/io/ByteSourceTester.java
@@ -19,6 +19,7 @@ package com.google.common.io;
import static com.google.common.io.SourceSinkFactory.ByteSourceFactory;
import static com.google.common.io.SourceSinkFactory.CharSourceFactory;
import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Charsets;
import com.google.common.base.Optional;
@@ -219,17 +220,15 @@ public class ByteSourceTester extends SourceSinkTester<ByteSource, byte[], ByteS
}
public void testSlice_illegalArguments() {
- try {
- source.slice(-1, 0);
- fail("expected IllegalArgumentException for call to slice with offset -1: " + source);
- } catch (IllegalArgumentException expected) {
- }
-
- try {
- source.slice(0, -1);
- fail("expected IllegalArgumentException for call to slice with length -1: " + source);
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ "expected IllegalArgumentException for call to slice with offset -1: " + source,
+ IllegalArgumentException.class,
+ () -> source.slice(-1, 0));
+
+ assertThrows(
+ "expected IllegalArgumentException for call to slice with length -1: " + source,
+ IllegalArgumentException.class,
+ () -> source.slice(0, -1));
}
// Test that you can not expand the readable data in a previously sliced ByteSource.