2929)
3030
3131import unittest
32+ import pytest
3233
3334
3435class TestPower (unittest .TestCase ):
@@ -128,8 +129,37 @@ def test_gcd(self):
128129 self .assertEqual (4 , gcd (8 , 12 ))
129130 self .assertEqual (1 , gcd (13 , 17 ))
130131
132+ def test_gcd_non_integer_input (self ):
133+ with pytest .raises (ValueError , match = r"Input arguments are not integers" ):
134+ gcd (1.0 , 5 )
135+ gcd (5 , 6.7 )
136+ gcd (33.8649 , 6.12312312 )
137+
138+ def test_gcd_zero_input (self ):
139+ with pytest .raises (ValueError , match = r"One or more input arguments equals zero" ):
140+ gcd (0 , 12 )
141+ gcd (12 , 0 )
142+ gcd (0 , 0 )
143+
144+ def test_gcd_negative_input (self ):
145+ self .assertEqual (1 , gcd (- 13 , - 17 ))
146+ self .assertEqual (4 , gcd (- 8 , 12 ))
147+ self .assertEqual (8 , gcd (24 , - 16 ))
148+
131149 def test_lcm (self ):
132150 self .assertEqual (24 , lcm (8 , 12 ))
151+ self .assertEqual (5767 , lcm (73 , 79 ))
152+
153+ def test_lcm_negative_numbers (self ):
154+ self .assertEqual (24 , lcm (- 8 , - 12 ))
155+ self .assertEqual (5767 , lcm (73 , - 79 ))
156+ self .assertEqual (1 , lcm (- 1 , 1 ))
157+
158+ def test_lcm_zero_input (self ):
159+ with pytest .raises (ValueError , match = r"One or more input arguments equals zero" ):
160+ lcm (0 , 12 )
161+ lcm (12 , 0 )
162+ lcm (0 , 0 )
133163
134164 def test_trailing_zero (self ):
135165 self .assertEqual (1 , trailing_zero (34 ))
@@ -140,6 +170,7 @@ def test_gcd_bit(self):
140170 self .assertEqual (1 , gcd (13 , 17 ))
141171
142172
173+
143174class TestGenerateStroboGrammatic (unittest .TestCase ):
144175 """[summary]
145176 Test for the file generate_strobogrammatic.py
0 commit comments