summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@theqtcompany.com>2015-10-15 15:40:26 +0200
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2015-11-02 17:00:50 +0000
commit8c2ca33073f20e1fe552bd8b5f663aec5b8a634d (patch)
treea8277e71b865e3e08908a4937668e163c35a03e6 /tests
parent84042523f272c1d30247e9329eea21036ff793f4 (diff)
Replace qdtoa and qstrtod implementation by a 3rdparty library
This also fixes the underlying cause of QTBUG-44039 and QTBUG-43885. You can choose between system, qt, and no libdouble-conversion support. If you choose "no", snprintf_l and sscanf_l will be used. By default, system double conversion is used if the system provides a double-conversion library. Otherwise the bundled libdouble-conversion is built. sscanf_l and snprintf_l are not used by default as the planned "shortest" conversion mode to produce the shortest possible string will give less precise results when implemented with snprintf_l. Change-Id: I8ca08a0fca5c54cf7009e48e771385614f6aa031 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/tools/qstring/qstring.pro4
-rw-r--r--tests/auto/corelib/tools/qstring/tst_qstring.cpp5
-rw-r--r--tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp7
3 files changed, 14 insertions, 2 deletions
diff --git a/tests/auto/corelib/tools/qstring/qstring.pro b/tests/auto/corelib/tools/qstring/qstring.pro
index a3ac7bc867..1ff9a4fc9e 100644
--- a/tests/auto/corelib/tools/qstring/qstring.pro
+++ b/tests/auto/corelib/tools/qstring/qstring.pro
@@ -7,6 +7,10 @@ contains(QT_CONFIG,icu):DEFINES += QT_USE_ICU
contains(QT_CONFIG,c++11): CONFIG += c++11
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
+!contains(QT_CONFIG, doubleconversion):!contains(QT_CONFIG, system-doubleconversion) {
+ DEFINES += QT_NO_DOUBLECONVERSION
+}
+
mac {
OBJECTIVE_SOURCES += tst_qstring_mac.mm
LIBS += -framework Foundation
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
index ca6046884a..cb911853e8 100644
--- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
@@ -4679,6 +4679,11 @@ void tst_QString::number()
QCOMPARE( QString::number(4.4), QLatin1String("4.4") );
QCOMPARE( QString::number(Q_INT64_C(-555)), QLatin1String("-555") );
QCOMPARE( QString::number(Q_UINT64_C(6666)), QLatin1String("6666") );
+
+#ifndef QT_NO_DOUBLECONVERSION // snprintf_l is too stupid for this
+ QCOMPARE( QString::number(12.05, 'f', 1), QString("12.1") );
+ QCOMPARE( QString::number(12.5, 'f', 0), QString("13") );
+#endif
}
void tst_QString::capacity_data()
diff --git a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp
index 6a1ce17aab..a0fdac075e 100644
--- a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp
+++ b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp
@@ -214,12 +214,15 @@ void tst_QDoubleSpinBox::setPrefixSuffix_data()
QTest::newRow("data0") << QString() << QString() << 10.5 << 1 << "10.5" << "10.5" << false;
QTest::newRow("data1") << QString() << "cm" << 10.5 << 2 << "10.50cm" << "10.50" << false;
- QTest::newRow("data2") << "cm: " << QString() << 10.5 << 0 << "cm: 10" << "10" << false;
+
+ // 10.5 is rounded correctly to 11 when using libdouble-conversion, or incorrectly to 10 when
+ // using snprintf. This is not the point of this test, though.
+ QTest::newRow("data2") << "cm: " << QString() << 10.4 << 0 << "cm: 10" << "10" << false;
QTest::newRow("data3") << "length: " << "cm" << 10.5 << 3 << "length: 10.500cm" << "10.500" << false;
QTest::newRow("data4") << QString() << QString() << 10.5 << 1 << "10.5" << "10.5" << true;
QTest::newRow("data5") << QString() << "cm" << 10.5 << 2 << "10.50cm" << "10.50" << true;
- QTest::newRow("data6") << "cm: " << QString() << 10.5 << 0 << "cm: 10" << "10" << true;
+ QTest::newRow("data6") << "cm: " << QString() << 10.4 << 0 << "cm: 10" << "10" << true;
QTest::newRow("data7") << "length: " << "cm" << 10.5 << 3 << "length: 10.500cm" << "10.500" << true;
}