Created
July 21, 2012 18:06
-
-
Save anonymous/3156604 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * To change this template, choose Tools | Templates | |
| * and open the template in the editor. | |
| */ | |
| package edu.uga.cs1302.mp3files; | |
| import java.util.ListIterator; | |
| import junit.framework.TestCase; | |
| import org.junit.AfterClass; | |
| import org.junit.BeforeClass; | |
| import org.junit.Test; | |
| public class SimpleArrayListTester extends TestCase { | |
| public SimpleArrayList<String> listTest = new SimpleArrayList<>(); | |
| ListIterator<String> listIter; | |
| int count; | |
| @BeforeClass | |
| public void setUpClass() throws Exception{ | |
| super.setUp(); | |
| listTest.add("a"); | |
| listTest.add("b"); | |
| listTest.add("c"); | |
| listTest.add("d"); | |
| listTest.add("e"); | |
| listTest.add("f"); | |
| count = 6; | |
| } | |
| @AfterClass | |
| public void tearDownClass() throws Exception{ | |
| super.tearDown(); | |
| listTest=null; | |
| listIter=null; | |
| } | |
| @Test | |
| public void testHasNext(){ | |
| listIter = listTest.listIterator(0); | |
| assertTrue(listIter.hasNext()); | |
| listIter = listTest.listIterator(count-1); | |
| assertTrue(!listIter.hasNext()); | |
| } | |
| @Test | |
| public void testNextIndex(){ | |
| listIter = listTest.listIterator(0); | |
| assertEquals(listIter.nextIndex(),1); | |
| } | |
| @Test | |
| public void testNext(){ | |
| listIter = listTest.listIterator(0); | |
| assertEquals(listIter.next(), "b"); | |
| } | |
| @Test | |
| public void testHasPrevious(){ | |
| listIter = listTest.listIterator(4); | |
| assertTrue(listIter.hasPrevious()); | |
| listIter = listTest.listIterator(0); | |
| assertTrue(!listIter.hasPrevious()); | |
| } | |
| @Test | |
| public void testPreviousIndex(){ | |
| listIter =listTest.listIterator(4); | |
| assertEquals(listIter.previousIndex(), 3); | |
| } | |
| @Test | |
| public void testPrevious(){ | |
| listIter = listTest.listIterator(4); | |
| assertEquals(listIter.previous(), "d"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment