mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-18 07:47:17 +00:00
check: add some more fail_unless_*() macros for convenience
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
This commit is contained in:
parent
125eb6886e
commit
22b7c0bf58
3 changed files with 134 additions and 16 deletions
|
@ -872,6 +872,11 @@ fail_unless_equals_float
|
||||||
fail_unless_equals_string
|
fail_unless_equals_string
|
||||||
fail_unless_equals_uint64
|
fail_unless_equals_uint64
|
||||||
fail_unless_equals_int64
|
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
|
fail_unless_message_error
|
||||||
|
|
||||||
assert_equals_int
|
assert_equals_int
|
||||||
|
@ -879,6 +884,10 @@ assert_equals_float
|
||||||
assert_equals_string
|
assert_equals_string
|
||||||
assert_equals_uint64
|
assert_equals_uint64
|
||||||
assert_equals_int64
|
assert_equals_int64
|
||||||
|
assert_equals_int_hex
|
||||||
|
assert_equals_int64_hex
|
||||||
|
assert_equals_uint64_hex
|
||||||
|
assert_equals_pointer
|
||||||
assert_message_error
|
assert_message_error
|
||||||
|
|
||||||
gst_check_init
|
gst_check_init
|
||||||
|
|
|
@ -149,6 +149,38 @@ G_STMT_START { \
|
||||||
*/
|
*/
|
||||||
#define assert_equals_int(a, b) fail_unless_equals_int(a, b)
|
#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:
|
* fail_unless_equals_int64:
|
||||||
* @a: a #gint64 value or expression
|
* @a: a #gint64 value or expression
|
||||||
|
@ -177,6 +209,37 @@ G_STMT_START { \
|
||||||
*/
|
*/
|
||||||
#define assert_equals_int64(a, b) fail_unless_equals_int64(a, b)
|
#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:
|
* fail_unless_equals_uint64:
|
||||||
* @a: a #guint64 value or expression
|
* @a: a #guint64 value or expression
|
||||||
|
@ -205,6 +268,37 @@ G_STMT_START { \
|
||||||
*/
|
*/
|
||||||
#define assert_equals_uint64(a, b) fail_unless_equals_uint64(a, b)
|
#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:
|
* fail_unless_equals_string:
|
||||||
* @a: a string literal or expression
|
* @a: a string literal or expression
|
||||||
|
@ -262,6 +356,37 @@ G_STMT_START { \
|
||||||
*/
|
*/
|
||||||
#define assert_equals_float(a, b) fail_unless_equals_float(a, b)
|
#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
|
* thread test macros and variables
|
||||||
|
|
|
@ -1089,22 +1089,6 @@ GST_START_TEST (test_read_macros)
|
||||||
guint32 uarray[2];
|
guint32 uarray[2];
|
||||||
guint8 *cpointer;
|
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);
|
memcpy (uarray, carray, 8);
|
||||||
cpointer = carray;
|
cpointer = carray;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue