mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-05 14:38:13 +02:00
[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.
This commit is contained in:
parent
70297f257d
commit
41cbd935f9
3 changed files with 17 additions and 2 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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)");
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue