diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2016-07-19 10:46:15 +0000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2016-07-19 10:46:15 +0000 |
commit | b3f260236a5f5bcf2db0692e90bb2a875b9da078 (patch) | |
tree | f1cc4378e829cc4521621329764914adb60439da /tests/auto/corelib/tools/qpair | |
parent | 267c01390544ba12f81783c8b0e37ed38db231d6 (diff) | |
parent | 82ea53ad24c92b345ac2b542a174887f5de5723a (diff) |
Merge "Merge remote-tracking branch 'origin/5.6' into 5.7" into refs/staging/5.7
Diffstat (limited to 'tests/auto/corelib/tools/qpair')
-rw-r--r-- | tests/auto/corelib/tools/qpair/tst_qpair.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qpair/tst_qpair.cpp b/tests/auto/corelib/tools/qpair/tst_qpair.cpp index fb0986d05b..1d5f7536c8 100644 --- a/tests/auto/corelib/tools/qpair/tst_qpair.cpp +++ b/tests/auto/corelib/tools/qpair/tst_qpair.cpp @@ -35,6 +35,7 @@ class tst_QPair : public QObject { Q_OBJECT private Q_SLOTS: + void pairOfReferences(); void testConstexpr(); void testConversions(); void taskQTBUG_48780_pairContainingCArray(); @@ -91,6 +92,35 @@ Q_STATIC_ASSERT(!QTypeInfo<QPairPP>::isDummy ); Q_STATIC_ASSERT(!QTypeInfo<QPairPP>::isPointer); +void tst_QPair::pairOfReferences() +{ + int i = 0; + QString s; + + QPair<int&, QString&> p(i, s); + + p.first = 1; + QCOMPARE(i, 1); + + i = 2; + QCOMPARE(p.first, 2); + + p.second = QLatin1String("Hello"); + QCOMPARE(s, QLatin1String("Hello")); + + s = QLatin1String("olleH"); + QCOMPARE(p.second, QLatin1String("olleH")); + + QPair<int&, QString&> q = p; + q.first = 3; + QCOMPARE(i, 3); + QCOMPARE(p.first, 3); + + q.second = QLatin1String("World"); + QCOMPARE(s, QLatin1String("World")); + QCOMPARE(p.second, QLatin1String("World")); +} + void tst_QPair::testConstexpr() { Q_CONSTEXPR QPair<int, double> pID = qMakePair(0, 0.0); |