5 |
|
* http://creativecommons.org/publicdomain/zero/1.0/ |
6 |
|
*/ |
7 |
|
|
8 |
– |
import java.util.ArrayList; |
8 |
|
import java.util.Arrays; |
9 |
|
import java.util.Collection; |
10 |
|
import java.util.Collections; |
29 |
|
} |
30 |
|
class SubListImplementation extends Implementation { |
31 |
|
public List emptyCollection() { |
32 |
< |
return super.emptyCollection().subList(0, 0); |
32 |
> |
List list = super.emptyCollection(); |
33 |
> |
ThreadLocalRandom rnd = ThreadLocalRandom.current(); |
34 |
> |
if (rnd.nextBoolean()) |
35 |
> |
list.add(makeElement(rnd.nextInt())); |
36 |
> |
int i = rnd.nextInt(list.size() + 1); |
37 |
> |
return list.subList(i, i); |
38 |
|
} |
39 |
|
} |
40 |
|
return newTestSuite( |
440 |
|
assertEquals(n, v.size()); |
441 |
|
assertNull(v.get(0)); |
442 |
|
assertNull(v.get(n - 1)); |
443 |
< |
assertThrows( |
444 |
< |
ArrayIndexOutOfBoundsException.class, |
441 |
< |
new Runnable() { public void run() { v.setSize(-1); }}); |
443 |
> |
assertThrows(ArrayIndexOutOfBoundsException.class, |
444 |
> |
() -> v.setSize(-1)); |
445 |
|
assertEquals(n, v.size()); |
446 |
|
assertNull(v.get(0)); |
447 |
|
assertNull(v.get(n - 1)); |