Add tabulate and ruff dependencies
This commit is contained in:
1 parent
7909016431
commit
96dce24e8b
6 files changed
+194
-2
No files matched your search
Whitespace-only changes.
@@ -0,0 +1,96 @@
|
||||
from math import pi
|
||||
|
||||
import pytest
|
||||
|
||||
from matrixmania import rot_2D, rot_3D
|
||||
|
||||
|
||||
def test_rot_2D_90_degrees():
|
||||
# Arrange
|
||||
angle = pi / 2
|
||||
expected = [
|
||||
[0.0, -1.0],
|
||||
[1.0, 0.0],
|
||||
]
|
||||
|
||||
# Act
|
||||
result = rot_2D(angle)
|
||||
|
||||
# Assert
|
||||
assert len(result) == len(expected)
|
||||
for actual_row, expected_row in zip(result, expected):
|
||||
assert actual_row == pytest.approx(expected_row)
|
||||
|
||||
|
||||
def test_rot_2D_invalid_angle():
|
||||
# Arrange
|
||||
angle = "ungueltig"
|
||||
|
||||
# Act & Assert:
|
||||
# Aufruf ausführen und prüfen, dass ein TypeError entsteht.
|
||||
with pytest.raises(TypeError):
|
||||
rot_2D(angle)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"axis, expected",
|
||||
[
|
||||
(
|
||||
"x",
|
||||
[
|
||||
[1.0, 0.0, 0.0],
|
||||
[0.0, 0.0, -1.0],
|
||||
[0.0, 1.0, 0.0],
|
||||
],
|
||||
),
|
||||
(
|
||||
"y",
|
||||
[
|
||||
[0.0, 0.0, 1.0],
|
||||
[0.0, 1.0, 0.0],
|
||||
[-1.0, 0.0, 0.0],
|
||||
],
|
||||
),
|
||||
(
|
||||
"z",
|
||||
[
|
||||
[0.0, -1.0, 0.0],
|
||||
[1.0, 0.0, 0.0],
|
||||
[0.0, 0.0, 1.0],
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_rot_3D_90_degrees(axis, expected):
|
||||
# Arrange
|
||||
angle = pi / 2
|
||||
|
||||
# Act
|
||||
result = rot_3D(angle, axis)
|
||||
|
||||
# Assert
|
||||
assert len(result) == len(expected)
|
||||
for actual_row, expected_row in zip(result, expected):
|
||||
assert actual_row == pytest.approx(expected_row)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("axis", ["a", "", "X"])
|
||||
def test_rot_3D_invalid_axis(axis):
|
||||
# Arrange
|
||||
angle = pi / 2
|
||||
|
||||
# Act & Assert:
|
||||
# Aufruf ausführen und den erwarteten ValueError prüfen.
|
||||
with pytest.raises(ValueError):
|
||||
rot_3D(angle, axis)
|
||||
|
||||
|
||||
def test_rot_3D_invalid_angle():
|
||||
# Arrange
|
||||
angle = "ungueltig"
|
||||
axis = "x"
|
||||
|
||||
# Act & Assert:
|
||||
# Aufruf ausführen und den erwarteten TypeError prüfen.
|
||||
with pytest.raises(TypeError):
|
||||
rot_3D(angle, axis)
|
||||
Reference in new issue
Block a user