Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.
Question about coverage metric scc and mc/dc
Comments
-
Hello skyocean
Yes, in most circumstances you are correct if you reach 100% simple condition coverage, MC/DC coverage will also be 100% percent. For example, when testing the try.cpp example below, C++Test will automatically generate test cases that will report about 50% simple condition coverage and 0% percent MC/DC coverage. Once a test case is created that will cover all possible conditions ( see test case below), the MC/DC coverage will also be 100% percent.
-----------------------cut-------------------------
// try.cpp
int e; // global function
void func(int a, int b, int c, int d)
{
if (( a < b ) && (c < d) && ((d +c ) < e))
{
}
}
--------------------------------------------------------
--------------------------------------------------------
/* test case to produce 100% coverage */
/* Pre-condition initialization */
/* Initializing argument 1 (a) */
int _a = -1;
/* Initializing argument 2 (b ) */
int _b = cpptestLimitsGetMaxInt();
/* Initializing argument 3 ( c ) */
int _c = 1;
/* Initializing argument 4 (d) */
int _d = 2;
/* Initializing global variable ::e */
{
::e = 5;
}
/* Tested function call */
::func(_a, _b, _c, _d);
--------------------------------------------------------0