【发布时间】:2014-01-16 16:32:11
【问题描述】:
我正在cashier 课程上进行代码覆盖,我的老师对报告的含义进行了非常简短的教学,我认为这对我的软件工程技能的发展非常重要,因此我需要你的建议以下 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 的问题
1)Lines executed:100.00% of 18中18是什么意思及意义
2) no branches 是什么意思
3)4是什么意思,在Calls executed:100.00% of 4中的意义
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 的问题
1) 所有功能名称等::'_ZN7cashier8settriesEi' 几乎与收银功能名称等匹配:void settries(int) ,我认为它指的是同一个功能,但我的老师感觉不同,谁对吗??
2) Lines executed:100.00% of 3for 函数中的 3 是什么意思:'_ZN7cashier8settriesEi'
【问题讨论】:
标签: c++ class code-coverage gcov