-
Notifications
You must be signed in to change notification settings - Fork 47
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
with_side_effects() should provide ability to inspect arguments passed to a mocked function #295
Comments
This is a great idea! I'm not familiar enough with GTK to see how they get away with this. Just calling a function/macro with more arguments than it has declared will surely fire error messages from most C compilers. Or am I misunderstanding you? I would appreciate a more detailed sketch of how this would look. |
Ok, I will try to explain this whole C function pointers magic above: The most important thing is to handle two typedef void (*Func2)(int, int); It will compile and run on any platform. However, this doesn't mean this For more information please visit: After some reconsideration I figured out we might use some other, typedef void (*FuncA)(void); void funcA(void) { int main() I personally like the second approach more sue to standard compliance Hope all is clear by now ;) |
The with_side_effects() should create the constrain that allows user to browse the arguments of a function.
This could be relatively easily achieved by just passing a second argument to a user callback.
Expected feature:
void user_callback(void* data, Arguments* args) {
// here it is possible to inspect/interact with args
}
//using cb
expect(mocked_function, with_side_effect(&user_callback, &unimportant));
Such change should be backward-compatible, because same thing
was used by GTK+ extensively:
// old code, most important thing is that gtk_main_quit
// declares no parameters, receives two
// and despite all of this works like a charm.
g_signal_connect(G_OBJECT(window), "destroy",
G_CALLBACK(gtk_main_quit), NULL);
The text was updated successfully, but these errors were encountered: