EXPECT_EQ Error
EXPECT_EQ Error
我正在使用谷歌测试函数EXPECT_EQ来运行函数的测试用例。函数 "find" 返回一个列表,并接收要查找的名称字符串。这是我的测试函数:
TEST_F(test_neighborhood, find) {
list<Man> test;
test.push_back(Man("username", "John", "Smith", 1, 1, ""));
EXPECT_EQ(neighborhood.find("John"), test);
}
但是当我试图"制造"时,它给了我一个很长的错误/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/algorithm:665:71:错误:无效 二进制表达式的操作数("const Man"和"const Man"( bool operator(((const _T1& __x, const _T1& __y( const {return __x == __y;}
我没有正确使用EXPECT_EQ吗?如何修复此错误?
EXPECT_EQ
要求为传递的项定义相等运算符。 std::list
已经有这样一个运算符为每个存储项调用相等运算符。因此,您似乎需要定义operator ==
来比较Man
类的两个实例的相等性:
bool operator ==(Man const & left, Man const & right)
相关文章:
- "error: no matching function for call to"构造函数错误
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 使用 LuaBridge 将 LuaJIT 绑定到C++会导致"PANIC: unprotected error"
- OpenMP卸载说'fatal error: could not find accel/nvptx-none/mkoffload'
- C++错误:"error: int aaa::bbb is protected within this context"
- 尝试链接我的着色器时,我收到错误代码"error c5145 must write to gl_position"
- C++,在int数组中输入字符串或字符会输出0,而不是ascii或error
- 使用 cmake 的 LLVM 构建在 tsan_libdispatch_mac.cc 期间失败; "Error: conflicting types for ..."
- C++ "error: invalid use of void expression"
- struct.error:解压缩 C++ 结构时,解包需要 288 字节的缓冲区
- 如何修复"error: ‘_1’ was not declared in this scope"?
- 从不同目录执行时"symbol lookup error:",否则从构建目录执行时按预期工作
- 对象声明中的模板"error: expected expression"
- 在C++中使用 Catch 测试框架编译错误"error: expected ';' at end of declaration list"
- OpenCV 3.4.1 error readNetFromTensorflow 无法在 cv::d nn::ReadProtoFromBinaryFile 中打开 .pb
- 已解决 - C++ 的崇高文本中的"fatal error: opencv: no such file or directory"
- 为什么我会"error: expected expression"?
- CMake Error at modules/videoio/cmake/detect_ffmpeg.cmake:16
- 如果两个静态库使用相同的另一个静态库,如何避免"LNK2005 Already Defined error"?
- 在 Objective-C++ -> EXC_BAD_ACCESS Error 中使用"new"关键字