]> git.localhorst.tv Git - blank.git/blobdiff - tst/world/ChunkTest.cpp
fix number as bool in TokenStreamReader
[blank.git] / tst / world / ChunkTest.cpp
index 79d349546a568ac602bfbb31a8eca541ae17f8d5..26f2014cfc3fbec2b061959ce893e2d51ce249e0 100644 (file)
@@ -17,15 +17,17 @@ void ChunkTest::setUp() {
        types = BlockTypeRegistry();
 
        BlockType obstacle;
+       obstacle.name = "obstacle";
        obstacle.visible = true;
        obstacle.block_light = true;
-       types.Add(obstacle);
+       types.Add(std::move(obstacle));
 
        BlockType source;
+       source.name = "source";
        source.visible = true;
        source.luminosity = 5;
        source.block_light = true;
-       types.Add(source);
+       types.Add(std::move(source));
 }
 
 void ChunkTest::tearDown() {
@@ -35,259 +37,259 @@ void ChunkTest::tearDown() {
 void ChunkTest::testBounds() {
        CPPUNIT_ASSERT_MESSAGE(
                "valid position out of bounds",
-               Chunk::InBounds(Chunk::Pos(0, 0, 0))
+               Chunk::InBounds(RoughLocation::Fine(0, 0, 0))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "valid position out of bounds",
-               Chunk::InBounds(Chunk::Pos(15, 0, 0))
+               Chunk::InBounds(RoughLocation::Fine(15, 0, 0))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "valid position out of bounds",
-               Chunk::InBounds(Chunk::Pos(0, 15, 0))
+               Chunk::InBounds(RoughLocation::Fine(0, 15, 0))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "valid position out of bounds",
-               Chunk::InBounds(Chunk::Pos(0, 0, 15))
+               Chunk::InBounds(RoughLocation::Fine(0, 0, 15))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "valid position out of bounds",
-               Chunk::InBounds(Chunk::Pos(15, 15, 15))
+               Chunk::InBounds(RoughLocation::Fine(15, 15, 15))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "invalid position in bounds",
-               !Chunk::InBounds(Chunk::Pos(-1, -1, -1))
+               !Chunk::InBounds(RoughLocation::Fine(-1, -1, -1))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "invalid position in bounds",
-               !Chunk::InBounds(Chunk::Pos(-1, 1, 0))
+               !Chunk::InBounds(RoughLocation::Fine(-1, 1, 0))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "invalid position in bounds",
-               !Chunk::InBounds(Chunk::Pos(16, -16, 0))
+               !Chunk::InBounds(RoughLocation::Fine(16, -16, 0))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "invalid position in bounds",
-               !Chunk::InBounds(Chunk::Pos(16, 16, 16))
+               !Chunk::InBounds(RoughLocation::Fine(16, 16, 16))
        );
 }
 
 void ChunkTest::testBorder() {
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::Pos(0, 0, 0))
+               Chunk::IsBorder(RoughLocation::Fine(0, 0, 0))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::Pos(0, 0, 8))
+               Chunk::IsBorder(RoughLocation::Fine(0, 0, 8))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::Pos(0, 0, 15))
+               Chunk::IsBorder(RoughLocation::Fine(0, 0, 15))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::Pos(0, 8, 0))
+               Chunk::IsBorder(RoughLocation::Fine(0, 8, 0))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::Pos(0, 8, 8))
+               Chunk::IsBorder(RoughLocation::Fine(0, 8, 8))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::Pos(0, 8, 15))
+               Chunk::IsBorder(RoughLocation::Fine(0, 8, 15))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::Pos(0, 15, 0))
+               Chunk::IsBorder(RoughLocation::Fine(0, 15, 0))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::Pos(0, 15, 8))
+               Chunk::IsBorder(RoughLocation::Fine(0, 15, 8))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::Pos(0, 15, 15))
+               Chunk::IsBorder(RoughLocation::Fine(0, 15, 15))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::Pos(8, 0, 0))
+               Chunk::IsBorder(RoughLocation::Fine(8, 0, 0))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::Pos(8, 0, 8))
+               Chunk::IsBorder(RoughLocation::Fine(8, 0, 8))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::Pos(8, 0, 15))
+               Chunk::IsBorder(RoughLocation::Fine(8, 0, 15))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::Pos(8, 8, 0))
+               Chunk::IsBorder(RoughLocation::Fine(8, 8, 0))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position is border",
-               !Chunk::IsBorder(Chunk::Pos(8, 8, 8))
+               !Chunk::IsBorder(RoughLocation::Fine(8, 8, 8))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::Pos(8, 8, 15))
+               Chunk::IsBorder(RoughLocation::Fine(8, 8, 15))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::Pos(8, 15, 0))
+               Chunk::IsBorder(RoughLocation::Fine(8, 15, 0))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::Pos(8, 15, 8))
+               Chunk::IsBorder(RoughLocation::Fine(8, 15, 8))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::Pos(8, 15, 15))
+               Chunk::IsBorder(RoughLocation::Fine(8, 15, 15))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::Pos(15, 0, 0))
+               Chunk::IsBorder(RoughLocation::Fine(15, 0, 0))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::Pos(15, 0, 8))
+               Chunk::IsBorder(RoughLocation::Fine(15, 0, 8))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::Pos(15, 0, 15))
+               Chunk::IsBorder(RoughLocation::Fine(15, 0, 15))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::Pos(15, 8, 0))
+               Chunk::IsBorder(RoughLocation::Fine(15, 8, 0))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::Pos(15, 8, 8))
+               Chunk::IsBorder(RoughLocation::Fine(15, 8, 8))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::Pos(15, 8, 15))
+               Chunk::IsBorder(RoughLocation::Fine(15, 8, 15))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::Pos(15, 15, 0))
+               Chunk::IsBorder(RoughLocation::Fine(15, 15, 0))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::Pos(15, 15, 8))
+               Chunk::IsBorder(RoughLocation::Fine(15, 15, 8))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::Pos(15, 15, 15))
+               Chunk::IsBorder(RoughLocation::Fine(15, 15, 15))
        );
 
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::ToIndex(Chunk::Pos(0, 0, 0)))
+               Chunk::IsBorder(Chunk::ToIndex(RoughLocation::Fine(0, 0, 0)))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::ToIndex(Chunk::Pos(0, 0, 8)))
+               Chunk::IsBorder(Chunk::ToIndex(RoughLocation::Fine(0, 0, 8)))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::ToIndex(Chunk::Pos(0, 0, 15)))
+               Chunk::IsBorder(Chunk::ToIndex(RoughLocation::Fine(0, 0, 15)))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::ToIndex(Chunk::Pos(0, 8, 0)))
+               Chunk::IsBorder(Chunk::ToIndex(RoughLocation::Fine(0, 8, 0)))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::ToIndex(Chunk::Pos(0, 8, 8)))
+               Chunk::IsBorder(Chunk::ToIndex(RoughLocation::Fine(0, 8, 8)))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::ToIndex(Chunk::Pos(0, 8, 15)))
+               Chunk::IsBorder(Chunk::ToIndex(RoughLocation::Fine(0, 8, 15)))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::ToIndex(Chunk::Pos(0, 15, 0)))
+               Chunk::IsBorder(Chunk::ToIndex(RoughLocation::Fine(0, 15, 0)))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::ToIndex(Chunk::Pos(0, 15, 8)))
+               Chunk::IsBorder(Chunk::ToIndex(RoughLocation::Fine(0, 15, 8)))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::ToIndex(Chunk::Pos(0, 15, 15)))
+               Chunk::IsBorder(Chunk::ToIndex(RoughLocation::Fine(0, 15, 15)))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::ToIndex(Chunk::Pos(8, 0, 0)))
+               Chunk::IsBorder(Chunk::ToIndex(RoughLocation::Fine(8, 0, 0)))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::ToIndex(Chunk::Pos(8, 0, 8)))
+               Chunk::IsBorder(Chunk::ToIndex(RoughLocation::Fine(8, 0, 8)))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::ToIndex(Chunk::Pos(8, 0, 15)))
+               Chunk::IsBorder(Chunk::ToIndex(RoughLocation::Fine(8, 0, 15)))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::ToIndex(Chunk::Pos(8, 8, 0)))
+               Chunk::IsBorder(Chunk::ToIndex(RoughLocation::Fine(8, 8, 0)))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position is border",
-               !Chunk::IsBorder(Chunk::ToIndex(Chunk::Pos(8, 8, 8)))
+               !Chunk::IsBorder(Chunk::ToIndex(RoughLocation::Fine(8, 8, 8)))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::ToIndex(Chunk::Pos(8, 8, 15)))
+               Chunk::IsBorder(Chunk::ToIndex(RoughLocation::Fine(8, 8, 15)))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::ToIndex(Chunk::Pos(8, 15, 0)))
+               Chunk::IsBorder(Chunk::ToIndex(RoughLocation::Fine(8, 15, 0)))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::ToIndex(Chunk::Pos(8, 15, 8)))
+               Chunk::IsBorder(Chunk::ToIndex(RoughLocation::Fine(8, 15, 8)))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::ToIndex(Chunk::Pos(8, 15, 15)))
+               Chunk::IsBorder(Chunk::ToIndex(RoughLocation::Fine(8, 15, 15)))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::ToIndex(Chunk::Pos(15, 0, 0)))
+               Chunk::IsBorder(Chunk::ToIndex(RoughLocation::Fine(15, 0, 0)))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::ToIndex(Chunk::Pos(15, 0, 8)))
+               Chunk::IsBorder(Chunk::ToIndex(RoughLocation::Fine(15, 0, 8)))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::ToIndex(Chunk::Pos(15, 0, 15)))
+               Chunk::IsBorder(Chunk::ToIndex(RoughLocation::Fine(15, 0, 15)))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::ToIndex(Chunk::Pos(15, 8, 0)))
+               Chunk::IsBorder(Chunk::ToIndex(RoughLocation::Fine(15, 8, 0)))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::ToIndex(Chunk::Pos(15, 8, 8)))
+               Chunk::IsBorder(Chunk::ToIndex(RoughLocation::Fine(15, 8, 8)))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::ToIndex(Chunk::Pos(15, 8, 15)))
+               Chunk::IsBorder(Chunk::ToIndex(RoughLocation::Fine(15, 8, 15)))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::ToIndex(Chunk::Pos(15, 15, 0)))
+               Chunk::IsBorder(Chunk::ToIndex(RoughLocation::Fine(15, 15, 0)))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::ToIndex(Chunk::Pos(15, 15, 8)))
+               Chunk::IsBorder(Chunk::ToIndex(RoughLocation::Fine(15, 15, 8)))
        );
        CPPUNIT_ASSERT_MESSAGE(
                "position not border",
-               Chunk::IsBorder(Chunk::ToIndex(Chunk::Pos(15, 15, 15)))
+               Chunk::IsBorder(Chunk::ToIndex(RoughLocation::Fine(15, 15, 15)))
        );
 }
 
