Skip to content

How to test particular pattern (return through runtime assigned func pointer) #874

Answered by mvandervoord
MikeExMachina asked this question in Q&A
Discussion options

You must be logged in to vote

Hi.

At the moment, we don't have an automatic way to do this. There are two versions of this pattern that I see frequently... One is more easily testable than the other.

Version 1: The init function accepts the function pointers as arguments.
Version 2: The init function assigned the function pointers internally to module-scoped static functions.

I believe you're talking about version 1, which is the better of the two scenarios.

When I encounter version 1, I usually make a header file specifically for testing these callbacks (often I just call it callbacks_<original_filename>.h and put it in the support folder). The only thing in this header file are prototypes for the types of callbacks …

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@MikeExMachina
Comment options

@PVeps
Comment options

Answer selected by MikeExMachina
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment