我试图通过GCOV找出我的源代码的覆盖范围。以下是结果的一部分:
328 : 8 : char* GetNumber() {
329 [ + - ][ + - ]: 8 : Log(__FILE__, __LINE__, CLASS_NAME, "Enter GetAccountNumber", "");
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
330 [ + - ][ + - ]: 8 : Log(__FILE__, __LINE__, CLASS_NAME, "Leave GetAccountNumber", "");
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
331 [ + - ]: 8 : return this->Number.c_str();
332 : : }
我确实使用了-coverage选项,默认情况下,coverage选项是启用的。 我想知道为什么分支数据看起来如此奇怪。 GCOV文件说:
’ + ’: Branch was taken at least once
’ - ’: Branch was not taken
’ # ’: The basic block containing the branch was never executed
那么为什么每行都有4 +/-,甚至在行中没有"行"。