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

Replacement for when() that checks argument list lengths (and reads better too maybe) #69

Open
malsyned opened this issue May 16, 2022 · 0 comments

Comments

@malsyned
Copy link
Owner

I did this spike of a couple of new macros and an additional bit of output for automock.py that would make unit tests fail when argument list lengths changed (preventing SIGSEGV) and also may make find-replaces on mocked function names work better, depending on how clever the tool is trying to be.

I think I want to implement it for real in PFSTest.

#define the_call(call) when(mock_wrapper_ ## call)
#define return_from(exp, result) do_return(result, exp)
typedef pfstest_expectation_t *expectation;

#define mock_wrapper_hw_adc_new(a1, a2, a3) mock_hw_adc_new, a1, a2, a3

test(something)
{
    return_from(
        the_call(hw_adc_new(the_int(0),
                           anything(),
                           capture_arg(&adc0_callbacks))),
        the_pointer(adc0));

    return_from(
        the_call(hw_adc_new(the_int(1),
                            anything(),
                            capture_arg(&adc0_callbacks))),
        the_pointer(adc1));

    verify(the_call(hw_adc_new(the_int(1),
                               anything(),
                               capture_arg(&adc0_callbacks))));

    expectation e = the_call(hw_adc_new(the_int(0),
                                        anything(),
                                        capture_arg(&adc0_callbacks)));
    return_from(e, the_pointer(adc0));
}```
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