Ugly 'fix' for the controller unit test on the p5 bot: in fail_unless_equals_float...
authorTim-Philipp Müller <tim@centricular.net>
Thu, 14 Jun 2007 15:56:03 +0000 (15:56 +0000)
committerTim-Philipp Müller <tim@centricular.net>
Thu, 14 Jun 2007 15:56:03 +0000 (15:56 +0000)
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
libs/gst/check/Makefile.am
libs/gst/check/gstcheck.h
pkgconfig/gstreamer-check-uninstalled.pc.in
pkgconfig/gstreamer-check.pc.in

index 0692c0d..15a7907 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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),
index 9bac01f..b9a1db9 100644 (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)
 
index adb9b7d..f40ad9c 100644 (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
  */
index 248ee49..97ce34f 100644 (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}
index 12488a9..74d8979 100644 (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}