7 |
|
*/ |
8 |
|
|
9 |
|
import junit.framework.*; |
10 |
+ |
import java.util.ArrayList; |
11 |
|
import java.util.Arrays; |
12 |
|
import java.util.Collection; |
13 |
|
import java.util.Collections; |
174 |
|
* set in insertion order |
175 |
|
*/ |
176 |
|
public void testIterator() { |
177 |
< |
Set empty = new CopyOnWriteArraySet(); |
177 |
> |
Collection empty = new CopyOnWriteArraySet(); |
178 |
|
assertFalse(empty.iterator().hasNext()); |
179 |
|
try { |
180 |
|
empty.iterator().next(); |
216 |
|
* toString holds toString of elements |
217 |
|
*/ |
218 |
|
public void testToString() { |
219 |
+ |
assertEquals("[]", new CopyOnWriteArraySet().toString()); |
220 |
|
CopyOnWriteArraySet full = populatedSet(3); |
221 |
|
String s = full.toString(); |
222 |
< |
for (int i = 0; i < 3; ++i) { |
222 |
> |
for (int i = 0; i < 3; ++i) |
223 |
|
assertTrue(s.contains(String.valueOf(i))); |
224 |
< |
} |
224 |
> |
assertEquals(new ArrayList(full).toString(), |
225 |
> |
full.toString()); |
226 |
|
} |
227 |
|
|
228 |
|
/** |
348 |
|
assertEquals(x, y); |
349 |
|
assertEquals(y, x); |
350 |
|
} |
351 |
+ |
|
352 |
+ |
/** |
353 |
+ |
* addAll is idempotent |
354 |
+ |
*/ |
355 |
+ |
public void testAddAll_idempotent() throws Exception { |
356 |
+ |
Set x = populatedSet(SIZE); |
357 |
+ |
Set y = new CopyOnWriteArraySet(x); |
358 |
+ |
y.addAll(x); |
359 |
+ |
assertEquals(x, y); |
360 |
+ |
assertEquals(y, x); |
361 |
+ |
} |
362 |
|
|
363 |
|
} |