Skip to content
Permalink
Browse files

Tests for QgsRasterRange

  • Loading branch information
nyalldawson committed Jun 7, 2018
1 parent a2042a4 commit e14862e3fee614e35c5b112fcaf2c7e7dc1af75e
Showing with 51 additions and 0 deletions.
  1. +1 −0 tests/src/python/CMakeLists.txt
  2. +50 −0 tests/src/python/test_qgsrasterrange.py
@@ -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)
@@ -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.
You can’t perform that action at this time.