forked from KulEDmitr/geometric_lib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_triangle.py
More file actions
56 lines (42 loc) · 1.57 KB
/
test_triangle.py
File metadata and controls
56 lines (42 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import unittest
from triangle import *
class TriangleTestCase(unittest.TestCase):
def test_area_zero(self):
res = area(100, 0)
self.assertEqual(res, 0)
def test_area_random(self):
res = area(123458, 12)
self.assertEqual(res, 740748)
def test_area_minus(self):
res = area(-123458, 12)
self.assertEqual(res, -740748)
def test_area_random_big(self):
res = area(123456789, 98765)
self.assertEqual(res, 6096604882792.5)
def test_area_string(self):
with self.assertRaises(TypeError):
res = area("134", 10)
def test_area_double(self):
res = area(1.78965, 4)
self.assertEqual(res, 3.5793)
def test_area_underscore_number(self):
res = area(4_000,78)
self.assertEqual(res, 156000)
def test_perimeter_zero(self):
with self.assertRaises(TypeError):
res = perimeter(100, 0, 5)
def test_perimeter_random(self):
res = perimeter(126789, 132467, 159256)
self.assertEqual(res, 418512)
def test_perimeter_minus(self):
with self.assertRaises(TypeError):
res = perimeter(-126789, 132467, 159256)
def test_perimeter_random_wrong(self):
with self.assertRaises(TypeError):
res = perimeter(126789, 132467, 359256)
def test_perimeter_string(self):
with self.assertRaises(TypeError):
res = perimeter("134", 100, 50)
def test_perimeter_underscore_number(self):
res = perimeter(126_789, 132467, 159256)
self.assertEqual(res, 418512)