From fcf1b7cbc9fb046a93354a819a3012b43cb61c1e Mon Sep 17 00:00:00 2001 From: fdai7764 Date: Fri, 19 Jan 2024 11:44:52 +0100 Subject: [PATCH] Added test for fraction conversion to decimal as well as corresponding functionality --- src/main/py/fractions.py | 2 ++ src/test/py/test_fractions.py | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 src/main/py/fractions.py create mode 100644 src/test/py/test_fractions.py diff --git a/src/main/py/fractions.py b/src/main/py/fractions.py new file mode 100644 index 0000000..24a04cf --- /dev/null +++ b/src/main/py/fractions.py @@ -0,0 +1,2 @@ +def frac_to_dec(num, denom): + return num/denom \ No newline at end of file diff --git a/src/test/py/test_fractions.py b/src/test/py/test_fractions.py new file mode 100644 index 0000000..9c856c1 --- /dev/null +++ b/src/test/py/test_fractions.py @@ -0,0 +1,17 @@ +import unittest +from src.main.py.fractions import * + + +class fractions(unittest.TestCase): + def setUp(self): + pass + + def tearDown(self): + pass + + def test_dec_value_of_20_by_5_should_be_4(self): + self.assertEqual(frac_to_dec(20,5), 4) # add assertion here + + +if __name__ == '__main__': + unittest.main()