summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2012-02-01 20:15:24 +0100
committerQt by Nokia <qt-info@nokia.com>2012-02-02 11:10:04 +0100
commit35b19be4784a65894ac9dfe64a6c036b95b06304 (patch)
tree996df27ec175b66d0ad7c79f2bd6a10887a56528 /tests/auto/corelib/tools
parentec9833388f514ac8050cc945e494e448dae545ea (diff)
Fix QString(QLatin1String) constructor for substrings
QLatin1String now has a constructor that takes explicit length, which makes it possible to create a QLatin1String that isn't null-terminated. Made the QString(QLatin1String) constructor work in that case. Change-Id: I4f4f07a956144b7ea4aa9c58a61c755fb99ef1b3 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'tests/auto/corelib/tools')
-rw-r--r--tests/auto/corelib/tools/qstring/tst_qstring.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
index f3ff6e08e2..781377f574 100644
--- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
@@ -223,6 +223,7 @@ private slots:
void operatorGreaterWithQLatin1String();
void compareQLatin1Strings();
+ void fromQLatin1StringWithLength();
};
typedef QList<int> IntList;
@@ -5277,6 +5278,14 @@ void tst_QString::compareQLatin1Strings()
QVERIFY(!(subab >= subabc));
}
+void tst_QString::fromQLatin1StringWithLength()
+{
+ QLatin1String latin1foo("foobar", 3);
+ QString foo(latin1foo);
+ QCOMPARE(foo.size(), latin1foo.size());
+ QCOMPARE(foo, QString::fromLatin1("foo"));
+}
+
QTEST_APPLESS_MAIN(tst_QString)
#include "tst_qstring.moc"