blob: 089e6eb37417e44fe3ccdccb25d27a76a4b2ff06 (
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
|
#include "turnsmm/turn-order.hpp"
#include "turnsmm/participant.hpp"
#include <catch2/catch_test_macros.hpp>
#include <turnsmm/enums.hpp>
#include <cstddef>
SCENARIO("Creating a turn order", "[lib][object][lifetime]")
{
GIVEN("A turn order constructed using the default constructor")
{
auto instance = Turns::TurnOrder{};
THEN("its participant count is 0")
{
REQUIRE(instance.get_participant_count() == 0uz);
REQUIRE(instance.get_property<std::size_t>("participant-count") == 0);
}
THEN("its running state is false")
{
REQUIRE_FALSE(instance.get_running());
REQUIRE_FALSE(instance.get_property<std::size_t>("running"));
}
THEN("its item count is 0")
{
REQUIRE(instance.get_n_items() == 0);
}
THEN("its item type is Turns.Participant")
{
REQUIRE(instance.get_item_type() == Turns::Participant::get_type());
}
THEN("its first item is NULL")
{
REQUIRE(instance.get_object(0) == nullptr);
REQUIRE(instance.get_typed_object<Turns::Participant>(0) == nullptr);
}
}
}
SCENARIO("Modifying a turn order", "[lib][object][data]")
{
GIVEN("An empty turn order")
{
auto instance = Turns::TurnOrder{};
CHECK(instance.get_participant_count() == 0);
WHEN("a participant is added")
{
auto participant = Turns::Participant::create("Test Participant", 10.0f, Turns::Disposition::Friendly);
instance.add(participant);
THEN("its participant count is 1")
{
REQUIRE(instance.get_participant_count() == 1);
}
THEN("its running state is false")
{
REQUIRE_FALSE(instance.get_running());
}
THEN("its item count is 1")
{
REQUIRE(instance.get_n_items() == 1);
}
THEN("its first item is the same participant")
{
auto obj = instance.get_object(0);
auto cnt = obj->gobj()->ref_count;
REQUIRE(cnt > 0);
REQUIRE(obj == participant);
}
}
}
}
|