diff options
| author | Felix Morgner <felix.morgner@gmail.com> | 2025-07-25 22:59:30 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@gmail.com> | 2025-07-25 22:59:30 +0200 |
| commit | d734f1e7803a756822524e0580ec8e9c93b821c6 (patch) | |
| tree | 28daa14da0ec330adaa87f1316167cf18274cfe4 /lib/tests/turns-participant.cpp | |
| parent | fb2fbeca028d7a854df1c4b23bd0395d11e1f724 (diff) | |
| download | turns-main.tar.xz turns-main.zip | |
lib: make Turns.Participant comparablemain
Diffstat (limited to 'lib/tests/turns-participant.cpp')
| -rw-r--r-- | lib/tests/turns-participant.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/lib/tests/turns-participant.cpp b/lib/tests/turns-participant.cpp index e9cc62e..fc76c4b 100644 --- a/lib/tests/turns-participant.cpp +++ b/lib/tests/turns-participant.cpp @@ -550,4 +550,51 @@ SCENARIO("Reading a participant", "[lib][object][data]") } } } +} + +SCENARIO("Comparing two participants", "[lib][object][logic]") +{ + auto name_lhs = "LHS"; + auto name_rhs = "RHS"; + auto disposition = TurnsParticipantDisposition::TURNS_PARTICIPANT_DISPOSITION_NEUTRAL; + + GIVEN("A participant with priority 0") + { + g_autoptr(TurnsParticipant) lhs = turns_participant_new_with(name_lhs, 0.0f, disposition); + + THEN("the it compares equal to itself") + { + REQUIRE(turns_participant_compare(lhs, lhs) == 0); + } + + AND_GIVEN("A participant with priority 10") + { + g_autoptr(TurnsParticipant) rhs = turns_participant_new_with(name_rhs, 10.0f, disposition); + + THEN("the first compares less than the second") + { + REQUIRE(turns_participant_compare(lhs, rhs) < 0); + } + + THEN("the second compares greater than the first") + { + REQUIRE(turns_participant_compare(rhs, lhs) > 0); + } + } + + AND_GIVEN("A participant with priority -10") + { + g_autoptr(TurnsParticipant) rhs = turns_participant_new_with(name_rhs, -10.0f, disposition); + + THEN("the first compares greater than the second") + { + REQUIRE(turns_participant_compare(lhs, rhs) > 0); + } + + THEN("the second compares less than the first") + { + REQUIRE(turns_participant_compare(rhs, lhs) < 0); + } + } + } }
\ No newline at end of file |
