From 3ee7f4c8a48baafd2a7fa5ac5e93a785d087b062 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Thu, 14 Jun 2007 15:56:03 +0000 Subject: [PATCH] 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. --- ChangeLog | 12 ++++++++++++ libs/gst/check/Makefile.am | 2 +- libs/gst/check/gstcheck.h | 20 ++++++++++++-------- pkgconfig/gstreamer-check-uninstalled.pc.in | 2 +- pkgconfig/gstreamer-check.pc.in | 2 +- 5 files changed, 27 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0692c0dbd0..15a7907770 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2007-06-14 Tim-Philipp Müller + + * 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 * libs/gst/base/gstbasesink.c: (gst_base_sink_reset_qos), diff --git a/libs/gst/check/Makefile.am b/libs/gst/check/Makefile.am index 9bac01f2a9..b9a1db9dc5 100644 --- a/libs/gst/check/Makefile.am +++ b/libs/gst/check/Makefile.am @@ -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) diff --git a/libs/gst/check/gstcheck.h b/libs/gst/check/gstcheck.h index adb9b7dbee..f40ad9c070 100644 --- a/libs/gst/check/gstcheck.h +++ b/libs/gst/check/gstcheck.h @@ -26,6 +26,7 @@ #include #include #include +#include #include @@ -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 */ diff --git a/pkgconfig/gstreamer-check-uninstalled.pc.in b/pkgconfig/gstreamer-check-uninstalled.pc.in index 248ee498b2..97ce34f989 100644 --- a/pkgconfig/gstreamer-check-uninstalled.pc.in +++ b/pkgconfig/gstreamer-check-uninstalled.pc.in @@ -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} diff --git a/pkgconfig/gstreamer-check.pc.in b/pkgconfig/gstreamer-check.pc.in index 12488a924e..74d89797ff 100644 --- a/pkgconfig/gstreamer-check.pc.in +++ b/pkgconfig/gstreamer-check.pc.in @@ -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}