Created unittest for iter_helpers
authorChristian Herdtweck <christian.herdtweck@intra2net.com>
Fri, 22 Jun 2018 12:09:49 +0000 (14:09 +0200)
committerChristian Herdtweck <christian.herdtweck@intra2net.com>
Mon, 8 Oct 2018 07:31:41 +0000 (09:31 +0200)
test/test_iter_helpers.py [new file with mode: 0644]

diff --git a/test/test_iter_helpers.py b/test/test_iter_helpers.py
new file mode 100644 (file)
index 0000000..73bd8b8
--- /dev/null
@@ -0,0 +1,77 @@
+# The software in this package is distributed under the GNU General
+# Public License version 2 (with a special exception described below).
+#
+# A copy of GNU General Public License (GPL) is included in this distribution,
+# in the file COPYING.GPL.
+#
+# As a special exception, if other files instantiate templates or use macros
+# or inline functions from this file, or you compile this file and link it
+# with other works to produce a work based on this file, this file
+# does not by itself cause the resulting work to be covered
+# by the GNU General Public License.
+#
+# However the source code for this file must still be made available
+# in accordance with section (3) of the GNU General Public License.
+#
+# This exception does not invalidate any other reasons why a work based
+# on this file might be covered by the GNU General Public License.
+
+""" test_iter_helpers.py: unit tests for iter_helpers
+
+Tests classes and functions in iter_helpers
+
+Should be able run from python2 and python3!
+
+For help see :py:mod:`unittest`
+
+.. codeauthor:: Intra2net
+"""
+
+from __future__ import print_function
+from __future__ import absolute_import
+
+import unittest
+
+# relative import of tested module ensures we do not test installed version
+from src import iter_helpers
+
+
+class ModuleNameTester(unittest.TestCase):
+    """ only test case in this module, see module doc for more help """
+
+    def test_interesting_repetition(self):
+        """ tests interesting_repetition """
+        self.assertTrue (iter_helpers.interesting_repetition(0))
+        self.assertTrue (iter_helpers.interesting_repetition(1))
+        self.assertTrue (iter_helpers.interesting_repetition(2))
+        self.assertTrue (iter_helpers.interesting_repetition(3))
+        self.assertFalse(iter_helpers.interesting_repetition(4))
+        self.assertTrue (iter_helpers.interesting_repetition(5))
+        self.assertFalse(iter_helpers.interesting_repetition(6))
+        self.assertTrue (iter_helpers.interesting_repetition(7))
+        self.assertFalse(iter_helpers.interesting_repetition(8))
+        self.assertFalse(iter_helpers.interesting_repetition(9))
+        self.assertTrue (iter_helpers.interesting_repetition(10))
+        self.assertTrue (iter_helpers.interesting_repetition(11))
+        self.assertTrue (iter_helpers.interesting_repetition(150))
+        self.assertFalse(iter_helpers.interesting_repetition(151))
+        self.assertTrue (iter_helpers.interesting_repetition(2000))
+        self.assertFalse(iter_helpers.interesting_repetition(2001))
+        self.assertTrue (iter_helpers.interesting_repetition(30000))
+        self.assertFalse(iter_helpers.interesting_repetition(30001))
+        self.assertTrue (iter_helpers.interesting_repetition(500000))
+        self.assertFalse(iter_helpers.interesting_repetition(500001))
+        self.assertTrue (iter_helpers.interesting_repetition(7500000))
+        self.assertFalse(iter_helpers.interesting_repetition(7500001))
+        self.assertTrue (iter_helpers.interesting_repetition(10000000))
+        self.assertFalse(iter_helpers.interesting_repetition(10000001))
+        self.assertTrue (iter_helpers.interesting_repetition(150000000))
+        self.assertFalse(iter_helpers.interesting_repetition(150000001))
+        self.assertTrue (iter_helpers.interesting_repetition(2000000000))
+        self.assertFalse(iter_helpers.interesting_repetition(2000000001))
+        self.assertTrue (iter_helpers.interesting_repetition(30000000000))
+        self.assertFalse(iter_helpers.interesting_repetition(30000000001))
+
+
+if __name__ == '__main__':
+    unittest.main()