Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/153.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何在GoogleMock中匹配C样式数组_C++_Googletest - Fatal编程技术网

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}