From cf51e2f33fa9ce28c3e822d75fcc87dfeaeed4b1 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 25 Jan 2016 10:41:15 +0100 Subject: QStringRef: add missing op[] [ChangeLog][QtCore][QStringRef] Added subscript operator. Change-Id: Ia85d5efcb7747d2961ba55922ddabe6a46bdf20b Reviewed-by: Lars Knoll --- tests/auto/corelib/tools/qstringref/tst_qstringref.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (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 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("s1"); -- cgit v1.2.3