nerdexam
iSQI

CTAL-TTA_001 · Question #32

Consider the following code fragment If (a>b) and (b>c) then b = (a+c)/2 endif Assume that in the following options, each of the three numbers in parenthesis represent the inputs for a test case…

The correct answer is C. (5, 4, 0); (4, 5, 0). Decision coverage requires the compound condition (a>b) AND (b>c) to evaluate to both TRUE and FALSE at least once - the minimum is 2 test cases. Option C works because (5, 4, 0) gives TRUE (5>4 AND 4>0 ), while (4, 5, 0) gives FALSE (4>5 , short-circuits to FALSE immediately)…

Structure-Based Testing

Question

Consider the following code fragment If (a>b) and (b>c) then b = (a+c)/2 endif Assume that in the following options, each of the three numbers in parenthesis represent the inputs for a test case, where the first number represents variable “a”, the second number represents variable “b”, and the third number represents variable “c”. Which of the following gives a set of test case inputs that achieves 100% decision coverage for this fragment of code with the minimum number of test cases? 2 credits [K3]

Options

  • A(5, 3, 2)
  • B(5, 3, 2); (5, 4, 0)
  • C(5, 4, 0); (4, 5, 0)
  • D(4, 5, 0); (5, 4, 5)

How the community answered

(19 responses)
  • A
    16% (3)
  • B
    5% (1)
  • C
    74% (14)
  • D
    5% (1)

Explanation

Decision coverage requires the compound condition (a>b) AND (b>c) to evaluate to both TRUE and FALSE at least once - the minimum is 2 test cases.

Option C works because (5, 4, 0) gives TRUE (5>4 AND 4>0 ), while (4, 5, 0) gives FALSE (4>5 , short-circuits to FALSE immediately) - both outcomes are covered with exactly 2 tests.

Why the others fail:

  • A has only one test case (5, 3, 2) → TRUE only; FALSE is never exercised.
  • B - the second test (5, 4, 0) is TRUE (5>4 AND 4>0 ), so both tests give TRUE; FALSE is never covered.
  • D - (4, 5, 0) is FALSE and (5, 4, 5) is also FALSE (5>4 but 4>5 ); both tests give FALSE, so TRUE is never covered.

Memory tip: For decision coverage, ask "do my test cases collectively produce at least one TRUE and one FALSE for the entire condition?" - individual sub-conditions don't matter here (that's condition coverage). Scan each option by computing the final TRUE/FALSE outcome and check that both appear.

Topics

#decision coverage#minimum test cases#condition testing#test case design

Community Discussion

No community discussion yet for this question.

Full CTAL-TTA_001 Practice