You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Check that a mocked variable has been written to #444
It would be really nice if cmock created expect style functions for header declared variables as well as functions. Is creating shim "setter" functions like above the only way to validate this kind of behavior?
Before someone tells me that providing direct access to vars is bad form and I should be providing api function all the time: This is not a pattern that I use frequently, the one place where it crops up is where the var in question is actually a representation of a hardware register declared in some chip support header that gets automagically defined by the compiler. Specifically I'm working on a PIC32 that requires sequentially writing multiple values to a "SYSKEY" register in order to unlock writing to certain other configuration registers that are otherwise locked and readonly.
Creating the expect-style interfaces (as you've proposed) wouldn't be hard. Unfortunately, the C language wouldn't allow us to intercept a direct variable assignment in the release portion of the code, so the generated hooks would be useless. We're confined in this case by the limits of the language.
Activity
mvandervoord commentedon Jun 5, 2023
Yes it's the only way.
Creating the expect-style interfaces (as you've proposed) wouldn't be hard. Unfortunately, the C language wouldn't allow us to intercept a direct variable assignment in the release portion of the code, so the generated hooks would be useless. We're confined in this case by the limits of the language.