summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-10-23 14:01:35 +0200
committerOswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>2015-10-23 14:45:03 +0200
commit790aef362fd195adf97d8c780a7cbbbade27d51f (patch)
tree8be464687ab21806cfe9f7ada27098b563aa41b2 /tests/auto/corelib/tools
parent9720efbd1035c2e939b0581163e6d804c713dd96 (diff)
parent07475c662eb73c833da2d461b8ef2702ca1e2cfb (diff)
Merge remote-tracking branch 'origin/5.6' into dev
Conflicts: .qmake.conf configure src/corelib/global/qglobal.h src/tools/qdoc/node.cpp src/tools/qdoc/qdocdatabase.cpp tests/auto/corelib/io/qsettings/tst_qsettings.cpp tools/configure/configureapp.cpp Change-Id: I66028ae5e441a06b73ee85ba72a03a3af3e8593f
Diffstat (limited to 'tests/auto/corelib/tools')
-rw-r--r--tests/auto/corelib/tools/qlatin1string/.gitignore1
-rw-r--r--tests/auto/corelib/tools/qlatin1string/qlatin1string.pro8
-rw-r--r--tests/auto/corelib/tools/qlatin1string/tst_qlatin1string.cpp126
-rw-r--r--tests/auto/corelib/tools/qlocale/tst_qlocale.cpp21
-rw-r--r--tests/auto/corelib/tools/qstring/tst_qstring.cpp3
-rw-r--r--tests/auto/corelib/tools/tools.pro1
6 files changed, 149 insertions, 11 deletions
diff --git a/tests/auto/corelib/tools/qlatin1string/.gitignore b/tests/auto/corelib/tools/qlatin1string/.gitignore
new file mode 100644
index 0000000000..dddf56b2df
--- /dev/null
+++ b/tests/auto/corelib/tools/qlatin1string/.gitignore
@@ -0,0 +1 @@
+tst_qlatin1string
diff --git a/tests/auto/corelib/tools/qlatin1string/qlatin1string.pro b/tests/auto/corelib/tools/qlatin1string/qlatin1string.pro
new file mode 100644
index 0000000000..219afa661b
--- /dev/null
+++ b/tests/auto/corelib/tools/qlatin1string/qlatin1string.pro
@@ -0,0 +1,8 @@
+CONFIG += testcase parallel_test
+TARGET = tst_qlatin1string
+QT = core testlib
+SOURCES = tst_qlatin1string.cpp
+DEFINES += QT_NO_CAST_TO_ASCII
+contains(QT_CONFIG,c++11): CONFIG += c++11 c++14
+
+DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/corelib/tools/qlatin1string/tst_qlatin1string.cpp b/tests/auto/corelib/tools/qlatin1string/tst_qlatin1string.cpp
new file mode 100644
index 0000000000..290c9fc12a
--- /dev/null
+++ b/tests/auto/corelib/tools/qlatin1string/tst_qlatin1string.cpp
@@ -0,0 +1,126 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+
+#include <QString>
+
+class tst_QLatin1String : public QObject
+{
+ Q_OBJECT
+
+private Q_SLOTS:
+ void nullString();
+ void emptyString();
+};
+
+void tst_QLatin1String::nullString()
+{
+ // default ctor
+ {
+ QLatin1String l1;
+ QCOMPARE(static_cast<const void*>(l1.data()), static_cast<const void*>(Q_NULLPTR));
+ QCOMPARE(l1.size(), 0);
+
+ QString s = l1;
+ QVERIFY(s.isNull());
+ }
+
+ // from nullptr
+ {
+ const char *null = Q_NULLPTR;
+ QLatin1String l1(null);
+ QCOMPARE(static_cast<const void*>(l1.data()), static_cast<const void*>(Q_NULLPTR));
+ QCOMPARE(l1.size(), 0);
+
+ QString s = l1;
+ QVERIFY(s.isNull());
+ }
+
+ // from null QByteArray
+ {
+ const QByteArray null;
+ QVERIFY(null.isNull());
+
+ QLatin1String l1(null);
+ QEXPECT_FAIL("", "null QByteArrays become non-null QLatin1Strings...", Continue);
+ QCOMPARE(static_cast<const void*>(l1.data()), static_cast<const void*>(Q_NULLPTR));
+ QCOMPARE(l1.size(), 0);
+
+ QString s = l1;
+ QEXPECT_FAIL("", "null QByteArrays become non-null QLatin1Strings become non-null QStrings...", Continue);
+ QVERIFY(s.isNull());
+ }
+}
+
+void tst_QLatin1String::emptyString()
+{
+ {
+ const char *empty = "";
+ QLatin1String l1(empty);
+ QCOMPARE(static_cast<const void*>(l1.data()), static_cast<const void*>(empty));
+ QCOMPARE(l1.size(), 0);
+
+ QString s = l1;
+ QVERIFY(s.isEmpty());
+ QVERIFY(!s.isNull());
+ }
+
+ {
+ const char *notEmpty = "foo";
+ QLatin1String l1(notEmpty, 0);
+ QCOMPARE(static_cast<const void*>(l1.data()), static_cast<const void*>(notEmpty));
+ QCOMPARE(l1.size(), 0);
+
+ QString s = l1;
+ QVERIFY(s.isEmpty());
+ QVERIFY(!s.isNull());
+ }
+
+ {
+ const QByteArray empty = "";
+ QLatin1String l1(empty);
+ QCOMPARE(static_cast<const void*>(l1.data()), static_cast<const void*>(empty.constData()));
+ QCOMPARE(l1.size(), 0);
+
+ QString s = l1;
+ QVERIFY(s.isEmpty());
+ QVERIFY(!s.isNull());
+ }
+}
+
+
+
+QTEST_APPLESS_MAIN(tst_QLatin1String)
+
+#include "tst_qlatin1string.moc"
diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
index 33c8eb303a..edaa00098e 100644
--- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
+++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
@@ -902,6 +902,7 @@ void tst_QLocale::long_long_conversion()
void tst_QLocale::long_long_conversion_extra()
{
QLocale l(QLocale::C);
+ l.setNumberOptions(0);
QCOMPARE(l.toString((qlonglong)1), QString("1"));
QCOMPARE(l.toString((qlonglong)12), QString("12"));
QCOMPARE(l.toString((qlonglong)123), QString("123"));
@@ -1613,20 +1614,20 @@ void tst_QLocale::numberOptions()
bool ok;
QLocale locale(QLocale::C);
- QCOMPARE(locale.numberOptions(), 0);
- QCOMPARE(locale.toInt(QString("12,345"), &ok), 12345);
+ QCOMPARE(locale.numberOptions(), QLocale::OmitGroupSeparator);
+ QCOMPARE(locale.toInt(QString("12345"), &ok), 12345);
QVERIFY(ok);
QCOMPARE(locale.toInt(QString("12345"), &ok), 12345);
QVERIFY(ok);
- QCOMPARE(locale.toString(12345), QString("12,345"));
+ QCOMPARE(locale.toString(12345), QString("12345"));
- locale.setNumberOptions(QLocale::OmitGroupSeparator);
- QCOMPARE(locale.numberOptions(), QLocale::OmitGroupSeparator);
+ locale.setNumberOptions(0);
+ QCOMPARE(locale.numberOptions(), 0);
QCOMPARE(locale.toInt(QString("12,345"), &ok), 12345);
QVERIFY(ok);
QCOMPARE(locale.toInt(QString("12345"), &ok), 12345);
QVERIFY(ok);
- QCOMPARE(locale.toString(12345), QString("12345"));
+ QCOMPARE(locale.toString(12345), QString("12,345"));
locale.setNumberOptions(QLocale::RejectGroupSeparator);
QCOMPARE(locale.numberOptions(), QLocale::RejectGroupSeparator);
@@ -2035,10 +2036,10 @@ void tst_QLocale::standaloneMonthName()
void tst_QLocale::currency()
{
const QLocale c(QLocale::C);
- QCOMPARE(c.toCurrencyString(qulonglong(1234)), QString("1,234"));
- QCOMPARE(c.toCurrencyString(qlonglong(-1234)), QString("-1,234"));
- QCOMPARE(c.toCurrencyString(double(1234.56)), QString("1,234.56"));
- QCOMPARE(c.toCurrencyString(double(-1234.56)), QString("-1,234.56"));
+ QCOMPARE(c.toCurrencyString(qulonglong(1234)), QString("1234"));
+ QCOMPARE(c.toCurrencyString(qlonglong(-1234)), QString("-1234"));
+ QCOMPARE(c.toCurrencyString(double(1234.56)), QString("1234.56"));
+ QCOMPARE(c.toCurrencyString(double(-1234.56)), QString("-1234.56"));
const QLocale en_US("en_US");
QCOMPARE(en_US.toCurrencyString(qulonglong(1234)), QString("$1,234"));
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
index 6b84fa367b..a1e6a1d1b1 100644
--- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
@@ -6256,14 +6256,15 @@ void tst_QString::arg_locale()
QLocale l(QLocale::English, QLocale::UnitedKingdom);
QString str("*%L1*%L2*");
- QCOMPARE(str.arg(123456).arg(1234.56), QString::fromLatin1("*123,456*1,234.56*"));
QLocale::setDefault(l);
+ QCOMPARE(str.arg(123456).arg(1234.56), QString::fromLatin1("*123,456*1,234.56*"));
l.setNumberOptions(QLocale::OmitGroupSeparator);
QLocale::setDefault(l);
QCOMPARE(str.arg(123456).arg(1234.56), QString::fromLatin1("*123456*1234.56*"));
QLocale::setDefault(QLocale::C);
+ QCOMPARE(str.arg(123456).arg(1234.56), QString::fromLatin1("*123456*1234.56*"));
}
diff --git a/tests/auto/corelib/tools/tools.pro b/tests/auto/corelib/tools/tools.pro
index 9024a1a1bb..f9e1c454e7 100644
--- a/tests/auto/corelib/tools/tools.pro
+++ b/tests/auto/corelib/tools/tools.pro
@@ -24,6 +24,7 @@ SUBDIRS=\
qhash \
qhash_strictiterators \
qhashfunctions \
+ qlatin1string \
qline \
qlinkedlist \
qlist \