forgot to add the file I said I added a few changesets ago

This commit is contained in:
Stephen M. McQuay 2012-03-19 22:33:23 -06:00
parent 12e82529a2
commit 84712d5613
2 changed files with 35 additions and 0 deletions

0
test/__init__.py Normal file
View File

35
test/vertex.py Normal file
View File

@ -0,0 +1,35 @@
import unittest
from surf.geometry import Vertex
class TestVertexOperations(unittest.TestCase):
def setUp(self):
self.origin = Vertex(0, 0, 0)
self.v1 = Vertex(-1, -1, -1)
self.v2 = Vertex(1, 1, 1)
self.v3 = Vertex(5, 4, 3)
self.v4 = Vertex(10, -2, 13)
self.v5 = Vertex(-4, 15.3, 100)
def test_addition(self):
added_v = self.v1 + self.v2
self.assertEqual(added_v, self.origin)
self.assertEqual(self.v3 + self.v4, Vertex(15, 2, 16))
def test_summation(self):
v = sum((self.v1, self.v2, self.v3, self.v4), Vertex())
self.assertEqual(v, Vertex(15, 2, 16))
v = sum((self.v1, self.v2, self.v3, self.v4, self.v5), Vertex())
self.assertEqual(v, Vertex(11, 17.3, 116))
def test_division(self):
v1 = self.v1 / 2
v2 = self.v1 / 2.0
self.assertEqual(v1, v2)
if __name__ == '__main__':
unittest.main(verbosity=3)