Implement Unit Testing for fancymath #8

Merged
TimDiller merged 17 commits from unit_tests into main 2025-10-24 17:10:59 +00:00
6 changed files with 73 additions and 0 deletions
Showing only changes of commit 13ac74132c - Show all commits

View File

@@ -4,6 +4,28 @@ from fancymath.vector import Vector
class TestVector(unittest.TestCase):
def test_cross_product(self):
# given
v1 = Vector(1, 2, 3)
v2 = Vector(3, 2, 1)
# when
v3 = v1 * v2
# then
self.assertIsInstance(v3, Vector)
self.assertEqual(v3.x, -4)
self.assertEqual(v3.y, 8)
self.assertEqual(v3.z, -4)
def test_cross_product_failure(self):
v1 = Vector(1, 2, 3)
v2 = (3, 2, 1)
with self.assertRaises(TypeError):
v1 * v2
def test_add_vector(self):
v1 = Vector(1, 2, 3)
v2 = Vector(-3, -2, -1)