I have the following setup (using g++
10 and lcov
1.14):
g++ SampleScript.cpp -g -O0 -fprofile-arcs -ftest-coverage -o MyScript
./MyScript
lcov -d . -c -o coverage.info --rc lcov_branch_coverage=1
genhtml coverage.info -o cov_out --legend --branch-coverage
with
/* SampleScript.cpp */
class Container
{
public:
Container()
: m_value(0) { }
Container(int value)
: m_value(value) { }
int& value()
{
return m_value;
}
const int& value() const
{
return m_value;
}
private:
int m_value;
};
int main()
{
const Container c;
return c.value();
}
But the resulting output incorrectly shows a 100% coverage even though my code skips 2 of the functions (1 constructor & 1 value()
function). Are there any settings that I am missing?