From 18795a59e98f2496ab7bb8705f96fa1a4d08ccba Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Mon, 15 Jul 2024 22:36:48 +0200 Subject: domain: extend participant tests --- domain/include/turns/domain/participant.hpp | 2 - domain/src/participant.cpp | 5 -- domain/tests/participant.cpp | 80 +++++++++++++++++++++++++---- 3 files changed, 69 insertions(+), 18 deletions(-) diff --git a/domain/include/turns/domain/participant.hpp b/domain/include/turns/domain/participant.hpp index a097abd..3f249d5 100644 --- a/domain/include/turns/domain/participant.hpp +++ b/domain/include/turns/domain/participant.hpp @@ -35,8 +35,6 @@ namespace turns::domain Glib::Property m_priority; }; - auto operator<=>(Glib::RefPtr const & lhs, Glib::RefPtr const & rhs) -> std::partial_ordering; - } // namespace turns::domain #endif \ No newline at end of file diff --git a/domain/src/participant.cpp b/domain/src/participant.cpp index 7ff9ce1..08c6deb 100644 --- a/domain/src/participant.cpp +++ b/domain/src/participant.cpp @@ -65,9 +65,4 @@ namespace turns::domain return m_priority.get_proxy(); } - auto operator<=>(Glib::RefPtr const & lhs, Glib::RefPtr const & rhs) -> std::partial_ordering - { - return *lhs <=> *rhs; - } - } // namespace turns::domain \ No newline at end of file diff --git a/domain/tests/participant.cpp b/domain/tests/participant.cpp index 268b395..6db98f7 100644 --- a/domain/tests/participant.cpp +++ b/domain/tests/participant.cpp @@ -9,7 +9,7 @@ namespace turns::domain::tests { - TEST_CASE("A participant") + TEST_CASE("A freshly constructed participant") { auto constexpr constructed_name = "Vana Thistletop"; auto constexpr constructed_priority = 17; @@ -20,26 +20,84 @@ namespace turns::domain::tests REQUIRE(participant::create(constructed_name, constructed_priority)); } - SECTION("the name can be read") + SECTION("allows access to its name via the associated accessors") { - REQUIRE(instance.get_name() == constructed_name); + 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("the name can be changed") + SECTION("allows access to its name via the associated property") { - instance.set_name("replaced"); - REQUIRE(instance.get_name() == "replaced"); + 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("the priority can be read") + SECTION("allows access to its priority via the associated accessors") { - REQUIRE(instance.get_priority() == constructed_priority); + 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("the priority can be changed") + SECTION("allows access to its priority via the associated property") { - instance.set_priority(8); - REQUIRE(instance.get_priority() == 8); + 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") -- cgit v1.2.3