When I use a stream operator, gcov/lcov report a branch not covered.
For example :
namespace {
const std::string LinuxBuildVersionFile = "/etc/linux.build.version";
}
std::string GetLinuxBuildVersion()
{
std::ifstream version_file(LinuxBuildVersionFile);
std::string version;
version_file >> version;
return version;
}
For the 3rd line, gcov reports : "one branch taken, one branch not taken". I suppose it is for the case where the file doesn't exist, but if so, it seems to me it should be reported in the stream operator coverage report.
What can I do so that the reported coverage is 100 % when I pass through this function ?
Thanks.