mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-04 05:22:30 +00:00
API: add fail_unless_equals_float() and assert_equals_float().
Original commit message from CVS: * docs/libs/gstreamer-libs-sections.txt: * libs/gst/check/gstcheck.h: API: add fail_unless_equals_float() and assert_equals_float(). Add documentation for some of the macros. * tests/check/libs/controller.c: (GST_START_TEST): Use newly-added asserts.
This commit is contained in:
parent
239d09ecdc
commit
9dc9602829
4 changed files with 117 additions and 20 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2007-06-14 Tim-Philipp Müller <tim at centricular dot net>
|
||||
|
||||
* docs/libs/gstreamer-libs-sections.txt:
|
||||
* libs/gst/check/gstcheck.h:
|
||||
API: add fail_unless_equals_float() and assert_equals_float().
|
||||
Add documentation for some of the macros.
|
||||
|
||||
* tests/check/libs/controller.c: (GST_START_TEST):
|
||||
Use newly-added asserts.
|
||||
|
||||
2007-06-14 Stefan Kost <ensonic@users.sf.net>
|
||||
|
||||
* gst/gstpad.c: (gst_pad_alloc_buffer_full), (gst_pad_push):
|
||||
|
|
|
@ -412,11 +412,13 @@ ASSERT_OBJECT_REFCOUNT_BETWEEN
|
|||
ASSERT_SET_STATE
|
||||
|
||||
fail_unless_equals_int
|
||||
fail_unless_equals_float
|
||||
fail_unless_equals_string
|
||||
fail_unless_equals_uint64
|
||||
fail_unless_message_error
|
||||
|
||||
assert_equals_int
|
||||
assert_equals_float
|
||||
assert_equals_string
|
||||
assert_equals_uint64
|
||||
assert_message_error
|
||||
|
|
|
@ -105,6 +105,15 @@ static void __testname ()\
|
|||
|
||||
|
||||
/* additional fail macros */
|
||||
/**
|
||||
* fail_unless_equals_int:
|
||||
* @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. This
|
||||
* macro is for use in unit tests.
|
||||
*/
|
||||
#define fail_unless_equals_int(a, b) \
|
||||
G_STMT_START { \
|
||||
int first = a; \
|
||||
|
@ -112,8 +121,26 @@ G_STMT_START { \
|
|||
fail_unless(first == second, \
|
||||
"'" #a "' (%d) is not equal to '" #b"' (%d)", first, second); \
|
||||
} G_STMT_END;
|
||||
/**
|
||||
* assert_equals_int:
|
||||
* @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. This
|
||||
* macro is for use in unit tests.
|
||||
*/
|
||||
#define assert_equals_int(a, b) fail_unless_equals_int(a, b)
|
||||
|
||||
/**
|
||||
* fail_unless_equals_uint64:
|
||||
* @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. This
|
||||
* macro is for use in unit tests.
|
||||
*/
|
||||
#define fail_unless_equals_uint64(a, b) \
|
||||
G_STMT_START { \
|
||||
guint64 first = a; \
|
||||
|
@ -122,8 +149,26 @@ G_STMT_START { \
|
|||
"'" #a "' (%" G_GUINT64_FORMAT ") is not equal to '" #b"' (%" \
|
||||
G_GUINT64_FORMAT ")", first, second); \
|
||||
} G_STMT_END;
|
||||
/**
|
||||
* assert_equals_uint64:
|
||||
* @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. This
|
||||
* macro is for use in unit tests.
|
||||
*/
|
||||
#define assert_equals_uint64(a, b) fail_unless_equals_uint64(a, b)
|
||||
|
||||
/**
|
||||
* fail_unless_equals_string:
|
||||
* @a: a string literal or expression
|
||||
* @b: a string literal or expression
|
||||
*
|
||||
* This macro checks that @a and @b are equal (as per strcmp) 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_string(a, b) \
|
||||
G_STMT_START { \
|
||||
const gchar * first = a; \
|
||||
|
@ -131,8 +176,48 @@ G_STMT_START { \
|
|||
fail_unless(strcmp (first, second) == 0, \
|
||||
"'" #a "' (%s) is not equal to '" #b"' (%s)", first, second); \
|
||||
} G_STMT_END;
|
||||
/**
|
||||
* assert_equals_string:
|
||||
* @a: a string literal or expression
|
||||
* @b: a string literal or expression
|
||||
*
|
||||
* This macro checks that @a and @b are equal (as per strcmp) 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 assert_equals_string(a, b) fail_unless_equals_string(a, b)
|
||||
|
||||
/**
|
||||
* fail_unless_equals_float:
|
||||
* @a: a #gdouble or #gfloat value or expression
|
||||
* @b: a #gdouble or #gfloat 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: 0.10.14
|
||||
*/
|
||||
#define fail_unless_equals_float(a, b) \
|
||||
G_STMT_START { \
|
||||
double first = a; \
|
||||
double second = b; \
|
||||
fail_unless(first == second, \
|
||||
"'" #a "' (%f) is not equal to '" #b"' (%f)", first, second); \
|
||||
} G_STMT_END;
|
||||
/**
|
||||
* assert_equals_float:
|
||||
* @a: a #gdouble or #gfloat value or expression
|
||||
* @b: a #gdouble or #gfloat 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: 0.10.14
|
||||
*/
|
||||
#define assert_equals_float(a, b) fail_unless_equals_float(a, b)
|
||||
|
||||
|
||||
/***
|
||||
* thread test macros and variables
|
||||
|
|
|
@ -390,14 +390,14 @@ GST_START_TEST (controller_new_okay2)
|
|||
fail_unless (ctrl != NULL, NULL);
|
||||
|
||||
GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
|
||||
fail_unless (G_OBJECT (ctrl)->ref_count == 1);
|
||||
fail_unless_equals_int (G_OBJECT (ctrl)->ref_count, 1);
|
||||
|
||||
ctrl2 = gst_controller_new (G_OBJECT (elem), "boolean", NULL);
|
||||
fail_unless (ctrl2 != NULL, NULL);
|
||||
fail_unless (ctrl2 == ctrl, NULL);
|
||||
|
||||
GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
|
||||
fail_unless (G_OBJECT (ctrl)->ref_count == 2);
|
||||
fail_unless_equals_int (G_OBJECT (ctrl)->ref_count, 2);
|
||||
|
||||
/* trying to control the same properties again should correctly
|
||||
* increase the refcount of the object returned as well */
|
||||
|
@ -407,7 +407,7 @@ GST_START_TEST (controller_new_okay2)
|
|||
fail_unless (ctrl3 == ctrl, NULL);
|
||||
|
||||
GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
|
||||
fail_unless (G_OBJECT (ctrl)->ref_count == 3);
|
||||
fail_unless_equals_int (G_OBJECT (ctrl)->ref_count, 3);
|
||||
|
||||
g_object_unref (ctrl);
|
||||
g_object_unref (ctrl2);
|
||||
|
@ -442,7 +442,7 @@ GST_START_TEST (controller_new_okay3)
|
|||
fail_unless (ctrl1 == ctrl3, NULL);
|
||||
|
||||
GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl1)->ref_count);
|
||||
fail_unless (G_OBJECT (ctrl1)->ref_count == 3);
|
||||
fail_unless_equals_int (G_OBJECT (ctrl1)->ref_count, 3);
|
||||
g_object_unref (ctrl1);
|
||||
g_object_unref (ctrl2);
|
||||
g_object_unref (ctrl3);
|
||||
|
@ -677,18 +677,18 @@ GST_START_TEST (controller_interpolate_cubic)
|
|||
|
||||
/* now pull in values for some timestamps */
|
||||
gst_controller_sync_values (ctrl, 0 * GST_SECOND);
|
||||
fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 0.0, NULL);
|
||||
fail_unless_equals_float (GST_TEST_MONO_SOURCE (elem)->val_double, 0.0);
|
||||
gst_controller_sync_values (ctrl, 1 * GST_SECOND);
|
||||
fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 5.0, NULL);
|
||||
fail_unless_equals_float (GST_TEST_MONO_SOURCE (elem)->val_double, 5.0);
|
||||
gst_controller_sync_values (ctrl, 2 * GST_SECOND);
|
||||
fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 2.0, NULL);
|
||||
fail_unless_equals_float (GST_TEST_MONO_SOURCE (elem)->val_double, 2.0);
|
||||
gst_controller_sync_values (ctrl, 3 * GST_SECOND);
|
||||
fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double > 2.0 &&
|
||||
GST_TEST_MONO_SOURCE (elem)->val_double < 8.0, NULL);
|
||||
gst_controller_sync_values (ctrl, 4 * GST_SECOND);
|
||||
fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 8.0, NULL);
|
||||
fail_unless_equals_float (GST_TEST_MONO_SOURCE (elem)->val_double, 8.0);
|
||||
gst_controller_sync_values (ctrl, 5 * GST_SECOND);
|
||||
fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 8.0, NULL);
|
||||
fail_unless_equals_float (GST_TEST_MONO_SOURCE (elem)->val_double, 8.0);
|
||||
|
||||
GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
|
||||
g_object_unref (ctrl);
|
||||
|
@ -962,7 +962,7 @@ GST_START_TEST (controller_refcount_new_list)
|
|||
ctrl = gst_controller_new_list (G_OBJECT (elem), list);
|
||||
fail_unless (ctrl != NULL, NULL);
|
||||
GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
|
||||
fail_unless (G_OBJECT (ctrl)->ref_count == 1);
|
||||
fail_unless_equals_int (G_OBJECT (ctrl)->ref_count, 1);
|
||||
g_list_free (list);
|
||||
g_object_unref (ctrl);
|
||||
gst_object_unref (elem);
|
||||
|
@ -974,7 +974,7 @@ GST_START_TEST (controller_refcount_new_list)
|
|||
ctrl = gst_controller_new_list (G_OBJECT (elem), list);
|
||||
fail_unless (ctrl != NULL, NULL);
|
||||
GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
|
||||
fail_unless (G_OBJECT (ctrl)->ref_count == 1);
|
||||
fail_unless_equals_int (G_OBJECT (ctrl)->ref_count, 1);
|
||||
g_list_free (list);
|
||||
g_object_unref (ctrl);
|
||||
gst_object_unref (elem);
|
||||
|
@ -986,7 +986,7 @@ GST_START_TEST (controller_refcount_new_list)
|
|||
ctrl = gst_controller_new_list (G_OBJECT (elem), list);
|
||||
fail_unless (ctrl != NULL, NULL);
|
||||
GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
|
||||
fail_unless (G_OBJECT (ctrl)->ref_count == 1);
|
||||
fail_unless_equals_int (G_OBJECT (ctrl)->ref_count, 1);
|
||||
g_list_free (list);
|
||||
g_object_unref (ctrl);
|
||||
gst_object_unref (elem);
|
||||
|
@ -1001,7 +1001,7 @@ GST_START_TEST (controller_refcount_new_list)
|
|||
fail_unless (ctrl2 != NULL, NULL);
|
||||
fail_unless (ctrl == ctrl2, NULL);
|
||||
GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
|
||||
fail_unless (G_OBJECT (ctrl)->ref_count == 2);
|
||||
fail_unless_equals_int (G_OBJECT (ctrl)->ref_count, 2);
|
||||
g_list_free (list);
|
||||
g_object_unref (ctrl);
|
||||
g_object_unref (ctrl2);
|
||||
|
@ -1017,7 +1017,7 @@ GST_START_TEST (controller_refcount_new_list)
|
|||
fail_unless (ctrl2 != NULL, NULL);
|
||||
fail_unless (ctrl == ctrl2, NULL);
|
||||
GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
|
||||
fail_unless (G_OBJECT (ctrl)->ref_count == 2);
|
||||
fail_unless_equals_int (G_OBJECT (ctrl)->ref_count, 2);
|
||||
g_list_free (list);
|
||||
g_object_unref (ctrl);
|
||||
g_object_unref (ctrl2);
|
||||
|
@ -1109,22 +1109,22 @@ GST_START_TEST (controller_linear_invalid_values)
|
|||
/* now pull in values for some timestamps and see if clipping works */
|
||||
/* 200.0 */
|
||||
gst_controller_sync_values (ctrl, 0 * GST_SECOND);
|
||||
fail_unless (GST_TEST_MONO_SOURCE (elem)->val_float == 100.0, NULL);
|
||||
fail_unless_equals_float (GST_TEST_MONO_SOURCE (elem)->val_float, 100.0);
|
||||
/* 100.0 */
|
||||
gst_controller_sync_values (ctrl, 1 * GST_SECOND);
|
||||
fail_unless (GST_TEST_MONO_SOURCE (elem)->val_float == 100.0, NULL);
|
||||
fail_unless_equals_float (GST_TEST_MONO_SOURCE (elem)->val_float, 100.0);
|
||||
/* 50.0 */
|
||||
gst_controller_sync_values (ctrl, 1 * GST_SECOND + 500 * GST_MSECOND);
|
||||
fail_unless (GST_TEST_MONO_SOURCE (elem)->val_float == 50.0, NULL);
|
||||
fail_unless_equals_float (GST_TEST_MONO_SOURCE (elem)->val_float, 50.0);
|
||||
/* 0.0 */
|
||||
gst_controller_sync_values (ctrl, 2 * GST_SECOND);
|
||||
fail_unless (GST_TEST_MONO_SOURCE (elem)->val_float == 0.0, NULL);
|
||||
fail_unless_equals_float (GST_TEST_MONO_SOURCE (elem)->val_float, 0.0);
|
||||
/* -100.0 */
|
||||
gst_controller_sync_values (ctrl, 3 * GST_SECOND);
|
||||
fail_unless (GST_TEST_MONO_SOURCE (elem)->val_float == 0.0, NULL);
|
||||
fail_unless_equals_float (GST_TEST_MONO_SOURCE (elem)->val_float, 0.0);
|
||||
/* -200.0 */
|
||||
gst_controller_sync_values (ctrl, 4 * GST_SECOND);
|
||||
fail_unless (GST_TEST_MONO_SOURCE (elem)->val_float == 0.0, NULL);
|
||||
fail_unless_equals_float (GST_TEST_MONO_SOURCE (elem)->val_float, 0.0);
|
||||
|
||||
GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
|
||||
g_object_unref (ctrl);
|
||||
|
|
Loading…
Reference in a new issue