diff options
Diffstat (limited to 'tests/clar_libgit2.h')
| -rw-r--r-- | tests/clar_libgit2.h | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/tests/clar_libgit2.h b/tests/clar_libgit2.h index 082fa9f4a..f51554293 100644 --- a/tests/clar_libgit2.h +++ b/tests/clar_libgit2.h @@ -3,6 +3,7 @@ #include "clar.h" #include <git2.h> +#include <posix.h> #include "common.h" /** @@ -51,7 +52,7 @@ GIT_INLINE(void) clar__assert_in_range( { if (lo > val || hi < val) { char buf[128]; - snprintf(buf, sizeof(buf), "%d not in [%d,%d]", val, lo, hi); + p_snprintf(buf, sizeof(buf), "%d not in [%d,%d]", val, lo, hi); clar__fail(file, line, err, buf, should_abort); } } @@ -78,6 +79,24 @@ void clar__assert_equal_file( const char *file, int line); +GIT_INLINE(void) clar__assert_equal_oid( + const char *file, int line, const char *desc, + const git_oid *one, const git_oid *two) +{ + if (git_oid_cmp(one, two)) { + char err[] = "\"........................................\" != \"........................................\""; + + git_oid_fmt(&err[1], one); + git_oid_fmt(&err[47], two); + + clar__fail(file, line, desc, err, 1); + } +} + +#define cl_assert_equal_oid(one, two) \ + clar__assert_equal_oid(__FILE__, __LINE__, \ + "OID mismatch: " #one " != " #two, (one), (two)) + /* * Some utility macros for building long strings */ @@ -131,7 +150,14 @@ int cl_repo_get_bool(git_repository *repo, const char *cfg); void cl_repo_set_string(git_repository *repo, const char *cfg, const char *value); -void cl_fake_home(git_buf *restore); -void cl_fake_home_cleanup(git_buf *restore); +/* set up a fake "home" directory and set libgit2 GLOBAL search path. + * + * automatically configures cleanup function to restore the regular search + * path, although you can call it explicitly if you wish (with NULL). + */ +void cl_fake_home(void); +void cl_fake_home_cleanup(void *); + +void cl_sandbox_set_search_path_defaults(void); #endif |
