From 036c51c6841a207921a8d2dff3971e74f71201e9 Mon Sep 17 00:00:00 2001 From: Dmitry Shachnev Date: Sun, 8 Jun 2014 19:17:00 +0400 Subject: Fix wrong qreal architecture checks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since Qt 5.2, qreal is double on all architectures by default, but some vendors (like Jolla) still use qreal = float. Instead of old (and broken) architecture checks, use runtime check sizeof(qreal) == sizeof(double). Remove the compile-time checks between DBL_MIN/DBL_MAX checks, these are sufficient on their own. Change-Id: Iae0c6486afaed0f0653fb3338c048c8f22d1e587 Reviewed-by: Alex Blasche Reviewed-by: Lisandro Damián Nicanor Pérez Meyer --- tests/auto/qgeocoordinate/tst_qgeocoordinate.cpp | 63 +++++++++++----------- .../auto/qgeopositioninfo/tst_qgeopositioninfo.cpp | 6 --- .../qgeosatelliteinfo/tst_qgeosatelliteinfo.cpp | 6 --- 3 files changed, 33 insertions(+), 42 deletions(-) diff --git a/tests/auto/qgeocoordinate/tst_qgeocoordinate.cpp b/tests/auto/qgeocoordinate/tst_qgeocoordinate.cpp index b3c2d020..581f5c00 100644 --- a/tests/auto/qgeocoordinate/tst_qgeocoordinate.cpp +++ b/tests/auto/qgeocoordinate/tst_qgeocoordinate.cpp @@ -516,36 +516,39 @@ private slots: << qreal(1000.0) << qreal(10.0) << QGeoCoordinate(); - QTest::newRow("brisbane -> melbourne") - << BRISBANE - << qreal(1374820.1618767744) - << qreal(211.1717286649) -// the following platforms use float for qreal -#if !defined(QT_NO_FPU) && !defined(Q_PROCESSOR_ARM) && !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) - << MELBOURNE; -#else - << QGeoCoordinate(-37.8142515084775, 144.963170622944); -#endif - QTest::newRow("london -> new york") - << LONDON - << qreal(5570538.4987236429) - << qreal(288.3388804508) -// the following platforms use float for qreal -#if !defined(QT_NO_FPU) && !defined(Q_PROCESSOR_ARM) && !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) - << NEW_YORK; -#else - << QGeoCoordinate(40.7145220608416, -74.0071216045375); -#endif - QTest::newRow("north pole -> south pole") - << NORTH_POLE - << qreal(20015109.4154876769) - << qreal(180.0) -// the following platforms use float for qreal -#if !defined(QT_NO_FPU) && !defined(Q_PROCESSOR_ARM) && !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) - << SOUTH_POLE; -#else - << QGeoCoordinate(-89.9999947369857, -90.0); -#endif + if (sizeof(qreal) == sizeof(double)) { + QTest::newRow("brisbane -> melbourne") + << BRISBANE + << qreal(1374820.1618767744) + << qreal(211.1717286649) + << MELBOURNE; + QTest::newRow("london -> new york") + << LONDON + << qreal(5570538.4987236429) + << qreal(288.3388804508) + << NEW_YORK; + QTest::newRow("north pole -> south pole") + << NORTH_POLE + << qreal(20015109.4154876769) + << qreal(180.0) + << SOUTH_POLE; + } else { + QTest::newRow("brisbane -> melbourne") + << BRISBANE + << qreal(1374820.1618767744) + << qreal(211.1717286649) + << QGeoCoordinate(-37.8142515084775, 144.963170622944); + QTest::newRow("london -> new york") + << LONDON + << qreal(5570538.4987236429) + << qreal(288.3388804508) + << QGeoCoordinate(40.7145220608416, -74.0071216045375); + QTest::newRow("north pole -> south pole") + << NORTH_POLE + << qreal(20015109.4154876769) + << qreal(180.0) + << QGeoCoordinate(-89.9999947369857, -90.0); + } } void degreesToString() diff --git a/tests/auto/qgeopositioninfo/tst_qgeopositioninfo.cpp b/tests/auto/qgeopositioninfo/tst_qgeopositioninfo.cpp index 21417f84..1a1274c6 100644 --- a/tests/auto/qgeopositioninfo/tst_qgeopositioninfo.cpp +++ b/tests/auto/qgeopositioninfo/tst_qgeopositioninfo.cpp @@ -73,21 +73,15 @@ QList tst_qgeopositioninfo_qrealTestValues() { QList values; -// the following platforms use float for qreal -#if !defined(QT_NO_FPU) && !defined(Q_PROCESSOR_ARM) && !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) if (qreal(DBL_MIN) == DBL_MIN) values << DBL_MIN; -#endif values << FLT_MIN; values << -1.0 << 0.0 << 1.0; values << FLT_MAX; -// the following platforms use float for qreal -#if !defined(QT_NO_FPU) && !defined(Q_PROCESSOR_ARM) && !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) if (qreal(DBL_MAX) == DBL_MAX) values << DBL_MAX; -#endif return values; } diff --git a/tests/auto/qgeosatelliteinfo/tst_qgeosatelliteinfo.cpp b/tests/auto/qgeosatelliteinfo/tst_qgeosatelliteinfo.cpp index 69f04762..7dc38d6b 100644 --- a/tests/auto/qgeosatelliteinfo/tst_qgeosatelliteinfo.cpp +++ b/tests/auto/qgeosatelliteinfo/tst_qgeosatelliteinfo.cpp @@ -73,21 +73,15 @@ QList tst_qgeosatelliteinfo_qrealTestValues() { QList values; -// the following platforms use float for qreal -#if !defined(QT_NO_FPU) && !defined(Q_PROCESSOR_ARM) && !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) if (qreal(DBL_MIN) == DBL_MIN) values << DBL_MIN; -#endif values << FLT_MIN; values << -1.0 << 0.0 << 1.0; values << FLT_MAX; -// the following platforms use float for qreal -#if !defined(QT_NO_FPU) && !defined(Q_PROCESSOR_ARM) && !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) if (qreal(DBL_MAX) == DBL_MAX) values << DBL_MAX; -#endif return values; } -- cgit v1.2.1