Skip to content

When testing C code, the checker throws an exception. The actual parameter of the C code cannot be unique_ptr, which is the syntax of C++11. #55

@lanzhongheng

Description

@lanzhongheng

return new IsEqual<std::unique_ptr<V, D> >(val);

sample code:

#include "sample3.h"

static unsigned char g_data = 0;

void save_data(const Sample3 *s)
{
    g_data = s->a + s->b;
}

int test(const Sample3 *s)
{
    if ((s->a >= 0x80) && (s->b >= 0x80)) {
        return -1;
    } else {
        save_data(s);
        return 0;
    }
}

testcase:

TEST_F(TestSuite3, T2)
{
    Sample3 t = {1, 2};
    MOCKER(save_data).stubs().with(eq((const Sample3*)&t));

    auto ret = test(&t);

    EXPECT_EQ(ret, 0);
}

test result:

[ RUN      ] TestSuite3.T2
unknown file: Failure
C++ exception with description "
=====================================
Unexpected invocation: the invocation cannot be found in allowed invoking list.
Invoked: save_data((Sample3 const*)0x7fff442b0630)
Allowed: 
method(save_data)
     .stubs()
     .invoked(0)
     .with(eq(unique_ptr (Sample3 const*)0x7fff442b0630));

=====================================
" thrown in the test body.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions