Structural testing 0/ a program A program, written in e, is aimed at regulating the temperature of
Question:
Structural testing 0/ a program A program, written in
e, is aimed at regulating the temperature of the engine of a car in the range [OOe, 90°C] (function named 'regulator').
1. Analyze the functioning of this pro gram.
2. Define some functional test vectors.
3. Analyze the coverage of these test sequences.
Program:
int modify_temperature(int temperature, int action, int duration)
/* int temperature, action, durationi */
{
int final_temperature, ti switch (action)
}
{
case 1: / * Heating * /
final_temperature = temperaturei for (t=Oi t final_temperature = temperaturei for (t=Oi t #define heat _a_ little 10 #define heat_much 20 #define cool _a_ little 10 #define cool_much 20 /* ************************************************ */ int regulator(int initial_temperature, int heating_state, int fan_state, int variation) /* variation return o faulty 1 OK o a little bit 1 much the final temperature if the regulation is possible -3000 if the regulation is impossible */
{
int temperature, final_temperature;
if ((initial_temperature > 0) &&
(initial_temperature <90))
return(initial_temperature);
else {
if ((initial_temperature <0) &&
(heating_state==l))
{
temperature = initial_temperature;
while (temperature <0)
{
if (variation==O)
temperature = modify_temperature(temperature, 1, heat_a_little);
else temperature = modify_temperature(temperature, 1, heat_much);
}
final_temperature = temperature;
return(final_temperature);
}
if ((initial_temperature > 90) && (fan_state==l))
{
temperature = initial_temperature;
while (temperature > 90)
{
if (variation==O)
temperature = modify_temperature(temperature, 2, cool_a_little);
else temperature = modify_temperature(temperature, 2, cool_much);
}
final_temperature = temperature;
return(final_temperature) ;
}
if ((heating_state == 0) I I (fan_state 0))
return(-3000) ;
}
Step by Step Answer:
Design Of Dependable Computing Systems
ISBN: 978-9048159413
1st Edition
Authors: J C Geffroy ,G Motet