STUDENT ID: 25211207696: Exercise (Lab) 6
STUDENT ID: 25211207696: Exercise (Lab) 6
White-box Testing
1. Problem 1: Let’s design the set of TCs for the problem (see the code below) by using
the "Condition Coverage Criteria"!
2. Problem 2: Let’s design the set of TCs for the problem (see the code below) by using
the "Basic-Path Coverage"!
static int CountC(string s)
{
int index = 0; int i = 0; int j = 0; int k = 0; 1
char[] strArray = s.ToCharArray();
if (strArray[index] == 'A') 2
{
while (++index < strArray.Length) 3
{
if (strArray[index] == 'B') 4
{
j = j + 1; 5
k = 0;
}
else if (strArray[index] == 'C') 6
{
i = i + j; 7
k = k + 1;
j = 0;
}
}
i = i + j; 8
}
else
{
return -1; 9
}
return i; 10
} Ne
SOLUTION
Problem 1.
1. Determine the nodes and construct a control flow graph.
5. Determine the minimum number of paths that satisfy condition coverage criteria.
1-2-10-ne
1-2-3-4-ne
1-2-3-5-6-10-ne
1-2-3-5-7-10-ne
1-2-3-4-5-7-8-9-10-ne
Problem 2.
1. Determine the nodes and construct a control flow graph.
2. Compute Cyclomatic Complexity of the control flow graph.
1-2-9-10-Ne
1-2-3-8-10-Ne
1-2-3-4-5-3-8-10-Ne
1-2-3-4-6-3-8-10-Ne
1-2-3-4-6-7-3-8-10-Ne