#include "turns/domain/participant.hpp" #include #include #include namespace turns::domain::tests { TEST_CASE("A freshly constructed participant") { auto constexpr constructed_name = "Vana Thistletop"; auto constexpr constructed_priority = 17; auto instance = participant{constructed_name, constructed_priority}; SECTION("can be created") { REQUIRE(participant::create(constructed_name, constructed_priority)); } SECTION("allows access to its name via the associated accessors") { SECTION("allowing to get it") { REQUIRE(instance.get_name() == constructed_name); } SECTION("allowing to get it via a constant object") { auto const & cref = instance; REQUIRE(cref.get_name() == constructed_name); } SECTION("allowing to set it") { instance.set_name("replaced"); REQUIRE(instance.get_name() == "replaced"); } } SECTION("allows access to its name via the associated property") { SECTION("allowing to get it") { REQUIRE(instance.property_name() == constructed_name); } SECTION("allowing to get it via a constant object") { auto const & cref = instance; REQUIRE(cref.property_name() == constructed_name); } SECTION("allowing to set it") { instance.property_name() = "replaced"; REQUIRE(instance.get_name() == "replaced"); } } SECTION("allows access to its priority via the associated accessors") { SECTION("allowing to get it") { REQUIRE(instance.get_priority() == constructed_priority); } SECTION("allowing to get it via a constant object") { auto const & cref = instance; REQUIRE(cref.get_priority() == constructed_priority); } SECTION("allowing to set it") { instance.set_priority(3); REQUIRE(instance.get_priority() == 3); } } SECTION("allows access to its priority via the associated property") { SECTION("allowing to get it") { REQUIRE(instance.property_priority() == constructed_priority); } SECTION("allowing to get it via a constant object") { auto const & cref = instance; REQUIRE(cref.property_priority() == constructed_priority); } SECTION("allowing to set it") { instance.property_priority() = 4; REQUIRE(instance.get_priority() == 4); } } SECTION("can be compared with another participant") { auto equivalent_instance = participant{"Equivalent", constructed_priority}; auto lesser_instance = participant{"Lesser", constructed_priority - 1}; auto greater_instance = participant{"Greater", constructed_priority + 1}; SECTION("yielding std::partial_ordering::equivalent for itself") { REQUIRE((instance <=> equivalent_instance) == std::partial_ordering::equivalent); } SECTION("yielding std::partial_ordering::equivalent for an equivalent participant") { REQUIRE((instance <=> equivalent_instance) == std::partial_ordering::equivalent); } SECTION("yielding std::partial_ordering::greater for a lesser participant") { REQUIRE((instance <=> lesser_instance) == std::partial_ordering::greater); } SECTION("yielding std::partial_ordering::less for a greater participant") { REQUIRE((instance <=> greater_instance) == std::partial_ordering::less); } } } } // namespace turns::domain::tests