summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/dialogs
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2023-08-07 14:42:55 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2023-08-07 21:56:10 +0000
commite0c1ae09fd79160015c8399980d2bec4df2273df (patch)
tree1c8b7f2acd829f47247a56307c10a351c7364c12 /tests/auto/widgets/dialogs
parent4741a7cd1c58dbb2adb85e7645ad552994b760ff (diff)
tst_QWizard: port away from Q_FOREACH[5/5]: CombinationsTestData ctor
This is iterating over data member containers that are otherwise only touched in the constructor of the same object. Luckily, the initialization of these containers does not require *this, so use NSDMI and mark the containers const, proving they can never be modified and thus the protective copy of Q_FOREACH isn't required. Now that we got rid of Q_FOREACH, we can and do make them arrays for extra measure ("never use dynamically-sized containers for statically-sized data"). Unfortunately, C++ neither allows us to use "flexible array members" nor AAA in NSDMI, so grab the nettle and supply the array size manually (ever so slightly violating DRY, but the compiler will complain if we get it wrong). Task-number: QTBUG-115803 Pick-to: 6.6 6.5 Change-Id: Ibb2ce48b6dcaf2e9d3d1a625602f3865d280c7c6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/widgets/dialogs')
-rw-r--r--tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp
index d4d36bb84f..a7d4992c07 100644
--- a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp
+++ b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp
@@ -1814,8 +1814,16 @@ public:
class CombinationsTestData
{
TestGroup testGroup;
- QList<QSharedPointer<Operation>> pageOps;
- QList<QSharedPointer<Operation>> styleOps;
+ const QSharedPointer<Operation> pageOps[3] = {
+ SetPage::create(0),
+ SetPage::create(1),
+ SetPage::create(2),
+ };
+ const QSharedPointer<Operation> styleOps[3] = {
+ SetStyle::create(QWizard::ClassicStyle),
+ SetStyle::create(QWizard::ModernStyle),
+ SetStyle::create(QWizard::MacStyle),
+ };
QMap<bool, QList<QSharedPointer<Operation>>> setAllOptions;
public:
@@ -1824,11 +1832,8 @@ public:
QTest::addColumn<bool>("ref");
QTest::addColumn<bool>("testEquality");
QTest::addColumn<QList<QSharedPointer<Operation>>>("operations");
- pageOps << SetPage::create(0) << SetPage::create(1) << SetPage::create(2);
- styleOps << SetStyle::create(QWizard::ClassicStyle) << SetStyle::create(QWizard::ModernStyle)
- << SetStyle::create(QWizard::MacStyle);
-#define SETPAGE(page) pageOps.at(page)
-#define SETSTYLE(style) styleOps.at(style)
+#define SETPAGE(page) pageOps[page]
+#define SETSTYLE(style) styleOps[style]
#define OPT(option, on) OptionInfo::instance().operation(option, on)
#define CLROPT(option) OPT(option, false)
#define SETOPT(option) OPT(option, true)
@@ -1906,7 +1911,7 @@ public:
testGroup.createTestRows();
}
- foreach (const QSharedPointer<Operation> &pageOp, pageOps) {
+ for (const QSharedPointer<Operation> &pageOp : pageOps) {
testGroup.reset("testAll 4.1");
testGroup.add() << pageOp;
testGroup.add() << pageOp << pageOp;
@@ -1929,7 +1934,7 @@ public:
}
}
- foreach (const QSharedPointer<Operation> &styleOp, styleOps) {
+ for (const QSharedPointer<Operation> &styleOp : styleOps) {
testGroup.reset("testAll 5.1");
testGroup.add() << styleOp;
testGroup.add() << styleOp << styleOp;
@@ -1952,8 +1957,8 @@ public:
}
}
- foreach (const QSharedPointer<Operation> &pageOp, pageOps) {
- foreach (const QSharedPointer<Operation> &styleOp, styleOps) {
+ for (const QSharedPointer<Operation> &pageOp : pageOps) {
+ for (const QSharedPointer<Operation> &styleOp : styleOps) {
testGroup.reset("testAll 6.1");
testGroup.add() << pageOp;