Commit 8f619461 by Thanassis Tsiodras

### Updated phrasing

parent 4ff765a7
 ... @@ -70,13 +70,18 @@ exercised - e.g. `b` was always 0! Look at the last branch counter, i.e. branch ... @@ -70,13 +70,18 @@ exercised - e.g. `b` was always 0! Look at the last branch counter, i.e. branch 1: 11: puts("Decision 1 was true"); 1: 11: puts("Decision 1 was true"); ``` ``` That is, the object code generated to represent the checking of condition `b==0` NEVER evaluated the condition as false. This means we don't have 100% condition coverage. Now, if we want to get 100% condition coverage, every condition in a decision Now, if we want to get 100% condition coverage, every condition in a decision in the program must take all possible outcomes at least once. In the code we in the program must take all possible outcomes at least once. In the code we have 4 conditions `a > 1`, `b == 0`, `a == 2`, `x > 1`. We need test cases that make have 4 conditions `a > 1`, `b == 0`, `a == 2`, `x > 1`. We need test cases that make all 4 of the conditions true and false. The previous test cases don’t suffice all 4 of the conditions true and false. The previous test cases don’t suffice because e.g. the condition `b == 0` is never evaluated to false. That could mean a because e.g. the condition `b == 0` is never evaluated to false. That could mean untested critical scenario that could have a bug. To satisfy condition coverage an untested critical scenario that could have a bug. we could have the following test cases: To achieve 100% condition coverage we could have the following test cases: a = 1, b = 0, x = 2 → a > 1(F), b == 0(T), a == 2(F), x > 1(T) a = 1, b = 0, x = 2 → a > 1(F), b == 0(T), a == 2(F), x > 1(T) a = 2, b = 1, x = 1 → a > 1(T), b == 0(F), a == 2(T), x > 1(F) a = 2, b = 1, x = 1 → a > 1(T), b == 0(F), a == 2(T), x > 1(F) ... @@ -92,6 +97,8 @@ we could have the following test cases: ... @@ -92,6 +97,8 @@ we could have the following test cases: Now each condition has been both true and false, but overall, decision 1 Now each condition has been both true and false, but overall, decision 1 was NEVER true - because its two conditions were once FT, and once TF. was NEVER true - because its two conditions were once FT, and once TF. Since the decision is formed from a logical AND (`&&`) of the two conditions, it was never evaluated as true. The gcov output indicates this, in that... The gcov output indicates this, in that... ... @@ -109,9 +116,9 @@ The gcov output indicates this, in that... ... @@ -109,9 +116,9 @@ The gcov output indicates this, in that... 2: 13: puts("Decision 1 was false"); 2: 13: puts("Decision 1 was false"); ``` ``` (b) ...and the branch coverage is also not 100%, since the FINAL (b) ...and the branch coverage is also not 100%, since the FINAL branch branch (the one that says in the object code, we've evaluated to true, in the object code (the one that says *"we've evaluated to true, let's execute the action of the `if`) is also not executed (see above, let's execute the action of the `if`"*) is also not executed (see above, branch 2 is taken 0 times). branch 2 is taken 0 times). Since both types of coverage are important and one does not guarantee Since both types of coverage are important and one does not guarantee ... ...
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment