7 |
|
|
8 |
|
import java.util.Vector; |
9 |
|
import java.util.Collection; |
10 |
+ |
import java.util.List; |
11 |
|
|
12 |
|
import junit.framework.Test; |
13 |
|
import junit.framework.TestSuite; |
20 |
|
public static Test suite() { |
21 |
|
class Implementation implements CollectionImplementation { |
22 |
|
public Class<?> klazz() { return Vector.class; } |
23 |
< |
public Collection emptyCollection() { return new Vector(); } |
23 |
> |
public List emptyCollection() { return new Vector(); } |
24 |
|
public Object makeElement(int i) { return i; } |
25 |
|
public boolean isConcurrent() { return false; } |
26 |
|
public boolean permitsNulls() { return true; } |
27 |
|
} |
28 |
< |
return newTestSuite(// VectorTest.class, |
29 |
< |
CollectionTest.testSuite(new Implementation())); |
28 |
> |
class SubListImplementation extends Implementation { |
29 |
> |
public List emptyCollection() { |
30 |
> |
return super.emptyCollection().subList(0, 0); |
31 |
> |
} |
32 |
> |
} |
33 |
> |
return newTestSuite( |
34 |
> |
VectorTest.class, |
35 |
> |
CollectionTest.testSuite(new Implementation()), |
36 |
> |
CollectionTest.testSuite(new SubListImplementation())); |
37 |
> |
} |
38 |
> |
|
39 |
> |
/** |
40 |
> |
* tests for setSize() |
41 |
> |
*/ |
42 |
> |
public void testSetSize() { |
43 |
> |
Vector v = new Vector(); |
44 |
> |
for (int n : new int[] { 100, 5, 50 }) { |
45 |
> |
v.setSize(n); |
46 |
> |
assertEquals(n, v.size()); |
47 |
> |
assertNull(v.get(0)); |
48 |
> |
assertNull(v.get(n - 1)); |
49 |
> |
} |
50 |
|
} |
51 |
|
|
52 |
|
} |