summaryrefslogtreecommitdiffstats
path: root/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp')
-rw-r--r--tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp83
1 files changed, 83 insertions, 0 deletions
diff --git a/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp b/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp
index 93cf1bf99e8..973a9b4fa5b 100644
--- a/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp
+++ b/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp
@@ -201,6 +201,13 @@ 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 }));
+ }
+
#if 0
// not allowed: map() with immutable sequences makes no sense
{
@@ -331,6 +338,13 @@ void tst_QtConcurrentMap::blockingMap()
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
{
@@ -564,6 +578,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 +692,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 }));
@@ -881,6 +917,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);
@@ -1020,6 +1067,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);
@@ -1283,6 +1341,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);
@@ -1420,6 +1490,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);