clar: format sha256 in cl_assert_equal_oid
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
diff --git a/tests/clar/clar_libgit2.h b/tests/clar/clar_libgit2.h
index da3f415..e0aff43 100644
--- a/tests/clar/clar_libgit2.h
+++ b/tests/clar/clar_libgit2.h
@@ -136,13 +136,30 @@ 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 (one->type != two->type) {
+ char err[64];
+
+ snprintf(err, 64, "different oid types: %d vs %d", one->type, two->type);
+ clar__fail(file, func, line, desc, err, 1);
+ } else if (one->type == 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);
+ } 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);
+ } else {
+ clar__fail(file, func, line, desc, "unknown oid types", 1);
}
}