mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2025-12-26 17:00:10 +01:00
Fix bitmap-font test by using near-equality for double comparison
This commit is contained in:
parent
468caac068
commit
247e101199
3 changed files with 9 additions and 8 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue