summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/tools/qstring.cpp2
-rw-r--r--tests/auto/corelib/tools/qstring/tst_qstring.cpp14
2 files changed, 15 insertions, 1 deletions
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 87b222881c..7c4280d36b 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -5402,7 +5402,7 @@ int QString::compare_helper(const QChar *data1, int length1, const char *data2,
Qt::CaseSensitivity cs)
{
if (!data2)
- return int(bool(data1));
+ return length1;
if (Q_UNLIKELY(length2 < 0))
length2 = int(strlen(data2));
// ### make me nothrow in all cases
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
index 6df9ad7cdf..36784435b8 100644
--- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
@@ -5012,6 +5012,12 @@ void tst_QString::operator_eqeq_nullstring()
QVERIFY( QString("") == "" );
QVERIFY( "" == QString("") );
+ QVERIFY(QString() == nullptr);
+ QVERIFY(nullptr == QString());
+
+ QVERIFY(QString("") == nullptr);
+ QVERIFY(nullptr == QString(""));
+
QVERIFY( QString().size() == 0 );
QVERIFY( QString("").size() == 0 );
@@ -5025,6 +5031,8 @@ void tst_QString::operator_smaller()
QString null;
QString empty("");
QString foo("foo");
+ const char *nullC = nullptr;
+ const char *emptyC = "";
QVERIFY( !(null < QString()) );
QVERIFY( !(null > QString()) );
@@ -5035,6 +5043,12 @@ void tst_QString::operator_smaller()
QVERIFY( !(null < empty) );
QVERIFY( !(null > empty) );
+ QVERIFY( !(nullC < empty) );
+ QVERIFY( !(nullC > empty) );
+
+ QVERIFY( !(null < emptyC) );
+ QVERIFY( !(null > emptyC) );
+
QVERIFY( null < foo );
QVERIFY( !(null > foo) );
QVERIFY( foo > null );