Core/EventMap: Clarify documentation of ScheduleEvent

(cherry picked from commit 7865c1c197)
This commit is contained in:
Carbenium
2020-07-25 18:16:17 +02:00
committed by Shauren
parent a5d85deced
commit da17942af9
2 changed files with 31 additions and 12 deletions

View File

@@ -115,7 +115,7 @@ public:
/**
* @name ScheduleEvent
* @brief Schedules a new event.
* @brief Schedules a new event. An existing event is not canceled.
* @param eventId The id of the new event.
* @param time The time until the event occurs as std::chrono type.
* @param group The group which the event is associated to. Has to be between 1 and 8. 0 means it has no group.
@@ -125,7 +125,7 @@ public:
/**
* @name ScheduleEvent
* @brief Schedules a new event.
* @brief Schedules a new event. An existing event is not canceled.
* @param eventId The id of the new event.
* @param minTime The minimum time until the event occurs as std::chrono type.
* @param maxTime The maximum time until the event occurs as std::chrono type.

View File

@@ -77,21 +77,40 @@ TEST_CASE("Schedule an event", "[EventMap]")
}
}
// TODO: The semantics of this case are not well defined.
// Document them first, check consumers and adapt test
// accordingly.
TEST_CASE("Schedule existing event", "[EventMap][!mayfail]")
TEST_CASE("Schedule existing event", "[EventMap]")
{
EventMap eventMap;
eventMap.ScheduleEvent(EVENT_1, 1s);
eventMap.ScheduleEvent(EVENT_1, 1s);
SECTION("Same time")
{
eventMap.ScheduleEvent(EVENT_1, 1s);
eventMap.ScheduleEvent(EVENT_1, 1s);
eventMap.Update(1000);
uint32 id = eventMap.ExecuteEvent();
eventMap.Update(1000);
uint32 id = eventMap.ExecuteEvent();
REQUIRE(id == EVENT_1);
REQUIRE(id == EVENT_1);
REQUIRE(eventMap.Empty());
id = eventMap.ExecuteEvent();
REQUIRE(id == EVENT_1);
REQUIRE(eventMap.Empty());
}
SECTION("Different time")
{
eventMap.ScheduleEvent(EVENT_1, 1s);
eventMap.ScheduleEvent(EVENT_1, 2s);
eventMap.Update(1000);
uint32 id = eventMap.ExecuteEvent();
REQUIRE(id == EVENT_1);
eventMap.Update(1000);
id = eventMap.ExecuteEvent();
REQUIRE(id == EVENT_1);
REQUIRE(eventMap.Empty());
}
}
TEST_CASE("Cancel a scheduled event", "[EventMap]")