Skip to content

Commit

Permalink
Tests for QgsRasterRange
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jun 13, 2018
1 parent a2042a4 commit e14862e
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/src/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ ADD_PYTHON_TEST(PyQgsRasterFileWriter test_qgsrasterfilewriter.py)
ADD_PYTHON_TEST(PyQgsRasterFileWriterTask test_qgsrasterfilewritertask.py)
ADD_PYTHON_TEST(PyQgsRasterLayer test_qgsrasterlayer.py)
ADD_PYTHON_TEST(PyQgsRasterColorRampShader test_qgsrastercolorrampshader.py)
ADD_PYTHON_TEST(PyQgsRasterRange test_qgsrasterrange.py)
ADD_PYTHON_TEST(PyQgsRatioLockButton test_qgsratiolockbutton.py)
ADD_PYTHON_TEST(PyQgsRectangle test_qgsrectangle.py)
ADD_PYTHON_TEST(PyQgsReferencedGeometry test_qgsreferencedgeometry.py)
Expand Down
50 changes: 50 additions & 0 deletions tests/src/python/test_qgsrasterrange.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# -*- coding: utf-8 -*-
"""QGIS Unit tests for QgsRasterRange.
.. note:: This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
"""
__author__ = 'Nyall Dawson'
__date__ = '07/06/2018'
__copyright__ = 'Copyright 2018, The QGIS Project'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

import qgis # NOQA switch sip api

from qgis.core import QgsRasterRange

from qgis.testing import unittest


class TestQgsRasterRange(unittest.TestCase):

def testBasic(self):
range = QgsRasterRange(1, 5)
self.assertEqual(range.min(), 1)
self.assertEqual(range.max(), 5)
range.setMin(2.2)
range.setMax(10.4)
self.assertEqual(range.min(), 2.2)
self.assertEqual(range.max(), 10.4)

def testEquality(self):
range = QgsRasterRange(1, 5)
range2 = QgsRasterRange(1, 5)
self.assertEqual(range, range2)
range2.setMin(2)
self.assertNotEqual(range, range2)
range2.setMin(1)
range2.setMax(4)
self.assertNotEqual(range, range2)
range2.setMax(5)
self.assertEqual(range, range2)
range = QgsRasterRange()
range2 = QgsRasterRange()
self.assertEqual(range, range2)


if __name__ == '__main__':
unittest.main()

0 comments on commit e14862e

Please sign in to comment.