From a34c670ee8d3e650d2efac0ce2289809f6ab2233 Mon Sep 17 00:00:00 2001 From: przemek83 <4788832+przemek83@users.noreply.github.com> Date: Mon, 7 Oct 2024 13:01:41 +0200 Subject: [PATCH] Add first test for Game class for testing no more enemies victory condition. --- test/CMakeLists.txt | 1 + test/GameTest.cpp | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 test/GameTest.cpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index fd2ab47..d2cf164 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -12,6 +12,7 @@ set(${PROJECT_TEST}_SOURCES DisplayTest.cpp MenuTest.cpp StatusTest.cpp + GameTest.cpp ) add_executable(${PROJECT_TEST} ${${PROJECT_TEST}_SOURCES}) diff --git a/test/GameTest.cpp b/test/GameTest.cpp new file mode 100644 index 0000000..1e77e19 --- /dev/null +++ b/test/GameTest.cpp @@ -0,0 +1,24 @@ +#include + +#include +#include + +#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 tanks; + Point point{0, 0}; + tanks.emplace_back(TankType::PLAYER_TIER_1, point); + Map map{3}; + Game game(tanks, map); + REQUIRE(game.isGameEnding(display)); + } +}