diff --git a/test/shared/CMakeLists.txt b/test/shared/CMakeLists.txt index f7bd6622..f809aea8 100644 --- a/test/shared/CMakeLists.txt +++ b/test/shared/CMakeLists.txt @@ -3,3 +3,10 @@ add_custom_test(map) add_custom_test(rules) add_custom_test(serialize) +add_custom_test(city) +add_custom_test(hexagon) +add_custom_test(controlpawn) +add_custom_test(barbarian) +add_custom_test(barbarianvillage) +add_custom_test(card) +add_custom_test(resource) diff --git a/test/shared/test_barbarian.cpp b/test/shared/test_barbarian.cpp new file mode 100644 index 00000000..a5d41de9 --- /dev/null +++ b/test/shared/test_barbarian.cpp @@ -0,0 +1,27 @@ +#include +#include + +BOOST_AUTO_TEST_SUITE( BarbarianTest ) + +BOOST_AUTO_TEST_CASE(TestStaticAssert) +{ + BOOST_CHECK(1); +} + +BOOST_AUTO_TEST_CASE( constructorAndGetters ) +{ + shared::Barbarian barbarian; + + shared::ElementEnum type = barbarian.getType(); + BOOST_CHECK(type == shared::ElementEnum::barbarian); + BOOST_CHECK(barbarian.isAlive == true); +} + +BOOST_AUTO_TEST_CASE( kill ) +{ + shared::Barbarian barbarian; + barbarian.kill(); + BOOST_CHECK(barbarian.isAlive == false); +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/test/shared/test_barbarianvillage.cpp b/test/shared/test_barbarianvillage.cpp new file mode 100644 index 00000000..fae14b6f --- /dev/null +++ b/test/shared/test_barbarianvillage.cpp @@ -0,0 +1,19 @@ +#include +#include + +BOOST_AUTO_TEST_SUITE( BarbarianVillageTest ) + +BOOST_AUTO_TEST_CASE(TestStaticAssert) +{ + BOOST_CHECK(1); +} + +BOOST_AUTO_TEST_CASE( constructorAndGetters ) +{ + shared::BarbarianVillage village; + + shared::ElementEnum type = village.getType(); + BOOST_CHECK(type == shared::ElementEnum::barbarianVillage); +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/test/shared/test_card.cpp b/test/shared/test_card.cpp new file mode 100644 index 00000000..7519eab9 --- /dev/null +++ b/test/shared/test_card.cpp @@ -0,0 +1,34 @@ +#include +#include + +BOOST_AUTO_TEST_SUITE( CardTest ) + +BOOST_AUTO_TEST_CASE(TestStaticAssert) +{ + BOOST_CHECK(1); +} + +BOOST_AUTO_TEST_CASE( constructorAndGetters ) +{ + shared::Card card(shared::CardsEnum::science); + + shared::CardsEnum type = card.getType(); + BOOST_CHECK(type == shared::CardsEnum::science); + BOOST_CHECK(card.getLevel() == 1); +} + +BOOST_AUTO_TEST_CASE( boxAndDifficulty ) +{ + shared::Card card(shared::CardsEnum::science); + + BOOST_CHECK(card.getNumberOfBox() == 0); + card.addBox(2); + BOOST_CHECK(card.getNumberOfBox() == 2); + card.removeBox(1); + BOOST_CHECK(card.getNumberOfBox() == 1); + + card.setDificulty(3); + BOOST_CHECK(card.getDificulty() == 3); +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/test/shared/test_city.cpp b/test/shared/test_city.cpp new file mode 100644 index 00000000..941957e3 --- /dev/null +++ b/test/shared/test_city.cpp @@ -0,0 +1,36 @@ +#include +#include + +BOOST_AUTO_TEST_SUITE( CityTest ) + +BOOST_AUTO_TEST_CASE(TestStaticAssert) +{ + BOOST_CHECK(1); +} + +BOOST_AUTO_TEST_CASE( constructorAndGetters ) +{ + shared::City city({20, 15}); + + BOOST_CHECK(city.getPosition()[0] == 20); + BOOST_CHECK(city.getPosition()[1] == 15); + + shared::ElementEnum type = city.getType(); + BOOST_CHECK(type == shared::ElementEnum::city); + + BOOST_CHECK(city.isMature == false); + BOOST_CHECK(city.isCapital == false); + BOOST_CHECK(city.isStateCity == false); +} + +BOOST_AUTO_TEST_CASE( setStateCity ) +{ + shared::City city({0, 0}); + city.setStateCity(shared::CityStateEnum::mohenjoDaro); + + BOOST_CHECK(city.stateCityType == shared::CityStateEnum::mohenjoDaro); + BOOST_CHECK(city.isStateCity == true); + +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/test/shared/test_controlpawn.cpp b/test/shared/test_controlpawn.cpp new file mode 100644 index 00000000..c2525725 --- /dev/null +++ b/test/shared/test_controlpawn.cpp @@ -0,0 +1,30 @@ +#include +#include + +BOOST_AUTO_TEST_SUITE( ControlPawnTest ) + +BOOST_AUTO_TEST_CASE(TestStaticAssert) +{ + BOOST_CHECK(1); +} + +BOOST_AUTO_TEST_CASE( constructorAndGetters ) +{ + shared::ControlPawn pawn({20, 15}); + + BOOST_CHECK(pawn.getPosition()[0] == 20); + BOOST_CHECK(pawn.getPosition()[1] == 15); + BOOST_CHECK(pawn.isReinforced() == false); + + shared::ElementEnum type = pawn.getType(); + BOOST_CHECK(type == shared::ElementEnum::controlPawn); +} + +BOOST_AUTO_TEST_CASE( setReinforced ) +{ + shared::ControlPawn pawn({0, 0}); + pawn.setReinforced(); + BOOST_CHECK(pawn.isReinforced() == true); +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/test/shared/test_hexagon.cpp b/test/shared/test_hexagon.cpp new file mode 100644 index 00000000..7e993ecd --- /dev/null +++ b/test/shared/test_hexagon.cpp @@ -0,0 +1,54 @@ +#include +#include + +BOOST_AUTO_TEST_SUITE( HexagonTest ) + +BOOST_AUTO_TEST_CASE(TestStaticAssert) +{ + BOOST_CHECK(1); +} + +BOOST_AUTO_TEST_CASE( constructorAndGetters ) +{ + shared::Hexagon hexagon; + + BOOST_CHECK(hexagon.getFieldLevel() == shared::FieldLevel::Grassland); +} + +BOOST_AUTO_TEST_CASE( setFieldType ) +{ + shared::Hexagon hexagon; + + hexagon.setFieldType(shared::FieldLevel::WonderMessa); + + BOOST_CHECK(hexagon.getFieldLevel() == shared::FieldLevel::WonderMessa); +} + +BOOST_AUTO_TEST_CASE( manageElements ) +{ + shared::Hexagon hexagon; + + BOOST_CHECK(hexagon.getElements().size() == 0); + + std::shared_ptr caravan1 = std::make_shared(); + std::variant element1 = *caravan1; + hexagon.addElement(std::make_shared>(element1)); + + BOOST_CHECK(hexagon.getElements().size() == 1); + + std::shared_ptr caravan2 = std::make_shared(); + std::variant element2 = *caravan2; + hexagon.addElement(std::make_shared>(element2)); + + BOOST_CHECK(hexagon.getElements().size() == 2); + + hexagon.removeElement(hexagon.getElements()[0]); + + BOOST_CHECK(hexagon.getElements().size() == 1); + + hexagon.clearElement(); + + BOOST_CHECK(hexagon.getElements().size() == 0); +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/test/shared/test_map.cpp b/test/shared/test_map.cpp index e516aa9f..dcf76f3d 100644 --- a/test/shared/test_map.cpp +++ b/test/shared/test_map.cpp @@ -1,6 +1,4 @@ #include -#include -#include #include BOOST_AUTO_TEST_SUITE( MapTest ) diff --git a/test/shared/test_resource.cpp b/test/shared/test_resource.cpp new file mode 100644 index 00000000..5ec0f730 --- /dev/null +++ b/test/shared/test_resource.cpp @@ -0,0 +1,23 @@ +#include +#include + +BOOST_AUTO_TEST_SUITE( MapTest ) + +BOOST_AUTO_TEST_CASE(TestStaticAssert) +{ + BOOST_CHECK(1); +} + +BOOST_AUTO_TEST_CASE( all ) +{ + shared::Resource resource(shared::ResourceEnum::stone); + + BOOST_CHECK(resource.getType() == shared::ResourceEnum::stone); + resource.isAlive = true; + resource.picked(); + BOOST_CHECK(resource.isAlive == false); + + +} + +BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file diff --git a/test/shared/test_serialize.cpp b/test/shared/test_serialize.cpp index 6ed2ee3b..1f7fecc7 100644 --- a/test/shared/test_serialize.cpp +++ b/test/shared/test_serialize.cpp @@ -1,5 +1,4 @@ #include -#include #include BOOST_AUTO_TEST_SUITE(SerializeTest)