#include "turns/domain/participant.hpp" #include #include #include namespace turns::domain::tests { TEST_CASE("A 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("the name can be read") { REQUIRE(instance.property_name() == constructed_name); } SECTION("the name can be changed") { instance.property_name() = "replaced"; REQUIRE(instance.property_name() == "replaced"); } SECTION("the priority can be read") { REQUIRE(instance.property_priority() == constructed_priority); } SECTION("the priority can be changed") { instance.property_priority() = 8; REQUIRE(instance.property_priority() == 8); } 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