summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>2014-10-13 08:49:16 +0200
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>2014-10-14 11:32:55 +0200
commit4bf0660ae4e695ceb79f585b92dedf00d7757f31 (patch)
tree86cb4921884eac14d2ee5c45005779ae831099ec /tests
parent5d9dcac0f2dc8da1a1ac79dbdd309654d6deabac (diff)
Make QStringRef::right() consistent with QString::right()
The implementation was inconsistent with QString::right(), and did not return the N rightmost characters but actually did the same as QString::mid(N) (returning the rightmost size - N characters.) Since this function is fairly recent (Qt 5.2), is documented to behave the same as QString::right(), and since these APIs are meant to be interchangeable, this needs to be fixed, even though it changes behavior. [ChangeLog][Important Behavior Changes] Changed QStringRef::right() to be consistent with QString::right(). The function now returns the N right-most characters, like the documentation already claimed. Change-Id: I2d1cd6d958dfa9354aa09f16bd27b1ed209c2d11 Task-number: QTBUG-41858 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/tools/qstringref/tst_qstringref.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp b/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp
index a38707ef08..3ba901061c 100644
--- a/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp
+++ b/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp
@@ -1870,9 +1870,9 @@ void tst_QStringRef::right()
QStringRef ref = originalString.rightRef(originalString.size() - 1);
QCOMPARE(ref.toString(), QLatin1String("OrginalString"));
- QCOMPARE(ref.right(ref.size() - 6).toString(), QLatin1String("String"));
+ QCOMPARE(ref.right(6).toString(), QLatin1String("String"));
QCOMPARE(ref.right(ref.size()).toString(), QLatin1String("OrginalString"));
- QCOMPARE(ref.right(0).toString(), QLatin1String("OrginalString"));
+ QCOMPARE(ref.right(0).toString(), QLatin1String(""));
QStringRef nullRef;
QVERIFY(nullRef.isNull());