summaryrefslogtreecommitdiff
path: root/lib/tests
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tests')
-rw-r--r--lib/tests/turns-participant.cpp47
-rw-r--r--lib/tests/turnsmm/participant.cpp47
2 files changed, 94 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
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