Skip to content

Commit

Permalink
Add a test for Crawl order
Browse files Browse the repository at this point in the history
  • Loading branch information
glebm committed Aug 7, 2024
1 parent df3d76c commit e5c628d
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion test/lighting_test.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#include <cmath>

#include <gmock/gmock.h>
#include <gtest/gtest.h>

#include "control.h"
#include "lighting.h"

using namespace devilution;
namespace devilution {
namespace {
using ::testing::ElementsAre;

TEST(Lighting, CrawlTables)
{
Expand Down Expand Up @@ -33,3 +36,26 @@ TEST(Lighting, CrawlTables)
}
}
}

TEST(Lighting, CrawlTablesVisitationOrder)
{
std::vector<Displacement> order;
Crawl(0, 2, [&](Displacement displacement) {
order.push_back(displacement);
return false;
});
EXPECT_THAT(
order,
ElementsAre(
Displacement(0, 0),
Displacement(0, 1), Displacement(0, -1),
Displacement(-1, 0), Displacement(1, 0),
Displacement(0, 2), Displacement(0, -2),
Displacement(-1, 2), Displacement(1, 2), Displacement(-1, -2), Displacement(1, -2),
Displacement(-1, 1), Displacement(1, 1), Displacement(-1, -1), Displacement(1, -1),
Displacement(-2, 0), Displacement(2, 0), Displacement(-2, 1),
Displacement(2, 1), Displacement(-2, -1), Displacement(2, -1)));
}

} // namespace
} // namespace devilution

0 comments on commit e5c628d

Please sign in to comment.