From cdbdb8b10ac8789a0638ddc1d4da3fc76a512963 Mon Sep 17 00:00:00 2001 From: BrSh31 Date: Tue, 4 Nov 2025 21:57:28 +0100 Subject: [PATCH] rot_3d and transpose test added --- tests/test_rot3D.py | 18 ++++++++++++++++++ tests/test_transpose.py | 12 ++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 tests/test_rot3D.py create mode 100644 tests/test_transpose.py diff --git a/tests/test_rot3D.py b/tests/test_rot3D.py new file mode 100644 index 0000000..5c664ae --- /dev/null +++ b/tests/test_rot3D.py @@ -0,0 +1,18 @@ +import math, pytest +from matrixmania import rot_3D + +def test_rot_3D_x_axis(): + angle = math.pi / 2 + R = rot_3D(angle, 'x') + expected = [ + [1, 0, 0], + [0, 0, -1], + [0, 1, 0] + ] + for r, e in zip(R, expected): + for rv, ev in zip(r, e): + assert math.isclose(rv, ev, abs_tol=1e-9) + +def test_rot_3D_invalid_axis(): + with pytest.raises(ValueError): + rot_3D(math.pi/4, 'a') \ No newline at end of file diff --git a/tests/test_transpose.py b/tests/test_transpose.py new file mode 100644 index 0000000..1875ea7 --- /dev/null +++ b/tests/test_transpose.py @@ -0,0 +1,12 @@ +import math, pytest +from matrixmania import transpose + +def test_transpose_basic(): + matrix = [[1, 2, 3], [4, 5, 6]] + expected = [[1, 4], [2, 5], [3, 6]] + assert transpose(matrix) == expected + +def test_transpose_invalid(): + matrix = [[1, 2], [3]] + with pytest.raises(ValueError): + transpose(matrix) \ No newline at end of file