Package chapter25

Examples of chapter25.MyLinkedList$Node


     * <code>size()</code> and
     * <code>add(Object o)</code> methods.
     */
    @Test
    public void testMyList_Size() {
        myList = new MyLinkedList();
        assertEquals(0, myList.size());
        for (int i = 0; i < 100; i++) {
            myList.add("newObject_#" + i);
        }
        assertEquals(100, myList.size());
View Full Code Here


     * <code>add(Object o)</code> and
     * <code>get(int index)</code> methods.
     */
    @Test
    public void testMyList_Add_Get() {
        myList = new MyLinkedList();
        myList.add("1");
        myList.add("2");
        myList.add("3");
        myList.add(0, "0.1");
        assertArrayEquals(new String[]{"0.1", "1", "2", "3"}, myList.toArray());
View Full Code Here

     * <code>get(int index)</code>,
     * <code>size()</code> methods.
     */
    @Test
    public void testMyList_AddAll() {
        myList = new MyLinkedList();
        myList.addAll(new String[]{"1", "2", "3"});
        assertEquals("2", myList.get(1));

        myList.addAll(1, new String[]{"1.1", "1.2", "1.3"});
        assertEquals("1.3", myList.get(3));
View Full Code Here

     * <code>get(int index)</code>,
     * <code>set(int index, Object o)</code> methods.
     */
    @Test
    public void testMyList_Get_Remove_Set() {
        myList = new MyLinkedList();
        for (int i = 0; i < 99; i++) {
            myList.add("newElement_" + i);
        }
        assertEquals("newElement_86", myList.get(86));
        assertEquals("newElement_0", myList.remove(0));
View Full Code Here

     * <code>add(Object o)</code>,
     * <code>indexOf(Object o)</code> methods.
     */
    @Test
    public void testMyList_IndexOf() {
        myList = new MyLinkedList();
        for (int i = 0; i < 99; i++) {
            myList.add("newElement_" + i);
        }
        assertEquals(86, myList.indexOf("newElement_86"));
        myList.add("LAST ONE");
View Full Code Here

     * <code>toArray()</code>,
     * <code>set(int index, Object o)</code> methods.
     */
    @Test
    public void testMyList_ToArray() {
        myList = new MyLinkedList();
        Object[] testStrings = new Object[]{"1", "2", "3", "4", "5"};
        for (Object string : testStrings) {
            myList.add(string);
        }
        assertArrayEquals(testStrings, myList.toArray());
View Full Code Here

        assertArrayEquals(testStrings, myList.toArray());
    }

    @Test(expected = IllegalArgumentException.class)
    public void testMyList_Illegal1() {
        myList = new MyLinkedList();
        myList.set(-1, "fail");
    }
View Full Code Here

        myList.set(-1, "fail");
    }

    @Test(expected = IllegalArgumentException.class)
    public void testMyList_Illegal2() {
        myList = new MyLinkedList();
        myList.add(42, "fail");
    }
View Full Code Here

        myList.add(42, "fail");
    }

    @Test(expected = NullPointerException.class)
    public void testMyList_Illegal3() {
        myList = new MyLinkedList();
        myList.addAll(null);
    }
View Full Code Here

        myList.addAll(null);
    }

    @Test(expected = IllegalArgumentException.class)
    public void testMyList_Illegal4() {
        myList = new MyLinkedList();
        myList.addAll(42, new String[]{"fail"});
    }
View Full Code Here

TOP

Related Classes of chapter25.MyLinkedList$Node

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.