Implementing run_unit_tests You are given this code for run_unit tests. void run
ID: 3704374 • Letter: I
Question
Implementing run_unit_tests You are given this code for run_unit tests. void run_unit tests(void) // 2 example unit tests //UTC midnight on 20th March ->time in Sydney: 11am AEDT assert (get_local_time (TOWN_SYDNEY, 3, 20, 0) 1100) // 42 is not a valid month assert(get_local_time(TOWN_SYDNEY, 42, ,INVALID_INPUT) //ADD YOUR ASSERT STATEMENTS HERE // you should add at least 40 more assert statements to this function // with a comment for each test explaining it // there should be comment before this function // explaining your overall testing strategy run_unit_tests includes two unit tests. Add your own unit tests for inputs to run_unit_tests. Implement them in exactly the same way as the example unit tests using assert statements. Do not take the inputs autotest uses and add them to run_unit_tests - invent your own tests.Explanation / Answer
Solution:
Note:
Required assert statement only given, there is no detailed information or code to give complete code.
void run_unit_tests(void)
{
// 2 example unit tests
// UTC midnight on 20th March -> time in Sydney: 11am AEDT
assert(get_local_time(TOWN_SYDNEY, 3, 20, 0) == 1100);
// 42 is not a valid month
assert(get_local_time(TOWN_SYDNEY, 42, 0, 0) == INVALID_INPUT);
// ADD YOUR ASSERT STATEMENTS HERE
// you should add at least 40 more assert statements to this function
// with a comment for each test explaining it
// there should be comment before this function
// explaining your overall testing strategy
// INVALID INPUTS
// code to check the towns which are invalid
// The town input which is below the lower limit
assert(get_local_time( -2, 3, 20, 0) == INVALID_INPUT);
// The town input which is above the upper limit
assert(get_local_time( 15, 3, 20, 0) == INVALID_INPUT);
// The town input which is above the upper limit
assert(get_local_time( 99, 3, 20, 0) == INVALID_INPUT);
// Time input which is below than the lower limit of 24hrs format
assert(get_local_time(TOWN_BRISBANE, 3, -2, 0) == INVALID_INPUT);
// Time input 2160 is incorrect 24hrs format
assert(get_local_time(TOWN_BRISBANE, 3, 2160, 0) == INVALID_INPUT);
// Time input should be 0001 in 24hrs format for 2401
assert(get_local_time(TOWN_BRISBANE, 3, 2401, 0) == INVALID_INPUT);
// invalid value of day beyond maximum limit
assert(get_local_time(TOWN_BRISBANE, 3, 45, 0) == INVALID_INPUT);
// invalid day value below then minimum value
assert(get_local_time(TOWN_BRISBANE, 3, -2, 0) == INVALID_INPUT);
// invalid month value of February
assert(get_local_time(TOWN_BRISBANE, 2, 30, 0) == INVALID_INPUT);
// invalid month value of September
assert(get_local_time(TOWN_BRISBANE, 9, 32, 0) == INVALID_INPUT);
// invalid month value of October
assert(get_local_time(TOWN_BRISBANE, 3, 33, 0) == INVALID_INPUT);
// month input which is below minimum value of yearly standard
assert(get_local_time(TOWN_BRISBANE, -2, 20, 0) == INVALID_INPUT);
// month input which is above maximum value of yearly standard
assert(get_local_time(TOWN_BRISBANE, 13, 20, 0) == INVALID_INPUT);
// month input above maximum value of yearly standard
assert(get_local_time(TOWN_BRISBANE, 99, 20, 0) == INVALID_INPUT);
// TRANSITIONS
// Code to check each offset which one is transitions over 2359 and back to 0000
// offset AEDT
assert(get_local_time(TOWN_BRISBANE, 4, 20, 1300) == 0000);
// offset AEST
assert(get_local_time(TOWN_BRISBANE, 7, 14, 1400) == 0000);
// offset ACDT
assert(get_local_time(TOWN_DARWIN, 3, 14, 1330) == 0000);
// offset ACST
assert(get_local_time(TOWN_DARWIN, 7, 14, 1430) == 0000);
// offset LHDT
assert(get_local_time(TOWN_PERTH, 3, 14, 1300) == 0000);
// offset LHST
assert(get_local_time(TOWN_PERTH, 7, 14, 1330) == 0000);
// offset NZDT
assert(get_local_time(TOWN_HOBART, 3, 14, 1100) == 0000);
// offset NZST
assert(get_local_time(TOWN_HOBART, 7, 14, 1200) == 0000);
// TESTS BASED TOWN
// variable to store town number
int vartown;
// PERTH 9
vartown = 9;
// DST between January and April
assert(get_local_time(vartown, 2, 14, 1200) == 2000);
// Standard time between April and October
assert(get_local_time(vartown, 6, 14, 1200) == 2000);
// DST between October and December
assert(get_local_time(vartown, 11, 14, 1200) == 2000);
// EUCLA 5
vartown = 5;
// DST between January and April
assert(get_local_time(vartown, 2, 14, 1200) == 2045);
// Standard time between April and October
assert(get_local_time(vartown, 6, 14, 1200) == 2045);
// DST between October and December
assert(get_local_time(vartown, 11, 14, 1200) == 2045);
// DARWIN TOWN 4
vartown = 4;
// DST between January and April
assert(get_local_time(vartown, 2, 14, 1200) == 2230);
// Standard time between April and October
assert(get_local_time(vartown, 6, 14, 1200) == 2130);
// DST between October and December
assert(get_local_time(vartown, 11, 14, 1200) == 2230);
// DST will end at year start
assert(get_local_time(vartown, 5, 31, 1629) == 259);
// DST will end at year start
assert(get_local_time(vartown, 5, 31, 1630) == 200);
// Second half of the year for the beginning of DST
assert(get_local_time(vartown, 11, 6, 1629) == 159);
// Second half of the year for the beginning of DST
assert(get_local_time(vartown, 11, 6, 1630) == 300);
}