summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qstringref
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2016-04-06 22:38:58 +0200
committerMarc Mutz <marc.mutz@kdab.com>2016-04-07 11:29:45 +0000
commit6958e189a3743aae63314acfdc706e2c3283a99b (patch)
tree4c3bb34409919e2d767c3bdc1d1c9e8fe5d11191 /tests/auto/corelib/tools/qstringref
parentee0951d69b38f766e67262487be95b88501aa4a5 (diff)
QStringRef: add missing {c,}r{begin,end}()
Most containers have them in Qt 5.7, so add them to QStringRef, too. Brush up the docs, use the const_iterator typedef in the API, for consistency with QString's docs. [ChangeLog][QtCore][QStringRef] Added reverse iterators, rbegin(), rend(), crbegin(), crend(). Change-Id: I3d2884a1b2faae02c610ab3871552b65bc6e2521 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'tests/auto/corelib/tools/qstringref')
-rw-r--r--tests/auto/corelib/tools/qstringref/tst_qstringref.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp b/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp
index b98c2fb4de..25b97ceaa8 100644
--- a/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp
+++ b/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp
@@ -52,6 +52,7 @@ private slots:
void indexOf();
void indexOf2_data();
void indexOf2();
+ void iteration();
void length_data();
void length();
void isEmpty();
@@ -446,6 +447,38 @@ void tst_QStringRef::indexOf2()
}
}
+void tst_QStringRef::iteration()
+{
+ QString hello = "Hello";
+ QString olleh = "olleH";
+
+ QStringRef ref(&hello);
+ QStringRef rref(&olleh);
+
+ const QStringRef &cref = ref;
+ const QStringRef &crref = rref;
+
+ QVERIFY(std::equal( ref.begin(), ref.end(), hello.begin()));
+ QVERIFY(std::equal( rref.begin(), rref.end(), olleh.begin()));
+ QVERIFY(std::equal( cref.begin(), cref.end(), hello.begin()));
+ QVERIFY(std::equal(crref.begin(), crref.end(), olleh.begin()));
+
+ QVERIFY(std::equal( ref.cbegin(), ref.cend(), hello.begin()));
+ QVERIFY(std::equal( rref.cbegin(), rref.cend(), olleh.begin()));
+ QVERIFY(std::equal( cref.cbegin(), cref.cend(), hello.begin()));
+ QVERIFY(std::equal(crref.cbegin(), crref.cend(), olleh.begin()));
+
+ QVERIFY(std::equal( ref.rbegin(), ref.rend(), hello.rbegin()));
+ QVERIFY(std::equal( rref.rbegin(), rref.rend(), olleh.rbegin()));
+ QVERIFY(std::equal( cref.rbegin(), cref.rend(), hello.rbegin()));
+ QVERIFY(std::equal(crref.rbegin(), crref.rend(), olleh.rbegin()));
+
+ QVERIFY(std::equal( ref.crbegin(), ref.crend(), hello.rbegin()));
+ QVERIFY(std::equal( rref.crbegin(), rref.crend(), olleh.rbegin()));
+ QVERIFY(std::equal( cref.crbegin(), cref.crend(), hello.rbegin()));
+ QVERIFY(std::equal(crref.crbegin(), crref.crend(), olleh.rbegin()));
+}
+
void tst_QStringRef::lastIndexOf_data()
{
QTest::addColumn<QString>("haystack");