Setting default values for mock() and check_expected() and then overriding them
I'm just getting started with cmocka and trying to figure out how to do basic things. I found one use case which I think should be pretty common but I can't find a good way to deal with it using the available API.
Basically, I have a big function with many parameters that I want to mock and then test for many different cases. To keep things easy, I will write the test so that it will end up using the same values for most of these parameters most of the time, i.e. I have a set of "default" expected parameter values and then only one or two of those will be different for each individual call.
I thought I could just set all these "default" expected parameters and return values with will_return_maybe() and expect_value_count(-2) at the top of the test function, to provide that "baseline" of what parameters the mocked function should expect most of the time. Then when I set up each individual call I can just use expect_value() or will_return() to push one or two new values specific to that call on top of the mocked/expected value stack, which will then be popped off by that next call. That would make the test code much easier than having to set up each parameter again from scratch for every call.
But when trying this out I found that it doesn't work -- and that in fact cmocka implements queue behavior, not stack behavior for these parameter and mock lists (even though the API description for Mock Objects explicitly calls it a stack). So once I do a will_return_maybe() or expect_value_count(-2) for any parameter, that is all it will ever return and I can never get it to do anything else again for the remainder of the test (because the first queue element is "infinite" so it will never pop off, and I can only append new things to the end of the queue which the test could never get to).
What are the common approaches to deal with the situation I described? Do I just need to have a big list of expect_value() statements that I need to copy&paste in front of every single call? Or should I build myself a complicated function that installs all my default expectations but can also take extra parameters to handle all the special cases I need? (I feel like I would just be implementing the stuff by hand that cmocka was designed to help me with, then.)
Also, is there a good reason that the lists implement queue behavior and not stack behavior? I can't really think of a big advantage to that, and the disadvantage is that it is much less flexible when enqueueing "infinite" objects and cannot be used for tricks like I was hoping to do.