Ugly 'fix' for the controller unit test on the p5 bot: in fail_unless_equals_float() check whether the values are 'al...

Original commit message from CVS:
* libs/gst/check/Makefile.am:
* libs/gst/check/gstcheck.h:
* pkgconfig/gstreamer-check-uninstalled.pc.in:
* pkgconfig/gstreamer-check.pc.in:
Ugly 'fix' for the controller unit test on the p5 bot: in
fail_unless_equals_float() check whether the values are 'almost
equal' by allowing a small absolute error, which should be good
enough for our use cases (normal numbers and values close to 0).
Proper fixage left to floating point arithmetic aficionados.
This commit is contained in:
Tim-Philipp Müller 2007-06-14 15:56:03 +00:00
parent 86e3999647
commit 3ee7f4c8a4
5 changed files with 27 additions and 11 deletions

View file

@ -1,3 +1,15 @@
2007-06-14 Tim-Philipp Müller <tim at centricular dot net>
* libs/gst/check/Makefile.am:
* libs/gst/check/gstcheck.h:
* pkgconfig/gstreamer-check-uninstalled.pc.in:
* pkgconfig/gstreamer-check.pc.in:
Ugly 'fix' for the controller unit test on the p5 bot: in
fail_unless_equals_float() check whether the values are 'almost
equal' by allowing a small absolute error, which should be good
enough for our use cases (normal numbers and values close to 0).
Proper fixage left to floating point arithmetic aficionados.
2007-06-14 Stefan Kost <ensonic@users.sf.net>
* libs/gst/base/gstbasesink.c: (gst_base_sink_reset_qos),

View file

@ -8,7 +8,7 @@ libgstcheck_@GST_MAJORMINOR@_la_SOURCES = \
libgstcheck_@GST_MAJORMINOR@_la_CFLAGS = $(GST_OBJ_CFLAGS) $(CHECK_CFLAGS)
libgstcheck_@GST_MAJORMINOR@_la_LIBADD = $(GST_OBJ_LIBS) $(CHECK_LIBS) \
$(top_builddir)/gst/libgstreamer-@GST_MAJORMINOR@.la
$(top_builddir)/gst/libgstreamer-@GST_MAJORMINOR@.la -lm
libgstcheck_@GST_MAJORMINOR@_la_LDFLAGS = -Wl,--export-dynamic \
libgstbase_@GST_MAJORMINOR@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) $(GST_LT_LDFLAGS)

View file

@ -26,6 +26,7 @@
#include <signal.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <check.h>
@ -192,9 +193,9 @@ G_STMT_START { \
* @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.
* This macro checks that @a and @b are (almost) 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
*/
@ -202,17 +203,20 @@ G_STMT_START { \
G_STMT_START { \
double first = a; \
double second = b; \
fail_unless(first == second, \
"'" #a "' (%f) is not equal to '" #b"' (%f)", first, second); \
/* This will only work for 'normal' values and values around 0, \
* which should be good enough for our purposes here */ \
fail_unless(fabs (first - second) < 0.0000001, \
"'" #a "' (%g) is not equal to '" #b "' (%g)", 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.
* This macro checks that @a and @b are (almost) 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
*/

View file

@ -9,5 +9,5 @@ Description: Unit testing helper library for GStreamer modules, Not Installed
Requires: gstreamer-@GST_MAJORMINOR@ = @VERSION@
Version: @VERSION@
Libs: ${libdir}/libgstcheck-@GST_MAJORMINOR@.la @CHECK_LIBS@
Libs: ${libdir}/libgstcheck-@GST_MAJORMINOR@.la @CHECK_LIBS@ -lm
Cflags: -I${includedir}

View file

@ -7,5 +7,5 @@ Name: GStreamer check unit testing
Description: Unit testing helper library for GStreamer modules
Requires: gstreamer-@GST_MAJORMINOR@
Version: @VERSION@
Libs: -L${libdir} -lgstcheck-@GST_MAJORMINOR@ @CHECK_LIBS@
Libs: -L${libdir} -lgstcheck-@GST_MAJORMINOR@ @CHECK_LIBS@ -lm
Cflags: -I${includedir}