1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
#include "turns/domain/turn_order.hpp"
#include "turns/domain/participant.hpp"
#include <catch2/catch_test_macros.hpp>
#include <compare>
#include <glibmm/init.h>
namespace turns::domain::tests
{
TEST_CASE("A freshly constructed turn order")
{
auto instance = turn_order::create();
SECTION("can be created")
{
REQUIRE(instance);
}
SECTION("has 0 items")
{
REQUIRE(instance->size() == 0);
}
SECTION("accepts a new participant")
{
instance->add("River along the Field", 14, disposition::friendly);
REQUIRE(instance->size() == 1);
}
SECTION("does nothing when trying to remove an item if no items were added beforehand")
{
instance->remove(5);
REQUIRE(instance->size() == 0);
}
SECTION("automatically sorts elements added in descending order of priority")
{
SECTION("when adding the higher one last")
{
instance->add("Tree Blossom", 6, disposition::friendly);
instance->add("Fish in the River", 12, disposition::friendly);
REQUIRE(instance->get(0)->get_name() == "Fish in the River");
}
SECTION("when adding the higher one first")
{
instance->add("Fish in the River", 12, disposition::friendly);
instance->add("Tree Blossom", 6, disposition::friendly);
REQUIRE(instance->get(0)->get_name() == "Fish in the River");
}
SECTION("keeping the insertion order when adding items with equal priority")
{
instance->add("Fish in the River", 6, disposition::friendly);
instance->add("Tree Blossom", 6, disposition::friendly);
REQUIRE(instance->get(0)->get_name() == "Fish in the River");
}
}
SECTION("does not accept the same item twice by components")
{
instance->add("Frozen Apple Tree", 2.1, disposition::friendly);
instance->add("Frozen Apple Tree", 2.1, disposition::friendly);
REQUIRE(instance->size() == 1);
}
}
} // namespace turns::domain::tests
|