Merge pull request #1848 from libgit2/ntk/fix/cl_assert_equal_sz Fix cl_assert_equal_sz error message formating
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 38
diff --git a/tests-clar/clar.c b/tests-clar/clar.c
index 5189e79..6c7399a 100644
--- a/tests-clar/clar.c
+++ b/tests-clar/clar.c
@@ -468,7 +468,7 @@ void clar__assert_equal(
}
}
}
- else if (!strcmp(PRIuZ, fmt) || !strcmp(PRIxZ, fmt)) {
+ else if (!strcmp("%"PRIuZ, fmt) || !strcmp("%"PRIxZ, fmt)) {
size_t sz1 = va_arg(args, size_t), sz2 = va_arg(args, size_t);
is_equal = (sz1 == sz2);
if (!is_equal) {
diff --git a/tests-clar/clar.h b/tests-clar/clar.h
index e1f244e..c40bc7a 100644
--- a/tests-clar/clar.h
+++ b/tests-clar/clar.h
@@ -68,6 +68,7 @@ void cl_fixture_cleanup(const char *fixture_name);
#define cl_assert_equal_p(p1,p2) clar__assert_equal(__FILE__,__LINE__,"Pointer mismatch: " #p1 " != " #p2, 1, "%p", (p1), (p2))
+#define cl_assert_equal_sz(sz1,sz2) clar__assert_equal(__FILE__,__LINE__,#sz1 " != " #sz2, 1, "%"PRIuZ, (size_t)(sz1), (size_t)(sz2))
void clar__fail(
const char *file,
diff --git a/tests-clar/clar_libgit2.h b/tests-clar/clar_libgit2.h
index 3cb0607..8dcfdee 100644
--- a/tests-clar/clar_libgit2.h
+++ b/tests-clar/clar_libgit2.h
@@ -32,8 +32,6 @@ void cl_git_report_failure(int, const char *, int, const char *);
#define cl_assert_at_line(expr,file,line) \
clar__assert((expr) != 0, file, line, "Expression is not true: " #expr, NULL, 1)
-#define cl_assert_equal_sz(sz1,sz2) clar__assert_equal(__FILE__,__LINE__,#sz1 " != " #sz2, 1, PRIuZ, (size_t)(sz1), (size_t)(sz2))
-
GIT_INLINE(void) clar__assert_in_range(
int lo, int val, int hi,
const char *file, int line, const char *err, int should_abort)