aboutsummaryrefslogtreecommitdiff
path: root/guava-tests/test/com/google/common/collect/ImmutableRangeSetTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'guava-tests/test/com/google/common/collect/ImmutableRangeSetTest.java')
-rw-r--r--guava-tests/test/com/google/common/collect/ImmutableRangeSetTest.java52
1 files changed, 17 insertions, 35 deletions
diff --git a/guava-tests/test/com/google/common/collect/ImmutableRangeSetTest.java b/guava-tests/test/com/google/common/collect/ImmutableRangeSetTest.java
index 1fe56c7cc..378841cbd 100644
--- a/guava-tests/test/com/google/common/collect/ImmutableRangeSetTest.java
+++ b/guava-tests/test/com/google/common/collect/ImmutableRangeSetTest.java
@@ -15,6 +15,7 @@
package com.google.common.collect;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.collect.testing.NavigableSetTestSuiteBuilder;
@@ -321,12 +322,7 @@ public class ImmutableRangeSetTest extends AbstractRangeSetTest {
.add(Range.closedOpen(1, 3))
.build();
- try {
- rangeSet.add(Range.open(3, 4));
- fail();
- } catch (UnsupportedOperationException expected) {
- // success
- }
+ assertThrows(UnsupportedOperationException.class, () -> rangeSet.add(Range.open(3, 4)));
}
@SuppressWarnings("DoNotCall")
@@ -337,12 +333,9 @@ public class ImmutableRangeSetTest extends AbstractRangeSetTest {
.add(Range.closedOpen(1, 3))
.build();
- try {
- rangeSet.addAll(ImmutableRangeSet.<Integer>of());
- fail();
- } catch (UnsupportedOperationException expected) {
- // success
- }
+ assertThrows(
+ UnsupportedOperationException.class,
+ () -> rangeSet.addAll(ImmutableRangeSet.<Integer>of()));
}
@SuppressWarnings("DoNotCall")
@@ -353,12 +346,7 @@ public class ImmutableRangeSetTest extends AbstractRangeSetTest {
.add(Range.closedOpen(1, 3))
.build();
- try {
- rangeSet.remove(Range.closed(6, 7));
- fail();
- } catch (UnsupportedOperationException expected) {
- // success
- }
+ assertThrows(UnsupportedOperationException.class, () -> rangeSet.remove(Range.closed(6, 7)));
}
@SuppressWarnings("DoNotCall")
@@ -369,19 +357,13 @@ public class ImmutableRangeSetTest extends AbstractRangeSetTest {
.add(Range.closedOpen(1, 3))
.build();
- try {
- rangeSet.removeAll(ImmutableRangeSet.<Integer>of());
- fail();
- } catch (UnsupportedOperationException expected) {
- // success
- }
+ assertThrows(
+ UnsupportedOperationException.class,
+ () -> rangeSet.removeAll(ImmutableRangeSet.<Integer>of()));
- try {
- rangeSet.removeAll(ImmutableRangeSet.of(Range.closed(6, 8)));
- fail();
- } catch (UnsupportedOperationException expected) {
- // success
- }
+ assertThrows(
+ UnsupportedOperationException.class,
+ () -> rangeSet.removeAll(ImmutableRangeSet.of(Range.closed(6, 8))));
}
@AndroidIncompatible // slow
@@ -429,11 +411,11 @@ public class ImmutableRangeSetTest extends AbstractRangeSetTest {
}
if (anyOverlaps) {
- try {
- RangeSet<Integer> copy = ImmutableRangeSet.copyOf(subset);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> {
+ RangeSet<Integer> copy = ImmutableRangeSet.copyOf(subset);
+ });
} else {
RangeSet<Integer> copy = ImmutableRangeSet.copyOf(subset);
assertEquals(mutable, copy);