summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-03-02 14:40:07 +0100
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-03-02 14:40:07 +0100
commit8c04a5e9640df0f1b2f533ee5fa698e2f466ad1f (patch)
tree32cf896f4a9c926dda04b3b671b29a2662c47aac /tests/auto/corelib/tools
parent310daae53926628f80c08e4415b94b90ad525c8f (diff)
parent78e92997ed35ddc8bb6f7f6c0a4fffba026d5d8f (diff)
Merge remote-tracking branch 'origin/5.11' into dev
Diffstat (limited to 'tests/auto/corelib/tools')
-rw-r--r--tests/auto/corelib/tools/qlocale/tst_qlocale.cpp46
-rw-r--r--tests/auto/corelib/tools/qstringapisymmetry/tst_qstringapisymmetry.cpp22
2 files changed, 64 insertions, 4 deletions
diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
index fc1ac7cf0f..d5e2935d28 100644
--- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
+++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
@@ -141,6 +141,8 @@ private slots:
void formattedDataSize();
void bcp47Name();
+ void systemLocale();
+
private:
QString m_decimal, m_thousand, m_sdate, m_ldate, m_time;
QString m_sysapp;
@@ -2641,5 +2643,49 @@ void tst_QLocale::bcp47Name()
QCOMPARE(QLocale("sr_Latn_HR").bcp47Name(), QStringLiteral("sr-Latn"));
}
+class MySystemLocale : public QSystemLocale
+{
+public:
+ MySystemLocale(const QLocale &locale) : m_locale(locale)
+ {
+ }
+
+ QVariant query(QueryType /*type*/, QVariant /*in*/) const override
+ {
+ return QVariant();
+ }
+
+ QLocale fallbackUiLocale() const override
+ {
+ return m_locale;
+ }
+
+private:
+ const QLocale m_locale;
+};
+
+void tst_QLocale::systemLocale()
+{
+ QLocale originalLocale;
+
+ MySystemLocale *sLocale = new MySystemLocale(QLocale("uk"));
+ QCOMPARE(QLocale().language(), QLocale::Ukrainian);
+ QCOMPARE(QLocale::system().language(), QLocale::Ukrainian);
+ delete sLocale;
+
+ sLocale = new MySystemLocale(QLocale("ca"));
+ QCOMPARE(QLocale().language(), QLocale::Catalan);
+ QCOMPARE(QLocale::system().language(), QLocale::Catalan);
+ delete sLocale;
+
+ sLocale = new MySystemLocale(QLocale("de"));
+ QCOMPARE(QLocale().language(), QLocale::German);
+ QCOMPARE(QLocale::system().language(), QLocale::German);
+ delete sLocale;
+
+ QCOMPARE(QLocale(), originalLocale);
+ QCOMPARE(QLocale::system(), originalLocale);
+}
+
QTEST_MAIN(tst_QLocale)
#include "tst_qlocale.moc"
diff --git a/tests/auto/corelib/tools/qstringapisymmetry/tst_qstringapisymmetry.cpp b/tests/auto/corelib/tools/qstringapisymmetry/tst_qstringapisymmetry.cpp
index 61d1f86f00..cb1fd9eb7d 100644
--- a/tests/auto/corelib/tools/qstringapisymmetry/tst_qstringapisymmetry.cpp
+++ b/tests/auto/corelib/tools/qstringapisymmetry/tst_qstringapisymmetry.cpp
@@ -33,6 +33,7 @@
#include <QString>
#include <QStringView>
#include <QChar>
+#include <QScopedArrayPointer>
#include <QStringRef>
#include <QLatin1String>
#include <QVector>
@@ -70,6 +71,19 @@ MAKE_ALL(const char*, QChar)
#undef MAKE_RELOP
// END FIXME
+// Return a plain ASCII row name consisting of maximum 16 chars and the
+// size for data
+static QByteArray rowName(const QByteArray &data)
+{
+ const int size = data.size();
+ QScopedArrayPointer<char> prettyC(QTest::toPrettyCString(data.constData(), qMin(16, size)));
+ QByteArray result = prettyC.data();
+ result += " (";
+ result += QByteArray::number(size);
+ result += ')';
+ return result;
+}
+
class tst_QStringApiSymmetry : public QObject
{
Q_OBJECT
@@ -1072,7 +1086,7 @@ void tst_QStringApiSymmetry::toLocal8Bit_data()
QString s;
for (char c : ba)
s += QLatin1Char(c);
- QTest::addRow("\"%s\" (%d)", ba.left(16).constData(), ba.size()) << s << ba;
+ QTest::newRow(rowName(ba).constData()) << s << ba;
};
QTest::addRow("null") << QString() << QByteArray();
@@ -1107,7 +1121,7 @@ void tst_QStringApiSymmetry::toLatin1_data()
QString s;
for (char c : ba)
s += QLatin1Char(c);
- QTest::addRow("\"%s\" (%d)", ba.left(16).constData(), ba.size()) << s << ba;
+ QTest::newRow(rowName(ba).constData()) << s << ba;
};
QTest::addRow("null") << QString() << QByteArray();
@@ -1140,7 +1154,7 @@ void tst_QStringApiSymmetry::toUtf8_data()
auto add = [](const char *u8) {
QByteArray ba(u8);
QString s = ba;
- QTest::addRow("\"%s\" (%d)", ba.left(16).constData(), ba.size()) << s << ba;
+ QTest::newRow(rowName(ba).constData()) << s << ba;
};
QTest::addRow("null") << QString() << QByteArray();
@@ -1178,7 +1192,7 @@ void tst_QStringApiSymmetry::toUcs4_data()
s += QLatin1Char(c);
ucs4.append(uint(uchar(c)));
}
- QTest::addRow("\"%s\" (%d)", ba.left(16).constData(), ba.size()) << s << ucs4;
+ QTest::newRow(rowName(ba).constData()) << s << ucs4;
};
QTest::addRow("null") << QString() << QVector<uint>();