From d734f1e7803a756822524e0580ec8e9c93b821c6 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 25 Jul 2025 22:59:30 +0200 Subject: lib: make Turns.Participant comparable --- lib/tests/turnsmm/participant.cpp | 47 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'lib/tests/turnsmm') diff --git a/lib/tests/turnsmm/participant.cpp b/lib/tests/turnsmm/participant.cpp index 47cf867..0cac20d 100644 --- a/lib/tests/turnsmm/participant.cpp +++ b/lib/tests/turnsmm/participant.cpp @@ -523,3 +523,50 @@ SCENARIO("Modifying a participant", "[lib][object][data]") } } } + +SCENARIO("Comparing two participants", "[lib][object][logic]") +{ + auto name_lhs = "LHS"; + auto name_rhs = "RHS"; + auto disposition = Turns::Participant::Disposition::Neutral; + + GIVEN("A participant with priority 0") + { + auto lhs = Turns::Participant{name_lhs, 0.0f, disposition}; + + THEN("the it compares equal to itself") + { + REQUIRE(lhs == lhs); + } + + AND_GIVEN("A participant with priority 10") + { + auto rhs = Turns::Participant{name_rhs, 10.0f, disposition}; + + THEN("the first compares less than the second") + { + REQUIRE(lhs < rhs); + } + + THEN("the second compares greater than the first") + { + REQUIRE(rhs > lhs); + } + } + + AND_GIVEN("A participant with priority -10") + { + auto rhs = Turns::Participant{name_rhs, -10.0f, disposition}; + + THEN("the first compares greater than the second") + { + REQUIRE(lhs > rhs); + } + + THEN("the second compares less than the first") + { + REQUIRE(rhs < lhs); + } + } + } +} \ No newline at end of file -- cgit v1.2.3