C++ 如何在GoogleMock中匹配C样式数组
给出下面的例子C++ 如何在GoogleMock中匹配C样式数组,c++,googletest,C++,Googletest,给出下面的例子 #include <gmock/gmock.h> #include <gtest/gtest.h> #include <stdint.h> using namespace ::testing; class Tested { public: virtual void setArray(const uint32_t[3]) {}; }; class Tested_mock: public Tested { public: M
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <stdint.h>
using namespace ::testing;
class Tested
{
public:
virtual void setArray(const uint32_t[3]) {};
};
class Tested_mock: public Tested
{
public:
MOCK_METHOD1(setArray, void(const uint32_t[3]));
};
class TestRunner: public ::testing::Test
{
public:
StrictMock<Tested_mock> t;
};
TEST_F(TestRunner, test)
{
uint32_t a[3] = {1UL, 2UL, 3UL};
EXPECT_CALL(t, setArray(_)).With(ElementsAreArray(a));
t.setArray(a);
}
#包括
#包括
#包括
使用namespace::测试;
等级考试
{
公众:
虚空集合数组(const uint32_t[3]){};
};
类测试\u模拟:公共测试
{
公众:
模拟方法1(集合数组,void(const uint32_t[3]);
};
类TestRunner:public::testing::Test
{
公众:
斯特里克特;
};
测试(TestRunner,TEST)
{
uint32_t a[3]={1UL,2UL,3UL};
使用(elementsarrarray(a)),预期_调用(t,setArray());
t、 setArray(a);
}
我不明白为什么在将参数更改为uint32\u t*
有效时无法编译此代码段。Gmock是否有固定大小数组参数的问题
您可以在这里找到编译输出
uint32_t a[]={1UL,2UL,3UL}
我已经用元素ararray(a,3)
试过了。它不起作用了…这个起作用了吗<代码>uint32_t a[3]={1,2,3}代码>