In some cases, with lambda expressions, CT and QualityScroll COVER may not display the same statement counts.
// definition of printVector() is skipped
// ...
void test(vector<int> &v)
{
printVector(v);
sort(v.begin(), v.end(), [](int first, int second) -> bool
{
return first > second;
});
printVector(v);
}
In CT, if no analysis option is particularly given, the return
statement of the lambda expression sort()
is included in the anaysis. As a result, the number of statements of test()
is counted as 4.
Open projectpath\.csdata\pa.ini
file and change the following option to Y
to exclude the lambda expression from project analysis.
If the option does not exist, manually add it.
ENABLE_LAMBDA_AS_UNKNOWN=Y
DISABLE_LAMBDA_CFG=Y
After editing the pa.ini
file, re-analyze the project and run the test. You can see that the number of statements in test()
is displayed as 3 in [Coverage View].
Need more help with this?
Don’t hesitate to contact us here.