diff --git a/tests/benchmarks/corelib/tools/qlist/main.cpp b/tests/benchmarks/corelib/tools/qlist/main.cpp index b65d02b7503..cede305c4f0 100644 --- a/tests/benchmarks/corelib/tools/qlist/main.cpp +++ b/tests/benchmarks/corelib/tools/qlist/main.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2020 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -134,11 +134,11 @@ class tst_QList: public QObject private Q_SLOTS: void removeAll_primitive_data(); - void removeAll_primitive(); - void removeAll_movable_data(); - void removeAll_movable(); - void removeAll_complex_data(); - void removeAll_complex(); + void removeAll_primitive() { removeAll_impl(); } + void removeAll_movable_data() { removeAll_primitive_data(); } + void removeAll_movable() { removeAll_impl(); } + void removeAll_complex_data() { removeAll_primitive_data(); } + void removeAll_complex() { removeAll_impl(); } // append 1 element: void appendOne_int_data() const { commonBenchmark_data(); } @@ -248,6 +248,9 @@ private Q_SLOTS: void removeFirstSpecial_QString() const { removeFirstSpecial_impl(); } private: + template + void removeAll_impl() const; + template void commonBenchmark_data() const; @@ -277,9 +280,13 @@ private: }; template -void removeAll_test(const QList &i10, ushort valueToRemove, int itemsToRemove) +void tst_QList::removeAll_impl() const { - bool isComplex = QTypeInfo::isComplex; + QFETCH(QList, i10); + QFETCH(int, itemsToRemove); + + constexpr int valueToRemove = 5; + constexpr bool isComplex = QTypeInfo::isComplex; MyBase::errorCount = 0; MyBase::liveCount = 0; @@ -311,63 +318,26 @@ void removeAll_test(const QList &i10, ushort valueToRemove, int itemsToRemo QCOMPARE(l.size() + removedCount, list.size()); QVERIFY(!l.contains(valueToRemove)); - QCOMPARE(MyBase::liveCount, isComplex ? l.isDetached() ? list.size() + l.size() + 1 : list.size() + 1 : 1); - QCOMPARE(MyBase::copyCount, isComplex ? l.isDetached() ? list.size() + l.size() : list.size() : 0); + QCOMPARE(MyBase::liveCount, + isComplex ? l.isDetached() ? list.size() + l.size() + 1 : list.size() + 1 : 1); + QCOMPARE(MyBase::copyCount, + isComplex ? l.isDetached() ? list.size() + l.size() : list.size() : 0); } if (isComplex) QCOMPARE(MyBase::errorCount, 0); } - void tst_QList::removeAll_primitive_data() { qRegisterMetaType >(); QTest::addColumn >("i10"); - QTest::addColumn("valueToRemove"); QTest::addColumn("itemsToRemove"); - QTest::newRow("0%") << (QList() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0) << 5 << 0; - QTest::newRow("10%") << (QList() << 0 << 0 << 0 << 0 << 5 << 0 << 0 << 0 << 0 << 0) << 5 << 1; - QTest::newRow("90%") << (QList() << 5 << 5 << 5 << 5 << 0 << 5 << 5 << 5 << 5 << 5) << 5 << 9; - QTest::newRow("100%") << (QList() << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5) << 5 << 10; -} - -void tst_QList::removeAll_primitive() -{ - QFETCH(QList, i10); - QFETCH(int, valueToRemove); - QFETCH(int, itemsToRemove); - - removeAll_test(i10, valueToRemove, itemsToRemove); -} - -void tst_QList::removeAll_movable_data() -{ - removeAll_primitive_data(); -} - -void tst_QList::removeAll_movable() -{ - QFETCH(QList, i10); - QFETCH(int, valueToRemove); - QFETCH(int, itemsToRemove); - - removeAll_test(i10, valueToRemove, itemsToRemove); -} - -void tst_QList::removeAll_complex_data() -{ - removeAll_primitive_data(); -} - -void tst_QList::removeAll_complex() -{ - QFETCH(QList, i10); - QFETCH(int, valueToRemove); - QFETCH(int, itemsToRemove); - - removeAll_test(i10, valueToRemove, itemsToRemove); + QTest::newRow("0%") << QList(10, 0) << 0; + QTest::newRow("10%") << (QList() << 0 << 0 << 0 << 0 << 5 << 0 << 0 << 0 << 0 << 0) << 1; + QTest::newRow("90%") << (QList() << 5 << 5 << 5 << 5 << 0 << 5 << 5 << 5 << 5 << 5) << 9; + QTest::newRow("100%") << QList(10, 5) << 10; } template