30 |
|
|
31 |
|
/** |
32 |
|
* Returns a new set of given size containing consecutive |
33 |
< |
* Integers 0 ... n. |
33 |
> |
* Integers 0 ... n - 1. |
34 |
|
*/ |
35 |
< |
private NavigableSet<Integer> populatedSet(int n) { |
35 |
> |
private static NavigableSet<Integer> populatedSet(int n) { |
36 |
|
ConcurrentSkipListSet<Integer> q = |
37 |
|
new ConcurrentSkipListSet<Integer>(); |
38 |
|
assertTrue(q.isEmpty()); |
39 |
|
|
40 |
< |
for (int i = n-1; i >= 0; i -= 2) |
40 |
> |
for (int i = n - 1; i >= 0; i -= 2) |
41 |
|
assertTrue(q.add(new Integer(i))); |
42 |
|
for (int i = (n & 1); i < n; i += 2) |
43 |
|
assertTrue(q.add(new Integer(i))); |
52 |
|
/** |
53 |
|
* Returns a new set of first 5 ints. |
54 |
|
*/ |
55 |
< |
private NavigableSet set5() { |
55 |
> |
private static NavigableSet set5() { |
56 |
|
ConcurrentSkipListSet q = new ConcurrentSkipListSet(); |
57 |
|
assertTrue(q.isEmpty()); |
58 |
|
q.add(one); |
70 |
|
/** |
71 |
|
* Returns a new set of first 5 negative ints. |
72 |
|
*/ |
73 |
< |
private NavigableSet dset5() { |
73 |
> |
private static NavigableSet dset5() { |
74 |
|
ConcurrentSkipListSet q = new ConcurrentSkipListSet(); |
75 |
|
assertTrue(q.isEmpty()); |
76 |
|
q.add(m1); |
244 |
|
assertTrue(q.contains(i)); |
245 |
|
assertTrue(q.remove(i)); |
246 |
|
assertFalse(q.contains(i)); |
247 |
< |
assertTrue(q.contains(i-1)); |
247 |
> |
assertTrue(q.contains(i - 1)); |
248 |
|
} |
249 |
|
for (int i = 0; i < SIZE; i += 2) { |
250 |
|
assertTrue(q.contains(i)); |
251 |
|
assertTrue(q.remove(i)); |
252 |
|
assertFalse(q.contains(i)); |
253 |
< |
assertFalse(q.remove(i+1)); |
254 |
< |
assertFalse(q.contains(i+1)); |
253 |
> |
assertFalse(q.remove(i + 1)); |
254 |
> |
assertFalse(q.contains(i + 1)); |
255 |
|
} |
256 |
|
assertTrue(q.isEmpty()); |
257 |
|
} |
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); |
741 |
|
} |
742 |
|
for (int i = 0; i < SIZE; i += 2 ) { |
743 |
|
assertTrue(q.remove(new Integer(i))); |
744 |
< |
assertFalse(q.remove(new Integer(i+1))); |
744 |
> |
assertFalse(q.remove(new Integer(i + 1))); |
745 |
|
} |
746 |
|
assertTrue(q.isEmpty()); |
747 |
|
} |
975 |
|
} |
976 |
|
|
977 |
|
/** |
978 |
< |
* A deserialized serialized set has same elements |
978 |
> |
* A deserialized/reserialized set equals original |
979 |
|
*/ |
980 |
|
public void testDescendingSerialization() throws Exception { |
981 |
|
NavigableSet x = dset5(); |