Loops
- A single loop can be covered with cases: Looping and Not looping. But experience shows that many loop related bugs are not discovered by C1+C2
- Bugs hide themselves in corners and gather at boundaries in the cases of loops, at or around the minimum or maximum number of times the loop can be iterated
- The minimum number of iterations is often zero, but it need not be
- There are three case for a single loop:
Case 1:
Single loop, zero minimum, N maximum, No Excluded values
Case 2:
Single loop, non zero minimum, no excluded values
Case 3:
Single loops with excluded values
Case 1:
Single loop, zero minimum, N maximum, No Excluded values
Case 2:
Single loop, non zero minimum, no excluded values
Case 3:
Single loops with excluded values
Case 1:
- Try bypassing the loop (zero iterations). If you cant, you either have a bug, or zero is not the minimum and you have the wrong case
- Could the loop-control variable be negative? could it appear to specify a negative number of iteratins? What happens to such a value?
- One pass through the loop
- Two passes through the loop
- A typical number of iterations, unless covered by a previous test
- One less than the maximum number of iterations
- The maximum number of iterations
- Attempt one more than the maximum number of iterations. What prevents the loop control variable from having this value? What will happen with this value if it is force?
- Try one less than the expected minimum
- What happens if the loop control variables value is less than the minimum?
- What previous the value from being less than the minimum?
- The minimum number of iterations
- One more than the minimum number of iterations
- Once, unless covered by a previous test
- Twice, unless covered by a previous test
- A typical value
- One less than the maximum value
- The maximum number of iterations
- Attempt one more than the maximum number of iterations
- Treat single loops with excluded values as two sets of tests, consisting of loops without excluded values, such as case 1 and case 2 above
- The test cases to attempt would be 0, 1, 2, 4, 6, 7 for the first range and 10, 11, 15, 19,20, 21 for the second range
0 comments:
Post a Comment