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
added string comparison mu_assert_string_eq #8
Conversation
+1, would save a lot of repetition in my tests |
minunit.h
Outdated
@@ -190,6 +191,29 @@ static void (*minunit_teardown)(void) = NULL; | |||
}\ | |||
) | |||
|
|||
#define mu_assert_string_eq(expected, result) MU__SAFE_BLOCK(\ | |||
char* minunit_tmp_e;\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be const char*
I would like to merge this pull request but the code is not 100% safe. I think I mentioned this earlier but the comment disappeared after the rebase: when dealing with macros one has to be careful when the arguments appear in the expanded body. With the current implementation A concrete example, if result = "queue.popAndReturn()" which removes and returns the element on top of a queue. The macro will be expanded to (only expanding expected):
I.e. it will potentially invoke popAndReturn twice and the logic would be wrong. I suggest to assign |
… the behaviour of the code see siu#8 (comment)
Looks good now, thanks for the contribution. |
Documentation in the README was omitted. |
string comparison is a very useful feature for many tests.
This particular one also checks if the strings are null, and replaces those with "", before doing the comparison.