Skip to content

Commit

Permalink
sipification problem and unit test attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
pierreloicq authored and nyalldawson committed Sep 14, 2018
1 parent 6443df6 commit cb382ed
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
Expand Up @@ -330,8 +330,8 @@ Reset the label decimal places to a numberbased on the minimum class interval
const QgsRendererRangeLabelFormat &legendFormat = QgsRendererRangeLabelFormat(),
bool useSymmetricMode = false,
double symmetryPoint = 0.0,
QStringList listForCboPrettyBreaks = {},
bool astride = false);
QStringList listForCboPrettyBreaks = QStringList(),
bool astride = false );
%Docstring
Creates a new graduated renderer.

Expand Down Expand Up @@ -518,9 +518,8 @@ Gets the symbol which is used to represent ``value``.
Returns the matching legend key for a value.
%End


QStringList mListForCboPrettyBreaks = {};



private:
QgsGraduatedSymbolRenderer( const QgsGraduatedSymbolRenderer & );
QgsGraduatedSymbolRenderer &operator=( const QgsGraduatedSymbolRenderer & );
Expand Down
4 changes: 2 additions & 2 deletions src/core/symbology/qgsgraduatedsymbolrenderer.h
Expand Up @@ -327,7 +327,7 @@ class CORE_EXPORT QgsGraduatedSymbolRenderer : public QgsFeatureRenderer
const QgsRendererRangeLabelFormat &legendFormat = QgsRendererRangeLabelFormat(),
bool useSymmetricMode = false,
double symmetryPoint = 0.0,
QStringList listForCboPrettyBreaks = {},
QStringList listForCboPrettyBreaks = QStringList(),
bool astride = false );

//! create renderer from XML element
Expand Down Expand Up @@ -483,7 +483,7 @@ class CORE_EXPORT QgsGraduatedSymbolRenderer : public QgsFeatureRenderer

bool mUseSymmetricMode = false;
double mSymmetryPoint = 0.0;
QStringList mListForCboPrettyBreaks = {};
QStringList mListForCboPrettyBreaks = QStringList();
bool mAstride = false;

private:
Expand Down
29 changes: 29 additions & 0 deletions tests/src/core/testqgsgraduatedsymbolrenderer.cpp
Expand Up @@ -20,6 +20,10 @@

#include "qgsgraduatedsymbolrenderer.h"

/** \ingroup UnitTests
* This is a unit test for the qgsGraduatedSymbolRenderer class.
*/

class TestQgsGraduatedSymbolRenderer: public QObject
{
Q_OBJECT
Expand All @@ -31,6 +35,7 @@ class TestQgsGraduatedSymbolRenderer: public QObject
void cleanup();// will be called after every testfunction.
void rangesOverlap();
void rangesHaveGaps();
void _makeBreaksSymmetric(QList<double> &breaks, double symmetryPoint, bool astride);


private:
Expand Down Expand Up @@ -136,5 +141,29 @@ void TestQgsGraduatedSymbolRenderer::rangesHaveGaps()
QVERIFY( renderer.rangesHaveGaps() );
}

void TestQgsGraduatedSymbolRenderer::_makeBreaksSymmetric(QList<double> &breaks, double symmetryPoint, bool astride)
{
const QList<double> unchanged_breaks = {1235, 1023, 997, 800, 555, 10, 1, -5, -11, -423, -811};

// with astride = false
breaks = unchanged_breaks;
symmetryPoint = 12.0;
astride = false;
_makeBreaksSymmetric( breaks, symmetryPoint, astride );

QVERIFY( breaks.contains( symmetryPoint) );
// /!\ breaks contain the maximum of the distrib but not the minimum ?
QVERIFY( breaks.count() % 2 == 0 );

// with astride = true
breaks = unchanged_breaks;
symmetryPoint = 666.3;
astride = true;
_makeBreaksSymmetric( breaks, symmetryPoint, astride );

QVERIFY( breaks.contains( symmetryPoint) );
QVERIFY( breaks.count() % 2 != 0 );
}

QGSTEST_MAIN( TestQgsGraduatedSymbolRenderer )
#include "testqgsgraduatedsymbolrenderer.moc"

0 comments on commit cb382ed

Please sign in to comment.