summaryrefslogtreecommitdiff
path: root/tests/clar/clar_libgit2.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/clar/clar_libgit2.h')
-rw-r--r--tests/clar/clar_libgit2.h24
1 files changed, 22 insertions, 2 deletions
diff --git a/tests/clar/clar_libgit2.h b/tests/clar/clar_libgit2.h
index da3f41524..d2d9da0aa 100644
--- a/tests/clar/clar_libgit2.h
+++ b/tests/clar/clar_libgit2.h
@@ -5,6 +5,7 @@
#include <git2.h>
#include "common.h"
#include "posix.h"
+#include "oid.h"
/**
* Replace for `clar_must_pass` that passes the last library error as the
@@ -136,13 +137,32 @@ GIT_INLINE(void) clar__assert_equal_oid(
const char *file, const char *func, int line, const char *desc,
const git_oid *one, const git_oid *two)
{
- if (git_oid_cmp(one, two)) {
- char err[] = "\"........................................\" != \"........................................\"";
+ if (git_oid_equal(one, two))
+ return;
+
+ if (git_oid_type(one) != git_oid_type(two)) {
+ char err[64];
+
+ snprintf(err, 64, "different oid types: %d vs %d", git_oid_type(one), git_oid_type(two));
+ clar__fail(file, func, line, desc, err, 1);
+ } else if (git_oid_type(one) == GIT_OID_SHA1) {
+ char err[] = "\"........................................\" != \"........................................\"";
git_oid_fmt(&err[1], one);
git_oid_fmt(&err[47], two);
clar__fail(file, func, line, desc, err, 1);
+#ifdef GIT_EXPERIMENTAL_SHA256
+ } else if (one->type == GIT_OID_SHA256) {
+ char err[] = "\"................................................................\" != \"................................................................\"";
+
+ git_oid_fmt(&err[1], one);
+ git_oid_fmt(&err[71], one);
+
+ clar__fail(file, func, line, desc, err, 1);
+#endif
+ } else {
+ clar__fail(file, func, line, desc, "unknown oid types", 1);
}
}