#include <glib.h>

#if !GLIB_CHECK_VERSION (2, 40, 0)
# define g_assert_true(expr)            g_assert ((expr))
# define g_assert_false(expr)           g_assert (!(expr))
# define g_assert_null(expr)            g_assert ((expr) == NULL)
# define g_assert_nonnull(expr)         g_assert ((expr) != NULL)
#endif

#define graphene_assert_fuzzy_equals(n1,n2,epsilon) \
  G_STMT_START { \
    typeof ((n1)) __n1 = (n1); \
    typeof ((n2)) __n2 = (n2); \
    typeof ((epsilon)) __epsilon = (epsilon); \
    if (__n1 > __n2) { \
      if ((__n1 - __n2) < __epsilon) ; else { \
        g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
                                    #n1 " == " #n2 " (+/- " #epsilon ")", \
                                    __n1, "==", __n2, 'f'); \
      } \
    } else { \
      if ((__n2 - __n1) < __epsilon) ; else { \
        g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
                                    #n1 " == " #n2 " (+/- " #epsilon ")", \
                                    __n1, "==", __n2, 'f'); \
      } \
    } \
  } G_STMT_END

#include <glib.h>

#if !GLIB_CHECK_VERSION (2, 40, 0)
# define g_assert_true(expr)            g_assert ((expr))
# define g_assert_false(expr)           g_assert (!(expr))
# define g_assert_null(expr)            g_assert ((expr) == NULL)
# define g_assert_nonnull(expr)         g_assert ((expr) != NULL)
#endif

--- 
+++ 
@@ -6,3 +6,23 @@
 # define g_assert_null(expr)            g_assert ((expr) == NULL)
 # define g_assert_nonnull(expr)         g_assert ((expr) != NULL)
 #endif
+
+#define graphene_assert_fuzzy_equals(n1,n2,epsilon) \
+  G_STMT_START { \
+    typeof ((n1)) __n1 = (n1); \
+    typeof ((n2)) __n2 = (n2); \
+    typeof ((epsilon)) __epsilon = (epsilon); \
+    if (__n1 > __n2) { \
+      if ((__n1 - __n2) < __epsilon) ; else { \
+        g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
+                                    #n1 " == " #n2 " (+/- " #epsilon ")", \
+                                    __n1, "==", __n2, 'f'); \
+      } \
+    } else { \
+      if ((__n2 - __n1) < __epsilon) ; else { \
+        g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
+                                    #n1 " == " #n2 " (+/- " #epsilon ")", \
+                                    __n1, "==", __n2, 'f'); \
+      } \
+    } \
+  } G_STMT_END
tests: Add a fuzzy comparison macro

We use something like this in the matrix test suite, but it's useful for
other types.
