From 21b5d0e2c3dfcafcca098d285498ffc9fbbf0498 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Sun, 29 Jan 2012 19:53:30 +0100 Subject: 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 Reviewed-by: Thiago Macieira --- tests/auto/corelib/tools/qstring/tst_qstring.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests/auto/corelib/tools') 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)) { -- cgit v1.2.3