From 58cbb9fe4f89b9febd780f7bdcfa4c2bb74a723e Mon Sep 17 00:00:00 2001 From: Kristian Evers Date: Sun, 6 May 2018 17:43:26 +0300 Subject: Replace int typecasts with calls to lround to avoid bad conversions on NaN input. Added test to check for those cases. --- src/gie.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/gie.c') diff --git a/src/gie.c b/src/gie.c index b81e6bdc..f9f76452 100644 --- a/src/gie.c +++ b/src/gie.c @@ -1942,6 +1942,19 @@ static int cart_selftest (void) { if (P->f != 1.0/298.257223563) return 125; proj_destroy(P); + /* Test that pj_fwd* and pj_inv* returns NaNs when receiving NaN input */ + P = proj_create(PJ_DEFAULT_CTX, "+proj=merc"); + if (0==P) return 0; + a = proj_coord(NAN, NAN, NAN, NAN); + a = proj_trans(P, PJ_FWD, a); + if ( !( isnan(a.v[0]) && isnan(a.v[1]) && isnan(a.v[2]) && isnan(a.v[3]) ) ) + return 126; + a = proj_coord(NAN, NAN, NAN, NAN); + a = proj_trans(P, PJ_INV, a); + if ( !( isnan(a.v[0]) && isnan(a.v[1]) && isnan(a.v[2]) && isnan(a.v[3]) ) ) + return 127; + proj_destroy(P); + return 0; } -- cgit v1.2.3