Skip to content
Permalink
Browse files

Fix failing equality operator test

  • Loading branch information
nyalldawson committed Feb 14, 2017
1 parent 3ca0b90 commit 3215173692ccb0c5ac854ca5234ea8d6113a3bf3
Showing with 29 additions and 0 deletions.
  1. +3 −0 python/core/qgsproperty.sip
  2. +15 −0 src/core/qgsproperty.cpp
  3. +3 −0 src/core/qgsproperty.h
  4. +8 −0 tests/src/core/testqgsproperty.cpp
@@ -90,6 +90,9 @@ class QgsProperty

operator bool() const;

bool operator==( const QgsProperty& other ) const;
bool operator!=( const QgsProperty& other ) const;

Type propertyType() const;

bool isActive() const;
@@ -237,6 +237,21 @@ QgsProperty &QgsProperty::operator=( const QgsProperty & other )
return *this;
}

bool QgsProperty::operator==( const QgsProperty& other ) const
{
return d->active == other.d->active
&& d->type == other.d->type
&& ( d->type != StaticProperty || d->staticValue == other.d->staticValue )
&& ( d->type != FieldBasedProperty || d->fieldName == other.d->fieldName )
&& ( d->type != ExpressionBasedProperty || d->expressionString == other.d->expressionString )
&& (( !d->transformer && !other.d->transformer ) || ( d->transformer && other.d->transformer && d->transformer->toExpression( QString() ) == other.d->transformer->toExpression( QString() ) ) );
}

bool QgsProperty::operator!=( const QgsProperty& other ) const
{
return ( !(( *this ) == other ) );
}

QgsProperty::Type QgsProperty::propertyType() const
{
return static_cast< Type >( d->type );
@@ -228,6 +228,9 @@ class CORE_EXPORT QgsProperty
*/
operator bool() const;

bool operator==( const QgsProperty& other ) const;
bool operator!=( const QgsProperty& other ) const;

/**
* Returns the property type.
*/
@@ -593,6 +593,14 @@ void TestQgsProperty::equality()
dd1.setField( QStringLiteral( "field" ) );
QVERIFY( dd1 == dd2 );
QVERIFY( !( dd1 != dd2 ) );

// with transformer
dd1.setTransformer( new QgsGenericNumericTransformer( 1, 2, 3, 4 ) );
QVERIFY( !( dd1 == dd2 ) );
QVERIFY( dd1 != dd2 );
dd2.setTransformer( new QgsGenericNumericTransformer( 1, 2, 3, 4 ) );
QVERIFY( dd1 == dd2 );
QVERIFY( !( dd1 != dd2 ) );
}

void TestQgsProperty::propertyTransformer()

0 comments on commit 3215173

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