diff options
author | Frans Englich <frans.englich@nokia.com> | 2009-07-13 11:02:20 (GMT) |
---|---|---|
committer | Frans Englich <frans.englich@nokia.com> | 2009-07-13 11:36:45 (GMT) |
commit | cc24c46c117248ecb98200416e7f25375e6bb476 (patch) | |
tree | 5b15f68fbe18db5274e9ed48f0f38476bb3af336 /tests | |
parent | 0aca5cf05288dc4d2175d1c4a78bf62a5ea96b21 (diff) | |
download | Qt-cc24c46c117248ecb98200416e7f25375e6bb476.zip Qt-cc24c46c117248ecb98200416e7f25375e6bb476.tar.gz Qt-cc24c46c117248ecb98200416e7f25375e6bb476.tar.bz2 |
QFlags::testFlag(): handle the zero case appropriately.
Brought up by Andy. See perforce change 314809,
17b07e3ab6192b31f77fd2f126705b9ab53b3937. Related to task 221708.
Reviewed-By: Andy Shaw
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qflags/tst_qflags.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/qflags/tst_qflags.cpp b/tests/auto/qflags/tst_qflags.cpp index a5f68dc..87d8258 100644 --- a/tests/auto/qflags/tst_qflags.cpp +++ b/tests/auto/qflags/tst_qflags.cpp @@ -45,6 +45,7 @@ class tst_QFlags: public QObject Q_OBJECT private slots: void testFlag() const; + void testFlagZeroFlag() const; void testFlagMultiBits() const; }; @@ -59,8 +60,31 @@ void tst_QFlags::testFlag() const QVERIFY(!btn.testFlag(Qt::LeftButton)); } +void tst_QFlags::testFlagZeroFlag() const +{ + { + Qt::MouseButtons btn = Qt::LeftButton | Qt::RightButton; + /* Qt::NoButton has the value 0. */ + + QVERIFY(!btn.testFlag(Qt::NoButton)); + } + + { + /* A zero enum set should test true with zero. */ + QVERIFY(Qt::MouseButtons().testFlag(Qt::NoButton)); + } + + { + Qt::MouseButtons btn = Qt::NoButton; + QVERIFY(btn.testFlag(Qt::NoButton)); + } +} + void tst_QFlags::testFlagMultiBits() const { + /* Qt::Window is 0x00000001 + * Qt::Dialog is 0x00000002 | Window + */ { const Qt::WindowFlags onlyWindow(Qt::Window); QVERIFY(!onlyWindow.testFlag(Qt::Dialog)); |