jeudi 22 octobre 2020

Gtest std::array matcher for custom type

I have union as

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>;

I have some function which accept this array

class test
{
public:
void Foo(my_union_2d &arg1);
};

Now I need to check if Mocked-Foo is called with my expected arguments

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):

However code doesn't compile, as array of array == operator is not found. I tried changing of AllOfArray, but I seems lost in documentation for GTest. Does anyone know what needs to be done or Reference point ?

Aucun commentaire:

Enregistrer un commentaire