Iterators are now working far more reliably and have more extensive tests that randomize inputs and fuzz them to check they keep working.
This commit is contained in:
parent
8e470df554
commit
70cd963e5c
11 changed files with 318 additions and 84 deletions
|
@ -10,33 +10,35 @@
|
|||
using namespace lighting;
|
||||
|
||||
TEST_CASE("lighting a map works", "[lighting]") {
|
||||
Map map(20,20);
|
||||
WorldBuilder builder(map);
|
||||
builder.generate();
|
||||
for(int i = 0; i < 5; i++) {
|
||||
Map map(20+i,23+i);
|
||||
WorldBuilder builder(map);
|
||||
builder.generate();
|
||||
|
||||
Point light1 = map.place_entity(0);
|
||||
Point light2 = map.place_entity(1);
|
||||
LightSource source1{7,1};
|
||||
LightSource source2{3,2};
|
||||
Point light1 = map.place_entity(0);
|
||||
Point light2 = map.place_entity(1);
|
||||
LightSource source1{7,1};
|
||||
LightSource source2{3,2};
|
||||
|
||||
LightRender lr(map.width(), map.height());
|
||||
LightRender lr(map.width(), map.height());
|
||||
|
||||
lr.reset_light();
|
||||
lr.reset_light();
|
||||
|
||||
lr.set_light_target(light1);
|
||||
lr.set_light_target(light2);
|
||||
lr.set_light_target(light1);
|
||||
lr.set_light_target(light2);
|
||||
|
||||
lr.path_light(map.walls());
|
||||
lr.path_light(map.walls());
|
||||
|
||||
lr.render_light(source1, light1);
|
||||
lr.render_light(source2, light2);
|
||||
lr.render_light(source1, light1);
|
||||
lr.render_light(source2, light2);
|
||||
|
||||
lr.clear_light_target(light1);
|
||||
lr.clear_light_target(light2);
|
||||
lr.clear_light_target(light1);
|
||||
lr.clear_light_target(light2);
|
||||
|
||||
const auto &lighting = lr.lighting();
|
||||
const auto &lighting = lr.lighting();
|
||||
|
||||
// confirm light is set at least at and around the two points
|
||||
REQUIRE(lighting[light1.y][light1.x] == lighting::LEVELS[source1.strength]);
|
||||
REQUIRE(lighting[light2.y][light2.x] == lighting::LEVELS[source2.strength]);
|
||||
// confirm light is set at least at and around the two points
|
||||
REQUIRE(lighting[light1.y][light1.x] == lighting::LEVELS[source1.strength]);
|
||||
REQUIRE(lighting[light2.y][light2.x] == lighting::LEVELS[source2.strength]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue