[cairo-commit] test/bitmap-font.c test/cairo-test.h test/pattern-getters.c

Carl Worth cworth at kemper.freedesktop.org
Mon Jan 28 21:26:15 PST 2008


 test/bitmap-font.c     |   11 ++++++-----
 test/cairo-test.h      |    2 ++
 test/pattern-getters.c |    4 +---
 3 files changed, 9 insertions(+), 8 deletions(-)

New commits:
commit 247e1011995b0241526262cc36eb34c7e5edd47c
Author: Carl Worth <cworth at cworth.org>
Date:   Mon Jan 28 21:24:56 2008 -0800

    Fix bitmap-font test by using near-equality for double comparison

diff --git a/test/bitmap-font.c b/test/bitmap-font.c
index b446000..a9e4e8b 100644
--- a/test/bitmap-font.c
+++ b/test/bitmap-font.c
@@ -49,11 +49,12 @@ static cairo_bool_t
 font_extents_equal (const cairo_font_extents_t *A,
 	            const cairo_font_extents_t *B)
 {
-    return A->ascent    == B->ascent        &&
-	   A->descent   == B->descent       &&
-	   A->height    == B->height        &&
-       A->max_x_advance == B->max_x_advance &&
-       A->max_y_advance == B->max_y_advance;
+    return
+	CAIRO_TEST_DOUBLE_EQUALS (A->ascent,  B->ascent)  &&
+	CAIRO_TEST_DOUBLE_EQUALS (A->descent, B->descent) &&
+	CAIRO_TEST_DOUBLE_EQUALS (A->height,  B->height)  &&
+	CAIRO_TEST_DOUBLE_EQUALS (A->max_x_advance, B->max_x_advance) &&
+	CAIRO_TEST_DOUBLE_EQUALS (A->max_y_advance, B->max_y_advance);
 }
 
 static cairo_test_status_t
diff --git a/test/cairo-test.h b/test/cairo-test.h
index d7ed3a7..6b6b373 100644
--- a/test/cairo-test.h
+++ b/test/cairo-test.h
@@ -133,6 +133,8 @@ cairo_test_create_pattern_from_png (const char *filename);
 cairo_status_t
 cairo_test_paint_checkered (cairo_t *cr);
 
+#define CAIRO_TEST_DOUBLE_EQUALS(a,b)  (fabs((a)-(b)) < 0.00001)
+
 CAIRO_END_DECLS
 
 #endif
diff --git a/test/pattern-getters.c b/test/pattern-getters.c
index 695245d..7a2f60d 100644
--- a/test/pattern-getters.c
+++ b/test/pattern-getters.c
@@ -38,14 +38,12 @@ cairo_test_t test = {
 
 #define CHECK_SUCCESS do { if (status) return CAIRO_TEST_FAILURE; } while (0)
 
-#define DOUBLE_EQUALS(a,b)  (fabs((a)-(b)) < 0.00001)
-
 static int
 double_buf_equal (double *a, double *b, int nc)
 {
     int i;
     for (i = 0; i < nc; i++) {
-	if (!DOUBLE_EQUALS(a[i],b[i])) {
+	if (!CAIRO_TEST_DOUBLE_EQUALS(a[i],b[i])) {
 	    cairo_test_log ("Error: doubles not equal: %g, %g\n",
 			    a[i], b[i]);
 	    return 0;


More information about the cairo-commit mailing list