surfaces/test/vertex.py

36 lines
959 B
Python

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)