Question: Need help with this C++ program file: Instructions: FifthElementTesting.cpp file: #include #include #include #include FifthElement.h using namespace std; void testGetFifthElement(); void testInsertNewFifthElement(); void testDeleteFifthElement(); void
Need help with this C++ program file:
Instructions:

FifthElementTesting.cpp file:
#include
using namespace std;
void testGetFifthElement(); void testInsertNewFifthElement(); void testDeleteFifthElement(); void testSwapFourthAndFifthElement();
bool checkTest(string testName, string whatItShouldBe, string whatItIs); bool checkTest(string testName, int whatItShouldBe, int whatItIs); bool checkTestMemory(string testName, int whatItShouldBe, int whatItIs);
int main() { testGetFifthElement(); testInsertNewFifthElement(); testDeleteFifthElement(); testSwapFourthAndFifthElement();
return 0; }
//This helps with testing, do not modify. bool checkTest(string testName, string whatItShouldBe, string whatItIs) {
if (whatItShouldBe == whatItIs) { cout
//This helps with testing, do not modify. bool checkTest(string testName, int whatItShouldBe, int whatItIs) {
if (whatItShouldBe == whatItIs) { cout
//This helps with testing, do not modify. bool checkTestMemory(string testName, int whatItShouldBe, int whatItIs) {
if (whatItShouldBe == whatItIs) { cout
//This helps with testing, do not modify. void testGetFifthElement() {
auto si = make_shared
stringstream sstream; sstream
//Test retrieving item. int item = si->getFifthElement(); checkTest("test #2: checking 5th element", 14, item); si.reset();
si = make_shared
sstream.str(""); sstream
//Test just to make sure the data went in the list. checkTest("test #3: adding only 5 elements", "10 11 12 13 14", sstream.str());
//Test retrieving item. item = si->getFifthElement(); checkTest("test #4: checking 5th at end", 14, item); si.reset();
si = make_shared //Try to access out of bounds. string caughtError = ""; try { item = si->getFifthElement(); } catch (exception &e) { caughtError = "caught"; } checkTest("test #6: testing exception ", "caught", caughtError); si.reset(); auto ss = make_shared >(); ss->insert("Multi Pass"); ss->insert("Lelu Dallas"); ss->insert("BIG BADA BOOM"); ss->insert("Bruce Willis"); ss->insert("Fried Chicken"); ss->insert("EEEAAAAAAAeeeaaaaaEEeeAAAEEaaaaAA"); checkTest("test #7: testing strings", "Fried Chicken", ss->getFifthElement()); ss.reset(); } //This helps with testing, do not modify. void testInsertNewFifthElement() { auto si = make_shared //Test inserting an item si->insertNewFifthElement(97); sstream.str(""); sstream checkTest("add test #2: adding 5th in middle", "10 11 12 13 97 14 15 16 17 18 19", sstream.str()); si = make_shared sstream.str(""); sstream //Test inserting an item si->insertNewFifthElement(97); sstream.str(""); sstream si = make_shared //Test just to make sure the data went in the list. checkTest("add test #5: adding only 4 values", "10 11 12 13", sstream.str()); //Test inserting an item si->insertNewFifthElement(97); sstream.str(""); sstream checkTest("add test #6: adding to end", "10 11 12 13 97", sstream.str()); } //This helps with testing, do not modify. void testDeleteFifthElement() { // Note from the instructor: Please do not delete the actual movie. It's very good and shouldn't be removed. auto si = make_shared //Test deleting an item si->deleteFifthElement(); sstream.str(""); sstream checkTest("delete test #2: delete 5th value", "10 11 12 13 15 16 17 18 19", sstream.str()); si = make_shared //Test deleting an item si->deleteFifthElement(); sstream.str(""); sstream si = make_shared //Test deleting an item si->deleteFifthElement(); sstream.str(""); sstream } //This helps with testing, do not modify. void testSwapFourthAndFifthElement() { // Note from the instructor: Please do not delete the actual movie. It's very good and shouldn't be removed. auto si = make_shared //Test swapping an item si->swapFourthAndFifthElement(); sstream.str(""); sstream }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
