Commit e0eaa84d authored by Emil's avatar Emil

Added more testsAdded more tests

parent e01569e1
......@@ -58,6 +58,9 @@ private:
public:
static void registerAsQmlType();
// public:
// Q_INVOKABLE void initNewNumanVsAI();
};
......
......@@ -11,6 +11,7 @@ find_package(Threads REQUIRED)
set(TESTS
utility_unittests
utility_unittests_moves
utility_unittests_occupied
)
......
// gtest
#include <gtest/gtest.h> // googletest header file
// engine
#include <engine/gameengine.h>
#include <engine/monkeyai.h>
// stl
#include <variant>
using namespace gameengine;
/////////////////
/// Legal Moves
static BitPieces P1 ("00000000"
"00000000"
"00000000"
"00000000"
"00000000"
"00000100"
"00000000"
"00000000");
static BitPieces P2 ("00000000"
"01000000"
"00000000"
"00000000"
"00000000"
"00000000"
"00000000"
"00000000");
static BitPieces P2_jump ("00000000"
"00000000"
"00000000"
"00000000"
"00000010"
"00000000"
"00000000"
"00000000");
static Move legal_moves_east(P1,
{BitPieces("00000000"
"00000000"
"00000000"
"00000000"
"00000010"
"00000000"
"00000000"
"00000000")},
{});
static Move legal_moves_west(P1,
{BitPieces("00000000"
"00000000"
"00000000"
"00000000"
"00001000"
"00000000"
"00000000"
"00000000")},
{});
static Move legal_jumps (P1,
{BitPieces("00000000"
"00000000"
"00000000"
"00000001"
"00000000"
"00000000"
"00000000"
"00000000")},
{P2_jump});
// Testing fixture
struct legalMovesParameters {
BitBoard board;
PlayerId player_id;
Moves legal_moves_exp;
};
struct legalMovesFixture : testing::Test,
testing::WithParamInterface<legalMovesParameters> {
};
// Tests
TEST_P(legalMovesFixture, EQ_Test)
{
auto params = GetParam();
auto legal_moves
= gameengine::utility::legalMoves(params.board, params.player_id);
EXPECT_EQ(legal_moves, params.legal_moves_exp);
}
// Test set instantiations
INSTANTIATE_TEST_SUITE_P(
legalMoves,
legalMovesFixture,
testing::Values(legalMovesParameters{
BitBoard({P1,P2}),
PlayerId::One,
Moves{legal_moves_east,legal_moves_west}
},
legalMovesParameters{
BitBoard({P1,P2_jump}),
PlayerId::One,
Moves{legal_jumps}
}
)
);
// gtest
#include <gtest/gtest.h> // googletest header file
// engine
#include <engine/gameengine.h>
#include <engine/monkeyai.h>
// stl
#include <variant>
using namespace gameengine;
/////////////////
/// occupiedPositions
static BitPieces P1 ("00000000"
"00000000"
"00000000"
"00000000"
"00000000"
"00000100"
"00000000"
"00000000");
static BitPieces P2 ("00000000"
"00000000"
"00000000"
"00000000"
"00000010"
"00000000"
"00000000"
"00000000");
static BitPieces P1_2 ("00000000"
"00000000"
"00000000"
"00000000"
"00000010"
"00000100"
"00000000"
"00000000");
// Testing fixture
struct occupiedPositionsParameters {
BitBoard board;
BitPieces full_board;
};
struct occupiedPositionsFixture : testing::Test,
testing::WithParamInterface<occupiedPositionsParameters> {
};
// Tests
TEST_P(occupiedPositionsFixture, EQ_Test)
{
auto params = GetParam();
auto full_board
= gameengine::utility::occupiedPositions(params.board);
EXPECT_EQ(full_board, params.full_board);
}
// Test set instantiations
INSTANTIATE_TEST_SUITE_P(
occupiedPositions,
occupiedPositionsFixture,
testing::Values(occupiedPositionsParameters{BitBoard({P1,P2}),P1_2}
)
);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment