From a8b7330197464ef21e5eae8a5d242c830cc79cf8 Mon Sep 17 00:00:00 2001 From: Psudopodiya Date: Sat, 30 Sep 2023 16:37:33 +0530 Subject: [PATCH 1/2] Added the test cases for add, sub, div, milt, mod definations --- .../test_basic_math.cpython-311.pyc | Bin 0 -> 5513 bytes easyPythonpi/test_basic_math.py | 56 ++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 easyPythonpi/__pycache__/test_basic_math.cpython-311.pyc create mode 100644 easyPythonpi/test_basic_math.py diff --git a/easyPythonpi/__pycache__/test_basic_math.cpython-311.pyc b/easyPythonpi/__pycache__/test_basic_math.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..52b8b6abc5d246d7e764ddb1adcb23cd0d542e91 GIT binary patch literal 5513 zcmd5=&2JM&6rc63lTBh1428y&1`<%I1;uf`AgJQAPC=AhAmlHsI9J#%)NerH9-)K^S(0x23TYukJ|#4?K&YsZ8zHCD zqDaUxd>dC<)Fdk1xhH7hn(V28_@iz$lFXZlO`YUb+Qv zEA0i0(XCfVB36xkp&8}{)to+8$Y)G_CU0b%so;!&GJ=b(e+_Vtd_x|Nho(yi}OV>Y3zuHFMLPnbO!bSZi|q zP^}dcnw2Tl&@)O77&$yUSB>*$@IGaB#?Vduwx;9@IT*?)9`rGHI8YdAtRDoJC#!Pg zvE27a?)z!C6;G4~N|!6~q!mxD#47TLC6APyyAI;y|JjUx;i@6A47Y`KAw&ThWV2o< zu45*zT~{~Fj8_=PHrg^XSW+wTAuB$#GEk96EqS!;+-w_kdZo+=t!n92TU$-V$?Nc9 zxc)q07uHU+Cuf_h33qgJS}AI5rnr9teQ~8CFnW7B_LYoEe8h^6tX!$c6P7$tcJ5bC z$7ZdT$uM1p%FQ|fmPCfmmh}KsMWZm~Q<{Fx3$&O_&6s|h8VcYjum`Fliy^#ro$%<0 ztrMZihK=mPIe2a4-PYy0yIf4XXq~PoF6#{~(6j5V(zADP4%`#8U8QGJy%t`4;ih_f z?11;RH-f>^R3)CW;;EHXMIN){v9fc&`u+FN5qNZQ)vrk~=NejXixGr#g{-Oj^rFES zZ=21|ZQcw5d-Me`cCd7+bjxOJxFU~R@_5;~Uq54QEoMoyEr$D!{V;JKJv+GBxQm^d zYdFvY0Y>8$d~XwEyglku`v(tO^r8AwD6zJT4EPxF+Dvg|6YO|9^#?L_dPS(jhpqVV z%9)CM)RK>uo%{8xO;C);4xzFjQ}*dApKLKUk?Oa7y7WG04q9}oDWFM4PR(XDW=CD`CY@z$hVe*;4S}$a(f#Wg zwLO>uX$cIZXm>N(EaqCp@r}6+>URL%SpOaX(urv7akT$YwEy=#LzQUCil)|x(6x`l zACW#Qvitt!2SOz>XhjCgk-;_5Y2*@5Q1+?Yq1m-v>DjYq?H)Iu)iE0Tap!UISLsx! z^S7`7*gi~u2!b1^fV;6Tn@zrCek##$tAfyu*1D}0os%_;Z}~~jFgmI6IF|>$s4A^) zC^tiW>d?p|p~ZjL2j!9NgwgXDlK`8_BR#3+n@p&@!Bg8%fPDxnVaE}?4k^mb2PxpW z)1Cl3aRj(idqEoTR=b_rI=92dk&z<^m`Sk{?Fee57P$WAQN^hWN-g}N+)Yp5;Ku+a z6Wgk?qU6<_rYO~JMS%{5ES4jRf`7s^TG&?XuoD4;PPQ8X;|R7F;RA#O!bb=xgi(Z} z2qzIvBb)_TY8(>$?*t~{Qw01Pe*?_BpEXGckAjb~)Q1u9Vs^chZ z0|+0%str)}v`%2F4gS^^;ZPXdt_yMq=jVd#nUyQo?13eIY;qoOGjgh)SCm9YRW9Up z6HS6^L{&y}IHSTpUdR?Z2T+wzn05i7^ literal 0 HcmV?d00001 diff --git a/easyPythonpi/test_basic_math.py b/easyPythonpi/test_basic_math.py new file mode 100644 index 0000000..18c2be5 --- /dev/null +++ b/easyPythonpi/test_basic_math.py @@ -0,0 +1,56 @@ +import unittest +import easyPythonpi + +class TestMathFunctions(unittest.TestCase): + + def test_add_positive_numbers(self): + self.assertEqual(easyPythonpi.add(2, 3), 5) + + def test_add_negative_numbers(self): + self.assertEqual(easyPythonpi.add(-1, 1), 0) + + def test_add_with_zero(self): + self.assertEqual(easyPythonpi.add(0.5, 0.5), 1.0) + + def test_subtract_positive_numbers(self): + self.assertEqual(easyPythonpi.sub(5, 2), 3) + + def test_subtract_with_zero(self): + self.assertEqual(easyPythonpi.sub(0, 0), 0) + + def test_subtract_negative_numbers(self): + self.assertEqual(easyPythonpi.sub(-1, -1), 0) + + def test_multiply_positive_numbers(self): + self.assertEqual(easyPythonpi.multi(3, 4), 12) + + def test_multiply_by_zero(self): + self.assertEqual(easyPythonpi.multi(0, 5), 0) + + def test_multiply_by_negative_numbers(self): + self.assertEqual(easyPythonpi.multi(-2, 6), -12) + + def test_divide_by_smaller_number(self): + self.assertEqual(easyPythonpi.div(6, 2), 3.0) + + def test_divide_zero_by_number(self): + self.assertEqual(easyPythonpi.div(0, 5), 0.0) + + def test_divide_by_zero_raises_exception(self): + with self.assertRaises(ZeroDivisionError): + easyPythonpi.div(5, 0) + + def test_mod_positive_numbers(self): + self.assertEqual(easyPythonpi.mod(7, 3), 1) + self.assertEqual(easyPythonpi.mod(10, 2), 0) + + def test_mod_zero(self): + self.assertEqual(easyPythonpi.mod(0, 5), 0) + + def test_mod_divide_by_zero(self): + with self.assertRaises(ZeroDivisionError): + easyPythonpi.mod(8, 0) + + +if __name__ == '__main__': + unittest.main() \ No newline at end of file From 8bd6a2f7ba2ab9754985b889ed6dd7b0e503ff75 Mon Sep 17 00:00:00 2001 From: Psudopodiya Date: Sat, 30 Sep 2023 16:39:56 +0530 Subject: [PATCH 2/2] Changed the name fo file to TestBasicMath --- easyPythonpi/{test_basic_math.py => TestBasicMath.py} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename easyPythonpi/{test_basic_math.py => TestBasicMath.py} (97%) diff --git a/easyPythonpi/test_basic_math.py b/easyPythonpi/TestBasicMath.py similarity index 97% rename from easyPythonpi/test_basic_math.py rename to easyPythonpi/TestBasicMath.py index 18c2be5..82d3cea 100644 --- a/easyPythonpi/test_basic_math.py +++ b/easyPythonpi/TestBasicMath.py @@ -1,7 +1,7 @@ import unittest import easyPythonpi -class TestMathFunctions(unittest.TestCase): +class TestBasicMath(unittest.TestCase): def test_add_positive_numbers(self): self.assertEqual(easyPythonpi.add(2, 3), 5)