Description: This in-class question explains aspects of testing, including path-completeness and boundary conditions.
Instructor: Dr. Ana Bell
The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high quality educational resources for free. To make a donation, or view additional materials from hundreds of MIT courses, visit MIT OpenCourseWare at ocw.mit.edu.
ANA BELL: Let's look at this exercise. So we have this function is even, same one as before, except now I'm giving you this implementation. If n is positive and n divided by 2's remainder is 0, return true. So if n is even and positive return true. The next one, if n is negative and divisible by 2 return true. OK, so far. And otherwise return false.
Question being, with that implementation is this test set n is 4, n is minus 4 path complete? And the answer is, yes. Because 4 is a positive number and divisible by 2. Minus 4 is a negative number and divisible by 2. And 5 would hit upon the else. So the answer is actually yes for that first question. Perfect.
Second question, with that implementation, which value for n is incorrectly labeled by that program? Well, n is very large still works, and is very small still works. And remember, I said you have to test boundary conditions. In this case, boundary conditions for this program being when n is equal to zero. So I think the orange is n is equal to 0. Perfect.