ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/jtreg/util/Collections/EmptyNavigableSet.java
(Generate patch)

Comparing jsr166/src/test/jtreg/util/Collections/EmptyNavigableSet.java (file contents):
Revision 1.8 by jsr166, Sun Jan 7 23:26:04 2018 UTC vs.
Revision 1.11 by jsr166, Mon Jan 8 03:12:03 2018 UTC

# Line 27 | Line 27
27   * @summary Unit test for Collections.emptyNavigableSet
28   * @run testng EmptyNavigableSet
29   */
30 +
31 + import org.testng.Assert;
32 + import org.testng.Assert.ThrowingRunnable;
33 + import org.testng.annotations.DataProvider;
34 + import org.testng.annotations.Test;
35 +
36   import java.math.BigInteger;
37   import java.util.Arrays;
38   import java.util.Collection;
39   import java.util.Collections;
40   import java.util.Comparator;
41   import java.util.Iterator;
36 import java.util.NoSuchElementException;
42   import java.util.NavigableSet;
43 + import java.util.NoSuchElementException;
44   import java.util.SortedSet;
45   import java.util.TreeSet;
46  
41 import org.testng.Assert;
42 import org.testng.Assert.ThrowingRunnable;
43 import org.testng.annotations.Test;
44 import org.testng.annotations.DataProvider;
45
47   import static org.testng.Assert.assertFalse;
48   import static org.testng.Assert.assertSame;
49   import static org.testng.Assert.assertTrue;
# Line 130 | Line 131 | public class EmptyNavigableSet {
131       */
132      @Test(dataProvider = "NavigableSet<?>", dataProviderClass = EmptyNavigableSet.class)
133      public void testContainsRequiresComparable(String description, NavigableSet<?> navigableSet) {
134 <        assertThrowsCCE(() -> {
135 <            navigableSet.contains(new Object());
136 <        },
136 <            description + ": Compareable should be required");
134 >        assertThrowsCCE(
135 >            () -> navigableSet.contains(new Object()),
136 >            description + ": Comparable should be required");
137      }
138  
139      /**
# Line 273 | Line 273 | public class EmptyNavigableSet {
273          Object last = (BigInteger.ZERO == first) ? BigInteger.TEN : BigInteger.ZERO;
274  
275              assertThrowsIAE(
276 <                () -> {
277 <                    navigableSet.subSet(last, true, first, false);
278 <                },
276 >                () -> navigableSet.subSet(last, true, first, false),
277                  description
278                  + ": Must throw IllegalArgumentException when fromElement is not less than toElement.");
279  
# Line 295 | Line 293 | public class EmptyNavigableSet {
293          // slightly smaller
294          NavigableSet ns = subSet.subSet(first, false, last, false);
295          // slight expansion
296 <        assertThrowsIAE(() -> {
297 <            ns.subSet(first, true, last, true);
300 <        },
296 >        assertThrowsIAE(
297 >            () -> ns.subSet(first, true, last, true),
298              description + ": Expansion should not be allowed");
299  
300          // much smaller
# Line 315 | Line 312 | public class EmptyNavigableSet {
312          NavigableSet ns = subSet.headSet(BigInteger.ONE, false);
313  
314          // slight expansion
315 <        assertThrowsIAE(() -> {
316 <            ns.headSet(BigInteger.ONE, true);
320 <        },
315 >        assertThrowsIAE(
316 >            () -> ns.headSet(BigInteger.ONE, true),
317              description + ": Expansion should not be allowed");
318  
319          // much smaller
# Line 335 | Line 331 | public class EmptyNavigableSet {
331          NavigableSet ns = subSet.tailSet(BigInteger.ONE, false);
332  
333          // slight expansion
334 <        assertThrowsIAE(() -> {
335 <            ns.tailSet(BigInteger.ONE, true);
340 <        },
334 >        assertThrowsIAE(
335 >            () -> ns.tailSet(BigInteger.ONE, true),
336              description + ": Expansion should not be allowed");
337  
338          // much smaller
# Line 349 | Line 344 | public class EmptyNavigableSet {
344       */
345      @Test(dataProvider = "NavigableSet<?>", dataProviderClass = EmptyNavigableSet.class)
346      public void testTailSet(String description, NavigableSet navigableSet) {
347 <        assertThrowsNPE(() -> {
348 <            navigableSet.tailSet(null);
354 <        },
347 >        assertThrowsNPE(
348 >            () -> navigableSet.tailSet(null),
349              description + ": Must throw NullPointerException for null element");
350  
351 <        assertThrowsCCE(() -> {
352 <            navigableSet.tailSet(new Object());
353 <        }, description);
351 >        assertThrowsCCE(
352 >            () -> navigableSet.tailSet(new Object()),
353 >            description);
354  
355          NavigableSet ss = navigableSet.tailSet("1", true);
356  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines