forked from co/TheLastRogue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
geometry_test.py
83 lines (75 loc) · 2.07 KB
/
geometry_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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import unittest
from geometry import other_side_of_point_direction, other_side_of_point
class TestComposition(unittest.TestCase):
def setUp(self):
pass
def test_other_side_of_point_direction_should_return_right_when_target_on_left(self):
"""
1, 2, r
.....
.12r.
.....
"""
p1 = (-1, 0)
p2 = (0, 0)
expected_r = (1, 0)
self.assertEqual(other_side_of_point_direction(p1, p2), expected_r)
def test_other_side_of_point_direction_should_return_down_when_target_above(self):
"""
1, 2, r
..1..
..2..
..r..
"""
p1 = (0, -1)
p2 = (0, 0)
expected_r = (0, 1)
self.assertEqual(other_side_of_point_direction(p1, p2), expected_r)
def test_other_side_of_point_direction_should_return_down_left_when_target_up_right(self):
"""
1, 2, r
...1.
..2..
.r...
"""
p1 = (1, -1)
p2 = (0, 0)
expected_r = (-1, 1)
self.assertEqual(other_side_of_point_direction(p1, p2), expected_r)
def test_other_side_of_point_direction_should_return_down_left_when_target_up_right(self):
"""
1, 2, r
...1.
..2..
.r...
"""
p1 = (1, -1)
p2 = (0, 0)
expected_r = (-1, 1)
self.assertEqual(other_side_of_point_direction(p1, p2), expected_r)
def test_other_side_of_point_should_return_down_when_target_is_up(self):
"""
1, 2, r
...1.
.....
.....
..2..
..r..
"""
p1 = (1, -3)
p2 = (0, 0)
expected_r = (0, 1)
self.assertEqual(other_side_of_point(p1, p2), expected_r)
def test_other_side_of_point_should_return_down_left_when_target_up_right(self):
"""
1, 2, r
.......1.
.........
.........
...2.....
..r......
"""
p1 = (4, -3)
p2 = (0, 0)
expected_r = (-1, 1)
self.assertEqual(other_side_of_point(p1, p2), expected_r)