Let's assume that we have a code like this:
switch(y)
{
case 1: case 2: case 3:
function();
break;
case 4: case 5: case 6:
function_2();
break;
}
Can we get the CC value as 6+1 here? Why a value of 1 is added? If the CC value is considered as 7, is that the number of independent paths?
What if a fall through scenario is considered above? As only possible two unique paths are there, 2 +1 =3
Which of the above are correct or are the both of them correct?
As we know,
CC = P+1.
Here, P = number of predicate nodes (conditions) = 2
Number of conditions will be 2 because:
source: here
So, CC = 2+1 = 3