Code example for ArrayDeque

Methods: addpeeksizetoArray

0
 
    /** 
     * @tests {@link java.util.ArrayDeque#toArray()} 
     */ 
    public void test_toArray() throws Exception { 
        assertEquals(0, testQue.toArray().length);
        assertTrue(testQue.add(testObjOne));
        assertTrue(testQue.add(testObjTwo));
        assertTrue(testQue.add(testObjOne));
        assertTrue(testQue.add(testObjThree));
        assertTrue(testQue.add(testObjLast));
        Object[] result = testQue.toArray();
        assertEquals(5, testQue.size());
        assertEquals(testObjOne, result[0]);
        assertEquals(testObjTwo, result[1]);
        assertEquals(testObjOne, result[2]);
        assertEquals(testObjThree, result[3]);
        assertEquals(testObjLast, result[4]);
        // change in array do not affect ArrayDeque 
        result[0] = null;
        assertEquals(5, testQue.size());
        assertEquals(testObjOne, testQue.peek());
    } 
 
    /** 
     * @tests {@link java.util.ArrayDeque#toArray(Object[])} 
     */ 
Stop searching for code, let great code find you!  Add Codota to your java IDE