GitBucket
4.20.0
Toggle navigation
Sign in
Files
Branches
1
Tags
Issues
Pull requests
Labels
Priorities
Milestones
Wiki
Forks
Jonathan
/
Assignment2B
Browse code
Renamed MainTest.java to IListTest.java.
master
1 parent
4171df6
commit
e53a79afa9532af2d831f24a859b978d2aa0417a
Jonathan Ström
authored
on 31 Aug 2017
Patch
Showing
2 changed files
src/IListTest.java
src/MainTest.java
Ignore Space
Show notes
View
src/IListTest.java
0 → 100644
public class IListTest { public static void main(String[] args) { System.out.println("The testing is starting..."); IList<String> list = new List<String>(); /*************************************** * Testing to add elements to the list. ***************************************/ list.addAt(0, "1"); // 1 list.addAt(1, "2"); // 1, 2 list.addAt(0, "3"); // 3, 1, 2 list.addAt(1, "4"); // 3, 4, 1, 2 System.out.println("Expected output: 3, 4, 1, 2"); for (int i = 0; i < list.size(); ++i) { System.out.println(list.getAllElementsAsStrings()[i]); } /*************************************** * Testing to get the size of the list. ***************************************/ System.out.println("Expected output: Size: 4"); System.out.println("Size: " + list.size()); /*************************************** * Testing to remove two elements and a third element that doesn't exist. ***************************************/ System.out.println("Expected output: true, true, false"); System.out.println(list.removeAt(0)); // 4, 1, 2 System.out.println(list.removeAt(2)); // 4, 1 System.out.println(list.removeAt(2)); // 4, 1 /*************************************** * Print out the list. ***************************************/ System.out.println("Expected output: 4, 1"); for (int i = 0; i < list.size(); ++i) { System.out.println(list.getAllElementsAsStrings()[i]); } /*************************************** * Try to find an item that exists, and one that doesn't. ***************************************/ System.out.println("Expected output: 1, -1"); System.out.println(list.find("1")); System.out.println(list.find("2")); /*************************************** * Testing appending a list to a list. ***************************************/ IList<String> newList = new List<String>(); newList.addAt(5, "5"); newList.addAt(5, "7"); newList.addAt(5, "11"); list.append(newList); System.out.println("Expected output: 4, 1, 5, 7, 11"); for (int i = 0; i < list.size(); ++i) { System.out.println(list.getAllElementsAsStrings()[i]); } /*************************************** * Testing to clear the list and remove an element from an empty list. ***************************************/ System.out.println("Expected output: Size: 0, false"); list.clear(); System.out.println("Size: " + list.size()); System.out.println(list.removeAt(0)); System.out.println("The testing has ended..."); } }
Show notes
View
src/MainTest.java
100644 → 0
public class MainTest { public static void main(String[] args) { System.out.println("The testing is starting..."); IList<String> list = new List<String>(); /*************************************** * Testing to add elements to the list. ***************************************/ list.addAt(0, "1"); // 1 list.addAt(1, "2"); // 1, 2 list.addAt(0, "3"); // 3, 1, 2 list.addAt(1, "4"); // 3, 4, 1, 2 System.out.println("Expected output: 3, 4, 1, 2"); for (int i = 0; i < list.size(); ++i) { System.out.println(list.getAllElementsAsStrings()[i]); } /*************************************** * Testing to get the size of the list. ***************************************/ System.out.println("Expected output: Size: 4"); System.out.println("Size: " + list.size()); /*************************************** * Testing to remove two elements and a third element that doesn't exist. ***************************************/ System.out.println("Expected output: true, true, false"); System.out.println(list.removeAt(0)); // 4, 1, 2 System.out.println(list.removeAt(2)); // 4, 1 System.out.println(list.removeAt(2)); // 4, 1 /*************************************** * Print out the list. ***************************************/ System.out.println("Expected output: 4, 1"); for (int i = 0; i < list.size(); ++i) { System.out.println(list.getAllElementsAsStrings()[i]); } /*************************************** * Try to find an item that exists, and one that doesn't. ***************************************/ System.out.println("Expected output: 1, -1"); System.out.println(list.find("1")); System.out.println(list.find("2")); /*************************************** * Testing appending a list to a list. ***************************************/ IList<String> newList = new List<String>(); newList.addAt(5, "5"); newList.addAt(5, "7"); newList.addAt(5, "11"); list.append(newList); System.out.println("Expected output: 4, 1, 5, 7, 11"); for (int i = 0; i < list.size(); ++i) { System.out.println(list.getAllElementsAsStrings()[i]); } /*************************************** * Testing to clear the list and remove an element from an empty list. ***************************************/ System.out.println("Expected output: Size: 0, false"); list.clear(); System.out.println("Size: " + list.size()); System.out.println(list.removeAt(0)); System.out.println("The testing has ended..."); } }
Show line notes below