Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class IterativeLinkListTest {
- private static final String FRENCH_POSTMALONE = "Zed Yun Pavarotti";
- private static final String WHITE_THUG = "47ter";
- private static final String SAD_RAPPER = "Tsew the Kid";
- private IterativeLinkedList<String> rapperToListen;
- @Before
- public void setUp() {
- this.rapperToListen = new IterativeLinkedList<String>(SAD_RAPPER,
- new IterativeLinkedList<String>(WHITE_THUG,
- new IterativeLinkedList<String>(FRENCH_POSTMALONE)));
- }
- @Test
- public void onConstruct_nextValue_shouldBeNull() throws Exception {
- IterativeLinkedList<String> nextIsNull = new IterativeLinkedList<String>("alone");
- assertNull(nextIsNull.getNext());
- }
- @Test
- public void onConstruct_nextValue_shouldExist() throws Exception {
- assertNotNull(rapperToListen.getNext());
- }
- @Test
- public void gettingFirstValue_shouldBeEqualsTo_beginningOfList() throws Exception {
- assertEquals(SAD_RAPPER, rapperToListen.first());
- }
- @Test
- public void gettingSecondValue_shouldBeEqualsTo_nextOfList() throws Exception {
- assertEquals(WHITE_THUG, rapperToListen.second());
- }
- @Test
- public void listLenghth_shouldBeEqualsTo_numberOfAllElements() throws Exception {
- assertEquals(3, rapperToListen.size());
- }
- @Test
- public void lastElement_shouldBe_lastAddElementInList() throws Exception {
- assertEquals(FRENCH_POSTMALONE, rapperToListen.last());
- }
- @Test
- public void getArbitraryElement_shouldReturn_valueForIndexInList() throws Exception {
- assertEquals(WHITE_THUG, rapperToListen.get(1));
- }
- @Test
- public void insertElementAtStart_shouldChange_valueForFirstIndex() throws Exception {
- rapperToListen.insertFirst("Dinos");
- assertEquals("Dinos", rapperToListen.first());
- assertEquals(4, rapperToListen.size());
- }
- @Test
- public void insertElementAtEnd_shouldChange_valueForLastIndex() throws Exception {
- rapperToListen.insertLast("Fianso");
- assertEquals("Fianso", rapperToListen.last());
- assertEquals(4, rapperToListen.size());
- }
- @Test
- public void insertElementAtArbitraryIndex_shouldChange_valueForChoosenIndex() throws Exception {
- rapperToListen.insert("Columbine", 1);
- assertEquals("Columbine", rapperToListen.second());
- assertEquals(4, rapperToListen.size());
- }
- @Test
- public void deleteElementByValue_shouldRemove_listElementAtCorrectIndex() throws Exception {
- rapperToListen.delete(SAD_RAPPER);
- assertEquals(WHITE_THUG, rapperToListen.first());
- assertEquals(2, rapperToListen.size());
- }
- @Test
- public void deleteElementByIndex_shouldRemove_listElementAtCorrectIndex() throws Exception {
- rapperToListen.delete(2);
- assertEquals(WHITE_THUG, rapperToListen.last());
- assertEquals(2, rapperToListen.size());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement