mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-06-05 21:15:20 +00:00
faceb864b8d566941c2e6ca112ace367bd4a27de
If we have a 'empty' macro, f.e.: \#if <something> \#define MY_LIBRARY_INLINE \#endif and using the user pattern 'MY_LIBRARY_INLINE', we would get the following effect: match = 'MY_LIBRARY_INLINE\n' <--- NOTE THAT THE NEWLINE IS PART OF THE MATCH post-match = '#endif\n' <--- NO BEGINNING NEWLINE SINCE IT IS PART OF THE MATCH ABOVE And lead to the new header: \#if <something> Which gives a compilation error since the preprocessor-if is not terminated properly. The root cause is that we add a any-whitespace-character regex to the user regex. This any-whitespace-character regex was added only to cleanup the whitespaces after a user regex. So the next line will be deleted if we check for any whitespace character (THIS INCLUDES A NEWLINE!) after the user regex. But this had the side effect that when matching a user regex, the newline was also seen as part of the match. Which in the case of an empty macro would mean that in the cleanup of the post-match, we would delete the line immediately after the empty macro (\#endif in the example above). So instead of matching with every whitespace character (which includes newlines!), we explicitly only check for whitespaces. Taking the example above, this has the desired effect: match = 'MY_LIBRARY_INLINE' <--- NOTE THAT THE NEWLINE IS NO LONGER PART OF THE MATCH post-match = '\n#endif\n' <--- BEGINNING NEWLINE NOW Now the cleanup after a define will see the beginning newline in the post-match and only remove that newline and now the preprocessor-if is terminated properly
CMock - Mock/stub generator for C
Getting Started
If you're using Ceedling, there is no need to install CMock. It will handle it for you. For everyone else, the simplest way is to grab it off github. You can also download it as a zip if you prefer. The Github method looks something like this:
> git clone --recursive https://github.com/throwtheswitch/cmock.git
> cd cmock
> bundle install # Ensures you have all RubyGems needed
If you plan to help with the development of CMock (or just want to verify that it can perform its self tests on your system) then you can enter the test directory and then ask it to test:
> cd test
> rake # Run all CMock self tests
API Documentation
- Not sure what you're doing?
- Interested in our MIT-style license?
- Are there examples?
- They are all in /examples
- Any other resources to check out?
- Definitely! Check out our developer portal on ThrowTheSwitch.org
Description
Languages
C
58.9%
Ruby
23.2%
Assembly
9.5%
Tcl
7.9%
Batchfile
0.4%
