diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2016-01-25 10:41:15 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2016-01-26 11:21:09 +0000 |
commit | cf51e2f33fa9ce28c3e822d75fcc87dfeaeed4b1 (patch) | |
tree | 43e4ad3b453a6f73c4e1836e752bb893c3092313 /tests/auto/corelib/tools | |
parent | 1c470f3af0e3093b9e17ffacb229bfff4c91511e (diff) |
QStringRef: add missing op[]
[ChangeLog][QtCore][QStringRef] Added subscript operator.
Change-Id: Ia85d5efcb7747d2961ba55922ddabe6a46bdf20b
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'tests/auto/corelib/tools')
-rw-r--r-- | tests/auto/corelib/tools/qstringref/tst_qstringref.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp b/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp index b3a1558931..b98c2fb4de 100644 --- a/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp +++ b/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp @@ -41,6 +41,7 @@ class tst_QStringRef : public QObject public slots: void cleanup(); private slots: + void at(); void endsWith(); void startsWith(); void contains(); @@ -172,6 +173,16 @@ void tst_QStringRef::cleanup() QLocale::setDefault(QString(QLatin1Char('C'))); } +void tst_QStringRef::at() +{ + const QString hw = QStringLiteral("Hello World"); + const QStringRef ref = hw.midRef(6); + QCOMPARE(ref.at(0), QChar('W')); + QCOMPARE(ref.at(4), QChar('d')); + QCOMPARE(ref[0], QChar('W')); + QCOMPARE(ref[4], QChar('d')); +} + void tst_QStringRef::length_data() { QTest::addColumn<QString>("s1"); |