From: Maximilian Friedersdorff Date: Mon, 4 Mar 2019 21:26:50 +0000 (+0000) Subject: Add unittests for collatz conjecture X-Git-Url: https://git.friedersdorff.com/?p=max%2Fpython_unittesting.git;a=commitdiff_plain;h=44e9c3ea492f2fbb43f6235deb9ec7b6ebb6f5e1 Add unittests for collatz conjecture --- diff --git a/3_collatz.py b/3_collatz.py new file mode 100644 index 0000000..d05c66b --- /dev/null +++ b/3_collatz.py @@ -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