summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2012-01-29 19:53:30 +0100
committerQt by Nokia <qt-info@nokia.com>2012-01-30 23:27:35 +0100
commit21b5d0e2c3dfcafcca098d285498ffc9fbbf0498 (patch)
treeb9397b9cbba2dbdbf9e9a9a521236c887cc6aec7 /tests/auto/corelib/tools
parentf605e269dde5d54e00bcc157a29f8df3712cbcb5 (diff)
Fix bugs when using a non 0 terminated QLatin1String
A few methods in QString still assumed that QLatin1String is always 0 terminated. Change this to rely on the size provided by QLatin1String instead. Change-Id: I9145a46e52ed8811f3b4e3d72d8a81a12588760a Reviewed-by: Kevin Simons <kevin.simons@nokia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/tools')
-rw-r--r--tests/auto/corelib/tools/qstring/tst_qstring.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
index 44c196d719..2a949436a0 100644
--- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
@@ -4798,6 +4798,13 @@ void tst_QString::compare()
QCOMPARE(sign(QString::compare(s1, QLatin1String(s2.toLatin1()), Qt::CaseInsensitive)), cir);
QCOMPARE(sign(QStringRef::compare(r1, QLatin1String(s2.toLatin1()))), csr);
QCOMPARE(sign(QStringRef::compare(r1, QLatin1String(s2.toLatin1()), Qt::CaseInsensitive)), cir);
+ QByteArray l1 = s2.toLatin1();
+ l1 += "x";
+ QLatin1String l1str(l1.constData(), l1.size() - 1);
+ QCOMPARE(sign(QString::compare(s1, l1str)), csr);
+ QCOMPARE(sign(QString::compare(s1, l1str, Qt::CaseInsensitive)), cir);
+ QCOMPARE(sign(QStringRef::compare(r1, l1str)), csr);
+ QCOMPARE(sign(QStringRef::compare(r1, l1str, Qt::CaseInsensitive)), cir);
}
if (isLatin(s1)) {