Skip to content

Commit

Permalink
Add unit test for Maze::positionConsideringTunnel()
Browse files Browse the repository at this point in the history
  • Loading branch information
orzechow committed Dec 6, 2024
1 parent b743206 commit dd1903a
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions demo/test/maze.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "utils/maze.hpp"

#include <gtest/gtest.h>

namespace utils::a_star {

using namespace demo;

TEST(MazeState, positionConsideringTunnel) {
const char str[] = {"### #"
"# "
"### #"};
Maze maze{makeCustomMazeState({5, 3}, str)};

// Regular position -> no wrapping
EXPECT_EQ(maze.positionConsideringTunnel({1, 1}).x, 1);
EXPECT_EQ(maze.positionConsideringTunnel({1, 1}).y, 1);

// Regular position -> no wrapping
EXPECT_EQ(maze.positionConsideringTunnel({4, 1}).x, 4);
EXPECT_EQ(maze.positionConsideringTunnel({4, 1}).y, 1);

// Position out of maze, without tunnel -> clamping
EXPECT_EQ(maze.positionConsideringTunnel({5, 1}).x, 4);
EXPECT_EQ(maze.positionConsideringTunnel({5, 1}).y, 1);

// Regular position -> no wrapping
EXPECT_EQ(maze.positionConsideringTunnel({3, 0}).x, 3);
EXPECT_EQ(maze.positionConsideringTunnel({3, 0}).y, 0);

// Position out of maze, with tunnel -> wrapping
EXPECT_EQ(maze.positionConsideringTunnel({3, -1}).x, 3);
EXPECT_EQ(maze.positionConsideringTunnel({3, -1}).y, 2);
}


} // namespace utils::a_star

0 comments on commit dd1903a

Please sign in to comment.