From 13ac74132c8496cb924f98a568ebb56dfa4ee64a Mon Sep 17 00:00:00 2001 From: Corran Webster Date: Fri, 24 Oct 2025 16:13:25 +0100 Subject: [PATCH] Add cross-product and tests --- test/test_vector.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/test_vector.py b/test/test_vector.py index 1f4ae0c..3606b6d 100644 --- a/test/test_vector.py +++ b/test/test_vector.py @@ -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)