check: add some more fail_unless_*() macros for convenience
authorTim-Philipp Müller <tim.muller@collabora.co.uk>
Tue, 19 Feb 2013 17:36:50 +0000 (17:36 +0000)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Tue, 19 Feb 2013 17:40:20 +0000 (17:40 +0000)
API: fail_unless_equals_int_hex
API: assert_equals_int_hex
API: fail_unless_equals_int64_hex
API: assert_equals_int64_hex
API: fail_unless_equals_uint64_hex
API: assert_equals_uint64_hex
API: fail_unless_equals_pointer
API: assert_equals_pointer

docs/libs/gstreamer-libs-sections.txt
libs/gst/check/gstcheck.h
tests/check/gst/gstutils.c

index 5c683ac..f82a565 100644 (file)
@@ -872,6 +872,11 @@ fail_unless_equals_float
 fail_unless_equals_string
 fail_unless_equals_uint64
 fail_unless_equals_int64
+fail_unless_equals_int_hex
+fail_unless_equals_int64_hex
+fail_unless_equals_uint64_hex
+fail_unless_equals_pointer
+
 fail_unless_message_error
 
 assert_equals_int
@@ -879,6 +884,10 @@ assert_equals_float
 assert_equals_string
 assert_equals_uint64
 assert_equals_int64
+assert_equals_int_hex
+assert_equals_int64_hex
+assert_equals_uint64_hex
+assert_equals_pointer
 assert_message_error
 
 gst_check_init
index 0ff3c6b..fe3011e 100644 (file)
@@ -150,6 +150,38 @@ G_STMT_START {                                                          \
 #define assert_equals_int(a, b) fail_unless_equals_int(a, b)
 
 /**
+ * fail_unless_equals_int_hex:
+ * @a: a #gint value or expression
+ * @b: a #gint 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 in
+ * hexadecimal format. This macro is for use in unit tests.
+ *
+ * Since: 1.2
+ */
+#define fail_unless_equals_int_hex(a, b)                                \
+G_STMT_START {                                                         \
+  int first = a;                                                       \
+  int second = b;                                                      \
+  fail_unless(first == second,                                         \
+    "'" #a "' (0x%08x) is not equal to '" #b"' (0x%08x)", first, second);\
+} G_STMT_END;
+
+/**
+ * assert_equals_int_hex:
+ * @a: a #gint value or expression
+ * @b: a #gint 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 in
+ * hexadecimal format. This macro is for use in unit tests.
+ *
+ * Since: 1.2
+ */
+#define assert_equals_int_hex(a, b) fail_unless_equals_int_hex(a, b)
+
+/**
  * fail_unless_equals_int64:
  * @a: a #gint64 value or expression
  * @b: a #gint64 value or expression
@@ -178,6 +210,37 @@ G_STMT_START {                                                          \
 #define assert_equals_int64(a, b) fail_unless_equals_int64(a, b)
 
 /**
+ * fail_unless_equals_int64_hex:
+ * @a: a #gint64 value or expression
+ * @b: a #gint64 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 in
+ * hexadecimal format. This macro is for use in unit tests.
+ *
+ * Since: 1.2
+ */
+#define fail_unless_equals_int64_hex(a, b)                              \
+G_STMT_START {                                                         \
+  gint64 first = a;                                                    \
+  gint64 second = b;                                                   \
+  fail_unless(first == second,                                         \
+    "'" #a "' (0x%016x) is not equal to '" #b"' (0x%016x)", first, second);\
+} G_STMT_END;
+/**
+ * assert_equals_int64_hex:
+ * @a: a #gint64 value or expression
+ * @b: a #gint64 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 in
+ * hexadecimal format. This macro is for use in unit tests.
+ *
+ * Since: 1.2
+ */
+#define assert_equals_int64_hex(a,b) fail_unless_equals_int64_hex(a,b)
+
+/**
  * fail_unless_equals_uint64:
  * @a: a #guint64 value or expression
  * @b: a #guint64 value or expression
@@ -206,6 +269,37 @@ G_STMT_START {                                                          \
 #define assert_equals_uint64(a, b) fail_unless_equals_uint64(a, b)
 
 /**
+ * fail_unless_equals_uint64_hex:
+ * @a: a #gint64 value or expression
+ * @b: a #gint64 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 in
+ * hexadecimal format. This macro is for use in unit tests.
+ *
+ * Since: 1.2
+ */
+#define fail_unless_equals_uint64_hex(a, b)                             \
+G_STMT_START {                                                         \
+  guint64 first = a;                                                   \
+  guint64 second = b;                                                  \
+  fail_unless(first == second,                                         \
+    "'" #a "' (0x%016x) is not equal to '" #b"' (0x%016x)", first, second);\
+} G_STMT_END;
+/**
+ * assert_equals_uint64_hex:
+ * @a: a #guint64 value or expression
+ * @b: a #guint64 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 in
+ * hexadecimal format. This macro is for use in unit tests.
+ *
+ * Since: 1.2
+ */
+#define assert_equals_uint64_hex(a,b) fail_unless_equals_uint64_hex(a,b)
+
+/**
  * fail_unless_equals_string:
  * @a: a string literal or expression
  * @b: a string literal or expression
@@ -262,6 +356,37 @@ G_STMT_START {                                                    \
  */
 #define assert_equals_float(a, b) fail_unless_equals_float(a, b)
 
+/**
+ * fail_unless_equals_pointer:
+ * @a: a pointer value or expression
+ * @b: a pointer 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.
+ *
+ * Since: 1.2
+ */
+#define fail_unless_equals_pointer(a, b)                          \
+G_STMT_START {                                                    \
+  gpointer first = a;                                             \
+  gpointer second = b;                                            \
+  fail_unless(first == second,                                    \
+    "'" #a "' (%p) is not equal to '" #b "' (%p)", first, second);\
+} G_STMT_END;
+
+/**
+ * assert_equals_pointer:
+ * @a: a pointer value or expression
+ * @b: a pointer 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.
+ *
+ * Since: 1.2
+ */
+#define assert_equals_pointer(a, b) fail_unless_equals_pointer(a, b)
 
 /***
  * thread test macros and variables
index 227fddc..35045f0 100644 (file)
@@ -1089,22 +1089,6 @@ GST_START_TEST (test_read_macros)
   guint32 uarray[2];
   guint8 *cpointer;
 
-#define fail_unless_equals_int_hex(a, b)                                \
-G_STMT_START {                                                         \
-  int first = a;                                                       \
-  int second = b;                                                      \
-  fail_unless(first == second,                                         \
-    "'" #a "' (0x%08x) is not equal to '" #b"' (0x%08x)", first, second);      \
-} G_STMT_END;
-
-#define fail_unless_equals_int64_hex(a, b)                                \
-G_STMT_START {                                                         \
-  gint64 first = a;                                                    \
-  gint64 second = b;                                                   \
-  fail_unless(first == second,                                         \
-    "'" #a "' (0x%016x) is not equal to '" #b"' (0x%016x)", first, second);    \
-} G_STMT_END;
-
   memcpy (uarray, carray, 8);
   cpointer = carray;