rot_3d and transpose test added

This commit is contained in:
BrSh31 2025-11-04 21:57:28 +01:00
parent deba331de9
commit cdbdb8b10a
2 changed files with 30 additions and 0 deletions

18
tests/test_rot3D.py Normal file
View File

@ -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')

12
tests/test_transpose.py Normal file
View File

@ -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)