From 8d3220459223e0cb2cfd06031c70359ecb2d39cd Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 27 Apr 2017 13:57:55 +0200 Subject: QStringRef: fix trimmed() returning null strings on empty input The QString API symmetry test strikes again, showing that this is inconsistent with both QString and QByteArray, which both return empty for empty inputs. The fix actually makes the implementation simpler. Extend the QStringRef test to cover null inputs, too. I can't merge the trimmed() test in the API symmetry test until everything is actually consistent. [ChangeLog][QtCore][QStringRef] trimmed() now returns an empty string-ref for an empty input. Before, it would return a null one. Change-Id: I6b35c5f498053c4e15a4a9dd465bc696258e7393 Reviewed-by: Edward Welbourne Reviewed-by: Anton Kudryavtsev --- tests/auto/corelib/tools/qstringref/tst_qstringref.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tests/auto/corelib/tools/qstringref') diff --git a/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp b/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp index d2374fe0ae..473f563f9b 100644 --- a/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp +++ b/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp @@ -1862,7 +1862,9 @@ void tst_QStringRef::double_conversion() void tst_QStringRef::trimmed() { - QString a; + QVERIFY(QStringRef().trimmed().isNull()); + QString a = ""; + QVERIFY(!QStringRef(&a).trimmed().isNull()); QStringRef b; a = "Text"; b = a.leftRef(-1); -- cgit v1.2.3