diff options
Diffstat (limited to 'tests/auto/corelib/global/qglobal')
-rw-r--r-- | tests/auto/corelib/global/qglobal/tst_qglobal.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp index 5547f832ff..3d8759fba5 100644 --- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp +++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp @@ -60,6 +60,7 @@ private slots: void qRoundDoubles_data(); void qRoundDoubles(); void PRImacros(); + void testqToUnderlying(); }; extern "C" { // functions in qglobal.c @@ -698,5 +699,24 @@ void tst_QGlobal::PRImacros() } } +void tst_QGlobal::testqToUnderlying() +{ + enum class E { + E1 = 123, + E2 = 456, + }; + static_assert(std::is_same_v<decltype(qToUnderlying(E::E1)), int>); + QCOMPARE(qToUnderlying(E::E1), 123); + QCOMPARE(qToUnderlying(E::E2), 456); + + enum EE : unsigned long { + EE1 = 123, + EE2 = 456, + }; + static_assert(std::is_same_v<decltype(qToUnderlying(EE1)), unsigned long>); + QCOMPARE(qToUnderlying(EE1), 123UL); + QCOMPARE(qToUnderlying(EE2), 456UL); +} + QTEST_APPLESS_MAIN(tst_QGlobal) #include "tst_qglobal.moc" |