ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/extra166y/ParallelArrayAsListTest.java
(Generate patch)

Comparing jsr166/src/test/extra166y/ParallelArrayAsListTest.java (file contents):
Revision 1.1 by dl, Sun Nov 1 22:00:35 2009 UTC vs.
Revision 1.3 by jsr166, Mon Nov 16 04:57:09 2009 UTC

# Line 2 | Line 2
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.*;
# Line 14 | Line 14 | import extra166y.*;
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() {
# Line 26 | Line 26 | public class ParallelArrayAsListTest ext
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());
# Line 56 | Line 56 | public class ParallelArrayAsListTest ext
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
# Line 128 | Line 128 | public class ParallelArrayAsListTest ext
128          assertEquals(a.hashCode(), b.hashCode());
129      }
130  
131 <    
131 >
132      /**
133       *   containsAll returns true for collection with subset of elements
134       */
# Line 170 | Line 170 | public class ParallelArrayAsListTest ext
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);
177          Iterator i = full.iterator();
178          int j;
179 <        for(j = 0; i.hasNext(); j++)
179 >        for (j = 0; i.hasNext(); j++)
180              assertEquals(j, ((Integer)i.next()).intValue());
181          assertEquals(SIZE, j);
182      }
# Line 202 | Line 202 | public class ParallelArrayAsListTest ext
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
# Line 222 | Line 222 | public class ParallelArrayAsListTest ext
222          List full = populatedArray(SIZE);
223          ListIterator i = full.listIterator();
224          int j;
225 <        for(j = 0; i.hasNext(); j++)
225 >        for (j = 0; i.hasNext(); j++)
226              assertEquals(j, ((Integer)i.next()).intValue());
227          assertEquals(SIZE, j);
228      }
# Line 234 | Line 234 | public class ParallelArrayAsListTest ext
234          List full = populatedArray(3);
235          ListIterator i = full.listIterator(1);
236          int j;
237 <        for(j = 0; i.hasNext(); j++)
237 >        for (j = 0; i.hasNext(); j++)
238              assertEquals(j+1, ((Integer)i.next()).intValue());
239          assertEquals(2, j);
240      }
# Line 312 | Line 312 | public class ParallelArrayAsListTest ext
312      public void testSubList() {
313          List a = populatedArray(10);
314          assertTrue(a.subList(1,1).isEmpty());
315 <        for(int j = 0; j < 9; ++j) {
316 <            for(int i = j ; i < 10; ++i) {
315 >        for (int j = 0; j < 9; ++j) {
316 >            for (int i = j ; i < 10; ++i) {
317                  List b = a.subList(j,i);
318 <                for(int k = j; k < i; ++k) {
318 >                for (int k = j; k < i; ++k) {
319                      assertEquals(new Integer(k), b.get(k-j));
320                  }
321              }
# Line 342 | Line 342 | public class ParallelArrayAsListTest ext
342              c.add("asdadasd");
343              c.toArray(new Long[5]);
344              shouldThrow();
345 <        } catch(ArrayStoreException e){}
345 >        } catch (ArrayStoreException e){}
346      }
347  
348      /**
# Line 353 | Line 353 | public class ParallelArrayAsListTest ext
353              List c = emptyArray();
354              c.get(-1);
355              shouldThrow();
356 <        } catch(IndexOutOfBoundsException e){}
356 >        } catch (IndexOutOfBoundsException e){}
357      }
358 <    
358 >
359      /**
360       *   get throws an IndexOutOfBoundsException on a too high index
361       */
# Line 366 | Line 366 | public class ParallelArrayAsListTest ext
366              c.add("asdad");
367              c.get(100);
368              shouldThrow();
369 <        } catch(IndexOutOfBoundsException e){}
369 >        } catch (IndexOutOfBoundsException e){}
370      }
371  
372      /**
# Line 377 | Line 377 | public class ParallelArrayAsListTest ext
377              List c = emptyArray();
378              c.set(-1,"qwerty");
379              shouldThrow();
380 <        } catch(IndexOutOfBoundsException e){}
380 >        } catch (IndexOutOfBoundsException e){}
381      }
382 <    
382 >
383      /**
384       *   set throws an IndexOutOfBoundsException on a too high index
385       */
# Line 390 | Line 390 | public class ParallelArrayAsListTest ext
390              c.add("asdad");
391              c.set(100, "qwerty");
392              shouldThrow();
393 <        } catch(IndexOutOfBoundsException e){}
393 >        } catch (IndexOutOfBoundsException e){}
394      }
395  
396      /**
# Line 401 | Line 401 | public class ParallelArrayAsListTest ext
401              List c = emptyArray();
402              c.add(-1,"qwerty");
403              shouldThrow();
404 <        } catch(IndexOutOfBoundsException e){}
404 >        } catch (IndexOutOfBoundsException e){}
405      }
406 <    
406 >
407      /**
408       *   add throws an IndexOutOfBoundsException on a too high index
409       */
# Line 414 | Line 414 | public class ParallelArrayAsListTest ext
414              c.add("asdasdasd");
415              c.add(100, "qwerty");
416              shouldThrow();
417 <        } catch(IndexOutOfBoundsException e){}
417 >        } catch (IndexOutOfBoundsException e){}
418      }
419  
420      /**
# Line 425 | Line 425 | public class ParallelArrayAsListTest ext
425              List c = emptyArray();
426              c.remove(-1);
427              shouldThrow();
428 <        } catch(IndexOutOfBoundsException e){}
428 >        } catch (IndexOutOfBoundsException e){}
429      }
430  
431      /**
# Line 438 | Line 438 | public class ParallelArrayAsListTest ext
438              c.add("adasdasd");
439              c.remove(100);
440              shouldThrow();
441 <        } catch(IndexOutOfBoundsException e){}
441 >        } catch (IndexOutOfBoundsException e){}
442      }
443 <    
443 >
444      /**
445       *   addAll throws an IndexOutOfBoundsException on a negative index
446       */
# Line 449 | Line 449 | public class ParallelArrayAsListTest ext
449              List c = emptyArray();
450              c.addAll(-1,new LinkedList());
451              shouldThrow();
452 <        } catch(IndexOutOfBoundsException e){}
452 >        } catch (IndexOutOfBoundsException e){}
453      }
454 <    
454 >
455      /**
456       *   addAll throws an IndexOutOfBoundsException on a too high index
457       */
# Line 462 | Line 462 | public class ParallelArrayAsListTest ext
462              c.add("asdasdasd");
463              c.addAll(100, new LinkedList());
464              shouldThrow();
465 <        } catch(IndexOutOfBoundsException e){}
465 >        } catch (IndexOutOfBoundsException e){}
466      }
467  
468      /**
# Line 473 | Line 473 | public class ParallelArrayAsListTest ext
473              List c = emptyArray();
474              c.listIterator(-1);
475              shouldThrow();
476 <        } catch(IndexOutOfBoundsException e){}
476 >        } catch (IndexOutOfBoundsException e){}
477      }
478  
479      /**
# Line 486 | Line 486 | public class ParallelArrayAsListTest ext
486              c.add("asdasdas");
487              c.listIterator(100);
488              shouldThrow();
489 <        } catch(IndexOutOfBoundsException e){}
489 >        } catch (IndexOutOfBoundsException e){}
490      }
491  
492      /**
# Line 498 | Line 498 | public class ParallelArrayAsListTest ext
498              c.subList(-1,100);
499  
500              shouldThrow();
501 <        } catch(IndexOutOfBoundsException e){}
501 >        } catch (IndexOutOfBoundsException e){}
502      }
503  
504      /**
# Line 510 | Line 510 | public class ParallelArrayAsListTest ext
510              c.add("asdasd");
511              c.subList(1,100);
512              shouldThrow();
513 <        } catch(IndexOutOfBoundsException e){}
513 >        } catch (IndexOutOfBoundsException e){}
514      }
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 {
# Line 523 | Line 523 | public class ParallelArrayAsListTest ext
523              c.subList(3,1);
524  
525              shouldThrow();
526 <        } catch(IndexOutOfBoundsException e){}
526 >        } catch (IndexOutOfBoundsException e){}
527      }
528  
529 <    
529 >
530   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines