diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2020-03-19 17:57:05 +0100 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2020-11-22 02:22:20 +0100 |
commit | 8ae9431c792f14a32909ac013a1383547d6bcfa8 (patch) | |
tree | f24f65816836fcc4e716e235ebb8866dce1985c5 /tests/auto/corelib/tools | |
parent | f08492c6fd9818c7d80b1725355453e179b4d85b (diff) |
QMargins(F): add support for structured binding
[ChangeLog][QtCore][QMargins] QMargins is usable in a structured
binding.
[ChangeLog][QtCore][QMarginsF] QMarginsF is usable in a structured
binding.
Change-Id: I0c501847b9377c47bd0e63da3735792075bd0079
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/tools')
-rw-r--r-- | tests/auto/corelib/tools/qmargins/tst_qmargins.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qmargins/tst_qmargins.cpp b/tests/auto/corelib/tools/qmargins/tst_qmargins.cpp index 6b89ba0b81..8d71ccf7ab 100644 --- a/tests/auto/corelib/tools/qmargins/tst_qmargins.cpp +++ b/tests/auto/corelib/tools/qmargins/tst_qmargins.cpp @@ -52,6 +52,8 @@ private slots: #ifndef QT_NO_DEBUG_STREAM void debugStreamCheckF(); #endif + + void structuredBinding(); }; // Testing get/set functions @@ -283,5 +285,59 @@ void tst_QMargins::debugStreamCheckF() } #endif +void tst_QMargins::structuredBinding() +{ + { + QMargins m(1, 2, 3, 4); + auto [left, top, right, bottom] = m; + QCOMPARE(left, 1); + QCOMPARE(top, 2); + QCOMPARE(right, 3); + QCOMPARE(bottom, 4); + } + { + QMargins m(1, 2, 3, 4); + auto &[left, top, right, bottom] = m; + QCOMPARE(left, 1); + QCOMPARE(top, 2); + QCOMPARE(right, 3); + QCOMPARE(bottom, 4); + + left = 10; + top = 20; + right = 30; + bottom = 40; + QCOMPARE(m.left(), 10); + QCOMPARE(m.top(), 20); + QCOMPARE(m.right(), 30); + QCOMPARE(m.bottom(), 40); + } + { + QMarginsF m(1.0, 2.0, 3.0, 4.0); + auto [left, top, right, bottom] = m; + QCOMPARE(left, 1.0); + QCOMPARE(top, 2.0); + QCOMPARE(right, 3.0); + QCOMPARE(bottom, 4.0); + } + { + QMarginsF m(1.0, 2.0, 3.0, 4.0); + auto &[left, top, right, bottom] = m; + QCOMPARE(left, 1.0); + QCOMPARE(top, 2.0); + QCOMPARE(right, 3.0); + QCOMPARE(bottom, 4.0); + + left = 10.0; + top = 20.0; + right = 30.0; + bottom = 40.0; + QCOMPARE(m.left(), 10.0); + QCOMPARE(m.top(), 20.0); + QCOMPARE(m.right(), 30.0); + QCOMPARE(m.bottom(), 40.0); + } +} + QTEST_APPLESS_MAIN(tst_QMargins) #include "tst_qmargins.moc" |