summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r--tests/auto/corelib/io/qsettings/tst_qsettings.cpp93
-rw-r--r--tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp17
-rw-r--r--tests/auto/corelib/thread/qatomicinteger/no-cxx11/char/char.pro (renamed from tests/auto/corelib/thread/qatomicinteger/cxx11/char/char.pro)0
-rw-r--r--tests/auto/corelib/thread/qatomicinteger/no-cxx11/char16_t/char16_t.pro (renamed from tests/auto/corelib/thread/qatomicinteger/cxx11/char16_t/char16_t.pro)0
-rw-r--r--tests/auto/corelib/thread/qatomicinteger/no-cxx11/char32_t/char32_t.pro (renamed from tests/auto/corelib/thread/qatomicinteger/cxx11/char32_t/char32_t.pro)0
-rw-r--r--tests/auto/corelib/thread/qatomicinteger/no-cxx11/int/int.pro (renamed from tests/auto/corelib/thread/qatomicinteger/cxx11/int/int.pro)0
-rw-r--r--tests/auto/corelib/thread/qatomicinteger/no-cxx11/long/long.pro (renamed from tests/auto/corelib/thread/qatomicinteger/cxx11/long/long.pro)0
-rw-r--r--tests/auto/corelib/thread/qatomicinteger/no-cxx11/qlonglong/qlonglong.pro (renamed from tests/auto/corelib/thread/qatomicinteger/cxx11/qlonglong/qlonglong.pro)0
-rw-r--r--tests/auto/corelib/thread/qatomicinteger/no-cxx11/qptrdiff/qptrdiff.pro (renamed from tests/auto/corelib/thread/qatomicinteger/cxx11/qptrdiff/qptrdiff.pro)0
-rw-r--r--tests/auto/corelib/thread/qatomicinteger/no-cxx11/quintptr/quintptr.pro (renamed from tests/auto/corelib/thread/qatomicinteger/cxx11/quintptr/quintptr.pro)0
-rw-r--r--tests/auto/corelib/thread/qatomicinteger/no-cxx11/qulonglong/qulonglong.pro (renamed from tests/auto/corelib/thread/qatomicinteger/cxx11/qulonglong/qulonglong.pro)0
-rw-r--r--tests/auto/corelib/thread/qatomicinteger/no-cxx11/schar/schar.pro (renamed from tests/auto/corelib/thread/qatomicinteger/cxx11/schar/schar.pro)0
-rw-r--r--tests/auto/corelib/thread/qatomicinteger/no-cxx11/short/short.pro (renamed from tests/auto/corelib/thread/qatomicinteger/cxx11/short/short.pro)0
-rw-r--r--tests/auto/corelib/thread/qatomicinteger/no-cxx11/uchar/uchar.pro (renamed from tests/auto/corelib/thread/qatomicinteger/cxx11/uchar/uchar.pro)0
-rw-r--r--tests/auto/corelib/thread/qatomicinteger/no-cxx11/uint/uint.pro (renamed from tests/auto/corelib/thread/qatomicinteger/cxx11/uint/uint.pro)0
-rw-r--r--tests/auto/corelib/thread/qatomicinteger/no-cxx11/ulong/ulong.pro (renamed from tests/auto/corelib/thread/qatomicinteger/cxx11/ulong/ulong.pro)0
-rw-r--r--tests/auto/corelib/thread/qatomicinteger/no-cxx11/ushort/ushort.pro (renamed from tests/auto/corelib/thread/qatomicinteger/cxx11/ushort/ushort.pro)0
-rw-r--r--tests/auto/corelib/thread/qatomicinteger/no-cxx11/wchar_t/wchar_t.pro (renamed from tests/auto/corelib/thread/qatomicinteger/cxx11/wchar_t/wchar_t.pro)0
-rw-r--r--tests/auto/corelib/thread/qatomicinteger/qatomicinteger.pri6
-rw-r--r--tests/auto/corelib/thread/qatomicinteger/qatomicinteger.pro32
-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
26 files changed, 214 insertions, 94 deletions
diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
index 30812700c5..b0cb59a012 100644
--- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
+++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
@@ -89,12 +89,11 @@ class tst_QSettings : public QObject
Q_OBJECT
public:
- tst_QSettings() : m_canWriteNativeSystemSettings(canWriteNativeSystemSettings()) {}
+ tst_QSettings();
public slots:
void initTestCase();
- void init();
- void cleanup();
+ void cleanup() { cleanupTestFiles(); }
private slots:
void getSetCheck();
void ctor_data();
@@ -166,6 +165,8 @@ private slots:
void bom();
private:
+ void cleanupTestFiles();
+
const bool m_canWriteNativeSystemSettings;
};
@@ -181,39 +182,16 @@ void tst_QSettings::getSetCheck()
QCOMPARE(true, obj1.fallbacksEnabled());
}
-#if defined(Q_OS_WINCE) || defined(Q_OS_WINRT)
-static void removePath(const QString& _path)
-{
- QString path = _path;
- QDir dir(path);
- if (!dir.exists())
- return;
- QStringList entries = dir.entryList(QDir::AllEntries | QDir::NoDotAndDotDot);
- foreach(QString name, entries) {
- QString absolute = path + name;
- if (QFileInfo(absolute).isDir())
- removePath(absolute+"\\");
- else
- QFile::remove(absolute);
- }
- dir.cdUp();
- if (path[path.size()-1] == '\\')
- path = path.left(path.size()-1);
- dir.rmdir(path.mid(path.lastIndexOf('\\')+1));
-}
-#endif
-
-static QString settingsPath(const char *path = "")
+static QString settingsPath(const char *path = Q_NULLPTR)
{
// Temporary path for files that are specified explicitly in the constructor.
#ifndef Q_OS_WINRT
- QString tempPath = QDir::tempPath();
+ static const QString tempPath = QDir::tempPath() + QLatin1String("/tst_QSettings");
#else
- QString tempPath = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
+ static const QString tempPath = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)
+ + QLatin1String("/tst_QSettings");
#endif
- if (tempPath.endsWith(QLatin1Char('/')))
- tempPath.truncate(tempPath.size() - 1);
- return QDir::toNativeSeparators(tempPath + "/tst_QSettings/" + QLatin1String(path));
+ return path && *path ? tempPath + QLatin1Char('/') + QLatin1String(path) : tempPath;
}
static bool readCustom1File(QIODevice &device, QSettings::SettingsMap &map)
@@ -283,6 +261,12 @@ static void populateWithFormats()
QTest::newRow("custom2") << QSettings::CustomFormat2;
}
+tst_QSettings::tst_QSettings()
+ : m_canWriteNativeSystemSettings(canWriteNativeSystemSettings())
+{
+ QStandardPaths::setTestModeEnabled(true);
+}
+
void tst_QSettings::initTestCase()
{
if (!m_canWriteNativeSystemSettings)
@@ -295,13 +279,19 @@ void tst_QSettings::initTestCase()
);
QCOMPARE(custom1, QSettings::CustomFormat1);
QCOMPARE(custom2, QSettings::CustomFormat2);
+
+ cleanupTestFiles();
}
-void tst_QSettings::init()
+void tst_QSettings::cleanupTestFiles()
{
QSettings::setSystemIniPath(settingsPath("__system__"));
QSettings::setUserIniPath(settingsPath("__user__"));
+ QDir settingsDir(settingsPath());
+ if (settingsDir.exists())
+ QVERIFY(settingsDir.removeRecursively());
+
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
QSettings("HKEY_CURRENT_USER\\Software\\software.org", QSettings::NativeFormat).clear();
QSettings("HKEY_CURRENT_USER\\Software\\other.software.org", QSettings::NativeFormat).clear();
@@ -317,17 +307,7 @@ void tst_QSettings::init()
QSettings("HKEY_LOCAL_MACHINE\\Software\\bat", QSettings::NativeFormat).clear();
QSettings("HKEY_LOCAL_MACHINE\\Software\\baz", QSettings::NativeFormat).clear();
}
- if (QDir(settingsPath()).exists()) {
-#if defined(Q_OS_WINCE)
- removePath(settingsPath());
-#else
- if (QSysInfo::windowsVersion() & QSysInfo::WV_NT_based)
- system(QString("rmdir /Q /S %1").arg(settingsPath()).toLatin1());
- else
- system(QString("deltree /Y %1").arg(settingsPath()).toLatin1());
-#endif
- }
-#elif defined(Q_OS_DARWIN)
+#elif defined(Q_OS_DARWIN) || defined(Q_OS_WINRT)
QSettings(QSettings::UserScope, "software.org", "KillerAPP").clear();
QSettings(QSettings::SystemScope, "software.org", "KillerAPP").clear();
QSettings(QSettings::UserScope, "other.software.org", "KillerAPP").clear();
@@ -338,31 +318,16 @@ void tst_QSettings::init()
QSettings(QSettings::SystemScope, "other.software.org").clear();
#endif
-#if !defined(Q_OS_WIN)
- system(QString("chmod -R u+rw %1 2> /dev/null").arg(settingsPath()).toLatin1());
- system(QString("rm -fr %1 2> /dev/null").arg(settingsPath()).toLatin1());
-#endif
+ const QString foo(QLatin1String("foo"));
#if defined(Q_OS_WINRT)
- QSettings(QSettings::UserScope, "software.org", "KillerAPP").clear();
- QSettings(QSettings::SystemScope, "software.org", "KillerAPP").clear();
- QSettings(QSettings::UserScope, "other.software.org", "KillerAPP").clear();
- QSettings(QSettings::SystemScope, "other.software.org", "KillerAPP").clear();
- QSettings(QSettings::UserScope, "software.org").clear();
- QSettings(QSettings::SystemScope, "software.org").clear();
- QSettings(QSettings::UserScope, "other.software.org").clear();
- QSettings(QSettings::SystemScope, "other.software.org").clear();
- QSettings("foo", QSettings::NativeFormat).clear();
- removePath(settingsPath());
- QFile::remove(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/foo");
+ QSettings(foo, QSettings::NativeFormat).clear();
+ QFile fooFile(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + QLatin1Char('/') + foo);
#else
- QFile::remove("foo");
+ QFile fooFile(foo);
#endif
-}
-
-void tst_QSettings::cleanup()
-{
- init();
+ if (fooFile.exists())
+ QVERIFY2(fooFile.remove(), qPrintable(fooFile.errorString()));
}
/*
diff --git a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp
index 532a53e5d3..24cde14459 100644
--- a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp
+++ b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp
@@ -163,6 +163,7 @@ private slots:
void string_write_operator_ToDevice_data();
void string_write_operator_ToDevice();
void latin1String_write_operator_ToDevice();
+ void stringref_write_operator_ToDevice();
// other
void skipWhiteSpace_data();
@@ -2554,6 +2555,22 @@ void tst_QTextStream::latin1String_write_operator_ToDevice()
QCOMPARE(buf.buffer().constData(), "No explicit lengthExplicit length");
}
+void tst_QTextStream::stringref_write_operator_ToDevice()
+{
+ QBuffer buf;
+ buf.open(QBuffer::WriteOnly);
+ QTextStream stream(&buf);
+ stream.setCodec(QTextCodec::codecForName("ISO-8859-1"));
+ stream.setAutoDetectUnicode(true);
+
+ const QString expected = "No explicit lengthExplicit length";
+
+ stream << expected.leftRef(18);
+ stream << expected.midRef(18);
+ stream.flush();
+ QCOMPARE(buf.buffer().constData(), "No explicit lengthExplicit length");
+}
+
// ------------------------------------------------------------------------------
void tst_QTextStream::useCase1()
{
diff --git a/tests/auto/corelib/thread/qatomicinteger/cxx11/char/char.pro b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/char/char.pro
index 64401f0229..64401f0229 100644
--- a/tests/auto/corelib/thread/qatomicinteger/cxx11/char/char.pro
+++ b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/char/char.pro
diff --git a/tests/auto/corelib/thread/qatomicinteger/cxx11/char16_t/char16_t.pro b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/char16_t/char16_t.pro
index 64401f0229..64401f0229 100644
--- a/tests/auto/corelib/thread/qatomicinteger/cxx11/char16_t/char16_t.pro
+++ b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/char16_t/char16_t.pro
diff --git a/tests/auto/corelib/thread/qatomicinteger/cxx11/char32_t/char32_t.pro b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/char32_t/char32_t.pro
index 64401f0229..64401f0229 100644
--- a/tests/auto/corelib/thread/qatomicinteger/cxx11/char32_t/char32_t.pro
+++ b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/char32_t/char32_t.pro
diff --git a/tests/auto/corelib/thread/qatomicinteger/cxx11/int/int.pro b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/int/int.pro
index 64401f0229..64401f0229 100644
--- a/tests/auto/corelib/thread/qatomicinteger/cxx11/int/int.pro
+++ b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/int/int.pro
diff --git a/tests/auto/corelib/thread/qatomicinteger/cxx11/long/long.pro b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/long/long.pro
index 64401f0229..64401f0229 100644
--- a/tests/auto/corelib/thread/qatomicinteger/cxx11/long/long.pro
+++ b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/long/long.pro
diff --git a/tests/auto/corelib/thread/qatomicinteger/cxx11/qlonglong/qlonglong.pro b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/qlonglong/qlonglong.pro
index 64401f0229..64401f0229 100644
--- a/tests/auto/corelib/thread/qatomicinteger/cxx11/qlonglong/qlonglong.pro
+++ b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/qlonglong/qlonglong.pro
diff --git a/tests/auto/corelib/thread/qatomicinteger/cxx11/qptrdiff/qptrdiff.pro b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/qptrdiff/qptrdiff.pro
index 64401f0229..64401f0229 100644
--- a/tests/auto/corelib/thread/qatomicinteger/cxx11/qptrdiff/qptrdiff.pro
+++ b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/qptrdiff/qptrdiff.pro
diff --git a/tests/auto/corelib/thread/qatomicinteger/cxx11/quintptr/quintptr.pro b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/quintptr/quintptr.pro
index 64401f0229..64401f0229 100644
--- a/tests/auto/corelib/thread/qatomicinteger/cxx11/quintptr/quintptr.pro
+++ b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/quintptr/quintptr.pro
diff --git a/tests/auto/corelib/thread/qatomicinteger/cxx11/qulonglong/qulonglong.pro b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/qulonglong/qulonglong.pro
index 64401f0229..64401f0229 100644
--- a/tests/auto/corelib/thread/qatomicinteger/cxx11/qulonglong/qulonglong.pro
+++ b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/qulonglong/qulonglong.pro
diff --git a/tests/auto/corelib/thread/qatomicinteger/cxx11/schar/schar.pro b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/schar/schar.pro
index 64401f0229..64401f0229 100644
--- a/tests/auto/corelib/thread/qatomicinteger/cxx11/schar/schar.pro
+++ b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/schar/schar.pro
diff --git a/tests/auto/corelib/thread/qatomicinteger/cxx11/short/short.pro b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/short/short.pro
index 64401f0229..64401f0229 100644
--- a/tests/auto/corelib/thread/qatomicinteger/cxx11/short/short.pro
+++ b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/short/short.pro
diff --git a/tests/auto/corelib/thread/qatomicinteger/cxx11/uchar/uchar.pro b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/uchar/uchar.pro
index 64401f0229..64401f0229 100644
--- a/tests/auto/corelib/thread/qatomicinteger/cxx11/uchar/uchar.pro
+++ b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/uchar/uchar.pro
diff --git a/tests/auto/corelib/thread/qatomicinteger/cxx11/uint/uint.pro b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/uint/uint.pro
index 64401f0229..64401f0229 100644
--- a/tests/auto/corelib/thread/qatomicinteger/cxx11/uint/uint.pro
+++ b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/uint/uint.pro
diff --git a/tests/auto/corelib/thread/qatomicinteger/cxx11/ulong/ulong.pro b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/ulong/ulong.pro
index 64401f0229..64401f0229 100644
--- a/tests/auto/corelib/thread/qatomicinteger/cxx11/ulong/ulong.pro
+++ b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/ulong/ulong.pro
diff --git a/tests/auto/corelib/thread/qatomicinteger/cxx11/ushort/ushort.pro b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/ushort/ushort.pro
index 64401f0229..64401f0229 100644
--- a/tests/auto/corelib/thread/qatomicinteger/cxx11/ushort/ushort.pro
+++ b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/ushort/ushort.pro
diff --git a/tests/auto/corelib/thread/qatomicinteger/cxx11/wchar_t/wchar_t.pro b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/wchar_t/wchar_t.pro
index 64401f0229..64401f0229 100644
--- a/tests/auto/corelib/thread/qatomicinteger/cxx11/wchar_t/wchar_t.pro
+++ b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/wchar_t/wchar_t.pro
diff --git a/tests/auto/corelib/thread/qatomicinteger/qatomicinteger.pri b/tests/auto/corelib/thread/qatomicinteger/qatomicinteger.pri
index fd4387b188..29e9464a4d 100644
--- a/tests/auto/corelib/thread/qatomicinteger/qatomicinteger.pri
+++ b/tests/auto/corelib/thread/qatomicinteger/qatomicinteger.pri
@@ -3,9 +3,9 @@ TYPE = $$basename(_PRO_FILE_PWD_)
dn = $$dirname(_PRO_FILE_PWD_)
FORCE = $$basename(dn)
-equals(FORCE, cxx11) {
- suffix = Cxx11_$$TYPE
- DEFINES += QT_ATOMIC_FORCE_CXX11
+equals(FORCE, no-cxx11) {
+ suffix = NoCxx11_$$TYPE
+ DEFINES += QT_ATOMIC_FORCE_NO_CXX11
} else: equals(FORCE, gcc) {
suffix = Gcc_$$TYPE
DEFINES += QT_ATOMIC_FORCE_GCC
diff --git a/tests/auto/corelib/thread/qatomicinteger/qatomicinteger.pro b/tests/auto/corelib/thread/qatomicinteger/qatomicinteger.pro
index 58e5b157bd..9d929e649e 100644
--- a/tests/auto/corelib/thread/qatomicinteger/qatomicinteger.pro
+++ b/tests/auto/corelib/thread/qatomicinteger/qatomicinteger.pro
@@ -19,22 +19,22 @@ SUBDIRS=\
contains(QT_CONFIG, c++11)|msvc: SUBDIRS +=\
- cxx11/char \
- cxx11/char16_t \
- cxx11/char32_t \
- cxx11/int \
- cxx11/long \
- cxx11/qlonglong \
- cxx11/qptrdiff \
- cxx11/quintptr \
- cxx11/qulonglong \
- cxx11/schar \
- cxx11/short \
- cxx11/uchar \
- cxx11/uint \
- cxx11/ulong \
- cxx11/ushort \
- cxx11/wchar_t \
+ no-cxx11/char \
+ no-cxx11/char16_t \
+ no-cxx11/char32_t \
+ no-cxx11/int \
+ no-cxx11/long \
+ no-cxx11/qlonglong \
+ no-cxx11/qptrdiff \
+ no-cxx11/quintptr \
+ no-cxx11/qulonglong \
+ no-cxx11/schar \
+ no-cxx11/short \
+ no-cxx11/uchar \
+ no-cxx11/uint \
+ no-cxx11/ulong \
+ no-cxx11/ushort \
+ no-cxx11/wchar_t \
# The GCC-style atomics only support 32-bit and pointer-sized but add
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 \