-
Notifications
You must be signed in to change notification settings - Fork 221
Add ck_assert_pstr_* macros with ability to compare undefined (NULL) strings #80
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1487,6 +1487,46 @@ do { \ | |
| */ | ||
| #define ck_assert_str_ge(X, Y) _ck_assert_str(X, >=, Y, 0, 0) | ||
|
|
||
| /** | ||
| * Check two strings to determine if 0==strcmp(X,Y) or if both are undefined | ||
| * | ||
| * If both X and Y are NULL the test passes. However, if only one is NULL | ||
| * the test fails. | ||
| * If not ((X==NULL)&&(Y==NULL)) || (0==strcmp(X,Y)), the test fails. | ||
| * | ||
| * @param X string | ||
| * @param Y string to compare against X | ||
| * | ||
| * @note If the check fails, the remaining of the test is aborted | ||
| * | ||
| * @since 0.11.0 | ||
| */ | ||
| #define ck_assert_pstr_eq(X, Y) _ck_assert_str(X, ==, Y, 1, 0) | ||
|
|
||
| /** | ||
| * Check two strings to determine if 0!=strcmp(X,Y) or one of them is undefined | ||
| * | ||
| * If either X or Y is NULL the test passes, however if both are NULL | ||
| * the test fails. | ||
| * If not (X!=NULL)&&(Y!=NULL)&&(0!=strcmp(X,Y)), the test fails. | ||
| * | ||
| * @param X string | ||
| * @param Y string to compare against X | ||
| * | ||
| * @note If the check fails, the remaining of the test is aborted | ||
| * | ||
| * @since 0.11.0 | ||
| */ | ||
| #define ck_assert_pstr_ne(X, Y) _ck_assert_str(X, !=, Y, 0, 1) | ||
|
|
||
| /* Memory location comparison macros with improved output compared to ck_assert() */ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like a duplicate of what comes after it. Did you mean to include it?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean that |
||
| /* OP might be any operator that can be used in '0 OP memcmp(X,Y,L)' comparison */ | ||
| /* The x and y parameter swap in memcmp() is needed to handle >, >=, <, <= operators */ | ||
| /* Output is limited to CK_MAX_ASSERT_MEM_PRINT_SIZE bytes */ | ||
| #ifndef CK_MAX_ASSERT_MEM_PRINT_SIZE | ||
| #define CK_MAX_ASSERT_MEM_PRINT_SIZE 64 | ||
| #endif | ||
|
|
||
| /* Memory location comparison macros with improved output compared to ck_assert() */ | ||
| /* OP might be any operator that can be used in '0 OP memcmp(X,Y,L)' comparison */ | ||
| /* The x and y parameter swap in memcmp() is needed to handle >, >=, <, <= operators */ | ||
|
|
||
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.
Did you intend this section to be before the ck_assert_ptr_* macros?