Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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;
DestructorTesterconst DestructorTester& obj
count;
totalCopyCalls;
void operatorconst 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 ;
unsigned int DestructorTester::totalCopyCalls ;
This helps with testing, do not modify.
bool checkTestint 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;
return false;
This helps with testing, comment it in when ready, but do not modify the code.
bool checkTestint 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;
return false;
This helps with testing, do not modify.
bool checkTestMemoryint 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 checkTestMemoryint 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 ;
int correct ;
cout testGetFifthElement Tests endl;
SinglyLinkedList si new SinglyLinkedList;
for int i ; i ; i
sipushBacki;
Test just to make sure the data went in the list.
checkTesttestNum correct, sigetStringFromList;
Test retrieving item.
int item sigetFifthElement;
checkTesttestNum correct, item;
delete si;
si new SinglyLinkedList;
for int i ; i ; i
sipushBacki;
Test just to make sure the data went in the list.
checkTesttestNum correct, sigetStringFromList;
Test retrieving item.
item sigetFifthElement;
checkTesttestNum correct, item;
delete si;
si new SinglyLinkedList;
for int i ; i ; i
sipushBacki;
Test just to make sure the data went in the list.
checkTesttestNum correct, sigetStringFromList;
Try to access out of bounds.
string caughtError ;
try
item sigetFifthElement;
catch std::outofrange&
caughtError "caught";
checkTesttestNum correct, "caught", caughtError;
delete si;
SinglyLinkedList ss new SinglyLinkedList;
sspushBackMulti Pass";
sspushBackLelu Dallas";
sspushBackBIG BADA BOOM";
sspushBackBruce Willis";
sspushBackFried Chicken";
sspushBackEEEAAAAAAAeeeaaaaaEEeeAAAEEaaaaAA;
checkTesttestNum correct, "Fried Chicken", ssgetFifthElement;
delete ss;
return testNum correct;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started