summaryrefslogtreecommitdiff
path: root/domain/tests
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@gmail.com>2024-07-16 10:02:47 +0200
committerFelix Morgner <felix.morgner@gmail.com>2024-07-16 10:02:47 +0200
commit5bb826fa63b2b2d6f7b8bca354fa4a1606781dc3 (patch)
treefdff35f04a92965e7044ef84133d93280fac11b7 /domain/tests
parent4e3b7165738d6d3648af70553da7fa2096606eb3 (diff)
downloadturns-5bb826fa63b2b2d6f7b8bca354fa4a1606781dc3.tar.xz
turns-5bb826fa63b2b2d6f7b8bca354fa4a1606781dc3.zip
turns: implement basic disposition integration
Diffstat (limited to 'domain/tests')
-rw-r--r--domain/tests/participant.cpp52
-rw-r--r--domain/tests/turn_order.cpp46
2 files changed, 70 insertions, 28 deletions
diff --git a/domain/tests/participant.cpp b/domain/tests/participant.cpp
index 6db98f7..dd244f4 100644
--- a/domain/tests/participant.cpp
+++ b/domain/tests/participant.cpp
@@ -1,4 +1,5 @@
#include "turns/domain/participant.hpp"
+#include "turns/domain/disposition.hpp"
#include <catch2/catch_test_macros.hpp>
@@ -13,11 +14,52 @@ namespace turns::domain::tests
{
auto constexpr constructed_name = "Vana Thistletop";
auto constexpr constructed_priority = 17;
- auto instance = participant{constructed_name, constructed_priority};
+ auto constexpr constructed_disposition = disposition::friendly;
+ auto instance = participant{constructed_name, constructed_priority, constructed_disposition};
SECTION("can be created")
{
- REQUIRE(participant::create(constructed_name, constructed_priority));
+ REQUIRE(participant::create(constructed_name, constructed_priority, constructed_disposition));
+ }
+
+ SECTION("allows access to its disposition via the associated accessors")
+ {
+ SECTION("allowing to get it")
+ {
+ REQUIRE(instance.get_disposition() == constructed_disposition);
+ }
+
+ SECTION("allowing to get it via a constant object")
+ {
+ auto const & cref = instance;
+ REQUIRE(cref.get_disposition() == constructed_disposition);
+ }
+
+ SECTION("allowing to set it")
+ {
+ instance.set_disposition(disposition::hostile);
+ REQUIRE(instance.get_disposition() == disposition::hostile);
+ }
+ }
+
+ SECTION("allows access to its disposition via the associated property")
+ {
+ SECTION("allowing to get it")
+ {
+ REQUIRE(instance.property_disposition() == constructed_disposition);
+ }
+
+ SECTION("allowing to get it via a constant object")
+ {
+ auto const & cref = instance;
+ REQUIRE(cref.property_disposition() == constructed_disposition);
+ }
+
+ SECTION("allowing to set it")
+ {
+ instance.property_disposition() = disposition::hostile;
+ REQUIRE(instance.get_disposition() == disposition::hostile);
+ }
}
SECTION("allows access to its name via the associated accessors")
@@ -102,9 +144,9 @@ namespace turns::domain::tests
SECTION("can be compared with another participant")
{
- auto equivalent_instance = participant{"Equivalent", constructed_priority};
- auto lesser_instance = participant{"Lesser", constructed_priority - 1};
- auto greater_instance = participant{"Greater", constructed_priority + 1};
+ auto equivalent_instance = participant{"Equivalent", constructed_priority, constructed_disposition};
+ auto lesser_instance = participant{"Lesser", constructed_priority - 1, constructed_disposition};
+ auto greater_instance = participant{"Greater", constructed_priority + 1, constructed_disposition};
SECTION("yielding std::partial_ordering::equivalent for itself")
{
diff --git a/domain/tests/turn_order.cpp b/domain/tests/turn_order.cpp
index 7172ffc..f1f2653 100644
--- a/domain/tests/turn_order.cpp
+++ b/domain/tests/turn_order.cpp
@@ -27,19 +27,19 @@ namespace turns::domain::tests
SECTION("accepts a new participant in form of a refptr")
{
- instance.append(participant::create("Honey Bunches of Oats", 12));
+ instance.append(participant::create("Honey Bunches of Oats", 12, disposition::friendly));
REQUIRE(instance.get_n_items() == 1);
}
SECTION("accepts a new participant in form of components")
{
- instance.append("River along the Field", 14);
+ instance.append("River along the Field", 14, disposition::friendly);
REQUIRE(instance.get_n_items() == 1);
}
SECTION("does nothing when trying to remove an item by refptr if no items were added beforehand")
{
- instance.remove(participant::create("Patch in the Forest", 3));
+ instance.remove(participant::create("Patch in the Forest", 3, disposition::friendly));
REQUIRE(instance.get_n_items() == 0);
}
@@ -51,7 +51,7 @@ namespace turns::domain::tests
SECTION("allows the removal of an item by refptr if the same item was added beforehand")
{
- auto item = participant::create("Blank Canvas", 23);
+ auto item = participant::create("Blank Canvas", 23, disposition::friendly);
instance.append(item);
instance.remove(item);
REQUIRE(instance.get_n_items() == 0);
@@ -59,9 +59,9 @@ namespace turns::domain::tests
SECTION("does nothing when trying to remove an item by refptr that was not added beforehand")
{
- auto item = participant::create("Blank Canvas", 23);
+ auto item = participant::create("Blank Canvas", 23, disposition::friendly);
instance.append(item);
- instance.remove(participant::create("Spell of Rain", 6));
+ instance.remove(participant::create("Spell of Rain", 6, disposition::friendly));
REQUIRE(instance.get_n_items() == 1);
}
@@ -69,22 +69,22 @@ namespace turns::domain::tests
{
SECTION("when appending the higher one last")
{
- instance.append(participant::create("Snow on the Field", 2));
- instance.append(participant::create("Bees behind the Cottage", 8));
+ instance.append(participant::create("Snow on the Field", 2, disposition::friendly));
+ instance.append(participant::create("Bees behind the Cottage", 8, disposition::friendly));
REQUIRE(instance.get_item(0)->get_name() == "Bees behind the Cottage");
}
SECTION("when appending the higher one first")
{
- instance.append(participant::create("Bees behind the Cottage", 8));
- instance.append(participant::create("Snow on the Field", 2));
+ instance.append(participant::create("Bees behind the Cottage", 8, disposition::friendly));
+ instance.append(participant::create("Snow on the Field", 2, disposition::friendly));
REQUIRE(instance.get_item(0)->get_name() == "Bees behind the Cottage");
}
SECTION("keeping the insertion order when appending items with equal priority")
{
- instance.append(participant::create("Snow on the Field", 8));
- instance.append(participant::create("Bees behind the Cottage", 8));
+ instance.append(participant::create("Snow on the Field", 8, disposition::friendly));
+ instance.append(participant::create("Bees behind the Cottage", 8, disposition::friendly));
REQUIRE(instance.get_item(0)->get_name() == "Snow on the Field");
}
}
@@ -93,29 +93,29 @@ namespace turns::domain::tests
{
SECTION("when appending the higher one last")
{
- instance.append("Tree Blossom", 6);
- instance.append("Fish in the River", 12);
+ instance.append("Tree Blossom", 6, disposition::friendly);
+ instance.append("Fish in the River", 12, disposition::friendly);
REQUIRE(instance.get_item(0)->get_name() == "Fish in the River");
}
SECTION("when appending the higher one first")
{
- instance.append("Fish in the River", 12);
- instance.append("Tree Blossom", 6);
+ instance.append("Fish in the River", 12, disposition::friendly);
+ instance.append("Tree Blossom", 6, disposition::friendly);
REQUIRE(instance.get_item(0)->get_name() == "Fish in the River");
}
SECTION("keeping the insertion order when appending items with equal priority")
{
- instance.append("Fish in the River", 6);
- instance.append("Tree Blossom", 6);
+ instance.append("Fish in the River", 6, disposition::friendly);
+ instance.append("Tree Blossom", 6, disposition::friendly);
REQUIRE(instance.get_item(0)->get_name() == "Fish in the River");
}
}
SECTION("does not accept the same item twice by the same refptr")
{
- auto item = participant::create("Angelic Berry", 9);
+ auto item = participant::create("Angelic Berry", 9, disposition::friendly);
instance.append(item);
instance.append(item);
REQUIRE(instance.get_n_items() == 1);
@@ -123,8 +123,8 @@ namespace turns::domain::tests
SECTION("does not accept the same item twice by different refptrs")
{
- auto item_one = participant::create("Misty Meadow", 14.2);
- auto item_two = participant::create("Misty Meadow", 14.2);
+ auto item_one = participant::create("Misty Meadow", 14.2, disposition::friendly);
+ auto item_two = participant::create("Misty Meadow", 14.2, disposition::friendly);
instance.append(item_one);
instance.append(item_two);
REQUIRE(instance.get_n_items() == 1);
@@ -132,8 +132,8 @@ namespace turns::domain::tests
SECTION("does not accept the same item twice by components")
{
- instance.append("Frozen Apple Tree", 2.1);
- instance.append("Frozen Apple Tree", 2.1);
+ instance.append("Frozen Apple Tree", 2.1, disposition::friendly);
+ instance.append("Frozen Apple Tree", 2.1, disposition::friendly);
REQUIRE(instance.get_n_items() == 1);
}
}