Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.72 KB | None | 0 0
  1. public class IterativeLinkListTest {
  2.    
  3.     private static final String FRENCH_POSTMALONE = "Zed Yun Pavarotti";
  4.     private static final String WHITE_THUG = "47ter";
  5.     private static final String SAD_RAPPER = "Tsew the Kid";
  6.     private IterativeLinkedList<String> rapperToListen;
  7.    
  8.     @Before
  9.     public void setUp() {
  10.         this.rapperToListen = new IterativeLinkedList<String>(SAD_RAPPER,
  11.                 new IterativeLinkedList<String>(WHITE_THUG,
  12.                         new IterativeLinkedList<String>(FRENCH_POSTMALONE)));
  13.     }
  14.  
  15.     @Test
  16.     public void onConstruct_nextValue_shouldBeNull() throws Exception {
  17.         IterativeLinkedList<String> nextIsNull = new IterativeLinkedList<String>("alone");
  18.         assertNull(nextIsNull.getNext());
  19.     }
  20.  
  21.     @Test
  22.     public void onConstruct_nextValue_shouldExist() throws Exception {
  23.         assertNotNull(rapperToListen.getNext());
  24.     }
  25.    
  26.     @Test
  27.     public void gettingFirstValue_shouldBeEqualsTo_beginningOfList() throws Exception {
  28.         assertEquals(SAD_RAPPER, rapperToListen.first());
  29.     }
  30.    
  31.     @Test
  32.     public void gettingSecondValue_shouldBeEqualsTo_nextOfList() throws Exception {
  33.         assertEquals(WHITE_THUG, rapperToListen.second());
  34.     }
  35.    
  36.     @Test
  37.     public void listLenghth_shouldBeEqualsTo_numberOfAllElements() throws Exception {
  38.         assertEquals(3, rapperToListen.size());
  39.     }
  40.    
  41.     @Test
  42.     public void lastElement_shouldBe_lastAddElementInList() throws Exception {
  43.         assertEquals(FRENCH_POSTMALONE, rapperToListen.last());
  44.     }
  45.    
  46.     @Test
  47.     public void getArbitraryElement_shouldReturn_valueForIndexInList() throws Exception {
  48.         assertEquals(WHITE_THUG, rapperToListen.get(1));
  49.     }
  50.    
  51.     @Test
  52.     public void insertElementAtStart_shouldChange_valueForFirstIndex() throws Exception {
  53.         rapperToListen.insertFirst("Dinos");
  54.         assertEquals("Dinos", rapperToListen.first());
  55.         assertEquals(4, rapperToListen.size());
  56.     }
  57.  
  58.     @Test
  59.     public void insertElementAtEnd_shouldChange_valueForLastIndex() throws Exception {
  60.         rapperToListen.insertLast("Fianso");
  61.         assertEquals("Fianso", rapperToListen.last());
  62.         assertEquals(4, rapperToListen.size());
  63.     }
  64.    
  65.     @Test
  66.     public void insertElementAtArbitraryIndex_shouldChange_valueForChoosenIndex() throws Exception {
  67.         rapperToListen.insert("Columbine", 1);
  68.         assertEquals("Columbine", rapperToListen.second());
  69.         assertEquals(4, rapperToListen.size());
  70.     }
  71.    
  72.     @Test
  73.     public void deleteElementByValue_shouldRemove_listElementAtCorrectIndex() throws Exception {
  74.         rapperToListen.delete(SAD_RAPPER);
  75.         assertEquals(WHITE_THUG, rapperToListen.first());
  76.         assertEquals(2, rapperToListen.size());
  77.     }
  78.  
  79.     @Test
  80.     public void deleteElementByIndex_shouldRemove_listElementAtCorrectIndex() throws Exception {
  81.         rapperToListen.delete(2);
  82.         assertEquals(WHITE_THUG, rapperToListen.last());
  83.         assertEquals(2, rapperToListen.size());
  84.     }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement