Files

38 lines
822 B
Python

import pytest
from matrixmania import rot_2D, rot_3D
import math
def test_rot_2D():
#Arrange
theta = math.pi / 2
expected_value = [
[0.0, -1.0],
[1.0, 0.0]
]
#Act
result = rot_2D(theta)
#Assert
assert len(result) == len(expected_value)
for row_result, row_expected in zip(result, expected_value):
assert row_result == pytest.approx(row_expected, abs=1e-5)
def test_rot_3D():
#Arrange
angle = 90
axis = "z"
expected_value = [
[0.0, -1.0, 0.0],
[1.0, 0.0, 0.0],
[0.0, 0.0, 1.0]
]
#Act
result = rot_3D(angle,axis)
#Assert
assert len(result) == len(expected_value)
for row_result, row_expected in zip(result, expected_value):
assert row_result == pytest.approx(row_expected, abs=1e-5)