|
| 1 | +#include <gtest/gtest.h> |
| 2 | + |
| 3 | +#include <bitbishop/bitboard.hpp> |
| 4 | +#include <bitbishop/lookups/between_squares.hpp> |
| 5 | +#include <bitbishop/square.hpp> |
| 6 | + |
| 7 | +using namespace Squares; |
| 8 | +using namespace Lookups; |
| 9 | + |
| 10 | +/** |
| 11 | + * @test Seeking for the direction using identical source and destination squares should return . |
| 12 | + */ |
| 13 | +TEST(DirectionTest, DirectionSameSquare) { |
| 14 | + EXPECT_EQ(direction(E4, E4), 0); |
| 15 | + EXPECT_EQ(direction(A1, A1), 0); |
| 16 | + EXPECT_EQ(direction(H8, H8), 0); |
| 17 | +} |
| 18 | + |
| 19 | +/** |
| 20 | + * @test Horizontal direction on same rank (step = +-1). |
| 21 | + * @brief Confirms direction() returns +1 for rightward and -1 for leftward movement. |
| 22 | + */ |
| 23 | +TEST(LookupsTest, DirectionSameRank) { |
| 24 | + EXPECT_EQ(direction(A1, H1), +1); |
| 25 | + EXPECT_EQ(direction(H1, A1), -1); |
| 26 | + EXPECT_EQ(direction(D4, G4), +1); |
| 27 | + EXPECT_EQ(direction(E5, B5), -1); |
| 28 | +} |
| 29 | + |
| 30 | +/** |
| 31 | + * @test Vertical direction on same file (step = +-8). |
| 32 | + * @brief Confirms direction() returns +8 for upward and -8 for downward movement. |
| 33 | + */ |
| 34 | +TEST(LookupsTest, DirectionSameFile) { |
| 35 | + EXPECT_EQ(direction(A1, A8), +8); |
| 36 | + EXPECT_EQ(direction(A8, A1), -8); |
| 37 | + EXPECT_EQ(direction(E2, E6), +8); |
| 38 | + EXPECT_EQ(direction(H7, H3), -8); |
| 39 | +} |
| 40 | + |
| 41 | +/** |
| 42 | + * @test NE-SW diagonal direction (step = +-9). |
| 43 | + * @brief Confirms direction() returns +9 for NE and -9 for SW movement. |
| 44 | + */ |
| 45 | +TEST(LookupsTest, DirectionNESWDiagonal) { |
| 46 | + EXPECT_EQ(direction(A1, H8), +9); |
| 47 | + EXPECT_EQ(direction(H8, A1), -9); |
| 48 | + EXPECT_EQ(direction(C3, E5), +9); |
| 49 | + EXPECT_EQ(direction(F6, D4), -9); |
| 50 | +} |
| 51 | + |
| 52 | +/** |
| 53 | + * @test NW-SE diagonal direction (step = +-7). |
| 54 | + * @brief Confirms direction() returns +7 for NW and -7 for SE movement. |
| 55 | + */ |
| 56 | +TEST(LookupsTest, DirectionNWSEDiagonal) { |
| 57 | + EXPECT_EQ(direction(A8, H1), -7); |
| 58 | + EXPECT_EQ(direction(H1, A8), +7); |
| 59 | + EXPECT_EQ(direction(B6, E3), -7); |
| 60 | + EXPECT_EQ(direction(F4, C7), +7); |
| 61 | +} |
0 commit comments