在xxxx.h文件中:
struct dn_instance_pair
{
std::string theDn;
int theInstance;
};
typedef struct dn_instance_pair t_dn_inst_pair;
struct table_rowid_type
{
char theTable[101];
sqlite3_int64 theRowid;
int operation;
};
// static class members
static vector dninstList;
static vector tablerowidList;
在xxxx.cpp中
// declaration of vectors.
// Included to this post only for completeness.
vector xxxx::dninstList;
vector xxxx::tablerowidList;
这些向量在静态回调函数中处理,因此它们也必须是静态的.
在cpputest中,当尝试在这些向量中的任何一个中添加某些内容时,会发生故障:
Leak size: 8 Allocated at: and line: 0. Type: "new" Content: "
添加到向量中的东西是自动变量,它发生在正常函数中:
t_dn_inst_pair thePair;
thePair.theDn = updated_dn;
thePair.theInstance = updated_instance;
在测试用例结束时清除向量:
xxxx::yyyy()->dninstList.clear();
(yyyy()返回指向单例xxxx对象的指针)
“This is a false positive. This is a one-time allocation and a
side-effect of C++ memory allocation and static initialization.”
所以我的问题是:
这种失败真的是假阳性吗?
br Esko