added tests

This commit is contained in:
hoffmeisterda104361 committed 2026-11-09 10:37:48 +01:00
1 parent 7afe5b2f7c
commit a3b16970ae
3 files changed
+32

No files matched your search

+1
View File
@@ -0,0 +1 @@
#
+2
View File
@@ -0,0 +1,2 @@
# pytest configuration
# Use default settings.
+29
View File
@@ -0,0 +1,29 @@
import pygame
from game.cube_game import CubeGame
from game.compute import rot_3d
def test_rot_3d_z_90():
# Rotating point [1, 0, 0] around z by 90 degrees should give [0, 1, 0]
points = [[1.0, 0.0, 0.0]]
rotated = rot_3d(points, 90.0, "z")
assert round(rotated[0][0], 5) == 0.0
assert round(rotated[0][1], 5) == 1.0
assert round(rotated[0][2], 5) == 0.0
def test_no_key_pressed():
game = CubeGame()
initial = game.rotation.copy()
game.update_game()
assert game.rotation == initial
def test_key_press_increments_rotation():
game = CubeGame()
event = pygame.event.Event(pygame.KEYDOWN, key=pygame.K_UP)
game.handle_event(event)
game.update_game()
assert game.rotation["x"] == 1.0
event_up = pygame.event.Event(pygame.KEYUP, key=pygame.K_UP)
game.handle_event(event_up)
game.update_game()
assert game.rotation["x"] == 1.0