< prev index next >

test/jdk/java/util/concurrent/tck/ArrayDequeTest.java

Print this page
rev 48215 : 8060192: Add default method <A> A[] Collection.toArray(IntFunction<A[]> generator)
Reviewed-by: martin, forax, psandoz


 755         // Provoke wraparound
 756         int added = size * 2;
 757         for (int i = 0; i < added; i++) {
 758             checkToArray(q);
 759             assertEquals((Integer) i, q.poll());
 760             q.addLast(size + i);
 761         }
 762         for (int i = 0; i < size; i++) {
 763             checkToArray(q);
 764             assertEquals((Integer) (added + i), q.poll());
 765         }
 766     }
 767 
 768     /**
 769      * toArray(null) throws NullPointerException
 770      */
 771     public void testToArray_NullArg() {
 772         ArrayDeque l = new ArrayDeque();
 773         l.add(new Object());
 774         try {
 775             l.toArray(null);
 776             shouldThrow();
 777         } catch (NullPointerException success) {}
 778     }
 779 
 780     /**
 781      * toArray(incompatible array type) throws ArrayStoreException
 782      */
 783     public void testToArray_incompatibleArrayType() {
 784         ArrayDeque l = new ArrayDeque();
 785         l.add(new Integer(5));
 786         try {
 787             l.toArray(new String[10]);
 788             shouldThrow();
 789         } catch (ArrayStoreException success) {}
 790         try {
 791             l.toArray(new String[0]);
 792             shouldThrow();
 793         } catch (ArrayStoreException success) {}
 794     }
 795 




 755         // Provoke wraparound
 756         int added = size * 2;
 757         for (int i = 0; i < added; i++) {
 758             checkToArray(q);
 759             assertEquals((Integer) i, q.poll());
 760             q.addLast(size + i);
 761         }
 762         for (int i = 0; i < size; i++) {
 763             checkToArray(q);
 764             assertEquals((Integer) (added + i), q.poll());
 765         }
 766     }
 767 
 768     /**
 769      * toArray(null) throws NullPointerException
 770      */
 771     public void testToArray_NullArg() {
 772         ArrayDeque l = new ArrayDeque();
 773         l.add(new Object());
 774         try {
 775             l.toArray((Object[])null);
 776             shouldThrow();
 777         } catch (NullPointerException success) {}
 778     }
 779 
 780     /**
 781      * toArray(incompatible array type) throws ArrayStoreException
 782      */
 783     public void testToArray_incompatibleArrayType() {
 784         ArrayDeque l = new ArrayDeque();
 785         l.add(new Integer(5));
 786         try {
 787             l.toArray(new String[10]);
 788             shouldThrow();
 789         } catch (ArrayStoreException success) {}
 790         try {
 791             l.toArray(new String[0]);
 792             shouldThrow();
 793         } catch (ArrayStoreException success) {}
 794     }
 795 


< prev index next >