- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在收银员
课上做代码覆盖,我的老师对报告的含义进行了非常简短的教学,我觉得这对我的软件工程技能的发展非常重要。因此,我需要您对以下 gcov 报告的解释提出建议。如果有任何有助于我理解 gcov 的链接或文章,我将不胜感激。
头文件
#ifndef CASHIER_H
#define CASHIER_H
#include <string>
using namespace std;
class cashier
{
public:
void setID(string);
string getID();
void setPassword(string);
string getPassword();
void settries(int);
int gettries();
void increase_tries();
private:
string ID;
string Password;
int tries;
};
#endif /* CASHIER_H */
执行文件
#include "cashier.h"
void cashier::setID(string value)
{
this->ID = value;
}
void cashier::setPassword(string value)
{
this->Password = value;
}
string cashier::getID()
{
return this->ID;
}
string cashier::getPassword()
{
return this->Password;
}
void cashier::settries(int value)
{
this->tries=value;
}
int cashier::gettries()
{
return this->tries;
}
void cashier::increase_tries()
{
this->tries = this->tries + 1 ;
}
我在命令提示符中键入以下命令以在类上使用 gcov
gcov -b cashier.gnco
我得到了如下结果A
File 'cashier.cpp'
Lines executed:100.00% of 18 //what does the 18 mean
No branches //what does no branches mean
Calls executed:100.00% of 4 // what does 4 mean ??
cashier.cpp:creating 'cashier.cpp.gcov'
File '/usr/include/c++/4.4/bits/basic_string.h' // Where did this come from ??
Lines executed:0.00% of 2
No branches
Calls executed:0.00% of 1
/usr/include/c++/4.4/bits/basic_string.h:creating 'basic_string.h.gcov
我输入以下命令
gcov -f cashier.gnco
我得到了如下结果B
Function '_ZN7cashier8settriesEi' // does this refer to the function :settries
Lines executed:100.00% of 3 // my teacher doesnt think so but i feel it refer
//to it , who is correct??
Function '_ZN7cashier8gettriesEv'
Lines executed:100.00% of 2
Function '_ZN7cashier14increase_triesEv'
Lines executed:100.00% of 3
Function '_ZN7cashier11getPasswordEv'
Lines executed:100.00% of 2
Function '_ZN7cashier5getIDEv'
Lines executed:100.00% of 2
Function '_ZNSsaSERKSs'
Lines executed:0.00% of 2
Function '_ZN7cashier11setPasswordESs'
Lines executed:100.00% of 3
Function '_ZN7cashier5setIDESs'
Lines executed:100.00% of 3
File 'cashier.cpp'
Lines executed:100.00% of 18
cashier.cpp:creating 'cashier.cpp.gcov'
File '/usr/include/c++/4.4/bits/basic_string.h'
Lines executed:0.00% of 2
/usr/include/c++/4.4/bits/basic_string.h:creating 'basic_string.h.gcov'
我对结果 A 的问题
18 是什么意思,它在 Lines executed:100.00% of 18
中有什么意义?
没有分支
是什么意思?
4 是什么意思,它在 Calls executed:100.00% of 4
中有什么意义?为什么我的类中有 7 个函数,却有 4 个函数调用?
整个段落是什么意思?
File '/usr/include/c++/4.4/bits/basic_string.h'
Lines executed:0.00% of 2
No branches
Calls executed:0.00% of 1
/usr/include/c++/4.4/bits/basic_string.h:creating 'basic_string.h.gcov
我对结果 B 的问题
所有函数名称等:_ZN7cashier8settlesEi
。几乎匹配收银员函数名称等:void settries(int)
。我认为它指的是相同的功能,但我的老师却不这么认为。哪个是正确的?
函数 _ZN7cashier8settriesEi
的 Lines executed:100.00% of 3
中的 3 是什么意思?
最佳答案
阅读手册页。在终端窗口中键入 man gcov
。另外,谷歌gcov。网上有说明。
gcov -b 查找分支。您的代码没有分支(没有 if 语句,没有循环),因此在这里使用 -b 选项有点没有意义。
gcov -f 给出每个函数的摘要。它省略了分支概率。
关于数字,有时 gcov 将左大括号和右大括号计为可执行语句,有时则不然。后面有点疼。查看 cashier.cpp.gcov 文件以查看哪些行被计算在内,哪些行没有。
关于诸如 _ZN7cashier8settriesEi 之类的名称:这是 cashier::settries(int)
的损坏名称。通过 c++filt 传递这些名称。
关于/usr/include/c++/4.4/bits/basic_string.h,忽略那些文件。它们不是您的,但会出现在 gcov 输出中。
关于c++ - Gcov报告解读,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21212832/
我使用 gcc -fprofile-arcs -ftest-coverage [filenames] 在一些 .c 文件上运行 gcov 工具。命令 但向该命令提供文件名是一项非常繁琐的工作。 相反,
我可以在 Windows 中安装 gcov 工具吗? 或者我可以在windows的eclipse中使用这个工具的插件吗? 我对这个工具很陌生。我对这个工具没有任何想法。请帮我获取这个工具的信息。 请告
我在 RHEL 上运行 gcov/gcc 4.1.2。 当我想为 gcov 文件指定一个目录时。关于如何执行此操作的任何想法? 最佳答案 从要创建其文件的目录运行 gcov。您必须使用 -o 参数来告
我正在尝试使用 gcov-tool 为多个源文件合并一些现有的覆盖率数据(不是我自己创建的)。但是当我调用 gcov-tool merge dir1 dir2 时,dir1 和 dir2 是包含 .g
我正在运行 gcov 来测量覆盖率,但对于我在 C 代码中使用的每个函数,我都收到“有来自退出 block 的弧”消息。这条消息有什么问题吗?我应该忽略它们吗? 最佳答案 这可能意味着您的 gcno
我正在尝试使用 gcc 4.8.2 和 lcov 1.10 获取 html 覆盖率以进行测试。我确定我的源文件、对象和 gcov 文件位于同一位置,并且我正在从我运行编译器的目录中运行 lcov。 我
我在远程服务器上用 gcov 标志编译了我的源文件。 CFLAGS += -fprofile-arcs -ftest-coverage -lgcov -coverage 编译工作正常。 gcc 4.7
在使用 gcov 支持编译我的项目时,我面临以下错误 以下是我在编译时的标志信息 编译器标志: CXXFLAGS="-Wno-deprecated -g -ggdb -fprofile-arcs -f
我正在尝试在 iPhone 项目上使用 gcov 并遵循 Apple 的说明 here ,但它不起作用。 当我构建并配置项目时,会为每个目标文件创建 .gcda 文件。但没有执行的行记录到 .gcda
我尝试使用 gcov 编译一个简单的应用程序并收到以下链接错误: gcc AllTests.o CuTestTest.o CuTest.o -o TestTest AllTests.o: In fun
资料夹结构 〜/沙盒/ dev 〜/沙盒/测试 我在dev目录中有main.cpp。我使用--coverage标志编译了代码以生成代码覆盖率。 现在,将生成a.out和main.gcno文件。 现在我
我正在使用 gcov 来获取我们项目的代码覆盖率,但它经常报告 50% 的普通函数调用的条件覆盖率。函数是否接受任何参数或返回任何数据都没有任何区别。我在 Jenkins 中使用 gcovr 和 Co
无法使用我的 C/C++ Makefile 项目在 Windows 上使用 mingw32 的 googletest 获取 gcov 覆盖文件完整源代码位于https://github.com/rus
我正在使用 gcov这是我第一次遇到与此 thread 中报告的问题类似的问题.但是,根据该线程中的评论,我无法解决我的问题。 我正在尝试测量 KMyMoney-4.6.4 中具体测试用例的覆盖率,即
我正在使用 eclipse indigo 和 linux 工具。其中一个工具是 gcov 的插件。我有一个项目是 statis lib(点一个文件)和另一个项目是一个单元测试,它与这个 lib 链接并
我在 32 位机器上使用 -fprofile-arcs -ftest-coverage 标志交叉编译我的可执行文件以覆盖。我在 64 位目标机器上运行生成的可执行文件。 当我运行可执行文件时,它不会生
是否可以使用 gcov 进行多线程应用程序的覆盖测试? 我已经对我们的代码库进行了一些简单的测试,但如果能对我们正在实现的覆盖范围有一些了解就更好了。如果 gcov 不合适,任何人都可以推荐一个替代工
我正在使用 gcov 来衡量我贡献的 c++ 库的测试覆盖率。出于某种原因,gcov 无法将许多文件中的行识别为可执行文件。在给定文件的 160 多行中,它会说其中 40 行是可执行的。例如:
MWE #include struct Foo { Foo() { std::cout << "Constructing Foo " << this << std::endl; }
我正在使用 gcov 测量我的 C++ 代码中的覆盖率。我希望能够标记某些源代码行,以便在使用 gcovr 时将它们排除在覆盖率报告之外。我知道它们存在,因为我曾经偶然发现过它们,但现在我找不到看到它
我是一名优秀的程序员,十分优秀!