Skip to content

Commit

Permalink
Fix equality test for QgsRasterRange when min/max is nan
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jun 13, 2018
1 parent e14862e commit efb44ad
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/core/raster/qgsrasterrange.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ class CORE_EXPORT QgsRasterRange

inline bool operator==( QgsRasterRange o ) const
{
return qgsDoubleNear( mMin, o.mMin ) && qgsDoubleNear( mMax, o.mMax );
return ( ( std::isnan( mMin ) && std::isnan( o.mMin ) ) || qgsDoubleNear( mMin, o.mMin ) )
&& ( ( std::isnan( mMax ) && std::isnan( o.mMax ) ) || qgsDoubleNear( mMax, o.mMax ) );
}

/**
Expand Down
10 changes: 10 additions & 0 deletions tests/src/python/test_qgsrasterrange.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ def testEquality(self):
range = QgsRasterRange()
range2 = QgsRasterRange()
self.assertEqual(range, range2)
range.setMin(1)
self.assertNotEqual(range, range2)
range2.setMin(1)
self.assertEqual(range, range2)
range = QgsRasterRange()
range2 = QgsRasterRange()
range.setMax(5)
self.assertNotEqual(range, range2)
range2.setMax(5)
self.assertEqual(range, range2)


if __name__ == '__main__':
Expand Down

0 comments on commit efb44ad

Please sign in to comment.