From 601d68584921a47d83d833228f5ec698e13b624c Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Mon, 23 Jan 2012 12:02:36 +0000 Subject: Make mid() and midRef() properly return empty, non-null objects If we request a substring starting at the very end of the string, QString::mid should return an empty string, not a null string. For instance, QString("abc").mid(3, 0) used to return a null one, while this patch makes it return an empty one. The same thing applies to QString::midRef() and QByteArray::mid(). Change-Id: Ie9efd7a0622d429efd0fb682c19856c19e9469af Reviewed-by: Lars Knoll --- tests/auto/other/collections/tst_collections.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/auto/other/collections') diff --git a/tests/auto/other/collections/tst_collections.cpp b/tests/auto/other/collections/tst_collections.cpp index 4edb9d2f3a..528d3b1737 100644 --- a/tests/auto/other/collections/tst_collections.cpp +++ b/tests/auto/other/collections/tst_collections.cpp @@ -1310,8 +1310,8 @@ void tst_Collections::byteArray() QVERIFY(hello.mid(0, hello.size()+1) == hello); QVERIFY(hello.mid(hello.size()-0) == ""); - - QVERIFY(hello.mid(hello.size()-0).isNull()); // weird but valid 3.x semantics + 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"); @@ -2030,8 +2030,8 @@ void tst_Collections::qstring() QVERIFY(hello.mid(0, hello.size()+1) == hello); QVERIFY(hello.mid(hello.size()-0) == ""); - - QVERIFY(hello.mid(hello.size()-0).isNull()); + 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"); -- cgit v1.2.3