diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2016-07-15 20:47:57 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2016-07-15 20:47:57 +0200 |
commit | 82ea53ad24c92b345ac2b542a174887f5de5723a (patch) | |
tree | 7d326274b52bbedac481be522a20732f77457073 /tests/auto/corelib/tools/qpair/tst_qpair.cpp | |
parent | e46e112eb10850801218bd810ecaeb8fd29f4c34 (diff) | |
parent | 178ab885626bcd67507fde7f67f65c1872ac3be3 (diff) |
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
qmake/library/qmakeevaluator.cpp
One side changed the iterator to use ranged-for, the other changed its
body; they only conflicted because the latter had to add braces around
the body, intruding on the for-line. Trivial resolution.
Change-Id: Ib487bc3bd6e3c5225db15f94b9a8f6caaa33456b
Diffstat (limited to 'tests/auto/corelib/tools/qpair/tst_qpair.cpp')
-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); |