Question: #define DOCTEST _ CONFIG _ IMPLEMENT _ WITH _ MAIN #include doctest.h / / Use Approx from doctest without saying doctest::Approx using doctest::Approx; /
#define DOCTESTCONFIGIMPLEMENTWITHMAIN
#include "doctest.h
Use Approx from doctest without saying doctest::Approx
using doctest::Approx;
#include
#include
using namespace std;
int getArea int width, int length
return width length;
int leftoverCardboardint cutoutSize
int sheetWidth cutoutSize;
return getArea sheetWidth, sheetWidth;
int getVolume int width, int length, int height
return getArea width length height;
int getMaxHeight int width, int length
return min width length ;
int getBestHeight int width, int length
int bestHeight maxVolume ;
int maxHeight getMaxHeight width length;
for int h ; h maxHeight; h
int currentVolume getVolume width h length h h;
if currentVolume maxVolume currentVolume maxVolume && leftoverCardboardh leftoverCardboard bestHeight
maxVolume currentVolume;
bestHeight h;
return bestHeight;
void printBoxOptions int width, int length
cout setw "Height" setw "Width" setw "Length" setw "Volume" setw "Leftover Amount" endl;
Tests
Uncomment tests to work on them. Make sure any test that does not compile or
causes a crash gets commented back out. Any test that runs should be left
on uncommented even if the test fails.
TESTCASE "getArea"
cout : getArea" endl;
CHECK getArea;
CHECK getArea;
TESTCASE "getVolume"
cout : getVolume" endl;
CHECK getVolume;
CHECK getVolume;
TESTCASE "leftoverCardboard"
cout : leftoverCardboard" endl;
CHECK leftoverCardboard;
CHECK leftoverCardboard;
TESTCASE "getMaxHeight"
cout : getMaxHeight" endl;
CHECK getMaxHeight;
CHECK getMaxHeight;
CHECK getMaxHeight;
CHECK getMaxHeight;
TESTCASE "getBestHeight"
cout : getBestHeight" endl;
CHECK getBestHeight;
CHECK getBestHeight;
CHECK getBestHeight;
CHECK getBestHeight;
CHECK getBestHeight;
TESTCASE "createBoxDescription"
cout : createBoxDescription" endl;
string test createBoxStatsString;
string goal;
INFO will only print if test is failed
INFOtest test;
INFOgoal goal;
CHECK test goal;
string test createBoxStatsString;
string goal;
INFO will only print if test is failed
INFOtest test;
INFOgoal goal;
CHECK test goal;
TESTCASE printBoxOptions
cout : printOptions" endl;
Not really an automated test. Need to verify output manually
cout RExpected:
Height Width Length Volume Leftover Amount
