Skip to content

Commit

Permalink
Fix WorldTest
Browse files Browse the repository at this point in the history
  • Loading branch information
yksen committed Sep 11, 2023
1 parent bdfe83a commit 13d2ad5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ add_custom_target(run
DEPENDS Everland
)
add_custom_target(run_tests
COMMAND EverlandTest
COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
DEPENDS EverlandTest
)
21 changes: 19 additions & 2 deletions test/world/WorldTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,24 @@

#include <gtest/gtest.h>

TEST(WorldTest, updateNeighbors)
class WorldTest : public ::testing::Test
{
protected:
void SetUp() override
{
window.Init(1, 1, "", FLAG_WINDOW_HIDDEN);
}

void TearDown() override
{
window.Close();
}

private:
rl::Window window;
};

TEST_F(WorldTest, updateNeighbors)
{
World world{"test", std::make_unique<DefaultGenerator>()};
world.update({0, 0}, 1);
Expand All @@ -11,7 +28,7 @@ TEST(WorldTest, updateNeighbors)
size_t count = 0;
for (auto &row : neighbors)
for (auto &neighbor : row)
if (neighbor)
if (neighbor != nullptr)
++count;

EXPECT_EQ(count, 8);
Expand Down

0 comments on commit 13d2ad5

Please sign in to comment.