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.cpp10
-rw-r--r--tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp12
-rw-r--r--tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp26
-rw-r--r--tests/auto/corelib/tools/collections/tst_collections.cpp134
-rwxr-xr-xtests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp20
-rw-r--r--tests/auto/corelib/tools/qhash/tst_qhash.cpp30
-rw-r--r--tests/auto/corelib/tools/qlocale/tst_qlocale.cpp14
-rw-r--r--tests/auto/corelib/tools/qmap/tst_qmap.cpp68
-rw-r--r--tests/auto/corelib/tools/qregexp/tst_qregexp.cpp8
-rw-r--r--tests/auto/corelib/tools/qset/tst_qset.cpp2
-rw-r--r--tests/auto/corelib/tools/qstring/tst_qstring.cpp393
-rw-r--r--tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp12
-rw-r--r--tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp4
13 files changed, 367 insertions, 366 deletions
diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
index 1dfba368bc..83ccf20a6d 100644
--- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
+++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
@@ -1223,16 +1223,16 @@ void tst_QSettings::remove()
{
QSettings settings0(QSettings::UserScope, "software.org", "KillerAPP");
int initialNumKeys = settings0.allKeys().size();
- QCOMPARE(settings0.value("key 1", "123").toString(), QString("123"));
+ QCOMPARE(settings0.value("key 1", "123").toString(), QLatin1String("123"));
settings0.remove("key 1");
- QCOMPARE(settings0.value("key 1", "456").toString(), QString("456"));
+ QCOMPARE(settings0.value("key 1", "456").toString(), QLatin1String("456"));
settings0.setValue("key 1", "bubloo");
- QCOMPARE(settings0.value("key 1").toString(), QString("bubloo"));
+ QCOMPARE(settings0.value("key 1").toString(), QLatin1String("bubloo"));
settings0.remove("key 2");
- QCOMPARE(settings0.value("key 1").toString(), QString("bubloo"));
+ QCOMPARE(settings0.value("key 1").toString(), QLatin1String("bubloo"));
settings0.remove("key 1");
- QCOMPARE(settings0.value("key 1", "789").toString(), QString("789"));
+ QCOMPARE(settings0.value("key 1", "789").toString(), QLatin1String("789"));
/*
Make sure that removing a key removes all the subkeys.
diff --git a/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp b/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp
index 9a4e020aad..7df085df7c 100644
--- a/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp
+++ b/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp
@@ -746,18 +746,18 @@ void tst_QUrlQuery::old_queryItems()
url.removeAllQueryItems("1");
QVERIFY(!url.hasQueryItem("1"));
- QCOMPARE(url.queryItemValue("4").toLatin1().constData(), "a b");
- QCOMPARE(url.queryItemValue("5").toLatin1().constData(), "&");
- QCOMPARE(url.queryItemValue("tex").toLatin1().constData(), "a + b = c");
- QCOMPARE(url.queryItemValue("foo bar").toLatin1().constData(), "hello world");
+ QCOMPARE(url.queryItemValue("4"), QLatin1String("a b"));
+ QCOMPARE(url.queryItemValue("5"), QLatin1String("&"));
+ QCOMPARE(url.queryItemValue("tex"), QLatin1String("a + b = c"));
+ QCOMPARE(url.queryItemValue("foo bar"), QLatin1String("hello world"));
//url.setUrl("http://www.google.com/search?q=a+b");
url.setQuery("q=a+b");
- QCOMPARE(url.queryItemValue("q"), QString("a+b"));
+ QCOMPARE(url.queryItemValue("q"), QLatin1String("a+b"));
//url.setUrl("http://www.google.com/search?q=a=b"); // invalid, but should be tolerated
url.setQuery("q=a=b");
- QCOMPARE(url.queryItemValue("q"), QString("a=b"));
+ QCOMPARE(url.queryItemValue("q"), QLatin1String("a=b"));
}
void tst_QUrlQuery::old_hasQueryItem_data()
diff --git a/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp b/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp
index 2707b6df41..5e967207d4 100644
--- a/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp
+++ b/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp
@@ -107,7 +107,7 @@ void tst_QTranslator::load()
QTranslator tor( 0 );
tor.load("hellotr_la");
QVERIFY(!tor.isEmpty());
- QCOMPARE(tor.translate("QPushButton", "Hello world!"), QString::fromLatin1("Hallo Welt!"));
+ QCOMPARE(tor.translate("QPushButton", "Hello world!"), QLatin1String("Hallo Welt!"));
}
void tst_QTranslator::load2()
@@ -118,7 +118,7 @@ void tst_QTranslator::load2()
QByteArray data = file.readAll();
tor.load((const uchar *)data.constData(), data.length());
QVERIFY(!tor.isEmpty());
- QCOMPARE(tor.translate("QPushButton", "Hello world!"), QString::fromLatin1("Hallo Welt!"));
+ QCOMPARE(tor.translate("QPushButton", "Hello world!"), QLatin1String("Hallo Welt!"));
}
class TranslatorThread : public QThread
@@ -129,7 +129,7 @@ class TranslatorThread : public QThread
if (tor.isEmpty())
qFatal("Could not load translation");
- if (tor.translate("QPushButton", "Hello world!") != QString::fromLatin1("Hallo Welt!"))
+ if (tor.translate("QPushButton", "Hello world!") != QLatin1String("Hallo Welt!"))
qFatal("Test string was not translated correctlys");
}
};
@@ -212,9 +212,9 @@ void tst_QTranslator::plural()
tor.load("hellotr_la");
QVERIFY(!tor.isEmpty());
QCoreApplication::installTranslator(&tor);
- QCOMPARE(QCoreApplication::translate("QPushButton", "Hello %n world(s)!", 0, 0), QString::fromLatin1("Hallo 0 Welten!"));
- QCOMPARE(QCoreApplication::translate("QPushButton", "Hello %n world(s)!", 0, 1), QString::fromLatin1("Hallo 1 Welt!"));
- QCOMPARE(QCoreApplication::translate("QPushButton", "Hello %n world(s)!", 0, 2), QString::fromLatin1("Hallo 2 Welten!"));
+ QCOMPARE(QCoreApplication::translate("QPushButton", "Hello %n world(s)!", 0, 0), QLatin1String("Hallo 0 Welten!"));
+ QCOMPARE(QCoreApplication::translate("QPushButton", "Hello %n world(s)!", 0, 1), QLatin1String("Hallo 1 Welt!"));
+ QCOMPARE(QCoreApplication::translate("QPushButton", "Hello %n world(s)!", 0, 2), QLatin1String("Hallo 2 Welten!"));
}
void tst_QTranslator::translate_qm_file_generated_with_msgfmt()
@@ -240,7 +240,7 @@ void tst_QTranslator::loadFromResource()
QTranslator tor;
tor.load(":/tst_qtranslator/hellotr_la.qm");
QVERIFY(!tor.isEmpty());
- QCOMPARE(tor.translate("QPushButton", "Hello world!"), QString::fromLatin1("Hallo Welt!"));
+ QCOMPARE(tor.translate("QPushButton", "Hello world!"), QLatin1String("Hallo Welt!"));
}
void tst_QTranslator::loadDirectory()
@@ -260,16 +260,16 @@ void tst_QTranslator::dependencies()
QTranslator tor;
tor.load("dependencies_la");
QVERIFY(!tor.isEmpty());
- QCOMPARE(tor.translate("QPushButton", "Hello world!"), QString::fromLatin1("Hallo Welt!"));
+ QCOMPARE(tor.translate("QPushButton", "Hello world!"), QLatin1String("Hallo Welt!"));
// plural
QCoreApplication::installTranslator(&tor);
- QCOMPARE(QCoreApplication::translate("QPushButton", "Hello %n world(s)!", 0, 0), QString::fromLatin1("Hallo 0 Welten!"));
- QCOMPARE(QCoreApplication::translate("QPushButton", "Hello %n world(s)!", 0, 1), QString::fromLatin1("Hallo 1 Welt!"));
- QCOMPARE(QCoreApplication::translate("QPushButton", "Hello %n world(s)!", 0, 2), QString::fromLatin1("Hallo 2 Welten!"));
+ QCOMPARE(QCoreApplication::translate("QPushButton", "Hello %n world(s)!", 0, 0), QLatin1String("Hallo 0 Welten!"));
+ QCOMPARE(QCoreApplication::translate("QPushButton", "Hello %n world(s)!", 0, 1), QLatin1String("Hallo 1 Welt!"));
+ QCOMPARE(QCoreApplication::translate("QPushButton", "Hello %n world(s)!", 0, 2), QLatin1String("Hallo 2 Welten!"));
// pick up translation from the file with dependencies
- QCOMPARE(tor.translate("QPushButton", "It's a small world"), QString::fromLatin1("Es ist eine kleine Welt"));
+ QCOMPARE(tor.translate("QPushButton", "It's a small world"), QLatin1String("Es ist eine kleine Welt"));
}
{
@@ -279,7 +279,7 @@ void tst_QTranslator::dependencies()
QByteArray data = file.readAll();
tor.load((const uchar *)data.constData(), data.length());
QVERIFY(!tor.isEmpty());
- QCOMPARE(tor.translate("QPushButton", "Hello world!"), QString::fromLatin1("Hallo Welt!"));
+ QCOMPARE(tor.translate("QPushButton", "Hello world!"), QLatin1String("Hallo Welt!"));
}
}
diff --git a/tests/auto/corelib/tools/collections/tst_collections.cpp b/tests/auto/corelib/tools/collections/tst_collections.cpp
index 4d1dc35817..22a282457b 100644
--- a/tests/auto/corelib/tools/collections/tst_collections.cpp
+++ b/tests/auto/corelib/tools/collections/tst_collections.cpp
@@ -517,11 +517,11 @@ void tst_Collections::list()
QList<QString> list = vector.toList();
QVERIFY(list.size() == 5);
- QVERIFY(list.at(0) == "99");
- QVERIFY(list.at(4) == "100");
+ QCOMPARE(list.at(0), QLatin1String("99"));
+ QCOMPARE(list.at(4), QLatin1String("100"));
list[0] = "10";
- QVERIFY(list.at(0) == "10");
- QVERIFY(vector.at(0) == "99");
+ QCOMPARE(list.at(0), QLatin1String("10"));
+ QCOMPARE(vector.at(0), QLatin1String("99"));
}
@@ -533,15 +533,15 @@ void tst_Collections::list()
QVERIFY((*it)[0] == QChar('H'));
QVERIFY(it->constData()[0] == QChar('H'));
it->replace(QChar('H'), QChar('X'));
- QVERIFY(list.first() == "Xello");
+ QCOMPARE(list.first(), QLatin1String("Xello"));
QList<QString>::const_iterator cit = list.constBegin();
- QVERIFY((*cit).toLower() == "xello");
- QVERIFY(cit->toUpper() == "XELLO");
+ QCOMPARE((*cit).toLower(), QLatin1String("xello"));
+ QCOMPARE(cit->toUpper(), QLatin1String("XELLO"));
cit = list.cbegin();
- QVERIFY((*cit).toLower() == "xello");
- QVERIFY(cit->toUpper() == "XELLO");
+ QCOMPARE((*cit).toLower(),QLatin1String("xello"));
+ QCOMPARE(cit->toUpper(), QLatin1String("XELLO"));
}
{
@@ -575,10 +575,10 @@ void tst_Collections::list()
list << "alpha" << "beta";
list += list;
QVERIFY(list.size() == 4);
- QVERIFY(list.at(0) == "alpha");
- QVERIFY(list.at(1) == "beta");
- QVERIFY(list.at(2) == "alpha");
- QVERIFY(list.at(3) == "beta");
+ QCOMPARE(list.at(0), QLatin1String("alpha"));
+ QCOMPARE(list.at(1), QLatin1String("beta"));
+ QCOMPARE(list.at(2), QLatin1String("alpha"));
+ QCOMPARE(list.at(3), QLatin1String("beta"));
}
// test endcases for inserting into a qlist
@@ -954,15 +954,15 @@ void tst_Collections::linkedList()
QVERIFY((*it)[0] == QChar('H'));
QVERIFY(it->constData()[0] == QChar('H'));
it->replace(QChar('H'), QChar('X'));
- QVERIFY(list.first() == "Xello");
+ QCOMPARE(list.first(), QLatin1String("Xello"));
QLinkedList<QString>::const_iterator cit = list.constBegin();
- QVERIFY((*cit).toLower() == "xello");
- QVERIFY(cit->toUpper() == "XELLO");
+ QCOMPARE((*cit).toLower(), QLatin1String("xello"));
+ QCOMPARE(cit->toUpper(), QLatin1String("XELLO"));
cit = list.cbegin();
- QVERIFY((*cit).toLower() == "xello");
- QVERIFY(cit->toUpper() == "XELLO");
+ QCOMPARE((*cit).toLower(), QLatin1String("xello"));
+ QCOMPARE(cit->toUpper(), QLatin1String("XELLO"));
}
{
@@ -970,10 +970,10 @@ void tst_Collections::linkedList()
list << "alpha" << "beta";
list += list;
QVERIFY(list.size() == 4);
- QVERIFY(*list.begin() == "alpha");
- QVERIFY(*(list.begin() + 1) == "beta");
- QVERIFY(*(list.begin() + 2) == "alpha");
- QVERIFY(*(list.begin() + 3) == "beta");
+ QCOMPARE(*list.begin(), QLatin1String("alpha"));
+ QCOMPARE(*(list.begin() + 1), QLatin1String("beta"));
+ QCOMPARE(*(list.begin() + 2), QLatin1String("alpha"));
+ QCOMPARE(*(list.begin() + 3), QLatin1String("beta"));
}
{
@@ -1054,8 +1054,8 @@ void tst_Collections::vector()
QVector<QString> vec;
vec << "foo" << "bar";
vec.reserve( 512 );
- QVERIFY(vec[0] == "foo");
- QVERIFY(vec[1] == "bar");
+ QCOMPARE(vec[0], QLatin1String("foo"));
+ QCOMPARE(vec[1], QLatin1String("bar"));
int initialLargeStaticCount = LargeStatic::count;
{
@@ -1070,10 +1070,10 @@ void tst_Collections::vector()
vector << "alpha" << "beta";
vector += vector;
QVERIFY(vector.size() == 4);
- QVERIFY(vector.at(0) == "alpha");
- QVERIFY(vector.at(1) == "beta");
- QVERIFY(vector.at(2) == "alpha");
- QVERIFY(vector.at(3) == "beta");
+ QCOMPARE(vector.at(0), QLatin1String("alpha"));
+ QCOMPARE(vector.at(1), QLatin1String("beta"));
+ QCOMPARE(vector.at(2), QLatin1String("alpha"));
+ QCOMPARE(vector.at(3), QLatin1String("beta"));
}
int originalLargeStaticCount = LargeStatic::count;
@@ -1594,15 +1594,15 @@ void tst_Collections::hash()
QVERIFY((*it)[0] == QChar('H'));
QVERIFY(it->constData()[0] == QChar('H'));
it->replace(QChar('H'), QChar('X'));
- QVERIFY(*hash.begin() == "Xello");
+ QCOMPARE(*hash.begin(), QLatin1String("Xello"));
QHash<int, QString>::const_iterator cit = hash.constBegin();
- QVERIFY((*cit).toLower() == "xello");
- QVERIFY(cit->toUpper() == "XELLO");
+ QCOMPARE((*cit).toLower(), QLatin1String("xello"));
+ QCOMPARE(cit->toUpper(), QLatin1String("XELLO"));
cit = hash.cbegin();
- QVERIFY((*cit).toLower() == "xello");
- QVERIFY(cit->toUpper() == "XELLO");
+ QCOMPARE((*cit).toLower(), QLatin1String("xello"));
+ QCOMPARE(cit->toUpper(), QLatin1String("XELLO"));
}
{
@@ -1915,15 +1915,15 @@ void tst_Collections::map()
QVERIFY((*it)[0] == QChar('H'));
QVERIFY(it->constData()[0] == QChar('H'));
it->replace(QChar('H'), QChar('X'));
- QVERIFY(*map.begin() == "Xello");
+ QCOMPARE(*map.begin(), QLatin1String("Xello"));
QMap<int, QString>::const_iterator cit = map.constBegin();
- QVERIFY((*cit).toLower() == "xello");
- QVERIFY(cit->toUpper() == "XELLO");
+ QCOMPARE((*cit).toLower(), QLatin1String("xello"));
+ QCOMPARE(cit->toUpper(), QLatin1String("XELLO"));
cit = map.cbegin();
- QVERIFY((*cit).toLower() == "xello");
- QVERIFY(cit->toUpper() == "XELLO");
+ QCOMPARE((*cit).toLower(), QLatin1String("xello"));
+ QCOMPARE(cit->toUpper(), QLatin1String("XELLO"));
}
{
@@ -2005,17 +2005,17 @@ void tst_Collections::qstring()
QVERIFY(hello.left(0) == "");
QVERIFY(!hello.left(0).isNull());
- QVERIFY(hello.left(1) == "h");
- QVERIFY(hello.left(2) == "he");
- QVERIFY(hello.left(200) == "hello");
+ QCOMPARE(hello.left(1), QLatin1String("h"));
+ QCOMPARE(hello.left(2), QLatin1String("he"));
+ QCOMPARE(hello.left(200), QLatin1String("hello"));
QVERIFY(hello.left(hello.size()) == hello);
QVERIFY(hello.left(hello.size()+1) == hello);
QVERIFY(hello.right(0) == "");
QVERIFY(!hello.right(0).isNull());
- QVERIFY(hello.right(1) == "o");
- QVERIFY(hello.right(2) == "lo");
- QVERIFY(hello.right(200) == "hello");
+ QCOMPARE(hello.right(1), QLatin1String("o"));
+ QCOMPARE(hello.right(2), QLatin1String("lo"));
+ QCOMPARE(hello.right(200), QLatin1String("hello"));
QVERIFY(hello.right(hello.size()) == hello);
QVERIFY(hello.right(hello.size()+1) == hello);
@@ -2023,16 +2023,16 @@ void tst_Collections::qstring()
QVERIFY(hello.mid(0, 1) == "h");
QVERIFY(hello.mid(0, 2) == "he");
QVERIFY(hello.mid(0, 200) == "hello");
- QVERIFY(hello.mid(0) == "hello");
+ QCOMPARE(hello.mid(0), QLatin1String("hello"));
QVERIFY(hello.mid(0, hello.size()) == hello);
QVERIFY(hello.mid(0, hello.size()+1) == hello);
QVERIFY(hello.mid(hello.size()-0) == "");
QVERIFY(hello.mid(hello.size()-0).isEmpty());
QVERIFY(!hello.mid(hello.size()-0).isNull());
- QVERIFY(hello.mid(hello.size()-1) == "o");
- QVERIFY(hello.mid(hello.size()-2) == "lo");
- QVERIFY(hello.mid(hello.size()-200) == "hello");
+ QCOMPARE(hello.mid(hello.size()-1), QLatin1String("o"));
+ QCOMPARE(hello.mid(hello.size()-2), QLatin1String("lo"));
+ QCOMPARE(hello.mid(hello.size()-200), QLatin1String("hello"));
QString null;
QString nonNull = "";
@@ -2048,7 +2048,7 @@ void tst_Collections::qstring()
QString fill = "123";
fill.fill('a');
- QVERIFY(fill == "aaa");
+ QCOMPARE(fill, QLatin1String("aaa"));
s.clear();
s = hello;
@@ -2060,15 +2060,15 @@ void tst_Collections::qstring()
QVERIFY(s == helloWorld);
s = "012345";
s.insert(3, 'E');
- QVERIFY(s == "012E345");
+ QCOMPARE(s, QLatin1String("012E345"));
s.insert(3, "INSID");
- QVERIFY(s == "012INSIDE345");
+ QCOMPARE(s, QLatin1String("012INSIDE345"));
s = "short";
s.insert(7, 'E');
- QVERIFY(s == "short E");
+ QCOMPARE(s, QLatin1String("short E"));
s = "short";
s.insert(7, "END");
- QVERIFY(s == "short END");
+ QCOMPARE(s, QLatin1String("short END"));
QVERIFY(QString::fromLatin1("hello") == "hello");
@@ -2125,25 +2125,25 @@ void tst_Collections::qstring()
s += QChar((uchar) 0xb0);
QVERIFY(s.toUtf8() != s.toLatin1());
QCOMPARE(s[s.length()-1].unicode(), (ushort)0xb0);
- QVERIFY(s.left(s.length()-1) == "ascii");
+ QCOMPARE(s.left(s.length()-1), QLatin1String("ascii"));
QVERIFY(s == QString::fromUtf8(s.toUtf8().constData()));
s = "12";
s.append('3');
s += '4';
- QVERIFY(s == "1234");
+ QCOMPARE(s, QLatin1String("1234"));
s = "repend";
s.prepend('p');
- QVERIFY(s == "prepend");
+ QCOMPARE(s, QLatin1String("prepend"));
s.prepend("abc ");
- QVERIFY(s == "abc prepend");
+ QCOMPARE(s, QLatin1String("abc prepend"));
s = " whitespace ";
- QVERIFY(s.trimmed() == "whitespace");
+ QCOMPARE(s.trimmed(), QLatin1String("whitespace"));
s = " lots of stuff ";
- QVERIFY(s.simplified() == "lots of stuff");
+ QCOMPARE(s.simplified(), QLatin1String("lots of stuff"));
s = "a hat, a stick, a ski";
QVERIFY(s[2] == 'h');
@@ -2152,17 +2152,17 @@ void tst_Collections::qstring()
s = "12223";
s.remove(1, 2);
- QVERIFY(s == "123");
+ QCOMPARE(s, QLatin1String("123"));
s = "(%1)(%2)";
s = s.arg("foo").arg(7);
- QVERIFY(s == "(foo)(7)");
+ QCOMPARE(s, QLatin1String("(foo)(7)"));
s = "stl rocks";
std::string stl_string = s.toStdString(); // TODO: std::string stl_string = s does not work.
- QVERIFY(s == "stl rocks");
+ QCOMPARE(s, QLatin1String("stl rocks"));
s = QString::fromStdString(stl_string); // TODO: s = stl_string does not work.
- QVERIFY(s == "stl rocks");
+ QCOMPARE(s, QLatin1String("stl rocks"));
{
QString str("Bananas");
@@ -2178,10 +2178,10 @@ void tst_Collections::qstring()
QString str = "Hello";
QString cstr = QString::fromRawData(str.unicode(), str.length());
- QVERIFY(str == "Hello");
- QVERIFY(cstr == "Hello");
+ QCOMPARE(str, QLatin1String("Hello"));
+ QCOMPARE(cstr, QLatin1String("Hello"));
cstr.clear();
- QVERIFY(str == "Hello");
+ QCOMPARE(str, QLatin1String("Hello"));
QVERIFY(cstr.isEmpty());
{
@@ -2328,7 +2328,7 @@ void tst_Collections::pair()
QPair<int, QString> a(1, "Zebra"), b(2, "Ying"), c(3, "Yang"), d(3, "Ying"), e(5, "Alabama");
QVERIFY(a.first == 1);
- QVERIFY(a.second == "Zebra");
+ QCOMPARE(a.second, QLatin1String("Zebra"));
QVERIFY(a == qMakePair(1, QString("Zebra")));
QVERIFY(a == a && b == b && c == c && d == d && e == e);
diff --git a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp
index 99e5c4c85d..105b8b45d8 100755
--- a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp
+++ b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp
@@ -312,24 +312,24 @@ void tst_QAlgorithms::swap()
{
QString a = "1", b = "2";
qSwap(a, b);
- QVERIFY(a == "2");
- QVERIFY(b == "1");
+ QCOMPARE(a, QLatin1String("2"));
+ QCOMPARE(b, QLatin1String("1"));
qSwap(a, a);
- QVERIFY(a == "2");
- QVERIFY(b == "1");
+ QCOMPARE(a, QLatin1String("2"));
+ QCOMPARE(b, QLatin1String("1"));
qSwap(b, b);
- QVERIFY(a == "2");
- QVERIFY(b == "1");
+ QCOMPARE(a, QLatin1String("2"));
+ QCOMPARE(b, QLatin1String("1"));
qSwap(a, b);
- QVERIFY(a == "1");
- QVERIFY(b == "2");
+ QCOMPARE(a, QLatin1String("1"));
+ QCOMPARE(b, QLatin1String("2"));
qSwap(b, a);
- QVERIFY(a == "2");
- QVERIFY(b == "1");
+ QCOMPARE(a, QLatin1String("2"));
+ QCOMPARE(b, QLatin1String("1"));
}
{
diff --git a/tests/auto/corelib/tools/qhash/tst_qhash.cpp b/tests/auto/corelib/tools/qhash/tst_qhash.cpp
index 6a5c6b5670..340453fb3e 100644
--- a/tests/auto/corelib/tools/qhash/tst_qhash.cpp
+++ b/tests/auto/corelib/tools/qhash/tst_qhash.cpp
@@ -510,24 +510,24 @@ void tst_QHash::key()
QCOMPARE(hash1.key(1, def), def);
hash1.insert("one", 1);
- QCOMPARE(hash1.key(1), QString("one"));
- QCOMPARE(hash1.key(1, def), QString("one"));
+ QCOMPARE(hash1.key(1), QLatin1String("one"));
+ QCOMPARE(hash1.key(1, def), QLatin1String("one"));
QCOMPARE(hash1.key(2), QString());
QCOMPARE(hash1.key(2, def), def);
hash1.insert("two", 2);
- QCOMPARE(hash1.key(1), QString("one"));
- QCOMPARE(hash1.key(1, def), QString("one"));
- QCOMPARE(hash1.key(2), QString("two"));
- QCOMPARE(hash1.key(2, def), QString("two"));
+ QCOMPARE(hash1.key(1), QLatin1String("one"));
+ QCOMPARE(hash1.key(1, def), QLatin1String("one"));
+ QCOMPARE(hash1.key(2), QLatin1String("two"));
+ QCOMPARE(hash1.key(2, def), QLatin1String("two"));
QCOMPARE(hash1.key(3), QString());
QCOMPARE(hash1.key(3, def), def);
hash1.insert("deux", 2);
- QCOMPARE(hash1.key(1), QString("one"));
- QCOMPARE(hash1.key(1, def), QString("one"));
- QVERIFY(hash1.key(2) == "deux" || hash1.key(2) == "two");
- QVERIFY(hash1.key(2, def) == "deux" || hash1.key(2, def) == "two");
+ QCOMPARE(hash1.key(1), QLatin1String("one"));
+ QCOMPARE(hash1.key(1, def), QLatin1String("one"));
+ QVERIFY(hash1.key(2) == QLatin1String("deux") || hash1.key(2) == QLatin1String("two"));
+ QVERIFY(hash1.key(2, def) == QLatin1String("deux") || hash1.key(2, def) == QLatin1String("two"));
QCOMPARE(hash1.key(3), QString());
QCOMPARE(hash1.key(3, def), def);
}
@@ -628,8 +628,8 @@ void tst_QHash::find()
map1.insert(1,"Mayer");
map1.insert(2,"Hej");
- QVERIFY(map1.find(1).value() == "Mayer");
- QVERIFY(map1.find(2).value() == "Hej");
+ QCOMPARE(map1.find(1).value(), QLatin1String("Mayer"));
+ QCOMPARE(map1.find(2).value(), QLatin1String("Hej"));
for(i = 3; i < 10; ++i) {
compareString = testString.arg(i);
@@ -661,8 +661,8 @@ void tst_QHash::constFind()
map1.insert(1,"Mayer");
map1.insert(2,"Hej");
- QVERIFY(map1.constFind(1).value() == "Mayer");
- QVERIFY(map1.constFind(2).value() == "Hej");
+ QCOMPARE(map1.constFind(1).value(), QLatin1String("Mayer"));
+ QCOMPARE(map1.constFind(2).value(), QLatin1String("Hej"));
for(i = 3; i < 10; ++i) {
compareString = testString.arg(i);
@@ -706,7 +706,7 @@ void tst_QHash::take()
map.insert(2, "zwei");
map.insert(3, "drei");
- QVERIFY(map.take(3) == "drei");
+ QCOMPARE(map.take(3), QLatin1String("drei"));
QVERIFY(!map.contains(3));
}
diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
index 913f770ee1..6c4fc5e62b 100644
--- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
+++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
@@ -1277,13 +1277,13 @@ void tst_QLocale::formatTimeZone()
QLocale enUS("en_US");
QDateTime dt1(QDate(2013, 1, 1), QTime(1, 0, 0), Qt::OffsetFromUTC, 60 * 60);
- QCOMPARE(enUS.toString(dt1, "t"), QString("UTC+01:00"));
+ QCOMPARE(enUS.toString(dt1, "t"), QLatin1String("UTC+01:00"));
QDateTime dt2(QDate(2013, 1, 1), QTime(1, 0, 0), Qt::OffsetFromUTC, -60 * 60);
- QCOMPARE(enUS.toString(dt2, "t"), QString("UTC-01:00"));
+ QCOMPARE(enUS.toString(dt2, "t"), QLatin1String("UTC-01:00"));
QDateTime dt3(QDate(2013, 1, 1), QTime(0, 0, 0), Qt::UTC);
- QCOMPARE(enUS.toString(dt3, "t"), QString("UTC"));
+ QCOMPARE(enUS.toString(dt3, "t"), QLatin1String("UTC"));
// LocalTime should vary
if (europeanTimeZone) {
@@ -1292,14 +1292,14 @@ void tst_QLocale::formatTimeZone()
#ifdef Q_OS_WIN
QEXPECT_FAIL("", "Windows only returns long name (QTBUG-32759)", Continue);
#endif // Q_OS_WIN
- QCOMPARE(enUS.toString(dt4, "t"), QString("CET"));
+ QCOMPARE(enUS.toString(dt4, "t"), QLatin1String("CET"));
// Time definitely in Daylight Time
QDateTime dt5(QDate(2013, 6, 1), QTime(0, 0, 0), Qt::LocalTime);
#ifdef Q_OS_WIN
QEXPECT_FAIL("", "Windows only returns long name (QTBUG-32759)", Continue);
#endif // Q_OS_WIN
- QCOMPARE(enUS.toString(dt5, "t"), QString("CEST"));
+ QCOMPARE(enUS.toString(dt5, "t"), QLatin1String("CEST"));
} else {
QSKIP("You must test using Central European (CET/CEST) time zone, e.g. TZ=Europe/Oslo");
}
@@ -1308,13 +1308,13 @@ void tst_QLocale::formatTimeZone()
#ifdef Q_OS_WIN
QEXPECT_FAIL("", "QTimeZone windows backend only returns long name", Continue);
#endif
- QCOMPARE(enUS.toString(dt6, "t"), QString("CET"));
+ QCOMPARE(enUS.toString(dt6, "t"), QLatin1String("CET"));
QDateTime dt7(QDate(2013, 6, 1), QTime(0, 0, 0), QTimeZone("Europe/Berlin"));
#ifdef Q_OS_WIN
QEXPECT_FAIL("", "QTimeZone windows backend only returns long name", Continue);
#endif
- QCOMPARE(enUS.toString(dt7, "t"), QString("CEST"));
+ QCOMPARE(enUS.toString(dt7, "t"), QLatin1String("CEST"));
// Current datetime should return current abbreviation
QCOMPARE(enUS.toString(QDateTime::currentDateTime(), "t"),
diff --git a/tests/auto/corelib/tools/qmap/tst_qmap.cpp b/tests/auto/corelib/tools/qmap/tst_qmap.cpp
index bb6535b635..7cd7d7980f 100644
--- a/tests/auto/corelib/tools/qmap/tst_qmap.cpp
+++ b/tests/auto/corelib/tools/qmap/tst_qmap.cpp
@@ -413,24 +413,24 @@ void tst_QMap::key()
QCOMPARE(map1.key(1, def), def);
map1.insert("one", 1);
- QCOMPARE(map1.key(1), QString("one"));
- QCOMPARE(map1.key(1, def), QString("one"));
+ QCOMPARE(map1.key(1), QLatin1String("one"));
+ QCOMPARE(map1.key(1, def), QLatin1String("one"));
QCOMPARE(map1.key(2), QString());
QCOMPARE(map1.key(2, def), def);
map1.insert("two", 2);
- QCOMPARE(map1.key(1), QString("one"));
- QCOMPARE(map1.key(1, def), QString("one"));
- QCOMPARE(map1.key(2), QString("two"));
- QCOMPARE(map1.key(2, def), QString("two"));
+ QCOMPARE(map1.key(1), QLatin1String("one"));
+ QCOMPARE(map1.key(1, def), QLatin1String("one"));
+ QCOMPARE(map1.key(2), QLatin1String("two"));
+ QCOMPARE(map1.key(2, def), QLatin1String("two"));
QCOMPARE(map1.key(3), QString());
QCOMPARE(map1.key(3, def), def);
map1.insert("deux", 2);
- QCOMPARE(map1.key(1), QString("one"));
- QCOMPARE(map1.key(1, def), QString("one"));
- QVERIFY(map1.key(2) == "deux" || map1.key(2) == "two");
- QVERIFY(map1.key(2, def) == "deux" || map1.key(2, def) == "two");
+ QCOMPARE(map1.key(1), QLatin1String("one"));
+ QCOMPARE(map1.key(1, def), QLatin1String("one"));
+ QVERIFY(map1.key(2) == QLatin1String("deux") || map1.key(2) == QLatin1String("two"));
+ QVERIFY(map1.key(2, def) == QLatin1String("deux") || map1.key(2, def) == QLatin1String("two"));
QCOMPARE(map1.key(3), QString());
QCOMPARE(map1.key(3, def), def);
}
@@ -608,8 +608,8 @@ void tst_QMap::find()
map1.insert(1,"Mayer");
map1.insert(2,"Hej");
- QVERIFY(map1.find(1).value() == "Mayer");
- QVERIFY(map1.find(2).value() == "Hej");
+ QCOMPARE(map1.find(1).value(), QLatin1String("Mayer"));
+ QCOMPARE(map1.find(2).value(), QLatin1String("Hej"));
for(i = 3; i < 10; ++i) {
compareString = testString.arg(i);
@@ -643,8 +643,8 @@ void tst_QMap::constFind()
QVERIFY(map1.constFind(4) == map1.constEnd());
- QVERIFY(map1.constFind(1).value() == "Mayer");
- QVERIFY(map1.constFind(2).value() == "Hej");
+ QCOMPARE(map1.constFind(1).value(), QLatin1String("Mayer"));
+ QCOMPARE(map1.constFind(2).value(), QLatin1String("Hej"));
for(i = 3; i < 10; ++i) {
compareString = testString.arg(i);
@@ -705,10 +705,10 @@ void tst_QMap::lowerUpperBound()
QCOMPARE(map1.lowerBound(5).key(), 5);
QCOMPARE(map1.lowerBound(6).key(), 7);
QCOMPARE(map1.lowerBound(7).key(), 7);
- QCOMPARE(map1.lowerBound(6).value(), QString("seven_2"));
- QCOMPARE(map1.lowerBound(7).value(), QString("seven_2"));
- QCOMPARE((++map1.lowerBound(6)).value(), QString("seven"));
- QCOMPARE((++map1.lowerBound(7)).value(), QString("seven"));
+ QCOMPARE(map1.lowerBound(6).value(), QLatin1String("seven_2"));
+ QCOMPARE(map1.lowerBound(7).value(), QLatin1String("seven_2"));
+ QCOMPARE((++map1.lowerBound(6)).value(), QLatin1String("seven"));
+ QCOMPARE((++map1.lowerBound(7)).value(), QLatin1String("seven"));
QCOMPARE(map1.lowerBound(10).key(), 10);
QVERIFY(map1.lowerBound(999) == map1.end());
}
@@ -733,11 +733,11 @@ void tst_QMap::mergeCompare()
map1b.unite(map2b);
sanityCheckTree(map1b, __LINE__);
- QVERIFY(map1.value(1) == "ett");
- QVERIFY(map1.value(2) == "tvo");
- QVERIFY(map1.value(3) == "tre");
- QVERIFY(map1.value(4) == "fyra");
- QVERIFY(map1.value(5) == "fem");
+ QCOMPARE(map1.value(1), QLatin1String("ett"));
+ QCOMPARE(map1.value(2), QLatin1String("tvo"));
+ QCOMPARE(map1.value(3), QLatin1String("tre"));
+ QCOMPARE(map1.value(4), QLatin1String("fyra"));
+ QCOMPARE(map1.value(5), QLatin1String("fem"));
map3.insert(1, "ett");
map3.insert(2, "tvo");
@@ -755,7 +755,7 @@ void tst_QMap::take()
map.insert(2, "zwei");
map.insert(3, "drei");
- QVERIFY(map.take(3) == "drei");
+ QCOMPARE(map.take(3), QLatin1String("drei"));
QVERIFY(!map.contains(3));
}
@@ -771,19 +771,19 @@ void tst_QMap::iterators()
//STL-Style iterators
QMap<int, QString>::iterator stlIt = map.begin();
- QVERIFY(stlIt.value() == "Teststring 1");
+ QCOMPARE(stlIt.value(), QLatin1String("Teststring 1"));
stlIt+=5;
- QVERIFY(stlIt.value() == "Teststring 6");
+ QCOMPARE(stlIt.value(), QLatin1String("Teststring 6"));
stlIt++;
- QVERIFY(stlIt.value() == "Teststring 7");
+ QCOMPARE(stlIt.value(), QLatin1String("Teststring 7"));
stlIt-=3;
- QVERIFY(stlIt.value() == "Teststring 4");
+ QCOMPARE(stlIt.value(), QLatin1String("Teststring 4"));
stlIt--;
- QVERIFY(stlIt.value() == "Teststring 3");
+ QCOMPARE(stlIt.value(), QLatin1String("Teststring 3"));
for(stlIt = map.begin(), i = 1; stlIt != map.end(); ++stlIt, ++i)
QVERIFY(stlIt.value() == testString.arg(i));
@@ -792,19 +792,19 @@ void tst_QMap::iterators()
//STL-Style const-iterators
QMap<int, QString>::const_iterator cstlIt = map.constBegin();
- QVERIFY(cstlIt.value() == "Teststring 1");
+ QCOMPARE(cstlIt.value(), QLatin1String("Teststring 1"));
cstlIt+=5;
- QVERIFY(cstlIt.value() == "Teststring 6");
+ QCOMPARE(cstlIt.value(), QLatin1String("Teststring 6"));
cstlIt++;
- QVERIFY(cstlIt.value() == "Teststring 7");
+ QCOMPARE(cstlIt.value(), QLatin1String("Teststring 7"));
cstlIt-=3;
- QVERIFY(cstlIt.value() == "Teststring 4");
+ QCOMPARE(cstlIt.value(), QLatin1String("Teststring 4"));
cstlIt--;
- QVERIFY(cstlIt.value() == "Teststring 3");
+ QCOMPARE(cstlIt.value(), QLatin1String("Teststring 3"));
for(cstlIt = map.constBegin(), i = 1; cstlIt != map.constEnd(); ++cstlIt, ++i)
QVERIFY(cstlIt.value() == testString.arg(i));
diff --git a/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp b/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp
index b9a3fc13c5..23259e520f 100644
--- a/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp
+++ b/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp
@@ -880,19 +880,19 @@ void tst_QRegExp::caretAnchoredOptimization()
{
QString s = "---babnana----";
s.replace( QRegExp("^-*|(-*)$"), "" );
- QVERIFY(s == "babnana");
+ QCOMPARE(s, QLatin1String("babnana"));
s = "---babnana----";
s.replace( QRegExp("^-*|(-{0,})$"), "" );
- QVERIFY(s == "babnana");
+ QCOMPARE(s, QLatin1String("babnana"));
s = "---babnana----";
s.replace( QRegExp("^-*|(-{1,})$"), "" );
- QVERIFY(s == "babnana");
+ QCOMPARE(s, QLatin1String("babnana"));
s = "---babnana----";
s.replace( QRegExp("^-*|(-+)$"), "" );
- QVERIFY(s == "babnana");
+ QCOMPARE(s, QLatin1String("babnana"));
}
void tst_QRegExp::isEmpty()
diff --git a/tests/auto/corelib/tools/qset/tst_qset.cpp b/tests/auto/corelib/tools/qset/tst_qset.cpp
index 134d257d64..ed9c269b00 100644
--- a/tests/auto/corelib/tools/qset/tst_qset.cpp
+++ b/tests/auto/corelib/tools/qset/tst_qset.cpp
@@ -737,7 +737,7 @@ void tst_QSet::stlMutableIterator()
QSet<QString>::const_iterator k = set2.insert("foo");
i = reinterpret_cast<QSet<QString>::iterator &>(k);
// #endif
- QVERIFY(*i == "foo");
+ QCOMPARE(*i, QLatin1String("foo"));
}
}
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
index 3ca2b76ecd..bc55d53a60 100644
--- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
@@ -969,61 +969,61 @@ void tst_QString::acc_01()
QString f;
f = e;
f[7]='F';
- QCOMPARE(e,(QString)"String E");
+ QCOMPARE(e, QLatin1String("String E"));
char text[]="String f";
f = text;
text[7]='!';
- QCOMPARE(f,(QString)"String f");
+ QCOMPARE(f, QLatin1String("String f"));
f[7]='F';
QCOMPARE(text[7],'!');
a="";
a[0]='A';
- QCOMPARE(a,(QString)"A");
+ QCOMPARE(a, QLatin1String("A"));
QCOMPARE(a.length(),1);
a[1]='B';
- QCOMPARE(a,(QString)"AB");
+ QCOMPARE(a, QLatin1String("AB"));
QCOMPARE(a.length(),2);
a[2]='C';
- QCOMPARE(a,(QString)"ABC");
+ QCOMPARE(a, QLatin1String("ABC"));
QCOMPARE(a.length(),3);
a = QString();
QVERIFY(a.isNull());
a[0]='A';
- QCOMPARE(a,(QString)"A");
+ QCOMPARE(a, QLatin1String("A"));
QCOMPARE(a.length(),1);
a[1]='B';
- QCOMPARE(a,(QString)"AB");
+ QCOMPARE(a, QLatin1String("AB"));
QCOMPARE(a.length(),2);
a[2]='C';
- QCOMPARE(a,(QString)"ABC");
+ QCOMPARE(a, QLatin1String("ABC"));
QCOMPARE(a.length(),3);
a="123";
b="456";
a[0]=a[1];
- QCOMPARE(a,(QString)"223");
+ QCOMPARE(a, QLatin1String("223"));
a[1]=b[1];
- QCOMPARE(b,(QString)"456");
- QCOMPARE(a,(QString)"253");
+ QCOMPARE(b, QLatin1String("456"));
+ QCOMPARE(a, QLatin1String("253"));
char t[]="TEXT";
a="A";
a=t;
- QCOMPARE(a,(QString)"TEXT");
+ QCOMPARE(a, QLatin1String("TEXT"));
QCOMPARE(a,(QString)t);
a[0]='X';
- QCOMPARE(a,(QString)"XEXT");
+ QCOMPARE(a, QLatin1String("XEXT"));
QCOMPARE(t[0],'T');
t[0]='Z';
- QCOMPARE(a,(QString)"XEXT");
+ QCOMPARE(a, QLatin1String("XEXT"));
a="ABC";
QCOMPARE(char(a.toLatin1()[1]),'B');
- QCOMPARE(strcmp(a.toLatin1(),((QString)"ABC").toLatin1()),0);
- QCOMPARE(a+="DEF",(QString)"ABCDEF");
- QCOMPARE(a+='G',(QString)"ABCDEFG");
- QCOMPARE(a+=((const char*)(0)),(QString)"ABCDEFG");
+ QCOMPARE(strcmp(a.toLatin1(), QByteArrayLiteral("ABC")), 0);
+ QCOMPARE(a+="DEF", QLatin1String("ABCDEF"));
+ QCOMPARE(a+='G', QLatin1String("ABCDEFG"));
+ QCOMPARE(a+=((const char*)(0)), QLatin1String("ABCDEFG"));
// non-member operators
@@ -1045,11 +1045,11 @@ void tst_QString::acc_01()
QVERIFY(a<=c);
QVERIFY(!(c<=a));
QVERIFY(!(d<=a));
- QCOMPARE(QString(a+b),(QString)"ABCABC");
- QCOMPARE(QString(a+"XXXX"),(QString)"ABCXXXX");
- QCOMPARE(QString(a+'X'),(QString)"ABCX");
- QCOMPARE(QString("XXXX"+a),(QString)"XXXXABC");
- QCOMPARE(QString('X'+a),(QString)"XABC");
+ QCOMPARE(QString(a+b), QLatin1String("ABCABC"));
+ QCOMPARE(QString(a+"XXXX"), QLatin1String("ABCXXXX"));
+ QCOMPARE(QString(a+'X'), QLatin1String("ABCX"));
+ QCOMPARE(QString("XXXX"+a), QLatin1String("XXXXABC"));
+ QCOMPARE(QString('X'+a), QLatin1String("XABC"));
a = (const char*)0;
QVERIFY(a.isNull());
QVERIFY(*a.toLatin1().constData() == '\0');
@@ -1115,7 +1115,7 @@ void tst_QString::constructor()
QVERIFY(a == (QString)"");
QCOMPARE(b,cb);
QCOMPARE(c,cc);
- QCOMPARE(d,(QString)"String D");
+ QCOMPARE(d, QLatin1String("String D"));
QString nullStr;
QVERIFY( nullStr.isNull() );
@@ -1204,11 +1204,11 @@ void tst_QString::truncate()
{
QString e("String E");
e.truncate(4);
- QCOMPARE(e,(QString)"Stri");
+ QCOMPARE(e, QLatin1String("Stri"));
e = "String E";
e.truncate(0);
- QCOMPARE(e,(QString)"");
+ QCOMPARE(e, QLatin1String(""));
QVERIFY(e.isEmpty());
QVERIFY(!e.isNull());
@@ -1218,25 +1218,25 @@ void tst_QString::fill()
{
QString e;
e.fill('e',1);
- QCOMPARE(e,(QString)"e");
+ QCOMPARE(e, QLatin1String("e"));
QString f;
f.fill('f',3);
- QCOMPARE(f,(QString)"fff");
+ QCOMPARE(f, QLatin1String("fff"));
f.fill('F');
- QCOMPARE(f,(QString)"FFF");
+ QCOMPARE(f, QLatin1String("FFF"));
}
void tst_QString::sprintf()
{
QString a;
a.sprintf("COMPARE");
- QCOMPARE(a,(QString)"COMPARE");
+ QCOMPARE(a, QLatin1String("COMPARE"));
a.sprintf("%%%d",1);
- QCOMPARE(a,(QString)"%1");
- QCOMPARE(a.sprintf("X%dY",2),(QString)"X2Y");
- QCOMPARE(a.sprintf("X%9iY", 50000 ),(QString)"X 50000Y");
- QCOMPARE(a.sprintf("X%-9sY","hello"),(QString)"Xhello Y");
- QCOMPARE(a.sprintf("X%-9iY", 50000 ),(QString)"X50000 Y");
+ QCOMPARE(a, QLatin1String("%1"));
+ QCOMPARE(a.sprintf("X%dY",2), QLatin1String("X2Y"));
+ QCOMPARE(a.sprintf("X%9iY", 50000 ), QLatin1String("X 50000Y"));
+ QCOMPARE(a.sprintf("X%-9sY","hello"), QLatin1String("Xhello Y"));
+ QCOMPARE(a.sprintf("X%-9iY", 50000 ), QLatin1String("X50000 Y"));
QCOMPARE(a.sprintf("%lf", 1.23), QString("1.230000"));
QCOMPARE(a.sprintf("%lf", 1.23456789), QString("1.234568"));
QCOMPARE(a.sprintf("%p", (void *)0xbfffd350), QString("0xbfffd350"));
@@ -1253,13 +1253,13 @@ void tst_QString::sprintf()
S1.sprintf("%f",d);
QCOMPARE(S1, QString("-514.256830"));
- QCOMPARE(a.sprintf("%.3s", "Hello" ),(QString)"Hel");
- QCOMPARE(a.sprintf("%10.3s", "Hello" ),(QString)" Hel");
- QCOMPARE(a.sprintf("%.10s", "Hello" ),(QString)"Hello");
- QCOMPARE(a.sprintf("%10.10s", "Hello" ),(QString)" Hello");
- QCOMPARE(a.sprintf("%-10.10s", "Hello" ),(QString)"Hello ");
- QCOMPARE(a.sprintf("%-10.3s", "Hello" ),(QString)"Hel ");
- QCOMPARE(a.sprintf("%-5.5s", "Hello" ),(QString)"Hello");
+ QCOMPARE(a.sprintf("%.3s", "Hello" ), QLatin1String("Hel"));
+ QCOMPARE(a.sprintf("%10.3s", "Hello" ), QLatin1String(" Hel"));
+ QCOMPARE(a.sprintf("%.10s", "Hello" ), QLatin1String("Hello"));
+ QCOMPARE(a.sprintf("%10.10s", "Hello" ), QLatin1String(" Hello"));
+ QCOMPARE(a.sprintf("%-10.10s", "Hello" ), QLatin1String("Hello "));
+ QCOMPARE(a.sprintf("%-10.3s", "Hello" ), QLatin1String("Hel "));
+ QCOMPARE(a.sprintf("%-5.5s", "Hello" ), QLatin1String("Hello"));
// Check utf8 conversion for %s
QCOMPARE(a.sprintf("%s", "\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205"), QString::fromLatin1("\366\344\374\326\304\334\370\346\345\330\306\305"));
@@ -1809,9 +1809,9 @@ void tst_QString::left()
{
QString a;
a="ABCDEFGHIEfGEFG"; // 15 chars
- QCOMPARE(a.left(3),(QString)"ABC");
+ QCOMPARE(a.left(3), QLatin1String("ABC"));
QVERIFY(!a.left(0).isNull());
- QCOMPARE(a.left(0),(QString)"");
+ QCOMPARE(a.left(0), QLatin1String(""));
QString n;
QVERIFY(n.left(3).isNull());
@@ -1827,10 +1827,10 @@ void tst_QString::leftRef()
{
QString a;
a="ABCDEFGHIEfGEFG"; // 15 chars
- QCOMPARE(a.leftRef(3).toString(),(QString)"ABC");
+ QCOMPARE(a.leftRef(3).toString(), QLatin1String("ABC"));
QVERIFY(a.leftRef(0).toString().isEmpty());
- QCOMPARE(a.leftRef(0).toString(),(QString)"");
+ QCOMPARE(a.leftRef(0).toString(), QLatin1String(""));
QString n;
QVERIFY(n.leftRef(3).toString().isEmpty());
@@ -1846,8 +1846,8 @@ void tst_QString::right()
{
QString a;
a="ABCDEFGHIEfGEFG"; // 15 chars
- QCOMPARE(a.right(3),(QString)"EFG");
- QCOMPARE(a.right(0),(QString)"");
+ QCOMPARE(a.right(3), QLatin1String("EFG"));
+ QCOMPARE(a.right(0), QLatin1String(""));
QString n;
QVERIFY(n.right(3).isNull());
@@ -1862,8 +1862,8 @@ void tst_QString::rightRef()
{
QString a;
a="ABCDEFGHIEfGEFG"; // 15 chars
- QCOMPARE(a.rightRef(3).toString(),(QString)"EFG");
- QCOMPARE(a.rightRef(0).toString(),(QString)"");
+ QCOMPARE(a.rightRef(3).toString(), QLatin1String("EFG"));
+ QCOMPARE(a.rightRef(0).toString(), QLatin1String(""));
QString n;
QVERIFY(n.rightRef(3).toString().isEmpty());
@@ -1879,8 +1879,8 @@ void tst_QString::mid()
QString a;
a="ABCDEFGHIEfGEFG"; // 15 chars
- QCOMPARE(a.mid(3,3),(QString)"DEF");
- QCOMPARE(a.mid(0,0),(QString)"");
+ QCOMPARE(a.mid(3,3), QLatin1String("DEF"));
+ QCOMPARE(a.mid(0,0), QLatin1String(""));
QVERIFY(!a.mid(15,0).isNull());
QVERIFY(a.mid(15,0).isEmpty());
QVERIFY(!a.mid(15,1).isNull());
@@ -1958,8 +1958,8 @@ void tst_QString::midRef()
QString a;
a="ABCDEFGHIEfGEFG"; // 15 chars
- QCOMPARE(a.midRef(3,3).toString(),(QString)"DEF");
- QCOMPARE(a.midRef(0,0).toString(),(QString)"");
+ QCOMPARE(a.midRef(3,3).toString(), QLatin1String("DEF"));
+ QCOMPARE(a.midRef(0,0).toString(), QLatin1String(""));
QVERIFY(!a.midRef(15,0).toString().isNull());
QVERIFY(a.midRef(15,0).toString().isEmpty());
QVERIFY(!a.midRef(15,1).toString().isNull());
@@ -2083,44 +2083,44 @@ void tst_QString::leftJustified()
{
QString a;
a="ABC";
- QCOMPARE(a.leftJustified(5,'-'),(QString)"ABC--");
- QCOMPARE(a.leftJustified(4,'-'),(QString)"ABC-");
- QCOMPARE(a.leftJustified(4),(QString)"ABC ");
- QCOMPARE(a.leftJustified(3),(QString)"ABC");
- QCOMPARE(a.leftJustified(2),(QString)"ABC");
- QCOMPARE(a.leftJustified(1),(QString)"ABC");
- QCOMPARE(a.leftJustified(0),(QString)"ABC");
+ QCOMPARE(a.leftJustified(5,'-'), QLatin1String("ABC--"));
+ QCOMPARE(a.leftJustified(4,'-'), QLatin1String("ABC-"));
+ QCOMPARE(a.leftJustified(4), QLatin1String("ABC "));
+ QCOMPARE(a.leftJustified(3), QLatin1String("ABC"));
+ QCOMPARE(a.leftJustified(2), QLatin1String("ABC"));
+ QCOMPARE(a.leftJustified(1), QLatin1String("ABC"));
+ QCOMPARE(a.leftJustified(0), QLatin1String("ABC"));
QString n;
QVERIFY(!n.leftJustified(3).isNull());
- QCOMPARE(a.leftJustified(4,' ',true),(QString)"ABC ");
- QCOMPARE(a.leftJustified(3,' ',true),(QString)"ABC");
- QCOMPARE(a.leftJustified(2,' ',true),(QString)"AB");
- QCOMPARE(a.leftJustified(1,' ',true),(QString)"A");
- QCOMPARE(a.leftJustified(0,' ',true),(QString)"");
+ QCOMPARE(a.leftJustified(4,' ',true), QLatin1String("ABC "));
+ QCOMPARE(a.leftJustified(3,' ',true), QLatin1String("ABC"));
+ QCOMPARE(a.leftJustified(2,' ',true), QLatin1String("AB"));
+ QCOMPARE(a.leftJustified(1,' ',true), QLatin1String("A"));
+ QCOMPARE(a.leftJustified(0,' ',true), QLatin1String(""));
}
void tst_QString::rightJustified()
{
QString a;
a="ABC";
- QCOMPARE(a.rightJustified(5,'-'),(QString)"--ABC");
- QCOMPARE(a.rightJustified(4,'-'),(QString)"-ABC");
- QCOMPARE(a.rightJustified(4),(QString)" ABC");
- QCOMPARE(a.rightJustified(3),(QString)"ABC");
- QCOMPARE(a.rightJustified(2),(QString)"ABC");
- QCOMPARE(a.rightJustified(1),(QString)"ABC");
- QCOMPARE(a.rightJustified(0),(QString)"ABC");
+ QCOMPARE(a.rightJustified(5,'-'), QLatin1String("--ABC"));
+ QCOMPARE(a.rightJustified(4,'-'), QLatin1String("-ABC"));
+ QCOMPARE(a.rightJustified(4), QLatin1String(" ABC"));
+ QCOMPARE(a.rightJustified(3), QLatin1String("ABC"));
+ QCOMPARE(a.rightJustified(2), QLatin1String("ABC"));
+ QCOMPARE(a.rightJustified(1), QLatin1String("ABC"));
+ QCOMPARE(a.rightJustified(0), QLatin1String("ABC"));
QString n;
QVERIFY(!n.rightJustified(3).isNull());
- QCOMPARE(a.rightJustified(4,'-',true),(QString)"-ABC");
- QCOMPARE(a.rightJustified(4,' ',true),(QString)" ABC");
- QCOMPARE(a.rightJustified(3,' ',true),(QString)"ABC");
- QCOMPARE(a.rightJustified(2,' ',true),(QString)"AB");
- QCOMPARE(a.rightJustified(1,' ',true),(QString)"A");
- QCOMPARE(a.rightJustified(0,' ',true),(QString)"");
- QCOMPARE(a,(QString)"ABC");
+ QCOMPARE(a.rightJustified(4,'-',true), QLatin1String("-ABC"));
+ QCOMPARE(a.rightJustified(4,' ',true), QLatin1String(" ABC"));
+ QCOMPARE(a.rightJustified(3,' ',true), QLatin1String("ABC"));
+ QCOMPARE(a.rightJustified(2,' ',true), QLatin1String("AB"));
+ QCOMPARE(a.rightJustified(1,' ',true), QLatin1String("A"));
+ QCOMPARE(a.rightJustified(0,' ',true), QLatin1String(""));
+ QCOMPARE(a, QLatin1String("ABC"));
}
void tst_QString::toUpper()
@@ -2302,21 +2302,21 @@ void tst_QString::trimmed()
{
QString a;
a="Text";
- QCOMPARE(a,(QString)"Text");
- QCOMPARE(a.trimmed(),(QString)"Text");
- QCOMPARE(a,(QString)"Text");
+ QCOMPARE(a, QLatin1String("Text"));
+ QCOMPARE(a.trimmed(), QLatin1String("Text"));
+ QCOMPARE(a, QLatin1String("Text"));
a=" ";
- QCOMPARE(a.trimmed(),(QString)"");
- QCOMPARE(a,(QString)" ");
+ QCOMPARE(a.trimmed(), QLatin1String(""));
+ QCOMPARE(a, QLatin1String(" "));
a=" a ";
- QCOMPARE(a.trimmed(),(QString)"a");
+ QCOMPARE(a.trimmed(), QLatin1String("a"));
a="Text";
- QCOMPARE(qMove(a).trimmed(),(QString)"Text");
+ QCOMPARE(qMove(a).trimmed(), QLatin1String("Text"));
a=" ";
- QCOMPARE(qMove(a).trimmed(),(QString)"");
+ QCOMPARE(qMove(a).trimmed(), QLatin1String(""));
a=" a ";
- QCOMPARE(qMove(a).trimmed(),(QString)"a");
+ QCOMPARE(qMove(a).trimmed(), QLatin1String("a"));
}
void tst_QString::simplified_data()
@@ -2442,12 +2442,13 @@ void tst_QString::insert_special_cases()
QCOMPARE(a.insert(1,'>'), QString("<>ABCABCABCABC"));
a = "Meal";
- QCOMPARE(a.insert(1, QLatin1String("ontr")), QString("Montreal"));
- QCOMPARE(a.insert(4, ""), QString("Montreal"));
- QCOMPARE(a.insert(3, QLatin1String("")), QString("Montreal"));
- QCOMPARE(a.insert(3, QLatin1String(0)), QString("Montreal"));
- QCOMPARE(a.insert(3, static_cast<const char *>(0)), QString("Montreal"));
- QCOMPARE(a.insert(0, QLatin1String("a")), QString("aMontreal"));
+ const QString montreal = QStringLiteral("Montreal");
+ QCOMPARE(a.insert(1, QLatin1String("ontr")), montreal);
+ QCOMPARE(a.insert(4, ""), montreal);
+ QCOMPARE(a.insert(3, QLatin1String("")), montreal);
+ QCOMPARE(a.insert(3, QLatin1String(0)), montreal);
+ QCOMPARE(a.insert(3, static_cast<const char *>(0)), montreal);
+ QCOMPARE(a.insert(0, QLatin1String("a")), QLatin1String("aMontreal"));
}
void tst_QString::append_data(bool emptyIsNoop)
@@ -3558,12 +3559,12 @@ void tst_QString::toDouble()
void tst_QString::setNum()
{
QString a;
- QCOMPARE(a.setNum(123),(QString)"123");
- QCOMPARE(a.setNum(-123),(QString)"-123");
- QCOMPARE(a.setNum(0x123,16),(QString)"123");
- QCOMPARE(a.setNum((short)123),(QString)"123");
- QCOMPARE(a.setNum(123L),(QString)"123");
- QCOMPARE(a.setNum(123UL),(QString)"123");
+ QCOMPARE(a.setNum(123), QLatin1String("123"));
+ QCOMPARE(a.setNum(-123), QLatin1String("-123"));
+ QCOMPARE(a.setNum(0x123,16), QLatin1String("123"));
+ QCOMPARE(a.setNum((short)123), QLatin1String("123"));
+ QCOMPARE(a.setNum(123L), QLatin1String("123"));
+ QCOMPARE(a.setNum(123UL), QLatin1String("123"));
QCOMPARE(a.setNum(2147483647L), QString("2147483647")); // 32 bit LONG_MAX
QCOMPARE(a.setNum(-2147483647L), QString("-2147483647")); // LONG_MIN + 1
QCOMPARE(a.setNum(-2147483647L-1L), QString("-2147483648")); // LONG_MIN
@@ -3820,7 +3821,7 @@ void tst_QString::check_QDataStream()
{
QDataStream in(&ar,QIODevice::ReadOnly);
in >> a;
- QCOMPARE(a,(QString)"COMPARE Text");
+ QCOMPARE(a, QLatin1String("COMPARE Text"));
}
}
@@ -3835,7 +3836,7 @@ void tst_QString::check_QTextStream()
{
QTextStream in(&ar,QIODevice::ReadOnly);
in >> a;
- QCOMPARE(a,(QString)"This");
+ QCOMPARE(a, QLatin1String("This"));
}
}
@@ -4528,100 +4529,100 @@ void tst_QString::arg()
QString s13( "%1% %x%c%2 %d%2-%" );
QString s14( "%1%2%3" );
- QCOMPARE( s4.arg("foo"), QString("[foo]") );
- QCOMPARE( s5.arg("foo"), QString("[foo]") );
- QCOMPARE( s6.arg("foo"), QString("[foo]") );
- QCOMPARE( s7.arg("foo"), QString("[foo]") );
- QCOMPARE( s8.arg("foo"), QString("[foo %1]") );
- QCOMPARE( s8.arg("foo").arg("bar"), QString("[foo bar]") );
- QCOMPARE( s8.arg("foo", "bar"), QString("[foo bar]") );
- QCOMPARE( s9.arg("foo"), QString("[foo %3]") );
- QCOMPARE( s9.arg("foo").arg("bar"), QString("[foo bar]") );
- QCOMPARE( s9.arg("foo", "bar"), QString("[foo bar]") );
- QCOMPARE( s10.arg("foo"), QString("[foo %2 %3]") );
- QCOMPARE( s10.arg("foo").arg("bar"), QString("[foo bar %3]") );
- QCOMPARE( s10.arg("foo", "bar"), QString("[foo bar %3]") );
- QCOMPARE( s10.arg("foo").arg("bar").arg("baz"), QString("[foo bar baz]") );
- QCOMPARE( s10.arg("foo", "bar", "baz"), QString("[foo bar baz]") );
- QCOMPARE( s11.arg("foo"), QString("[%9 %3 foo]") );
- QCOMPARE( s11.arg("foo").arg("bar"), QString("[%9 bar foo]") );
- QCOMPARE( s11.arg("foo", "bar"), QString("[%9 bar foo]") );
- QCOMPARE( s11.arg("foo").arg("bar").arg("baz"), QString("[baz bar foo]") );
- QCOMPARE( s11.arg("foo", "bar", "baz"), QString("[baz bar foo]") );
+ QCOMPARE( s4.arg("foo"), QLatin1String("[foo]") );
+ QCOMPARE( s5.arg("foo"), QLatin1String("[foo]") );
+ QCOMPARE( s6.arg("foo"), QLatin1String("[foo]") );
+ QCOMPARE( s7.arg("foo"), QLatin1String("[foo]") );
+ QCOMPARE( s8.arg("foo"), QLatin1String("[foo %1]") );
+ QCOMPARE( s8.arg("foo").arg("bar"), QLatin1String("[foo bar]") );
+ QCOMPARE( s8.arg("foo", "bar"), QLatin1String("[foo bar]") );
+ QCOMPARE( s9.arg("foo"), QLatin1String("[foo %3]") );
+ QCOMPARE( s9.arg("foo").arg("bar"), QLatin1String("[foo bar]") );
+ QCOMPARE( s9.arg("foo", "bar"), QLatin1String("[foo bar]") );
+ QCOMPARE( s10.arg("foo"), QLatin1String("[foo %2 %3]") );
+ QCOMPARE( s10.arg("foo").arg("bar"), QLatin1String("[foo bar %3]") );
+ QCOMPARE( s10.arg("foo", "bar"), QLatin1String("[foo bar %3]") );
+ QCOMPARE( s10.arg("foo").arg("bar").arg("baz"), QLatin1String("[foo bar baz]") );
+ QCOMPARE( s10.arg("foo", "bar", "baz"), QLatin1String("[foo bar baz]") );
+ QCOMPARE( s11.arg("foo"), QLatin1String("[%9 %3 foo]") );
+ QCOMPARE( s11.arg("foo").arg("bar"), QLatin1String("[%9 bar foo]") );
+ QCOMPARE( s11.arg("foo", "bar"), QLatin1String("[%9 bar foo]") );
+ QCOMPARE( s11.arg("foo").arg("bar").arg("baz"), QLatin1String("[baz bar foo]") );
+ QCOMPARE( s11.arg("foo", "bar", "baz"), QLatin1String("[baz bar foo]") );
QCOMPARE( s12.arg("a").arg("b").arg("c").arg("d").arg("e"),
- QString("[e b c e a d]") );
- QCOMPARE( s12.arg("a", "b", "c", "d").arg("e"), QString("[e b c e a d]") );
- QCOMPARE( s12.arg("a").arg("b", "c", "d", "e"), QString("[e b c e a d]") );
+ QLatin1String("[e b c e a d]") );
+ QCOMPARE( s12.arg("a", "b", "c", "d").arg("e"), QLatin1String("[e b c e a d]") );
+ QCOMPARE( s12.arg("a").arg("b", "c", "d", "e"), QLatin1String("[e b c e a d]") );
QCOMPARE( s13.arg("alpha").arg("beta"),
- QString("alpha% %x%cbeta %dbeta-%") );
- QCOMPARE( s13.arg("alpha", "beta"), QString("alpha% %x%cbeta %dbeta-%") );
- QCOMPARE( s14.arg("a", "b", "c"), QString("abc") );
- QCOMPARE( s8.arg("%1").arg("foo"), QString("[foo foo]") );
- QCOMPARE( s8.arg("%1", "foo"), QString("[%1 foo]") );
- QCOMPARE( s4.arg("foo", 2), QString("[foo]") );
- QCOMPARE( s4.arg("foo", -2), QString("[foo]") );
- QCOMPARE( s4.arg("foo", 10), QString("[ foo]") );
- QCOMPARE( s4.arg("foo", -10), QString("[foo ]") );
+ QLatin1String("alpha% %x%cbeta %dbeta-%") );
+ QCOMPARE( s13.arg("alpha", "beta"), QLatin1String("alpha% %x%cbeta %dbeta-%") );
+ QCOMPARE( s14.arg("a", "b", "c"), QLatin1String("abc") );
+ QCOMPARE( s8.arg("%1").arg("foo"), QLatin1String("[foo foo]") );
+ QCOMPARE( s8.arg("%1", "foo"), QLatin1String("[%1 foo]") );
+ QCOMPARE( s4.arg("foo", 2), QLatin1String("[foo]") );
+ QCOMPARE( s4.arg("foo", -2), QLatin1String("[foo]") );
+ QCOMPARE( s4.arg("foo", 10), QLatin1String("[ foo]") );
+ QCOMPARE( s4.arg("foo", -10), QLatin1String("[foo ]") );
QString firstName( "James" );
QString lastName( "Bond" );
QString fullName = QString( "My name is %2, %1 %2" )
.arg( firstName ).arg( lastName );
- QCOMPARE( fullName, QString("My name is Bond, James Bond") );
+ QCOMPARE( fullName, QLatin1String("My name is Bond, James Bond") );
// number overloads
- QCOMPARE( s4.arg(0), QString("[0]") );
- QCOMPARE( s4.arg(-1), QString("[-1]") );
- QCOMPARE( s4.arg(4294967295UL), QString("[4294967295]") ); // ULONG_MAX 32
+ QCOMPARE( s4.arg(0), QLatin1String("[0]") );
+ QCOMPARE( s4.arg(-1), QLatin1String("[-1]") );
+ QCOMPARE( s4.arg(4294967295UL), QLatin1String("[4294967295]") ); // ULONG_MAX 32
QCOMPARE( s4.arg(Q_INT64_C(9223372036854775807)), // LLONG_MAX
- QString("[9223372036854775807]") );
+ QLatin1String("[9223372036854775807]") );
QTest::ignoreMessage(QtWarningMsg, "QString::arg: Argument missing: \"\" , 0");
QCOMPARE( QString().arg(0), QString() );
QTest::ignoreMessage(QtWarningMsg, "QString::arg: Argument missing: \"\" , 0");
QCOMPARE( QString("").arg(0), QString("") );
QTest::ignoreMessage(QtWarningMsg, "QString::arg: Argument missing: \" \" , 0");
- QCOMPARE( QString(" ").arg(0), QString(" ") );
+ QCOMPARE( QString(" ").arg(0), QLatin1String(" ") );
QTest::ignoreMessage(QtWarningMsg, "QString::arg: Argument missing: \"%\" , 0");
- QCOMPARE( QString("%").arg(0), QString("%") );
+ QCOMPARE( QString("%").arg(0), QLatin1String("%") );
QTest::ignoreMessage(QtWarningMsg, "QString::arg: Argument missing: \"%%\" , 0");
- QCOMPARE( QString("%%").arg(0), QString("%%") );
+ QCOMPARE( QString("%%").arg(0), QLatin1String("%%") );
QTest::ignoreMessage(QtWarningMsg, "QString::arg: Argument missing: \"%%%\" , 0");
- QCOMPARE( QString("%%%").arg(0), QString("%%%") );
- QCOMPARE( QString("%%%1%%%2").arg("foo").arg("bar"), QString("%%foo%%bar") );
-
- QCOMPARE( QString("%1").arg("hello", -10), QString("hello ") );
- QCOMPARE( QString("%1").arg("hello", -5), QString("hello") );
- QCOMPARE( QString("%1").arg("hello", -2), QString("hello") );
- QCOMPARE( QString("%1").arg("hello", 0), QString("hello") );
- QCOMPARE( QString("%1").arg("hello", 2), QString("hello") );
- QCOMPARE( QString("%1").arg("hello", 5), QString("hello") );
- QCOMPARE( QString("%1").arg("hello", 10), QString(" hello") );
- QCOMPARE( QString("%1%1").arg("hello"), QString("hellohello") );
- QCOMPARE( QString("%2%1").arg("hello"), QString("%2hello") );
- QCOMPARE( QString("%1%1").arg(QString::null), QString("") );
- QCOMPARE( QString("%2%1").arg(""), QString("%2") );
+ QCOMPARE( QString("%%%").arg(0), QLatin1String("%%%") );
+ QCOMPARE( QString("%%%1%%%2").arg("foo").arg("bar"), QLatin1String("%%foo%%bar") );
+
+ QCOMPARE( QString("%1").arg("hello", -10), QLatin1String("hello ") );
+ QCOMPARE( QString("%1").arg("hello", -5), QLatin1String("hello") );
+ QCOMPARE( QString("%1").arg("hello", -2), QLatin1String("hello") );
+ QCOMPARE( QString("%1").arg("hello", 0), QLatin1String("hello") );
+ QCOMPARE( QString("%1").arg("hello", 2), QLatin1String("hello") );
+ QCOMPARE( QString("%1").arg("hello", 5), QLatin1String("hello") );
+ QCOMPARE( QString("%1").arg("hello", 10), QLatin1String(" hello") );
+ QCOMPARE( QString("%1%1").arg("hello"), QLatin1String("hellohello") );
+ QCOMPARE( QString("%2%1").arg("hello"), QLatin1String("%2hello") );
+ QCOMPARE( QString("%1%1").arg(QString::null), QLatin1String("") );
+ QCOMPARE( QString("%2%1").arg(""), QLatin1String("%2") );
QCOMPARE( QString("%2 %L1").arg(12345.6789).arg(12345.6789),
- QString("12345.7 12.345,7") );
+ QLatin1String("12345.7 12.345,7") );
QCOMPARE( QString("[%2] [%L1]").arg(12345.6789, 9).arg(12345.6789, 9),
- QString("[ 12345.7] [ 12.345,7]") );
+ QLatin1String("[ 12345.7] [ 12.345,7]") );
QCOMPARE( QString("[%2] [%L1]").arg(12345.6789, 9, 'g', 7).arg(12345.6789, 9, 'g', 7),
- QString("[ 12345.68] [12.345,68]") );
+ QLatin1String("[ 12345.68] [12.345,68]") );
QCOMPARE( QString("[%2] [%L1]").arg(12345.6789, 10, 'g', 7, QLatin1Char('0')).arg(12345.6789, 10, 'g', 7, QLatin1Char('0')),
- QString("[0012345.68] [012.345,68]") );
+ QLatin1String("[0012345.68] [012.345,68]") );
QCOMPARE( QString("%2 %L1").arg(123456789).arg(123456789),
- QString("123456789 123.456.789") );
+ QLatin1String("123456789 123.456.789") );
QCOMPARE( QString("[%2] [%L1]").arg(123456789, 12).arg(123456789, 12),
- QString("[ 123456789] [ 123.456.789]") );
+ QLatin1String("[ 123456789] [ 123.456.789]") );
QCOMPARE( QString("[%2] [%L1]").arg(123456789, 13, 10, QLatin1Char('0')).arg(123456789, 12, 10, QLatin1Char('0')),
- QString("[000123456789] [00123.456.789]") );
+ QLatin1String("[000123456789] [00123.456.789]") );
QCOMPARE( QString("[%2] [%L1]").arg(123456789, 13, 16, QLatin1Char('0')).arg(123456789, 12, 16, QLatin1Char('0')),
- QString("[0000075bcd15] [00000075bcd15]") );
+ QLatin1String("[0000075bcd15] [00000075bcd15]") );
QCOMPARE( QString("%L2 %L1 %3").arg(12345.7).arg(123456789).arg('c'),
- QString("123.456.789 12.345,7 c") );
+ QLatin1String("123.456.789 12.345,7 c") );
// multi-digit replacement
QString input("%%%L0 %1 %02 %3 %4 %5 %L6 %7 %8 %%% %090 %10 %11 %L12 %14 %L9888 %9999 %%%%%%%L");
@@ -4631,36 +4632,36 @@ void tst_QString::arg()
.arg("k").arg("l").arg("m")
.arg("n").arg("o").arg("p");
- QCOMPARE(input, QString("%%A B C D E f g h i %%% j0 k l m n o88 p99 %%%%%%%L"));
+ QCOMPARE(input, QLatin1String("%%A B C D E f g h i %%% j0 k l m n o88 p99 %%%%%%%L"));
QString str("%1 %2 %3 %4 %5 %6 %7 %8 %9 foo %10 %11 bar");
str = str.arg("one", "2", "3", "4", "5", "6", "7", "8", "9");
str = str.arg("ahoy", "there");
- QCOMPARE(str, QString("one 2 3 4 5 6 7 8 9 foo ahoy there bar"));
+ QCOMPARE(str, QLatin1String("one 2 3 4 5 6 7 8 9 foo ahoy there bar"));
QString str2("%123 %234 %345 %456 %567 %999 %1000 %1230");
str2 = str2.arg("A", "B", "C", "D", "E", "F");
- QCOMPARE(str2, QString("A B C D E F %1000 %1230"));
-
- QCOMPARE(QString("%1").arg(-1, 3, 10, QChar('0')), QString("-01"));
- QCOMPARE(QString("%1").arg(-100, 3, 10, QChar('0')), QString("-100"));
- QCOMPARE(QString("%1").arg(-1, 3, 10, QChar(' ')), QString(" -1"));
- QCOMPARE(QString("%1").arg(-100, 3, 10, QChar(' ')), QString("-100"));
- QCOMPARE(QString("%1").arg(1U, 3, 10, QChar(' ')), QString(" 1"));
- QCOMPARE(QString("%1").arg(1000U, 3, 10, QChar(' ')), QString("1000"));
- QCOMPARE(QString("%1").arg(-1, 3, 10, QChar('x')), QString("x-1"));
- QCOMPARE(QString("%1").arg(-100, 3, 10, QChar('x')), QString("-100"));
- QCOMPARE(QString("%1").arg(1U, 3, 10, QChar('x')), QString("xx1"));
- QCOMPARE(QString("%1").arg(1000U, 3, 10, QChar('x')), QString("1000"));
-
- QCOMPARE(QString("%1").arg(-1., 3, 'g', -1, QChar('0')), QString("-01"));
- QCOMPARE(QString("%1").arg(-100., 3, 'g', -1, QChar('0')), QString("-100"));
- QCOMPARE(QString("%1").arg(-1., 3, 'g', -1, QChar(' ')), QString(" -1"));
- QCOMPARE(QString("%1").arg(-100., 3, 'g', -1, QChar(' ')), QString("-100"));
- QCOMPARE(QString("%1").arg(1., 3, 'g', -1, QChar('x')), QString("xx1"));
- QCOMPARE(QString("%1").arg(1000., 3, 'g', -1, QChar('x')), QString("1000"));
- QCOMPARE(QString("%1").arg(-1., 3, 'g', -1, QChar('x')), QString("x-1"));
- QCOMPARE(QString("%1").arg(-100., 3, 'g', -1, QChar('x')), QString("-100"));
+ QCOMPARE(str2, QLatin1String("A B C D E F %1000 %1230"));
+
+ QCOMPARE(QString("%1").arg(-1, 3, 10, QChar('0')), QLatin1String("-01"));
+ QCOMPARE(QString("%1").arg(-100, 3, 10, QChar('0')), QLatin1String("-100"));
+ QCOMPARE(QString("%1").arg(-1, 3, 10, QChar(' ')), QLatin1String(" -1"));
+ QCOMPARE(QString("%1").arg(-100, 3, 10, QChar(' ')), QLatin1String("-100"));
+ QCOMPARE(QString("%1").arg(1U, 3, 10, QChar(' ')), QLatin1String(" 1"));
+ QCOMPARE(QString("%1").arg(1000U, 3, 10, QChar(' ')), QLatin1String("1000"));
+ QCOMPARE(QString("%1").arg(-1, 3, 10, QChar('x')), QLatin1String("x-1"));
+ QCOMPARE(QString("%1").arg(-100, 3, 10, QChar('x')), QLatin1String("-100"));
+ QCOMPARE(QString("%1").arg(1U, 3, 10, QChar('x')), QLatin1String("xx1"));
+ QCOMPARE(QString("%1").arg(1000U, 3, 10, QChar('x')), QLatin1String("1000"));
+
+ QCOMPARE(QString("%1").arg(-1., 3, 'g', -1, QChar('0')), QLatin1String("-01"));
+ QCOMPARE(QString("%1").arg(-100., 3, 'g', -1, QChar('0')), QLatin1String("-100"));
+ QCOMPARE(QString("%1").arg(-1., 3, 'g', -1, QChar(' ')), QLatin1String(" -1"));
+ QCOMPARE(QString("%1").arg(-100., 3, 'g', -1, QChar(' ')), QLatin1String("-100"));
+ QCOMPARE(QString("%1").arg(1., 3, 'g', -1, QChar('x')), QLatin1String("xx1"));
+ QCOMPARE(QString("%1").arg(1000., 3, 'g', -1, QChar('x')), QLatin1String("1000"));
+ QCOMPARE(QString("%1").arg(-1., 3, 'g', -1, QChar('x')), QLatin1String("x-1"));
+ QCOMPARE(QString("%1").arg(-100., 3, 'g', -1, QChar('x')), QLatin1String("-100"));
QLocale::setDefault(QString("ar"));
QCOMPARE( QString("%L1").arg(12345.6789, 10, 'g', 7, QLatin1Char('0')),
@@ -4673,13 +4674,13 @@ void tst_QString::arg()
void tst_QString::number()
{
- QCOMPARE( QString::number(int(0)), QString("0") );
- QCOMPARE( QString::number((unsigned int)(11)), QString("11") );
- QCOMPARE( QString::number(-22L), QString("-22") );
- QCOMPARE( QString::number(333UL), QString("333") );
- QCOMPARE( QString::number(4.4), QString("4.4") );
- QCOMPARE( QString::number(Q_INT64_C(-555)), QString("-555") );
- QCOMPARE( QString::number(Q_UINT64_C(6666)), QString("6666") );
+ QCOMPARE( QString::number(int(0)), QLatin1String("0") );
+ QCOMPARE( QString::number((unsigned int)(11)), QLatin1String("11") );
+ QCOMPARE( QString::number(-22L), QLatin1String("-22") );
+ QCOMPARE( QString::number(333UL), QLatin1String("333") );
+ 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") );
}
void tst_QString::capacity_data()
diff --git a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp
index 82f78b2b0b..1c736fba65 100644
--- a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp
+++ b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp
@@ -148,14 +148,14 @@ void tst_QVarLengthArray::oldTests()
QVarLengthArray<QString> sa(10);
sa[0] = "Hello";
sa[9] = "World";
- QVERIFY(*sa.data() == "Hello");
- QVERIFY(sa[9] == "World");
+ QCOMPARE(*sa.data(), QLatin1String("Hello"));
+ QCOMPARE(sa[9], QLatin1String("World"));
sa.reserve(512);
- QVERIFY(*sa.data() == "Hello");
- QVERIFY(sa[9] == "World");
+ QCOMPARE(*sa.data(), QLatin1String("Hello"));
+ QCOMPARE(sa[9], QLatin1String("World"));
sa.resize(512);
- QVERIFY(*sa.data() == "Hello");
- QVERIFY(sa[9] == "World");
+ QCOMPARE(*sa.data(), QLatin1String("Hello"));
+ QCOMPARE(sa[9], QLatin1String("World"));
}
{
int arr[2] = {1, 2};
diff --git a/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp b/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp
index 8875355565..94b785ae1d 100644
--- a/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp
+++ b/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp
@@ -1051,11 +1051,11 @@ void tst_QXmlStream::readNextStartElement() const
QXmlStreamReader reader(in);
QVERIFY(reader.readNextStartElement());
- QVERIFY(reader.isStartElement() && reader.name() == "A");
+ QVERIFY(reader.isStartElement() && reader.name() == QLatin1String("A"));
int amountOfB = 0;
while (reader.readNextStartElement()) {
- QVERIFY(reader.isStartElement() && reader.name() == "B");
+ QVERIFY(reader.isStartElement() && reader.name() == QLatin1String("B"));
++amountOfB;
reader.skipCurrentElement();
}