For which of the following would major medical coverage be useful?

How many calls of the following function do I need to satisfy condition coverage?

  • int foo(int x, int y){ int z = 0; if ((x>0) && (y>0)) { z = x; } return z; } The wikipedia article says 3: foo (0,0), foo (1,0) and foo (1,1), but I'm not sure why do I need to call foo (1,0) in order to satisfy condition coverage.

  • Answer:

    The operator "&&" is shortcut operator, if (x>0) is false, (y>0) will not be evaluated, so it equals: int foo(int x, int y){ int z = 0; if(x>0){ if(y>0) { z = x; } } return z; } and condition cover is (0,x) (1,0) (1,1)

Liu Dong Qing at Quora Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.