#include "turns/domain/turn_order.hpp" #include "turns/domain/participant.hpp" #include #include #include namespace turns::domain::tests { TEST_CASE("A freshly constructed turn order") { auto instance = turn_order::create(); SECTION("can be created") { REQUIRE(instance); } SECTION("has 0 items") { REQUIRE(instance->size() == 0); } SECTION("accepts a new participant") { instance->add("River along the Field", 14, disposition::friendly); REQUIRE(instance->size() == 1); } SECTION("does nothing when trying to remove an item if no items were added beforehand") { instance->remove(5); REQUIRE(instance->size() == 0); } SECTION("automatically sorts elements added in descending order of priority") { SECTION("when adding the higher one last") { instance->add("Tree Blossom", 6, disposition::friendly); instance->add("Fish in the River", 12, disposition::friendly); REQUIRE(instance->get(0)->get_name() == "Fish in the River"); } SECTION("when adding the higher one first") { instance->add("Fish in the River", 12, disposition::friendly); instance->add("Tree Blossom", 6, disposition::friendly); REQUIRE(instance->get(0)->get_name() == "Fish in the River"); } SECTION("keeping the insertion order when adding items with equal priority") { instance->add("Fish in the River", 6, disposition::friendly); instance->add("Tree Blossom", 6, disposition::friendly); REQUIRE(instance->get(0)->get_name() == "Fish in the River"); } } SECTION("does not accept the same item twice by components") { instance->add("Frozen Apple Tree", 2.1, disposition::friendly); instance->add("Frozen Apple Tree", 2.1, disposition::friendly); REQUIRE(instance->size() == 1); } } } // namespace turns::domain::tests