33 |
|
* Returns a new set of given size containing consecutive |
34 |
|
* Integers 0 ... n - 1. |
35 |
|
*/ |
36 |
< |
private NavigableSet<Integer> populatedSet(int n) { |
36 |
> |
private static NavigableSet<Integer> populatedSet(int n) { |
37 |
|
TreeSet<Integer> q = new TreeSet<>(); |
38 |
|
assertTrue(q.isEmpty()); |
39 |
|
|
52 |
|
/** |
53 |
|
* Returns a new set of first 5 ints. |
54 |
|
*/ |
55 |
< |
private NavigableSet set5() { |
55 |
> |
private static NavigableSet set5() { |
56 |
|
TreeSet q = new TreeSet(); |
57 |
|
assertTrue(q.isEmpty()); |
58 |
|
q.add(one); |
67 |
|
return s; |
68 |
|
} |
69 |
|
|
70 |
< |
private NavigableSet dset5() { |
70 |
> |
private static NavigableSet dset5() { |
71 |
|
TreeSet q = new TreeSet(); |
72 |
|
assertTrue(q.isEmpty()); |
73 |
|
q.add(m1); |
405 |
|
*/ |
406 |
|
public void testToArray() { |
407 |
|
NavigableSet q = populatedSet(SIZE); |
408 |
< |
Object[] o = q.toArray(); |
409 |
< |
for (int i = 0; i < o.length; i++) |
410 |
< |
assertSame(o[i], q.pollFirst()); |
408 |
> |
Object[] a = q.toArray(); |
409 |
> |
assertSame(Object[].class, a.getClass()); |
410 |
> |
for (Object o : a) |
411 |
> |
assertSame(o, q.pollFirst()); |
412 |
> |
assertTrue(q.isEmpty()); |
413 |
|
} |
414 |
|
|
415 |
|
/** |
420 |
|
Integer[] ints = new Integer[SIZE]; |
421 |
|
Integer[] array = q.toArray(ints); |
422 |
|
assertSame(ints, array); |
423 |
< |
for (int i = 0; i < ints.length; i++) |
424 |
< |
assertSame(ints[i], q.pollFirst()); |
423 |
> |
for (Integer o : ints) |
424 |
> |
assertSame(o, q.pollFirst()); |
425 |
> |
assertTrue(q.isEmpty()); |
426 |
|
} |
427 |
|
|
428 |
|
/** |
476 |
|
} |
477 |
|
|
478 |
|
/** |
479 |
< |
* A deserialized serialized set has same elements |
479 |
> |
* A deserialized/reserialized set equals original |
480 |
|
*/ |
481 |
|
public void testSerialization() throws Exception { |
482 |
|
NavigableSet x = populatedSet(SIZE); |
964 |
|
} |
965 |
|
|
966 |
|
/** |
967 |
< |
* A deserialized serialized set has same elements |
967 |
> |
* A deserialized/reserialized set equals original |
968 |
|
*/ |
969 |
|
public void testDescendingSerialization() throws Exception { |
970 |
|
NavigableSet x = dset5(); |