From 0e22001a3bb070d4e9956e89543ec0e5ac6f23f8 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Wed, 24 Feb 2021 19:44:09 +0100 Subject: Add more support for structured bindings After QPoint(F), it's now the time of QSize(F) and QVectorND, which can be unambiguously decomposed. [ChangeLog][QtCore][QSize] QSize is now usable in a structured binding declaration. [ChangeLog][QtCore][QSizeF] QSizeF is now usable in a structured binding declaration. [ChangeLog][QtGui][QVector2D] QVector2D is now usable in a structured binding declaration. [ChangeLog][QtGui][QVector3D] QVector3D is now usable in a structured binding declaration. [ChangeLog][QtGui][QVector4D] QVector4D is now usable in a structured binding declaration. Change-Id: I67bb152f4210f2be27607179cd2ec522174cc483 Reviewed-by: Volker Hilsheimer --- tests/auto/corelib/tools/qsize/tst_qsize.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tests/auto/corelib/tools/qsize') diff --git a/tests/auto/corelib/tools/qsize/tst_qsize.cpp b/tests/auto/corelib/tools/qsize/tst_qsize.cpp index 1bac2bd19b..83b4f1bd34 100644 --- a/tests/auto/corelib/tools/qsize/tst_qsize.cpp +++ b/tests/auto/corelib/tools/qsize/tst_qsize.cpp @@ -49,6 +49,8 @@ private slots: void transpose_data(); void transpose(); + + void structuredBinding(); }; // Testing get/set functions @@ -250,5 +252,26 @@ void tst_QSize::transpose() QCOMPARE(input1 , expected); } +void tst_QSize::structuredBinding() +{ + { + QSize size(10, 20); + auto [width, height] = size; + QCOMPARE(width, 10); + QCOMPARE(height, 20); + } + { + QSize size(30, 40); + auto &[width, height] = size; + QCOMPARE(width, 30); + QCOMPARE(height, 40); + + width = 100; + height = 200; + QCOMPARE(size.width(), 100); + QCOMPARE(size.height(), 200); + } +} + QTEST_APPLESS_MAIN(tst_QSize) #include "tst_qsize.moc" -- cgit v1.2.3