I think when simple condition coverage(scc) reaches 100%, then the mc/dc will also be 100%, is this correct? if this is not true, does anyone have some code snapshots to illustrate? thanks.
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.
Comments
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);
--------------------------------------------------------