-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDirectionUnitTests.py
More file actions
50 lines (40 loc) · 1.41 KB
/
DirectionUnitTests.py
File metadata and controls
50 lines (40 loc) · 1.41 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
#!/usr/bin/python2
########################################################################
# File Name: DirectionUnitTests.py
# Authors: Nicole Lewey and Jacob Lundgren
# Date: 12/08/2014
# Class: CS360 - Open Source
# Assignment: Ninja Game - Create Open Source Project
# Purpose: Contains unit tests for the Direction module
########################################################################
# python2 -m unittest DirectionUnitTests
import unittest
from Direction import *
class TestDirectionFunctions(unittest.TestCase):
def setUp(self):
""" Initializes the direction object
"""
self.direction = Direction()
def tearDown(self):
""" There is nothing to tear down
"""
pass
def test_getXOffset(self):
""" Tests that the function returns the proper value for x
offset
"""
self.assertTrue(self.direction.getXOffset() == 0)
def test_getYOffset(self):
""" Tests that the function returns the proper value for y
offset
"""
self.assertTrue(self.direction.getYOffset() == 0)
def test_calcDirection(self):
""" Tests that the correct x and y offsets are being calculated
"""
self.direction.calcDirection(0, 0, 10, 10)
self.assertEqual(math.floor(self.direction._xOffset), -8)
self.assertEqual(math.floor(self.direction._yOffset), -8)
self.direction.calcDirection(-25, 0, 0, 0)
self.assertEqual(self.direction._xOffset, 0)
self.assertEqual(self.direction._yOffset, 0)