Question: I need help DEBUGGING so the TEST CASES will run. This is my third time asking for help, please someone help me with correct coding.

I need help DEBUGGING so the TEST CASES will run. This is my third time asking for help, please someone help me with correct coding. TEST CASES: class DestructorTester {
public:
static unsigned int getCount(){
return count;
}
static unsigned int getTotalCopyCalls(){
return totalCopyCalls;
}
DestructorTester(){
count++;
}
DestructorTester(const DestructorTester& obj){
count++;
totalCopyCalls++;
}
void operator=(const DestructorTester& obj){
// Not a constructor, so no new object is created here. No need to increment count.
totalCopyCalls++;
}
~DestructorTester(){
count--;
}
private:
static unsigned int count;
static unsigned int totalCopyCalls;
};
unsigned int DestructorTester::count =0;
unsigned int DestructorTester::totalCopyCalls =0;
//This helps with testing, do not modify.
bool checkTest(int testNum, int& correct, int whatItShouldBe, int whatItIs){
if (whatItShouldBe == whatItIs){
correct++;
cout "Passed " testNum endl;
return true;
}
else {
cout "***Failed test " testNum "***" endl " Output was " whatItIs endl " Output should have been " whatItShouldBe endl;
cout "The unit test checker is closing down the program now due to a failed test" endl;
exit(1);
return false;
}
}
//This helps with testing, comment it in when ready, but do not modify the code.
bool checkTest(int testNum, int& correct, string whatItShouldBe, string whatItIs){
if (whatItShouldBe == whatItIs){
correct++;
cout "Passed " testNum endl;
return true;
}
else {
if (whatItShouldBe ==""){
cout "***Failed test " testNum "***" endl " Output was " whatItIs endl " Output should have been blank. " endl;
}
else {
cout "***Failed test " testNum "***" endl " Output was " whatItIs endl " Output should have been " whatItShouldBe endl;
}
cout "The unit test checker is closing down the program now due to a failed test" endl;
exit(1);
return false;
}
}
//This helps with testing, do not modify.
bool checkTestMemory(int testNum, int& correct, int whatItShouldBe, int whatItIs){
if (whatItShouldBe == whatItIs){
correct++;
cout "Passed " testNum endl;
return true;
}
else {
cout "***Failed test " testNum ". You have a memory leak. " endl;
return false;
}
}
//This helps with testing, do not modify.
bool checkTestMemory2(int testNum, int& correct, int beforeTotalCopyCalls, int afterTotalCopyCalls){
if (beforeTotalCopyCalls == afterTotalCopyCalls){
correct++;
cout "Passed " testNum endl;
return true;
}
else {
cout "***Failed test " testNum "You didn't move the pointers around, you copied values "(afterTotalCopyCalls - beforeTotalCopyCalls)" times." endl;
return false;
}
}
//This helps with testing, do not modify.
bool testGetFifthElement(){
int testNum =1;
int correct =0;
cout "--------testGetFifthElement 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 retrieving item.
int item = si->getFifthElement();
checkTest(testNum++, correct, 14, item); //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 retrieving item.
item = si->getFifthElement();
checkTest(testNum++, correct, 14, item); //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
//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;
}
 I need help DEBUGGING so the TEST CASES will run. This

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!