Skip to content

Commit 8173241

Browse files
committed
clar: format sha256 in cl_assert_equal_oid
1 parent 0db1c57 commit 8173241

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

tests/clar/clar_libgit2.h

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,30 @@ GIT_INLINE(void) clar__assert_equal_oid(
136136
const char *file, const char *func, int line, const char *desc,
137137
const git_oid *one, const git_oid *two)
138138
{
139-
if (git_oid_cmp(one, two)) {
140-
char err[] = "\"........................................\" != \"........................................\"";
141139

140+
if (git_oid_equal(one, two))
141+
return;
142+
143+
if (one->type != two->type) {
144+
char err[64];
145+
146+
snprintf(err, 64, "different oid types: %d vs %d", one->type, two->type);
147+
clar__fail(file, func, line, desc, err, 1);
148+
} else if (one->type == GIT_OID_SHA1) {
149+
char err[] = "\"........................................\" != \"........................................\"";
142150
git_oid_fmt(&err[1], one);
143151
git_oid_fmt(&err[47], two);
144152

145153
clar__fail(file, func, line, desc, err, 1);
154+
} else if (one->type == GIT_OID_SHA256) {
155+
char err[] = "\"................................................................\" != \"................................................................\"";
156+
157+
git_oid_fmt(&err[1], one);
158+
git_oid_fmt(&err[71], one);
159+
160+
clar__fail(file, func, line, desc, err, 1);
161+
} else {
162+
clar__fail(file, func, line, desc, "unknown oid types", 1);
146163
}
147164
}
148165

0 commit comments

Comments
 (0)