Consider the following code:
1: public void trash (int x) {
2: int n, m;
3: m = 0;
4: if (x>0) m = 4;
5: if (x > 5)
6: n = 3*m
7: else
8: n = 4*m;
9: int o = takeOut(n, m); // Note Order
10: System.out.println("o is: " + o);
11: }
12: public int takeOut (int a, int b) {
13: int d, e;
14: d = 42*a;
15: if (a>0)
16: e = 2*b+d;
17: else
18: e = b+d;
19: return e;
20: }
1: (m,3) -> (b,16) 2: (m,3) -> (b,18) 3: (m,4) -> (b,16) 4: (m,4) -> (b,18) 5: (n,6) -> (a,14) 6: (n,8) -> (a,14) 7: (e,16) -> (o,10) 8: (e,18) -> (o,10)
x = 0 covers 2, 6, and 8 x = 1 covers 3, 6, and 7 x = 6 covers 3, 5, and 7Note that the second test doesn't add anything in terms of coverage.