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

Additional option to be able to mock global variables #474

Open
cabbott9 opened this issue Apr 22, 2024 · 0 comments
Open

Additional option to be able to mock global variables #474

cabbott9 opened this issue Apr 22, 2024 · 0 comments

Comments

@cabbott9
Copy link

Unfortunately I have to work in a lot of legacy code which contains 100s of global variables. If cmock could define these things would be much easier, also preventing the case where a data type changes such that an old test (declaring variable as old type) still seems to pass.
Suggestion; when cmock reads the header file any "Extern" or "Extern const" parameters get included as real parameters into the mock_file.c (both cases would be a normal changeable variable, const is ignored). This would be a feature normally turned off, but could be enabled through the configuration.
NOTE: Only extern in the header file are to be processed in this way (i.e. if header includes another header (which is bad) that header is ignored for this process)

Header file example:
extern U8 myParameter[PARAM_ARRAY_SIZE];
extern const uint8 whatEver;

mock_.c:
U8 myParameter[PARAM_ARRAY_SIZE];
uint8 whatEver;

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

No branches or pull requests

1 participant