summaryrefslogtreecommitdiffstats
path: root/tests/auto/concurrent/qtconcurrentmedian
diff options
context:
space:
mode:
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);
}