/
plane_test.py
50 lines (33 loc) · 1.31 KB
/
plane_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
import unittest
import plane
from plane import Plane
from vector import Vector
class ParallelPlanesTest(unittest.TestCase):
def test_parallel_planes_are_parallel(self):
l1 = Plane(Vector([2,3,4]), 6)
l2 = Plane(Vector([2,3,4]), 12)
self.assertTrue(l1.parallelTo(l2))
self.assertTrue(l2.parallelTo(l1))
def test_non_parallel_planes_are_not_parallel(self):
l1 = Plane(Vector([2,3,4]), 6)
l2 = Plane(Vector([3,2,1]), 6)
self.assertFalse(l1.parallelTo(l2))
self.assertFalse(l2.parallelTo(l1))
# 'coincident' planes are the same plane
class CoincidentPlanesTest(unittest.TestCase):
def test_coincident_planes_are_coincident(self):
l1 = Plane(Vector([1,1,1]), 1)
l2 = Plane(Vector([-3,-3,-3]), -3)
self.assertTrue(l1.coincidentTo(l2))
self.assertTrue(l2.coincidentTo(l1))
def test_non_coincident_planes_are_not_coincident(self):
l1 = Plane(Vector([1,1,1]), 1)
l2 = Plane(Vector([1,1,1]), 2)
self.assertFalse(l1.coincidentTo(l2))
self.assertFalse(l2.coincidentTo(l1))
def test_equal_overload_uses_coincident_planes(self):
l1 = Plane(Vector([1,1,1]), 1)
l2 = Plane(Vector([-3,-3,-3]), -3)
self.assertTrue(l1 == l2)
if __name__ == '__main__':
unittest.main()