// CONCATENATE TWO NONEMPTY LISTS TEST_F(LListIntTest, ConcatenationENominal){ LListInt newList; LListInt finalList; newList.insert(0, 3); newList.insert(1, 4); newList.insert(2, 5); finalList = list + newList; EXPECT_EQ(finalList.size(), list.size() + newList.size()); for(int i=0; i<list.size(); i++) EXPECT_EQ(finalList[i], list[i]); for(int i=0; i<newList.size(); i++) EXPECT_EQ(finalList[i+list.size()], newList[i]); }
/** * Concatenation Operator (other should be appended to the end of this) */ LListInt LListInt::operator+(const LListInt& other) const{ LListInt temp = *this; // new temporary LinkedList that will be returned for(int i = 0; i < other.size(); i++){ temp.insert(i + this->size(), other.get(i)); // inserting to the end of the object on the left hand side } return temp; }
// ASSIGNMENT OPERATOR (COPY) WITH NONEMPTY LIST ONTO NONEMPTY LIST TEST_F(LListIntTest, AssignmentOffNominal){ LListInt newList; newList.insert(0, 5); newList.insert(1, 9); newList = list; EXPECT_EQ(newList.size(), list.size()); for(int i=0; i<newList.size(); i++) EXPECT_EQ(newList[i], list[i]); }
TEST_F(llisttest, addNominal) { LListInt add; for(int i = 5; i < 10; i++){ add.insert(i-5, i); } list = list + add; for (int i = 0 ; i < 10; i++) { EXPECT_EQ(list.get(i), i); } }
int main() { LListInt * list = new LListInt(); // Check if the list is initially empty. if (list->empty()) { cout << "SUCCESS: List is empty initially." << endl; } else { cout << "FAIL: List is not empty initially when it should be." << endl; } // Calls to insert function list->insert(0, 88); list->insert(1, 3); list->insert(2, 14); list->insert(1, 5); list->insert(4, 28); list->insert(-3, 31); //current list is: 88 5 3 14 28 // Check if the list is still empty. if (!list->empty()) { cout << "SUCCESS: List is not empty after 5 insertions." << endl; } else { cout << "FAIL: List is empty after 5 insertions." << endl; } // Check if there are 5 items in the list. if (list->size() == 5) { cout << "SUCCESS: List has size 5 after the insertions." << endl; } else { cout << "FAIL: List has size " << list->size() << " after 5 insertions." << endl; } // Check if the value is correct. if (list->get(0) == 88) { cout << "SUCCESS: 88 is at the 1st index of the list." << endl; } else { cout << "FAIL: 88 is not at the 1st index of the list, " << list->get(1) << " is instead." << endl; } list->remove(2); // Check if the value is correct. if (list->get(2) == 14) { cout << "SUCCESS: 14 is at the 2nd index of the list, remove function worked" << endl; } else { cout << "FAIL: 14 is not at the 2nd index of the list, " << list->get(2) << " is instead." << endl; } // Clean up memory. delete list; }
TEST_F(llisttest, assignNominal) { LListInt assign; for(int i = 0; i < 5; i++){ assign.insert(i, i+1); } for(int i = 0; i < 5; i++){ EXPECT_EQ(assign.get(i), i+1); } assign = list; for (int i = 0 ; i < 5; i++) { EXPECT_EQ(assign.get(i), i); } }
int main() { LListInt * list = new LListInt(); // Check if the list is initially empty. if (list->empty()) { cout << "SUCCESS: List is empty initially." << endl; } else { cout << "FAIL: List is not empty initially when it should be." << endl; } // Test -> Insert an item at the head list->insert(0, 3); // Check if the list is still empty if (!list->empty()) { cout << "SUCCESS: List is not empty after one insertion." << endl; } else { cout << "FAIL: List is empty after one insertion." << endl; } // Check if the size if (list->size() == 1) { cout << "SUCCESS: List has size 1 after one insertion." << endl; } else { cout << "FAIL: List has size " << list->size() << " after one insertion."; cout << endl; } // Check if the value is correct. if (list->get(0) == 3) { cout << "SUCCESS: 3 is at the 0th index of the list." << endl; } else { cout << "FAIL: 3 is not at the 0th index of the list, " << list->get(0); cout << " is instead." << endl; } // Test -> Insert an item at the beginning list->insert(0, 2); if (list->get(0) == 2) { cout << "SUCCESS: 2 is at the 0th index of the list." << endl; } else { cout << "FAIL: 2 is not at the 0th index of the list, " << list->get(0); cout << " is instead." << endl; } // Test -> Insert an item at the end list->insert(2, 5); if (list->get(2) == 5) { cout << "SUCCESS: 5 is at the 2th index of the list." << endl; } else { cout << "FAIL: 5 is not at the 2th index of the list, " << list->get(0); cout << " is instead." << endl; } // Test -> Insert item in the middle list->insert(2, 4); if (list->get(2) == 4) { cout << "SUCCESS: 4 is at the 2th index of the list." << endl; } else { cout << "FAIL: 4 is not at the 2th index of the list, " << list->get(0); cout << " is instead." << endl; } // Test -> inserting at a wrong location list->insert(5, 0); // Clean up memory. delete list; }
int main(){ LListInt* list = new LListInt(); cout << "BEGINNING 15 TEST CASES..." << endl; // We can assume that the following will work if and only if get(), size() and empty() work // get() and set() will throw a core dump if given bad location // NOMINAL // 1. Check if the list is initially empty. if (list->empty()) cout << "SUCCESS: (1) List is empty initially." << endl; else cout << "FAIL: (1) List is not empty initially when it should be." << endl; // OFFNOMINAL // 2. Check: insert into empty list with bad location list->insert(1, 5); if(list->empty()) cout << "SUCCESS: (2) List is still empty." << endl; else cout << "FAIL: (2) List now has " << list->size() << " element(s)" << endl; // NOMINAL // 3. Check: insert into empty list with loc = 0 list->insert(0,5); // 5 if(list->size()==1){ if(list->get(0)==5) cout << "SUCCESS"; else cout << "FAIL"; string temp = printlist(list); cout << ": (3) list is " << temp << endl; } else cout << "FAIL: (3) list has size " << list->size() << " instead of 1" << endl; // BOUNDARY // 4. Check: insert element to end of list. (loc == size) list->insert(1,8); // 5, 8 if(list->size()==2){ if(list->get(0)==5 && list->get(1)==8) cout << "SUCCESS"; else cout << "FAIL"; string temp = printlist(list); cout << ": (4) list is " << temp << endl; } else cout << "FAIL: (4) list has size " << list->size() << " instead of 2" << endl; // BOUNDARY // 5. Check: insert element to front of list list->insert(0,2); // 2, 5, 8 if(list->size()==3){ if(list->get(0)==2 && list->get(1)==5 && list->get(2)==8) cout << "SUCCESS"; else cout << "FAIL"; string temp = printlist(list); cout << ": (5) list is " << temp << endl; } else cout << "FAIL: (5) list has size " << list->size() << " instead of 3" << endl; // NOMINAL // 6. Check: insert element to middle of list list->insert(2,3); // 2, 5, 3, 8 if(list->size()==4){ if(list->get(0)==2 && list->get(1)==5 && list->get(2)==3 && list->get(3)==8) cout << "SUCCESS"; else cout << "FAIL"; string temp = printlist(list); cout << ": (6) list is " << temp << endl; } else cout << "FAIL: (6) list has size " << list->size() << " instead of 4" << endl; // OFFNOMINAL // 7. Check: insert element in bad location list->insert(5,0); // 2, 5, 3, 8 if(list->size()==4){ if(list->get(0)==2 && list->get(1)==5 && list->get(2)==3 && list->get(3)==8) cout << "SUCCESS"; else cout << "FAIL"; string temp = printlist(list); cout << ": (7) list is " << temp << endl; } else if(list->size()==5) cout << "FAIL: (7) the 5th element " << list->get(5) << " was incorrectly inserted" << endl; else cout << "FAIL: (7) list has size " << list->size() << " instead of 4" << endl; // OFFNOMINAL // 8. Check: remove element from loc == size (bad location) list->remove(4); if(list->size()==4){ if(list->get(0)==2 && list->get(1)==5 && list->get(2)==3 && list->get(3)==8) cout << "SUCCESS"; else cout << "FAIL"; string temp = printlist(list); cout << ": (8) list is " << temp << endl; } else cout << "FAIL: (8) list has size " << list->size() << " instead of 4" << endl; // OFFNOMINAL // 9. Check: remove element from loc > size (bad location) list->remove(5); if(list->size()==4){ if(list->get(0)==2 && list->get(1)==5 && list->get(2)==3 && list->get(3)==8) cout << "SUCCESS"; else cout << "FAIL"; string temp = printlist(list); cout << ": (9) list is " << temp << endl; } else cout << "FAIL: (9) list has size " << list->size() << " instead of 4" << endl; // BOUNDARY // 10. Check: remove element from end of list list->remove(3); // 2, 5, 3 if(list->size()==3){ if(list->get(0)==2 && list->get(1)==5 && list->get(2)==3) cout << "SUCCESS"; else cout << "FAIL"; string temp = printlist(list); cout << ": (10) list is " << temp << endl; } else cout << "FAIL: (10) list has size " << list->size() << " instead of 3" << endl; // BOUNDARY // 11. Check: removing from beginning of list list->remove(0); // 5, 3 if(list->size()==2){ if(list->get(0)==5 && list->get(1)==3) cout << "SUCCESS"; else cout << "FAIL"; string temp = printlist(list); cout << ": (11) list is " << temp << endl; } else cout << "FAIL: (11) list has size " << list->size() << " instead of 2" << endl; // NOMINAL // 12. Check: removing from middle of list list->insert(1,9); // 5, 9, 3 list->remove(1); // 5, 3 if(list->size()==2){ if(list->get(0)==5 && list->get(1)==3) cout << "SUCCESS"; else cout << "FAIL"; string temp = printlist(list); cout << ": (12) list is " << temp << endl; } else cout << "FAIL: (12) list has size " << list->size() << " instead of 2" << endl; // 13. Check: setting list->set(0, 3); // 3, 3 list->set(1, 5); // 3, 5 if(list->size()==2){ if(list->get(1)==5 && list->get(0)==3) cout << "SUCCESS"; else cout << "FAIL"; string temp = printlist(list); cout << ": (13) list is " << temp << endl; } else cout << "FAIL: (13) list has size " << list->size() << " instead of 2" << endl; // NOMINAL // 14. Check: clear list->clear(); string temp = printlist(list); if (list->empty()) cout << "SUCCESS: (14) List is emptied." << endl; else cout << "FAIL: (14) List is not empty: " << temp << endl; //OFFNOMINAL // 15. Check: remove list->remove(0); temp = printlist(list); if (list->empty()) cout << "SUCCESS: (15) List is empty and ok." << endl; else cout << "FAIL: (15) List is not empty: " << temp << endl; cout << "ALL TESTS ARE COMPLETE. NOW DELETING LIST." << endl; delete list; return 0; }
int main() { LListInt * list = new LListInt(); // Check if the list is initially empty. if (list->empty()) { cout << "SUCCESS: List is empty initially." << endl; } else { cout << "FAIL: List is not empty initially when it should be." << endl; } // Remove an item from an empty list //list->remove(0); // Insert an item from invalid location //list->insert(-1, 1); //list->insert(3, 3); // Insert an item at the head. list->insert(0, 3); // Check if the list is still empty. if (!list->empty()) { cout << "SUCCESS: List is not empty after one insertion." << endl; } else { cout << "FAIL: List is empty after one insertion." << endl; } if (list->size() == 1) { cout << "SUCCESS: List has size 1 after one insertion." << endl; } else { cout << "FAIL: List has size " << list->size() << " after one insertion."; cout << endl; } // Insert an item from invalid location //list->insert(3, 3); // Insert an item to the end of an existing list list->insert(1, 2); list->insert(2, 1); if (list->size() == 3) { cout << "SUCCESS: List has size 3 after three insertion." << endl; } else { cout << "FAIL: List has size " << list->size() << " after three insertion."; cout << endl; } // Check if the value is correct. if (list->get(0) == 3) { cout << "SUCCESS: 3 is at the 0th index of the list." << endl; } else { cout << "FAIL: 3 is not at the 0th index of the list, " << list->get(0); cout << " is instead." << endl; } // Check if the value is correct. if (list->get(1) == 2) { cout << "SUCCESS: 2 is at the 1st index of the list." << endl; } else { cout << "FAIL: 2 is not at the 1st index of the list, " << list->get(2); cout << " is instead." << endl; } // Check if the value is correct. if (list->get(2) == 1) { cout << "SUCCESS: 1 is at the 2nd index of the list." << endl; } else { cout << "FAIL: 1 is not at the 2nd index of the list, " << list->get(2); cout << " is instead." << endl; } // Insert an item into middle of an existing list list->insert(1, 3); list->insert(0, 10); if (list->size() == 5) { cout << "SUCCESS: List has size 5 after five insertion." << endl; } else { cout << "FAIL: List has size " << list->size() << " after five insertion."; cout << endl; } // Check if the value is correct. if (list->get(0) == 10) { cout << "SUCCESS: 10 is at the 0th index of the list." << endl; } else { cout << "FAIL: 10 is not at the 0th index of the list, " << list->get(0); cout << " is instead." << endl; } // Check if the value is correct. if (list->get(1) == 3) { cout << "SUCCESS: 3 is at the 1st index of the list." << endl; } else { cout << "FAIL: 3 is not at the 1st index of the list, " << list->get(1); cout << " is instead." << endl; } // Check if the value is correct. if (list->get(2) == 3) { cout << "SUCCESS: 3 is at the 2nd index of the list." << endl; } else { cout << "FAIL: 3 is not at the 2nd index of the list, " << list->get(2); cout << " is instead." << endl; } // Remove item from invalid location //list->remove(-1); //list->remove(6); // Remove item from ends of the list list->remove(0); list->remove(3); if (list->size() == 3) { cout << "SUCCESS: List has size 3 after two removals." << endl; } else { cout << "FAIL: List has size " << list->size() << " after two removals."; cout << endl; } // Check if the value is correct. if (list->get(0) == 3) { cout << "SUCCESS: 3 is at the 0th index of the list." << endl; } else { cout << "FAIL: 3 is not at the 0th index of the list, " << list->get(0); cout << " is instead." << endl; } // Check if the value is correct. if (list->get(2) == 2) { cout << "SUCCESS: 2 is at the 3rd index of the list." << endl; } else { cout << "FAIL: 2 is not at the 3rd index of the list, " << list->get(2); cout << " is instead." << endl; } // Remove item from middle of an array list->remove(1); if (list->size() == 2) { cout << "SUCCESS: List has size 2 after three removals." << endl; } else { cout << "FAIL: List has size " << list->size() << " after three removals."; cout << endl; } // Check if the value is correct. if (list->get(1) == 2) { cout << "SUCCESS: 2 is at the 1st index of the list." << endl; } else { cout << "FAIL: 2 is not at the 1st index of the list, " << list->get(1); cout << " is instead." << endl; } // Clean list list->clear(); if (list->empty()) { cout << "SUCCESS: List is empty after clear()." << endl; } else { cout << "FAIL: List is not empty after clear() when it should be." << endl; } // Clean up memory. delete list; }
int main() { LListInt * list = new LListInt(); list->insert(0, 3); //insert an item to the empty list. if (list->size() == 1) { cout << "SUCCESS: List has size 1 after one insertion." << endl; } else { cout << "FAIL: List has size " << list->size() << " after one insertion."; cout << endl; } if (list->get(0) == 3) { cout << "SUCCESS: 3 is at the 0th index of the list." << endl; } else { cout << "FAIL: 3 is not at the 0th index of the list, " << list->get(0); cout << " is instead." << endl; } list->insert(1,4); //insert an item at the valid location SIZE //the tail will be changed and the size would be changed to 2 if (list->size() == 2) { cout << "SUCCESS: List has size 2 after one insertion." << endl; } else { cout << "FAIL: List has size " << list->size() << " after one insertion."; cout << endl; } //the second item will have the value 2; if (list->get(1) == 4) { cout << "SUCCESS: 4 is at the 1st index of the list." << endl; } else { cout << "FAIL: 4 is not at the 1st index of the list, " << list->get(1); cout << " is instead." << endl; } list->insert(1,5); //add one item at the location between 0 to Size-1 if(list->size() == 3){ cout << "SUCCESS: List has size 3 after one insertion." << endl; } else { cout << "FAIL: List has size " << list->size() << " after one insertion."; cout << endl; } if (list->get(1) == 5) { cout << "SUCCESS: 5 is at the 1st index of the list." << endl; } else { cout << "FAIL: 5 is not at the 1st index of the list, " << list->get(1); cout << " is instead." << endl; } //5 should be the new value of the 1st index if (list->get(2) == 4) { cout << "SUCCESS: 4 is at the 2nd index of the list." << endl; } else { cout << "FAIL: 4 is not at the 2nd index of the list, " << list->get(2); cout << " is instead." << endl; } //4 would be pushed to the next position at the 2nd. //the substitution is successful. list->insert(5,4); list->insert(-2,4); //insert an item to the array at the location out of valid range if(list->size() == 3){ cout << "SUCCESS: List has size 3 after two insertion." << endl; } else { cout << "FAIL: List has size " << list->size() << " after one insertion."; cout << endl; } list->remove(1); //delete the item in location 1 in the valid range if(list->size() == 2){ cout << "SUCCESS: List has size 2 after one remove." << endl; } else { cout << "FAIL: List has size " << list->size() << " after one insertion."; cout << endl; } //the size should be 2 now. if (list->get(1) == 4) { cout << "SUCCESS: 4 is at the 1st index of the list." << endl; } else { cout << "FAIL: 4 is not at the 1st index of the list, " << list->get(1); cout << " is instead." << endl; } //the item with value 4 will substitute the value at location 1 before list->remove(4); list->remove(-2); //delete the item at the location out of the valid range if(list->size() == 2){ cout << "SUCCESS: List has size 2 after one remove." << endl; } else { cout << "FAIL: List has size " << list->size() << " after one insertion."; cout << endl; } //the size should keep 2 now. list->insert(2,5); //insert item with value 5 to the list. list->remove(2); //remove the last item(boundary) if(list->size() == 2){ cout << "SUCCESS: List has size 2 after one remove." << endl; } else { cout << "FAIL: List has size " << list->size() << " after one insertion."; cout << endl; } //the last item is removed and the size will become 2 if (list->get(1) == 4) { cout << "SUCCESS: 4 is at the 1st index of the list." << endl; } else { cout << "FAIL: 4 is not at the 1st index of the list, " << list->get(1); cout << " is instead." << endl; } list->insert(2,5); list->remove(0); //remove the first boundary item //the rest items should move left by one spot if(list->size() == 2){ cout << "SUCCESS: List has size 2 after one remove." << endl; } else { cout << "FAIL: List has size " << list->size() << " after one insertion."; cout << endl; } //the first item is removed and the size will become 2 if (list->get(1) == 5) { cout << "SUCCESS: 5 is at the 1st index of the list." << endl; } else { cout << "FAIL: 5 is not at the 1st index of the list, " << list->get(1); cout << " is instead." << endl; } list->clear(); if(list->size() == 0){ cout << "SUCCESS: List has size 0 after one clear." << endl; } else { cout << "FAIL: List has size " << list->size() << " after one insertion."; cout << endl; } list->remove(0); if(list->size() == 0){ cout << "SUCCESS: List has size 0 after one clear." << endl; } else { cout << "FAIL: List has size " << list->size() << " after one insertion."; cout << endl; } delete list; return 0; }
int main() { LListInt * list = new LListInt(); if (list->empty()) { cout << "SUCCESS: List is empty initially." << endl; } else { cout << "FAIL: List is not empty initially when it should be." << endl; } // Testing insert function cout << "\nTesting insert function\n"; list->insert(0,1); list->insert(1,5); list->insert(2,7); if (list->get(0) == 1 && list->get(1) == 5 && list->get(2) == 7) { cout << "SUCCESS: Elements 1, 5, 7 are successfully inserted to the list." << endl; } else { cout << "FAIL: Insertion failed." << endl; } cout << "DISPLAYING: List after insertion \n"; for (int i=-0; i < list->size(); i++) { cout << list->get(i) << " "; } cout << endl << endl; //Inserting head list->insert(0,0); if (list->get(0) == 0) { cout << "SUCCESS: Inserting element from the front of the list" << endl; } else { cout << "FAIL: Failed to insert element from the front of the list." << endl; } cout << "DISPLAYING: List after inserting from the front of the list \n"; for (int i=-0; i < list->size(); i++) { cout << list->get(i) << " "; } cout << endl << endl; //Inserting tail list->insert(list->size(),8); if (list->get(list->size()-1) == 8) { cout << "SUCCESS: Inserting element from the back of the list" << endl; } else { cout << "FAIL: Failed to insert element from the back of the list." << endl; } cout << "DISPLAYING: List after inserting from the back of the list\n"; for (int i=-0; i < list->size(); i++) { cout << list->get(i) << " "; } cout << endl << endl; //Inserting elements in certain positions" << endl; list->insert(2,2); if (list->get(2) == 2) { cout << "SUCCESS: Inserting element on position 2 in the list" << endl; } else { cout << "FAIL: Failed to insert element on postion 2 in the list." << endl; } cout << "DISPLAYING: List after inserting element on position 2 in the list\n"; for (int i=-0; i < list->size(); i++) { cout << list->get(i) << " "; } cout << endl << endl; //0 1 2 4 5 7 8 list->insert(3,4); if (list->get(3) == 4) { cout << "SUCCESS: Inserting element on position 3 in the list" << endl; } else { cout << "FAIL: Failed to insert element on postion 3 in the list." << endl; } cout << "DISPLAYING: List after inserting element on position 3 in the list\n"; for (int i=-0; i < list->size(); i++) { cout << list->get(i) << " "; } cout << endl<< endl; //0 1 2 4 5 6 7 8 list->insert(5,6); if (list->get(5) == 6) { cout << "SUCCESS: Inserting element on position 5 in the list" << endl; } else { cout << "FAIL: Failed to insert element on postion 5 in the list." << endl; } cout << "DISPLAYING: List after inserting element on position 5 in the list\n"; for (int i=-0; i < list->size(); i++) { cout << list->get(i) << " "; } cout << endl << endl; //0 1 2 3 4 5 6 7 8 list->insert(3,3); if (list->get(3) == 3) { cout << "SUCCESS: Inserting element on position 3 in the list" << endl; } else { cout << "FAIL: Failed to insert element on postion 3 in the list." << endl; } cout << "DISPLAYING: List after inserting element on position 3 in the list\n"; for (int i=-0; i < list->size(); i++) { cout << list->get(i) << " "; } cout << endl << endl; int x = list->size(); //Testing invalid location insertion list->insert(-1,5); list->insert(10,9); if (list->size() == x) { cout << "SUCCESS: Invalid insertion did not alter the list." << endl; } else { cout << "FAIL: Invalid insertion altered the list." << endl; } cout << "DISPLAYING: List after attempting to insert in invalid position of the list\n"; for (int i=-0; i < list->size(); i++) { cout << list->get(i) << " "; } cout << "\n\nTesting remove function \n"; //"Removing head\n"; list->remove(0); if (list->get(0) == 1) { cout << "SUCCESS: Removing element from the front of the list" << endl; } else { cout << "FAIL: Failed to remove element from the front of the list." << endl; } cout << "DISPLAYING: List after removing element from the front of the list \n"; for (int i=-0; i < list->size(); i++) { cout << list->get(i) << " "; } cout << endl << endl; //Removing tail list->remove(list->size() - 1); if (list->get(list->size()-1) == 7) { cout << "SUCCESS: Removing element from the back of the list" << endl; } else { cout << "FAIL: Failed to remove element from the back of the list." << endl; } cout << "DISPLAYING: List after removing element from the back of the list \n"; for (int i=-0; i < list->size(); i++) { cout << list->get(i) << " "; } cout << endl << endl; //1 2 3 4 5 6 7 //Removing elements in certain positions\n"; list->remove(2); //remove 3 if(list->get(2) == 3) { cout << "SUCCESS: Removing element on position 2 in the list" << endl; } else { cout << "FAIL: Failed to remove element on postion 2 in the list." << endl; } cout << "DISPLAYING: List after removing element on position 2 in the list\n"; for (int i=-0; i < list->size(); i++) { cout << list->get(i) << " "; } cout << endl << endl; // 1 2 4 5 6 7 list->remove(4); //remove 6 if(list->get(4) == 7) { cout << "SUCCESS: Removing element on position 4 in the list" << endl; } else { cout << "FAIL: Failed to remove element on postion 4 in the list." << endl; } cout << "DISPLAYING: List after removing element on position 4 in the list\n"; for (int i=-0; i < list->size(); i++) { cout << list->get(i) << " "; } cout << endl << endl; //1 2 4 5 7 list->remove(1); //remove 2 if (list->get(1) == 4) { cout << "SUCCESS: Removing element on position 1 in the list" << endl; } else { cout << "FAIL: Failed to remove element on postion 1 in the list." << endl; } cout << "DISPLAYING: List after removing element on position 1 in the list\n"; for (int i=-0; i < list->size(); i++) { cout << list->get(i) << " "; } cout << endl << endl; // 1 4 5 7 //Testing invalid location for removal list->remove(-1); list->remove(4); x = list->size(); if (list->size() == x) { cout << "SUCCESS: Invalid removal did not alter the list." << endl; } else { cout << "FAIL: Invalid removal altered the list." << endl; } cout << "DISPLAYING: List after attempting to remove element in invalid position of the list\n"; for (int i=-0; i < list->size(); i++) { cout << list->get(i) << " "; } cout << endl << endl; //Removing the rest of the element in the list for (int i=0; i<x; i++) { list->remove(0); } if (list->size() == 0) { cout << "SUCCESS: Removing the rest of the elements from the list" << endl; } else { cout << "FAIL: The list is not empty" << endl; } cout << "DISPLAYING: The list after removing \n"; for (int i=0; i < list->size(); i++) { cout << list->get(i) << " "; } cout << endl; if (list->empty()) { cout << "SUCCESS: List is now empty." << endl; } else { cout << "FAIL: List is not empty." << endl; } // Clean up memory. delete list; list = NULL; }