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

Implement FFF_RESET_CALLED_FAKES macro #82

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ChiefGokhlayeh
Copy link

Thank you for your contribution.

Before submitting this PR, please make sure:

  • Your code builds clean without any errors or warnings
  • You are not breaking consistency
  • You have added unit tests
  • All tests and other checks pass

Hi!
long time user of fff but one thing always annoyed me:

Why do we have to call RESET_FAKE() for each fake function individually? Wouldn't it be nice to have a reset all fakes macro?

Personally I don't see a reason why not. So I went ahead and implemented a crude solution I thought I'd share.

This PR adds a FFF_RESET_CALLED_FAKES() macro which, similar to FFF_RESET_HISTORY() can be placed in the global setup section of your unit-test. Internally we maintain a reset_list inside the global fff struct. Once a fake function is called, the respective _reset function pointer is placed in this list. FFF_RESET_CALLED_FAKES simply invokes every function inside fff.reset_list.

Best regards

PS: FFF is awesome!

@AppVeyorBot
Copy link

@AppVeyorBot
Copy link

@rubiot
Copy link
Contributor

rubiot commented Apr 14, 2021

This is brilliant! This always annoyed me as well. Why isn't this merged yet? Now, is there any reason the code for FFF_RESET_CALLED_FAKES should not be called automatically from FFF_RESET_HISTORY? I never had the need to reset individual fakes in any of my projects.

@ChiefGokhlayeh
Copy link
Author

@rubiot,
Thought about that, but as far as I remember FFF_RESET_HISTORY strictly resets the global call history (fff.call_history_idx = 0) and is not tied to any fakes. I agree, it makes more sense to merge these two together and have a single FFF_RESET_ALL (or simply FFF_RESET?).

Regarding why this hasn't been merged yet, I don't know. To my own discredit, I didn't follow up on this PR very diligently.

@meekrosoft meekrosoft force-pushed the master branch 2 times, most recently from b0792e6 to bdb7397 Compare August 4, 2022 08:23
@ChiefGokhlayeh ChiefGokhlayeh force-pushed the feature/macro-to-reset-all-fakes branch from e8aacd5 to 75cad07 Compare August 12, 2023 11:45
@ChiefGokhlayeh
Copy link
Author

Rebased source branch to fix merge conflicts.

@wulfgarpro wulfgarpro self-assigned this Aug 13, 2023
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

Successfully merging this pull request may close these issues.

4 participants