Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help debugging to get test cases to run. TEST CODE / / Try to access out of bounds. string caughtError = ;

Need help debugging to get test cases to run. TEST CODE //Try to access out of bounds.
string caughtError ="";
try {
item = si->getFifthElement();
}
catch (std::out_of_range&){
caughtError = "caught";
}
checkTest(testNum++, correct, "caught", caughtError); //6
delete si;
SinglyLinkedList* ss = new SinglyLinkedList;
ss->pushBack("Multi Pass");
ss->pushBack("Lelu Dallas");
ss->pushBack("BIG BADA BOOM");
ss->pushBack("Bruce Willis");
ss->pushBack("Fried Chicken");
ss->pushBack("EEEAAAAAAAeeeaaaaaEEeeAAAEEaaaaAA");
checkTest(testNum++, correct, "Fried Chicken", ss->getFifthElement()); //8
delete ss;
return testNum -1== correct;
}
//This helps with testing, do not modify.
bool testInsertNewFifthElement(){
int testNum =1;
int correct =0;
cout "--------testInsertNewFifthElement Tests--------" endl;
SinglyLinkedList* si = new SinglyLinkedList;
for (int i =10; i 20; i++){
si->pushBack(i);
}
//Test just to make sure the data went in the list.
checkTest(testNum++, correct, "10111213141516171819", si->getStringFromList()); //1
//Test inserting an item
si->insertNewFifthElement(97);
checkTest(testNum++, correct, "1011121397141516171819", si->getStringFromList()); //2
delete si;
si = new SinglyLinkedList;
for (int i =10; i 15; i++){
si->pushBack(i);
}
//Test just to make sure the data went in the list.
checkTest(testNum++, correct, "1011121314", si->getStringFromList()); //3
//Test inserting an item
si->insertNewFifthElement(97);
checkTest(testNum++, correct, "101112139714", si->getStringFromList()); //4
delete si;
si = new SinglyLinkedList;
for (int i =10; i 14; i++){
si->pushBack(i);
}
//Test just to make sure the data went in the list.
checkTest(testNum++, correct, "10111213", si->getStringFromList()); //5
//Test inserting an item
si->insertNewFifthElement(97);
checkTest(testNum++, correct, "1011121397", si->getStringFromList()); //6
checkTest(testNum++, correct, 97, si->getLast()); //7
delete si;
// Now test inserting an invalid option
si = new SinglyLinkedList;
for (int i =10; i 13; i++){
si->pushBack(i);
}
si->insertNewFifthElement(1000);
//Test just to make sure the data didn't go in at all and didn't crash.
checkTest(testNum++, correct, "101112", si->getStringFromList()); //8
delete si;
return testNum -1== correct;
}
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Finance The Role Of Data Analytics In Manda Due Diligence

Authors: Ps Publishing

1st Edition

B0CR6SKTQG, 979-8873324675

Students also viewed these Databases questions

Question

Draw the graph of the equation x + |x| = y + | y |.

Answered: 1 week ago

Question

If you were Joe Melcan, what would you do?

Answered: 1 week ago

Question

1. Outline the listening process and styles of listening

Answered: 1 week ago

Question

4. Explain key barriers to competent intercultural communication

Answered: 1 week ago