summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJeff Muizelaar <jmuizelaar@mozilla.com>2009-02-11 15:24:20 -0500
committerJeff Muizelaar <jmuizelaar@mozilla.com>2009-02-11 15:24:24 -0500
commit41cbd935f9dba276db716e2c71ac21dc60505be9 (patch)
tree08b0573e74a8bff54a4c8cbe7cf37dca936189b2 /test
parent70297f257d4dc0accb5183b806d43a033887acb7 (diff)
[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.
Diffstat (limited to 'test')
-rw-r--r--test/cairo-test.h15
-rw-r--r--test/invalid-matrix.c2
-rw-r--r--test/user-font-rescale.c2
3 files changed, 17 insertions, 2 deletions
diff --git a/test/cairo-test.h b/test/cairo-test.h
index ac8856b3..5a5be44e 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 4ac109e5..933e81c9 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 04d3f53c..ae56ef84 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,