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
Related Q & A:
- How many push ups and sit ups should I do?Best solution by Yahoo! Answers
- How many watts do I need between each subwoofer?Best solution by Yahoo! Answers
- How many direct TV receivers do I need for 3 rooms?Best solution by Yahoo! Answers
- How many more subscribers do I need for a partnership?Best solution by Yahoo! Answers
- How many regents do I need to graduate?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
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.