#C++ tests

4 messages · Page 1 of 1 (latest)

forest sorrel
#

I don´t understand why the tests find an error in my code:

// ovenTime returns the amount in minutes that the lasagna should stay in the
// oven.
int ovenTime() {
// TODO: Return the correct time.
return 40;
}
/* remainingOvenTime returns the remaining
minutes based on the actual minutes already in the oven.
*/
int timeSpendInOven = 0;
int neededBakeTime = 40;

int remainingOvenTime(int actualMinutesInOven) {
// TODO: Calculate and return the remaining in the oven based on the time
// the lasagna has already been there.
int actual = neededBakeTime - timeSpendInOven;
return actual;
}

/* preparationTime returns an estimate of the preparation time based on the
number of layers and the necessary time per layer.
*/
int ovenTimeForEachLayer = 2;

int preparationTime(int numberOfLayers) {
// TODO: Calculate and return the preparation time with the
// numberOfLayers.
int time = ovenTimeForEachLayer * numberOfLayers;
return time;
}

// elapsedTime calculates the total time spent to create and bake the lasagna so
// far.
int elapsedTime(int numberOfLayers, int actualMinutesInOven) {
// TODO: Calculate and return the total time so far.
return preparationTime(numberOfLayers) + actualMinutesInOven;
}

#

This is the test failed:

#

FAILED:
REQUIRE( expected == actual )
with expansion:
40 == 0
at /tmp/lasagna/lasagna_test.cpp:25

odd falcon
#

I think this is not the complete message from the failed test. There should be more that tells you which function gets called.