summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qstringref
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2017-04-27 13:57:55 +0200
committerMarc Mutz <marc.mutz@kdab.com>2017-04-27 17:04:32 +0000
commit8d3220459223e0cb2cfd06031c70359ecb2d39cd (patch)
tree172f15d6be0ad8a0e61ccdaad179d8cef8d29b68 /tests/auto/corelib/tools/qstringref
parent0803285fe7e6bca32eac77e88a2cb1f47a308865 (diff)
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 <edward.welbourne@qt.io> Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Diffstat (limited to 'tests/auto/corelib/tools/qstringref')
-rw-r--r--tests/auto/corelib/tools/qstringref/tst_qstringref.cpp4
1 files changed, 3 insertions, 1 deletions
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);