问题描述
我有工会
using my_union = union my_union {
struct {
int var1;
int var2;
};
long
var;
bool operator == (const my_union & oth) {
return var == oth.var;
}
};
using my_union_1d = std::array < my_union,2 > ;
using my_union_2d = std::array < my_union_1d,3 > ;
class test {
public:
void Foo(my_union_2d & arg1);
};
现在我需要检查是否使用预期参数调用了Mocked-Foo
class TestMock: Public Test {
public: MOCK_METHOD(void,Foo,(my_union_2d & ));
};
my_union_2d expected_args;
EXPECT_CALL( * (TestMock * ) obj,Foo(expected_args)).Times(1):
但是由于未找到array ==运算符的数组,所以代码无法编译。我尝试更改AllOfArray,但似乎对GTest的文档迷失了。有人知道需要做什么或参考点吗?
解决方法
作为成员函数的正确setsebool -P haproxy_connect_any=1
应该是operator==
方法:
const
,
经过调查,我能够解决编译问题。
MATCHER_P(MyMatch,oth,"Arg is not the same")
{
for (uint8_t outer=0; outer <3; outer++)
{
for (uint8_t inner = 0; inner < 2; inner++)
{
if ((arg[inner].var1 != oth[inner].var1) ||
(arg[inner].var2 != oth[inner].var2))
return 0;
}
}
return 1;
}
并呼叫为
EXPECT_CALL( * (TestMock * ) obj,Foo(MyMatch(expected_args))).Times(1);