diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000..a28f53a113 Binary files /dev/null and b/.DS_Store differ diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000000..3a2bcfdf55 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,45 @@ + +name: CI/CD + +on: + push: + branches: + - cicd_409308 + pull_request: + branches: + - cicd_409308 + +jobs: + test-on-linux: + runs-on: ubuntu-latest + steps: + - name: repository clone + uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: "3.10" + architecture: x64 + - name: Run tests + run: | + python -m unittest "testcircle.py" + python -m unittest "testrectangle.py" + python -m unittest "testsquare.py" + python -m unittest "testtriangle.py" + + test-on-windows: + runs-on: windows-latest + steps: + - name: repository clone + uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: "3.10" + architecture: x64 + - name: Run tests + run: | + python -m unittest "testcircle.py" + python -m unittest "testrectangle.py" + python -m unittest "testsquare.py" + python -m unittest "testtriangle.py" diff --git a/docs/.idea/.gitignore b/docs/.idea/.gitignore new file mode 100644 index 0000000000..13566b81b0 --- /dev/null +++ b/docs/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/docs/.idea/docs.iml b/docs/.idea/docs.iml new file mode 100644 index 0000000000..d0876a78d0 --- /dev/null +++ b/docs/.idea/docs.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/docs/.idea/inspectionProfiles/profiles_settings.xml b/docs/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000000..105ce2da2d --- /dev/null +++ b/docs/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/docs/.idea/modules.xml b/docs/.idea/modules.xml new file mode 100644 index 0000000000..6049cfe013 --- /dev/null +++ b/docs/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/docs/.idea/vcs.xml b/docs/.idea/vcs.xml new file mode 100644 index 0000000000..6c0b863585 --- /dev/null +++ b/docs/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/docs/README.md b/docs/README.md index 63f8727939..d1d8a1463f 100644 --- a/docs/README.md +++ b/docs/README.md @@ -7,4 +7,10 @@ ## Perimeter - Circle: P = 2πR - Rectangle: P = 2a + 2b -- Square: P = 4a \ No newline at end of file +- Square: P = 4a + +--- + +##Results: +- Successful tests: 4 +- Unsuccessful test: 8 \ No newline at end of file diff --git a/rectangle.py b/rectangle.py new file mode 100644 index 0000000000..daa623b2c4 --- /dev/null +++ b/rectangle.py @@ -0,0 +1,5 @@ +def area(a, b): + return a * b + +def perimeter(a, b): + return 2*(a + b) \ No newline at end of file diff --git a/testcircle.py b/testcircle.py new file mode 100644 index 0000000000..24b16a5446 --- /dev/null +++ b/testcircle.py @@ -0,0 +1,30 @@ +import unittest +from circle import area +from circle import perimeter +from math import pi + + +class CircleTestCase(unittest.TestCase): + def test_int(self): + self.assertAlmostEqual(area(3),28.26, delta=0.01) + def test_int(self): + self.assertAlmostEqual(perimeter(3),18.84, delta=0.01) + + def test_negativenumbers(self): + with self.assertRaises(ValueError): + (area(-3)) + def test_negativenumbers(self): + with self.assertRaises(ValueError): + (perimeter(-3)) + + + def test_str(self): + with self.assertRaises(TypeError): + (area('abc')) + + def test_str(self): + with self.assertRaises(TypeError): + (perimeter('abc')) + +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/testrectangle.py b/testrectangle.py new file mode 100644 index 0000000000..0bfc8d4825 --- /dev/null +++ b/testrectangle.py @@ -0,0 +1,26 @@ +import unittest +from rectangle import area +from rectangle import perimeter +class RectangleTestCase(unittest.TestCase): + def test_int(self): + self.assertEqual(area(5,3),15) + def test_int(self): + self.assertEqual(perimeter(5,3),16) + + def test_negativenumbers(self): + with self.assertRaises(ValueError): + (area(-5, 3)) + def test_negativenumbers(self): + with self.assertRaises(ValueError): + (perimeter(-5, 3)) + + + def test_str(self): + with self.assertRaises(TypeError): + (area('bcd','bcd')) + def test_str(self): + with self.assertRaises(TypeError): + (perimeter('bcd', 'bcd')) + +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/testsquare.py b/testsquare.py new file mode 100644 index 0000000000..c5814b4369 --- /dev/null +++ b/testsquare.py @@ -0,0 +1,25 @@ +import unittest +from square import area +from square import perimeter +class SquareTestCase(unittest.TestCase): + def test_int(self): + self.assertEqual(area(7),7*7) + def test_int(self): + self.assertEqual(perimeter(7),4*7) + + def test_negativenumbers(self): + with self.assertRaises(ValueError): + (area(-7)) + + def test_negativenumbers(self): + with self.assertRaises(ValueError): + (perimeter(-7)) + def test_str(self): + with self.assertRaises(TypeError): + (area('cde','cde')) + + def test_str(self): + with self.assertRaises(TypeError): + (perimeter('cde','cde')) +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/testtriangle.py b/testtriangle.py new file mode 100644 index 0000000000..09d126f7f3 --- /dev/null +++ b/testtriangle.py @@ -0,0 +1,39 @@ +import unittest +from triangle import area +from triangle import perimeter +class TriangleTestCase(unittest.TestCase): + def test_int(self): + a = 9 + b = 10 + c = 11 + h = 13 + self.assertEqual(area(a,h),a*h/2) + def test_int(self): + a = 9 + b = 10 + c = 11 + h = 13 + self.assertEqual(perimeter(a,b,c),a+b+c) + + def test_negativenumbers(self): + a = -9 + b = 10 + c = -11 + h = 13 + with self.assertRaises(ValueError): + (area(a,h)) + + def test_negativenumbers(self): + a = -9 + b = 10 + c = -11 + h = 13 + with self.assertRaises(ValueError): + (perimeter(a, b, c)) + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/triangle.py b/triangle.py new file mode 100644 index 0000000000..c2dc5c91b3 --- /dev/null +++ b/triangle.py @@ -0,0 +1,7 @@ + +def area(a, h): + return a * h / 2 + + +def perimeter(a, b, c): + return a + b + c