VoxelEngine/tests/test_Structures.py

60 lines
1.6 KiB
Python
Raw Permalink Normal View History

2020-11-08 10:20:23 +01:00
from Lights.Lights import Light
from Objects.Objects import Object
from Objects.World import World
def test_world_put_object():
w = World(5, 5, 5, 3, 3, 3)
o = Object()
w.put_object(5, 5, 5, o)
assert w.chunks[1][1][1].content[0][0][0] == o, 'Put Object into world failed'
def test_world_get_object():
w = World(5, 5, 5, 3, 3, 3)
o = Object()
w.put_object(5, 5, 5, o)
assert w.get_object(5, 5, 5) == o, 'Put Object into world failed'
def test_world_put_visibility():
w = World(5, 5, 5, 3, 3, 3)
o = Object()
w.put_object(4, 5, 5, o)
w.put_object(6, 5, 5, o)
w.put_object(5, 4, 5, o)
w.put_object(5, 6, 5, o)
w.put_object(5, 5, 4, o)
w.put_object(5, 5, 6, o)
w.put_object(5, 5, 5, o)
assert w.chunks[1][1][1].visible[0][0][0] == 0, 'Initial visibility not set!'
assert w.chunks[1][1][1].visible[1][0][0] == 5, 'Neighbours visibility not set!'
assert w.chunks[1][1][1].visible[0][1][0] == 5, 'Neighbours visibility not set!'
assert w.chunks[1][1][1].visible[0][0][1] == 5, 'Neighbours visibility not set!'
assert w.chunks[0][1][1].visible[4][0][0] == 5, 'Neighbours visibility not set!'
assert w.chunks[1][0][1].visible[0][4][0] == 5, 'Neighbours visibility not set!'
assert w.chunks[1][1][0].visible[0][0][4] == 5, 'Neighbours visibility not set!'
def test_world_add_light():
w = World(5, 5, 5, 3, 3, 3)
l = Light()
w.add_light(1.5, 2, 3.7, l)
def test_world_remove_light():
w = World(5, 5, 5, 3, 3, 3)
l = Light()
w.add_light(1.5, 2, 3.7, l)
w.remove_light(l)