summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDamien Lespiau <damien.lespiau@intel.com>2015-06-27 15:26:50 +0100
committerDamien Lespiau <damien.lespiau@intel.com>2015-06-27 16:04:08 +0100
commit0a38e977c026fee3a499946652263b2adfe7c27c (patch)
tree43a45014e17badfee07d5a72e5bbf8d0f0b01c50 /lib
parent23888526c7c979a40218bb8bc669fb383d86c5c3 (diff)
lib: Add double versions of igt_assert_cmp() and igt_assert_eq()
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/igt_core.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/igt_core.h b/lib/igt_core.h
index 583a7611..2b2b6e93 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -365,6 +365,24 @@ void igt_exit(void) __attribute__((noreturn));
} while (0)
/**
+ * igt_assert_cmpdouble:
+ * @n1: first value
+ * @cmp: compare operator
+ * @ncmp: negated version of @cmp
+ * @n2: second value
+ *
+ * Like igt_assert_cmpint(), but for doubles;
+ */
+#define igt_assert_cmpdouble(n1, cmp, ncmp, n2) \
+ do { \
+ double __n1 = (n1), __n2 = (n2); \
+ if (__n1 cmp __n2) ; else \
+ __igt_fail_assert(IGT_LOG_DOMAIN, __FILE__, __LINE__, __func__, \
+ #n1 " " #cmp " " #n2, \
+ "error: %#lf " #ncmp " %#lf\n", __n1, __n2); \
+ } while (0)
+
+/**
* igt_assert_eq:
* @n1: first integer
* @n2: second integer
@@ -387,6 +405,15 @@ void igt_exit(void) __attribute__((noreturn));
#define igt_assert_eq_u32(n1, n2) igt_assert_cmpuint(n1, ==, !=, n2)
/**
+ * igt_assert_eq_double:
+ * @n1: first double
+ * @n2: second double
+ *
+ * Like igt_assert_eq(), but for doubles.
+ */
+#define igt_assert_eq_double(n1, n2) igt_assert_cmpdouble(n1, ==, !=, n2)
+
+/**
* igt_assert_neq:
* @n1: first integer
* @n2: second integer