Question: Suppose that David needs to test a function (named, compdate ) that compares dates with the following specification: int compdate (int year1 , int month1

Suppose that David needs to test a function (named, compdate) that compares dates with the following specification:

int compdate(int year1, int month1, int day1, int year2, int month2, int day2);

/* compdate returns 0 if date1 = date2, -1 if date1 before date2, 1 if date1 after date2, -2 if any element of any date is invalid; valid years are all integers (<0 >

David decides to use a random testing scheme to test the compdate function, he also decides to run 200 tests where each test is performed by the following function:

int randomtest_compdate() {

int i;

for (i=0; i<200; i++){ int y1 = random_int(); /* returns a random 32 bit value */ int y2 = random_int(); int m1 = (random_int() % 11) + 1; int m2 = (random_int() % 11) + 1; int d1 = (random_int() % 30) + 1; int d2 = (random_int() % 30) + 1; int c = compdate(y1,m1,d1,y2,m2,d2); oracle(y1,m1,d1,y2,m2,d2,c);

}

}

Assuming that oracle function does a good job of checking compdates correctness:

Discuss the random testing approach and propose how to improve it.

For each improvement, explain the weakness of the original scheme.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

When testing the compdate function the random testing approach has both advantages and limitations Here we will discuss the current strategys weaknesses and suggest improvements Random Testing Approac... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!