check: Add a fail_unless_equals_clocktime macro for convenience
authorThibault Saunier <tsaunier@igalia.com>
Mon, 9 Jul 2018 00:52:08 +0000 (20:52 -0400)
committerThibault Saunier <tsaunier@igalia.com>
Mon, 9 Jul 2018 00:56:16 +0000 (20:56 -0400)
libs/gst/check/gstcheck.h

index 306c0d6..cc6d5f3 100644 (file)
@@ -500,6 +500,24 @@ G_STMT_START {                                                    \
  */
 #define assert_equals_pointer(a, b) fail_unless_equals_pointer(a, b)
 
+/**
+ * fail_unless_equals_clocktime:
+ * @a: a #GstClockTime value or expression
+ * @b: a #GstClockTime value or expression
+ *
+ * This macro checks that @a and @b are equal and aborts if this is not the
+ * case, printing both expressions and the values they evaluated to. This
+ * macro is for use in unit tests.
+ */
+#define fail_unless_equals_clocktime(a, b)                              \
+G_STMT_START {                                                          \
+  GstClockTime first = a;                                                        \
+  GstClockTime second = b;                                                       \
+  fail_unless(first == second,                                          \
+    "'" #a "' (%" GST_TIME_FORMAT") is not equal to '" #b"' (%" GST_TIME_FORMAT")", \
+      GST_TIME_ARGS (first), GST_TIME_ARGS (second));       \
+} G_STMT_END;
+
 /***
  * thread test macros and variables
  */