X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=tst%2Fworld%2FChunkTest.cpp;h=c8dac8319f30835cbacf20a6b9c3d4391db1531a;hb=5998b18978bd8e7a0c9deb516474634e1d3521c9;hp=3ecf0f6912b7d42ae2f5853c5ad71e6effbad170;hpb=a74e9630e55ca47c23f3ba3c9ccffcaccad394ff;p=blank.git diff --git a/tst/world/ChunkTest.cpp b/tst/world/ChunkTest.cpp index 3ecf0f6..c8dac83 100644 --- a/tst/world/ChunkTest.cpp +++ b/tst/world/ChunkTest.cpp @@ -322,7 +322,6 @@ void ChunkTest::testNeighbor() { "chunk did not link correct neighbor", &*chunk, &neighbor->GetNeighbor(Block::Opposite(face)) ); - chunk->Unlink(); chunk->ClearNeighbors(); } @@ -451,6 +450,81 @@ void ChunkTest::testLightPropagation() { // now block the light to the left chunk->SetBlock(Chunk::Pos(6, 7, 7), Block(1)); + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "adding obstacle affected unrelated index", + 5, chunk->GetLight(Chunk::Pos(7, 7, 7)) + ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "adding obstacle affected unrelated index", + 4, chunk->GetLight(Chunk::Pos(8, 7, 7)) + ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "adding obstacle affected unrelated index", + 4, chunk->GetLight(Chunk::Pos(7, 8, 7)) + ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "adding obstacle affected unrelated index", + 4, chunk->GetLight(Chunk::Pos(7, 6, 7)) + ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "adding obstacle affected unrelated index", + 4, chunk->GetLight(Chunk::Pos(7, 7, 8)) + ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "adding obstacle affected unrelated index", + 4, chunk->GetLight(Chunk::Pos(7, 7, 6)) + ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "adding obstacle affected unrelated index", + 3, chunk->GetLight(Chunk::Pos(6, 6, 7)) + ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "adding obstacle affected unrelated index", + 3, chunk->GetLight(Chunk::Pos(6, 8, 7)) + ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "adding obstacle affected unrelated index", + 3, chunk->GetLight(Chunk::Pos(6, 7, 6)) + ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "adding obstacle affected unrelated index", + 3, chunk->GetLight(Chunk::Pos(6, 7, 6)) + ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "adding obstacle affected unrelated index", + 2, chunk->GetLight(Chunk::Pos(5, 6, 7)) + ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "adding obstacle affected unrelated index", + 2, chunk->GetLight(Chunk::Pos(5, 8, 7)) + ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "adding obstacle affected unrelated index", + 2, chunk->GetLight(Chunk::Pos(5, 7, 6)) + ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "adding obstacle affected unrelated index", + 2, chunk->GetLight(Chunk::Pos(5, 7, 6)) + ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "adding obstacle resulted in unexpected light level behind it", + 1, chunk->GetLight(Chunk::Pos(5, 7, 7)) + ); + + // and remove it again + chunk->SetBlock(Chunk::Pos(6, 7, 7), Block(0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "removing obstacle did not refill light correctly", + 4, chunk->GetLight(Chunk::Pos(6, 7, 7)) + ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "removing obstacle did not refill light correctly", + 3, chunk->GetLight(Chunk::Pos(5, 7, 7)) + ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "removing obstacle did not refill light correctly", + 2, chunk->GetLight(Chunk::Pos(4, 7, 7)) + ); } }