为什么在gtest中将shared_variable重置为nil
Why shared_variable is reset to nil in gtest
这是我的代码,xmlDoc*d在"ExTest,try1"中总是重置为零
ex_test.cpp
typedef const char* str;
class ExTest : public ::testing::Test {
protected:
static str html;
static xmlDoc *d;
static void SetUpTestCase() {
html = "<html></html>";
xmlDoc *d = xmlParseDoc((const xmlChar *) html);
d;//0x685a30
}
};
str ExTest::html = NULL;
xmlDoc *ExTest::d = NULL;
TEST_F(ExTest, try1) {
d; //nil
}
您有两个不同的变量,都称为d
。
static xmlDoc *d; <- here's one
static void SetUpTestCase() {
html = "<html></html>";
xmlDoc *d = ... <- here's the other
你的意思可能是:
d = xmlParseDoc((const xmlChar *) html);
这将设置现有d
变量的值,而不是创建新的值。
相关文章:
- C++ Singleton - Prevent ::instance() to variable
- 如何通过多类"Union variable" (sfml) 使用轮询事件
- 将成员函数作为构造函数参数调用时出错 "Variable is not a type name"
- 为什么我会收到"Run-Time Check Failure #2 - Stack around the variable 'pr' was corrupted"错误?
- C++:寻找"returning address of local variable..."的更正
- C++ - 在我尝试制作一个简单的计算器时有一个"uninitialized local variable y used"警告
- Visual Studio Code "variable " u8 的 C/C++ 扩展名 " " 不是类型名称"
- C++ "Using Uninitialized Memory.. (variable name) "
- cudaMallocManaged for host-initiated variable
- Cppcheck "Reference to auto variable returned"失败的原因?
- OpenCV 和 C++:"Can't resolve variable 'Mat`"
- 是否有用于"go to variable type definition" C++中"auto"变量的 Visual Studio 键盘快捷方式?
- 冲刺错误"variable may be unsafe" (C4996)...选择?
- Visual Studio生成"Error: uninitialized local variable 'x' "而在线编译器不会 - 为什么?
- GUID variable for JPEG,BMP,PNG
- 如何修复初始化后'stack around variable was corrupted.'变量未更改为分配的值
- C++:从 "const variable*" 转换为"uint32"会失去精度
- C++17 'inline variable' vs 'extern' 关键字继承自 C 的新功能
- Tensorflow C++ API assign variable value
- 明确定义'static const variable in a struct'对C++ 11 及以上有什么影响吗?