它是 LCOV 的错误还是对一个函数中的不同命中计数有意义
is it a bug of lcov or meaningful about the different hit count in one function?
10 [ + - ][ + - ] : 2 : Conf::~Conf() {}
11 : :
12 : :
13 : 2 : Conf::Conf( std::string filename, std::string delimiter,
14 : : std::string comment )
15 [ + - ][ + - ]: 2 :: m_Delimiter(delimiter), m_Comment(comment)
16 : : {
17 : : // Construct a Conf, getting keys and values from given file
18 : :
19 [ + - ][ + - ]: 4 : std::ifstream in( filename.c_str() );
[ + - ]
20 : :
21 [ + - ][ - + ]: 2 : if( !in ) throw File_not_found( filename );
[ # # ]
22 : :
23 [ + - ]: 2 : in >> (*this);
24 : 2 : }
代码覆盖率报告如上。对于类 Conf,构造函数的命中数是 2,但这一行std::ifstream in( filename.c_str() );
的命中数是 4,我认为它也应该是 2。您如何看待此代码覆盖率报告中的不同命中数,这是一个错误吗lcov
或有意义?
看起来他们正在计算两件事(第 19 行有两行带方括号(,计数必须显示这两个条目的总和。为什么编译器将行一分为二?我不太确定。
就我而言,我实际上删除了分支计数功能以避免处理它。对于像我这样的大型项目,它似乎没有用。也许这样做可以消除这种副作用。
相关文章:
- 在C++中,使用带有 std::optional 参数的函数<T>来表示可选参数是否有意义?
- sizeof(函数)有意义吗?
- 插入向量时,使用lambda的返回而不是函数的返回是否有意义?
- 将指针的地址传递给需要指针到指针的函数有什么意义?
- 内联这个函数,确实有意义
- 将 final 关键字添加到没有基类(未派生)的类中的虚函数是否有意义
- 函数返回rvalue参考是否有意义
- 删除默认类构造函数有什么意义?
- 将 [[noreturn]] 添加到主函数是否有意义
- 拥有一个没有构造函数的类是否有意义
- constexpr移动构造函数是否有意义
- 在不提供定义的情况下重写函数有什么意义?
- Arduino C++:F()宏在函数内部有意义吗
- 初始化对象后,用隐式转换而不是赋值运算符调用构造函数有什么意义
- 具有多个非可选参数的转换构造函数是什么样子的?为什么它有意义
- 从 STL 容器继承并删除"新"运算符以防止由于缺少虚拟析构函数而导致未定义的行为是否有意义?
- 在某些情况下无法返回有意义值的 C++ 函数
- 在动态内存上操作,重载constmemeber函数有意义吗
- 这就是为什么 C++ 11 中的移动构造函数有意义
- static_cast对getInt()函数有意义吗