aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmllocale
diff options
context:
space:
mode:
authorLeander Beernaert <leander.beernaert@qt.io>2020-01-16 16:25:06 +0100
committerLeander Beernaert <leander.beernaert@qt.io>2020-01-16 16:25:06 +0100
commit1d333d3375874efb8d37df37dc5ef561573794ad (patch)
tree2d8c995f64c05c84c1fcceb2c5cb40fcae69855f /tests/auto/qml/qqmllocale
parentb106d86c433706928b0b0c206a0d9f831681e1bf (diff)
parente79a2658cde899d6ee11ec3c0d0a3768eb2c864b (diff)
Merge remote-tracking branch 'origin/dev' into wip/cmake
Diffstat (limited to 'tests/auto/qml/qqmllocale')
-rw-r--r--tests/auto/qml/qqmllocale/tst_qqmllocale.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp
index a90749208c..c846ee32df 100644
--- a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp
+++ b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp
@@ -102,6 +102,7 @@ private slots:
void numberFromLocaleString_data();
void numberFromLocaleString();
void numberConstToLocaleString();
+ void numberOptions();
void stringLocaleCompare_data();
void stringLocaleCompare();
@@ -1157,6 +1158,35 @@ void tst_qqmllocale::numberConstToLocaleString()
QCOMPARE(obj->property("const2").toString(), l.toString(1234., 'f', 2));
}
+void tst_qqmllocale::numberOptions()
+{
+ QQmlEngine engine;
+ QQmlComponent comp(&engine);
+ comp.setData(R"(
+ import QtQml 2.15
+ QtObject {
+ id: root
+ property string formatted
+ property bool caughtException: false
+ Component.onCompleted: () => {
+ const myLocale = Qt.locale("de_DE")
+ myLocale.numberOptions = Locale.OmitGroupSeparator | Locale.RejectTrailingZeroesAfterDot
+ root.formatted = Number(10000).toLocaleString(myLocale, 'f', 4)
+ try {
+ Number.fromLocaleString(myLocale, "1,10");
+ } catch (e) {console.warn(e); root.caughtException = true}
+ }
+ }
+ )", QUrl("testdata"));
+ QTest::ignoreMessage(QtMsgType::QtWarningMsg, "Error: Locale: Number.fromLocaleString(): Invalid format");
+ QScopedPointer<QObject> root {comp.create()};
+ qDebug() << comp.errorString();
+ QVERIFY(root);
+ QCOMPARE(root->property("formatted").toString(), QLatin1String("10000,0000"));
+ QCOMPARE(root->property("caughtException").toBool(), true);
+
+}
+
void tst_qqmllocale::stringLocaleCompare_data()
{
QTest::addColumn<QString>("string1");