Professional Documents
Culture Documents
LCSAJ Coverage
LCSAJ Coverage
LCSAJ coverage
Es. Consider this simple program:
int function math
1. begin
2. int z;
3. if (s) then
4.
z = x + y;
5. else
6.
z= x * y;
7. end if;
8. return z;
9. end math;
(bool s,
int x,y)
Start line
(X)
End line
(Y)
Jump to
(Z)
-1 (exit)
LCSAJ coverage
Es.2 - Example of LCSAJ for loops:
int function factorial(int x)
1. begin
2. int y,z;
3. y = x;
4. z = x - 1;
5. while (z > 1) loop
6.
y = y * z;
7.
z--;
8. end loop;
9. return y;
10.end factorial;
Start line
(X)
End line
(Y)
Jump to
(Z)
10
-1
LCSAJ coverage
Es.2 - Example of LCSAJ for nested and concatenated if:
bool function example(int x)
1. begin
2. bool y;
3. if (g(x)) then
4.
found = TRUE;
5. else
6.
found = FALSE;
7. end if;
8. if (found) then
9.
if (x > 0) then
10.
y = TRUE;
11.
else
12.
y = FALSE;
13.
end if;
14. end if;
15.end example;
Jump to
(Z)
14
12
11
13
14
12
11
13
12
15
-1
13
15
-1
14
15
-1
LCSAJ coverage
LCSAJ coverage gives more information than Decision Coverage
because each branch is evaluated in different ways depending on
the previous branch and not as an individual node.
The advantage of this metric is that avoids the exponential
difficulty of path coverage. The disadvantage is that it does not
avoid unfeasible paths.