blob: dd244f473f97eb228768363508f723b3cac21846 (
plain)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
#include "turns/domain/participant.hpp"
#include "turns/domain/disposition.hpp"
#include <catch2/catch_test_macros.hpp>
#include <compare>
#include <glibmm/init.h>
namespace turns::domain::tests
{
TEST_CASE("A freshly constructed participant")
{
auto constexpr constructed_name = "Vana Thistletop";
auto constexpr constructed_priority = 17;
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, 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")
{
SECTION("allowing to get it")
{
REQUIRE(instance.get_name() == constructed_name);
}
SECTION("allowing to get it via a constant object")
{
auto const & cref = instance;
REQUIRE(cref.get_name() == constructed_name);
}
SECTION("allowing to set it")
{
instance.set_name("replaced");
REQUIRE(instance.get_name() == "replaced");
}
}
SECTION("allows access to its name via the associated property")
{
SECTION("allowing to get it")
{
REQUIRE(instance.property_name() == constructed_name);
}
SECTION("allowing to get it via a constant object")
{
auto const & cref = instance;
REQUIRE(cref.property_name() == constructed_name);
}
SECTION("allowing to set it")
{
instance.property_name() = "replaced";
REQUIRE(instance.get_name() == "replaced");
}
}
SECTION("allows access to its priority via the associated accessors")
{
SECTION("allowing to get it")
{
REQUIRE(instance.get_priority() == constructed_priority);
}
SECTION("allowing to get it via a constant object")
{
auto const & cref = instance;
REQUIRE(cref.get_priority() == constructed_priority);
}
SECTION("allowing to set it")
{
instance.set_priority(3);
REQUIRE(instance.get_priority() == 3);
}
}
SECTION("allows access to its priority via the associated property")
{
SECTION("allowing to get it")
{
REQUIRE(instance.property_priority() == constructed_priority);
}
SECTION("allowing to get it via a constant object")
{
auto const & cref = instance;
REQUIRE(cref.property_priority() == constructed_priority);
}
SECTION("allowing to set it")
{
instance.property_priority() = 4;
REQUIRE(instance.get_priority() == 4);
}
}
SECTION("can be compared with another participant")
{
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")
{
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
|