auto test added

This commit is contained in:
BrSh31 2025-11-02 22:46:11 +01:00
parent 21b6b019da
commit d0086d6ae5
3 changed files with 40 additions and 1 deletions

View File

@ -14,3 +14,8 @@ requires = ["hatchling"]
build-backend = "hatchling.build" build-backend = "hatchling.build"
[tool.hatch.build.targets.wheel] [tool.hatch.build.targets.wheel]
packages = ["matrixmania"] packages = ["matrixmania"]
[tool.pytest.ini_options]
pythonpath = [
"."
]

14
tests/test_matmul.py Normal file
View File

@ -0,0 +1,14 @@
from matrixmania.compute import matmul, transpose
import pytest
def test_matmul_basic():
a = [[1, 2], [3, 4]]
b = [[2, 0], [1, 2]]
expected = [[4, 4], [10, 8]]
assert matmul(a, b) == expected
def test_matmul_invalid_dimensions():
a = [[1, 2, 3]]
b = [[1, 2], [3, 4]]
with pytest.raises(ValueError):
matmul(a, b)

20
tests/test_rot.py Normal file
View File

@ -0,0 +1,20 @@
from matrixmania.compute import rot_2D
import math
def test_rot_2D_identity():
"""Rotation by 0 radians should return identity matrix"""
result = rot_2D(0)
expected = [[1, 0], [0, 1]]
assert all(abs(result[i][j] - expected[i][j]) < 1e-9 for i in range(2) for j in range(2))
def test_rot_2D_90_degrees():
"""Rotation by 90° (pi/2 radians)"""
result = rot_2D(math.pi / 2)
expected = [[0, -1], [1, 0]]
assert all(abs(result[i][j] - expected[i][j]) < 1e-9 for i in range(2) for j in range(2))
def test_rot_2D_180_degrees():
"""Rotation by 180° (pi radians)"""
result = rot_2D(math.pi)
expected = [[-1, 0], [0, -1]]
assert all(abs(result[i][j] - expected[i][j]) < 1e-9 for i in range(2) for j in range(2))