Skip to content

Commit ecd5976

Browse files
committed
Added tests for factorial and conversions
1 parent 299ab2b commit ecd5976

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

tests/test_math.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
from pygorithm.math import (
44
lcm,
55
lcm_using_gcd,
6-
sieve_of_eratosthenes)
6+
sieve_of_eratosthenes,
7+
factorial,
8+
conversion)
79

810
class TestLCM(unittest.TestCase):
911
def test_lcm(self):
@@ -16,5 +18,22 @@ class TestSieveOfEratosthenes(unittest.TestCase):
1618
def test_sieve_of_eratosthenes(self):
1719
self.assertEqual(sieve_of_eratosthenes.sieve_of_eratosthenes(10), [2, 3, 5, 7])
1820

21+
class TestFactorial(unittest.TestCase):
22+
def test_factorial(self):
23+
self.assertEqual(factorial.factorial(10), 3628800)
24+
25+
class TestConversion(unittest.TestCase):
26+
def test_dec_to_bin(self):
27+
self.assertEqual(conversion.decimal_to_binary(2), '10')
28+
29+
def test_bin_to_dec(self):
30+
self.assertEqual(conversion.binary_to_decimal('1010'), 10)
31+
32+
def test_dec_to_hex(self):
33+
self.assertEqual(conversion.decimal_to_hex(30), '1E')
34+
35+
def test_hex_to_dex(self):
36+
self.assertEqual(conversion.hex_to_decimal('1E'), 30)
37+
1938
if __name__ == '__main__':
2039
unittest.main()

0 commit comments

Comments
 (0)