@@ -305,7 +307,7 @@ void ChunkTest::testNeighbor() {
        for (int i = 0; i < Block::FACE_COUNT; ++i) {
                Block::Face face = Block::Face(i);
                neighbor->Position(Block::FaceNormal(face));
-               chunk->SetNeighbor(*neighbor);
+               chunk->SetNeighbor(face, *neighbor);
                CPPUNIT_ASSERT_MESSAGE(
                        "chunk did not link right neighbor",
                        chunk->HasNeighbor(face)
@@ -323,17 +325,201 @@ void ChunkTest::testNeighbor() {
                        &*chunk, &neighbor->GetNeighbor(Block::Opposite(face))
                );
                chunk->Unlink();
-               chunk->ClearNeighbors();
        }
+}
 
-       neighbor->Position({1, 1, 1});
-       chunk->SetNeighbor(*neighbor);
-       for (int i = 0; i < Block::FACE_COUNT; ++i) {
-               CPPUNIT_ASSERT_MESSAGE(
-                       "chunk linked with non-neighbor",
-                       !chunk->HasNeighbor(Block::Face(i))
+
+void ChunkTest::testBlock() {
+       unique_ptr<Chunk> chunk(new Chunk(types));
+
+       for (int index = 0; index < Chunk::size; ++index) {
+               CPPUNIT_ASSERT_EQUAL_MESSAGE(
+                       "default chunk has non-default block",
+                       Block(), chunk->BlockAt(index)
                );
        }
+
+       Block block(1, Block::FACE_LEFT, Block::TURN_RIGHT);
+       chunk->SetBlock(0, block);
+       CPPUNIT_ASSERT_EQUAL_MESSAGE(
+               "wrong type on set block",
+               block.type, chunk->BlockAt(0).type
+       );
+       CPPUNIT_ASSERT_EQUAL_MESSAGE(
+               "wrong orientation on set block",
+               block.orient, chunk->BlockAt(0).orient
+       );
+       for (int index = 1; index < Chunk::size; ++index) {
+               CPPUNIT_ASSERT_EQUAL_MESSAGE(
+                       "changing block at index 0 affected some other block",
+                       Block(), chunk->BlockAt(index)
+               );
+       }
+}
+
+void ChunkTest::testLight() {
+       unique_ptr<Chunk> chunk(new Chunk(types));
+
+       for (int index = 0; index < Chunk::size; ++index) {
+               CPPUNIT_ASSERT_EQUAL_MESSAGE(
+                       "default chunk has non-zero light level",
+                       0, chunk->GetLight(index)
+               );
+       }
+
+       chunk->SetLight(0, 15);
+       CPPUNIT_ASSERT_EQUAL_MESSAGE(
+               "wrong light level on set index",
+               15, chunk->GetLight(0)
+       );
+       for (int index = 1; index < Chunk::size; ++index) {
+               CPPUNIT_ASSERT_EQUAL_MESSAGE(
+                       "changing light at index 0 affected some other index",
+                       0, chunk->GetLight(index)
+               );
+       }
+}
+
+void ChunkTest::testLightPropagation() {
+       unique_ptr<Chunk> chunk(new Chunk(types));
+       // this is required to make the chunk do lighting propagation at all
+       chunk->ScanLights();
+
+       // 0 air, 1 solid, 2 solid and emits light level of 5
+       chunk->SetBlock(RoughLocation::Fine(7, 7, 7), Block(2));
+       CPPUNIT_ASSERT_EQUAL_MESSAGE(
+               "adding luminant block did not set correct light level",
+               5, chunk->GetLight(RoughLocation::Fine(7, 7, 7))
+       );
+
+       CPPUNIT_ASSERT_EQUAL_MESSAGE(
+               "light did not propagate correctly in +X",
+               4, chunk->GetLight(RoughLocation::Fine(8, 7, 7))
+       );
+       CPPUNIT_ASSERT_EQUAL_MESSAGE(
+               "light did not propagate correctly in -X",
+               4, chunk->GetLight(RoughLocation::Fine(6, 7, 7))
+       );
+       CPPUNIT_ASSERT_EQUAL_MESSAGE(
+               "light did not propagate correctly in +Y",
+               4, chunk->GetLight(RoughLocation::Fine(7, 8, 7))
+       );
+       CPPUNIT_ASSERT_EQUAL_MESSAGE(
+               "light did not propagate correctly in -Y",
+               4, chunk->GetLight(RoughLocation::Fine(7, 6, 7))
+       );
+       CPPUNIT_ASSERT_EQUAL_MESSAGE(
+               "light did not propagate correctly in +Z",
+               4, chunk->GetLight(RoughLocation::Fine(7, 7, 8))
+       );
+       CPPUNIT_ASSERT_EQUAL_MESSAGE(
+               "light did not propagate correctly in -Z",
+               4, chunk->GetLight(RoughLocation::Fine(7, 7, 6))
+       );
+
+       CPPUNIT_ASSERT_EQUAL_MESSAGE(
+               "light did not propagate correctly in 2D diagonal",
+               3, chunk->GetLight(RoughLocation::Fine(8, 8, 7))
+       );
+       CPPUNIT_ASSERT_EQUAL_MESSAGE(
+               "light did not propagate correctly in 2D diagonal",
+               3, chunk->GetLight(RoughLocation::Fine(7, 6, 8))
+       );
+       CPPUNIT_ASSERT_EQUAL_MESSAGE(
+               "light did not propagate correctly in 2D diagonal",
+               3, chunk->GetLight(RoughLocation::Fine(6, 7, 8))
+       );
+
+       CPPUNIT_ASSERT_EQUAL_MESSAGE(
+               "light did not propagate correctly in 3D diagonal",
+               2, chunk->GetLight(RoughLocation::Fine(8, 6, 6))
+       );
+       CPPUNIT_ASSERT_EQUAL_MESSAGE(
+               "light did not propagate correctly in 3D diagonal",
+               2, chunk->GetLight(RoughLocation::Fine(6, 6, 8))
+       );
+       CPPUNIT_ASSERT_EQUAL_MESSAGE(
+               "light did not propagate correctly in 3D diagonal",
+               2, chunk->GetLight(RoughLocation::Fine(6, 8, 8))
+       );
+
+       // now block the light to the left
+       chunk->SetBlock(RoughLocation::Fine(6, 7, 7), Block(1));
+       CPPUNIT_ASSERT_EQUAL_MESSAGE(
+               "adding obstacle affected unrelated index",
+               5, chunk->GetLight(RoughLocation::Fine(7, 7, 7))
+       );
+       CPPUNIT_ASSERT_EQUAL_MESSAGE(
+               "adding obstacle affected unrelated index",
+               4, chunk->GetLight(RoughLocation::Fine(8, 7, 7))
+       );
+       CPPUNIT_ASSERT_EQUAL_MESSAGE(
+               "adding obstacle affected unrelated index",
+               4, chunk->GetLight(RoughLocation::Fine(7, 8, 7))
+       );
+       CPPUNIT_ASSERT_EQUAL_MESSAGE(
+               "adding obstacle affected unrelated index",
+               4, chunk->GetLight(RoughLocation::Fine(7, 6, 7))
+       );
+       CPPUNIT_ASSERT_EQUAL_MESSAGE(
+               "adding obstacle affected unrelated index",
+               4, chunk->GetLight(RoughLocation::Fine(7, 7, 8))
+       );
+       CPPUNIT_ASSERT_EQUAL_MESSAGE(
+               "adding obstacle affected unrelated index",
+               4, chunk->GetLight(RoughLocation::Fine(7, 7, 6))
+       );
+       CPPUNIT_ASSERT_EQUAL_MESSAGE(
+               "adding obstacle affected unrelated index",
+               3, chunk->GetLight(RoughLocation::Fine(6, 6, 7))
+       );
+       CPPUNIT_ASSERT_EQUAL_MESSAGE(
+               "adding obstacle affected unrelated index",
+               3, chunk->GetLight(RoughLocation::Fine(6, 8, 7))
+       );
+       CPPUNIT_ASSERT_EQUAL_MESSAGE(
+               "adding obstacle affected unrelated index",
+               3, chunk->GetLight(RoughLocation::Fine(6, 7, 6))
+       );
+       CPPUNIT_ASSERT_EQUAL_MESSAGE(
+               "adding obstacle affected unrelated index",
+               3, chunk->GetLight(RoughLocation::Fine(6, 7, 6))
+       );
+       CPPUNIT_ASSERT_EQUAL_MESSAGE(
+               "adding obstacle affected unrelated index",
+               2, chunk->GetLight(RoughLocation::Fine(5, 6, 7))
+       );
+       CPPUNIT_ASSERT_EQUAL_MESSAGE(
+               "adding obstacle affected unrelated index",
+               2, chunk->GetLight(RoughLocation::Fine(5, 8, 7))
+       );
+       CPPUNIT_ASSERT_EQUAL_MESSAGE(
+               "adding obstacle affected unrelated index",
+               2, chunk->GetLight(RoughLocation::Fine(5, 7, 6))
+       );
+       CPPUNIT_ASSERT_EQUAL_MESSAGE(
+               "adding obstacle affected unrelated index",
+               2, chunk->GetLight(RoughLocation::Fine(5, 7, 6))
+       );
+       CPPUNIT_ASSERT_EQUAL_MESSAGE(
+               "adding obstacle resulted in unexpected light level behind it",
+               1, chunk->GetLight(RoughLocation::Fine(5, 7, 7))
+       );
+
+       // and remove it again
+       chunk->SetBlock(RoughLocation::Fine(6, 7, 7), Block(0));
+       CPPUNIT_ASSERT_EQUAL_MESSAGE(
+               "removing obstacle did not refill light correctly",
+               4, chunk->GetLight(RoughLocation::Fine(6, 7, 7))
+       );
+       CPPUNIT_ASSERT_EQUAL_MESSAGE(
+               "removing obstacle did not refill light correctly",
+               3, chunk->GetLight(RoughLocation::Fine(5, 7, 7))
+       );
+       CPPUNIT_ASSERT_EQUAL_MESSAGE(
+               "removing obstacle did not refill light correctly",
+               2, chunk->GetLight(RoughLocation::Fine(4, 7, 7))
+       );
 }
 
 }