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.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests-clar/clar_libgit2.h b/tests-clar/clar_libgit2.h
index 5371b2864..8c8357e40 100644
--- a/tests-clar/clar_libgit2.h
+++ b/tests-clar/clar_libgit2.h
@@ -34,6 +34,20 @@ void cl_git_report_failure(int, const char *, int, const char *);
#define cl_assert_equal_sz(sz1,sz2) cl_assert_equal_i((int)sz1, (int)(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)
+{
+ if (lo > val || hi < val) {
+ char buf[128];
+ snprintf(buf, sizeof(buf), "%d not in [%d,%d]", val, lo, hi);
+ clar__fail(file, line, err, buf, should_abort);
+ }
+}
+
+#define cl_assert_in_range(L,V,H) \
+ clar__assert_in_range((L),(V),(H),__FILE__,__LINE__,"Range check: " #V " in [" #L "," #H "]", 1)
+
/*
* Some utility macros for building long strings
*/