blob: 4f32aa0a4104228fe7b44911d3d163b576c91f8b (
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
|
#include "turns/domain/participant.hpp"
#include <catch2/catch_test_macros.hpp>
#include <glibmm/init.h>
#include <compare>
namespace turns::domain::tests
{
TEST_CASE("A participant")
{
auto constexpr constructed_name = "Vana Thistletop";
auto constexpr constructed_order = 17;
auto instance = participant{constructed_name, constructed_order};
SECTION("can be created")
{
REQUIRE(participant::create(constructed_name, constructed_order));
}
SECTION("the name can be read")
{
REQUIRE(instance.property_name() == constructed_name);
}
SECTION("the name can be changed")
{
instance.property_name() = "replaced";
REQUIRE(instance.property_name() == "replaced");
}
SECTION("the order can be read")
{
REQUIRE(instance.property_order_value() == constructed_order);
}
SECTION("the order can be changed")
{
instance.property_order_value() = 8;
REQUIRE(instance.property_order_value() == 8);
}
SECTION("can be compared with another participant")
{
auto equivalent_instance = participant{"Equivalent", constructed_order};
auto lesser_instance = participant{"Lesser", constructed_order - 1};
auto greater_instance = participant{"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
|