Skip to content

Commit

Permalink
Add first test for Game class for testing no more enemies victory con…
Browse files Browse the repository at this point in the history
…dition.
  • Loading branch information
przemek83 committed Oct 7, 2024
1 parent 30094f9 commit a34c670
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ set(${PROJECT_TEST}_SOURCES
DisplayTest.cpp
MenuTest.cpp
StatusTest.cpp
GameTest.cpp
)

add_executable(${PROJECT_TEST} ${${PROJECT_TEST}_SOURCES})
Expand Down
24 changes: 24 additions & 0 deletions test/GameTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <catch2/catch_test_macros.hpp>

#include <src/Game.h>
#include <src/Map.h>

#include "src/Config.h"
#include "src/TankType.h"
#include "test/FakeDisplay.h"

TEST_CASE("Check winning conditions", "[Game]")
{
FakeDisplay display;
Config::getInstance().setDefaultSleepTimeInSeconds(0);

SECTION("Check no more enemies")
{
std::list<Tank> tanks;
Point point{0, 0};
tanks.emplace_back(TankType::PLAYER_TIER_1, point);
Map map{3};
Game game(tanks, map);
REQUIRE(game.isGameEnding(display));
}
}

0 comments on commit a34c670

Please sign in to comment.