Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
45 changes: 45 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -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"
8 changes: 8 additions & 0 deletions docs/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions docs/.idea/docs.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions docs/.idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions docs/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions docs/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@
## Perimeter
- Circle: P = 2πR
- Rectangle: P = 2a + 2b
- Square: P = 4a
- Square: P = 4a

---

##Results:
- Successful tests: 4
- Unsuccessful test: 8
5 changes: 5 additions & 0 deletions rectangle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def area(a, b):
return a * b

def perimeter(a, b):
return 2*(a + b)
30 changes: 30 additions & 0 deletions testcircle.py
Original file line number Diff line number Diff line change
@@ -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()
26 changes: 26 additions & 0 deletions testrectangle.py
Original file line number Diff line number Diff line change
@@ -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()
25 changes: 25 additions & 0 deletions testsquare.py
Original file line number Diff line number Diff line change
@@ -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()
39 changes: 39 additions & 0 deletions testtriangle.py
Original file line number Diff line number Diff line change
@@ -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()
7 changes: 7 additions & 0 deletions triangle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

def area(a, h):
return a * h / 2


def perimeter(a, b, c):
return a + b + c