summaryrefslogtreecommitdiff
path: root/domain/tests/participant.cpp
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@gmail.com>2024-07-13 15:29:54 +0200
committerFelix Morgner <felix.morgner@gmail.com>2024-07-13 15:29:54 +0200
commite4130ea27cc3a13780e95bd0654675336fa564ec (patch)
tree5843966a0f479949e2bdbd947b2307be59a31042 /domain/tests/participant.cpp
parent826b7916c2dfb00116777ca42858624edf6a7f92 (diff)
downloadturns-e4130ea27cc3a13780e95bd0654675336fa564ec.tar.xz
turns-e4130ea27cc3a13780e95bd0654675336fa564ec.zip
domain/participant: add three way comparison operator
Diffstat (limited to 'domain/tests/participant.cpp')
-rw-r--r--domain/tests/participant.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/domain/tests/participant.cpp b/domain/tests/participant.cpp
index b7429aa..ee8af74 100644
--- a/domain/tests/participant.cpp
+++ b/domain/tests/participant.cpp
@@ -1,8 +1,11 @@
#include "turns/domain/participant.hpp"
#include <catch2/catch_test_macros.hpp>
+
#include <glibmm/init.h>
+#include <compare>
+
namespace turns::domain::tests
{
@@ -38,6 +41,33 @@ namespace turns::domain::tests
instance->order(8);
REQUIRE(instance->order() == 8);
}
+
+ SECTION("can be compared with another participant")
+ {
+ auto equivalent_instance = participant::create("Equivalent", constructed_order);
+ auto lesser_instance = participant::create("Lesser", constructed_order - 1);
+ auto greater_instance = participant::create("Greater", constructed_order + 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 \ No newline at end of file