[cairo-commit] test/cairo-test.h test/invalid-matrix.c test/user-font-rescale.c
Jeff Muizelaar
jrmuizel at kemper.freedesktop.org
Wed Feb 11 15:25:24 PST 2009
test/cairo-test.h | 15 +++++++++++++++
test/invalid-matrix.c | 2 +-
test/user-font-rescale.c | 2 +-
3 files changed, 17 insertions(+), 2 deletions(-)
New commits:
commit 41cbd935f9dba276db716e2c71ac21dc60505be9
Author: Jeff Muizelaar <jmuizelaar at mozilla.com>
Date: Wed Feb 11 15:24:20 2009 -0500
[test] Add cairo_test_NaN and use it in place of strtod
strtod("NaN") returns 0.0 with the MSVC runtime so we
need to generate NaN some other way.
diff --git a/test/cairo-test.h b/test/cairo-test.h
index ac8856b..5a5be44 100644
--- a/test/cairo-test.h
+++ b/test/cairo-test.h
@@ -64,6 +64,21 @@ typedef unsigned __int64 uint64_t;
#include <math.h>
+static inline double
+cairo_test_NaN (void)
+{
+#ifdef _MSC_VER
+ /* MSVC strtod("NaN", NULL) returns 0.0 */
+ union {
+ uint32_t i[2];
+ double d;
+ } nan = {{0xffffffff, 0x7fffffff}};
+ return nan.d;
+#else
+ return strtod("NaN", NULL);
+#endif
+}
+
typedef enum cairo_test_status {
CAIRO_TEST_SUCCESS = 0,
CAIRO_TEST_NO_MEMORY,
diff --git a/test/invalid-matrix.c b/test/invalid-matrix.c
index 4ac109e..933e81c 100644
--- a/test/invalid-matrix.c
+++ b/test/invalid-matrix.c
@@ -74,7 +74,7 @@ if ((status) == CAIRO_STATUS_SUCCESS) { \
#endif
/* create a bogus matrix and check results of attempted inversion */
- bogus.x0 = bogus.xy = bogus.xx = strtod ("NaN", NULL);
+ bogus.x0 = bogus.xy = bogus.xx = cairo_test_NaN ();
bogus.y0 = bogus.yx = bogus.yy = bogus.xx;
status = cairo_matrix_invert (&bogus);
CHECK_STATUS (status, "cairo_matrix_invert(NaN)");
diff --git a/test/user-font-rescale.c b/test/user-font-rescale.c
index 04d3f53..ae56ef8 100644
--- a/test/user-font-rescale.c
+++ b/test/user-font-rescale.c
@@ -211,7 +211,7 @@ create_rescaled_font (cairo_font_face_t *substitute_font,
for (i = 0; i < r->glyph_count; i++) {
r->desired_width[i] = desired_width[i];
/* use NaN to specify unset */
- r->rescale_factor[i] = strtod ("NaN", NULL);
+ r->rescale_factor[i] = cairo_test_NaN ();
}
status = cairo_font_face_set_user_data (user_font_face,
More information about the cairo-commit
mailing list