11 |
|
import java.io.*; |
12 |
|
|
13 |
|
public class CopyOnWriteArraySetTest extends JSR166TestCase { |
14 |
– |
|
14 |
|
public static void main(String[] args) { |
15 |
|
junit.textui.TestRunner.run (suite()); |
16 |
|
} |
18 |
– |
|
17 |
|
public static Test suite() { |
18 |
|
return new TestSuite(CopyOnWriteArraySetTest.class); |
19 |
|
} |
37 |
|
} |
38 |
|
|
39 |
|
/** |
40 |
< |
* Collection-constructed list holds all of its elements |
40 |
> |
* Collection-constructed set holds all of its elements |
41 |
|
*/ |
42 |
|
public void testConstructor3() { |
43 |
|
Integer[] ints = new Integer[SIZE]; |
50 |
|
|
51 |
|
|
52 |
|
/** |
53 |
< |
* addAll correctly adds each element from the given collection |
53 |
> |
* addAll adds each element from the given collection |
54 |
|
*/ |
55 |
|
public void testAddAll() { |
56 |
|
CopyOnWriteArraySet full = populatedSet(3); |
63 |
|
} |
64 |
|
|
65 |
|
/** |
66 |
< |
* addAllAbsent adds each element from the given collection that did not |
67 |
< |
* already exist in the List |
66 |
> |
* addAll adds each element from the given collection that did not |
67 |
> |
* already exist in the set |
68 |
|
*/ |
69 |
|
public void testAddAll2() { |
70 |
|
CopyOnWriteArraySet full = populatedSet(3); |
77 |
|
} |
78 |
|
|
79 |
|
/** |
80 |
< |
* addIfAbsent will not add the element if it already exists in the list |
80 |
> |
* add will not add the element if it already exists in the set |
81 |
|
*/ |
82 |
|
public void testAdd2() { |
83 |
|
CopyOnWriteArraySet full = populatedSet(3); |
86 |
|
} |
87 |
|
|
88 |
|
/** |
89 |
< |
* addIfAbsent correctly adds the element when it does not exist |
90 |
< |
* in the list |
89 |
> |
* add adds the element when it does not exist |
90 |
> |
* in the set |
91 |
|
*/ |
92 |
|
public void testAdd3() { |
93 |
|
CopyOnWriteArraySet full = populatedSet(3); |
96 |
|
} |
97 |
|
|
98 |
|
/** |
99 |
< |
* clear correctly removes all elements from the list |
99 |
> |
* clear removes all elements from the set |
100 |
|
*/ |
101 |
|
public void testClear() { |
102 |
|
CopyOnWriteArraySet full = populatedSet(3); |
105 |
|
} |
106 |
|
|
107 |
|
/** |
108 |
< |
* contains returns the correct values |
108 |
> |
* contains returns true for added elements |
109 |
|
*/ |
110 |
|
public void testContains() { |
111 |
|
CopyOnWriteArraySet full = populatedSet(3); |
133 |
|
|
134 |
|
|
135 |
|
/** |
136 |
< |
* containsAll returns the correct values |
136 |
> |
* containsAll returns true for collections with subset of elements |
137 |
|
*/ |
138 |
|
public void testContainsAll() { |
139 |
|
CopyOnWriteArraySet full = populatedSet(3); |
146 |
|
} |
147 |
|
|
148 |
|
/** |
149 |
< |
* isEmpty returns the correct values |
149 |
> |
* isEmpty is true when empty, else false |
150 |
|
*/ |
151 |
|
public void testIsEmpty() { |
152 |
|
CopyOnWriteArraySet empty = new CopyOnWriteArraySet(); |
156 |
|
} |
157 |
|
|
158 |
|
/** |
159 |
< |
* iterator() returns an iterator containing the elements of the list |
159 |
> |
* iterator() returns an iterator containing the elements of the set |
160 |
|
*/ |
161 |
|
public void testIterator() { |
162 |
|
CopyOnWriteArraySet full = populatedSet(3); |
194 |
|
|
195 |
|
|
196 |
|
/** |
197 |
< |
* removeAll correctly removes all elements from the given collection |
197 |
> |
* removeAll removes all elements from the given collection |
198 |
|
*/ |
199 |
|
public void testRemoveAll() { |
200 |
|
CopyOnWriteArraySet full = populatedSet(3); |
217 |
|
} |
218 |
|
|
219 |
|
/** |
220 |
< |
* size returns the correct values |
220 |
> |
* size returns the number of elements |
221 |
|
*/ |
222 |
|
public void testSize() { |
223 |
|
CopyOnWriteArraySet empty = new CopyOnWriteArraySet(); |
227 |
|
} |
228 |
|
|
229 |
|
/** |
230 |
< |
* toArray returns an Object array containing all elements from the list |
230 |
> |
* toArray returns an Object array containing all elements from the set |
231 |
|
*/ |
232 |
|
public void testToArray() { |
233 |
|
CopyOnWriteArraySet full = populatedSet(3); |
240 |
|
|
241 |
|
/** |
242 |
|
* toArray returns an Integer array containing all elements from |
243 |
< |
* the list |
243 |
> |
* the set |
244 |
|
*/ |
245 |
|
public void testToArray2() { |
246 |
|
CopyOnWriteArraySet full = populatedSet(3); |
255 |
|
|
256 |
|
/** |
257 |
|
* toArray throws an ArrayStoreException when the given array can |
258 |
< |
* not store the objects inside the list |
258 |
> |
* not store the objects inside the set |
259 |
|
*/ |
260 |
|
public void testToArray_ArrayStoreException() { |
261 |
|
try { |
268 |
|
} |
269 |
|
|
270 |
|
/** |
271 |
< |
* |
271 |
> |
* A deserialized seriealized set is equal |
272 |
|
*/ |
273 |
|
public void testSerialization() { |
274 |
|
CopyOnWriteArraySet q = populatedSet(SIZE); |