diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2011-07-06 22:16:34 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2011-07-06 22:16:34 (GMT) |
commit | e6843c5a9cf4949e7521c1304bb5dc5d48fbc9be (patch) | |
tree | ec904055b73a577f39adbe6c71ae43fe11b7ca2b /tests/auto/qflags/tst_qflags.cpp | |
parent | 74d8577f5b71a593a968d0723aaca19a5249b7d3 (diff) | |
parent | f650c43d130d28fa7eca2f6accf8aacd76ae508d (diff) | |
download | Qt-e6843c5a9cf4949e7521c1304bb5dc5d48fbc9be.zip Qt-e6843c5a9cf4949e7521c1304bb5dc5d48fbc9be.tar.gz Qt-e6843c5a9cf4949e7521c1304bb5dc5d48fbc9be.tar.bz2 |
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-earth-staging into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/qt-earth-staging:
Add Q_DECL_CONSTEXPR
Use Q_DECL_CONSTEXPR in QFlags
Fix QScopedPointerarray default constructor
Diffstat (limited to 'tests/auto/qflags/tst_qflags.cpp')
-rw-r--r-- | tests/auto/qflags/tst_qflags.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/qflags/tst_qflags.cpp b/tests/auto/qflags/tst_qflags.cpp index 87025b6..85e64a6 100644 --- a/tests/auto/qflags/tst_qflags.cpp +++ b/tests/auto/qflags/tst_qflags.cpp @@ -47,6 +47,7 @@ private slots: void testFlag() const; void testFlagZeroFlag() const; void testFlagMultiBits() const; + void constExpr(); }; void tst_QFlags::testFlag() const @@ -96,5 +97,32 @@ void tst_QFlags::testFlagMultiBits() const } } +template <int N, typename T> bool verifyConstExpr(T n) { return n == N; } + +void tst_QFlags::constExpr() +{ +#ifdef Q_COMPILER_CONSTEXPR + Qt::MouseButtons btn = Qt::LeftButton | Qt::RightButton; + switch (btn) { + case Qt::LeftButton: QVERIFY(false); break; + case Qt::RightButton: QVERIFY(false); break; + case Qt::LeftButton | Qt::RightButton: QVERIFY(true); break; + default: QVERIFY(false); + } + + QVERIFY(verifyConstExpr<(Qt::LeftButton | Qt::RightButton) & Qt::LeftButton>(Qt::LeftButton)); + QVERIFY(verifyConstExpr<(Qt::LeftButton | Qt::RightButton) & Qt::MiddleButton>(0)); + QVERIFY(verifyConstExpr<(Qt::LeftButton | Qt::RightButton) | Qt::MiddleButton>(Qt::LeftButton | Qt::RightButton | Qt::MiddleButton)); + QVERIFY(verifyConstExpr<~(Qt::LeftButton | Qt::RightButton)>(~(Qt::LeftButton | Qt::RightButton))); + QVERIFY(verifyConstExpr<Qt::MouseButtons(Qt::LeftButton) ^ Qt::RightButton>(Qt::LeftButton ^ Qt::RightButton)); + QVERIFY(verifyConstExpr<Qt::MouseButtons(0)>(0)); + QVERIFY(verifyConstExpr<Qt::MouseButtons(Qt::RightButton) & 0xff>(Qt::RightButton)); + QVERIFY(verifyConstExpr<Qt::MouseButtons(Qt::RightButton) | 0xff>(0xff)); + + QVERIFY(!verifyConstExpr<Qt::RightButton>(!Qt::MouseButtons(Qt::LeftButton))); +#endif +} + + QTEST_MAIN(tst_QFlags) #include "tst_qflags.moc" |