]> git.friedersdorff.com Git - max/python_unittesting.git/blobdiff - 3_collatz.py
Add unittests for collatz conjecture
[max/python_unittesting.git] / 3_collatz.py
diff --git a/3_collatz.py b/3_collatz.py
new file mode 100644 (file)
index 0000000..d05c66b
--- /dev/null
@@ -0,0 +1,20 @@
+from collatz import collatz, longest_collatz
+
+def test_length_collatz_13():
+    assert collatz(13) == 9
+
+def test_length_collatz_9():
+    assert collatz(9) == 19
+
+def test_length_collatz_77031():
+    assert collatz(77031) == 350
+
+def test_length_collatz_8400511():
+    assert collatz(8400511) == 685
+
+
+def test_longest_collatz_under_1_000_000():
+    assert longest_collatz(1000000) == 837799
+
+def test_longest_collatz_under_1_000_000_000():
+    assert longest_collatz(1000000000) == 670617279