Skip to content
Permalink
Browse files

Fix equality test for QgsRasterRange when min/max is nan

  • Loading branch information
nyalldawson committed Jun 13, 2018
1 parent e14862e commit efb44ad8e652a5085fdaec6ff75cfe29fea7a929
Showing with 12 additions and 1 deletion.
  1. +2 −1 src/core/raster/qgsrasterrange.h
  2. +10 −0 tests/src/python/test_qgsrasterrange.py
@@ -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 ) );
}

/**
@@ -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__':

0 comments on commit efb44ad

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