diff options
author | Russell Belfer <arrbee@arrbee.com> | 2011-11-27 21:47:58 -0800 |
---|---|---|
committer | Russell Belfer <arrbee@arrbee.com> | 2011-11-27 21:56:44 -0800 |
commit | 8c74d22ebfae33323b5561d9bd988f272ff61a01 (patch) | |
tree | 29d4bfd7f0f13c141e37c1aeb8ab8cfaa41b85cf /tests-clay/clay_libgit2.h | |
parent | 880b6f0c22153db164ecb3a18c362ba8337365d3 (diff) | |
download | libgit2-8c74d22ebfae33323b5561d9bd988f272ff61a01.tar.gz |
Extend git_buf with new utility functions and unit tests.
Add new functions to git_buf for:
* initializing a buffer from a string
* joining one or more strings onto a buffer with separators
* swapping two buffers in place
* extracting data from a git_buf (leaving it empty)
Also, make git_buf_free leave a git_buf back in its initted state,
and slightly tweak buffer allocation sizes and thresholds.
Finally, port unit tests to clay and extend with lots of new tests
for the various git_buf functions.
Diffstat (limited to 'tests-clay/clay_libgit2.h')
-rw-r--r-- | tests-clay/clay_libgit2.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests-clay/clay_libgit2.h b/tests-clay/clay_libgit2.h index 8784b7e61..2eedc61d2 100644 --- a/tests-clay/clay_libgit2.h +++ b/tests-clay/clay_libgit2.h @@ -25,4 +25,20 @@ */ #define cl_git_fail(expr) cl_must_fail(expr) +/** + * Wrapper for string comparison that knows about nulls. + */ +#define cl_assert_strequal(a,b) \ + cl_assert_strequal_internal(a,b,__FILE__,__LINE__) + +GIT_INLINE(void) cl_assert_strequal_internal(const char *a, const char *b, const char *file, int line) +{ + int match = (a == NULL || b == NULL) ? (a == b) : (strcmp(a, b) == 0); + if (!match) { + char buf[4096]; + snprintf(buf, 4096, "'%s' != '%s'", a, b); + clay__assert(0, file, line, buf, "Strings do not match", 1); + } +} + #endif |