Code example for ArrayDeque

Methods: add, peekFirst, peekLast

0
 
    /** 
     * @tests {@link java.util.ArrayDeque#add(Object)} 
     */ 
    public void test_add() throws Exception { 
        assertTrue(testQue.add(testObjOne));
        assertTrue(testQue.add(testObjTwo));
        assertTrue(testQue.add(testObjOne));
        assertTrue(testQue.add(testObjThree));
        assertEquals(testObjOne, testQue.peekFirst());
        assertEquals(testObjThree, testQue.peekLast());
        try { 
            testQue.add(null);
            fail("Should throw NullPointerException");
        } catch (NullPointerException e) {
            // expected 
        } 
    } 
 
    /** 
     * @tests {@link java.util.ArrayDeque#offer(Object)}