Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

l. Create a package in eclipse with the name cse360hw7. Copy the OrderedIntListj

ID: 3825305 • Letter: L

Question

l. Create a package in eclipse with the name cse360hw7. Copy the OrderedIntListjava file into this package. 2. Generate the initial set of JUnit test cases. All should have the default of fail. 3. Complete the code for your test cases. Create new methods as needed for the tests. Your tests should not have any if statements, loops or output. Use asserts to check the results. 4. Thoroughly test the code. Consider the following tests for insert. This is a minimum of 6 different tests. Each tests should be in its own method. a. insert into an empty list b. insert at beginning, at end and in middle c. insert duplicates d. insert causing array expansion 5. Make sure that all the code meets all coding and documentation standards. The junit test cases should include internal documentation while the orderedIntListjava file contain both internal and external documentation. 6. Submit the following file for grading OrderedIntListTestjava.

Explanation / Answer

// Note: Please thumbs up if you like the answer

// You need to configure/add junit jar to eclipse

package cse360hw7;

import static org.junit.Assert.*;

import org.junit.Test;

public class OrderedIntListTest {

   OrderedIntList defObj = new OrderedIntList();
   OrderedIntList sizeObj = new OrderedIntList(5);
  
   /*
   * checking default size
   */
   @Test
   public void testCase1() {
       //fail("Not yet implemented");
       assertEquals(10,defObj.size());
   }
  
  
   /*
   * checking default size
   */
   @Test
   public void testCase2() {
       //fail("Not yet implemented");
       assertEquals(5,sizeObj.size());
   }
  
   /*
   * checking insert method
   */
   @Test
   public void testCase3() {
       //fail("Not yet implemented");
       sizeObj.insert(10);
       sizeObj.insert(20);
       sizeObj.insert(30);
       sizeObj.insert(40);
       sizeObj.insert(50);
       sizeObj.insert(60);
       // adding 6th element will increase the size of list by 50%, so new size will be (size+size/2) = 7
       assertEquals(7, sizeObj.size());
   }

   /*
   * checking duplicate insert element
   */
   @Test
   public void testCase4() {
       //fail("Not yet implemented");
       sizeObj.insert(10);
       sizeObj.insert(20);
       sizeObj.insert(30);
       sizeObj.insert(40);
       sizeObj.insert(40);
       sizeObj.insert(40);
       sizeObj.insert(40);
       sizeObj.insert(40);
       // size will not be increased
       assertEquals(5, sizeObj.size());
   }
  
   /*
   * checking elements in list by calling toString method
   */

   @Test
   public void testCase5() {
       //fail("Not yet implemented");
       // toString test
       // 102030405060
       sizeObj.insert(10);
       sizeObj.insert(20);
       sizeObj.insert(30);
       sizeObj.insert(40);
       sizeObj.insert(50);
       sizeObj.insert(60);
       String valOfsizeObj="10 20 30 40 50 60";
       //System.out.println("Returned string is: "+sizeObj.toString());
       assertEquals(valOfsizeObj, sizeObj.toString());
   }

   /*
   * checking delete method in list
   */
   @Test
   public void testCase6() {
       //fail("Not yet implemented");
       sizeObj.insert(10);
       sizeObj.insert(20);
       sizeObj.insert(30);
       sizeObj.insert(40);
       sizeObj.insert(50);
       sizeObj.insert(60);
       sizeObj.delete(60);
       sizeObj.delete(10);
       String valOfsizeObj="20 30 40 50";
       //System.out.println("Returned string is: "+sizeObj.toString());
       assertEquals(valOfsizeObj, sizeObj.toString());

   }
  
}