Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
lanzhongheng opened this issue Mar 8, 2024 · 0 comments

Comments

@lanzhongheng
Copy link

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant