summaryrefslogtreecommitdiffstats
path: root/tests/auto/concurrent
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/concurrent')
-rw-r--r--tests/auto/concurrent/CMakeLists.txt9
-rw-r--r--tests/auto/concurrent/qtconcurrentfilter/CMakeLists.txt11
-rw-r--r--tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp514
-rw-r--r--tests/auto/concurrent/qtconcurrentfiltermapgenerated/CMakeLists.txt11
-rw-r--r--tests/auto/concurrent/qtconcurrentfiltermapgenerated/generation_helpers.h34
-rw-r--r--tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/function_signature.py27
-rw-r--r--tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generate_excel.py27
-rw-r--r--tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generate_gui.py27
-rw-r--r--tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generate_testcase.py27
-rw-r--r--tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generator_main.py27
-rw-r--r--tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/helpers.py27
-rw-r--r--tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/option_management.py27
-rw-r--r--tests/auto/concurrent/qtconcurrentfiltermapgenerated/tst_qtconcurrent_selected_tests.cpp29
-rw-r--r--tests/auto/concurrent/qtconcurrentfiltermapgenerated/tst_qtconcurrentfiltermapgenerated.cpp29
-rw-r--r--tests/auto/concurrent/qtconcurrentfiltermapgenerated/tst_qtconcurrentfiltermapgenerated.h29
-rw-r--r--tests/auto/concurrent/qtconcurrentiteratekernel/CMakeLists.txt11
-rw-r--r--tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp34
-rw-r--r--tests/auto/concurrent/qtconcurrentmap/CMakeLists.txt11
-rw-r--r--tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp501
-rw-r--r--tests/auto/concurrent/qtconcurrentmedian/CMakeLists.txt11
-rw-r--r--tests/auto/concurrent/qtconcurrentmedian/tst_qtconcurrentmedian.cpp34
-rw-r--r--tests/auto/concurrent/qtconcurrentrun/CMakeLists.txt12
-rw-r--r--tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp139
-rw-r--r--tests/auto/concurrent/qtconcurrenttask/CMakeLists.txt11
-rw-r--r--tests/auto/concurrent/qtconcurrenttask/tst_qtconcurrenttask.cpp31
-rw-r--r--tests/auto/concurrent/qtconcurrentthreadengine/CMakeLists.txt11
-rw-r--r--tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp51
-rw-r--r--tests/auto/concurrent/testhelper_functions.h38
28 files changed, 977 insertions, 773 deletions
diff --git a/tests/auto/concurrent/CMakeLists.txt b/tests/auto/concurrent/CMakeLists.txt
index dce6effa55..0088ebfcf6 100644
--- a/tests/auto/concurrent/CMakeLists.txt
+++ b/tests/auto/concurrent/CMakeLists.txt
@@ -1,10 +1,13 @@
-# Generated from concurrent.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
add_subdirectory(qtconcurrentfilter)
add_subdirectory(qtconcurrentiteratekernel)
add_subdirectory(qtconcurrentfiltermapgenerated)
add_subdirectory(qtconcurrentmap)
add_subdirectory(qtconcurrentmedian)
-add_subdirectory(qtconcurrentrun)
+if(NOT INTEGRITY)
+ add_subdirectory(qtconcurrentrun)
+ add_subdirectory(qtconcurrenttask)
+endif()
add_subdirectory(qtconcurrentthreadengine)
-add_subdirectory(qtconcurrenttask)
diff --git a/tests/auto/concurrent/qtconcurrentfilter/CMakeLists.txt b/tests/auto/concurrent/qtconcurrentfilter/CMakeLists.txt
index f81bed27d6..3c00393d39 100644
--- a/tests/auto/concurrent/qtconcurrentfilter/CMakeLists.txt
+++ b/tests/auto/concurrent/qtconcurrentfilter/CMakeLists.txt
@@ -1,12 +1,19 @@
-# Generated from qtconcurrentfilter.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qtconcurrentfilter Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qtconcurrentfilter LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qtconcurrentfilter
SOURCES
tst_qtconcurrentfilter.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Concurrent
)
diff --git a/tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp b/tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp
index 6c27884977..e19a596d5d 100644
--- a/tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp
+++ b/tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp
@@ -1,34 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <qtconcurrentfilter.h>
#include <QCoreApplication>
#include <QList>
#include <QTest>
+#include <QSet>
#include "../testhelper_functions.h"
@@ -51,6 +27,7 @@ private slots:
void filteredReducedInitialValueThreadPool();
void filteredReducedInitialValueWithMoveOnlyCallables();
void filteredReducedDifferentTypeInitialValue();
+ void filteredReduceOptionConvertableToResultType();
void resultAt();
void incrementalResults();
void noDetach();
@@ -102,6 +79,19 @@ void tst_QtConcurrentFilter::filter()
CHECK_FAIL("member");
testFilter(intList, intListEven, lambdaIsEven);
CHECK_FAIL("lambda");
+
+ // non-template sequences
+ {
+
+ NonTemplateSequence list({ 1, 2, 3, 4 });
+ QtConcurrent::filter(list, keepEvenNumbers).waitForFinished();
+ QCOMPARE(list, NonTemplateSequence({ 2, 4 }));
+ }
+ {
+ NonTemplateSequence list({ 1, 2, 3, 4 });
+ QtConcurrent::blockingFilter(list, keepEvenNumbers);
+ QCOMPARE(list, NonTemplateSequence({ 2, 4 }));
+ }
}
static QSemaphore semaphore(1);
@@ -179,6 +169,19 @@ void tst_QtConcurrentFilter::filterThreadPool()
CHECK_FAIL("function");
testFilterThreadPool(&pool, intList, intListEven, lambdaIsOdd);
CHECK_FAIL("lambda");
+
+ // non-template sequences
+ {
+
+ NonTemplateSequence list({ 1, 2, 3, 4 });
+ QtConcurrent::filter(list, keepEvenIntegers).waitForFinished();
+ QCOMPARE(list, NonTemplateSequence({ 2, 4 }));
+ }
+ {
+ NonTemplateSequence list({ 1, 2, 3, 4 });
+ QtConcurrent::blockingFilter(list, keepEvenIntegers);
+ QCOMPARE(list, NonTemplateSequence({ 2, 4 }));
+ }
}
void tst_QtConcurrentFilter::filterWithMoveOnlyCallable()
@@ -254,6 +257,18 @@ void tst_QtConcurrentFilter::filtered()
testFiltered(intList, intListEven, lambdaIsEven);
CHECK_FAIL("lambda");
+ // non-template sequences
+ {
+ NonTemplateSequence list({ 1, 2, 3, 4 });
+ auto future = QtConcurrent::filtered(list, keepEvenIntegers);
+ QCOMPARE(future.results(), QList({ 2, 4 }));
+ }
+ {
+ NonTemplateSequence list({ 1, 2, 3, 4 });
+ auto result = QtConcurrent::blockingFiltered(list, keepEvenIntegers);
+ QCOMPARE(result, NonTemplateSequence({ 2, 4 }));
+ }
+
{
// rvalue sequences
auto future = QtConcurrent::filtered(std::vector { 1, 2, 3, 4 }, keepEvenIntegers);
@@ -329,6 +344,18 @@ void tst_QtConcurrentFilter::filteredThreadPool()
testFilteredThreadPool(&pool, intList, intListEven, lambdaIsOdd);
CHECK_FAIL("lambda");
+ // non-template sequences
+ {
+ NonTemplateSequence list({ 1, 2, 3, 4 });
+ auto future = QtConcurrent::filtered(&pool, list, keepEvenIntegers);
+ QCOMPARE(future.results(), QList({ 2, 4 }));
+ }
+ {
+ NonTemplateSequence list({ 1, 2, 3, 4 });
+ auto result = QtConcurrent::blockingFiltered(&pool, list, keepEvenIntegers);
+ QCOMPARE(result, NonTemplateSequence({ 2, 4 }));
+ }
+
{
// rvalue sequences
auto future = QtConcurrent::filtered(&pool, std::vector { 1, 2, 3, 4 }, keepEvenIntegers);
@@ -410,23 +437,47 @@ void testFilteredReduced(const QList<SourceObject> &sourceObjectList,
FilterObject filterObject,
ReduceObject reduceObject)
{
- const ResultObject result1 = QtConcurrent::filteredReduced<ResultObject>(
- sourceObjectList, filterObject, reduceObject).result();
- QCOMPARE(result1, expectedResult);
-
- const ResultObject result2 = QtConcurrent::filteredReduced<ResultObject>(
- sourceObjectList.constBegin(), sourceObjectList.constEnd(),
- filterObject, reduceObject).result();
- QCOMPARE(result2, expectedResult);
-
- const ResultObject result3 = QtConcurrent::blockingFilteredReduced<ResultObject>(
- sourceObjectList, filterObject, reduceObject);
- QCOMPARE(result3, expectedResult);
+ // Result type is passed explicitly
+ {
+ const ResultObject result1 = QtConcurrent::filteredReduced<ResultObject>(
+ sourceObjectList, filterObject, reduceObject).result();
+ QCOMPARE(result1, expectedResult);
+
+ const ResultObject result2 = QtConcurrent::filteredReduced<ResultObject>(
+ sourceObjectList.constBegin(), sourceObjectList.constEnd(),
+ filterObject, reduceObject).result();
+ QCOMPARE(result2, expectedResult);
+
+ const ResultObject result3 = QtConcurrent::blockingFilteredReduced<ResultObject>(
+ sourceObjectList, filterObject, reduceObject);
+ QCOMPARE(result3, expectedResult);
+
+ const ResultObject result4 = QtConcurrent::blockingFilteredReduced<ResultObject>(
+ sourceObjectList.constBegin(), sourceObjectList.constEnd(),
+ filterObject, reduceObject);
+ QCOMPARE(result4, expectedResult);
+ }
- const ResultObject result4 = QtConcurrent::blockingFilteredReduced<ResultObject>(
- sourceObjectList.constBegin(), sourceObjectList.constEnd(),
- filterObject, reduceObject);
- QCOMPARE(result4, expectedResult);
+ // Result type is deduced
+ {
+ const ResultObject result1 = QtConcurrent::filteredReduced(
+ sourceObjectList, filterObject, reduceObject).result();
+ QCOMPARE(result1, expectedResult);
+
+ const ResultObject result2 = QtConcurrent::filteredReduced(
+ sourceObjectList.constBegin(), sourceObjectList.constEnd(),
+ filterObject, reduceObject).result();
+ QCOMPARE(result2, expectedResult);
+
+ const ResultObject result3 = QtConcurrent::blockingFilteredReduced(
+ sourceObjectList, filterObject, reduceObject);
+ QCOMPARE(result3, expectedResult);
+
+ const ResultObject result4 = QtConcurrent::blockingFilteredReduced(
+ sourceObjectList.constBegin(), sourceObjectList.constEnd(),
+ filterObject, reduceObject);
+ QCOMPARE(result4, expectedResult);
+ }
}
template <typename SourceObject,
@@ -537,6 +588,18 @@ void tst_QtConcurrentFilter::filteredReduced()
testFilteredReduced(intList, intSum, lambdaIsEven, lambdaIntSumReduce);
CHECK_FAIL("lambda-lambda");
+ // non-template sequences
+ {
+ NonTemplateSequence list({ 1, 2, 3, 4 });
+ auto future = QtConcurrent::filteredReduced(list, keepEvenIntegers, intSumReduce);
+ QCOMPARE(future.result(), intSum);
+ }
+ {
+ NonTemplateSequence list({ 1, 2, 3, 4 });
+ auto result = QtConcurrent::blockingFilteredReduced(list, keepEvenIntegers, intSumReduce);
+ QCOMPARE(result, intSum);
+ }
+
{
// rvalue sequences
auto future = QtConcurrent::filteredReduced(std::vector { 1, 2, 3, 4 }, keepEvenIntegers,
@@ -570,28 +633,57 @@ void testFilteredReducedThreadPool(QThreadPool *pool,
FilterObject filterObject,
ReduceObject reduceObject)
{
- const ResultObject result1 = QtConcurrent::filteredReduced<ResultObject>(
- pool, sourceObjectList, filterObject, reduceObject).result();
- QCOMPARE(result1, expectedResult);
- QCOMPARE(threadCount(), 1); // ensure the only one thread was working
-
- const ResultObject result2 =
- QtConcurrent::filteredReduced<ResultObject>(pool, sourceObjectList.constBegin(),
- sourceObjectList.constEnd(), filterObject,
- reduceObject).result();
- QCOMPARE(result2, expectedResult);
- QCOMPARE(threadCount(), 1); // ensure the only one thread was working
-
- const ResultObject result3 = QtConcurrent::blockingFilteredReduced<ResultObject>(
- pool, sourceObjectList, filterObject, reduceObject);
- QCOMPARE(result3, expectedResult);
- QCOMPARE(threadCount(), 1); // ensure the only one thread was working
+ // Result type is passed explicitly
+ {
+ const ResultObject result1 = QtConcurrent::filteredReduced<ResultObject>(
+ pool, sourceObjectList, filterObject, reduceObject).result();
+ QCOMPARE(result1, expectedResult);
+ QCOMPARE(threadCount(), 1); // ensure the only one thread was working
+
+ const ResultObject result2 =
+ QtConcurrent::filteredReduced<ResultObject>(pool, sourceObjectList.constBegin(),
+ sourceObjectList.constEnd(), filterObject,
+ reduceObject).result();
+ QCOMPARE(result2, expectedResult);
+ QCOMPARE(threadCount(), 1); // ensure the only one thread was working
+
+ const ResultObject result3 = QtConcurrent::blockingFilteredReduced<ResultObject>(
+ pool, sourceObjectList, filterObject, reduceObject);
+ QCOMPARE(result3, expectedResult);
+ QCOMPARE(threadCount(), 1); // ensure the only one thread was working
+
+ const ResultObject result4 = QtConcurrent::blockingFilteredReduced<ResultObject>(
+ pool, sourceObjectList.constBegin(), sourceObjectList.constEnd(),
+ filterObject, reduceObject);
+ QCOMPARE(result4, expectedResult);
+ QCOMPARE(threadCount(), 1); // ensure the only one thread was working
+ }
- const ResultObject result4 = QtConcurrent::blockingFilteredReduced<ResultObject>(
- pool, sourceObjectList.constBegin(), sourceObjectList.constEnd(),
- filterObject, reduceObject);
- QCOMPARE(result4, expectedResult);
- QCOMPARE(threadCount(), 1); // ensure the only one thread was working
+ // Result type is deduced
+ {
+ const ResultObject result1 = QtConcurrent::filteredReduced(
+ pool, sourceObjectList, filterObject, reduceObject).result();
+ QCOMPARE(result1, expectedResult);
+ QCOMPARE(threadCount(), 1); // ensure the only one thread was working
+
+ const ResultObject result2 =
+ QtConcurrent::filteredReduced(pool, sourceObjectList.constBegin(),
+ sourceObjectList.constEnd(), filterObject,
+ reduceObject).result();
+ QCOMPARE(result2, expectedResult);
+ QCOMPARE(threadCount(), 1); // ensure the only one thread was working
+
+ const ResultObject result3 = QtConcurrent::blockingFilteredReduced(
+ pool, sourceObjectList, filterObject, reduceObject);
+ QCOMPARE(result3, expectedResult);
+ QCOMPARE(threadCount(), 1); // ensure the only one thread was working
+
+ const ResultObject result4 = QtConcurrent::blockingFilteredReduced(
+ pool, sourceObjectList.constBegin(), sourceObjectList.constEnd(),
+ filterObject, reduceObject);
+ QCOMPARE(result4, expectedResult);
+ QCOMPARE(threadCount(), 1); // ensure the only one thread was working
+ }
}
void tst_QtConcurrentFilter::filteredReducedThreadPool()
@@ -636,6 +728,19 @@ void tst_QtConcurrentFilter::filteredReducedThreadPool()
testFilteredReducedThreadPool(&pool, intList, intSum, lambdaIsOdd, lambdaSumReduce);
CHECK_FAIL("lambda-lambda");
+ // non-template sequences
+ {
+ NonTemplateSequence list({ 1, 2, 3, 4 });
+ auto future = QtConcurrent::filteredReduced(&pool, list, keepOddIntegers, intSumReduce);
+ QCOMPARE(future.result(), intSum);
+ }
+ {
+ NonTemplateSequence list({ 1, 2, 3, 4 });
+ auto result =
+ QtConcurrent::blockingFilteredReduced(&pool, list, keepOddIntegers, intSumReduce);
+ QCOMPARE(result, intSum);
+ }
+
{
// rvalue sequences
auto future = QtConcurrent::filteredReduced(&pool, std::vector { 1, 2, 3, 4 },
@@ -666,50 +771,50 @@ void tst_QtConcurrentFilter::filteredReducedWithMoveOnlyCallables()
const auto sum = 6;
{
const auto result =
- QtConcurrent::filteredReduced<int>(intList, KeepEvenIntegersMoveOnly(),
- IntSumReduceMoveOnly()).result();
+ QtConcurrent::filteredReduced(intList, KeepEvenIntegersMoveOnly(),
+ IntSumReduceMoveOnly()).result();
QCOMPARE(result, sum);
}
{
const auto result =
- QtConcurrent::filteredReduced<int>(intList.begin(), intList.end(),
- KeepEvenIntegersMoveOnly(),
- IntSumReduceMoveOnly()).result();
+ QtConcurrent::filteredReduced(intList.begin(), intList.end(),
+ KeepEvenIntegersMoveOnly(),
+ IntSumReduceMoveOnly()).result();
QCOMPARE(result, sum);
}
{
- const auto result = QtConcurrent::blockingFilteredReduced<int>(
- intList, KeepEvenIntegersMoveOnly(), IntSumReduceMoveOnly());
+ const auto result = QtConcurrent::blockingFilteredReduced(
+ intList, KeepEvenIntegersMoveOnly(), IntSumReduceMoveOnly());
QCOMPARE(result, sum);
}
{
- const auto result = QtConcurrent::blockingFilteredReduced<int>(
- intList.begin(), intList.end(), KeepEvenIntegersMoveOnly(), IntSumReduceMoveOnly());
+ const auto result = QtConcurrent::blockingFilteredReduced(
+ intList.begin(), intList.end(), KeepEvenIntegersMoveOnly(), IntSumReduceMoveOnly());
QCOMPARE(result, sum);
}
QThreadPool pool;
{
const auto result =
- QtConcurrent::filteredReduced<int>(&pool, intList, KeepEvenIntegersMoveOnly(),
- IntSumReduceMoveOnly()).result();
+ QtConcurrent::filteredReduced(&pool, intList, KeepEvenIntegersMoveOnly(),
+ IntSumReduceMoveOnly()).result();
QCOMPARE(result, sum);
}
{
- const auto result = QtConcurrent::filteredReduced<int>(
- &pool, intList.begin(), intList.end(),
- KeepEvenIntegersMoveOnly(), IntSumReduceMoveOnly()).result();
+ const auto result = QtConcurrent::filteredReduced(
+ &pool, intList.begin(), intList.end(),
+ KeepEvenIntegersMoveOnly(), IntSumReduceMoveOnly()).result();
QCOMPARE(result, sum);
}
{
- const auto result = QtConcurrent::blockingFilteredReduced<int>(
- &pool, intList, KeepEvenIntegersMoveOnly(), IntSumReduceMoveOnly());
+ const auto result = QtConcurrent::blockingFilteredReduced(
+ &pool, intList, KeepEvenIntegersMoveOnly(), IntSumReduceMoveOnly());
QCOMPARE(result, sum);
}
{
- const auto result = QtConcurrent::blockingFilteredReduced<int>(
- &pool, intList.begin(), intList.end(), KeepEvenIntegersMoveOnly(),
- IntSumReduceMoveOnly());
+ const auto result = QtConcurrent::blockingFilteredReduced(
+ &pool, intList.begin(), intList.end(), KeepEvenIntegersMoveOnly(),
+ IntSumReduceMoveOnly());
QCOMPARE(result, sum);
}
}
@@ -774,23 +879,47 @@ void testFilteredReducedInitialValue(const QList<SourceObject> &sourceObjectList
ReduceObject reduceObject,
InitialObject &&initialObject)
{
- const ResultObject result1 = QtConcurrent::filteredReduced<ResultObject>(
- sourceObjectList, filterObject, reduceObject, initialObject).result();
- QCOMPARE(result1, expectedResult);
-
- const ResultObject result2 = QtConcurrent::filteredReduced<ResultObject>(
- sourceObjectList.constBegin(), sourceObjectList.constEnd(),
- filterObject, reduceObject, initialObject).result();
- QCOMPARE(result2, expectedResult);
-
- const ResultObject result3 = QtConcurrent::blockingFilteredReduced<ResultObject>(
- sourceObjectList, filterObject, reduceObject, initialObject);
- QCOMPARE(result3, expectedResult);
+ // Result type is passed explicitly
+ {
+ const ResultObject result1 = QtConcurrent::filteredReduced<ResultObject>(
+ sourceObjectList, filterObject, reduceObject, initialObject).result();
+ QCOMPARE(result1, expectedResult);
+
+ const ResultObject result2 = QtConcurrent::filteredReduced<ResultObject>(
+ sourceObjectList.constBegin(), sourceObjectList.constEnd(),
+ filterObject, reduceObject, initialObject).result();
+ QCOMPARE(result2, expectedResult);
+
+ const ResultObject result3 = QtConcurrent::blockingFilteredReduced<ResultObject>(
+ sourceObjectList, filterObject, reduceObject, initialObject);
+ QCOMPARE(result3, expectedResult);
+
+ const ResultObject result4 = QtConcurrent::blockingFilteredReduced<ResultObject>(
+ sourceObjectList.constBegin(), sourceObjectList.constEnd(),
+ filterObject, reduceObject, initialObject);
+ QCOMPARE(result4, expectedResult);
+ }
- const ResultObject result4 = QtConcurrent::blockingFilteredReduced<ResultObject>(
- sourceObjectList.constBegin(), sourceObjectList.constEnd(),
- filterObject, reduceObject, initialObject);
- QCOMPARE(result4, expectedResult);
+ // Result type is deduced
+ {
+ const ResultObject result1 = QtConcurrent::filteredReduced(
+ sourceObjectList, filterObject, reduceObject, initialObject).result();
+ QCOMPARE(result1, expectedResult);
+
+ const ResultObject result2 = QtConcurrent::filteredReduced(
+ sourceObjectList.constBegin(), sourceObjectList.constEnd(),
+ filterObject, reduceObject, initialObject).result();
+ QCOMPARE(result2, expectedResult);
+
+ const ResultObject result3 = QtConcurrent::blockingFilteredReduced(
+ sourceObjectList, filterObject, reduceObject, initialObject);
+ QCOMPARE(result3, expectedResult);
+
+ const ResultObject result4 = QtConcurrent::blockingFilteredReduced(
+ sourceObjectList.constBegin(), sourceObjectList.constEnd(),
+ filterObject, reduceObject, initialObject);
+ QCOMPARE(result4, expectedResult);
+ }
}
template <typename SourceObject,
@@ -910,6 +1039,20 @@ void tst_QtConcurrentFilter::filteredReducedInitialValue()
lambdaIntSumReduce, intInitial);
CHECK_FAIL("lambda-lambda");
+ // non-template sequences
+ {
+ NonTemplateSequence list({ 1, 2, 3, 4 });
+ auto future =
+ QtConcurrent::filteredReduced(list, keepEvenIntegers, intSumReduce, intInitial);
+ QCOMPARE(future.result(), intSum);
+ }
+ {
+ NonTemplateSequence list({ 1, 2, 3, 4 });
+ auto result = QtConcurrent::blockingFilteredReduced(list, keepEvenIntegers, intSumReduce,
+ intInitial);
+ QCOMPARE(result, intSum);
+ }
+
{
// rvalue sequences
auto future = QtConcurrent::filteredReduced(std::vector { 1, 2, 3, 4 }, keepEvenIntegers,
@@ -945,28 +1088,57 @@ void testFilteredReducedInitialValueThreadPool(QThreadPool *pool,
ReduceObject reduceObject,
InitialObject &&initialObject)
{
- const ResultObject result1 = QtConcurrent::filteredReduced<ResultObject>(
- pool, sourceObjectList, filterObject, reduceObject, initialObject).result();
- QCOMPARE(result1, expectedResult);
- QCOMPARE(threadCount(), 1); // ensure the only one thread was working
-
- const ResultObject result2 =
- QtConcurrent::filteredReduced<ResultObject>(pool, sourceObjectList.constBegin(),
- sourceObjectList.constEnd(), filterObject,
- reduceObject, initialObject).result();
- QCOMPARE(result2, expectedResult);
- QCOMPARE(threadCount(), 1); // ensure the only one thread was working
-
- const ResultObject result3 = QtConcurrent::blockingFilteredReduced<ResultObject>(
- pool, sourceObjectList, filterObject, reduceObject, initialObject);
- QCOMPARE(result3, expectedResult);
- QCOMPARE(threadCount(), 1); // ensure the only one thread was working
+ // Result type is passed explicitly
+ {
+ const ResultObject result1 = QtConcurrent::filteredReduced<ResultObject>(
+ pool, sourceObjectList, filterObject, reduceObject, initialObject).result();
+ QCOMPARE(result1, expectedResult);
+ QCOMPARE(threadCount(), 1); // ensure the only one thread was working
+
+ const ResultObject result2 =
+ QtConcurrent::filteredReduced<ResultObject>(pool, sourceObjectList.constBegin(),
+ sourceObjectList.constEnd(), filterObject,
+ reduceObject, initialObject).result();
+ QCOMPARE(result2, expectedResult);
+ QCOMPARE(threadCount(), 1); // ensure the only one thread was working
+
+ const ResultObject result3 = QtConcurrent::blockingFilteredReduced<ResultObject>(
+ pool, sourceObjectList, filterObject, reduceObject, initialObject);
+ QCOMPARE(result3, expectedResult);
+ QCOMPARE(threadCount(), 1); // ensure the only one thread was working
+
+ const ResultObject result4 = QtConcurrent::blockingFilteredReduced<ResultObject>(
+ pool, sourceObjectList.constBegin(), sourceObjectList.constEnd(),
+ filterObject, reduceObject, initialObject);
+ QCOMPARE(result4, expectedResult);
+ QCOMPARE(threadCount(), 1); // ensure the only one thread was working
+ }
- const ResultObject result4 = QtConcurrent::blockingFilteredReduced<ResultObject>(
- pool, sourceObjectList.constBegin(), sourceObjectList.constEnd(),
- filterObject, reduceObject, initialObject);
- QCOMPARE(result4, expectedResult);
- QCOMPARE(threadCount(), 1); // ensure the only one thread was working
+ // Result type is deduced
+ {
+ const ResultObject result1 = QtConcurrent::filteredReduced(
+ pool, sourceObjectList, filterObject, reduceObject, initialObject).result();
+ QCOMPARE(result1, expectedResult);
+ QCOMPARE(threadCount(), 1); // ensure the only one thread was working
+
+ const ResultObject result2 =
+ QtConcurrent::filteredReduced(pool, sourceObjectList.constBegin(),
+ sourceObjectList.constEnd(), filterObject,
+ reduceObject, initialObject).result();
+ QCOMPARE(result2, expectedResult);
+ QCOMPARE(threadCount(), 1); // ensure the only one thread was working
+
+ const ResultObject result3 = QtConcurrent::blockingFilteredReduced(
+ pool, sourceObjectList, filterObject, reduceObject, initialObject);
+ QCOMPARE(result3, expectedResult);
+ QCOMPARE(threadCount(), 1); // ensure the only one thread was working
+
+ const ResultObject result4 = QtConcurrent::blockingFilteredReduced(
+ pool, sourceObjectList.constBegin(), sourceObjectList.constEnd(),
+ filterObject, reduceObject, initialObject);
+ QCOMPARE(result4, expectedResult);
+ QCOMPARE(threadCount(), 1); // ensure the only one thread was working
+ }
}
void tst_QtConcurrentFilter::filteredReducedInitialValueThreadPool()
@@ -1021,6 +1193,20 @@ void tst_QtConcurrentFilter::filteredReducedInitialValueThreadPool()
lambdaSumReduce, intInitial);
CHECK_FAIL("lambda-lambda");
+ // non-template sequences
+ {
+ NonTemplateSequence list({ 1, 2, 3, 4 });
+ auto future =
+ QtConcurrent::filteredReduced(list, keepOddIntegers, intSumReduce, intInitial);
+ QCOMPARE(future.result(), intSum);
+ }
+ {
+ NonTemplateSequence list({ 1, 2, 3, 4 });
+ auto result = QtConcurrent::blockingFilteredReduced(list, keepOddIntegers, intSumReduce,
+ intInitial);
+ QCOMPARE(result, intSum);
+ }
+
{
// rvalue sequences
auto future = QtConcurrent::filteredReduced(&pool, std::vector { 1, 2, 3, 4 },
@@ -1053,52 +1239,52 @@ void tst_QtConcurrentFilter::filteredReducedInitialValueWithMoveOnlyCallables()
const auto sum = 16;
{
const auto result =
- QtConcurrent::filteredReduced<int>(intList, KeepEvenIntegersMoveOnly(),
- IntSumReduceMoveOnly(), initial).result();
+ QtConcurrent::filteredReduced(intList, KeepEvenIntegersMoveOnly(),
+ IntSumReduceMoveOnly(), initial).result();
QCOMPARE(result, sum);
}
{
const auto result =
- QtConcurrent::filteredReduced<int>(intList.begin(), intList.end(),
- KeepEvenIntegersMoveOnly(),
- IntSumReduceMoveOnly(), initial).result();
+ QtConcurrent::filteredReduced(intList.begin(), intList.end(),
+ KeepEvenIntegersMoveOnly(),
+ IntSumReduceMoveOnly(), initial).result();
QCOMPARE(result, sum);
}
{
- const auto result = QtConcurrent::blockingFilteredReduced<int>(
- intList, KeepEvenIntegersMoveOnly(), IntSumReduceMoveOnly(), initial);
+ const auto result = QtConcurrent::blockingFilteredReduced(
+ intList, KeepEvenIntegersMoveOnly(), IntSumReduceMoveOnly(), initial);
QCOMPARE(result, sum);
}
{
- const auto result = QtConcurrent::blockingFilteredReduced<int>(
- intList.begin(), intList.end(), KeepEvenIntegersMoveOnly(), IntSumReduceMoveOnly(),
- initial);
+ const auto result = QtConcurrent::blockingFilteredReduced(
+ intList.begin(), intList.end(), KeepEvenIntegersMoveOnly(), IntSumReduceMoveOnly(),
+ initial);
QCOMPARE(result, sum);
}
QThreadPool pool;
{
const auto result =
- QtConcurrent::filteredReduced<int>(&pool, intList, KeepEvenIntegersMoveOnly(),
- IntSumReduceMoveOnly(), initial).result();
+ QtConcurrent::filteredReduced(&pool, intList, KeepEvenIntegersMoveOnly(),
+ IntSumReduceMoveOnly(), initial).result();
QCOMPARE(result, sum);
}
{
const auto result =
- QtConcurrent::filteredReduced<int>(
+ QtConcurrent::filteredReduced(
&pool, intList.begin(), intList.end(),
KeepEvenIntegersMoveOnly(), IntSumReduceMoveOnly(), initial).result();
QCOMPARE(result, sum);
}
{
- const auto result = QtConcurrent::blockingFilteredReduced<int>(
- &pool, intList, KeepEvenIntegersMoveOnly(), IntSumReduceMoveOnly(), initial);
+ const auto result = QtConcurrent::blockingFilteredReduced(
+ &pool, intList, KeepEvenIntegersMoveOnly(), IntSumReduceMoveOnly(), initial);
QCOMPARE(result, sum);
}
{
- const auto result = QtConcurrent::blockingFilteredReduced<int>(
- &pool, intList.begin(), intList.end(), KeepEvenIntegersMoveOnly(),
- IntSumReduceMoveOnly(), initial);
+ const auto result = QtConcurrent::blockingFilteredReduced(
+ &pool, intList.begin(), intList.end(), KeepEvenIntegersMoveOnly(),
+ IntSumReduceMoveOnly(), initial);
QCOMPARE(result, sum);
}
}
@@ -1153,6 +1339,56 @@ void tst_QtConcurrentFilter::filteredReducedDifferentTypeInitialValue()
CHECK_FAIL("lambda-lambda");
}
+void tst_QtConcurrentFilter::filteredReduceOptionConvertableToResultType()
+{
+ const QList<int> intList { 1, 2, 3 };
+ const int sum = 4;
+ QThreadPool p;
+ ReduceOption ro = OrderedReduce;
+
+ // With container
+ QCOMPARE(QtConcurrent::filteredReduced(intList, keepOddIntegers, intSumReduce, ro).result(),
+ sum);
+ QCOMPARE(QtConcurrent::blockingFilteredReduced(intList, keepOddIntegers, intSumReduce, ro),
+ sum);
+
+ // With iterators
+ QCOMPARE(QtConcurrent::filteredReduced(intList.begin(), intList.end(), keepOddIntegers,
+ intSumReduce, ro).result(), sum);
+ QCOMPARE(QtConcurrent::blockingFilteredReduced(intList.begin(), intList.end(), keepOddIntegers,
+ intSumReduce, ro), sum);
+
+ // With custom QThreadPool;
+ QCOMPARE(QtConcurrent::filteredReduced(&p, intList, keepOddIntegers, intSumReduce, ro).result(),
+ sum);
+ QCOMPARE(QtConcurrent::blockingFilteredReduced(&p, intList, keepOddIntegers, intSumReduce, ro),
+ sum);
+ QCOMPARE(QtConcurrent::filteredReduced(&p, intList.begin(), intList.end(), keepOddIntegers,
+ intSumReduce, ro).result(), sum);
+ QCOMPARE(QtConcurrent::blockingFilteredReduced(&p, intList.begin(), intList.end(),
+ keepOddIntegers, intSumReduce, ro), sum);
+
+ // The same as above, but specify the result type explicitly (this invokes different overloads)
+ QCOMPARE(QtConcurrent::filteredReduced<int>(intList, keepOddIntegers, intSumReduce,
+ ro).result(), sum);
+ QCOMPARE(QtConcurrent::blockingFilteredReduced<int>(intList, keepOddIntegers, intSumReduce, ro),
+ sum);
+
+ QCOMPARE(QtConcurrent::filteredReduced<int>(intList.begin(), intList.end(), keepOddIntegers,
+ intSumReduce, ro).result(), sum);
+ QCOMPARE(QtConcurrent::blockingFilteredReduced<int>(intList.begin(), intList.end(),
+ keepOddIntegers, intSumReduce, ro), sum);
+
+ QCOMPARE(QtConcurrent::filteredReduced<int>(&p, intList, keepOddIntegers, intSumReduce,
+ ro).result(), sum);
+ QCOMPARE(QtConcurrent::blockingFilteredReduced<int>(&p, intList, keepOddIntegers, intSumReduce,
+ ro), sum);
+ QCOMPARE(QtConcurrent::filteredReduced<int>(&p, intList.begin(), intList.end(), keepOddIntegers,
+ intSumReduce, ro).result(),sum);
+ QCOMPARE(QtConcurrent::blockingFilteredReduced<int>(&p, intList.begin(), intList.end(),
+ keepOddIntegers, intSumReduce, ro), sum);
+}
+
bool filterfn(int i)
{
return (i % 2);
@@ -1198,7 +1434,7 @@ void tst_QtConcurrentFilter::incrementalResults()
QCOMPARE(future.isFinished(), true);
QCOMPARE(future.resultCount(), count / 2);
- QCOMPARE(future.results().count(), count / 2);
+ QCOMPARE(future.results().size(), count / 2);
}
void tst_QtConcurrentFilter::noDetach()
diff --git a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/CMakeLists.txt b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/CMakeLists.txt
index 1933365e86..12545702eb 100644
--- a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/CMakeLists.txt
+++ b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/CMakeLists.txt
@@ -1,13 +1,20 @@
-# Generated from qtconcurrentfiltermapgenerated.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qtconcurrentfiltermapgenerated Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qtconcurrentfiltermapgenerated LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qtconcurrentfiltermapgenerated
SOURCES
tst_qtconcurrent_selected_tests.cpp
tst_qtconcurrentfiltermapgenerated.cpp tst_qtconcurrentfiltermapgenerated.h
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Concurrent
)
diff --git a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generation_helpers.h b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generation_helpers.h
index ab8385b30b..aaa0d85002 100644
--- a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generation_helpers.h
+++ b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generation_helpers.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QTBASE_GENERATION_HELPERS_H
#define QTBASE_GENERATION_HELPERS_H
@@ -156,10 +131,7 @@ public:
bool operator()(const T &el)
{
- if (!movedFrom)
- return el.isOdd();
- else
- return -1;
+ return movedFrom || el.isOdd();
}
};
diff --git a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/function_signature.py b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/function_signature.py
index 049eea8d43..d87c8a2e9b 100644
--- a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/function_signature.py
+++ b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/function_signature.py
@@ -1,30 +1,5 @@
-#############################################################################
-#
# Copyright (C) 2020 The Qt Company Ltd.
-# Contact: https://www.qt.io/licensing/
-#
-# This file is part of the test suite of the Qt Toolkit.
-#
-# $QT_BEGIN_LICENSE:GPL-EXCEPT$
-# Commercial License Usage
-# Licensees holding valid commercial Qt licenses may use this file in
-# accordance with the commercial license agreement provided with the
-# Software or, alternatively, in accordance with the terms contained in
-# a written agreement between you and The Qt Company. For licensing terms
-# and conditions see https://www.qt.io/terms-conditions. For further
-# information use the contact form at https://www.qt.io/contact-us.
-#
-# GNU General Public License Usage
-# Alternatively, this file may be used under the terms of the GNU
-# General Public License version 3 as published by the Free Software
-# Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-# included in the packaging of this file. Please review the following
-# information to ensure the GNU General Public License requirements will
-# be met: https://www.gnu.org/licenses/gpl-3.0.html.
-#
-# $QT_END_LICENSE$
-#
-#############################################################################
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
from option_management import need_separate_output_sequence
diff --git a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generate_excel.py b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generate_excel.py
index b9aad29e5a..d05e31fc21 100644
--- a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generate_excel.py
+++ b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generate_excel.py
@@ -1,30 +1,5 @@
-#############################################################################
-#
# Copyright (C) 2020 The Qt Company Ltd.
-# Contact: https://www.qt.io/licensing/
-#
-# This file is part of the test suite of the Qt Toolkit.
-#
-# $QT_BEGIN_LICENSE:GPL-EXCEPT$
-# Commercial License Usage
-# Licensees holding valid commercial Qt licenses may use this file in
-# accordance with the commercial license agreement provided with the
-# Software or, alternatively, in accordance with the terms contained in
-# a written agreement between you and The Qt Company. For licensing terms
-# and conditions see https://www.qt.io/terms-conditions. For further
-# information use the contact form at https://www.qt.io/contact-us.
-#
-# GNU General Public License Usage
-# Alternatively, this file may be used under the terms of the GNU
-# General Public License version 3 as published by the Free Software
-# Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-# included in the packaging of this file. Please review the following
-# information to ensure the GNU General Public License requirements will
-# be met: https://www.gnu.org/licenses/gpl-3.0.html.
-#
-# $QT_END_LICENSE$
-#
-#############################################################################
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
import pandas as pd
from option_management import function_describing_options
diff --git a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generate_gui.py b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generate_gui.py
index 050ccb5839..54c1285e74 100644
--- a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generate_gui.py
+++ b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generate_gui.py
@@ -1,30 +1,5 @@
-#############################################################################
-#
# Copyright (C) 2020 The Qt Company Ltd.
-# Contact: https://www.qt.io/licensing/
-#
-# This file is part of the test suite of the Qt Toolkit.
-#
-# $QT_BEGIN_LICENSE:GPL-EXCEPT$
-# Commercial License Usage
-# Licensees holding valid commercial Qt licenses may use this file in
-# accordance with the commercial license agreement provided with the
-# Software or, alternatively, in accordance with the terms contained in
-# a written agreement between you and The Qt Company. For licensing terms
-# and conditions see https://www.qt.io/terms-conditions. For further
-# information use the contact form at https://www.qt.io/contact-us.
-#
-# GNU General Public License Usage
-# Alternatively, this file may be used under the terms of the GNU
-# General Public License version 3 as published by the Free Software
-# Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-# included in the packaging of this file. Please review the following
-# information to ensure the GNU General Public License requirements will
-# be met: https://www.gnu.org/licenses/gpl-3.0.html.
-#
-# $QT_END_LICENSE$
-#
-#############################################################################
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
import importlib
import sys
diff --git a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generate_testcase.py b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generate_testcase.py
index 9ba03a31a0..d35a7e9065 100644
--- a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generate_testcase.py
+++ b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generate_testcase.py
@@ -1,30 +1,5 @@
-#############################################################################
-#
# Copyright (C) 2020 The Qt Company Ltd.
-# Contact: https://www.qt.io/licensing/
-#
-# This file is part of the test suite of the Qt Toolkit.
-#
-# $QT_BEGIN_LICENSE:GPL-EXCEPT$
-# Commercial License Usage
-# Licensees holding valid commercial Qt licenses may use this file in
-# accordance with the commercial license agreement provided with the
-# Software or, alternatively, in accordance with the terms contained in
-# a written agreement between you and The Qt Company. For licensing terms
-# and conditions see https://www.qt.io/terms-conditions. For further
-# information use the contact form at https://www.qt.io/contact-us.
-#
-# GNU General Public License Usage
-# Alternatively, this file may be used under the terms of the GNU
-# General Public License version 3 as published by the Free Software
-# Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-# included in the packaging of this file. Please review the following
-# information to ensure the GNU General Public License requirements will
-# be met: https://www.gnu.org/licenses/gpl-3.0.html.
-#
-# $QT_END_LICENSE$
-#
-#############################################################################
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
import textwrap
import time
from subprocess import Popen, PIPE
diff --git a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generator_main.py b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generator_main.py
index 399488bb59..87cb4c7bc4 100644
--- a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generator_main.py
+++ b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/generator_main.py
@@ -1,30 +1,5 @@
-#############################################################################
-#
# Copyright (C) 2020 The Qt Company Ltd.
-# Contact: https://www.qt.io/licensing/
-#
-# This file is part of the test suite of the Qt Toolkit.
-#
-# $QT_BEGIN_LICENSE:GPL-EXCEPT$
-# Commercial License Usage
-# Licensees holding valid commercial Qt licenses may use this file in
-# accordance with the commercial license agreement provided with the
-# Software or, alternatively, in accordance with the terms contained in
-# a written agreement between you and The Qt Company. For licensing terms
-# and conditions see https://www.qt.io/terms-conditions. For further
-# information use the contact form at https://www.qt.io/contact-us.
-#
-# GNU General Public License Usage
-# Alternatively, this file may be used under the terms of the GNU
-# General Public License version 3 as published by the Free Software
-# Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-# included in the packaging of this file. Please review the following
-# information to ensure the GNU General Public License requirements will
-# be met: https://www.gnu.org/licenses/gpl-3.0.html.
-#
-# $QT_END_LICENSE$
-#
-#############################################################################
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
from option_management import function_describing_options, skip_function_description, testcase_describing_options
from generate_testcase import generate_testcase
diff --git a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/helpers.py b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/helpers.py
index ed485ac3da..fbe969789c 100644
--- a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/helpers.py
+++ b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/helpers.py
@@ -1,30 +1,5 @@
-#############################################################################
-#
# Copyright (C) 2020 The Qt Company Ltd.
-# Contact: https://www.qt.io/licensing/
-#
-# This file is part of the test suite of the Qt Toolkit.
-#
-# $QT_BEGIN_LICENSE:GPL-EXCEPT$
-# Commercial License Usage
-# Licensees holding valid commercial Qt licenses may use this file in
-# accordance with the commercial license agreement provided with the
-# Software or, alternatively, in accordance with the terms contained in
-# a written agreement between you and The Qt Company. For licensing terms
-# and conditions see https://www.qt.io/terms-conditions. For further
-# information use the contact form at https://www.qt.io/contact-us.
-#
-# GNU General Public License Usage
-# Alternatively, this file may be used under the terms of the GNU
-# General Public License version 3 as published by the Free Software
-# Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-# included in the packaging of this file. Please review the following
-# information to ensure the GNU General Public License requirements will
-# be met: https://www.gnu.org/licenses/gpl-3.0.html.
-#
-# $QT_END_LICENSE$
-#
-#############################################################################
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
def insert_testcases_into_file(filename, testcases):
diff --git a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/option_management.py b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/option_management.py
index bac2a8d368..6a1fc87f9f 100644
--- a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/option_management.py
+++ b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/generator/option_management.py
@@ -1,30 +1,5 @@
-#############################################################################
-#
# Copyright (C) 2020 The Qt Company Ltd.
-# Contact: https://www.qt.io/licensing/
-#
-# This file is part of the test suite of the Qt Toolkit.
-#
-# $QT_BEGIN_LICENSE:GPL-EXCEPT$
-# Commercial License Usage
-# Licensees holding valid commercial Qt licenses may use this file in
-# accordance with the commercial license agreement provided with the
-# Software or, alternatively, in accordance with the terms contained in
-# a written agreement between you and The Qt Company. For licensing terms
-# and conditions see https://www.qt.io/terms-conditions. For further
-# information use the contact form at https://www.qt.io/contact-us.
-#
-# GNU General Public License Usage
-# Alternatively, this file may be used under the terms of the GNU
-# General Public License version 3 as published by the Free Software
-# Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-# included in the packaging of this file. Please review the following
-# information to ensure the GNU General Public License requirements will
-# be met: https://www.gnu.org/licenses/gpl-3.0.html.
-#
-# $QT_END_LICENSE$
-#
-#############################################################################
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
import itertools
diff --git a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/tst_qtconcurrent_selected_tests.cpp b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/tst_qtconcurrent_selected_tests.cpp
index 6b72648720..edb7cce4c9 100644
--- a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/tst_qtconcurrent_selected_tests.cpp
+++ b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/tst_qtconcurrent_selected_tests.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "tst_qtconcurrentfiltermapgenerated.h"
diff --git a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/tst_qtconcurrentfiltermapgenerated.cpp b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/tst_qtconcurrentfiltermapgenerated.cpp
index 5983d6cf76..089ca3f867 100644
--- a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/tst_qtconcurrentfiltermapgenerated.cpp
+++ b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/tst_qtconcurrentfiltermapgenerated.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <qtconcurrentfilter.h>
#include <qtconcurrentmap.h>
#include <QCoreApplication>
diff --git a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/tst_qtconcurrentfiltermapgenerated.h b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/tst_qtconcurrentfiltermapgenerated.h
index 1b49a523f8..31b62ac4fd 100644
--- a/tests/auto/concurrent/qtconcurrentfiltermapgenerated/tst_qtconcurrentfiltermapgenerated.h
+++ b/tests/auto/concurrent/qtconcurrentfiltermapgenerated/tst_qtconcurrentfiltermapgenerated.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <qtconcurrentfilter.h>
#include <qtconcurrentmap.h>
#include <QTest>
diff --git a/tests/auto/concurrent/qtconcurrentiteratekernel/CMakeLists.txt b/tests/auto/concurrent/qtconcurrentiteratekernel/CMakeLists.txt
index 2c74f6542e..2eea340795 100644
--- a/tests/auto/concurrent/qtconcurrentiteratekernel/CMakeLists.txt
+++ b/tests/auto/concurrent/qtconcurrentiteratekernel/CMakeLists.txt
@@ -1,12 +1,19 @@
-# Generated from qtconcurrentiteratekernel.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qtconcurrentiteratekernel Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qtconcurrentiteratekernel LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qtconcurrentiteratekernel
SOURCES
tst_qtconcurrentiteratekernel.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Concurrent
)
diff --git a/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
index 4163883a5b..27113ad8b7 100644
--- a/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+++ b/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
@@ -1,31 +1,7 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QThread>
+#include <QSet>
struct TestIterator
{
@@ -245,7 +221,7 @@ void tst_QtConcurrentIterateKernel::throttling()
QCOMPARE(iterations.loadRelaxed(), totalIterations);
- QCOMPARE(threads.count(), 1);
+ QCOMPARE(threads.size(), 1);
}
class MultipleResultsFor : public IterateKernel<TestIterator, int>
@@ -263,7 +239,7 @@ public:
void tst_QtConcurrentIterateKernel::multipleResults()
{
QFuture<int> f = startThreadEngine(new MultipleResultsFor(0, 10)).startAsynchronously();
- QCOMPARE(f.results().count() , 10);
+ QCOMPARE(f.results().size() , 10);
QCOMPARE(f.resultAt(0), 0);
QCOMPARE(f.resultAt(5), 5);
QCOMPARE(f.resultAt(9), 9);
diff --git a/tests/auto/concurrent/qtconcurrentmap/CMakeLists.txt b/tests/auto/concurrent/qtconcurrentmap/CMakeLists.txt
index 20ccbdf374..62b434a25f 100644
--- a/tests/auto/concurrent/qtconcurrentmap/CMakeLists.txt
+++ b/tests/auto/concurrent/qtconcurrentmap/CMakeLists.txt
@@ -1,13 +1,20 @@
-# Generated from qtconcurrentmap.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qtconcurrentmap Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qtconcurrentmap LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qtconcurrentmap
SOURCES
tst_qtconcurrentmap.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Concurrent
)
diff --git a/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp b/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp
index 5bcf90c0d6..3e3165013f 100644
--- a/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp
+++ b/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <qtconcurrentmap.h>
#include <qexception.h>
#include <qdebug.h>
@@ -32,6 +7,7 @@
#include <QThread>
#include <QMutex>
#include <QTest>
+#include <QSet>
#include <QRandomGenerator>
#include "../testhelper_functions.h"
@@ -54,6 +30,7 @@ private slots:
void mappedReducedInitialValueThreadPool();
void mappedReducedInitialValueWithMoveOnlyCallable();
void mappedReducedDifferentTypeInitialValue();
+ void mappedReduceOptionConvertableToResultType();
void assignResult();
void functionOverloads();
void noExceptFunctionOverloads();
@@ -73,7 +50,7 @@ public slots:
using namespace QtConcurrent;
-void multiplyBy2Immutable(int x)
+void multiplyBy2Immutable([[maybe_unused]] int x)
{
x *= 2;
}
@@ -81,7 +58,7 @@ void multiplyBy2Immutable(int x)
class MultiplyBy2Immutable
{
public:
- void operator()(int x)
+ void operator()([[maybe_unused]] int x)
{
x *= 2;
}
@@ -186,9 +163,9 @@ void tst_QtConcurrentMap::map()
QCOMPARE(list, QList<int>() << 1 << 2 << 3);
// lambda
- QtConcurrent::map(list, [](int x){x *= 2;}).waitForFinished();
+ QtConcurrent::map(list, []([[maybe_unused]] int x){x *= 2;}).waitForFinished();
QCOMPARE(list, QList<int>() << 1 << 2 << 3);
- QtConcurrent::map(list.begin(), list.end(), [](int x){x *= 2;}).waitForFinished();
+ QtConcurrent::map(list.begin(), list.end(), []([[maybe_unused]] int x){x *= 2;}).waitForFinished();
QCOMPARE(list, QList<int>() << 1 << 2 << 3);
}
@@ -201,6 +178,24 @@ void tst_QtConcurrentMap::map()
QCOMPARE(moveOnlyVector, MoveOnlyVector<int>({ 2, 4, 6 }));
}
+ // non-template sequences
+ {
+ NonTemplateSequence list { 1, 2, 3 };
+ QtConcurrent::map(list, multiplyBy2InPlace).waitForFinished();
+ QCOMPARE(list, NonTemplateSequence({ 2, 4, 6 }));
+ }
+
+ // custom pool with invalid number of threads
+ {
+ QList<int> list;
+ list << 1 << 2 << 3;
+ QThreadPool pool;
+ pool.setMaxThreadCount(0); // explicitly set incorrect value
+ // This should not crash
+ QtConcurrent::map(&pool, list, MultiplyBy2InPlace()).waitForFinished();
+ QCOMPARE(list, QList<int>() << 2 << 4 << 6);
+ }
+
#if 0
// not allowed: map() with immutable sequences makes no sense
{
@@ -231,7 +226,7 @@ void tst_QtConcurrentMap::map()
#if 0
// not allowed: map() on a const list, where functors try to modify the items in the list
{
- const QList<int> list = QList<int>() << 1 << 2 << 3;;
+ const QList<int> list = QList<int>() << 1 << 2 << 3;
QtConcurrent::map(list, MultiplyBy2InPlace());
QtConcurrent::map(list, multiplyBy2InPlace);
@@ -325,12 +320,19 @@ void tst_QtConcurrentMap::blockingMap()
QCOMPARE(list, QList<int>() << 1 << 2 << 3);
// lambda
- QtConcurrent::blockingMap(list, [](int x) { x *= 2; });
+ QtConcurrent::blockingMap(list, []([[maybe_unused]] int x) { x *= 2; });
QCOMPARE(list, QList<int>() << 1 << 2 << 3);
- QtConcurrent::blockingMap(list.begin(), list.end(), [](int x) { x *= 2; });
+ QtConcurrent::blockingMap(list.begin(), list.end(), []([[maybe_unused]] int x) { x *= 2; });
QCOMPARE(list, QList<int>() << 1 << 2 << 3);
}
+ // non-template sequences
+ {
+ NonTemplateSequence list { 1, 2, 3 };
+ QtConcurrent::blockingMap(list, multiplyBy2InPlace);
+ QCOMPARE(list, NonTemplateSequence({ 2, 4, 6 }));
+ }
+
#if 0
// not allowed: map() with immutable sequences makes no sense
{
@@ -361,7 +363,7 @@ void tst_QtConcurrentMap::blockingMap()
#if 0
// not allowed: map() on a const list, where functors try to modify the items in the list
{
- const QList<int> list = QList<int>() << 1 << 2 << 3;;
+ const QList<int> list = QList<int>() << 1 << 2 << 3;
QtConcurrent::blockingMap(list, MultiplyBy2InPlace());
QtConcurrent::blockingMap(list, multiplyBy2InPlace);
@@ -564,6 +566,17 @@ void tst_QtConcurrentMap::mapped()
#endif
{
+ // non-template sequences
+ NonTemplateSequence list { 1, 2, 3 };
+
+ auto future = QtConcurrent::mapped(list, multiplyBy2);
+ QCOMPARE(future.results(), QList({ 2, 4, 6 }));
+
+ auto result = QtConcurrent::blockingMapped(list, multiplyBy2);
+ QCOMPARE(result, NonTemplateSequence({ 2, 4, 6 }));
+ }
+
+ {
// rvalue sequences
auto future = QtConcurrent::mapped(std::vector { 1, 2, 3 }, multiplyBy2);
QCOMPARE(future.results(), QList<int>({ 2, 4, 6 }));
@@ -667,6 +680,17 @@ void tst_QtConcurrentMap::mappedThreadPool()
CHECK_FAIL("lambda");
{
+ // non-template sequences
+ NonTemplateSequence list { 1, 2, 3 };
+
+ auto future = QtConcurrent::mapped(&pool, list, multiplyBy2);
+ QCOMPARE(future.results(), QList({ 2, 4, 6 }));
+
+ auto result = QtConcurrent::blockingMapped(&pool, list, multiplyBy2);
+ QCOMPARE(result, NonTemplateSequence({ 2, 4, 6 }));
+ }
+
+ {
// rvalue sequences
auto future = QtConcurrent::mapped(&pool, std::vector { 1, 2, 3 }, multiplyBy2);
QCOMPARE(future.results(), QList<int>({ 2, 4, 6 }));
@@ -761,22 +785,45 @@ public:
template <typename SourceObject, typename ResultObject, typename MapObject, typename ReduceObject>
void testMappedReduced(const QList<SourceObject> &sourceObjectList, const ResultObject &expectedResult, MapObject mapObject, ReduceObject reduceObject)
{
- const ResultObject result1 = QtConcurrent::mappedReduced<ResultObject>(
- sourceObjectList, mapObject, reduceObject).result();
- QCOMPARE(result1, expectedResult);
+ // Result type is passed explicitly
+ {
+ const ResultObject result1 = QtConcurrent::mappedReduced<ResultObject>(
+ sourceObjectList, mapObject, reduceObject).result();
+ QCOMPARE(result1, expectedResult);
- const ResultObject result2 = QtConcurrent::mappedReduced<ResultObject>(
- sourceObjectList.constBegin(), sourceObjectList.constEnd(),
- mapObject, reduceObject).result();
- QCOMPARE(result2, expectedResult);
+ const ResultObject result2 = QtConcurrent::mappedReduced<ResultObject>(
+ sourceObjectList.constBegin(), sourceObjectList.constEnd(),
+ mapObject, reduceObject).result();
+ QCOMPARE(result2, expectedResult);
- const ResultObject result3 = QtConcurrent::blockingMappedReduced<ResultObject>(
- sourceObjectList, mapObject, reduceObject);
- QCOMPARE(result3, expectedResult);
+ const ResultObject result3 = QtConcurrent::blockingMappedReduced<ResultObject>(
+ sourceObjectList, mapObject, reduceObject);
+ QCOMPARE(result3, expectedResult);
- const ResultObject result4 = QtConcurrent::blockingMappedReduced<ResultObject>(
- sourceObjectList.constBegin(), sourceObjectList.constEnd(), mapObject, reduceObject);
- QCOMPARE(result4, expectedResult);
+ const ResultObject result4 = QtConcurrent::blockingMappedReduced<ResultObject>(
+ sourceObjectList.constBegin(), sourceObjectList.constEnd(), mapObject, reduceObject);
+ QCOMPARE(result4, expectedResult);
+ }
+
+ // Result type is deduced
+ {
+ const ResultObject result1 = QtConcurrent::mappedReduced(
+ sourceObjectList, mapObject, reduceObject).result();
+ QCOMPARE(result1, expectedResult);
+
+ const ResultObject result2 = QtConcurrent::mappedReduced(
+ sourceObjectList.constBegin(), sourceObjectList.constEnd(),
+ mapObject, reduceObject).result();
+ QCOMPARE(result2, expectedResult);
+
+ const ResultObject result3 = QtConcurrent::blockingMappedReduced(
+ sourceObjectList, mapObject, reduceObject);
+ QCOMPARE(result3, expectedResult);
+
+ const ResultObject result4 = QtConcurrent::blockingMappedReduced(
+ sourceObjectList.constBegin(), sourceObjectList.constEnd(), mapObject, reduceObject);
+ QCOMPARE(result4, expectedResult);
+ }
}
template <typename SourceObject, typename ResultObject, typename MapObject, typename ReduceObject>
@@ -858,6 +905,17 @@ void tst_QtConcurrentMap::mappedReduced()
CHECK_FAIL("lambda-lambda");
{
+ // non-template sequences
+ NonTemplateSequence list { 1, 2, 3 };
+
+ auto future = QtConcurrent::mappedReduced(list, multiplyBy2, intSumReduce);
+ QCOMPARE(future.result(), 12);
+
+ auto result = QtConcurrent::blockingMappedReduced(list, multiplyBy2, intSumReduce);
+ QCOMPARE(result, 12);
+ }
+
+ {
// rvalue sequences
auto future = QtConcurrent::mappedReduced(std::vector { 1, 2, 3 }, intSquare, intSumReduce);
QCOMPARE(future.result(), sumOfSquares);
@@ -886,27 +944,57 @@ void testMappedReducedThreadPool(QThreadPool *pool,
MapObject mapObject,
ReduceObject reduceObject)
{
- const ResultObject result1 = QtConcurrent::mappedReduced<ResultObject>(
- pool, sourceObjectList, mapObject, reduceObject).result();
- QCOMPARE(result1, expectedResult);
- QCOMPARE(threadCount(), 1); // ensure the only one thread was working
+ // Result type is passed explicitly
+ {
+ const ResultObject result1 = QtConcurrent::mappedReduced<ResultObject>(
+ pool, sourceObjectList, mapObject, reduceObject).result();
+ QCOMPARE(result1, expectedResult);
+ QCOMPARE(threadCount(), 1); // ensure the only one thread was working
- const ResultObject result2 =
- QtConcurrent::mappedReduced<ResultObject>(pool, sourceObjectList.constBegin(),
- sourceObjectList.constEnd(), mapObject,
- reduceObject).result();
- QCOMPARE(result2, expectedResult);
- QCOMPARE(threadCount(), 1); // ensure the only one thread was working
+ const ResultObject result2 =
+ QtConcurrent::mappedReduced<ResultObject>(pool, sourceObjectList.constBegin(),
+ sourceObjectList.constEnd(), mapObject,
+ reduceObject).result();
+ QCOMPARE(result2, expectedResult);
+ QCOMPARE(threadCount(), 1); // ensure the only one thread was working
- const ResultObject result3 = QtConcurrent::blockingMappedReduced<ResultObject>(pool,
- sourceObjectList, mapObject, reduceObject);
- QCOMPARE(result3, expectedResult);
- QCOMPARE(threadCount(), 1); // ensure the only one thread was working
+ const ResultObject result3 = QtConcurrent::blockingMappedReduced<ResultObject>(
+ pool, sourceObjectList, mapObject, reduceObject);
+ QCOMPARE(result3, expectedResult);
+ QCOMPARE(threadCount(), 1); // ensure the only one thread was working
- const ResultObject result4 = QtConcurrent::blockingMappedReduced<ResultObject>(pool,
- sourceObjectList.constBegin(), sourceObjectList.constEnd(), mapObject, reduceObject);
- QCOMPARE(result4, expectedResult);
- QCOMPARE(threadCount(), 1); // ensure the only one thread was working
+ const ResultObject result4 = QtConcurrent::blockingMappedReduced<ResultObject>(
+ pool, sourceObjectList.constBegin(), sourceObjectList.constEnd(),
+ mapObject, reduceObject);
+ QCOMPARE(result4, expectedResult);
+ QCOMPARE(threadCount(), 1); // ensure the only one thread was working
+ }
+
+ // Result type is deduced
+ {
+ const ResultObject result1 = QtConcurrent::mappedReduced(
+ pool, sourceObjectList, mapObject, reduceObject).result();
+ QCOMPARE(result1, expectedResult);
+ QCOMPARE(threadCount(), 1); // ensure the only one thread was working
+
+ const ResultObject result2 =
+ QtConcurrent::mappedReduced(pool, sourceObjectList.constBegin(),
+ sourceObjectList.constEnd(), mapObject,
+ reduceObject).result();
+ QCOMPARE(result2, expectedResult);
+ QCOMPARE(threadCount(), 1); // ensure the only one thread was working
+
+ const ResultObject result3 = QtConcurrent::blockingMappedReduced(
+ pool, sourceObjectList, mapObject, reduceObject);
+ QCOMPARE(result3, expectedResult);
+ QCOMPARE(threadCount(), 1); // ensure the only one thread was working
+
+ const ResultObject result4 = QtConcurrent::blockingMappedReduced(
+ pool, sourceObjectList.constBegin(), sourceObjectList.constEnd(),
+ mapObject, reduceObject);
+ QCOMPARE(result4, expectedResult);
+ QCOMPARE(threadCount(), 1); // ensure the only one thread was working
+ }
}
int intCube(int x)
@@ -967,6 +1055,17 @@ void tst_QtConcurrentMap::mappedReducedThreadPool()
CHECK_FAIL("lambda-lambda");
{
+ // non-template sequences
+ NonTemplateSequence list { 1, 2, 3 };
+
+ auto future = QtConcurrent::mappedReduced(&pool, list, multiplyBy2, intSumReduce);
+ QCOMPARE(future.result(), 12);
+
+ auto result = QtConcurrent::blockingMappedReduced(&pool, list, multiplyBy2, intSumReduce);
+ QCOMPARE(result, 12);
+ }
+
+ {
// rvalue sequences
auto future =
QtConcurrent::mappedReduced(&pool, std::vector { 1, 2, 3 }, intCube, intSumReduce);
@@ -987,6 +1086,17 @@ void tst_QtConcurrentMap::mappedReducedThreadPool()
intCube, intSumReduce);
QCOMPARE(result, sumOfCubes);
}
+
+ {
+ // pool with invalid number of threads
+ QThreadPool pool;
+ pool.setMaxThreadCount(0); // explicitly set incorrect value
+
+ // This should not crash
+ NonTemplateSequence list { 1, 2, 3 };
+ auto future = QtConcurrent::mappedReduced(&pool, list, multiplyBy2, intSumReduce);
+ QCOMPARE(future.result(), 12);
+ }
}
void tst_QtConcurrentMap::mappedReducedWithMoveOnlyCallable()
@@ -994,46 +1104,46 @@ void tst_QtConcurrentMap::mappedReducedWithMoveOnlyCallable()
const QList<int> intList { 1, 2, 3 };
const auto sum = 12;
{
- const auto result = QtConcurrent::mappedReduced<int>(
+ const auto result = QtConcurrent::mappedReduced(
intList, MultiplyBy2(), IntSumReduceMoveOnly()).result();
QCOMPARE(result, sum);
}
{
const auto result =
- QtConcurrent::mappedReduced<int>(intList.begin(), intList.end(),
- MultiplyBy2(), IntSumReduceMoveOnly()).result();
+ QtConcurrent::mappedReduced(intList.begin(), intList.end(),
+ MultiplyBy2(), IntSumReduceMoveOnly()).result();
QCOMPARE(result, sum);
}
{
- const auto result = QtConcurrent::blockingMappedReduced<int>(intList, MultiplyBy2(),
- IntSumReduceMoveOnly());
+ const auto result = QtConcurrent::blockingMappedReduced(intList, MultiplyBy2(),
+ IntSumReduceMoveOnly());
QCOMPARE(result, sum);
}
{
- const auto result = QtConcurrent::blockingMappedReduced<int>(
+ const auto result = QtConcurrent::blockingMappedReduced(
intList.begin(), intList.end(), MultiplyBy2(), IntSumReduceMoveOnly());
QCOMPARE(result, sum);
}
QThreadPool pool;
{
- const auto result = QtConcurrent::mappedReduced<int>(&pool, intList, MultiplyBy2(),
- IntSumReduceMoveOnly()).result();
+ const auto result = QtConcurrent::mappedReduced(&pool, intList, MultiplyBy2(),
+ IntSumReduceMoveOnly()).result();
QCOMPARE(result, sum);
}
{
const auto result =
- QtConcurrent::mappedReduced<int>(&pool, intList.begin(), intList.end(),
- MultiplyBy2(), IntSumReduceMoveOnly()).result();
+ QtConcurrent::mappedReduced(&pool, intList.begin(), intList.end(),
+ MultiplyBy2(), IntSumReduceMoveOnly()).result();
QCOMPARE(result, sum);
}
{
- const auto result = QtConcurrent::blockingMappedReduced<int>(&pool, intList, MultiplyBy2(),
- IntSumReduceMoveOnly());
+ const auto result = QtConcurrent::blockingMappedReduced(&pool, intList, MultiplyBy2(),
+ IntSumReduceMoveOnly());
QCOMPARE(result, sum);
}
{
- const auto result = QtConcurrent::blockingMappedReduced<int>(
+ const auto result = QtConcurrent::blockingMappedReduced(
&pool, intList.begin(), intList.end(), MultiplyBy2(), IntSumReduceMoveOnly());
QCOMPARE(result, sum);
}
@@ -1096,23 +1206,49 @@ void testMappedReducedInitialValue(const QList<SourceObject> &sourceObjectList,
ReduceObject reduceObject,
InitialObject &&initialObject)
{
- const ResultObject result1 =
- QtConcurrent::mappedReduced<ResultObject>(sourceObjectList, mapObject, reduceObject,
- initialObject).result();
- QCOMPARE(result1, expectedResult);
+ // Result type is passed explicitly
+ {
+ const ResultObject result1 =
+ QtConcurrent::mappedReduced<ResultObject>(sourceObjectList, mapObject, reduceObject,
+ initialObject).result();
+ QCOMPARE(result1, expectedResult);
- const ResultObject result2 = QtConcurrent::mappedReduced<ResultObject>(
- sourceObjectList.constBegin(), sourceObjectList.constEnd(),
- mapObject, reduceObject, initialObject).result();
- QCOMPARE(result2, expectedResult);
+ const ResultObject result2 = QtConcurrent::mappedReduced<ResultObject>(
+ sourceObjectList.constBegin(), sourceObjectList.constEnd(),
+ mapObject, reduceObject, initialObject).result();
+ QCOMPARE(result2, expectedResult);
- const ResultObject result3 = QtConcurrent::blockingMappedReduced<ResultObject>(
- sourceObjectList, mapObject, reduceObject, initialObject);
- QCOMPARE(result3, expectedResult);
+ const ResultObject result3 = QtConcurrent::blockingMappedReduced<ResultObject>(
+ sourceObjectList, mapObject, reduceObject, initialObject);
+ QCOMPARE(result3, expectedResult);
- const ResultObject result4 = QtConcurrent::blockingMappedReduced<ResultObject>(
- sourceObjectList.constBegin(), sourceObjectList.constEnd(), mapObject, reduceObject, initialObject);
- QCOMPARE(result4, expectedResult);
+ const ResultObject result4 = QtConcurrent::blockingMappedReduced<ResultObject>(
+ sourceObjectList.constBegin(), sourceObjectList.constEnd(),
+ mapObject, reduceObject, initialObject);
+ QCOMPARE(result4, expectedResult);
+ }
+
+ // Result type is deduced
+ {
+ const ResultObject result1 =
+ QtConcurrent::mappedReduced(sourceObjectList, mapObject, reduceObject,
+ initialObject).result();
+ QCOMPARE(result1, expectedResult);
+
+ const ResultObject result2 = QtConcurrent::mappedReduced(
+ sourceObjectList.constBegin(), sourceObjectList.constEnd(),
+ mapObject, reduceObject, initialObject).result();
+ QCOMPARE(result2, expectedResult);
+
+ const ResultObject result3 = QtConcurrent::blockingMappedReduced(
+ sourceObjectList, mapObject, reduceObject, initialObject);
+ QCOMPARE(result3, expectedResult);
+
+ const ResultObject result4 = QtConcurrent::blockingMappedReduced(
+ sourceObjectList.constBegin(), sourceObjectList.constEnd(),
+ mapObject, reduceObject, initialObject);
+ QCOMPARE(result4, expectedResult);
+ }
}
template <typename SourceObject, typename ResultObject, typename InitialObject, typename MapObject, typename ReduceObject>
@@ -1204,6 +1340,18 @@ void tst_QtConcurrentMap::mappedReducedInitialValue()
CHECK_FAIL("lambda-lambda");
{
+ // non-template sequences
+ NonTemplateSequence list { 1, 2, 3 };
+
+ auto future = QtConcurrent::mappedReduced(list, multiplyBy2, intSumReduce, intInitial);
+ QCOMPARE(future.result(), intInitial + 12);
+
+ auto result =
+ QtConcurrent::blockingMappedReduced(list, multiplyBy2, intSumReduce, intInitial);
+ QCOMPARE(result, intInitial + 12);
+ }
+
+ {
// rvalue sequences
auto future = QtConcurrent::mappedReduced(std::vector { 1, 2, 3 }, intSquare, intSumReduce,
intInitial);
@@ -1234,28 +1382,57 @@ void testMappedReducedInitialValueThreadPool(QThreadPool *pool,
ReduceObject reduceObject,
InitialObject &&initialObject)
{
- const ResultObject result1 = QtConcurrent::mappedReduced<ResultObject>(
- pool, sourceObjectList, mapObject, reduceObject, initialObject).result();
- QCOMPARE(result1, expectedResult);
- QCOMPARE(threadCount(), 1); // ensure the only one thread was working
+ // Result type is passed explicitly
+ {
+ const ResultObject result1 = QtConcurrent::mappedReduced<ResultObject>(
+ pool, sourceObjectList, mapObject, reduceObject, initialObject).result();
+ QCOMPARE(result1, expectedResult);
+ QCOMPARE(threadCount(), 1); // ensure the only one thread was working
- const ResultObject result2 =
- QtConcurrent::mappedReduced<ResultObject>(pool, sourceObjectList.constBegin(),
- sourceObjectList.constEnd(), mapObject,
- reduceObject, initialObject).result();
- QCOMPARE(result2, expectedResult);
- QCOMPARE(threadCount(), 1); // ensure the only one thread was working
+ const ResultObject result2 =
+ QtConcurrent::mappedReduced<ResultObject>(pool, sourceObjectList.constBegin(),
+ sourceObjectList.constEnd(), mapObject,
+ reduceObject, initialObject).result();
+ QCOMPARE(result2, expectedResult);
+ QCOMPARE(threadCount(), 1); // ensure the only one thread was working
- const ResultObject result3 = QtConcurrent::blockingMappedReduced<ResultObject>(
- pool, sourceObjectList, mapObject, reduceObject, initialObject);
- QCOMPARE(result3, expectedResult);
- QCOMPARE(threadCount(), 1); // ensure the only one thread was working
+ const ResultObject result3 = QtConcurrent::blockingMappedReduced<ResultObject>(
+ pool, sourceObjectList, mapObject, reduceObject, initialObject);
+ QCOMPARE(result3, expectedResult);
+ QCOMPARE(threadCount(), 1); // ensure the only one thread was working
- const ResultObject result4 = QtConcurrent::blockingMappedReduced<ResultObject>(
- pool, sourceObjectList.constBegin(), sourceObjectList.constEnd(),
- mapObject, reduceObject, initialObject);
- QCOMPARE(result4, expectedResult);
- QCOMPARE(threadCount(), 1); // ensure the only one thread was working
+ const ResultObject result4 = QtConcurrent::blockingMappedReduced<ResultObject>(
+ pool, sourceObjectList.constBegin(), sourceObjectList.constEnd(),
+ mapObject, reduceObject, initialObject);
+ QCOMPARE(result4, expectedResult);
+ QCOMPARE(threadCount(), 1); // ensure the only one thread was working
+ }
+
+ // Result type is deduced
+ {
+ const ResultObject result1 = QtConcurrent::mappedReduced(
+ pool, sourceObjectList, mapObject, reduceObject, initialObject).result();
+ QCOMPARE(result1, expectedResult);
+ QCOMPARE(threadCount(), 1); // ensure the only one thread was working
+
+ const ResultObject result2 =
+ QtConcurrent::mappedReduced(pool, sourceObjectList.constBegin(),
+ sourceObjectList.constEnd(), mapObject,
+ reduceObject, initialObject).result();
+ QCOMPARE(result2, expectedResult);
+ QCOMPARE(threadCount(), 1); // ensure the only one thread was working
+
+ const ResultObject result3 = QtConcurrent::blockingMappedReduced(
+ pool, sourceObjectList, mapObject, reduceObject, initialObject);
+ QCOMPARE(result3, expectedResult);
+ QCOMPARE(threadCount(), 1); // ensure the only one thread was working
+
+ const ResultObject result4 = QtConcurrent::blockingMappedReduced(
+ pool, sourceObjectList.constBegin(), sourceObjectList.constEnd(),
+ mapObject, reduceObject, initialObject);
+ QCOMPARE(result4, expectedResult);
+ QCOMPARE(threadCount(), 1); // ensure the only one thread was working
+ }
}
void tst_QtConcurrentMap::mappedReducedInitialValueThreadPool()
@@ -1312,6 +1489,19 @@ void tst_QtConcurrentMap::mappedReducedInitialValueThreadPool()
CHECK_FAIL("lambda-lambda");
{
+ // non-template sequences
+ NonTemplateSequence list { 1, 2, 3 };
+
+ auto future =
+ QtConcurrent::mappedReduced(&pool, list, multiplyBy2, intSumReduce, intInitial);
+ QCOMPARE(future.result(), intInitial + 12);
+
+ auto result = QtConcurrent::blockingMappedReduced(&pool, list, multiplyBy2, intSumReduce,
+ intInitial);
+ QCOMPARE(result, intInitial + 12);
+ }
+
+ {
// rvalue sequences
auto future = QtConcurrent::mappedReduced(&pool, std::vector { 1, 2, 3 }, intCube,
intSumReduce, intInitial);
@@ -1341,50 +1531,50 @@ void tst_QtConcurrentMap::mappedReducedInitialValueWithMoveOnlyCallable()
const auto sum = 22;
{
const auto result =
- QtConcurrent::mappedReduced<int>(intList, MultiplyBy2(),
- IntSumReduceMoveOnly(), initialValue).result();
+ QtConcurrent::mappedReduced(intList, MultiplyBy2(),
+ IntSumReduceMoveOnly(), initialValue).result();
QCOMPARE(result, sum);
}
{
const auto result =
- QtConcurrent::mappedReduced<int>(intList.begin(), intList.end(), MultiplyBy2(),
- IntSumReduceMoveOnly(), initialValue).result();
+ QtConcurrent::mappedReduced(intList.begin(), intList.end(), MultiplyBy2(),
+ IntSumReduceMoveOnly(), initialValue).result();
QCOMPARE(result, sum);
}
{
- const auto result = QtConcurrent::blockingMappedReduced<int>(
- intList, MultiplyBy2(), IntSumReduceMoveOnly(), initialValue);
+ const auto result = QtConcurrent::blockingMappedReduced(
+ intList, MultiplyBy2(), IntSumReduceMoveOnly(), initialValue);
QCOMPARE(result, sum);
}
{
- const auto result = QtConcurrent::blockingMappedReduced<int>(
- intList.begin(), intList.end(), MultiplyBy2(), IntSumReduceMoveOnly(),
- initialValue);
+ const auto result = QtConcurrent::blockingMappedReduced(
+ intList.begin(), intList.end(), MultiplyBy2(), IntSumReduceMoveOnly(),
+ initialValue);
QCOMPARE(result, sum);
}
QThreadPool pool;
{
const auto result =
- QtConcurrent::mappedReduced<int>(&pool, intList, MultiplyBy2(),
- IntSumReduceMoveOnly(), initialValue).result();
+ QtConcurrent::mappedReduced(&pool, intList, MultiplyBy2(),
+ IntSumReduceMoveOnly(), initialValue).result();
QCOMPARE(result, sum);
}
{
- const auto result = QtConcurrent::mappedReduced<int>(&pool, intList.begin(), intList.end(),
- MultiplyBy2(), IntSumReduceMoveOnly(),
- initialValue).result();
+ const auto result = QtConcurrent::mappedReduced(&pool, intList.begin(), intList.end(),
+ MultiplyBy2(), IntSumReduceMoveOnly(),
+ initialValue).result();
QCOMPARE(result, sum);
}
{
- const auto result = QtConcurrent::blockingMappedReduced<int>(
- &pool, intList, MultiplyBy2(), IntSumReduceMoveOnly(), initialValue);
+ const auto result = QtConcurrent::blockingMappedReduced(
+ &pool, intList, MultiplyBy2(), IntSumReduceMoveOnly(), initialValue);
QCOMPARE(result, sum);
}
{
- const auto result = QtConcurrent::blockingMappedReduced<int>(
- &pool, intList.begin(), intList.end(), MultiplyBy2(), IntSumReduceMoveOnly(),
- initialValue);
+ const auto result = QtConcurrent::blockingMappedReduced(
+ &pool, intList.begin(), intList.end(), MultiplyBy2(), IntSumReduceMoveOnly(),
+ initialValue);
QCOMPARE(result, sum);
}
}
@@ -1438,6 +1628,51 @@ void tst_QtConcurrentMap::mappedReducedDifferentTypeInitialValue()
CHECK_FAIL("lambda-lambda");
}
+void tst_QtConcurrentMap::mappedReduceOptionConvertableToResultType()
+{
+ const QList<int> intList { 1, 2, 3 };
+ const int sum = 12;
+ QThreadPool p;
+ ReduceOption ro = OrderedReduce;
+
+ // With container
+ QCOMPARE(QtConcurrent::mappedReduced(intList, multiplyBy2, intSumReduce, ro).result(), sum);
+ QCOMPARE(QtConcurrent::blockingMappedReduced(intList, multiplyBy2, intSumReduce, ro), sum);
+
+ // With iterators
+ QCOMPARE(QtConcurrent::mappedReduced(intList.begin(), intList.end(), multiplyBy2, intSumReduce,
+ ro).result(), sum);
+ QCOMPARE(QtConcurrent::blockingMappedReduced(intList.begin(), intList.end(), multiplyBy2,
+ intSumReduce, ro), sum);
+
+ // With custom QThreadPool;
+ QCOMPARE(QtConcurrent::mappedReduced(&p, intList, multiplyBy2, intSumReduce, ro).result(), sum);
+ QCOMPARE(QtConcurrent::blockingMappedReduced(&p, intList, multiplyBy2, intSumReduce, ro), sum);
+ QCOMPARE(QtConcurrent::mappedReduced(&p, intList.begin(), intList.end(), multiplyBy2,
+ intSumReduce, ro).result(), sum);
+ QCOMPARE(QtConcurrent::blockingMappedReduced(&p, intList.begin(), intList.end(), multiplyBy2,
+ intSumReduce, ro), sum);
+
+ // The same as above, but specify the result type explicitly (this invokes different overloads)
+ QCOMPARE(QtConcurrent::mappedReduced<int>(intList, multiplyBy2, intSumReduce, ro).result(),
+ sum);
+ QCOMPARE(QtConcurrent::blockingMappedReduced<int>(intList, multiplyBy2, intSumReduce, ro), sum);
+
+ QCOMPARE(QtConcurrent::mappedReduced<int>(intList.begin(), intList.end(), multiplyBy2,
+ intSumReduce, ro).result(), sum);
+ QCOMPARE(QtConcurrent::blockingMappedReduced<int>(intList.begin(), intList.end(), multiplyBy2,
+ intSumReduce, ro), sum);
+
+ QCOMPARE(QtConcurrent::mappedReduced<int>(&p, intList, multiplyBy2, intSumReduce, ro).result(),
+ sum);
+ QCOMPARE(QtConcurrent::blockingMappedReduced<int>(&p, intList, multiplyBy2, intSumReduce, ro),
+ sum);
+ QCOMPARE(QtConcurrent::mappedReduced<int>(&p, intList.begin(), intList.end(), multiplyBy2,
+ intSumReduce, ro).result(), sum);
+ QCOMPARE(QtConcurrent::blockingMappedReduced<int>(&p, intList.begin(), intList.end(),
+ multiplyBy2, intSumReduce, ro), sum);
+}
+
int sleeper(int val)
{
QTest::qSleep(100);
@@ -1743,7 +1978,7 @@ void tst_QtConcurrentMap::incrementalResults()
QCOMPARE(future.isFinished(), true);
QCOMPARE(future.resultCount(), count);
- QCOMPARE(future.results().count(), count);
+ QCOMPARE(future.results().size(), count);
}
/*
@@ -1834,7 +2069,7 @@ void tst_QtConcurrentMap::stlContainersLambda()
QtConcurrent::mapped(list, [](const int &i) { return mapper(i); }).waitForFinished();
- QtConcurrent::blockingMap(list, [](int x) { x *= 2; });
+ QtConcurrent::blockingMap(list, []([[maybe_unused]] int x) { x *= 2; });
}
InstanceCounter ic_fn(const InstanceCounter & ic)
diff --git a/tests/auto/concurrent/qtconcurrentmedian/CMakeLists.txt b/tests/auto/concurrent/qtconcurrentmedian/CMakeLists.txt
index cbae4d1fb1..63f0135467 100644
--- a/tests/auto/concurrent/qtconcurrentmedian/CMakeLists.txt
+++ b/tests/auto/concurrent/qtconcurrentmedian/CMakeLists.txt
@@ -1,12 +1,19 @@
-# Generated from qtconcurrentmedian.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qtconcurrentmedian Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qtconcurrentmedian LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qtconcurrentmedian
SOURCES
tst_qtconcurrentmedian.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Concurrent
)
diff --git a/tests/auto/concurrent/qtconcurrentmedian/tst_qtconcurrentmedian.cpp b/tests/auto/concurrent/qtconcurrentmedian/tst_qtconcurrentmedian.cpp
index 8a797447bb..7eea013c8b 100644
--- a/tests/auto/concurrent/qtconcurrentmedian/tst_qtconcurrentmedian.cpp
+++ b/tests/auto/concurrent/qtconcurrentmedian/tst_qtconcurrentmedian.cpp
@@ -1,30 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
#include <qtconcurrentmedian.h>
#include <QTest>
@@ -73,11 +49,11 @@ void tst_QtConcurrentMedian::median_data()
void tst_QtConcurrentMedian::median()
{
- QFETCH(QList<double> , values);
+ QFETCH(const QList<double> , values);
QFETCH(double, expectedMedian);
QtConcurrent::Median m;
- foreach (double value, values)
+ for (double value : values)
m.addValue(value);
QCOMPARE(m.median(), expectedMedian);
}
diff --git a/tests/auto/concurrent/qtconcurrentrun/CMakeLists.txt b/tests/auto/concurrent/qtconcurrentrun/CMakeLists.txt
index 9f3b60481d..a8b6792570 100644
--- a/tests/auto/concurrent/qtconcurrentrun/CMakeLists.txt
+++ b/tests/auto/concurrent/qtconcurrentrun/CMakeLists.txt
@@ -1,14 +1,22 @@
-# Generated from qtconcurrentrun.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qtconcurrentrun Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qtconcurrentrun LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qtconcurrentrun
SOURCES
tst_qtconcurrentrun.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Concurrent
+ Qt::TestPrivate
)
## Scopes:
diff --git a/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp b/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp
index 1b0b9577cf..0bc2961903 100644
--- a/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp
+++ b/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <qtconcurrentrun.h>
#include <QFuture>
#include <QMutex>
@@ -35,12 +10,15 @@
#include <QTimer>
#include <QFutureSynchronizer>
+#include <QtTest/private/qemulationdetector_p.h>
+
using namespace QtConcurrent;
class tst_QtConcurrentRun: public QObject
{
Q_OBJECT
private slots:
+ void initTestCase();
void runLightFunction();
void runHeavyFunction();
void returnValue();
@@ -64,6 +42,9 @@ private slots:
void moveOnlyType();
void crefFunction();
void customPromise();
+ void nonDefaultConstructibleValue();
+ void nullThreadPool();
+ void nullThreadPoolNoLeak();
};
void light()
@@ -105,6 +86,13 @@ void heavy()
qDebug("done function");
}
+void tst_QtConcurrentRun::initTestCase()
+{
+ // proxy check for QEMU; catches slightly more though
+ if (QTestPrivate::isRunningArmOnX86())
+ QSKIP("Runs into spurious crashes on QEMU -- QTBUG-106906");
+}
+
void tst_QtConcurrentRun::runLightFunction()
{
qDebug("starting function");
@@ -678,10 +666,10 @@ void tst_QtConcurrentRun::implicitConvertibleTypes()
{
QThreadPool pool;
- double d;
+ double d = 0.0;
run(doubleFunction, d).waitForFinished();
run(&pool, doubleFunction, d).waitForFinished();
- int i;
+ int i = 0;
run(doubleFunction, d).waitForFinished();
run(&pool, doubleFunction, d).waitForFinished();
run(doubleFunction, i).waitForFinished();
@@ -827,7 +815,7 @@ public:
void run() override {
int iter = 60;
while (--iter && !cancel.loadRelaxed())
- QThread::currentThread()->msleep(25);
+ QThread::currentThread()->sleep(std::chrono::milliseconds{25});
}
};
@@ -1101,12 +1089,25 @@ void report3(QPromise<int> &promise)
promise.addResult(1);
}
+static void staticReport3(QPromise<int> &promise)
+{
+ promise.addResult(0);
+ promise.addResult(2);
+ promise.addResult(1);
+}
+
void reportN(QPromise<double> &promise, int n)
{
for (int i = 0; i < n; ++i)
promise.addResult(0);
}
+static void staticReportN(QPromise<double> &promise, int n)
+{
+ for (int i = 0; i < n; ++i)
+ promise.addResult(0);
+}
+
void reportString1(QPromise<QString> &promise, const QString &s)
{
promise.addResult(s);
@@ -1180,11 +1181,21 @@ void tst_QtConcurrentRun::withPromise()
QCOMPARE(run(report3).results(),
QList<int>({0, 2, 1}));
- QCOMPARE(run(reportN, 4).results(),
- QList<double>({0, 0, 0, 0}));
+ QCOMPARE(run(&staticReport3).results(),
+ QList<int>({0, 2, 1}));
+ QCOMPARE(run(staticReport3).results(),
+ QList<int>({0, 2, 1}));
+
+ QCOMPARE(run(&reportN, 2).results(),
+ QList<double>({0, 0}));
QCOMPARE(run(reportN, 2).results(),
QList<double>({0, 0}));
+ QCOMPARE(run(&staticReportN, 2).results(),
+ QList<double>({0, 0}));
+ QCOMPARE(run(staticReportN, 2).results(),
+ QList<double>({0, 0}));
+
QString s = QLatin1String("string");
const QString &crs = QLatin1String("cr string");
const QString cs = QLatin1String("c string");
@@ -1271,11 +1282,21 @@ void tst_QtConcurrentRun::withPromiseInThreadPool()
QCOMPARE(run(pool.data(), report3).results(),
QList<int>({0, 2, 1}));
- QCOMPARE(run(pool.data(), reportN, 4).results(),
- QList<double>({0, 0, 0, 0}));
+ QCOMPARE(run(pool.data(), &staticReport3).results(),
+ QList<int>({0, 2, 1}));
+ QCOMPARE(run(pool.data(), staticReport3).results(),
+ QList<int>({0, 2, 1}));
+
+ QCOMPARE(run(pool.data(), &reportN, 2).results(),
+ QList<double>({0, 0}));
QCOMPARE(run(pool.data(), reportN, 2).results(),
QList<double>({0, 0}));
+ QCOMPARE(run(pool.data(), &staticReportN, 2).results(),
+ QList<double>({0, 0}));
+ QCOMPARE(run(pool.data(), staticReportN, 2).results(),
+ QList<double>({0, 0}));
+
QString s = QLatin1String("string");
const QString &crs = QLatin1String("cr string");
const QString cs = QLatin1String("c string");
@@ -1405,7 +1426,7 @@ void tst_QtConcurrentRun::withPromiseAndThen()
setFlag(syncEnd);
future.waitForFinished();
- QCOMPARE(future.results().count(), 0);
+ QCOMPARE(future.results().size(), 0);
QVERIFY(runExecuted);
QVERIFY(!cancelReceivedBeforeSync);
QVERIFY(cancelReceivedAfterSync);
@@ -1425,7 +1446,7 @@ void tst_QtConcurrentRun::withPromiseAndThen()
setFlag(syncEnd);
resultFuture.waitForFinished();
- QCOMPARE(future.results().count(), 1);
+ QCOMPARE(future.results().size(), 1);
QCOMPARE(future.result(), 1);
QVERIFY(runExecuted);
QVERIFY(thenExecuted);
@@ -1448,7 +1469,7 @@ void tst_QtConcurrentRun::withPromiseAndThen()
setFlag(syncEnd);
resultFuture.waitForFinished();
- QCOMPARE(future.results().count(), 0);
+ QCOMPARE(future.results().size(), 0);
QVERIFY(runExecuted);
QVERIFY(!thenExecuted);
QVERIFY(cancelExecuted);
@@ -1564,6 +1585,50 @@ void tst_QtConcurrentRun::customPromise()
QCOMPARE(p.future().progressMaximum(), 10);
}
+void tst_QtConcurrentRun::nonDefaultConstructibleValue()
+{
+ struct NonDefaultConstructible
+ {
+ explicit NonDefaultConstructible(int v) : value(v) { }
+ int value = 0;
+ };
+
+ auto future = QtConcurrent::run([] { return NonDefaultConstructible(42); });
+ QCOMPARE(future.result().value, 42);
+}
+
+// QTBUG-98901
+void tst_QtConcurrentRun::nullThreadPool()
+{
+ QThreadPool *pool = nullptr;
+ std::atomic<bool> isInvoked = false;
+ auto future = run(pool, [&] { isInvoked = true; });
+ future.waitForFinished();
+ QVERIFY(future.isCanceled());
+ QVERIFY(!isInvoked);
+}
+
+struct LifetimeChecker
+{
+ LifetimeChecker() { ++count; }
+ LifetimeChecker(const LifetimeChecker &) { ++count; }
+ ~LifetimeChecker() { --count; }
+
+ void operator()() { }
+
+ static std::atomic<int> count;
+};
+std::atomic<int> LifetimeChecker::count = 0;
+
+void tst_QtConcurrentRun::nullThreadPoolNoLeak()
+{
+ {
+ QThreadPool *pool = nullptr;
+ auto future = run(pool, LifetimeChecker());
+ future.waitForFinished();
+ }
+ QCOMPARE(LifetimeChecker::count, 0);
+}
QTEST_MAIN(tst_QtConcurrentRun)
#include "tst_qtconcurrentrun.moc"
diff --git a/tests/auto/concurrent/qtconcurrenttask/CMakeLists.txt b/tests/auto/concurrent/qtconcurrenttask/CMakeLists.txt
index 60f5cb47e3..89226eaacc 100644
--- a/tests/auto/concurrent/qtconcurrenttask/CMakeLists.txt
+++ b/tests/auto/concurrent/qtconcurrenttask/CMakeLists.txt
@@ -1,12 +1,19 @@
-# Generated from qtconcurrenttask.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qtconcurrenttask Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qtconcurrenttask LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qtconcurrenttask
SOURCES
tst_qtconcurrenttask.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Concurrent
)
diff --git a/tests/auto/concurrent/qtconcurrenttask/tst_qtconcurrenttask.cpp b/tests/auto/concurrent/qtconcurrenttask/tst_qtconcurrenttask.cpp
index a95f424d0b..d570b0f974 100644
--- a/tests/auto/concurrent/qtconcurrenttask/tst_qtconcurrenttask.cpp
+++ b/tests/auto/concurrent/qtconcurrenttask/tst_qtconcurrenttask.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <qtconcurrenttask.h>
@@ -57,7 +32,7 @@ void tst_QtConcurrentTask::taskWithFreeFunction()
{
QVariant value(42);
- auto result = task(&qvariant_cast<int>)
+ auto result = task([](const QVariant &var){ return qvariant_cast<int>(var); })
.withArguments(value)
.spawn()
.result();
diff --git a/tests/auto/concurrent/qtconcurrentthreadengine/CMakeLists.txt b/tests/auto/concurrent/qtconcurrentthreadengine/CMakeLists.txt
index 8a7f006674..c3c8c9ea59 100644
--- a/tests/auto/concurrent/qtconcurrentthreadengine/CMakeLists.txt
+++ b/tests/auto/concurrent/qtconcurrentthreadengine/CMakeLists.txt
@@ -1,12 +1,19 @@
-# Generated from qtconcurrentthreadengine.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qtconcurrentthreadengine Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qtconcurrentthreadengine LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qtconcurrentthreadengine
SOURCES
tst_qtconcurrentthreadengine.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Concurrent
)
diff --git a/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp b/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
index 85f83c61f7..0151b13693 100644
--- a/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+++ b/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
@@ -1,35 +1,14 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
+
#include <qtconcurrentthreadengine.h>
#include <qexception.h>
#include <QThread>
#include <QElapsedTimer>
#include <QTest>
+#include <QSet>
using namespace QtConcurrent;
@@ -255,25 +234,21 @@ public:
void tst_QtConcurrentThreadEngine::threadCount()
{
- //QTBUG-23333: This test is unstable
-
const int repeats = 10;
for (int i = 0; i < repeats; ++i) {
(new ThreadCountUser())->startAsynchronously().waitForFinished();
- const auto count = threads.count();
- const auto count_expected = QThreadPool::globalInstance()->maxThreadCount();
- if (count != count_expected)
- QEXPECT_FAIL("", "QTBUG-23333", Abort);
- QCOMPARE(count, count_expected);
+ const auto count = threads.size();
+ const auto maxThreadCount = QThreadPool::globalInstance()->maxThreadCount();
+ QVERIFY(count <= maxThreadCount);
+ QVERIFY(!threads.contains(QThread::currentThread()));
}
// Set the finish flag immediately, this should give us one thread only.
for (int i = 0; i < repeats; ++i) {
(new ThreadCountUser(true /*finishImmediately*/))->startAsynchronously().waitForFinished();
- const auto count = threads.count();
- if (count != 1)
- QEXPECT_FAIL("", "QTBUG-23333", Abort);
+ const auto count = threads.size();
QCOMPARE(count, 1);
+ QVERIFY(!threads.contains(QThread::currentThread()));
}
}
@@ -299,7 +274,7 @@ void tst_QtConcurrentThreadEngine::multipleResults()
{
MultipleResultsUser *engine = new MultipleResultsUser();
QFuture<int> f = engine->startAsynchronously();
- QCOMPARE(f.results().count() , 10);
+ QCOMPARE(f.results().size() , 10);
QCOMPARE(f.resultAt(0), 0);
QCOMPARE(f.resultAt(5), 5);
QCOMPARE(f.resultAt(9), 9);
diff --git a/tests/auto/concurrent/testhelper_functions.h b/tests/auto/concurrent/testhelper_functions.h
index e890053e5c..88c2e28910 100644
--- a/tests/auto/concurrent/testhelper_functions.h
+++ b/tests/auto/concurrent/testhelper_functions.h
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef FUNCTIONS_H
#define FUNCTIONS_H
+#include <QList>
+
#include <vector>
bool keepEvenIntegers(const int &x)
@@ -196,4 +173,11 @@ private:
std::vector<T> data;
};
+struct NonTemplateSequence : public QList<int>
+{
+ NonTemplateSequence() = default;
+
+ NonTemplateSequence(std::initializer_list<int> args) : QList(args) { }
+};
+
#endif