-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from KIT-MRT/fix_position_considering_tunnel
- Loading branch information
Showing
2 changed files
with
41 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |