summaryrefslogtreecommitdiffstats
path: root/tests/auto/concurrent/qtconcurrentmedian
diff options
context:
space:
mode:
authorKarsten Heimrich <karsten.heimrich@qt.io>2020-04-07 12:34:24 +0200
committerKarsten Heimrich <karsten.heimrich@qt.io>2020-04-09 02:49:18 +0200
commitb75c82f6456edbc00646da15531cfb63f8957817 (patch)
treea11709410f3e2e8f7787eaef8fe1e7f6500ab12f /tests/auto/concurrent/qtconcurrentmedian
parent9ad8b80fb970cfe96c7c7bae781b20528b2ce334 (diff)
Resolve Qt6 TODO items, replace Median and BlockSizeManager
* Replaces the, only internaly used, implementation of template class Median with a fixed size none templated version. * Replaces BlockSizeManager with an updated BlockSizeManager V2, but keeping the original name. * adapt the auto-test to take the fixed size array into account Change-Id: If76cb944676c4a06a7566ad0bc37ded25b81c70c Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Diffstat (limited to 'tests/auto/concurrent/qtconcurrentmedian')
-rw-r--r--tests/auto/concurrent/qtconcurrentmedian/tst_qtconcurrentmedian.cpp42
1 files changed, 27 insertions, 15 deletions
diff --git a/tests/auto/concurrent/qtconcurrentmedian/tst_qtconcurrentmedian.cpp b/tests/auto/concurrent/qtconcurrentmedian/tst_qtconcurrentmedian.cpp
index f5ae80dca5..22e555d2db 100644
--- a/tests/auto/concurrent/qtconcurrentmedian/tst_qtconcurrentmedian.cpp
+++ b/tests/auto/concurrent/qtconcurrentmedian/tst_qtconcurrentmedian.cpp
@@ -39,33 +39,45 @@ private slots:
void tst_QtConcurrentMedian::median_data()
{
- QTest::addColumn<QList<int> >("values");
- QTest::addColumn<int>("expectedMedian");
+ QTest::addColumn<QList<double> >("values");
+ QTest::addColumn<double>("expectedMedian");
QTest::newRow("size=1")
- << (QList<int>() << 1)
- << 1;
+ << (QList<double>() << 1.0)
+ << 0.0; // six 0.0 in front of the actual value
QTest::newRow("size=2")
- << (QList<int>() << 3 << 2)
- << 3;
+ << (QList<double>() << 3.0 << 2.0)
+ << 0.0; // five 0.0 in front of the actual value
QTest::newRow("size=3")
- << (QList<int>() << 3 << 1 << 2)
- << 2;
+ << (QList<double>() << 3.0 << 1.0 << 2.0)
+ << 0.0; // four 0.0 in front of the actual value
- QTest::newRow("gcc bug 58800 (nth_element)")
- << (QList<int>() << 207089 << 202585 << 180067 << 157549 << 211592 << 216096 << 207089)
- << 207089;
+ QTest::newRow("size=4")
+ << (QList<double>() << 3.0 << 1.0 << 2.0 << 4.0)
+ << 1.0; // three 0.0 in front of the first actual value, pick 1.0
+
+ QTest::newRow("size=5")
+ << (QList<double>() << 3.0 << 1.0 << 2.0 << 3.0 << 1.0)
+ << 1.0; // two 0.0 in front of the first actual value, pick 1.0
+
+ QTest::newRow("size=6")
+ << (QList<double>() << 3.0 << 1.0 << 2.0 << 3.0 << 1.0 << 2.0)
+ << 2.0; // one 0.0 in front of the first actual value, pick 2.0
+
+ QTest::newRow("size=7")
+ << QList<double> { 207089.0, 202585.0, 180067.0, 157549.0, 211592.0, 216096.0, 207089.0 }
+ << 207089.0;
}
void tst_QtConcurrentMedian::median()
{
- QFETCH(QList<int> , values);
- QFETCH(int, expectedMedian);
+ QFETCH(QList<double> , values);
+ QFETCH(double, expectedMedian);
- QtConcurrent::Median<int> m(values.size());
- foreach (int value, values)
+ QtConcurrent::Median m;
+ foreach (double value, values)
m.addValue(value);
QCOMPARE(m.median(), expectedMedian);
}