6 |
|
* Pat Fisher, Mike Judd. |
7 |
|
*/ |
8 |
|
|
9 |
– |
import junit.framework.*; |
9 |
|
import java.util.ArrayList; |
10 |
|
import java.util.Arrays; |
11 |
|
import java.util.Collection; |
16 |
|
import java.util.Vector; |
17 |
|
import java.util.concurrent.CopyOnWriteArraySet; |
18 |
|
|
19 |
+ |
import junit.framework.Test; |
20 |
+ |
import junit.framework.TestSuite; |
21 |
+ |
|
22 |
|
public class CopyOnWriteArraySetTest extends JSR166TestCase { |
23 |
|
public static void main(String[] args) { |
24 |
|
junit.textui.TestRunner.run(suite()); |
194 |
|
assertTrue(it.hasNext()); |
195 |
|
assertEquals(elements[j], it.next()); |
196 |
|
} |
197 |
< |
assertFalse(it.hasNext()); |
198 |
< |
try { |
199 |
< |
it.next(); |
200 |
< |
shouldThrow(); |
201 |
< |
} catch (NoSuchElementException success) {} |
197 |
> |
assertIteratorExhausted(it); |
198 |
> |
} |
199 |
> |
|
200 |
> |
/** |
201 |
> |
* iterator of empty collection has no elements |
202 |
> |
*/ |
203 |
> |
public void testEmptyIterator() { |
204 |
> |
assertIteratorExhausted(new CopyOnWriteArraySet().iterator()); |
205 |
|
} |
206 |
|
|
207 |
|
/** |
346 |
|
Set x = populatedSet(SIZE); |
347 |
|
Set y = serialClone(x); |
348 |
|
|
349 |
< |
assertTrue(x != y); |
349 |
> |
assertNotSame(y, x); |
350 |
|
assertEquals(x.size(), y.size()); |
351 |
|
assertEquals(x.toString(), y.toString()); |
352 |
|
assertTrue(Arrays.equals(x.toArray(), y.toArray())); |
353 |
|
assertEquals(x, y); |
354 |
|
assertEquals(y, x); |
355 |
|
} |
356 |
+ |
|
357 |
+ |
/** |
358 |
+ |
* addAll is idempotent |
359 |
+ |
*/ |
360 |
+ |
public void testAddAll_idempotent() throws Exception { |
361 |
+ |
Set x = populatedSet(SIZE); |
362 |
+ |
Set y = new CopyOnWriteArraySet(x); |
363 |
+ |
y.addAll(x); |
364 |
+ |
assertEquals(x, y); |
365 |
+ |
assertEquals(y, x); |
366 |
+ |
} |
367 |
|
|
368 |
|
} |