50 |
|
public class EmptyNavigableSet { |
51 |
|
|
52 |
|
public static <T> void assertInstance(T actual, Class<? extends T> expected) { |
53 |
< |
assertInstance(expected.isInstance(actual), null); |
53 |
> |
assertInstance(actual, expected, null); |
54 |
|
} |
55 |
|
|
56 |
|
public static <T> void assertInstance(T actual, Class<? extends T> expected, String message) { |
130 |
|
*/ |
131 |
|
@Test(dataProvider = "NavigableSet<?>", dataProviderClass = EmptyNavigableSet.class) |
132 |
|
public void testContainsRequiresComparable(String description, NavigableSet<?> navigableSet) { |
133 |
< |
assertThrowsCCE(() -> { |
134 |
< |
navigableSet.contains(new Object()); |
135 |
< |
}, |
136 |
< |
description + ": Compareable should be required"); |
133 |
> |
assertThrowsCCE( |
134 |
> |
() -> navigableSet.contains(new Object()), |
135 |
> |
description + ": Comparable should be required"); |
136 |
|
} |
137 |
|
|
138 |
|
/** |
181 |
|
*/ |
182 |
|
@Test(dataProvider = "NavigableSet<?>", dataProviderClass = EmptyNavigableSet.class) |
183 |
|
public void testFirst(String description, NavigableSet<?> navigableSet) { |
184 |
< |
assertThrowsNSEE(() -> { |
186 |
< |
navigableSet.first(); |
187 |
< |
}, description); |
184 |
> |
assertThrowsNSEE(navigableSet::first, description); |
185 |
|
} |
186 |
|
|
187 |
|
/** |
207 |
|
*/ |
208 |
|
@Test(dataProvider = "NavigableSet<?>", dataProviderClass = EmptyNavigableSet.class) |
209 |
|
public void testLast(String description, NavigableSet<?> navigableSet) { |
210 |
< |
assertThrowsNSEE(() -> { |
214 |
< |
navigableSet.last(); |
215 |
< |
}, description); |
210 |
> |
assertThrowsNSEE(navigableSet::last, description); |
211 |
|
} |
212 |
|
|
213 |
|
/** |
272 |
|
Object last = (BigInteger.ZERO == first) ? BigInteger.TEN : BigInteger.ZERO; |
273 |
|
|
274 |
|
assertThrowsIAE( |
275 |
< |
() -> { |
281 |
< |
navigableSet.subSet(last, true, first, false); |
282 |
< |
}, |
275 |
> |
() -> navigableSet.subSet(last, true, first, false), |
276 |
|
description |
277 |
|
+ ": Must throw IllegalArgumentException when fromElement is not less than toElement."); |
278 |
|
|
292 |
|
// slightly smaller |
293 |
|
NavigableSet ns = subSet.subSet(first, false, last, false); |
294 |
|
// slight expansion |
295 |
< |
assertThrowsIAE(() -> { |
296 |
< |
ns.subSet(first, true, last, true); |
304 |
< |
}, |
295 |
> |
assertThrowsIAE( |
296 |
> |
() -> ns.subSet(first, true, last, true), |
297 |
|
description + ": Expansion should not be allowed"); |
298 |
|
|
299 |
|
// much smaller |
311 |
|
NavigableSet ns = subSet.headSet(BigInteger.ONE, false); |
312 |
|
|
313 |
|
// slight expansion |
314 |
< |
assertThrowsIAE(() -> { |
315 |
< |
ns.headSet(BigInteger.ONE, true); |
324 |
< |
}, |
314 |
> |
assertThrowsIAE( |
315 |
> |
() -> ns.headSet(BigInteger.ONE, true), |
316 |
|
description + ": Expansion should not be allowed"); |
317 |
|
|
318 |
|
// much smaller |
330 |
|
NavigableSet ns = subSet.tailSet(BigInteger.ONE, false); |
331 |
|
|
332 |
|
// slight expansion |
333 |
< |
assertThrowsIAE(() -> { |
334 |
< |
ns.tailSet(BigInteger.ONE, true); |
344 |
< |
}, |
333 |
> |
assertThrowsIAE( |
334 |
> |
() -> ns.tailSet(BigInteger.ONE, true), |
335 |
|
description + ": Expansion should not be allowed"); |
336 |
|
|
337 |
|
// much smaller |
343 |
|
*/ |
344 |
|
@Test(dataProvider = "NavigableSet<?>", dataProviderClass = EmptyNavigableSet.class) |
345 |
|
public void testTailSet(String description, NavigableSet navigableSet) { |
346 |
< |
assertThrowsNPE(() -> { |
347 |
< |
navigableSet.tailSet(null); |
358 |
< |
}, |
346 |
> |
assertThrowsNPE( |
347 |
> |
() -> navigableSet.tailSet(null), |
348 |
|
description + ": Must throw NullPointerException for null element"); |
349 |
|
|
350 |
< |
assertThrowsCCE(() -> { |
351 |
< |
navigableSet.tailSet(new Object()); |
352 |
< |
}, description); |
350 |
> |
assertThrowsCCE( |
351 |
> |
() -> navigableSet.tailSet(new Object()), |
352 |
> |
description); |
353 |
|
|
354 |
|
NavigableSet ss = navigableSet.tailSet("1", true); |
355 |
|
|