38 |
|
* Integers 0 ... n - 1. |
39 |
|
*/ |
40 |
|
private static ConcurrentSkipListSet<Integer> populatedSet(int n) { |
41 |
< |
ConcurrentSkipListSet<Integer> q = |
42 |
< |
new ConcurrentSkipListSet<Integer>(); |
41 |
> |
ConcurrentSkipListSet<Integer> q = new ConcurrentSkipListSet<>(); |
42 |
|
assertTrue(q.isEmpty()); |
43 |
|
for (int i = n - 1; i >= 0; i -= 2) |
44 |
|
assertTrue(q.add(new Integer(i))); |
525 |
|
} |
526 |
|
|
527 |
|
/** |
528 |
< |
* A deserialized serialized set has same elements |
528 |
> |
* A cloned set equals original |
529 |
> |
*/ |
530 |
> |
public void testClone() { |
531 |
> |
ConcurrentSkipListSet x = populatedSet(SIZE); |
532 |
> |
ConcurrentSkipListSet y = x.clone(); |
533 |
> |
|
534 |
> |
assertNotSame(x, y); |
535 |
> |
assertEquals(x.size(), y.size()); |
536 |
> |
assertEquals(x, y); |
537 |
> |
assertEquals(y, x); |
538 |
> |
while (!x.isEmpty()) { |
539 |
> |
assertFalse(y.isEmpty()); |
540 |
> |
assertEquals(x.pollFirst(), y.pollFirst()); |
541 |
> |
} |
542 |
> |
assertTrue(y.isEmpty()); |
543 |
> |
} |
544 |
> |
|
545 |
> |
/** |
546 |
> |
* A deserialized/reserialized set equals original |
547 |
|
*/ |
548 |
|
public void testSerialization() throws Exception { |
549 |
|
NavigableSet x = populatedSet(SIZE); |