Skip to content

Commit

Permalink
Add some tests for MenuItem class.
Browse files Browse the repository at this point in the history
  • Loading branch information
przemek83 committed Sep 14, 2024
1 parent 6984d82 commit a106e26
Show file tree
Hide file tree
Showing 2 changed files with 31 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 @@ -8,6 +8,7 @@ set(${PROJECT_TEST}_SOURCES
TankTest.cpp
MapUtilsTest.cpp
ConfigTest.cpp
MenuItemTest.cpp
)

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

#include <src/MenuItem.h>
#include <src/Screen.h>

TEST_CASE("MenuItem initialization and properties", "[MenuItem]")
{
MenuItem menuItem(UserChoice::LEVEL_MENU);

SECTION("Creation")
{
REQUIRE(menuItem.getUserChoice() == UserChoice::LEVEL_MENU);
REQUIRE(menuItem.getWidth() == 0);
REQUIRE(menuItem.getHeight() == 0);
REQUIRE(menuItem.getResourceType() == ResourceType::MENU_ITEM);
}

SECTION("Set selected")
{
menuItem.setSelected(true);
REQUIRE(menuItem.getResourceType() == ResourceType::MENU_ITEM_SELECTED);
}

SECTION("Set not selected")
{
menuItem.setSelected(true);
menuItem.setSelected(false);
REQUIRE(menuItem.getResourceType() == ResourceType::MENU_ITEM);
}
}

0 comments on commit a106e26

Please sign in to comment.