Skip to content
Permalink
Browse files

sipification problem and unit test attempt

  • Loading branch information
pierreloicq authored and nyalldawson committed Sep 14, 2018
1 parent 6443df6 commit cb382ededd7151242d673490561b1f58158372d8
@@ -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.

@@ -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 & );
@@ -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
@@ -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:
@@ -20,6 +20,10 @@

#include "qgsgraduatedsymbolrenderer.h"

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

class TestQgsGraduatedSymbolRenderer: public QObject
{
Q_OBJECT
@@ -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:
@@ -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.
You can’t perform that action at this time.