-
Notifications
You must be signed in to change notification settings - Fork 21
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
Extend motoRosAssert(..)
to output expected value
#268
Comments
Context: #266 (among others). |
This could have helped with #292 as well. |
What would the scope of this issue be? The conditions tested by |
We should be able to use macro stringification to avoid having to create There are various C / C++ unit testing frameworks which use this approach to print more informative result/error messages. In the end Edit: I just realised this won't help accessing the values that are use in the conditionals. So I would suggest we indeed create I would really recommend to take a look at some existing C unit testing frameworks. re: where to stop: let's just start with the minimal set needed to cover the current conditionals. We can always add more later. |
I have some work related to this here. I am using macro stringification to print out variable names and values. The macros make it a bit ugly, but it adds a lot of information to the debug log without making calls to the assertion functions more difficult. I believe that I could get rid of the |
Two points:
I believe that either the |
What the macros offer is the ability to read in the variable/expression names that are being tested without having to manually enter that information in as a string. E.g. if I call
If it fails, then as part of the print out, it will say
whereas the non-macro version would say something along the lines of
I do agree though that my current approach isn't ideal. I could get rid of the stringification altogether, but that would mean that the printout would be less detailed, as shown above. I could instead get rid of the "original" functions and just define it all as a macro, I just didn't do that because I already had the functions written when I decided to try the stringification. |
Ah. I definitely missed that fact |
I did change the names to be more verbose, and changed some other naming conventions. If some of the names are too long, I can change them back |
Current implementation posts an alarm and enters an infinite loop printing
motoRosAssert: MotoROS2: Fatal Error (subcode: N)
.While that works, it would be more helpful to us (and users) if it printed the expected value (whatever that would mean for specific
motoRosAssert(..)
invocations).Example:
motoros2/src/PositionMonitor.c
Lines 55 to 62 in d8b75dd
an extended version of
motoRosAssert(..)
would output the values ofret
andRCL_RET_OK
as part of the message.The text was updated successfully, but these errors were encountered: