summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qpair/tst_qpair.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/tools/qpair/tst_qpair.cpp')
-rw-r--r--tests/auto/corelib/tools/qpair/tst_qpair.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qpair/tst_qpair.cpp b/tests/auto/corelib/tools/qpair/tst_qpair.cpp
index 076efc5428..bce02d1a42 100644
--- a/tests/auto/corelib/tools/qpair/tst_qpair.cpp
+++ b/tests/auto/corelib/tools/qpair/tst_qpair.cpp
@@ -41,6 +41,8 @@ class tst_QPair : public QObject
Q_OBJECT
private Q_SLOTS:
void testConstexpr();
+ void testConversions();
+ void taskQTBUG_48780_pairContainingCArray();
};
class C { char _[4]; };
@@ -108,5 +110,72 @@ void tst_QPair::testConstexpr()
Q_UNUSED(pSI);
}
+void tst_QPair::testConversions()
+{
+ // construction from lvalue:
+ {
+ const QPair<int, double> rhs(42, 4.5);
+ const QPair<int, int> pii = rhs;
+ QCOMPARE(pii.first, 42);
+ QCOMPARE(pii.second, 4);
+
+ const QPair<int, float> pif = rhs;
+ QCOMPARE(pif.first, 42);
+ QCOMPARE(pif.second, 4.5f);
+ }
+
+ // assignment from lvalue:
+ {
+ const QPair<int, double> rhs(42, 4.5);
+ QPair<int, int> pii;
+ pii = rhs;
+ QCOMPARE(pii.first, 42);
+ QCOMPARE(pii.second, 4);
+
+ QPair<int, float> pif;
+ pif = rhs;
+ QCOMPARE(pif.first, 42);
+ QCOMPARE(pif.second, 4.5f);
+ }
+
+ // construction from rvalue:
+ {
+#define rhs qMakePair(42, 4.5)
+ const QPair<int, int> pii = rhs;
+ QCOMPARE(pii.first, 42);
+ QCOMPARE(pii.second, 4);
+
+ const QPair<int, float> pif = rhs;
+ QCOMPARE(pif.first, 42);
+ QCOMPARE(pif.second, 4.5f);
+#undef rhs
+ }
+
+ // assignment from rvalue:
+ {
+#define rhs qMakePair(42, 4.5)
+ QPair<int, int> pii;
+ pii = rhs;
+ QCOMPARE(pii.first, 42);
+ QCOMPARE(pii.second, 4);
+
+ QPair<int, float> pif;
+ pif = rhs;
+ QCOMPARE(pif.first, 42);
+ QCOMPARE(pif.second, 4.5f);
+#undef rhs
+ }
+}
+
+void tst_QPair::taskQTBUG_48780_pairContainingCArray()
+{
+ // compile-only:
+ QPair<int[2], int> pair;
+ pair.first[0] = 0;
+ pair.first[1] = 1;
+ pair.second = 2;
+ Q_UNUSED(pair);
+}
+
QTEST_APPLESS_MAIN(tst_QPair)
#include "tst_qpair.moc"