--- jsr166/src/test/tck/CopyOnWriteArrayListTest.java 2003/12/27 19:26:43 1.6 +++ jsr166/src/test/tck/CopyOnWriteArrayListTest.java 2009/11/16 04:57:10 1.9 @@ -2,8 +2,8 @@ * Written by Doug Lea with assistance from members of JCP JSR-166 * Expert Group and released to the public domain, as explained at * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. + * Other contributors include Andrew Wright, Jeffrey Hayes, + * Pat Fisher, Mike Judd. */ import junit.framework.*; @@ -12,9 +12,9 @@ import java.util.concurrent.*; import java.io.*; public class CopyOnWriteArrayListTest extends JSR166TestCase{ - + public static void main(String[] args) { - junit.textui.TestRunner.run (suite()); + junit.textui.TestRunner.run (suite()); } public static Test suite() { @@ -24,7 +24,7 @@ public class CopyOnWriteArrayListTest ex static CopyOnWriteArrayList populatedArray(int n){ CopyOnWriteArrayList a = new CopyOnWriteArrayList(); assertTrue(a.isEmpty()); - for (int i = 0; i < n; ++i) + for (int i = 0; i < n; ++i) a.add(new Integer(i)); assertFalse(a.isEmpty()); assertEquals(n, a.size()); @@ -48,7 +48,7 @@ public class CopyOnWriteArrayListTest ex for (int i = 0; i < SIZE-1; ++i) ints[i] = new Integer(i); CopyOnWriteArrayList a = new CopyOnWriteArrayList(ints); - for (int i = 0; i < SIZE; ++i) + for (int i = 0; i < SIZE; ++i) assertEquals(ints[i], a.get(i)); } @@ -60,10 +60,10 @@ public class CopyOnWriteArrayListTest ex for (int i = 0; i < SIZE-1; ++i) ints[i] = new Integer(i); CopyOnWriteArrayList a = new CopyOnWriteArrayList(Arrays.asList(ints)); - for (int i = 0; i < SIZE; ++i) + for (int i = 0; i < SIZE; ++i) assertEquals(ints[i], a.get(i)); } - + /** * addAll adds each element from the given collection @@ -141,7 +141,7 @@ public class CopyOnWriteArrayListTest ex } /** - * adding at an index places it in the indindicated index + * adding at an index places it in the indicated index */ public void testAddIndex() { CopyOnWriteArrayList full = populatedArray(3); @@ -174,7 +174,7 @@ public class CopyOnWriteArrayListTest ex assertEquals(a.hashCode(), b.hashCode()); } - + /** * containsAll returns true for collection with subset of elements */ @@ -226,13 +226,13 @@ public class CopyOnWriteArrayListTest ex } /** - * iterator() returns an iterator containing the elements of the list + * iterator() returns an iterator containing the elements of the list */ public void testIterator() { CopyOnWriteArrayList full = populatedArray(SIZE); Iterator i = full.iterator(); int j; - for(j = 0; i.hasNext(); j++) + for (j = 0; i.hasNext(); j++) assertEquals(j, ((Integer)i.next()).intValue()); assertEquals(SIZE, j); } @@ -260,7 +260,7 @@ public class CopyOnWriteArrayListTest ex for (int i = 0; i < 3; ++i) { assertTrue(s.indexOf(String.valueOf(i)) >= 0); } - } + } /** * lastIndexOf returns the index for the given object @@ -291,7 +291,7 @@ public class CopyOnWriteArrayListTest ex CopyOnWriteArrayList full = populatedArray(SIZE); ListIterator i = full.listIterator(); int j; - for(j = 0; i.hasNext(); j++) + for (j = 0; i.hasNext(); j++) assertEquals(j, ((Integer)i.next()).intValue()); assertEquals(SIZE, j); } @@ -303,7 +303,7 @@ public class CopyOnWriteArrayListTest ex CopyOnWriteArrayList full = populatedArray(3); ListIterator i = full.listIterator(1); int j; - for(j = 0; i.hasNext(); j++) + for (j = 0; i.hasNext(); j++) assertEquals(j+1, ((Integer)i.next()).intValue()); assertEquals(2, j); } @@ -381,10 +381,10 @@ public class CopyOnWriteArrayListTest ex public void testSubList() { CopyOnWriteArrayList a = populatedArray(10); assertTrue(a.subList(1,1).isEmpty()); - for(int j = 0; j < 9; ++j) { - for(int i = j ; i < 10; ++i) { + for (int j = 0; j < 9; ++j) { + for (int i = j ; i < 10; ++i) { List b = a.subList(j,i); - for(int k = j; k < i; ++k) { + for (int k = j; k < i; ++k) { assertEquals(new Integer(k), b.get(k-j)); } } @@ -411,7 +411,7 @@ public class CopyOnWriteArrayListTest ex c.add("asdadasd"); c.toArray(new Long[5]); shouldThrow(); - } catch(ArrayStoreException e){} + } catch (ArrayStoreException e){} } /** @@ -422,9 +422,9 @@ public class CopyOnWriteArrayListTest ex CopyOnWriteArrayList c = new CopyOnWriteArrayList(); c.get(-1); shouldThrow(); - } catch(IndexOutOfBoundsException e){} + } catch (IndexOutOfBoundsException e){} } - + /** * get throws an IndexOutOfBoundsException on a too high index */ @@ -435,7 +435,7 @@ public class CopyOnWriteArrayListTest ex c.add("asdad"); c.get(100); shouldThrow(); - } catch(IndexOutOfBoundsException e){} + } catch (IndexOutOfBoundsException e){} } /** @@ -446,9 +446,9 @@ public class CopyOnWriteArrayListTest ex CopyOnWriteArrayList c = new CopyOnWriteArrayList(); c.set(-1,"qwerty"); shouldThrow(); - } catch(IndexOutOfBoundsException e){} + } catch (IndexOutOfBoundsException e){} } - + /** * set throws an IndexOutOfBoundsException on a too high index */ @@ -459,7 +459,7 @@ public class CopyOnWriteArrayListTest ex c.add("asdad"); c.set(100, "qwerty"); shouldThrow(); - } catch(IndexOutOfBoundsException e){} + } catch (IndexOutOfBoundsException e){} } /** @@ -470,9 +470,9 @@ public class CopyOnWriteArrayListTest ex CopyOnWriteArrayList c = new CopyOnWriteArrayList(); c.add(-1,"qwerty"); shouldThrow(); - } catch(IndexOutOfBoundsException e){} + } catch (IndexOutOfBoundsException e){} } - + /** * add throws an IndexOutOfBoundsException on a too high index */ @@ -483,7 +483,7 @@ public class CopyOnWriteArrayListTest ex c.add("asdasdasd"); c.add(100, "qwerty"); shouldThrow(); - } catch(IndexOutOfBoundsException e){} + } catch (IndexOutOfBoundsException e){} } /** @@ -494,7 +494,7 @@ public class CopyOnWriteArrayListTest ex CopyOnWriteArrayList c = new CopyOnWriteArrayList(); c.remove(-1); shouldThrow(); - } catch(IndexOutOfBoundsException e){} + } catch (IndexOutOfBoundsException e){} } /** @@ -507,9 +507,9 @@ public class CopyOnWriteArrayListTest ex c.add("adasdasd"); c.remove(100); shouldThrow(); - } catch(IndexOutOfBoundsException e){} + } catch (IndexOutOfBoundsException e){} } - + /** * addAll throws an IndexOutOfBoundsException on a negative index */ @@ -518,9 +518,9 @@ public class CopyOnWriteArrayListTest ex CopyOnWriteArrayList c = new CopyOnWriteArrayList(); c.addAll(-1,new LinkedList()); shouldThrow(); - } catch(IndexOutOfBoundsException e){} + } catch (IndexOutOfBoundsException e){} } - + /** * addAll throws an IndexOutOfBoundsException on a too high index */ @@ -531,7 +531,7 @@ public class CopyOnWriteArrayListTest ex c.add("asdasdasd"); c.addAll(100, new LinkedList()); shouldThrow(); - } catch(IndexOutOfBoundsException e){} + } catch (IndexOutOfBoundsException e){} } /** @@ -542,7 +542,7 @@ public class CopyOnWriteArrayListTest ex CopyOnWriteArrayList c = new CopyOnWriteArrayList(); c.listIterator(-1); shouldThrow(); - } catch(IndexOutOfBoundsException e){} + } catch (IndexOutOfBoundsException e){} } /** @@ -555,7 +555,7 @@ public class CopyOnWriteArrayListTest ex c.add("asdasdas"); c.listIterator(100); shouldThrow(); - } catch(IndexOutOfBoundsException e){} + } catch (IndexOutOfBoundsException e){} } /** @@ -567,7 +567,7 @@ public class CopyOnWriteArrayListTest ex c.subList(-1,100); shouldThrow(); - } catch(IndexOutOfBoundsException e){} + } catch (IndexOutOfBoundsException e){} } /** @@ -579,12 +579,12 @@ public class CopyOnWriteArrayListTest ex c.add("asdasd"); c.subList(1,100); shouldThrow(); - } catch(IndexOutOfBoundsException e){} + } catch (IndexOutOfBoundsException e){} } /** * subList throws IndexOutOfBoundsException when the second index - * is lower then the first + * is lower then the first */ public void testSubList3_IndexOutOfBoundsException() { try { @@ -592,7 +592,7 @@ public class CopyOnWriteArrayListTest ex c.subList(3,1); shouldThrow(); - } catch(IndexOutOfBoundsException e){} + } catch (IndexOutOfBoundsException e){} } /** @@ -613,9 +613,9 @@ public class CopyOnWriteArrayListTest ex assertEquals(q.size(), r.size()); assertTrue(q.equals(r)); assertTrue(r.equals(q)); - } catch(Exception e){ + } catch (Exception e){ unexpectedException(); } } - + }