Skip to content
Permalink
Browse files

Fix incorrect calculation of max in QgsStatisticalSummary

  • Loading branch information
nyalldawson committed May 10, 2015
1 parent 6a312be commit e371219d87790bb2a5e692eb7d2e6ba100833d1a
Showing with 15 additions and 1 deletion.
  1. +1 −1 src/core/qgsstatisticalsummary.cpp
  2. +14 −0 tests/src/core/testqgsstatisticalsummary.cpp
@@ -36,7 +36,7 @@ void QgsStatisticalSummary::reset()
mMean = 0;
mMedian = 0;
mMin = std::numeric_limits<double>::max();
mMax = std::numeric_limits<double>::min();
mMax = -std::numeric_limits<double>::max();
mStdev = 0;
mSampleStdev = 0;
mMinority = 0;
@@ -32,6 +32,7 @@ class TestQgsStatisticSummary: public QObject
void init();// will be called before each testfunction is executed.
void cleanup();// will be called after every testfunction.
void stats();
void maxMin();

private:

@@ -119,5 +120,18 @@ void TestQgsStatisticSummary::stats()
QCOMPARE( s.interQuartileRange(), 11.0 );
}

void TestQgsStatisticSummary::maxMin()
{
QgsStatisticalSummary s( QgsStatisticalSummary::All );

//test max/min of negative value list
QList<double> negativeVals;
negativeVals << -5.0 << -10.0 << -15.0;
s.calculate( negativeVals );

QCOMPARE( s.min(), -15.0 );
QCOMPARE( s.max(), -5.0 );
}

QTEST_MAIN( TestQgsStatisticSummary )
#include "testqgsstatisticalsummary.moc"

0 comments on commit e371219

Please sign in to comment.
You can’t perform that action at this time.