summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorSona Kurazyan <sona.kurazyan@qt.io>2019-11-04 10:18:41 +0100
committerSona Kurazyan <sona.kurazyan@qt.io>2019-11-04 20:06:38 +0100
commit43c964b8ada63942b5d239f60fdbca6f5773f678 (patch)
treee01307e14a2b3d67b2bed4d4d0218438a1a33b3f /tests/auto
parent06456873fceddcd340431fc5999c50ff6d3c2371 (diff)
Fix converting a null QStringRef to QString
The assumption when calling QStringRef::toString() on a null QStringRef (i.e. when QStringRef::isNull() is true) is that QStringRef::toString().isNull() will also return true. With the current implementation we return a null QString() only when the QStringRef references a nullptr QString. We need to do the same also when QStringRef references a QString with null private data. Change-Id: I4177a5ea187ae758d7c46fe76a9d0583140e90cb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/text/qstringref/tst_qstringref.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/auto/corelib/text/qstringref/tst_qstringref.cpp b/tests/auto/corelib/text/qstringref/tst_qstringref.cpp
index 6f01947131..20d5426bf7 100644
--- a/tests/auto/corelib/text/qstringref/tst_qstringref.cpp
+++ b/tests/auto/corelib/text/qstringref/tst_qstringref.cpp
@@ -87,6 +87,7 @@ private slots:
void mid();
void split_data();
void split();
+ void nullToString();
};
static QStringRef emptyRef()
@@ -2177,6 +2178,18 @@ void tst_QStringRef::split()
}
}
+void tst_QStringRef::nullToString()
+{
+ QStringRef nullRef;
+ QVERIFY(nullRef.isNull());
+ QVERIFY(nullRef.toString().isNull());
+
+ QString str;
+ nullRef = &str;
+ QVERIFY(nullRef.isNull());
+ QVERIFY(nullRef.toString().isNull());
+}
+
QTEST_APPLESS_MAIN(tst_QStringRef)
#include "tst_qstringref.moc"