2 |
|
* Written by Doug Lea with assistance from members of JCP JSR-166 |
3 |
|
* Expert Group and released to the public domain, as explained at |
4 |
|
* http://creativecommons.org/licenses/publicdomain |
5 |
< |
* Other contributors include Andrew Wright, Jeffrey Hayes, |
6 |
< |
* Pat Fisher, Mike Judd. |
5 |
> |
* Other contributors include Andrew Wright, Jeffrey Hayes, |
6 |
> |
* Pat Fisher, Mike Judd. |
7 |
|
*/ |
8 |
|
|
9 |
|
import junit.framework.*; |
14 |
|
import java.io.*; |
15 |
|
|
16 |
|
public class ParallelArrayAsListTest extends JSR166TestCase{ |
17 |
< |
|
17 |
> |
|
18 |
|
public static void main(String[] args) { |
19 |
< |
junit.textui.TestRunner.run (suite()); |
19 |
> |
junit.textui.TestRunner.run (suite()); |
20 |
|
} |
21 |
|
|
22 |
|
public static Test suite() { |
26 |
|
static List populatedArray(int n){ |
27 |
|
List a = ParallelArray.createEmpty(n, Object.class, ParallelArray.defaultExecutor()).asList(); |
28 |
|
assertTrue(a.isEmpty()); |
29 |
< |
for (int i = 0; i < n; ++i) |
29 |
> |
for (int i = 0; i < n; ++i) |
30 |
|
a.add(new Integer(i)); |
31 |
|
assertFalse(a.isEmpty()); |
32 |
|
assertEquals(n, a.size()); |
56 |
|
for (int i = 0; i < SIZE-1; ++i) |
57 |
|
ints[i] = new Integer(i); |
58 |
|
List a = ParallelArray.createUsingHandoff(ints, ParallelArray.defaultExecutor()).asList(); |
59 |
< |
for (int i = 0; i < SIZE; ++i) |
59 |
> |
for (int i = 0; i < SIZE; ++i) |
60 |
|
assertEquals(ints[i], a.get(i)); |
61 |
|
} |
62 |
< |
|
62 |
> |
|
63 |
|
|
64 |
|
/** |
65 |
|
* addAll adds each element from the given collection |
128 |
|
assertEquals(a.hashCode(), b.hashCode()); |
129 |
|
} |
130 |
|
|
131 |
< |
|
131 |
> |
|
132 |
|
/** |
133 |
|
* containsAll returns true for collection with subset of elements |
134 |
|
*/ |
170 |
|
} |
171 |
|
|
172 |
|
/** |
173 |
< |
* iterator() returns an iterator containing the elements of the list |
173 |
> |
* iterator() returns an iterator containing the elements of the list |
174 |
|
*/ |
175 |
|
public void testIterator() { |
176 |
|
List full = populatedArray(SIZE); |
202 |
|
for (int i = 0; i < 3; ++i) { |
203 |
|
assertTrue(s.indexOf(String.valueOf(i)) >= 0); |
204 |
|
} |
205 |
< |
} |
205 |
> |
} |
206 |
|
|
207 |
|
/** |
208 |
|
* lastIndexOf returns the index for the given object |
355 |
|
shouldThrow(); |
356 |
|
} catch(IndexOutOfBoundsException e){} |
357 |
|
} |
358 |
< |
|
358 |
> |
|
359 |
|
/** |
360 |
|
* get throws an IndexOutOfBoundsException on a too high index |
361 |
|
*/ |
379 |
|
shouldThrow(); |
380 |
|
} catch(IndexOutOfBoundsException e){} |
381 |
|
} |
382 |
< |
|
382 |
> |
|
383 |
|
/** |
384 |
|
* set throws an IndexOutOfBoundsException on a too high index |
385 |
|
*/ |
403 |
|
shouldThrow(); |
404 |
|
} catch(IndexOutOfBoundsException e){} |
405 |
|
} |
406 |
< |
|
406 |
> |
|
407 |
|
/** |
408 |
|
* add throws an IndexOutOfBoundsException on a too high index |
409 |
|
*/ |
440 |
|
shouldThrow(); |
441 |
|
} catch(IndexOutOfBoundsException e){} |
442 |
|
} |
443 |
< |
|
443 |
> |
|
444 |
|
/** |
445 |
|
* addAll throws an IndexOutOfBoundsException on a negative index |
446 |
|
*/ |
451 |
|
shouldThrow(); |
452 |
|
} catch(IndexOutOfBoundsException e){} |
453 |
|
} |
454 |
< |
|
454 |
> |
|
455 |
|
/** |
456 |
|
* addAll throws an IndexOutOfBoundsException on a too high index |
457 |
|
*/ |
515 |
|
|
516 |
|
/** |
517 |
|
* subList throws IndexOutOfBoundsException when the second index |
518 |
< |
* is lower then the first |
518 |
> |
* is lower then the first |
519 |
|
*/ |
520 |
|
public void testSubList3_IndexOutOfBoundsException() { |
521 |
|
try { |
526 |
|
} catch(IndexOutOfBoundsException e){} |
527 |
|
} |
528 |
|
|
529 |
< |
|
529 |
> |
|
530 |
|
} |