From 5baa1e2d392686211dd8c7c28a60a7381c34c456 Mon Sep 17 00:00:00 2001 From: fdai7764 Date: Sun, 28 Jan 2024 12:25:29 +0100 Subject: [PATCH] added test for conversion from radian to degree with some tolerance as well as corresponding functionality --- src/main/py/trigonometry.py | 3 +++ src/test/py/test_trigonometry.py | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 src/main/py/trigonometry.py create mode 100644 src/test/py/test_trigonometry.py diff --git a/src/main/py/trigonometry.py b/src/main/py/trigonometry.py new file mode 100644 index 0000000..ac7fbce --- /dev/null +++ b/src/main/py/trigonometry.py @@ -0,0 +1,3 @@ +import math +def rad2deg(radNumber): + return (radNumber * 180) / math.pi \ No newline at end of file diff --git a/src/test/py/test_trigonometry.py b/src/test/py/test_trigonometry.py new file mode 100644 index 0000000..fcd919b --- /dev/null +++ b/src/test/py/test_trigonometry.py @@ -0,0 +1,20 @@ +import unittest +from src.main.py.trigonometry import * + + +class MyTestCase(unittest.TestCase): + def setUp(self): + pass + + def tearDown(self): + pass + + def test_rad_2_to_deg_should_be_114_point_59(self): + delta = rad2deg(2) - 114.59 + if delta < 0: + delta *= -1 + self.assertLess(delta, 0.01) + + +if __name__ == '__main__': + unittest.main()