summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2015-01-19 11:29:52 +0100
committerMarc Mutz <marc.mutz@kdab.com>2017-01-28 07:46:22 +0000
commitce3402b5efc929b99d6ecb27f47e671cdcfae393 (patch)
tree41c2c17e0dd1aa686a43272979354eb9ffd9ac82 /tests
parent1aea3c1229556d2a692194c615844579f315e3be (diff)
QSizePolicy: add some constexpr
Also add a basic test for constexpr expressions involving QSizePolicy. GCC < 4.8.0 has problems with initializing variant members in constexpr ctors: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54922 Instead of revoking its Q_COMPILER_CONSTEXPR, which is a source-incompatible change, simply note the fact so we can selectively provide constexpr for QSizePolicy. Change-Id: Iba8e5a7cdf847d73e8e2b6bb6211fb3c9846aa0a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/widgets/kernel/qsizepolicy/qsizepolicy.pro1
-rw-r--r--tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp14
2 files changed, 15 insertions, 0 deletions
diff --git a/tests/auto/widgets/kernel/qsizepolicy/qsizepolicy.pro b/tests/auto/widgets/kernel/qsizepolicy/qsizepolicy.pro
index 84629c7c0a..d325bc4aeb 100644
--- a/tests/auto/widgets/kernel/qsizepolicy/qsizepolicy.pro
+++ b/tests/auto/widgets/kernel/qsizepolicy/qsizepolicy.pro
@@ -1,4 +1,5 @@
CONFIG += testcase
+contains(QT_CONFIG, c++14): CONFIG += c++14
TARGET = tst_qsizepolicy
QT += widgets widgets-private testlib
diff --git a/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp b/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp
index cd5aa03689..15bd0a8c1c 100644
--- a/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp
+++ b/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp
@@ -41,6 +41,7 @@ class tst_QSizePolicy : public QObject
private Q_SLOTS:
void cleanup() { QVERIFY(QApplication::topLevelWidgets().isEmpty()); }
void qtest();
+ void constExpr();
void defaultValues();
void getSetCheck_data() { data(); }
void getSetCheck();
@@ -102,6 +103,19 @@ void tst_QSizePolicy::qtest()
#undef CHECK2
}
+void tst_QSizePolicy::constExpr()
+{
+/* gcc < 4.8.0 has problems with init'ing variant members in constexpr ctors */
+/* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54922 */
+#if !defined(Q_CC_GNU) || defined(Q_CC_INTEL) || defined(Q_CC_CLANG) || Q_CC_GNU >= 408
+ // check that certain ctors are constexpr (compile-only):
+ { Q_CONSTEXPR QSizePolicy sp; Q_UNUSED(sp); }
+ { Q_CONSTEXPR QSizePolicy sp = QSizePolicy(); Q_UNUSED(sp); }
+#else
+ QSKIP("QSizePolicy cannot be constexpr with this version of the compiler.");
+#endif
+}
+
void tst_QSizePolicy::defaultValues()
{
{