-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhexagon_test.py
53 lines (42 loc) · 1.36 KB
/
hexagon_test.py
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
#!/usr/bin/python
# -*-coding:Utf-8 -*
"""
Test of hexagon module
"""
import unittest
import sfml as sf
from hexagon import Hexagon
from hexagon import HexagonLine
class TestHexagonLine(unittest.TestCase):
"""
Test HexagonLine class
"""
def setUp(self):
"""intialize the environment for all tests"""
self.hexagon = HexagonLine((0, 0), 60, sf.Color(127, 127, 127))
def test_radius(self):
"""test the radius value of hexagon"""
radius = self.hexagon.get_radius()
self.assertEqual(radius, 60)
def test_apothem(self):
"""test the apothem value of hexagon"""
apothem = self.hexagon.get_apothem()
self.assertAlmostEqual(apothem, 51.961524227)
class TestHexagon(unittest.TestCase):
"""
Test Hexagon class
"""
def setUp(self):
"""intialize the environment for all tests"""
self.hexagon = Hexagon((0, 0), 50, sf.Color(127, 127, 127),
sf.Color(127, 127, 127))
def test_radius(self):
"""test the radius value of hexagon"""
radius = self.hexagon.get_radius()
self.assertEqual(radius, 50)
def test_apothem(self):
"""test the apothem value of hexagon"""
apothem = self.hexagon.get_apothem()
self.assertAlmostEqual(apothem, 43.301270189)
if __name__ == '__main__':
unittest.main()